@flowplayer/player 3.0.8 → 3.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/embed.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=t()}(this,(function(){"use strict";const e=[],t=[];function r(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",r=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),n=/Android/.test(t)&&!/Firefox/.test(t),i=/^((?!chrome|android).)*safari/i.test(t),a=/SamsungBrowser/.test(t),s=a&&/SMART-TV/.test(t);return{controls:!r,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:n,iphone:r,safari:i,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:a,samsung_tv:a&&s,touch:!!("ontouchstart"in window)}}const n="error",i="click",a="dblclick",s="load",o="mouseenter",l="mouseleave",u="touchend",c="fullscreenenter",d="fullscreenexit",f="loadedmetadata",h="loadeddata",p="progress",v="loadstart",g="pause",m="playing",y="waiting",E="canplay",_="ended",T="seeked",b="seeking",A="reap",S="config",w="landscape",L="portrait";var k=Object.freeze({__proto__:null,MOUNT:"mount",ERROR:n,CONTEXT_MENU:"contextmenu",CLICK:i,DBL_CLICK:a,KEYUP:"keyup",KEYDOWN:"keydown",LOAD:s,MOUSE_ENTER:o,MOUSE_LEAVE:l,MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:u,TOUCH_CANCEL:"touchcancel",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_ENTER:c,FULLSCREEN_EXIT:d,FULLSCREEN_CHANGE:"fullscreenchange",WEBKIT_NEEDKEY:"webkitneedkey",METADATA:f,DATA:h,PROGRESS:p,TIME_UPDATE:"timeupdate",LOAD_START:v,VOLUME_CHANGE:"volumechange",PAUSE:g,PLAYING:m,PLAY:"play",WAITING:y,CAN_PLAY:E,ENDED:_,SEEKED:T,SEEKING:b,DURATION_CHANGE:"durationchange",BEFORE_PLAY:"beforeplay",BEFORE_PAUSE:"beforepause",STATE:"state",CUEPOINTS:"cuepoints",CUEPOINT_START:"cuepointstart",CUEPOINT_END:"cuepointend",VIEW_ENTER:"viewenter",VIEW_LEAVE:"viewleave",SOURCE:"src",RECOVER:"recover",REAP:A,CONFIG:S,QUALITIES:"qualities",SET_QUALITY:"quality:set",NON_RECOVERABLE_ERROR:"error:fatal",RECOMMENDATIONS_READY:"recommendationsready",AUDIO_ONLY_SOURCE:"audioonlysource",LANDSCAPE:w,PORTRAIT:L,RENDER_PLUGIN:"renderplugin",DVR:"dvr",LIVE:"live",SEEK_QUEUED:"seek:queued",SEEK_CANCEL:"seek:cancel",PLUGIN_REGISTERED:"plugin:registered",REMOTE_SESSION_STARTED:"remotesession:started",REMOTE_SESSION_ENDED:"remotesession:ended",INTERSECTIONCHANGE:"intersectionchange"});const R="flowplayer-ui",D="flowplayer-control",O="flowplayer-live-status",C="flowplayer-elapsed-time",I="flowplayer-timeline-bar",x="flowplayer-volume-bar",P="flowplayer-header",M="flowplayer-primary",F="flowplayer-middle",N="flowplayer-middle-zone",U="flowplayer-wait",B="flowplayer-play-icon",j="flowplayer-pause-icon",G="flowplayer-rewind-icon",H="flowplayer-volume-icon",K="flowplayer-live-countdown";var V=Object.freeze({__proto__:null,SUBTITLES_MENU:"flowplayer-subtitles-menu",SHARE_MENU:"flowplayer-share-menu",SPEED_MENU:"flowplayer-speed-menu",QUALITY_MENU:"flowplayer-quality-menu",AUDIO_MENU:"flowplayer-audio-menu",UI:R,CONTROL:D,CONTROL_BUTTONS:"flowplayer-control-buttons",LIVE_STATUS:O,ELAPSED:C,TIMELINE:I,CONTROL_DURATION:"flowplayer-control-duration",VOLUME_CONTROL:"flowplayer-volume-control",VOLUME_BAR:x,HEADER:P,HEADER_LEFT_ZONE:"flowplayer-header-left-zone",HEADER_RIGHT_ZONE:"flowplayer-header-right-zone",PRIMARY:M,HEADER_DURATION:"flowplayer-header-duration",MIDDLE:F,MIDDLE_ZONE:N,WAIT:U,MIDDLE_BUTTONS:"flowplayer-middle-buttons",MIDDLE_LEFT_ZONE:"flowplayer-middle-left-zone",MIDDLE_RIGHT_ZONE:"flowplayer-middle-right-zone",AIRPLAY_ICON:"flowplayer-airplay-icon",CHROMECAST_ICON:"flowplayer-chromecast-icon",SMALL_PLAY_ICON:"flowplayer-small-play-icon",SMALL_PAUSE_ICON:"flowplayer-small-pause-icon",PLAY_ICON:B,PAUSE_ICON:j,FULLSCREEN_ENTER_ICON:"flowplayer-fullscreen-enter-icon",FULLSCREEN_EXIT_ICON:"flowplayer-fullscreen-exit-icon",SKIP_NEXT_ICON:"flowplayer-skip-next-icon",SKIP_PREVIOUS_ICON:"flowplayer-skip-previous-icon",FAST_FORWARD_ICON:"flowplayer-fast-forward-icon",REWIND_ICON:G,SHARE_ICON:"flowplayer-share-icon",VOLUME_ICON:H,MUTE_ICON:"flowplayer-mute-icon",UNMUTE_ICON:"flowplayer-unmute-icon",CLOSE_ICON:"flowplayer-close-icon",FACEBOOK_ICON:"flowplayer-facebook-icon",TWITTER_ICON:"flowplayer-twitter-icon",LINK_ICON:"flowplayer-link-icon",EMBED_ICON:"flowplayer-embed-icon",LIVE_COUNTDOWN:K,PLAYLIST_CONTROLS:"flowplayer-playlist-controls",THUMBNAILS_CAROUSEL:"flowplayer-thumbnails-carousel"});const W="is-playing",q="is-paused",z="is-loaded",Y="is-loading",X="is-starting",Q="is-seeking",Z="is-ended",J="is-waiting",$="is-touched",ee="is-in-viewport";var te=Object.freeze({__proto__:null,PLAYING:W,FULLSCREEN:"is-fullscreen",PAUSED:q,MUTED:"is-muted",LOADED:z,LOADING:Y,STARTING:X,SEEKING:Q,GRABBING:"is-grabbing",DISABLED:"is-disabled",SMALL:"is-small",TINY:"is-tiny",RTL:"is-rtl",ENDED:Z,LIVE:"is-live",ERRORED:"is-error",WAITING:J,AUTOPLAY:"is-autoplay",NO_AUTOPLAY:"no-autoplay",SEAMLESS:"is-seamless",TOGGLING:"is-toggling",LIVE_SEEKED:"is-live-seeked",NO_DVR:"no-timeline",HAS_POSTER:"has-poster",MENU_OPENED:"has-menu-opened",TOUCHED:$,HOVERED:"is-hovered",TOUCH_DEVICE:"is-touch-device",WILL_SEEK:"will-seek",SEEKABLE:"is-seekable",IN_VIEWPORT:ee});function re(e){this.message=e}re.prototype=new Error,re.prototype.name="InvalidCharacterError";var ne="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new re("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,s="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};var ie=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(ne(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return ne(t)}};function ae(e){this.message=e}ae.prototype=new Error,ae.prototype.name="InvalidTokenError";var se=function(e,t){if("string"!=typeof e)throw new ae("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(ie(e.split(".")[r]))}catch(e){throw new ae("Invalid token specified: "+e.message)}};se.InvalidTokenError=ae;const oe=new Map,le=(e,t)=>new(((e,t)=>{const r=e.get(t);if(!r)throw new Error(`no flowplayer component with the name ${t} exists`);const n=window.customElements.get(t);if(!n)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(r);return"function"!=typeof i?n:i})(e._customElements,t))(e),ue=(e,t,r)=>{window.customElements.get(t)||window.customElements.define(t,r),e.customElements.get(t)||e.customElements.set(t,t)};var ce,de;!function(e){e[e.LOW=1]="LOW",e[e.MEDIUM=2]="MEDIUM",e[e.HIGH=4]="HIGH"}(ce||(ce={})),function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(de||(de={}));function fe(e,t,r){const n="boolean"==typeof r;if("boolean"!=typeof r&&(r=e.paused),function(e,t,r){const n=e.poll(t?"beforeplay":"beforepause",{forced:r});return n&&n.defaultPrevented}(e,r,n))return;if(!r)return e.hasState("is-live")&&e.setState("is-live-seeked",!0),e.pause();if(0==e.reaper)return;const i=e.reaper.get("__pending_play");return 0!=e.paused||i?i?(i.src!==pe(e.original_src)&&he(e),i):(function(e){return(0==e.networkState||0==e.readyState)&&e.currentSrc==pe(e.original_src)}(e)&&he(e),(e=>e.autoplay&&de.AUDIO_REQUIRED&e.autoplay)(t)?function(e){e.muted=!1,0==e.volume&&(e.volume=1);return e.play().catch(e=>{console.warn("[flowplayer/play] autoplay audio required\n%s",e.message)})}(e):(e.setState(X,!1),e.play().catch(t=>(console.warn("[flowplayer/play] attempting muted autoplay\n%s",t.message),e.muted=!0,e.volume=0,e.play())))):void 0}function he(e){e.currentSrc.match(/^blob:/)||e.load()}function pe(e){const t=document.createElement("a");return t.href=e,t.href}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=e()}(this,(function(){"use strict";const t=[],e=[];function r(){const t="undefined"!=typeof document&&"undefined"!=typeof window,e=t?navigator.userAgent:"",r=/iP(hone|od)/i.test(e)&&!/iPad/.test(e)&&!/IEMobile/i.test(e),i=/Android/.test(e)&&!/Firefox/.test(e),n=/^((?!chrome|android).)*safari/i.test(e),s=/SamsungBrowser/.test(e),a=s&&/SMART-TV/.test(e);return{controls:!r,video:function(e){return t&&document.createElement("video").canPlayType(e)},lang:t&&window.navigator.language,android:i,iphone:r,safari:n,ios:t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:s,samsung_tv:s&&a,touch:!!("ontouchstart"in window)}}const i="error",n="click",s="dblclick",a="load",o="mouseenter",l="mouseleave",u="touchend",d="fullscreenenter",c="fullscreenexit",h="loadedmetadata",f="loadeddata",p="progress",g="loadstart",m="pause",v="playing",y="waiting",E="canplay",T="ended",_="seeked",b="seeking",S="src",A="reap",L="config",w="landscape",k="portrait";var R=Object.freeze({__proto__:null,MOUNT:"mount",ERROR:i,CONTEXT_MENU:"contextmenu",CLICK:n,DBL_CLICK:s,KEYUP:"keyup",KEYDOWN:"keydown",LOAD:a,MOUSE_ENTER:o,MOUSE_LEAVE:l,MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_MOVE:"mousemove",TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:u,TOUCH_CANCEL:"touchcancel",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_ENTER:d,FULLSCREEN_EXIT:c,FULLSCREEN_CHANGE:"fullscreenchange",WEBKIT_NEEDKEY:"webkitneedkey",METADATA:h,DATA:f,PROGRESS:p,TIME_UPDATE:"timeupdate",LOAD_START:g,VOLUME_CHANGE:"volumechange",PAUSE:m,PLAYING:v,PLAY:"play",WAITING:y,CAN_PLAY:E,ENDED:T,SEEKED:_,SEEKING:b,DURATION_CHANGE:"durationchange",BEFORE_PLAY:"beforeplay",BEFORE_PAUSE:"beforepause",STATE:"state",CUEPOINTS:"cuepoints",CUEPOINT_START:"cuepointstart",CUEPOINT_END:"cuepointend",VIEW_ENTER:"viewenter",VIEW_LEAVE:"viewleave",SOURCE:S,RECOVER:"recover",REAP:A,CONFIG:L,QUALITIES:"qualities",SET_QUALITY:"quality:set",NON_RECOVERABLE_ERROR:"error:fatal",RECOMMENDATIONS_READY:"recommendationsready",AUDIO_ONLY_SOURCE:"audioonlysource",LANDSCAPE:w,PORTRAIT:k,RENDER_PLUGIN:"renderplugin",DVR:"dvr",LIVE:"live",SEEK_QUEUED:"seek:queued",SEEK_CANCEL:"seek:cancel",PLUGIN_REGISTERED:"plugin:registered",REMOTE_SESSION_STARTED:"remotesession:started",REMOTE_SESSION_ENDED:"remotesession:ended",INTERSECTIONCHANGE:"intersectionchange"});const D="flowplayer-ui",O="flowplayer-control",I="flowplayer-live-status",C="flowplayer-elapsed-time",P="flowplayer-timeline-bar",x="flowplayer-volume-bar",M="flowplayer-header",F="flowplayer-header-right-zone",N="flowplayer-primary",U="flowplayer-middle",B="flowplayer-middle-zone",G="flowplayer-wait",j="flowplayer-small-play-icon",H="flowplayer-small-pause-icon",K="flowplayer-play-icon",V="flowplayer-pause-icon",q="flowplayer-rewind-icon",W="flowplayer-volume-icon",z="flowplayer-live-countdown";var Y=Object.freeze({__proto__:null,SUBTITLES_MENU:"flowplayer-subtitles-menu",SHARE_MENU:"flowplayer-share-menu",SPEED_MENU:"flowplayer-speed-menu",QUALITY_MENU:"flowplayer-quality-menu",AUDIO_MENU:"flowplayer-audio-menu",UI:D,CONTROL:O,CONTROL_BUTTONS:"flowplayer-control-buttons",LIVE_STATUS:I,ELAPSED:C,TIMELINE:P,CONTROL_DURATION:"flowplayer-control-duration",VOLUME_CONTROL:"flowplayer-volume-control",VOLUME_BAR:x,HEADER:M,HEADER_LEFT_ZONE:"flowplayer-header-left-zone",HEADER_RIGHT_ZONE:F,PRIMARY:N,HEADER_DURATION:"flowplayer-header-duration",MIDDLE:U,MIDDLE_ZONE:B,WAIT:G,MIDDLE_BUTTONS:"flowplayer-middle-buttons",MIDDLE_LEFT_ZONE:"flowplayer-middle-left-zone",MIDDLE_RIGHT_ZONE:"flowplayer-middle-right-zone",AIRPLAY_ICON:"flowplayer-airplay-icon",CHROMECAST_ICON:"flowplayer-chromecast-icon",SMALL_PLAY_ICON:j,SMALL_PAUSE_ICON:H,PLAY_ICON:K,PAUSE_ICON:V,FULLSCREEN_ENTER_ICON:"flowplayer-fullscreen-enter-icon",FULLSCREEN_EXIT_ICON:"flowplayer-fullscreen-exit-icon",SKIP_NEXT_ICON:"flowplayer-skip-next-icon",SKIP_PREVIOUS_ICON:"flowplayer-skip-previous-icon",FAST_FORWARD_ICON:"flowplayer-fast-forward-icon",REWIND_ICON:q,SHARE_ICON:"flowplayer-share-icon",VOLUME_ICON:W,MUTE_ICON:"flowplayer-mute-icon",UNMUTE_ICON:"flowplayer-unmute-icon",CLOSE_ICON:"flowplayer-close-icon",FACEBOOK_ICON:"flowplayer-facebook-icon",TWITTER_ICON:"flowplayer-twitter-icon",LINK_ICON:"flowplayer-link-icon",EMBED_ICON:"flowplayer-embed-icon",LIVE_COUNTDOWN:z,PLAYLIST_CONTROLS:"flowplayer-playlist-controls",THUMBNAILS_CAROUSEL:"flowplayer-thumbnails-carousel"});const X="is-playing",Q="is-paused",$="is-loaded",J="is-loading",Z="is-starting",tt="is-seeking",et="is-ended",rt="is-live",it="is-waiting",nt="no-timeline",st="is-touched",at="is-in-viewport";var ot=Object.freeze({__proto__:null,PLAYING:X,FULLSCREEN:"is-fullscreen",PAUSED:Q,MUTED:"is-muted",LOADED:$,LOADING:J,STARTING:Z,SEEKING:tt,GRABBING:"is-grabbing",DISABLED:"is-disabled",SMALL:"is-small",TINY:"is-tiny",RTL:"is-rtl",ENDED:et,LIVE:rt,ERRORED:"is-error",WAITING:it,AUTOPLAY:"is-autoplay",NO_AUTOPLAY:"no-autoplay",SEAMLESS:"is-seamless",TOGGLING:"is-toggling",LIVE_SEEKED:"is-live-seeked",NO_DVR:nt,HAS_POSTER:"has-poster",MENU_OPENED:"has-menu-opened",TOUCHED:st,HOVERED:"is-hovered",TOUCH_DEVICE:"is-touch-device",WILL_SEEK:"will-seek",SEEKABLE:"is-seekable",IN_VIEWPORT:at});function lt(t){this.message=t}lt.prototype=new Error,lt.prototype.name="InvalidCharacterError";var ut="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new lt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,n=0,s=0,a="";i=e.charAt(s++);~i&&(r=n%4?64*r+i:i,n++%4)?a+=String.fromCharCode(255&r>>(-2*n&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};var dt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ut(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ut(e)}};function ct(t){this.message=t}ct.prototype=new Error,ct.prototype.name="InvalidTokenError";var ht=function(t,e){if("string"!=typeof t)throw new ct("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(dt(t.split(".")[r]))}catch(t){throw new ct("Invalid token specified: "+t.message)}};ht.InvalidTokenError=ct;const ft=new Map,pt=(t,e)=>new(((t,e)=>{const r=t.get(e);if(!r)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const n=window.customElements.get(r);return"function"!=typeof n?i:n})(t._customElements,e))(t),gt=(t,e,r)=>{window.customElements.get(e)||window.customElements.define(e,r),t.customElements.get(e)||t.customElements.set(e,e)};var mt,vt;!function(t){t[t.LOW=1]="LOW",t[t.MEDIUM=2]="MEDIUM",t[t.HIGH=4]="HIGH"}(mt||(mt={})),function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(vt||(vt={}));function yt(t,e,r){const i="boolean"==typeof r;if("boolean"!=typeof r&&(r=t.paused),function(t,e,r){const i=t.poll(e?"beforeplay":"beforepause",{forced:r});return i&&i.defaultPrevented}(t,r,i))return;if(!r)return t.hasState(rt)&&t.setState("is-live-seeked",!0),t.pause();if(0==t.reaper)return;const n=t.reaper.get("__pending_play");return 0!=t.paused||n?n?(n.src!==Tt(t.original_src)&&Et(t),n):(function(t){return(0==t.networkState||0==t.readyState)&&t.currentSrc==Tt(t.original_src)}(t)&&Et(t),(t=>t.autoplay&&vt.AUDIO_REQUIRED&t.autoplay)(e)?function(t){t.muted=!1,0==t.volume&&(t.volume=1);return t.play().catch(t=>{console.warn("[flowplayer/play] autoplay audio required\n%s",t.message)})}(t):(t.setState(Z,!1),t.play().catch(e=>(console.warn("[flowplayer/play] attempting muted autoplay\n%s",e.message),t.muted=!0,t.volume=0,t.play())))):void 0}function Et(t){t.currentSrc.match(/^blob:/)||t.load()}function Tt(t){const e=document.createElement("a");return e.href=t,e.href}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -12,362 +12,366 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function ve(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function ge(e,t,r,n){return new(r||(r=Promise))((function(i,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function o(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}l((n=n.apply(e,t||[])).next())}))}function me(e){const t=document.createElement("a");t.href=e;const r=t.pathname&&t.pathname.split(".");return r.length>1&&r[r.length-1]}function ye(e){switch(e){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return e}}const Ee=e=>{var{src:t}=e,r=ve(e,["src"]);return[Object.assign({src:t,type:t?ye("video/"+me(t)):""},r)]};function _e(e){return Ee({src:e})}function Te(e){var{src:t,type:r}=e,n=ve(e,["src","type"]);return t&&r?[Object.assign({src:t,type:r},n)]:r&&!t?[Object.assign({type:r},n)]:Ee(Object.assign({src:t},n))}var be;function Ae(e,t,r,n={safari:!1}){const i=function(e){return"string"==typeof e?_e(e):Array.isArray(e)||"object"!=typeof e?e.reduce((function(e,t){return"string"==typeof t&&(t=_e(t)),"object"!=typeof t||Array.isArray(t)||(t=Te(t)),e.concat(t)}),[]):Te(e)}(r);return e.currentSrc&&(e.innerHTML=""),[Q,W,q,Y,z].forEach(t=>e.setState(t,!1)),t.autoplay&&e.hasState(ee)||e.setState(X,!0),Array(...Array(i.length)).map((e,t)=>t).some(r=>{const a=i[r];if(be.Ok==function(e,t,r){e.emit("src",r),"string"==typeof r.src&&(e.original_src=r.src);const n=function(e,t,r){return e.plugins.filter(e=>{return(t=e)&&"wants"in t;var t}).find(e=>e.wants(r.src||"",r,t))}(e,t,r);return n?(n.onload(t,e.root,e,r),be.Ok):be.Err}(e,t,a)||be.Ok==function(e,t,r,n={safari:!1}){var i;/^audio\//.test(r.type||"")&&e.emit("audioonlysource");t.start_time&&(r.src=r.src+"#t="+t.start_time);if(""==e.canPlayType(r.type||""))return be.Err;if(r.drm&&(!r.drm["com.apple.fps.1_0"]||!n.safari))return be.Err;"string"==typeof r.src&&(e.preload=t.autoplay?"auto":null!==(i=t.preload)&&void 0!==i?i:"auto",e.src=r.src,"none"!==e.preload&&e.setState(Y,!0));return be.Ok}(e,t,a,n))return!0;r==i.length-1&&"string"==typeof a.src&&(e.src=a.src)}),function(e,t){!function(e,t){if(!e.currentSrc)return;if("none"==e.opt("preload"))return;if(t.autoplay&&t.autoplay>0)return;e.load()}(e,t)}(e,t),e}!function(e){e[e.Err=0]="Err",e[e.Ok=1]="Ok"}(be||(be={}));const Se=[A,b,"src","seek:cancel"];var we;function Le(e,t,r){return isNaN(e.duration)||isNaN(e.currentTime)?{}:(t.offset+=r,0==t.offset?ke(e,t):(t.timer&&clearTimeout(t.timer),t.timer=setTimeout((function(){0!=e.reaper&&(e.currentTime=function(e,t,r=0){return Math.max(Math.min(t,e),r)}(e.currentTime+t.offset,e.duration),t.timer=0,ke(e,t))}),1e3),function(e,t){e.setState("will-seek",!0),e.setState(we.BACKWARD,t.offset<0),e.setState(we.FORWARD,t.offset>0)}(e,t),e.emit("seek:queued",t),t))}function ke(e,t){t.timer&&clearTimeout(t.timer),t.timer=t.offset=0,function(e){e.setState(we.FORWARD,!1),e.setState(we.BACKWARD,!1),e.setState("will-seek",!1)}(e)}function Re(e,t){const r=e._customElements.get(t);return r&&e.root.querySelector(r)||void 0}function De(){if("undefined"==typeof document)return!1;const e=document.documentElement;return e&&"rtl"==e.getAttribute("dir")}function Oe(...e){const t=document.createElement("div");return 0==e.length||t.classList.add(...e),t}function Ce(e,t,r){const n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;n.length;){if(null==e)return r;const t=n.shift();if("string"!=typeof t)return r;e=e[t]}return null==e?r:e}function Ie(e){const t="number"==typeof e?e:parseInt(e,10);return(t>9?"":"0")+t}function xe(e){if(isNaN(e)||e>=Number.MAX_SAFE_INTEGER)return"";const t=e<0?"-":"";e=Math.round(Math.abs(e));const r=Math.floor(e/3600);let n=Math.floor(e/60);return e-=60*n,r>=1?(n-=60*r,t+r+":"+Ie(n)+":"+Ie(e)):t+Ie(n)+":"+Ie(e)}!function(e){e.FORWARD="forward",e.BACKWARD="backward"}(we||(we={}));const Pe=navigator.languages||[navigator.language];function Me(e,t,r){const n={};return r=t.lang||r,e[r]&&(n[r]=e[r]),function(){try{return Pe.reduce((e,t)=>~t.indexOf("-")?e.concat(t,t.split("-")[0]):e.concat(t),[])}catch(e){return[]}}().forEach((function(t){e[t]&&!n[t]&&(n[t]=e[t])})),Object.values(n)}const Fe=[1e7]+""+-1e3+-4e3+-8e3+-1e11,Ne=()=>"undefined"==typeof crypto?"":Fe.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));let Ue="";!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const Be=["touchstart","touchmove"];function je(e,t){const r=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(r,"data",{get:()=>t}),r}function Ge(e,t,r){const n=je(t,r);return e.dispatchEvent(n),e}function He(e,t,r){const n=je(t,r);return e.dispatchEvent(n),n}function Ke(e,t,r,n){Array.isArray(t)?t.forEach(t=>Ve(e,t,r,n)):Ve(e,t,r,n)}function Ve(e,t,r,n){if(i=t,!~Be.indexOf(i))return e.addEventListener(t,r,n),e;var i;const a=Object.assign(n||{},{passive:!0});return e.addEventListener(t,r,a),e}function We(e,t,r,n){return Ke(e,t,r,Object.assign(n||{},{once:!0}))}class PlayerStorage{constructor(e){this.implementation=e}removeItem(e){try{this.implementation.removeItem(e)}catch(e){}}getItem(e){try{return this.implementation.getItem(e)}catch(e){return null}}setItem(e,t){try{this.implementation.setItem(e,t)}catch(e){}}clear(){try{this.implementation.clear()}catch(e){}}get length(){try{return this.implementation.length}catch(e){return 0}}key(e){try{return this.implementation.key(e)}catch(e){return null}}}const qe={preload:"none",rtl:!1,controls:!0},ze=["loop","muted","preload"];function Ye(e,n,i){i._storage=new PlayerStorage(window.localStorage),i.toJSON=function(){return{duration:i.duration,volume:i.volume,currentTime:i.currentTime,states:i.root.className}},i.setSrc=function(t){return Ae(i,e,t,r())},i.playerState=i.playerState||{},i.setState=function(e,t){if(i.playerState[e]===!!t)return i;const r=Object.assign({},i.playerState,{[e]:t});return r[J]&&(r[W]=!1),i.playerState=r,Ge(i,"state",i.playerState),i},i.createComponents=function(...e){return Array.from({length:e.length}).map((t,r)=>le(this,e[r]))},i.hasState=function(e){return!!i.playerState[e]},i.transitionState=function(e,t,r){!i.hasState(e)&&i.hasState(t)||(r=0),r&&i.setState("is-toggling",!0),i.setState(t,!1),i.setState(e,!0),r&&setTimeout((function(){i.setState("is-toggling",!1)}),r)},i.emit=(e,t)=>(Ge(i,e,t),i),i.on=(e,t)=>(Ke(i,e,t),i),i.once=(e,t)=>(We(i,e,t),i),i.off=(e,t)=>{var r,n;return r=e,n=t,i.removeEventListener(r,n),i},i.poll=(e,t)=>He(i,e,t),i.togglePlay=function(t){return fe(i,e,t)},i.toggleMute=function(e){e=null==e?!i.muted:!!e,i.muted=e,i.muted||i.volume||(i.volume=1),Ge(i,"volumechange")},i.toggleDisable=function(e){e=null==e?!i.disabled:!!e,i.setState("is-disabled",e),i.disabled=e},i.destroy=function(){i.pause();const e=t.indexOf(i);~e&&t.splice(e,1),setTimeout((function(){i.setSrc([]),i.reaper&&i.reaper.clear(),Ge(i,A)}),0)},i.setAttrs=function(e){return ze.forEach(t=>{if(!(t in e))return;const r=e[t];r?i.setAttribute(t,r.toString()):i.removeAttribute(t)}),i},i.opt=function(t,r){return r=void 0===r?Ce(qe,t):r,Ce(e,t,r)},i.i18n=function(e,t){if(!i.reaper)return"";const r=i.reaper.get("translations");return r?function e(t,r,n,i){return(i=i||0)>=t.length?n:Ce(t[i],r,e(t,r,n,i+1))}(r,e,t||""):t||""},i.setOpts=function(t){Object.assign(e,t),"disabled"in t&&void 0!==t.disabled&&i.toggleDisable(t.disabled),"muted"in t&&void 0!==t.muted&&i.toggleMute(t.muted);const r=!!e.autoplay&&!i.hasState("no-autoplay");i.setState("is-autoplay",r),i.setState("is-rtl",i.opt("rtl",function(e){if(!e)return De();const t=e.getAttribute("dir");return t?"rtl"==t:De()}(n))),i.setState("is-live",!!e.live),i.setState("no-timeline",!(!e.live||e.dvr)),i.setState("has-poster","string"==typeof e.poster&&e.poster.length>0),i.setState("is-seekable",!!e.seekable),n.style.backgroundImage=i.hasState("has-poster")?"url('"+e.poster+"')":"",Ge(i,S,e)},i.renderPlugin=function(e){He(i,"renderplugin",e).defaultPrevented||i.root.appendChild(e)};const a={offset:0,timer:0};var s,o;o=a,(s=i).on(Se,(function(){ke(s,o)})),i.enqueueSeek=function(e){if(0!=i.opts.seekable&&!(1==i.opts.disabled&&e>0))return Le(i,a,e)},i.deviceId=function(){return function(e){if(Ue)return Ue;try{const t=e.getItem("flowplayer/uuid");if(t)return t;const r=Ne();return e.setItem("flowplayer/uuid",r),r}catch(e){return Ue=Ne()}}(i._storage)}}function Xe(e,t){const r=t.querySelector("video"),n=r||(e._video_element_callback?e._video_element_callback(e):document.createElement("video"));return n.classList.add("fp-engine"),n.playsInline=!0,r||t.append(n),n}function Qe(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const r=e.flowplayer;return"function"==typeof r?(r(t),t):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(t)||r.extensions.push(t),t)}function Ze(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}}const Je=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function $e(e,t){return!!~Je.indexOf(e)||e.indexOf(t)===e.length-t.length}$e.check_whitelist=function(e){return!!~Je.indexOf(e)};const et="production";function tt(e,t){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let n={c:"{}",exp:0};t=t||{};try{n=se(e),r.valid_jwt=!0}catch(e){}return r.raw=e,r.data=JSON.parse(n.c),r.exp=n.exp,t.require_valid_token&&tt.validate(r),r}function rt(e){try{return tt.validate(e),{success:!0,message:""}}catch(e){return{success:!1,message:e.message}}}var nt;function it(e){return{grant:e,is_granted:t=>(e&t)===t}}function at({root:e,video:t,data:r}){t&&t.destroy(),console.error(new Error(r.details||r.reason)),e.innerHTML="",e.classList.remove("flowplayer"),e.classList.add("flowplayer-fatal"),e.style.removeProperty("background-image");const n=document.createElement("h2");n.textContent="Playback Error";const i=document.createElement("p");i.textContent="Are you the site owner?";const a=document.createElement("a");a.classList.add("troubleshoot"),a.target="_blank",a.href="https://flowplayer.com/help/developers/troubleshooting#"+r.reason,a.textContent="Troubleshoot?";const s=document.createElement("img");s.src="https://flowplayer.com/user/pages/images/logo-white.png",e.append(n,i,a,s)}function st(e,t){const r=t.clientWidth;t.classList.toggle("is-small",r<600),t.classList.toggle("is-tiny",r<400)}function ot(e,t,n){let i=!0;t.classList.add("flowplayer"),st(0,t),Ke(n,[v,"resize"],(function(){st(0,t)})),Ke(n,"state",(function(){Object.entries(n.playerState).forEach((function([e,r]){t.classList.toggle(e,r)}))})),Ke(n,"timeupdate",(function(){n.setState(J,!1)})),Ke(n,_,(function(t){setTimeout((function(){if(!t.defaultPrevented){if(e.rewind&&!n.loop){const t=n.src;e.autoplay&&(e.autoplay=0,n.setState("is-autoplay",!1)),n.setState(Q,!0),We(n,T,(function(){t===n.src&&(n.setState(Q,!1),n.pause(),n.setState(X,!0))})),n.currentTime=0}We(n,"timeupdate",(function(){n.setState(Z,!1)})),n.transitionState(Z,W,e.loop||e.rewind?0:300)}}),0)})),Ke(n,[b,T],(function(e){n.setState(Q,e.type==b),n.setState(q,n.paused),n.setState(W,!n.paused)})),Ke(n,_,(function(){n.setState(W,!1),i=!0})),Ke(n,r().ios?f:h,(function(){var e,t;n.setState(z,!0),n.setState(Y,!1);const r=n;0===(null===(e=r.videoTracks)||void 0===e?void 0:e.length)&&(null===(t=r.audioTracks)||void 0===t?void 0:t.length)>0&&n.emit("audioonlysource")})),Ke(n,[y,E,v],(function(t){if(!n.hasState(Q)&&(t.type!=E||e.autoplay||n.setState(J,!1),t.type!=v||"none"!=n.opt("preload")||e.autoplay)){if(t.type==v&&e.autoplay)return We(n,m,(function(){n.setState(J,!1)}));t.type==y&&([W,q,X].forEach((function(e){n.setState(e,!1)})),n.hasState(z)||n.setState(Y,!0)),n.setState(Z,!1),n.setState(J,t.type==y)}})),Ke(n,[m,g],(function(t){setTimeout(()=>{const e=new CustomEvent("flowplayer/"+t.type,{detail:n});document.dispatchEvent(e)},0);const r=t.type==m,a=n.currentTime==n.duration,s=r&&i&&e.autoplay||n.hasState(J);if(r&&(n.started=!0,i=!1),n.setState(J,!1).setState(X,!1),a||n.hasState(Q))return;const o=r?W:q,l=r?q:W;n.transitionState(o,l,s?0:300),r&&n.setState("no-autoplay",!1)}))}tt.validate=function(e){if("string"==typeof e&&(e=tt(e)),!e||!e.raw){if($e.check_whitelist(window.location.hostname)||"dev"===et.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,r=$e.bind(null,t);if("dev"!==et.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==et.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},tt.id=function(e){if(e)return"string"==typeof e&&(e=tt(e)),e.data.id},function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN"}(nt||(nt={})),it.of=it,it.from_token=function(e){const t=tt(e,{require_valid_token:!0});return it.of(t.data.acl)},it.permissions=nt;const lt=[0].concat(Array.from({length:100}).map((e,t)=>(t+1)/100));function ut(e,r,n){if(!window.IntersectionObserver)return;const a={should_resume:!!e.autoplay,has_user_gesture:!1,locked:!1};[u,i].forEach(e=>We(n,e,()=>a.has_user_gesture=!0)),Ke(n,"play",(function(){a.locked||(a.should_resume=!0)})),Ke(n,"src",(function(){a.should_resume=!!e.autoplay})),Ke(n,g,(function(){a.locked||(a.should_resume=!1)})),Ke(n,E,(function(r){if(e.autoplay&&(!t.filter((function(e){return!e.paused})).length||e.multiplay))return n.hasState(ee)&&a.should_resume?n.togglePlay(!0):void(e.autopause||n.hasState(ee)||!a.should_resume||We(n,"viewenter",()=>{e.autoplay&&a.should_resume&&n.togglePlay(!0)}))}));const s=new IntersectionObserver(e=>{e.forEach(e=>{setTimeout(()=>{const t=e.intersectionRatio,r=n.hasState(ee);if(n.setState(ee,t>=.2),n.emit("intersectionchange",{ratio:t}),r===n.hasState(ee))return;const i=n.hasState(ee)?"viewenter":"viewleave";n.emit(i)},0)})},{threshold:lt});s.observe(r),n.on(A,()=>s.disconnect()),e.autopause&&(Ke(n,"viewenter",(function(){a.should_resume&&e.autopause&&n.togglePlay(!0)})),Ke(n,"viewleave",(function(){if(!e.autopause)return;const t=!n.paused;a.locked=!0,n.pause(),setTimeout((function(){a.should_resume=t,a.locked=!1}),0)})))}function ct(e,t){if(!window.ResizeObserver)return;const r=new ResizeObserver(e=>{const r=e[e.length-1];t.emit("resize",r)});r.observe(e),t.on(A,()=>r.disconnect())}function dt(e){if("number"==typeof e&&!isNaN(e))return Number(e);if("string"==typeof e){const t=e.split(":");return Number(t[1])/Number(t[0])}return e}function ft(e,t,r){const n=document.createElement("div");n.classList.add("fp-ratio"),t.append(n);let i=dt(e.ratio||.5625);n.style.paddingTop=100*i+"%";const a=[h,f];r.on(a,(function(){const e=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth;e&&r.setOpts({ratio:e})})),r.on(S,(function(){const t=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth,a=dt((null==e?void 0:e.ratio)||t||.5625);i!==a&&(i=a,n.style.paddingTop=100*a+"%")}))}class ExplorerPlan{constructor(){this.cleanUp=this.cleanUp.bind(this),this.render=this.render.bind(this),this.wireUp=this.wireUp.bind(this)}init(e,t,r){this.root=t,this.player=r,this.wireUp()}wireUp(){var e,t;this.cleanUp(),null===(e=this.player)||void 0===e||e.once(m,this.render),null===(t=this.player)||void 0===t||t.once(_,this.wireUp)}cleanUp(){var e,t,r,n;null===(t=null===(e=this._logo)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this._logo),null===(r=this.player)||void 0===r||r.off(m,this.render),null===(n=this.player)||void 0===n||n.off(_,this.wireUp)}render(){var e,t,r;null===(t=null===(e=this._logo)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this._logo);const n=(null===(r=this.root)||void 0===r?void 0:r.querySelector(".fp-ui"))||this.root;if(!n)return;const i=this._logo=document.createElement("a");i.href="https://explorer.flowplayer.com",i.target="_blank",Object.entries(ht).forEach(([e,t])=>{i.style.setProperty(e,t,"important")}),n.appendChild(i)}}const ht={display:"block",opacity:"1",visibility:"visible",width:"33%","padding-top":"9%",position:"absolute","z-index":"9999",bottom:"25%",left:"10%","background-size":"cover","background-image":"url(https://static.flowplayer.com/explorer/explorer.svg)"},pt="flowplayer/"+m;function vt(e){const t=t=>{t.detail!==e&&!e.opt("multiplay")&&e.pause()};e.on(A,()=>document.removeEventListener(pt,t)),document.addEventListener(pt,t)}const gt=function(){const e=Ze(),t=e.flowplayer?e.flowplayer:{extensions:[]};return Array.isArray(t.extensions)||(t.extensions=[]),t}();function mt(r,n){if("function"==typeof r)return e.push(...[...arguments].filter(e=>"function"==typeof e)),mt;"string"==typeof n&&(n={src:n}),n||(n={}),n.token||"string"!=typeof window.__FLOWPLAYER_TOKEN||(n.token=window.__FLOWPLAYER_TOKEN);const i="string"==typeof r?document.querySelector(r):r;if(!i)return console.error(new Error("Flowplayer: '"+r.toString()+"' not found"));const a=i.querySelector("video.fp-engine");if(a)return a;const s=rt(n.token);if(!s.success)return at({root:i,data:{reason:"token",details:s.message}});const o=new Map,l=Xe(n,i);l.reaper=o,l._customElements=oe,Object.defineProperty(l,"token",{value:"string"==typeof n.token?tt.id(n.token):"",writable:!1}),l.addEventListener(A,()=>{o.clear(),l.reaper=0,delete l.root}),l.root=i,n.token&&it.from_token(n.token).is_granted(it.permissions.DEVELOPER_PLAN)&&e.push(ExplorerPlan),!~t.indexOf(l)&&t.push(l),Ye(n,i,l),l.setAttrs(n),l.plugins=mt.extensions.map(e=>new e(mt,l)),ot(n,i,l),ut(n,i,l),ct(i,l),ft(n,i,l),vt(l),l.plugins.forEach(e=>{try{e.init(n,i,l)}catch(t){console.log("Error(plugin/%s)",e.constructor.name,t)}}),l.setOpts(n),l.opts=n,n.src&&l.setSrc(n.src);const u=l.readyState;return u>0&&l.currentSrc&&l.emit(f),u>2&&l.currentSrc&&l.emit(E),l.emit("mount"),l.on("error:fatal",(function(e){at({root:i,video:l,data:e.data||{}})})),l}Object.assign(mt,gt),function(n){Array.isArray(n.extensions)&&n.extensions.forEach(t=>e.push(t)),n.customElements=oe,n.defaultElements=V,n.version="3.0.8",n.commit="c23496a4f8c940803c8c2853e8f12754b7e23298",n.instances=t,n.extensions=e,n.support=r,n.events=k,n.states=te,n.jwt=se,n.autoplay=de,n.quality=ce}(mt),"object"==typeof document&&setTimeout(Ge,0,document,"flowplayer:umd",mt);var yt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function _t(e){var t={exports:{}};return e(t,t.exports),t.exports}var Tt=_t((function(e,t){var r=yt&&yt.__assign||function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};t.__esModule=!0,t.remove=t.downcase=t.pluck=t.merge=void 0,t.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.reduce((function(e,t){return r(r({},e),t)}),{})},t.pluck=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return Object.keys(e).filter((function(e){return~r.indexOf(e)})).reduce((function(r,n){var i;return t.merge(r,((i={})[n]=e[n],i))}),{})},t.downcase=function(e){return(e||"").toString().toLowerCase()},t.remove=function(e,t){var r=e.lastIndexOf(t);return~r&&e.splice(r,1),e}})),bt=_t((function(e,t){var r=yt&&yt.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=yt&&yt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=yt&&yt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};t.__esModule=!0;var a=i(Tt),s=function(){function e(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return e.of=function(){return new e},e.is_empty=function(e){return 0==e.pending.length},e.is_high_water=function(t){return t.open.length==e.MAX_OPEN_REQUESTS},e.maybe_spawn_req=function(t){if(e.is_empty(t))return t;if(e.is_high_water(t))return t;try{var r=e.lpop(t);r&&e.request(t,r)}catch(e){}},e.increment_failures=function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t},e.handle_error=function(t,r){e.rm(t,r),e.increment_failures(t)},e.request=function(t,r){var n=r[0],i=r[1],a=r[2];if(!(Date.now()<t.stats.ttl)){var s=new XMLHttpRequest;t.open.push(s),s.timeout=e.REQUEST_TIMEOUT_MS,s.ontimeout=function(){e.handle_error(t,s)},s.onerror=function(r){e.handle_error(t,s)},s.onreadystatechange=function(){s.readyState==XMLHttpRequest.DONE&&e.rm(t,s),Math.floor(s.status/100)},s.onload=function(){e.rm(t,s),t.stats.failures&&t.stats.failures--},s.open(i,n),s.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{s.send(JSON.stringify(a))}catch(e){}}},e.rpush=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return r.forEach((function(r){t.pending.length>=e.MAX_PENDING||(t.pending.push(r),e.maybe_spawn_req(t))})),t},e.lpop=function(e){return e.pending.shift()},e.rm=function(e,t){return a.remove(e.open,t),e},e.MAX_OPEN_REQUESTS=3,e.MAX_PENDING=5,e.REQUEST_TIMEOUT_MS=4e3,e.REQUEST_TTL_MS=5e3,e.MAX_FAILURE_COUNT=3,e}();t.default=s})),At=_t((function(e,t){var r=yt&&yt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var n=r(bt);t.default=n.default.of()})),St=_t((function(e,t){t.__esModule=!0,t.prepare_url=t.URL_PARAM=void 0,t.URL_PARAM=/:([a-zA-Z_]+)/g,t.prepare_url=function(e,r){return e.url.replace(t.URL_PARAM,(function(t){if((t=t.slice(1,t.length))in r)return r[t].toString();e.log.error(new Error("\n preparing url["+e.url+"] failed\n \n parameter["+t+"] not detected in params:\n \n "+JSON.stringify(r,null,2)+"\n "))}))}})),wt=_t((function(e,t){t.__esModule=!0,t.Log=void 0;var r=function(){function e(e){this.emitter=e}return e.prepare=function(e,t){var r=document.createEvent("Event");return r.initEvent(e,!1,!0),r.ns=e,r.data=t,r},e.of=function(t){return new e(t)},e.prototype.info=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.INFO,t))},e.prototype.error=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.ERROR,t))},e.prototype.warn=function(t){this.emitter.dispatchEvent(e.prepare(e.NAMESPACE.WARN,t))},e.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},e}();t.Log=r})),Lt=_t((function(e,t){var r;t.__esModule=!0,t.Verb=void 0,(r=t.Verb||(t.Verb={})).POST="POST",r.PUT="PUT",r.GET="GET"})),kt=_t((function(e,t){var r=yt&&yt.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=yt&&yt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=yt&&yt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},a=yt&&yt.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var a=arguments[t],s=0,o=a.length;s<o;s++,i++)n[i]=a[s];return n},s=yt&&yt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=s(At),l=s(bt),u=i(St),c=i(Tt),d=function(){function e(t,r){var n=this;void 0===r&&(r={});var i=this;if(this.emitter=t,this.url=r.url,this.log=wt.Log.of(this.emitter),this.verb=r.verb,this.metadata=c.merge({},r.metadata||{}),this.rq=r.rq||o.default,this.events=r.events||[],this.required_keys=r.required_keys||[],this.optional_keys=r.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),e.assert_emitter_api(this.emitter),void 0===e.verb[this.verb])throw new Error("invalid HTTP verb["+this.verb+"] passed");if("string"!=typeof this.url)throw new Error("invalid API url["+this.url+"] passed");e.TRACKERS.push(this),i.events.forEach((function(t){e.create_listener(n,t,(function(r){void 0===r&&(r={});var a=c.merge(i.metadata,{event_type:t},r.data||r),s=u.prepare_url(i,a),o=e.pluck_valid_keys(i,a),d=e.ensure_required_keys(i,o);if(d.length)return i.log.error("Tracker.validate_metadata() failed for \n Event["+t+"]\n missing keys: "+d+"\n payload:\n "+JSON.stringify(o,null,2));l.default.rpush(n.rq,[s,n.verb,o])}))}))}return e.of=function(t,r){return new e(t,r)},e.ensure_required_keys=function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))},e.pluck_valid_keys=function(e,t){return c.pluck.apply(c,a([t],e.valid_keys))},e.merge_metadata=function(t,r){return void 0===r&&(r={}),t.metadata=e.pluck_valid_keys(t,c.merge(t.metadata,r)),t},e.assert_emitter_api=function(e){if("function"!=typeof(e||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(e||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")},e.create_listener=function(e,t,r){e.listeners.push([t,r]),e.emitter.addEventListener(t,r)},e.prototype.destroy=function(){var t=this;this.listeners.forEach((function(e){var r=e[0],n=e[1];return t.emitter.removeEventListener(r,n)})),delete this.rq,delete this.emitter,c.remove(e.TRACKERS,this)},e.prototype.put=function(t){return void 0===t&&(t={}),e.merge_metadata(this,t),this},e.TRACKERS=[],e.QUEUE=o.default,e.verb=Lt.Verb,e}();t.default=d})),Rt=_t((function(e,t){var r=yt&&yt.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=yt&&yt.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=yt&&yt.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},a=yt&&yt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0,t.API=t.Tracker=void 0;var s=a(kt);t.Tracker=s.default;var o=i(St);t.API=o})),Dt="ping",Ot="display",Ct="view";const It=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],xt=["created","position"],Pt=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function Mt(e,t){return e.duration/1===e.duration&&Object.assign(t,function(e){const t=e/100;return{segment_duration:t,breakpoints:Array(...Array(100)).map((function(e,r){return Math.floor(r*t*1e3)/1e3}))}}(e.duration))}function Ft(e,t,r){if(!t.segment_duration&&!Mt(e,t))return;const n=function(e,t,r){const n=t.last_idx,i=r?99:Nt(e,t);return t.last_idx=i,i<=n?[]:t.breakpoints.slice(n,99==i?100:i).map((function(e){return t.breakpoints.indexOf(e)}))}(e,t,r);0!=n.length&&e.emit(Dt,{position:n})}function Nt(e,t){return Math.min(Math.floor(e.currentTime/t.segment_duration),99)}const Ut="vod",Bt="live",jt=[Ot,Dt,Ct];function Gt(e,t,r){switch(null==t?void 0:t.kind){case"live":return function(e,t){const r=Date.now();r-t.last_tracked_ts<6e4||(t.last_tracked_ts=r,++t.ticks,e.emit(Dt,{position:60*t.ticks}))}(e,t);case"vod":return Ft(e,t,"boolean"==typeof r&&r)}}function Ht(e){const t=e.ads;return void 0!==t&&(void 0!==t.schedule&&("function"==typeof t.hasPreroll&&(t.currentRequests?t.currentRequests:!!t.adPlaying||!(!t.hasPreroll()||0!=t.nextIndex))))}function Kt(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(e){return!1}}class Analytics{init(e,t,r){if(!it.from_token(e.token||"").is_granted(it.permissions.ANALYTICS))return;if(r.analytics)return;const n=r.analytics={ticker:void 0,last_media_id:"",ended:!1},i={locked:!1,ttl:6e3,task:()=>{Gt(r,n.ticker)}};const a={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:e.player_id,customer_user_id:e.customer_user_id},s=Rt.Tracker.of(r,{verb:Rt.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:jt,required_keys:It,optional_keys:Pt.concat(xt).slice(0),metadata:a});r.on(A,(function(){s&&s.destroy()})),r.on(S,(function(t){if(!s)return;const i=Ce(t,"data.metadata",{});if(!i.media_id)return;const a=Ce(s,"metadata.media_id");if(a&&i.media_id==a)return;const o=Ce(e,"analytics",{});s.put(i),s.put(o);const l=Ce(e,"metadata.live_start_time",e.live)?Bt:Ut;s.put({video_type:l,source:e.source||Kt()||""}),n.ticker=e.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},n.ended=!1,r.emit(Ot)}));let o=0;r.on(m,(function(){if(!s)return;if(o||function(e,t){return e.metadata.media_id&&e.metadata.media_id==t.last_media_id}(s,n))return;s.put({muted:r.muted});const e=Ht(r);if(e)return o=Promise.resolve(e).then((function(){n.last_media_id=s.metadata.media_id,r.emit(Ct),o=0})).catch((function(){o=0}));n.last_media_id=s.metadata.media_id,r.emit(Ct)})),r.on("timeupdate",(function(){var t;s&&(o||Ht(r)||n.ended||(!e.live&&r.currentTime+.25>=r.duration&&Gt(r,n.ticker,!0),(t=i).locked||(t.locked=setTimeout((function(){return t.task(),function(e){return e.locked=!1,e}(t)}),t.ttl))))})),r.on(T,(function(){s&&n.ticker&&"vod"==n.ticker.kind&&function(e,t){Mt(e,t),t.last_idx=Nt(e,t)}(r,n.ticker)})),r.on(_,(function(){s&&function(e,t){t.ended||(t.ended=!0,Gt(e,t.ticker))}(r,n)}))}}var Vt;function Wt(e){switch(e){case Vt.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case Vt.MEDIA_ERR_NETWORK:return"a network error occurred";case Vt.MEDIA_ERR_DECODE:return"unable to decode media content";case Vt.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case Vt.NO_INTERNET:return"no internet connection detected";case Vt.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}function qt(){}function zt(){return"https:"===location.protocol}function Yt(e){const t=document.createElement("a");return t.href=e,t}function Xt(e){try{return!!new URL(e)}catch(e){return!1}}Qe(Ze(),Analytics),"undefined"!=typeof window&&window.matchMedia&&[w,L].forEach((function(e){window.matchMedia("(orientation: "+e+")").addListener((function(r){t.length&&t.forEach((function(t){r.matches&&t.emit(e)}))}))})),function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(Vt||(Vt={}));const Qt=()=>!0===(navigator||{}).onLine;function Zt(e,t,r){r.on(n,(function(e){const t=e.data||r.error||new Error,n=e.code||t.code,i="Error: %s\n"+(null===(a=(new Error).stack)||void 0===a?void 0:a.split("\n").slice(2).join("\n"));var a;setTimeout((function(){if(e.defaultPrevented)return;if("AbortError"==t.name)return;r.setState("is-error",!0),8===n||t.fatal||function(e){const t=e.togglePlay,r=e.root;e.togglePlay=qt,e.once("recover",(function(){e.togglePlay=t,e.setState("is-error",!1);const n=r.querySelector(".fp-error");n&&n.remove()}))}(r);const a=function(e,t,r){switch(t){case"http:0":return function(e){return function(e){try{return zt()&&"http:"==Yt(e).protocol}catch(e){return!1}}(e.original_src)?{code:Vt.MIXED_CONTENT}:Qt()?{code:Vt.MEDIA_ERR_NETWORK}:Qt()?{code:Vt.UNKNOWN}:{code:Vt.NO_INTERNET}}(e);case Vt.MEDIA_ERR_SRC_NOT_SUPPORTED:return e.once(v,(function(){e.emit("recover")})),r;default:return r}}(r,n,t),s=function(e,t){if(t.message)return t.message;if(t.stack)return t.stack;const r=t.code||-1,n=Wt(r);return e.i18n("media_errors."+r,n)}(r,a);console.error(i,s);const o=r.reaper&&r.reaper.get("ui");return o&&function(e,t,r,n){if(!e)return;const i=document.createElement("div");if(i.classList.add("fp-error"),i.innerText=t,n){const t=e.querySelector("#"+n);t&&e.removeChild(t),i.id=n}if(e.append(i),r){const e=document.createElement("div");e.classList.add("fp-error-details"),e.innerText=r,i.append(e)}}(o,s,t.details)}))}))}var Jt=Object.freeze({__proto__:null,NO_FULLSCREEN:1,NO_VOLUME_CONTROL:2,NO_MUTE:4,LOGO_ON_RIGHT:8,USE_DRAG_HANDLE:16,USE_PLAY_2:32,USE_PLAY_3:64,USE_THIN_CONTROLBAR:128,NO_TITLE:256,NO_DESCRIPTION:512,NO_CONTROLS:1024,NO_DURATION:2048,NO_HEADER:4096,AUDIO_ONLY:8192,NO_TOUCH_ZONES:16384});function $t(e,t,r){let n=()=>document.fullscreenElement,i="fullscreenchange";if(!Element.prototype.requestFullscreen){const e=Element.prototype,t=document;e.webkitRequestFullScreen&&(e.requestFullscreen=e.webkitRequestFullScreen,t.fullscreenEnabled=!0),t.webkitCancelFullScreen&&(document.exitFullscreen=t.webkitCancelFullScreen),i="webkit"+i,n=()=>t.webkitCurrentFullScreenElement}const s=()=>r.getFullsceenTarget?r.getFullsceenTarget():t;r.toggleFullScreen=function(e,t){if(r.ios_fullscreen_disabled)return;if("boolean"!=typeof e&&(e=!r.hasState("is-fullscreen")),er(r)&&(e?function(e){e.getAttribute("playsinline")&&e.removeAttribute("playsinline");e.getAttribute("webkit-playsinline")&&e.removeAttribute("webkit-playsinline");e.webkitEnterFullScreen()}(r):function(e,t){e.getAttribute("playsinline")||e.setAttribute("playsinline","");e.getAttribute("webkit-playsinline")||e.setAttribute("webkit-playsinline","");t||e.webkitExitFullScreen();e.togglePlay(!1),e.hasState($)||e.setState($,!0)}(r,t)),!document.fullscreenEnabled)return;const n=s();e?n.requestFullscreen():document.exitFullscreen()},er(r)&&(r.ios_fullscreen_disabled=!0,r.once("beforeplay",(function(){r.ios_fullscreen_disabled=!1})),r.on("webkitendfullscreen",(function(){r.toggleFullScreen(!1,!0)}))),setTimeout(()=>{const e=s();e.addEventListener(i,(function(){const t=n(),i=t===e||t==r;r.emit(i?c:d),r.setState("is-fullscreen",i)}))},0),!1!==e.doubleclick&&t.addEventListener(a,(function(e){var t;e.target&&(null===(t=e.target)||void 0===t?void 0:t.classList.contains("fp-ui"))&&r.toggleFullScreen()}))}function er(e){return r().ios&&"function"==typeof e.webkitEnterFullScreen&&"function"==typeof e.webkitExitFullScreen}function tr(e,t){if("object"!=typeof e.opts)return{head:0,tail:0};if(0==e.seekable.length)return{head:0,tail:0};const r=e.seekable.end(e.seekable.length-1);return{head:r,tail:Math.max(e.seekable.start(0),r-t)}}function rr(e){return e.opt("live",!1)||e.duration>=Number.MAX_SAFE_INTEGER}function nr(e){return isFinite(e.duration)?e.duration:0==e.seekable.length?0:e.seekable.end(0)}function ir(e){return function(e,t){return tr(e,t).head}(e,0)-.5}function ar(e,t,r){if(!r.reaper)return;const n=document.createDocumentFragment(),i=le(r,R);n.appendChild(i),r.reaper.set("ui",i),~t.className.indexOf("use-play-")||t.classList.add("use-play-1"),function(e,t,r){const n=Oe("fp-footer");t.append(n),r.on(S,(function(e){var t,r;const i=null===(t=e.data)||void 0===t?void 0:t.description,a=null===(r=e.data)||void 0===r?void 0:r.title;if(n.innerHTML="","string"==typeof a){const e=Oe("fp-title");e.innerText=a,n.append(e)}if("string"==typeof i){const e=i.split(" "),t=Oe("fp-desc");for(t.innerText=e.join(" "),n.append(t);e.length>1&&t.scrollHeight>t.offsetHeight;)e.pop(),t.innerText=e.join(" ")+"..."}}))}(0,t,r),Zt(0,0,r),t.appendChild(n),[o,l].forEach(e=>{t.addEventListener(e,(function(e){r.setState("is-hovered",e.type==o),r.setState("is-accessibility",!1)}))}),$t(e,t,r),r.on("volumechange",(function(){const e=0==r.volume||r.muted;r.setState("is-muted",e),r._storage.setItem("mute",e.toString())})),"true"==r._storage.getItem("mute")&&(r.muted=!0,r.setState("is-muted",r.muted));const a=r._storage.getItem("volume");a&&!isNaN(Number(a))&&(r.volume=Number(a)),r.emit("volumechange"),r.on("dvr/window",t=>{var n;e.live&&(!("dvr"in(n=e))||1==n.dvr)&&function(e,t,r){if(0==t)return!0;const n=tr(e,r);return n.head-n.tail>=t}(r,e.seconds_to_dvr||60,t.detail)&&r.setOpts({dvr:r.seekable.length>0})}),r.on("live",(function(){r.setState("is-live-seeked",!1)})),r.on("seeking",(function(){if(!rr(r))return;if(0==r.seekable.length||0==r.played.length)return;if(0==nr(r))return;const e=ir(r),t=r.currentTime>=e?"live":"dvr";if("live"===t)return r.emit(t);const n=nr(r),i=r.seekable.end(0)-r.seekable.start(0),a=(n-r.currentTime)/i*100,s=Math.round(a);r.setState("is-live-seeked",s>0),r.emit(t,{offset:s})})),r.on(f,(function(){r.setOpts({live:rr(r)})})),r.on("durationchange",(function(e){const t=rr(r),n=t?nr(r):e.data||r.duration;isNaN(n)||r.setOpts({live:t,duration:n})})),r.on(S,(function(r){var n,i;e.seekable=void 0===(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.seekable)||r.data.seekable;const a=null===(i=r.data)||void 0===i?void 0:i.ui;if("number"!=typeof a)return;const s=t.classList;s.toggle("use-play-1",!(32&a||64&a)),s.toggle("use-play-2",(32&a)>0),s.toggle("use-play-3",(64&a)>0),s.toggle("use-thin-controlbar",(128&a)>0),s.toggle("no-title",(256&a)>0),s.toggle("no-description",(512&a)>0),s.toggle("logo-on-right",(8&a)>0),s.toggle("use-drag-handle",(16&a)>0),s.toggle("no-controls",(1024&a)>0),s.toggle("no-duration",(2048&a)>0),s.toggle("no-header",(4096&a)>0),s.toggle("no-mute",(4&a)>0),s.toggle("no-volume",(2&a)>0),s.toggle("no-fullscreen",(1&a)>0),s.toggle("no-touch-zones",(16384&a)>0)}));let s=null;i.addEventListener("mousemove",(function(){"number"==typeof s&&clearTimeout(s),r.setState("is-hovered",!0),s=0==r.paused&&setTimeout((function(){r.setState("is-hovered",!1)}),2e3)}))}function sr(e,t,r){if(it.from_token(e.token||"").is_granted(it.permissions.NO_METERING))return;const n=tt.id(e.token||"");n&&r.once(m,()=>function(e,t){fetch("https://pmi.flowplayer.com/in",{method:"POST",body:JSON.stringify({token_id:t,factor:1,rnd:Math.random().toString(36).substring(2)})}).then(t=>{401==t.status&&e.emit("error:fatal",{reason:"token",details:"The token online validation failed"})})}(r,n))}var or={ads:{ad:"Ad",ads:"Ads",advertisement:"Advertisement"},audio:{button_txt:"Audio",menu_title:"Audio"},core:{exit_fullscreen:"Exit fullscreen",fullscreen:"Fullscreen",mute:"Mute",pause:"Pause",play:"Play",unmute:"Unmute",volume:"Volume"},ovp:{starting_in:"Countdown"},playlist:{cancel:"Cancel",up_next:"Up next"},qsel:{menu_title:"Quality"},share:{clipboard_failure:"Access to clipboard failed",clipboard_success:"The text is now on your clipboard",embed:"Embed",link:"Link",menu_title:"Share"},speed:{menu_title:"Speed"}};class I18n{init(e,t,r){r.reaper&&r.reaper.set("translations",Me(I18n,e,"en"))}}I18n.en=or;const lr="rebuffer";var ur=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:lr});const cr=navigator;function dr(e){var t,r;const n=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return n?1e-6*n:(null===(r=cr.connection)||void 0===r?void 0:r.downlink)||-1}function fr(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const hr="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),pr=window,vr=pr._flowplayerTimekeeper||(pr._flowplayerTimekeeper={});function gr(){return ge(this,void 0,void 0,(function*(){const e=vr.cachedServerOffset;if(e)return e;const t=vr.pendingRequest||(vr.pendingRequest=fetch(hr)),r=yield t,n=parseInt(r.headers.get("age")||"0"),i=yield r.json(),a=Date.now()-i.millisUtc-1e3*n;return vr.cachedServerOffset=a,vr.cachedServerOffset}))}const mr=e=>{switch(e){case!0:return de.ON;case!1:return de.OFF;default:return e}},yr=[];function Er(e){if(e.suspended)return;const t=yr.slice(0);yr.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),fr("https://health.flowplayer.com/v1/health/events",t))}function _r(e,t,r){return ge(this,void 0,void 0,(function*(){const n=yield br();yr.push(Object.assign(t,n)),e.logger.log(":enqueue",t.event,t),yr.length<10&&!r||Er(e)}))}const Tr=()=>{var e,t;try{const r=window;return null===(t=null===(e=null==r?void 0:r.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},br=()=>ge(void 0,void 0,void 0,(function*(){try{const e=yield gr();return{timestamp:Date.now()-e,adjustedTimestamp:!0}}catch(e){return{timestamp:Date.now(),adjustedTimestamp:!1}}})),Ar=(e,t)=>Object.assign(e,{detail:t}),Sr=(e,{event:t,media_session_id:r,session_id:n})=>({event:t,media_session_id:r,session_id:n,device_id:e.deviceId(),version:"3.0.8",commit:"c23496a4f8c940803c8c2853e8f12754b7e23298",ima_sdk_version:Tr(),preload:e.opt("preload"),autoplay:mr(e.opt("autoplay")),live:e.opt("live"),dvr:e.opt("dvr"),source:e.original_src,downlink_mbs:dr(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),wr=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function Lr(e,t,r,n){const i=Sr(t,e.eventInfo(r)),{before:a,after:s}=n;_r(e,((e,t,r)=>Object.assign(e,{state:{before:t,after:r}}))(i,wr(a),wr(s)))}const kr=(e,t)=>{let r=null;return(...n)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Rr=Ne();class Health{constructor(e,t){this.session_id=Rr,this.suspended=!1,this.logger=function(e,t){return{log:(...r)=>{const n=e.opt("debug");n&&t.match(n)&&console.log(t,...r)}}}(t,"health"),this.media_session_id=Ne(),this.analyticsLoop=setInterval(()=>Er(this),2e3),t.on(A,()=>clearInterval(this.analyticsLoop));const r=this;if(t.health={get media_session_id(){return r.media_session_id},set media_session_id(e){r.media_session_id=e},get session_id(){return r.session_id},set session_id(e){r.session_id=e},toggle(e){e?r.resume():r.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>Er(this),2e3)}init(e,t,r){!function(e){e.on(y,(function(t){e.seeking||e.networkState===e.NETWORK_LOADING&&e.readyState!==e.HAVE_NOTHING&&e.emit(lr)}))}(r),r.on("health:record",({detail:e})=>{const t=Sr(r,this.eventInfo(e.event));Object.assign(t,e.detail||{}),_r(this,t)}),[E,v,s,f,h,p,y,lr].forEach(e=>{r.on(e,e=>{_r(this,Sr(r,this.eventInfo(e.type)))})}),[m,g,b,T,_,c,d].forEach(e=>{r.on(e,e=>{_r(this,Sr(r,this.eventInfo(e.type)))})}),r.on("volumechange",kr(800,e=>{const t=Sr(r,this.eventInfo(e.type));_r(this,Ar(t,{volume:parseFloat(r.volume.toFixed(2)),muted:r.muted}))})),r.on("resize",kr(800,e=>{const n=Sr(r,this.eventInfo(e.type));_r(this,Ar(n,{height:t.clientHeight,width:t.clientWidth}))})),r.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return Lr(this,r,e,t)}});let i=Date.now()+5e3;r.on("timeupdate",e=>{if(Date.now()<i)return;i=Date.now()+5e3;const t=Sr(r,this.eventInfo(e.type));var n;_r(this,Ar(t,{duration:(n=r.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),r.addEventListener(n,e=>{const t=Sr(r,this.eventInfo(e.type)),n=e.error||r.error;if(!n)return _r(this,t,!0);const i=n.code,a={error_message:n.message||Wt(i),error_code:i,error_stack:n.stack||""};return _r(this,Ar(t,a),!0)}),r.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!Xt(r.original_src))return;if(!Xt(n))return;if(n==r.original_src)return;this.media_session_id=Ne();_r(this,Sr(r,this.eventInfo(e.type))),Er(this)}),r.on("visibilitychange",e=>{_r(this,Sr(r,this.eventInfo(e.type))),Er(this)})}}var Dr;function Or(e,t){if(function(e){return Object.values(Dr).includes(e)}(t=t||Dr.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function Cr(e){const t=document.createElement("a");return t.href=e,t.origin}function Ir(e,t){const r=document.createElement("track");r.className="fp-track renderable",r.kind=t.kind||"captions",r.id=["fp",t.lang].join("-");const n=r.track;return"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),Cr(e.src)!==Cr(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(Or(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&Or(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(r[e]=t[e])}),n.mode=t.default?"hidden":"disabled",r.onload=function(){},n.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(r),r}Health.events=ur,Health._UNLOAD_SUBSCRIBED=!1,Qe(window,Health),function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(Dr||(Dr={}));var xr=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});class Chapters{constructor(){this._track_added_handler=qt,this._cue_changed_handler=qt,this.chapters=[],this.render=this.render.bind(this)}init(e,t,r){this._root=t,this._player=r,this._timeline=Re(r,I),this._track_added_handler=this.track_added.bind(this,r),this._cue_changed_handler=this.cue_changed.bind(this,r),r.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(r,e),r.chapters=this,r.on(S,e=>{e.data&&this.wireup(r,e.data)}),r.on(A,()=>{this.wiredown(r),r.textTracks.removeEventListener("addtrack",this._track_added_handler),r.off("durationchange",this.render)}),r.on("durationchange",this.render)}track_added(e,t){}cue_changed(e,t){var r;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&Ge(this._timeline,"chapter:changed",null===(r=this.current_cue)||void 0===r?void 0:r.text))}set_chapters(e){this.chapters=e,this.render()}jump(e){this._player&&this.chapters[e]&&(this._player.currentTime=this.chapters[e].start)}current(){if(this.current_cue)return this.chapters.find(e=>e.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const e=this._player.duration;isFinite(e)&&(Ge(this._timeline,"chapters:new",this.chapters.map(t=>({title:t.label,left:t.start/e*100+"%",width:(t.end-t.start)/e*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(e,t){const r=Array.isArray(t.chapters)?t.chapters[0]:t.chapters;r&&r.src!==this._current_chapters_src&&(this.wiredown(e),this._current_chapters_track=Ir(e,Object.assign(Object.assign({},r),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var e;(null===(e=this._current_chapters_track)||void 0===e?void 0:e.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(e=>e instanceof VTTCue).map(e=>{const t=e;return{start:e.startTime,end:e.endTime,cue:t,label:t.text}}))},this._current_chapters_src=r.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(e){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),e.removeChild(this._current_chapters_track))}}Chapters.events=xr,Qe(window,Chapters);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerPrimary extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-primary");const t={logo:""};e.on(S,e=>{var r,n;const i=t.logo,a=(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.logo)||"";i!=a&&(t.logo=a,this.set_logo(a,null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.logo_href))})}set_logo(e,t){if(this.innerHTML="",!e)return;const r=document.createElement("img");if(r.classList.add("fp-logo"),r.src=e,!t)return this.append(r);const n=document.createElement("a");n.href=t,n.append(r),this.append(n)}}class FlowplayerHeaderDuration extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-duration"),e.on(S,e=>{var t;const r=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.duration)||NaN;this.innerText=isFinite(r)?xe(r):""})}}const Pr={name:"fp-fullscreen",translation_key:"core.fullscreen"},Mr={name:"fp-fullscreen-exit",translation_key:"core.exit_fullscreen"},Fr={name:"fp-play",translation_key:"core.play"},Nr={name:"fp-pause",translation_key:"core.pause"},Ur={translation_key:"core.mute",name:"fp-volume-mute-unmute"},Br={translation_key:"core.play",name:"fp-small-play"},jr={translation_key:"core.pause",name:"fp-small-pause"},Gr={name:"fp-fast-forward"},Hr={name:"fp-rewind"};class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}document.addEventListener(i,(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{const t=e.root.querySelector("details[open].fp-menu-container");t&&(t.open=!1,e.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const Kr={passive:!0};var Vr;function Wr(e,t){let r=0,n=-1,i=-1;const a=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),s=e.classList;e.id=a,s.remove(Vr.GRABBING),s.remove(Vr.TOUCHING);const o=t.onseek||qt,l=t.onstart||qt,c=t.onend||qt,d=t.onmouse||qt,f=t.ontouch||qt,h=t.ontouchend||qt;function p(t){!function(){const t=e.getBoundingClientRect();r=t.left,n=t.width}();let i=(function(e){return"function"==typeof window.TouchEvent&&e instanceof TouchEvent}(t)?t.changedTouches[0].pageX:t.pageX)-r;return i>n&&(i=n),i<0&&(i=0),i/n*100}function v(t){const r=p(t);r!=i&&(o(e,r),i=r)}return e.addEventListener("touchstart",(function(t){qr(e,t)&&(s.add(Vr.TOUCHING),zr(e.parentElement)&&(t.preventDefault(),s.add(Vr.GRABBING),f(e,p(t)),l(e,p(t)),v(t)))}),Kr),e.addEventListener("touchmove",(function(t){t.preventDefault(),v(t),d(e,p(t))}),Kr),e.addEventListener(u,(function(t){setTimeout((function(){s.remove(Vr.TOUCHING)}),500),qr(e,t)&&(t.preventDefault(),s.remove(Vr.GRABBING),h(e,p(t)),c(e,p(t)),n=0)}),Kr),e.addEventListener("touchcancel",(function(){s.remove(Vr.GRABBING,Vr.TOUCHING),n=0}),Kr),e.addEventListener("mousedown",(function(t){s.contains(Vr.TOUCHING)||(document.addEventListener("mousemove",v),s.add(Vr.GRABBING),l(e,p(t)),t.preventDefault(),v(t))})),e.addEventListener("mousemove",(function(t){s.contains(Vr.TOUCHING)||d(e,p(t))})),document.addEventListener("mouseup",(function(t){s.contains(Vr.TOUCHING)||(document.removeEventListener("mousemove",v),s.contains(Vr.GRABBING)&&(s.remove(Vr.GRABBING),c(e,p(t)),n=0))})),e}function qr(e,t){const r=t.target;return!!r&&(r&&!r.closest(e.id)||!zr(e.parentElement)||!e.classList.contains(Vr.TOUCHING))}function zr(e){if(!e)return!1;const t=window.getComputedStyle(e);return"0"!==t.width&&"0"!==t.height&&"0"!==t.opacity&&"none"!==t.display&&"hidden"!==t.visibility}!function(e){e.GRABBING="has-grab",e.TOUCHING="has-touch"}(Vr||(Vr={}));class FlowplayerVolumeBar extends FlowplayerComponent{constructor(e){super(e),this.className="fp-volume";const t=e.root.classList,r=t.contains("is-tiny")?6:t.contains("is-small")?8:10,n=Array.from({length:r}).map(()=>{const e=document.createElement("i");return e.className="fp-tick",e});this.append(...n),Wr(this,{onseek:(t,r)=>{r>0&&(e.muted=!1,e._storage.removeItem("mute")),e._storage.setItem("volume",(e.volume=r/100).toString()),this.adjustVolumeSlider(e.volume)}}),this.setAttribute("tabindex","0"),this.setAttribute("role","slider"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","1"),this.setAttribute("aria-label",e.i18n("core.volume","volume")),e.on("volumechange",()=>{(0==e.volume||e.muted)&&this.adjustVolumeSlider(0),this.classList.contains(Vr.GRABBING)||this.adjustVolumeSlider(e.volume)})}adjustVolumeSlider(e){this.setAttribute("aria-valuenow",e.toString());const t=Array.from(this.querySelectorAll(".fp-tick")),r=Math.round(e*t.length);t.forEach((e,t)=>{e.classList.toggle("fp-color",t<r)})}}function Yr(e,t){if(!e.parentElement)return;const r=e.clientWidth/e.parentElement.clientWidth*100/2;e.style.left=t-r+"%",e.style.display="block"}function Xr(e,t){if(isNaN(e.duration))return;const r=e.buffered;r.length&&(t.style.width=Math.min(r.end(r.length-1)/e.duration*100,100)+"%")}function Qr(e,t){e.style.width="0",t.style.display="none"}function Zr(e,t,r){if(t.seeking||!t.seekable||0==t.seekable.length)return;Yr(r,e);const n=t.seekable.end(t.seekable.length-1)-t.seekable.start(0),i=(100-Math.max(0,Math.min(e,100)))/100*n;r.innerText="-"+xe(i)}function Jr(e,t){e/=100,t.currentTime=function(e,t){if(t>1||t<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;if(isFinite(e.duration))return nr(e)*t;const r=e.seekable.start(0);return r+t*(e.seekable.end(0)-r)}(t,e)}function $r(e,t){e.style.width="0",t.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(e){let t;super(e),this.bufferEle=Oe("fp-buffer"),this.progress=Oe("fp-progress","fp-color"),this.tooltipEle=Oe("fp-timestamp"),this.proposedSeekBar=Oe("fp-hover"),this.dragger=Oe("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",e.i18n("timeline","Timeline")),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);let r=!1;const n=requestAnimationFrame;let i=void 0;const a=()=>{var r;0==e.reaper||t.live||(r=e,this.progress.style.width=r.currentTime/r.duration*100+"%",i=void 0,e.paused||this.classList.contains(Vr.GRABBING)||i||(i=setTimeout(a,200)))},s=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);Wr(this,{onseek:(r,n)=>{if(s())switch(!!t.live){case!0:Zr(n,e,this.tooltipEle);break;case!1:!function(e,t,r){const n=t.duration*(e/100);if(t.disabled&&n>t.currentTime)return!1;r.style.width=e+"%",t.currentTime=n}(n,e,this.progress),Yr(this.tooltipEle,n)}},onstart:()=>{s()&&(e.emit("timeline/gesture/start"),e.setState(Q,!0),t.live||function(e){e.style.display="block"}(this.tooltipEle))},onend:function(r,i){n(a),0!=t.seekable&&(e.setState(Q,!1),t.live&&Jr(i,e))},ontouch:function(){e.paused||(r=!0,e.pause())},ontouchend:()=>{r&&(r=!1,e.play()),t.live?$r(this.proposedSeekBar,this.tooltipEle):Qr(this.proposedSeekBar,this.tooltipEle)},onmouse:(r,n)=>{if(s()&&!this.classList.contains(Vr.GRABBING))switch(e.emit("timeline/gesture/move",{percent:n}),!!t.live){case!0:!function(e,t){t.style.width=function(e){return 100-e}(e)+"%"}(n,this.proposedSeekBar),Zr(n,e,this.tooltipEle);break;case!1:!function(e,t){t.style.width=e+"%"}(n,this.proposedSeekBar),function(e,t,r){if(isNaN(e)||isNaN(t.duration))return;Yr(r,e),r.innerHTML="";const n=document.createElement("span");n.innerText=xe(e/100*t.duration),r.append(n)}(n,e,this.tooltipEle)}}}),e.on(S,(function(e){e.data&&(t=e.data)})),e.on(m,()=>n(a)),e.on("live",()=>{this.progress.style.width="0%"}),e.on(p,()=>{0==e.reaper||t.live||Xr(e,this.bufferEle)}),e.on("dvr",e=>{e.detail&&(this.progress.style.width=e.detail.offset+"%")}),e.on("timeupdate",()=>{0!=e.reaper&&(n(a),this.setAttribute("aria-valuenow",e.currentTime+""),t.live||Xr(e,this.bufferEle))}),e.on(f,()=>{0!=e.reaper&&(t.live||Xr(e,this.bufferEle))}),e.on("durationchange",t=>{if(0==e.reaper)return;const r=rr(e)?nr(e):t.data||e.duration;isNaN(r)||(this.setAttribute("aria-valuemax",r+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener(l,()=>{e.emit("timeline/gesture/end"),t.live?$r(this.proposedSeekBar,this.tooltipEle):Qr(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(e){super(e),this.handleChapters(e)}handleChapters(e){const t=document.createElement("div");let r;this.addEventListener("chapters:new",e=>{t.innerText="",this.querySelectorAll(".fp-chapter").forEach(e=>this.removeChild(e)),e.data&&e.data.forEach(e=>{const n=document.createElement("div");n.className="fp-chapter",n.style.left=e.left,n.style.bottom=n.style.top="0",n.style.width=e.width,n.title=e.title,n.onmouseover=()=>{t.innerText=e.title},n.onmouseleave=()=>{t.innerText=r||""},this.appendChild(n)})}),this.addEventListener("chapter:changed",n=>{var i;const a=n.data;a&&(t.parentNode||(null===(i=Re(e,D))||void 0===i||i.insertAdjacentElement("beforebegin",t),t.classList.toggle("fp-togglable",!0),t.classList.toggle("fp-chapter-info",!0)),r=a,t.innerText=a)})}}class FlowplayerLiveStatus extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-live-status");const t=Oe("fp-live-text"),r=Oe("fp-live-indicator","fp-color");t.textContent="live",this.append(r,t),this.addEventListener(i,(function(){!function(e){try{if(!e.hasState("is-live-seeked"))return;e.emit("live"),e.dvr_offset=0,e.currentTime=ir(e)}catch(e){console.warn("failed to seek to now: %j",e)}}(e)}))}}class FlowplayerDuration extends FlowplayerComponent{constructor(e){let t;super(e),this.classList.add("fp-duration"),e.on(S,r=>{if(0==e.reaper||!r.data)return;t=r.data;const n=rr(e)?NaN:r.data.duration||0;if(isNaN(n)||n>=Number.MAX_SAFE_INTEGER)return this.style.display="none";this.style.display="inline-block",this.innerText=xe(n)}),e.on(f,()=>{var r,n;0==e.reaper||t.live||(n=this,(r=e).duration&&(n.innerText=xe(r.duration)))})}}class FlowplayerElapsedTime extends FlowplayerComponent{constructor(e){let t;super(e),this.classList.add("fp-elapsed"),this.innerText=xe(0),e.on(S,e=>{e.data&&(t=e.data)}),e.on("timeupdate",()=>{var r;0!=e.reaper&&(t.live?(r=e,this.innerText=xe(r.currentTime)):function(e,t){t.innerText=xe(e.currentTime)}(e,this))})}}class FlowplayerControlButtons extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-btns","fp-small-switch");const t=le(e,"flowplayer-small-pause-icon"),r=le(e,"flowplayer-small-play-icon");t.addEventListener("click",(function(){e.togglePlay(),setTimeout((function(){r.focus&&r.focus()}),100)})),r.addEventListener("click",(function(){e.togglePlay(),setTimeout((function(){t.focus&&t.focus()}),100)})),this.append(t,r)}}class FlowplayerLeftRightZone extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add(t);const r=this.classList.contains("fp-left-zone")?-1:1,n=document.createElement("span"),i=le(e,this.classList.contains("fp-left-zone")?G:"flowplayer-fast-forward-icon");i.removeAttribute("tabindex"),n.classList.add("fp-zone-seconds"),this.append(n,i);e.on(T,()=>{n.innerText=""}),e.on("seek:queued",e=>{const t=e.data;if(!t)return;if("number"!=typeof t.offset)return;const r=t.offset;if(0==r)return this.reset_zone();r>0&&this.classList.contains("fp-right-zone")||r<0&&!this.classList.contains("fp-right-zone")?this.render_zone_state(r):this.reset_zone()}),e.on("seek:cancel",()=>{this.reset_zone()}),this.reset_zone(),this.addEventListener(u,(function(t){isNaN(e.duration)||isNaN(e.currentTime)||16384&e.opt("ui")||e.hasState("no-timeline")||!e.hasState("will-seek")&&!e.hasState($)||e.enqueueSeek(5*r)&&(t.stopPropagation(),t.preventDefault())}))}reset_zone(){const e=this.querySelector(".fp-zone-seconds");e&&(e.innerText="")}render_zone_state(e){const t=this.querySelector(".fp-zone-seconds");t&&(t.innerText=Math.abs(e)+"")}}class FlowplayerHeaderLeftRight extends FlowplayerComponent{constructor(e,t,...r){super(e),this.className=t;const n=e.createComponents(...r);this.append(...n),"fp-left"!==t&&n.forEach(t=>{t.addEventListener(i,()=>e.toggleFullScreen())})}}class FlowplayerMiddleWait extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-wait"),Array(...Array(4)).map((e,t)=>t).forEach(()=>{this.append(document.createElement("b"))})}}class FlowplayerMiddleZone extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-middle-zone");const t=e.createComponents(U,"flowplayer-middle-buttons");this.append(...t)}}class FlowplayerMiddleButtons extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-switch"),[B,j].forEach(t=>{const r=le(e,t);r.removeAttribute("tabindex"),this.append(r)})}}class FlowplayerVolumeControl extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-volume-control");const t=le(e,H);this.append(t),!r().ios&&this.append(le(e,x)),t instanceof FlowplayerIcon&&t.addEventListener(i,(function(){e.toggleMute()}))}}class FlowplayerHeader extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-header"),this.append(...e.createComponents("flowplayer-header-left-zone","flowplayer-header-right-zone")),e.reaper&&e.reaper.set("header",this)}}class FlowplayerControls extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-controls","fp-togglable"),this.append(...e.createComponents("flowplayer-control-buttons",O,C,I,"flowplayer-control-duration","flowplayer-volume-control"))}}class FullscreenIcon extends FlowplayerIcon{constructor(e,t){super(e,t),this.setAttribute("role","button"),this.setAttribute("aria-label",e.i18n(t==Pr?"core.fullscreen":"core.fullscreen_exit"))}}class FlowplayerMiddle extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-middle"),this.append(...e.createComponents("flowplayer-middle-left-zone",N,"flowplayer-middle-right-zone")),this.setAttribute("tabindex","0"),this.setAttribute("role","button"),this.setAttribute("aria-label",e.i18n("core.play")),e.reaper&&e.reaper.set("middle",this),this.handleClick(e),this.handleTouch(e),[m,T].forEach(t=>e.once(t,()=>{this.removeAttribute("tabindex"),this.removeAttribute("role"),this.removeAttribute("aria-label")}))}handleClick(e){[i,a].forEach(t=>this.addEventListener(t,(function(t){if(!t.defaultPrevented)return t.preventDefault(),e.emit(t.type),!1}))),e.on(i,(function(t){setTimeout((function(){t.defaultPrevented||e.hasState(J)||e.togglePlay()}),0)})),e.on(a,(function(t){setTimeout((function(){t.defaultPrevented||e.toggleFullScreen()}),0)}))}handleTouch(e){let t=!1;this.addEventListener(u,(function(t){0!=t.cancelable&&(t.preventDefault(),e.emit(t.type,{source:t}))})),e.on(u,(function(r){setTimeout((function(){if(r.defaultPrevented)return;if(e.hasState(J))return;if(e.ended)return e.togglePlay(!0);const n=e.hasState(X);t&&clearTimeout(t),(n||e.hasState($)||e.hasState("no-autoplay"))&&(e.hasState($)&&(e.setState($,!1),e.setState("is-hovered",!1)),e.togglePlay(),n)||(e.setState($,!0),e.paused||(t=setTimeout((function(){t=!1,e.setState($,!1),e.setState("is-hovered",!1)}),2e3)))}),0)}))}}class FlowplayerUi extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-ui"),this.append(...e.createComponents(P,F,D))}}mt.extensions.unshift.apply(mt.extensions,[I18n,Analytics,Health,class Default{constructor(e){ue(e,R,FlowplayerUi),ue(e,D,FlowplayerControls),ue(e,O,FlowplayerLiveStatus),ue(e,"flowplayer-control-duration",FlowplayerDuration),ue(e,I,e.extensions.find(e=>e.name===Chapters.name)?FlowplayerChaptersTimelineBar:FlowplayerTimelineBar),ue(e,C,FlowplayerElapsedTime),ue(e,x,FlowplayerVolumeBar),ue(e,"flowplayer-volume-control",FlowplayerVolumeControl),ue(e,"flowplayer-control-buttons",FlowplayerControlButtons),ue(e,P,FlowplayerHeader),ue(e,M,FlowplayerPrimary),ue(e,"flowplayer-header-duration",FlowplayerHeaderDuration),ue(e,"flowplayer-header-left-zone",class extends FlowplayerHeaderLeftRight{constructor(e){super(e,"fp-left",M,"flowplayer-header-duration")}}),ue(e,"flowplayer-header-right-zone",class extends FlowplayerHeaderLeftRight{constructor(e){super(e,"fp-right fp-togglable","flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon")}}),ue(e,F,FlowplayerMiddle),ue(e,N,FlowplayerMiddleZone),ue(e,U,FlowplayerMiddleWait),ue(e,"flowplayer-middle-buttons",FlowplayerMiddleButtons),ue(e,"flowplayer-middle-right-zone",class extends FlowplayerLeftRightZone{constructor(e){super(e,"fp-right-zone")}}),ue(e,"flowplayer-middle-left-zone",class extends FlowplayerLeftRightZone{constructor(e){super(e,"fp-left-zone")}}),ue(e,"flowplayer-small-play-icon",class extends FlowplayerIcon{constructor(e){super(e,Br),this.setAttribute("role","button")}}),ue(e,"flowplayer-small-pause-icon",class extends FlowplayerIcon{constructor(e){super(e,jr),this.setAttribute("role","button")}}),ue(e,B,class extends FlowplayerIcon{constructor(e){super(e,Fr)}}),ue(e,j,class extends FlowplayerIcon{constructor(e){super(e,Nr)}}),ue(e,"flowplayer-fullscreen-enter-icon",class extends FullscreenIcon{constructor(e){super(e,Pr)}}),ue(e,"flowplayer-fullscreen-exit-icon",class extends FullscreenIcon{constructor(e){super(e,Mr)}}),ue(e,"flowplayer-fast-forward-icon",class extends FlowplayerIcon{constructor(e){super(e,Gr)}}),ue(e,G,class extends FlowplayerIcon{constructor(e){super(e,Hr)}}),ue(e,H,class extends FlowplayerIcon{constructor(e){super(e,Ur),this.classList.add("fp-volumebtn"),e.on("volumechange",()=>{const t=0==e.volume||e.muted;this.setAttribute("aria-label",t?e.i18n("unmute","unmute"):e.i18n("mute","mute"))})}})}init(e,t,r){var n;sr(e,0,r),ar(e,t,r),n=r,"undefined"!=typeof window&&"ontouchstart"in window&&n.setState("is-touch-device",!0),n.setState("is-accessibility",!1)}}]);var en=Object.assign(mt,{ui:Jt,i18n:I18n}),tn=Et(_t((function(e,t){var r;"undefined"!=typeof window&&(r=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
15
+ ***************************************************************************** */function _t(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]])}return r}function bt(t){const e=document.createElement("a");e.href=t;const r=e.pathname&&e.pathname.split(".");return r.length>1&&r[r.length-1]}function St(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const At=t=>{var{src:e}=t,r=_t(t,["src"]);return[Object.assign({src:e,type:e?St("video/"+bt(e)):""},r)]};function Lt(t){return At({src:t})}function wt(t){var{src:e,type:r}=t,i=_t(t,["src","type"]);return e&&r?[Object.assign({src:e,type:r},i)]:r&&!e?[Object.assign({type:r},i)]:At(Object.assign({src:e},i))}var kt;function Rt(t,e,r,i={safari:!1}){const n=function(t){return"string"==typeof t?Lt(t):Array.isArray(t)||"object"!=typeof t?t.reduce((function(t,e){return"string"==typeof e&&(e=Lt(e)),"object"!=typeof e||Array.isArray(e)||(e=wt(e)),t.concat(e)}),[]):wt(t)}(r);return t.currentSrc&&(t.innerHTML="",t.setOpts({live:!1,dvr_window:void 0}),delete t.opts.live,delete t.opts.dvr),[tt,X,Q,J,$].forEach(e=>t.setState(e,!1)),e.autoplay||t.setState(Z,!0),Array(...Array(n.length)).map((t,e)=>e).some(r=>{const s=n[r];if(kt.Ok==function(t,e,r){t.emit(S,r),"string"==typeof r.src&&(t.original_src=r.src);const i=function(t,e,r){return t.plugins.filter(t=>{return(e=t)&&"wants"in e;var e}).find(t=>t.wants(r.src||"",r,e))}(t,e,r);return i?(i.onload(e,t.root,t,r),kt.Ok):kt.Err}(t,e,s)||kt.Ok==function(t,e,r,i={safari:!1}){var n;/^audio\//.test(r.type||"")&&t.emit("audioonlysource");e.start_time&&(r.src=r.src+"#t="+e.start_time);if(""==t.canPlayType(r.type||""))return kt.Err;if(r.drm&&(!r.drm["com.apple.fps.1_0"]||!i.safari))return kt.Err;"string"==typeof r.src&&(t.preload=e.autoplay?"auto":null!==(n=e.preload)&&void 0!==n?n:"auto",t.src=r.src,"none"!==t.preload&&t.setState(J,!0));return kt.Ok}(t,e,s,i))return!0;r==n.length-1&&"string"==typeof s.src&&(t.src=s.src)}),function(t,e){!function(t,e){if(!t.currentSrc)return;if("none"==t.opt("preload"))return;if(e.autoplay&&e.autoplay>0)return;t.load()}(t,e)}(t,e),t}!function(t){t[t.Err=0]="Err",t[t.Ok=1]="Ok"}(kt||(kt={}));const Dt=[A,b,S,"seek:cancel"];var Ot;function It(t,e,r){return isNaN(t.duration)||isNaN(t.currentTime)?{}:(e.offset+=r,0==e.offset?Ct(t,e):(e.timer&&clearTimeout(e.timer),e.timer=setTimeout((function(){0!=t.reaper&&(t.currentTime=function(t,e,r=0){return Math.max(Math.min(e,t),r)}(t.currentTime+e.offset,t.duration),e.timer=0,Ct(t,e))}),1e3),function(t,e){t.setState("will-seek",!0),t.setState(Ot.BACKWARD,e.offset<0),t.setState(Ot.FORWARD,e.offset>0)}(t,e),t.emit("seek:queued",e),e))}function Ct(t,e){e.timer&&clearTimeout(e.timer),e.timer=e.offset=0,function(t){t.setState(Ot.FORWARD,!1),t.setState(Ot.BACKWARD,!1),t.setState("will-seek",!1)}(t)}function Pt(t,e){const r=t._customElements.get(e);return r&&t.root.querySelector(r)||void 0}function xt(){if("undefined"==typeof document)return!1;const t=document.documentElement;return t&&"rtl"==t.getAttribute("dir")}function Mt(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function Ft(t,e,r){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return r;const e=i.shift();if("string"!=typeof e)return r;t=t[e]}return null==t?r:t}function Nt(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function Ut(t){if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return"";const e=t<0?"-":"";t=Math.round(Math.abs(t));const r=Math.floor(t/3600);let i=Math.floor(t/60);return t-=60*i,r>=1?(i-=60*r,e+r+":"+Nt(i)+":"+Nt(t)):e+Nt(i)+":"+Nt(t)}!function(t){t.FORWARD="forward",t.BACKWARD="backward"}(Ot||(Ot={}));const Bt=navigator.languages||[navigator.language];function Gt(t,e,r){const i={};return r=e.lang||r,t[r]&&(i[r]=t[r]),function(){try{return Bt.reduce((t,e)=>~e.indexOf("-")?t.concat(e,e.split("-")[0]):t.concat(e),[])}catch(t){return[]}}().forEach((function(e){t[e]&&!i[e]&&(i[e]=t[e])})),Object.values(i)}const jt=[1e7]+""+-1e3+-4e3+-8e3+-1e11,Ht=()=>"undefined"==typeof crypto?"":jt.replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16));let Kt="";!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const Vt=["touchstart","touchmove"];function qt(t,e){const r=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(r,"data",{get:()=>e}),r}function Wt(t,e,r){const i=qt(e,r);return t.dispatchEvent(i),t}function zt(t,e,r){const i=qt(e,r);return t.dispatchEvent(i),i}function Yt(t,e,r,i){Array.isArray(e)?e.forEach(e=>Xt(t,e,r,i)):Xt(t,e,r,i)}function Xt(t,e,r,i){if(n=e,!~Vt.indexOf(n))return t.addEventListener(e,r,i),t;var n;const s=Object.assign(i||{},{passive:!0});return t.addEventListener(e,r,s),t}function Qt(t,e,r,i){return Yt(t,e,r,Object.assign(i||{},{once:!0}))}class PlayerStorage{constructor(t,e){this.implementation=t,e&&(e.keys.forEach(t=>{"string"==typeof e.implementation[t]&&this.implementation.setItem(t,e.implementation[t])}),this.implementation.__fp_storage_keys=e.implementation.__fp_storage_keys||"[]");try{this.keys=JSON.parse(this.implementation.__fp_storage_keys||"[]")}catch(t){this.keys=[]}}removeKey(t,e=!1){this.keys=this.keys.filter(e=>e!==t),e||this.storeKeys()}addKey(t){this.removeKey(t,!0),this.keys.push(t),this.storeKeys()}storeKeys(){this.implementation.__fp_storage_keys=JSON.stringify(this.keys)}removeItem(t){try{this.implementation.removeItem(t),this.removeKey(t)}catch(t){}}getItem(t){try{return this.implementation.getItem(t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem(t,e),this.addKey(t)}catch(t){}}clear(){try{this.keys.forEach(t=>this.implementation.removeItem(t)),this.keys=[],this.implementation.removeItem("__fp_storage_keys")}catch(t){}}get length(){try{return this.implementation.length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}const $t={preload:"none",rtl:!1,controls:!0},Jt=["loop","muted","preload"];function Zt(t,i,n){n._storage=new PlayerStorage(window.localStorage),n.toJSON=function(){return{duration:n.duration,volume:n.volume,currentTime:n.currentTime,states:n.root.className}},n.setSrc=function(e){return Rt(n,t,e,r())},n.playerState=n.playerState||{},n.setState=function(t,e){if(n.playerState[t]===!!e)return n;const r=Object.assign({},n.playerState,{[t]:e});return r[it]&&(r[X]=!1),n.playerState=r,Wt(n,"state",n.playerState),n},n.createComponents=function(...t){return Array.from({length:t.length}).map((e,r)=>pt(this,t[r]))},n.hasState=function(t){return!!n.playerState[t]},n.transitionState=function(t,e,r){!n.hasState(t)&&n.hasState(e)||(r=0),r&&n.setState("is-toggling",!0),n.setState(e,!1),n.setState(t,!0),r&&setTimeout((function(){n.setState("is-toggling",!1)}),r)},n.emit=(t,e)=>(Wt(n,t,e),n),n.on=(t,e)=>(Yt(n,t,e),n),n.once=(t,e)=>(Qt(n,t,e),n),n.off=(t,e)=>{var r,i;return r=t,i=e,n.removeEventListener(r,i),n},n.poll=(t,e)=>zt(n,t,e),n.togglePlay=function(e){return yt(n,t,e)},n.toggleMute=function(t){t=null==t?!n.muted:!!t,n.muted=t,n.muted||n.volume||(n.volume=1),Wt(n,"volumechange")},n.toggleDisable=function(t){t=null==t?!n.disabled:!!t,n.setState("is-disabled",t),n.disabled=t},n.destroy=function(){n.pause();const t=e.indexOf(n);~t&&e.splice(t,1),setTimeout((function(){n.setSrc([]),n.reaper&&n.reaper.clear(),Wt(n,A)}),0)},n.setAttrs=function(t){return Jt.forEach(e=>{if(!(e in t))return;const r=t[e];r?n.setAttribute(e,r.toString()):n.removeAttribute(e)}),n},n.opt=function(e,r){return r=void 0===r?Ft($t,e):r,Ft(t,e,r)},n.i18n=function(t,e){if(!n.reaper)return"";const r=n.reaper.get("translations");return r?function t(e,r,i,n){return(n=n||0)>=e.length?i:Ft(e[n],r,t(e,r,i,n+1))}(r,t,e||""):e||""},n.setOpts=function(e){Object.assign(t,e),"disabled"in e&&void 0!==e.disabled&&n.toggleDisable(e.disabled),"muted"in e&&void 0!==e.muted&&n.toggleMute(e.muted);const r=!!t.autoplay&&!n.hasState("no-autoplay");n.setState("is-autoplay",r),n.setState("is-rtl",n.opt("rtl",function(t){if(!t)return xt();const e=t.getAttribute("dir");return e?"rtl"==e:xt()}(i))),n.setState(rt,!!t.live),n.setState(nt,!(!t.live||t.dvr)),n.setState("has-poster","string"==typeof t.poster&&t.poster.length>0),n.setState("is-seekable",!!t.seekable),i.style.backgroundImage=n.hasState("has-poster")?"url('"+t.poster+"')":"",Wt(n,L,t)},n.renderPlugin=function(t){zt(n,"renderplugin",t).defaultPrevented||n.root.appendChild(t)};const s={offset:0,timer:0};var a,o;o=s,(a=n).on(Dt,(function(){Ct(a,o)})),n.enqueueSeek=function(t){if(0!=n.opts.seekable&&!(1==n.opts.disabled&&t>0))return It(n,s,t)},n.deviceId=function(){return function(t){if(Kt)return Kt;try{const e=t.getItem("flowplayer/uuid");if(e)return e;const r=Ht();return t.setItem("flowplayer/uuid",r),r}catch(t){return Kt=Ht()}}(n._storage)}}function te(t,e){const r=e.querySelector("video"),i=r||(t._video_element_callback?t._video_element_callback(t):document.createElement("video"));return i.classList.add("fp-engine"),i.playsInline=!0,r||e.append(i),i}function ee(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const r=t.flowplayer;return"function"==typeof r?(r(e),e):(Array.isArray(r.extensions)||(r.extensions=[]),~r.extensions.indexOf(e)||r.extensions.push(e),e)}function re(){return"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}}const ie=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function ne(t,e){return!!~ie.indexOf(t)||t.indexOf(e)===t.length-e.length}ne.check_whitelist=function(t){return!!~ie.indexOf(t)};const se="production";function ae(t,e){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};e=e||{};try{i=ht(t),r.valid_jwt=!0}catch(t){}return r.raw=t,r.data=JSON.parse(i.c),r.exp=i.exp,e.require_valid_token&&ae.validate(r),r}function oe(t){try{return ae.validate(t),{success:!0,message:""}}catch(t){return{success:!1,message:t.message}}}var le;function ue(t){return{grant:t,is_granted:e=>(t&e)===e}}function de({root:t,video:e,data:r}){e&&e.destroy(),console.error(new Error(r.details||r.reason)),t.innerHTML="",t.classList.remove("flowplayer"),t.classList.add("flowplayer-fatal"),t.style.removeProperty("background-image");const i=document.createElement("h2");i.textContent="Playback Error";const n=document.createElement("p");n.textContent="Are you the site owner?";const s=document.createElement("a");s.classList.add("troubleshoot"),s.target="_blank",s.href="https://flowplayer.com/help/developers/troubleshooting#"+r.reason,s.textContent="Troubleshoot?";const a=document.createElement("img");a.src="https://flowplayer.com/user/pages/images/logo-white.png",t.append(i,n,s,a)}function ce(t,e){const r=e.clientWidth;e.classList.toggle("is-small",r<600),e.classList.toggle("is-tiny",r<400)}function he(t,e,i){let n=!0;e.classList.add("flowplayer"),ce(0,e),Yt(i,[g,"resize"],(function(){ce(0,e)})),Yt(i,"state",(function(){Object.entries(i.playerState).forEach((function([t,r]){e.classList.toggle(t,r)}))})),Yt(i,"timeupdate",(function(){i.setState(it,i.readyState<3)})),Yt(i,T,(function(e){setTimeout((function(){if(!e.defaultPrevented){if(t.rewind&&!i.loop){const e=i.src;t.autoplay&&(t.autoplay=0,i.setState("is-autoplay",!1)),i.setState(tt,!0),Qt(i,_,(function(){e===i.src&&(i.setState(tt,!1),i.pause(),i.setState(Z,!0))})),i.currentTime=0}Qt(i,"timeupdate",(function(){i.setState(et,!1)})),i.transitionState(et,X,t.loop||t.rewind?0:300)}}),0)})),Yt(i,[b,_],(function(t){i.setState(tt,t.type==b),i.setState(Q,i.paused),i.setState(X,!i.paused)})),Yt(i,T,(function(){i.setState(X,!1),n=!0})),Yt(i,r().ios?h:f,(function(){var t,e;i.setState($,!0),i.setState(J,!1);const r=i;0===(null===(t=r.videoTracks)||void 0===t?void 0:t.length)&&(null===(e=r.audioTracks)||void 0===e?void 0:e.length)>0&&i.emit("audioonlysource")})),Yt(i,[y,E,g],(function(e){if(!i.hasState(tt)&&(e.type!=E||t.autoplay||i.setState(it,!1),e.type!=g||"none"!=i.opt("preload")||t.autoplay)){if(e.type==g&&t.autoplay)return Qt(i,v,(function(){i.setState(it,!1)}));e.type==y&&([X,Q,Z].forEach((function(t){i.setState(t,!1)})),i.hasState($)||i.setState(J,!0)),i.setState(et,!1),i.setState(it,e.type==y)}})),Yt(i,[v,m],(function(e){setTimeout(()=>{const t=new CustomEvent("flowplayer/"+e.type,{detail:i});document.dispatchEvent(t)},0);const r=e.type==v,s=i.currentTime==i.duration,a=r&&n&&t.autoplay||i.hasState(it);if(r&&(i.started=!0,n=!1),i.setState(it,!1).setState(Z,!1),s||i.hasState(tt))return;const o=r?X:Q,l=r?Q:X;i.transitionState(o,l,a?0:300),r&&i.setState("no-autoplay",!1)}))}ae.validate=function(t){if("string"==typeof t&&(t=ae(t)),!t||!t.raw){if(ne.check_whitelist(window.location.hostname)||"dev"===se.toString())return!0;throw new Error("No token provided in configuration")}if(!t.valid_jwt)throw new Error("Invalid token provided");const e=window.location.hostname,r=ne.bind(null,e);if("dev"!==se.toString()&&t.data.domain&&t.data.domain.length&&!t.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==se.toString()&&1e3*t.exp-Date.now()<0)throw new Error("Expired token");return!0},ae.id=function(t){if(t)return"string"==typeof t&&(t=ae(t)),t.data.id},function(t){t[t.ADS=2]="ADS",t[t.ANALYTICS=4]="ANALYTICS",t[t.NO_METERING=8]="NO_METERING",t[t.DEVELOPER_PLAN=16]="DEVELOPER_PLAN"}(le||(le={})),ue.of=ue,ue.from_token=function(t){const e=ae(t,{require_valid_token:!0});return ue.of(e.data.acl)},ue.permissions=le;const fe=[0].concat(Array.from({length:100}).map((t,e)=>(e+1)/100));function pe(t,e,r){if(!window.IntersectionObserver)return;const i={should_resume:!!t.autoplay,has_user_gesture:!1,locked:!1};[u,n].forEach(t=>Qt(r,t,()=>i.has_user_gesture=!0)),Yt(r,"play",(function(){i.locked||(i.should_resume=!0)})),Yt(r,S,(function(){i.should_resume=!!t.autoplay})),Yt(r,m,(function(){i.locked||(i.should_resume=!1)})),Yt(r,E,(function(e){if(t.autoplay)return r.hasState(at)&&i.should_resume?r.togglePlay(!0):void(t.autopause||r.hasState(at)||!i.should_resume||Qt(r,"viewenter",()=>{t.autoplay&&i.should_resume&&r.togglePlay(!0)}))}));const s=new IntersectionObserver(t=>{t.forEach(t=>{setTimeout(()=>{const e=t.intersectionRatio,i=r.hasState(at);if(r.setState(at,e>=.2),r.emit("intersectionchange",{ratio:e}),i===r.hasState(at))return;const n=r.hasState(at)?"viewenter":"viewleave";r.emit(n)},0)})},{threshold:fe});s.observe(e),r.on(A,()=>s.disconnect()),t.autopause&&(Yt(r,"viewenter",(function(){i.should_resume&&t.autopause&&r.togglePlay(!0)})),Yt(r,"viewleave",(function(){if(!t.autopause)return;const e=!r.paused;i.locked=!0,r.pause(),setTimeout((function(){i.should_resume=e,i.locked=!1}),0)})))}function ge(t,e){if(!window.ResizeObserver)return;const r=new ResizeObserver(t=>{const r=t[t.length-1];e.emit("resize",r)});r.observe(t),e.on(A,()=>r.disconnect())}function me(t){if("number"==typeof t&&!isNaN(t))return Number(t);if("string"==typeof t){const e=t.split(":");return Number(e[1])/Number(e[0])}return t}function ve(t,e,r){const i=document.createElement("div");i.classList.add("fp-ratio"),e.append(i);let n=me(t.ratio||.5625);i.style.paddingTop=100*n+"%";const s=[f,h];r.on(s,(function(){const t=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth;t&&r.setOpts({ratio:t})})),r.on(L,(function(){const e=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth,s=me((null==t?void 0:t.ratio)||e||.5625);n!==s&&(n=s,i.style.paddingTop=100*s+"%")}))}class ExplorerPlan{constructor(){this.cleanUp=this.cleanUp.bind(this),this.render=this.render.bind(this),this.wireUp=this.wireUp.bind(this)}init(t,e,r){this.root=e,this.player=r,this.wireUp()}wireUp(){var t,e;this.cleanUp(),null===(t=this.player)||void 0===t||t.once(v,this.render),null===(e=this.player)||void 0===e||e.once(T,this.wireUp)}cleanUp(){var t,e,r,i;null===(e=null===(t=this._logo)||void 0===t?void 0:t.parentElement)||void 0===e||e.removeChild(this._logo),null===(r=this.player)||void 0===r||r.off(v,this.render),null===(i=this.player)||void 0===i||i.off(T,this.wireUp)}render(){var t,e,r;null===(e=null===(t=this._logo)||void 0===t?void 0:t.parentElement)||void 0===e||e.removeChild(this._logo);const i=(null===(r=this.root)||void 0===r?void 0:r.querySelector(".fp-ui"))||this.root;if(!i)return;const n=this._logo=document.createElement("a");n.href="https://explorer.flowplayer.com",n.target="_blank",Object.entries(ye).forEach(([t,e])=>{n.style.setProperty(t,e,"important")}),i.appendChild(n)}}const ye={display:"block",opacity:"1",visibility:"visible",width:"33%","padding-top":"9%",position:"absolute","z-index":"9999",bottom:"25%",left:"10%","background-size":"cover","background-image":"url(https://static.flowplayer.com/explorer/explorer.svg)"},Ee="flowplayer/"+v;function Te(t){const e=e=>{e.detail!==t&&!1===t.opt("multiplay")&&t.togglePlay(!1)};t.on(A,()=>document.removeEventListener(Ee,e)),document.addEventListener(Ee,e)}const _e=function(){const t=re(),e=t.flowplayer?t.flowplayer:{extensions:[]};return Array.isArray(e.extensions)||(e.extensions=[]),e}();function be(r,i){if("function"==typeof r)return t.push(...[...arguments].filter(t=>"function"==typeof t)),be;"string"==typeof i&&(i={src:i}),i||(i={}),i.token||"string"!=typeof window.__FLOWPLAYER_TOKEN||(i.token=window.__FLOWPLAYER_TOKEN);const n="string"==typeof r?document.querySelector(r):r;if(!n)return console.error(new Error("Flowplayer: '"+r.toString()+"' not found"));const s=n.querySelector("video.fp-engine");if(s)return s;const a=oe(i.token);if(!a.success)return de({root:n,data:{reason:"token",details:a.message}});const o=new Map,l=te(i,n);l.reaper=o,l._customElements=ft,Object.defineProperty(l,"token",{value:"string"==typeof i.token?ae.id(i.token):"",writable:!1}),l.addEventListener(A,()=>{o.clear(),l.reaper=0,delete l.root}),l.root=n,i.token&&ue.from_token(i.token).is_granted(ue.permissions.DEVELOPER_PLAN)&&t.push(ExplorerPlan),!~e.indexOf(l)&&e.push(l),Zt(i,n,l),l.setAttrs(i),l.plugins=be.extensions.map(t=>new t(be,l)),he(i,n,l),pe(i,n,l),ge(n,l),ve(i,n,l),Te(l),l.plugins.forEach(t=>{try{t.init(i,n,l)}catch(e){console.log("Error(plugin/%s)",t.constructor.name,e)}}),l.setOpts(i),l.opts=i,i.src&&l.setSrc(i.src);const u=l.readyState;return u>0&&l.currentSrc&&l.emit(h),u>2&&l.currentSrc&&l.emit(E),l.emit("mount"),l.on("error:fatal",(function(t){de({root:n,video:l,data:t.data||{}})})),l}Object.assign(be,_e),function(i){Array.isArray(i.extensions)&&i.extensions.forEach(e=>t.push(e)),i.customElements=ft,i.defaultElements=Y,i.version="3.1.0-rc.2",i.commit="f1b2a64310ddd065f3012d9728939b5d0b1bed26",i.instances=e,i.extensions=t,i.support=r,i.events=R,i.states=ot,i.jwt=ht,i.autoplay=vt,i.quality=mt}(be),"object"==typeof document&&setTimeout(Wt,0,document,"flowplayer:umd",be);var Se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Le(t){var e={exports:{}};return t(e,e.exports),e.exports}var we=Le((function(t,e){var r=Se&&Se.__assign||function(){return(r=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};e.__esModule=!0,e.remove=e.downcase=e.pluck=e.merge=void 0,e.merge=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return r(r({},t),e)}),{})},e.pluck=function(t){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return Object.keys(t).filter((function(t){return~r.indexOf(t)})).reduce((function(r,i){var n;return e.merge(r,((n={})[i]=t[i],n))}),{})},e.downcase=function(t){return(t||"").toString().toLowerCase()},e.remove=function(t,e){var r=t.lastIndexOf(e);return~r&&t.splice(r,1),t}})),ke=Le((function(t,e){var r=Se&&Se.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),i=Se&&Se.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Se&&Se.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e};e.__esModule=!0;var s=n(we),a=function(){function t(){this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return t.of=function(){return new t},t.is_empty=function(t){return 0==t.pending.length},t.is_high_water=function(e){return e.open.length==t.MAX_OPEN_REQUESTS},t.maybe_spawn_req=function(e){if(t.is_empty(e))return e;if(t.is_high_water(e))return e;try{var r=t.lpop(e);r&&t.request(e,r)}catch(t){}},t.increment_failures=function(e){return e.stats.failures++,e.stats.failures>t.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+t.REQUEST_TTL_MS),e},t.handle_error=function(e,r){t.rm(e,r),t.increment_failures(e)},t.request=function(e,r){var i=r[0],n=r[1],s=r[2];if(!(Date.now()<e.stats.ttl)){var a=new XMLHttpRequest;e.open.push(a),a.timeout=t.REQUEST_TIMEOUT_MS,a.ontimeout=function(){t.handle_error(e,a)},a.onerror=function(r){t.handle_error(e,a)},a.onreadystatechange=function(){a.readyState==XMLHttpRequest.DONE&&t.rm(e,a),Math.floor(a.status/100)},a.onload=function(){t.rm(e,a),e.stats.failures&&e.stats.failures--},a.open(n,i),a.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{a.send(JSON.stringify(s))}catch(t){}}},t.rpush=function(e){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return r.forEach((function(r){e.pending.length>=t.MAX_PENDING||(e.pending.push(r),t.maybe_spawn_req(e))})),e},t.lpop=function(t){return t.pending.shift()},t.rm=function(t,e){return s.remove(t.open,e),t},t.MAX_OPEN_REQUESTS=3,t.MAX_PENDING=5,t.REQUEST_TIMEOUT_MS=4e3,t.REQUEST_TTL_MS=5e3,t.MAX_FAILURE_COUNT=3,t}();e.default=a})),Re=Le((function(t,e){var r=Se&&Se.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var i=r(ke);e.default=i.default.of()})),De=Le((function(t,e){e.__esModule=!0,e.prepare_url=e.URL_PARAM=void 0,e.URL_PARAM=/:([a-zA-Z_]+)/g,e.prepare_url=function(t,r){return t.url.replace(e.URL_PARAM,(function(e){if((e=e.slice(1,e.length))in r)return r[e].toString();t.log.error(new Error("\n preparing url["+t.url+"] failed\n \n parameter["+e+"] not detected in params:\n \n "+JSON.stringify(r,null,2)+"\n "))}))}})),Oe=Le((function(t,e){e.__esModule=!0,e.Log=void 0;var r=function(){function t(t){this.emitter=t}return t.prepare=function(t,e){var r=document.createEvent("Event");return r.initEvent(t,!1,!0),r.ns=t,r.data=e,r},t.of=function(e){return new t(e)},t.prototype.info=function(e){this.emitter.dispatchEvent(t.prepare(t.NAMESPACE.INFO,e))},t.prototype.error=function(e){this.emitter.dispatchEvent(t.prepare(t.NAMESPACE.ERROR,e))},t.prototype.warn=function(e){this.emitter.dispatchEvent(t.prepare(t.NAMESPACE.WARN,e))},t.NAMESPACE={INFO:"tracker:info",ERROR:"tracker:err",WARN:"tracker:warn"},t}();e.Log=r})),Ie=Le((function(t,e){var r;e.__esModule=!0,e.Verb=void 0,(r=e.Verb||(e.Verb={})).POST="POST",r.PUT="PUT",r.GET="GET"})),Ce=Le((function(t,e){var r=Se&&Se.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),i=Se&&Se.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Se&&Se.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e},s=Se&&Se.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var i=Array(t),n=0;for(e=0;e<r;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,n++)i[n]=s[a];return i},a=Se&&Se.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var o=a(Re),l=a(ke),u=n(De),d=n(we),c=function(){function t(e,r){var i=this;void 0===r&&(r={});var n=this;if(this.emitter=e,this.url=r.url,this.log=Oe.Log.of(this.emitter),this.verb=r.verb,this.metadata=d.merge({},r.metadata||{}),this.rq=r.rq||o.default,this.events=r.events||[],this.required_keys=r.required_keys||[],this.optional_keys=r.optional_keys||[],this.listeners=[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),t.assert_emitter_api(this.emitter),void 0===t.verb[this.verb])throw new Error("invalid HTTP verb["+this.verb+"] passed");if("string"!=typeof this.url)throw new Error("invalid API url["+this.url+"] passed");t.TRACKERS.push(this),n.events.forEach((function(e){t.create_listener(i,e,(function(r){void 0===r&&(r={});var s=d.merge(n.metadata,{event_type:e},r.data||r),a=u.prepare_url(n,s),o=t.pluck_valid_keys(n,s),c=t.ensure_required_keys(n,o);if(c.length)return n.log.error("Tracker.validate_metadata() failed for \n Event["+e+"]\n missing keys: "+c+"\n payload:\n "+JSON.stringify(o,null,2));l.default.rpush(i.rq,[a,i.verb,o])}))}))}return t.of=function(e,r){return new t(e,r)},t.ensure_required_keys=function(t,e){return t.required_keys.filter((function(t){return!(t in e)}))},t.pluck_valid_keys=function(t,e){return d.pluck.apply(d,s([e],t.valid_keys))},t.merge_metadata=function(e,r){return void 0===r&&(r={}),e.metadata=t.pluck_valid_keys(e,d.merge(e.metadata,r)),e},t.assert_emitter_api=function(t){if("function"!=typeof(t||{}).addEventListener)throw new Error("Tracker() received an emitter that does not implement the addEventListener method");if("function"!=typeof(t||{}).removeEventListener)throw new Error("Tracker() received an emitter that does not implement the removeEventListener method")},t.create_listener=function(t,e,r){t.listeners.push([e,r]),t.emitter.addEventListener(e,r)},t.prototype.destroy=function(){var e=this;this.listeners.forEach((function(t){var r=t[0],i=t[1];return e.emitter.removeEventListener(r,i)})),delete this.rq,delete this.emitter,d.remove(t.TRACKERS,this)},t.prototype.put=function(e){return void 0===e&&(e={}),t.merge_metadata(this,e),this},t.TRACKERS=[],t.QUEUE=o.default,t.verb=Ie.Verb,t}();e.default=c})),Pe=Le((function(t,e){var r=Se&&Se.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),i=Se&&Se.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Se&&Se.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e},s=Se&&Se.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0,e.API=e.Tracker=void 0;var a=s(Ce);e.Tracker=a.default;var o=n(De);e.API=o})),xe="ping",Me="display",Fe="view";const Ne=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],Ue=["created","position"],Be=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function Ge(t,e){return t.duration/1===t.duration&&Object.assign(e,function(t){const e=t/100;return{segment_duration:e,breakpoints:Array(...Array(100)).map((function(t,r){return Math.floor(r*e*1e3)/1e3}))}}(t.duration))}function je(t,e,r){if(!e.segment_duration&&!Ge(t,e))return;const i=function(t,e,r){const i=e.last_idx,n=r?99:He(t,e);return e.last_idx=n,n<=i?[]:e.breakpoints.slice(i,99==n?100:n).map((function(t){return e.breakpoints.indexOf(t)}))}(t,e,r);0!=i.length&&t.emit(xe,{position:i})}function He(t,e){return Math.min(Math.floor(t.currentTime/e.segment_duration),99)}const Ke="vod",Ve="live",qe=[Me,xe,Fe];function We(t,e,r){switch(null==e?void 0:e.kind){case"live":return function(t,e){const r=Date.now();r-e.last_tracked_ts<6e4||(e.last_tracked_ts=r,++e.ticks,t.emit(xe,{position:60*e.ticks}))}(t,e);case"vod":return je(t,e,"boolean"==typeof r&&r)}}function ze(t){const e=t.ads;return void 0!==e&&(void 0!==e.schedule&&("function"==typeof e.hasPreroll&&(e.currentRequests?e.currentRequests:!!e.adPlaying||!(!e.hasPreroll()||0!=e.nextIndex))))}function Ye(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(t){return!1}}class Analytics$1{init(t,e,r){if(!ue.from_token(t.token||"").is_granted(ue.permissions.ANALYTICS))return;if(r.analytics)return;const i=r.analytics={ticker:void 0,last_media_id:"",ended:!1},n={locked:!1,ttl:6e3,task:()=>{We(r,i.ticker)}};const s={session_id:r.deviceId(),autoplay:r.autoplay,muted:r.muted,player_id:t.player_id,customer_user_id:t.customer_user_id},a=Pe.Tracker.of(r,{verb:Pe.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:qe,required_keys:Ne,optional_keys:Be.concat(Ue).slice(0),metadata:s});r.on(A,(function(){a&&a.destroy()})),r.on(L,(function(e){if(!a)return;const n=Ft(e,"data.metadata",{});if(!n.media_id)return;const s=Ft(a,"metadata.media_id");if(s&&n.media_id==s)return;const o=Ft(t,"analytics",{});a.put(n),a.put(o);const l=Ft(t,"metadata.live_start_time",t.live)?Ve:Ke;a.put({video_type:l,source:t.source||Ye()||""}),i.ticker=t.live?{ticks:0,last_tracked_ts:Date.now(),kind:"live"}:{last_idx:0,segment_duration:0,breakpoints:[],kind:"vod"},i.ended=!1,r.emit(Me)}));let o=0;r.on(v,(function(){if(!a)return;if(o||function(t,e){return t.metadata.media_id&&t.metadata.media_id==e.last_media_id}(a,i))return;a.put({muted:r.muted});const t=ze(r);if(t)return o=Promise.resolve(t).then((function(){i.last_media_id=a.metadata.media_id,r.emit(Fe),o=0})).catch((function(){o=0}));i.last_media_id=a.metadata.media_id,r.emit(Fe)})),r.on("timeupdate",(function(){var e;a&&(o||ze(r)||i.ended||(!t.live&&r.currentTime+.25>=r.duration&&We(r,i.ticker,!0),(e=n).locked||(e.locked=setTimeout((function(){return e.task(),function(t){return t.locked=!1,t}(e)}),e.ttl))))})),r.on(_,(function(){a&&i.ticker&&"vod"==i.ticker.kind&&function(t,e){Ge(t,e),e.last_idx=He(t,e)}(r,i.ticker)})),r.on(T,(function(){a&&function(t,e){e.ended||(e.ended=!0,We(t,e.ticker))}(r,i)}))}}var Xe;function Qe(t){switch(t){case Xe.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case Xe.MEDIA_ERR_NETWORK:return"a network error occurred";case Xe.MEDIA_ERR_DECODE:return"unable to decode media content";case Xe.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case Xe.NO_INTERNET:return"no internet connection detected";case Xe.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}function $e(){}function Je(){return"https:"===location.protocol}function Ze(t){const e=document.createElement("a");return e.href=t,e}function tr(t){try{return!!new URL(t)}catch(t){return!1}}ee(re(),Analytics$1),"undefined"!=typeof window&&window.matchMedia&&[w,k].forEach((function(t){window.matchMedia("(orientation: "+t+")").addListener((function(r){e.length&&e.forEach((function(e){r.matches&&e.emit(t)}))}))})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",t[t.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",t[t.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",t[t.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",t[t.MIXED_CONTENT=1001]="MIXED_CONTENT",t[t.NO_INTERNET=1002]="NO_INTERNET"}(Xe||(Xe={}));const er=()=>!0===(navigator||{}).onLine;function rr(t,e,r){r.on(i,(function(t){const e=t.data||r.error||new Error,i=t.code||e.code,n="Error: %s\n"+(null===(s=(new Error).stack)||void 0===s?void 0:s.split("\n").slice(2).join("\n"));var s;setTimeout((function(){if(t.defaultPrevented)return;if("AbortError"==e.name)return;r.setState("is-error",!0),8===i||e.fatal||function(t){const e=t.togglePlay,r=t.root;t.togglePlay=$e,t.once("recover",(function(){t.togglePlay=e,t.setState("is-error",!1);const i=r.querySelector(".fp-error");i&&i.remove()}))}(r);const s=function(t,e,r){switch(e){case"http:0":return function(t){return function(t){try{return Je()&&"http:"==Ze(t).protocol}catch(t){return!1}}(t.original_src)?{code:Xe.MIXED_CONTENT}:er()?{code:Xe.MEDIA_ERR_NETWORK}:er()?{code:Xe.UNKNOWN}:{code:Xe.NO_INTERNET}}(t);case Xe.MEDIA_ERR_SRC_NOT_SUPPORTED:return t.once(g,(function(){t.emit("recover")})),r;default:return r}}(r,i,e),a=function(t,e){if(e.message)return e.message;if(e.stack)return e.stack;const r=e.code||-1,i=Qe(r);return t.i18n("media_errors."+r,i)}(r,s);console.error(n,a);const o=r.reaper&&r.reaper.get("ui");return o&&function(t,e,r,i){if(!t)return;const n=document.createElement("div");if(n.classList.add("fp-error"),n.innerText=e,i){const e=t.querySelector("#"+i);e&&t.removeChild(e),n.id=i}if(t.append(n),r){const t=document.createElement("div");t.classList.add("fp-error-details"),t.innerText=r,n.append(t)}}(o,a,e.details)}))}))}var ir=Object.freeze({__proto__:null,NO_FULLSCREEN:1,NO_VOLUME_CONTROL:2,NO_MUTE:4,LOGO_ON_RIGHT:8,USE_DRAG_HANDLE:16,USE_PLAY_2:32,USE_PLAY_3:64,USE_THIN_CONTROLBAR:128,NO_TITLE:256,NO_DESCRIPTION:512,NO_CONTROLS:1024,NO_DURATION:2048,NO_HEADER:4096,AUDIO_ONLY:8192,NO_TOUCH_ZONES:16384});function nr(t,e,r){let i=()=>document.fullscreenElement,n="fullscreenchange";if(!Element.prototype.requestFullscreen){const t=Element.prototype,e=document;t.webkitRequestFullScreen&&(t.requestFullscreen=t.webkitRequestFullScreen,e.fullscreenEnabled=!0),e.webkitCancelFullScreen&&(document.exitFullscreen=e.webkitCancelFullScreen),n="webkit"+n,i=()=>e.webkitCurrentFullScreenElement}const a=()=>r.getFullsceenTarget?r.getFullsceenTarget():e;r.toggleFullScreen=function(t,e){if(r.ios_fullscreen_disabled)return;if("boolean"!=typeof t&&(t=!r.hasState("is-fullscreen")),sr(r)&&(t?function(t){t.getAttribute("playsinline")&&t.removeAttribute("playsinline");t.getAttribute("webkit-playsinline")&&t.removeAttribute("webkit-playsinline");t.webkitEnterFullScreen()}(r):function(t,e){t.getAttribute("playsinline")||t.setAttribute("playsinline","");t.getAttribute("webkit-playsinline")||t.setAttribute("webkit-playsinline","");e||t.webkitExitFullScreen();t.togglePlay(!1),t.hasState(st)||t.setState(st,!0)}(r,e)),!document.fullscreenEnabled)return;const i=a();t?i.requestFullscreen():document.exitFullscreen()},sr(r)&&(r.ios_fullscreen_disabled=!0,r.once("beforeplay",(function(){r.ios_fullscreen_disabled=!1})),r.on("webkitendfullscreen",(function(){r.toggleFullScreen(!1,!0)}))),setTimeout(()=>{const t=a();t.addEventListener(n,(function(){const e=i(),n=e===t||e==r;r.emit(n?d:c),r.setState("is-fullscreen",n)}))},0),!1!==t.doubleclick&&e.addEventListener(s,(function(t){var e;t.target&&(null===(e=t.target)||void 0===e?void 0:e.classList.contains("fp-ui"))&&r.toggleFullScreen()}))}function sr(t){return r().ios&&"function"==typeof t.webkitEnterFullScreen&&"function"==typeof t.webkitExitFullScreen}function ar(t,e){if("object"!=typeof t.opts)return{head:0,tail:0};if(0==t.seekable.length)return{head:0,tail:0};const r=e||t.opts.dvr_window,i=t.seekable.end(t.seekable.length-1);return{head:i,tail:r?i-r:t.seekable.start(0)}}function or(t){return t.opt("live",!1)||t.duration>=Number.MAX_SAFE_INTEGER}function lr(t){return isFinite(t.duration)?t.duration:0==t.seekable.length?0:ar(t).head}function ur(t){return cr(t)-.5}function dr(t){return ar(t).tail}function cr(t){return ar(t).head}function hr(t){return Math.min(100,Math.max(0,(t.currentTime-dr(t))/(cr(t)-dr(t))*100))}function fr(t,e,r){if(!r.reaper)return;const i=document.createDocumentFragment(),n=pt(r,D);i.appendChild(n),r.reaper.set("ui",n),~e.className.indexOf("use-play-")||e.classList.add("use-play-1"),function(t,e,r){const i=Mt("fp-footer");e.append(i),r.on(L,(function(t){var e,r;const n=null===(e=t.data)||void 0===e?void 0:e.description,s=null===(r=t.data)||void 0===r?void 0:r.title;if(i.innerHTML="","string"==typeof s){const t=Mt("fp-title");t.innerText=s,i.append(t)}if("string"==typeof n){const t=n.split(" "),e=Mt("fp-desc");for(e.innerText=t.join(" "),i.append(e);t.length>1&&e.scrollHeight>e.offsetHeight;)t.pop(),e.innerText=t.join(" ")+"..."}}))}(0,e,r),rr(0,0,r),e.appendChild(i),[o,l].forEach(t=>{e.addEventListener(t,(function(t){r.setState("is-hovered",t.type==o),r.setState("is-accessibility",!1)}))}),nr(t,e,r),r.on("volumechange",(function(){const t=0==r.volume||r.muted;r.setState("is-muted",t),r._storage.setItem("mute",t.toString())})),"true"==r._storage.getItem("mute")&&(r.muted=!0,r.setState("is-muted",r.muted));const s=r._storage.getItem("volume");s&&!isNaN(Number(s))&&(r.volume=Number(s)),r.emit("volumechange"),r.on("dvr/window",e=>{var i;t.live&&(!("dvr"in(i=t))||1==i.dvr)&&function(t,e,r){if(0==e)return!0;const i=ar(t,r);return i.head-i.tail>=e}(r,t.seconds_to_dvr||60,e.detail)&&(r.setOpts({dvr:r.seekable.length>0}),r.seekable.length>0&&r.setOpts({dvr_window:e.detail}))}),r.on("live",(function(){r.setState("is-live-seeked",!1)})),r.on("seeking",(function(){if(!or(r))return;if(0==r.seekable.length)return;if(0==lr(r))return;const t=ur(r),e=r.currentTime>=t?"live":"dvr";if("live"===e)return r.emit(e);const i=lr(r),n=ar(r),s=(i-r.currentTime)/(n.head-n.tail)*100,a=Math.round(s);r.setState("is-live-seeked",a>0),r.emit(e,{offset:a})})),r.on(h,(function(){r.setOpts({live:or(r)})})),r.on("durationchange",(function(t){const e=or(r),i=e?lr(r):t.data||r.duration;isNaN(i)||r.setOpts({live:e,duration:i})})),r.on(L,(function(r){var i,n;t.seekable=void 0===(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.seekable)||r.data.seekable;const s=null===(n=r.data)||void 0===n?void 0:n.ui;if("number"!=typeof s)return;const a=e.classList;a.toggle("use-play-1",!(32&s||64&s)),a.toggle("use-play-2",(32&s)>0),a.toggle("use-play-3",(64&s)>0),a.toggle("use-thin-controlbar",(128&s)>0),a.toggle("no-title",(256&s)>0),a.toggle("no-description",(512&s)>0),a.toggle("logo-on-right",(8&s)>0),a.toggle("use-drag-handle",(16&s)>0),a.toggle("no-controls",(1024&s)>0),a.toggle("no-duration",(2048&s)>0),a.toggle("no-header",(4096&s)>0),a.toggle("no-mute",(4&s)>0),a.toggle("no-volume",(2&s)>0),a.toggle("no-fullscreen",(1&s)>0),a.toggle("no-touch-zones",(16384&s)>0)}));let a=null;n.addEventListener("mousemove",(function(){"number"==typeof a&&clearTimeout(a),r.setState("is-hovered",!0),a=0==r.paused&&setTimeout((function(){r.setState("is-hovered",!1)}),2e3)}))}function pr(t,e,r){if(ue.from_token(t.token||"").is_granted(ue.permissions.NO_METERING))return;const i=ae.id(t.token||"");i&&r.once(v,()=>function(t,e){fetch("https://pmi.flowplayer.com/in",{method:"POST",body:JSON.stringify({token_id:e,factor:1,rnd:Math.random().toString(36).substring(2)})}).then(e=>{401==e.status&&t.emit("error:fatal",{reason:"token",details:"The token online validation failed"})})}(r,i))}var gr={ads:{ad:"Ad",ads:"Ads",advertisement:"Advertisement"},audio:{button_txt:"Audio",menu_title:"Audio"},core:{exit_fullscreen:"Exit fullscreen",fullscreen:"Fullscreen",mute:"Mute",pause:"Pause",play:"Play",unmute:"Unmute",volume:"Volume"},ovp:{starting_in:"Countdown"},playlist:{cancel:"Cancel",up_next:"Up next"},qsel:{menu_title:"Quality"},share:{clipboard_failure:"Access to clipboard failed",clipboard_success:"The text is now on your clipboard",embed:"Embed",link:"Link",menu_title:"Share"},speed:{menu_title:"Speed"}};class I18n{init(t,e,r){r.reaper&&r.reaper.set("translations",Gt(I18n,t,"en"))}}I18n.en=gr;const mr="health:record",vr="rebuffer";var yr=Object.freeze({__proto__:null,RECORD:mr,REBUFFER:vr});function Er(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(...i)=>{const n=(null==e?void 0:e.debug)||r;n&&t.match(n)&&console.log(t,...i)};return i.log=i,i}const Tr=navigator;function _r(t){var e,r;const i=null===(e=t.hls)||void 0===e?void 0:e.bandwidthEstimate;return i?1e-6*i:(null===(r=Tr.connection)||void 0===r?void 0:r.downlink)||-1}function br(t,e){return function(t,e){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,e)}(t,JSON.stringify({events:e}))}const Sr="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),Ar=window,Lr=Ar._flowplayerTimekeeper||(Ar._flowplayerTimekeeper={});async function wr(){const t=Lr.cachedServerOffset;if(t)return t;const e=Lr.pendingRequest||(Lr.pendingRequest=fetch(Sr)),r=await e,i=parseInt(r.headers.get("age")||"0"),n=await r.json(),s=Date.now()-n.millisUtc-1e3*i;return Lr.cachedServerOffset=s,Lr.cachedServerOffset}const kr=t=>{switch(t){case!0:return vt.ON;case!1:return vt.OFF;default:return t}},Rr=[];function Dr(t){if(t.suspended)return;const e=Rr.slice(0);Rr.length=0,0!=e.length&&(t.logger.log(`:dispatch events={${e.length}}`),br("https://health.flowplayer.com/v1/health/events",e))}async function Or(t,e,r){const i=await Cr();Rr.push(Object.assign(e,i)),t.logger.log(":enqueue",e.event,e),Rr.length<10&&!r||Dr(t)}const Ir=()=>{var t,e;try{const r=window;return null===(e=null===(t=null==r?void 0:r.google)||void 0===t?void 0:t.ima)||void 0===e?void 0:e.VERSION}catch(t){return}},Cr=async()=>{try{const t=await wr();return{timestamp:Date.now()-t,adjustedTimestamp:!0}}catch(t){return{timestamp:Date.now(),adjustedTimestamp:!1}}},Pr=(t,e)=>Object.assign(t,{detail:e}),xr=(t,{event:e,media_session_id:r,session_id:i})=>({event:e,media_session_id:r,session_id:i,device_id:t.deviceId(),version:"3.1.0-rc.2",commit:"f1b2a64310ddd065f3012d9728939b5d0b1bed26",ima_sdk_version:Ir(),preload:t.opt("preload"),autoplay:kr(t.opt("autoplay")),live:t.opt("live"),dvr:t.opt("dvr"),source:t.original_src,downlink_mbs:_r(t),player_id:t.opt("metadata.player_id"),media_id:t.opt("metadata.media_id"),site_id:t.opt("metadata.site_id"),category_id:t.opt("metadata.category_id"),sitegroup_id:t.opt("metadata.sitegroup_id"),token:t.token,plugins:t.plugins.map(t=>t.constructor.name).sort((t,e)=>t.localeCompare(e)),current_time:t.currentTime,external_media_id:t.opt("external_media_id")}),Mr=t=>({bitrate:null==t?void 0:t.bitrate,resolution:null==t?void 0:t.attrs.RESOLUTION,frame_rate:null==t?void 0:t.attrs["FRAME-RATE"]});function Fr(t,e,r,i){const n=xr(e,t.eventInfo(r)),{before:s,after:a}=i;Or(t,((t,e,r)=>Object.assign(t,{state:{before:e,after:r}}))(n,Mr(s),Mr(a)))}const Nr=(t,e)=>{let r=null;return(...i)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>e(...i),t)}},Ur=Ht();class Health{constructor(t,e){this.session_id=Ur,this.suspended=!1,this.logger=Er("health",e.opts),this.media_session_id=Ht(),this.analyticsLoop=setInterval(()=>Dr(this),2e3),e.on(A,()=>clearInterval(this.analyticsLoop));const r=this;if(e.health={get media_session_id(){return r.media_session_id},set media_session_id(t){r.media_session_id=t},get session_id(){return r.session_id},set session_id(t){r.session_id=t},toggle(t){t?r.resume():r.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const e=e=>t.instances.forEach(t=>t.emit(e.type));document.addEventListener("visibilitychange",t=>{"hidden"==document.visibilityState&&e(t)}),window.addEventListener("pagehide",e)}}eventInfo(t){return{event:t,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>Dr(this),2e3)}init(t,e,r){!function(t){t.on(y,(function(e){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(vr)}))}(r),r.on(mr,({detail:t})=>{const e=xr(r,this.eventInfo(t.event));Object.assign(e,t.detail||{}),Or(this,e)}),[E,g,a,h,f,p,y,vr].forEach(t=>{r.on(t,t=>{Or(this,xr(r,this.eventInfo(t.type)))})}),[v,m,b,_,T,d,c].forEach(t=>{r.on(t,t=>{Or(this,xr(r,this.eventInfo(t.type)))})}),r.on("volumechange",Nr(800,t=>{const e=xr(r,this.eventInfo(t.type));Or(this,Pr(e,{volume:parseFloat(r.volume.toFixed(2)),muted:r.muted}))})),r.on("resize",Nr(800,t=>{const i=xr(r,this.eventInfo(t.type));Or(this,Pr(i,{height:e.clientHeight,width:e.clientWidth}))})),r.on("qualitychange",({type:t,detail:e})=>{switch(e.kind){case"hls":return Fr(this,r,t,e)}});let n=Date.now()+5e3;r.on("timeupdate",t=>{if(Date.now()<n)return;n=Date.now()+5e3;const e=xr(r,this.eventInfo(t.type));var i;Or(this,Pr(e,{duration:(i=r.duration,Number.isFinite(i)?i:i===1/0?-1:void 0)}))}),r.addEventListener(i,t=>{const e=xr(r,this.eventInfo(t.type)),i=t.error||r.error;if(!i)return Or(this,e,!0);const n=i.code,s={error_message:i.message||Qe(n),error_code:n,error_stack:i.stack||""};return Or(this,Pr(e,s),!0)}),r.on(S,t=>{var e;const i=null===(e=t.detail)||void 0===e?void 0:e.src;if("string"!=typeof i)return;if(!tr(r.original_src))return;if(!tr(i))return;if(i==r.original_src)return;this.media_session_id=Ht();Or(this,xr(r,this.eventInfo(t.type))),Dr(this)}),r.on("visibilitychange",t=>{Or(this,xr(r,this.eventInfo(t.type))),Dr(this)})}}var Br;function Gr(t,e){if(function(t){return Object.values(Br).includes(t)}(e=e||Br.Anonymous))return t instanceof HTMLVideoElement&&(t.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in t?t.crossOrigin=e:t.setAttribute("crossorigin",e),t}function jr(t){const e=document.createElement("a");return e.href=t,e.origin}function Hr(t,e){const r=document.createElement("track");r.className="fp-track renderable",r.kind=e.kind||"captions",r.id=["fp",e.lang].join("-");const i=r.track;return"string"!=typeof e.crossorigin&&function(t,e){try{return t.src.startsWith("blob:"),jr(t.src)!==jr(e)}catch(t){return console.error(t),!0}}(t,e.src)&&(Gr(t),e.crossorigin=t.getAttribute("crossorigin")),"crossorigin"in e&&Gr(t,e.crossorigin),Object.keys(e).forEach(t=>{"default"!==t&&(r[t]=e[t])}),i.mode=e.default?"hidden":"disabled",r.onload=function(){},i.oncuechange=function(e){t.emit(e.type,{track:e.target})},t.appendChild(r),r}Health.events=yr,Health._UNLOAD_SUBSCRIBED=!1,ee(window,Health),function(t){t.Anonymous="anonymous",t.UseCredentials="use-credentials",t.Empty=""}(Br||(Br={}));var Kr=Object.freeze({__proto__:null,CHAPTER_CHANGED:"chapter:changed",CHAPTERS_NEW:"chapters:new"});class Chapters{constructor(){this._track_added_handler=$e,this._cue_changed_handler=$e,this.chapters=[],this.render=this.render.bind(this)}init(t,e,r){this._root=e,this._player=r,this._timeline=Pt(r,P),this._track_added_handler=this.track_added.bind(this,r),this._cue_changed_handler=this.cue_changed.bind(this,r),r.textTracks.addEventListener("addtrack",this._track_added_handler),this.wireup(r,t),r.chapters=this,r.on(L,t=>{t.data&&this.wireup(r,t.data)}),r.on(A,()=>{this.wiredown(r),r.textTracks.removeEventListener("addtrack",this._track_added_handler),r.off("durationchange",this.render)}),r.on("durationchange",this.render)}track_added(t,e){}cue_changed(t,e){var r;this._current_chapters_track&&(this.current_cue=this._current_chapters_track.track.activeCues?this._current_chapters_track.track.activeCues[0]:void 0,this._timeline&&Wt(this._timeline,"chapter:changed",null===(r=this.current_cue)||void 0===r?void 0:r.text))}set_chapters(t){this.chapters=t,this.render()}jump(t){this._player&&this.chapters[t]&&(this._player.currentTime=this.chapters[t].start)}current(){if(this.current_cue)return this.chapters.find(t=>t.cue==this.current_cue)}render(){if(!this._root||!this._player||!this._timeline)return;const t=this._player.duration;isFinite(t)&&(Wt(this._timeline,"chapters:new",this.chapters.map(e=>({title:e.label,left:e.start/t*100+"%",width:(e.end-e.start)/t*100+"%"}))),this._root.classList.toggle("has-chapters",!!this.chapters.length))}wireup(t,e){const r=Array.isArray(e.chapters)?e.chapters[0]:e.chapters;r&&r.src!==this._current_chapters_src&&(this.wiredown(t),this._current_chapters_track=Hr(t,Object.assign(Object.assign({},r),{kind:"chapters",default:!0})),this._current_chapters_track.onload=()=>{var t;(null===(t=this._current_chapters_track)||void 0===t?void 0:t.track.cues)&&this.set_chapters(Array.from(this._current_chapters_track.track.cues).filter(t=>t instanceof VTTCue).map(t=>{const e=t;return{start:t.startTime,end:t.endTime,cue:e,label:e.text}}))},this._current_chapters_src=r.src,this._current_chapters_track.addEventListener("cuechange",this._cue_changed_handler))}wiredown(t){this.set_chapters([]),this._current_chapters_track&&(this._current_chapters_track.removeEventListener("cuechange",this._cue_changed_handler),t.removeChild(this._current_chapters_track))}}Chapters.events=Kr,ee(window,Chapters);class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerPrimary extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-primary");const e={logo:""};t.on(L,t=>{var r,i;const n=e.logo,s=(null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.logo)||"";n!=s&&(e.logo=s,this.set_logo(s,null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.logo_href))})}set_logo(t,e){if(this.innerHTML="",!t)return;const r=document.createElement("img");if(r.classList.add("fp-logo"),r.src=t,!e)return this.append(r);const i=document.createElement("a");i.href=e,i.append(r),this.append(i)}}class FlowplayerHeaderDuration extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-duration"),t.on(L,t=>{var e;const r=(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.duration)||NaN;this.innerText=isFinite(r)?Ut(r):""})}}const Vr={name:"fp-fullscreen",translation_key:"core.fullscreen"},qr={name:"fp-fullscreen-exit",translation_key:"core.exit_fullscreen"},Wr={name:"fp-play",translation_key:"core.play"},zr={name:"fp-pause",translation_key:"core.pause"},Yr={translation_key:"core.mute",name:"fp-volume-mute-unmute"},Xr={translation_key:"core.play",name:"fp-small-play"},Qr={translation_key:"core.pause",name:"fp-small-pause"},$r={name:"fp-fast-forward"},Jr={name:"fp-rewind"};class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}document.addEventListener(n,(function(t){this.active_menu&&!t.composedPath().includes(this.active_menu)&&(Array.from(document.querySelectorAll(".fp-engine")).forEach(t=>{const e=t.root.querySelector("details[open].fp-menu-container");e&&(e.open=!1,t.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const Zr={passive:!0};var ti;function ei(t,e){let r=0,i=-1,n=-1;const s=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),a=t.classList;t.id=s,a.remove(ti.GRABBING),a.remove(ti.TOUCHING);const o=e.onseek||$e,l=e.onstart||$e,d=e.onend||$e,c=e.onmouse||$e,h=e.ontouch||$e,f=e.ontouchend||$e;function p(e){!function(){const e=t.getBoundingClientRect();r=e.left,i=e.width}();let n=(function(t){return"function"==typeof window.TouchEvent&&t instanceof TouchEvent}(e)?e.changedTouches[0].pageX:e.pageX)-r;return n>i&&(n=i),n<0&&(n=0),n/i*100}function g(e){const r=p(e);r!=n&&(o(t,r),n=r)}return t.addEventListener("touchstart",(function(e){ri(t,e)&&(a.add(ti.TOUCHING),ii(t.parentElement)&&(a.add(ti.GRABBING),h(t,p(e)),l(t,p(e)),g(e)))}),Zr),t.addEventListener("touchmove",(function(e){g(e),c(t,p(e))}),Zr),t.addEventListener(u,(function(e){setTimeout((function(){a.remove(ti.TOUCHING)}),500),ri(t,e)&&(a.remove(ti.GRABBING),f(t,p(e)),d(t,p(e)),i=0)}),Zr),t.addEventListener("touchcancel",(function(){a.remove(ti.GRABBING,ti.TOUCHING),i=0}),Zr),t.addEventListener("mousedown",(function(e){a.contains(ti.TOUCHING)||(document.addEventListener("mousemove",g),a.add(ti.GRABBING),l(t,p(e)),e.preventDefault(),g(e))})),t.addEventListener("mousemove",(function(e){a.contains(ti.TOUCHING)||c(t,p(e))})),document.addEventListener("mouseup",(function(e){a.contains(ti.TOUCHING)||(document.removeEventListener("mousemove",g),a.contains(ti.GRABBING)&&(a.remove(ti.GRABBING),d(t,p(e)),i=0))})),t}function ri(t,e){const r=e.target;return!!r&&(r&&!r.closest(t.id)||!ii(t.parentElement)||!t.classList.contains(ti.TOUCHING))}function ii(t){if(!t)return!1;const e=window.getComputedStyle(t);return"0"!==e.width&&"0"!==e.height&&"0"!==e.opacity&&"none"!==e.display&&"hidden"!==e.visibility}!function(t){t.GRABBING="has-grab",t.TOUCHING="has-touch"}(ti||(ti={}));class FlowplayerVolumeBar extends FlowplayerComponent{constructor(t){super(t),this.className="fp-volume";const e=t.root.classList,r=e.contains("is-tiny")?6:e.contains("is-small")?8:10,i=Array.from({length:r}).map(()=>{const t=document.createElement("i");return t.className="fp-tick",t});this.append(...i),ei(this,{onseek:(e,r)=>{r>0&&(t.muted=!1,t._storage.removeItem("mute")),t._storage.setItem("volume",(t.volume=r/100).toString()),this.adjustVolumeSlider(t.volume)}}),this.setAttribute("tabindex","0"),this.setAttribute("role","slider"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax","1"),this.setAttribute("aria-label",t.i18n("core.volume","volume")),t.on("volumechange",()=>{const e=0==t.volume||t.muted;e&&this.adjustVolumeSlider(0);const r=t.opt("ui");this.classList.contains(ti.GRABBING)||e&&"number"==typeof r&&(4&r)>0||this.adjustVolumeSlider(t.volume)})}adjustVolumeSlider(t){this.setAttribute("aria-valuenow",t.toString());const e=Array.from(this.querySelectorAll(".fp-tick")),r=Math.round(t*e.length);e.forEach((t,e)=>{t.classList.toggle("fp-color",e<r)})}}function ni(t,e){if(!t.parentElement)return;const r=t.clientWidth/t.parentElement.clientWidth*100/2;t.style.left=e-r+"%",t.style.display="block"}function si(t,e){if(isNaN(t.duration))return;const r=t.buffered;r.length&&(e.style.width=Math.min(r.end(r.length-1)/t.duration*100,100)+"%")}function ai(t,e){t.style.width="0",e.style.display="none"}function oi(t,e,r){if(!e.seekable||0==e.seekable.length)return;ni(r,t);const i=ar(e),n=(100-Math.max(0,Math.min(t,100)))/100*(i.head-i.tail);r.innerText="-"+Ut(n)}function li(t,e){t/=100,e.currentTime=function(t,e){if(e>1||e<0)return console.warn("cannot calculate a percent outside of range(0..1)"),0;const r=ar(t);return r.tail+e*(r.head-r.tail)}(e,t)}function ui(t,e){t.style.width="0",e.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(t){let e;super(t),this.bufferEle=Mt("fp-buffer"),this.progress=Mt("fp-progress","fp-color"),this.tooltipEle=Mt("fp-timestamp"),this.proposedSeekBar=Mt("fp-hover"),this.dragger=Mt("fp-dragger","fp-color"),this.classList.add("fp-timeline","fp-bar"),this.tooltipEle.style.display="none",this.setAttribute("role","slider"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",t.i18n("timeline","Timeline")),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);let r=!1;const n=requestAnimationFrame;let s=void 0;const a=()=>{0==t.reaper||e.live||(!function(t,e){e.style.width=t.currentTime/t.duration*100+"%"}(t,this.progress),s=void 0,t.paused||this.classList.contains(ti.GRABBING)||s||(s=setTimeout(a,200)))},o=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);ei(this,{onseek:(r,i)=>{if(o())switch(!!e.live){case!0:oi(i,t,this.tooltipEle);break;case!1:!function(t,e,r){const i=e.duration*(t/100);if(e.disabled&&i>e.currentTime)return!1;r.style.width=t+"%",e.currentTime=i}(i,t,this.progress),ni(this.tooltipEle,i)}},onstart:()=>{o()&&(t.emit("timeline/gesture/start"),t.setState(tt,!0),e.live||function(t){t.style.display="block"}(this.tooltipEle))},onend:function(r,i){n(a),0!=e.seekable&&e.live&&li(i,t)},ontouch:function(){t.paused||(r=!0,t.pause())},ontouchend:()=>{r&&(r=!1,t.play()),e.live?ui(this.proposedSeekBar,this.tooltipEle):ai(this.proposedSeekBar,this.tooltipEle)},onmouse:(r,i)=>{if(o()&&!this.classList.contains(ti.GRABBING))switch(t.emit("timeline/gesture/move",{percent:i}),!!e.live){case!0:!function(t,e){e.style.width=t+"%"}(i,this.proposedSeekBar),oi(i,t,this.tooltipEle);break;case!1:!function(t,e){e.style.width=t+"%"}(i,this.proposedSeekBar),function(t,e,r){if(isNaN(t)||isNaN(e.duration))return;ni(r,t),r.innerHTML="";const i=document.createElement("span");i.innerText=Ut(t/100*e.duration),r.append(i)}(i,t,this.tooltipEle)}}}),t.on(L,(function(t){t.data&&(e=t.data)})),t.on(v,()=>n(a)),t.on("live",()=>{this.progress.style.width="100%"}),t.on(p,()=>{0==t.reaper||e.live||si(t,this.bufferEle)}),t.on("dvr",t=>{t.detail&&(this.progress.style.width=100-t.detail.offset+"%")}),t.on("timeupdate",()=>{0!=t.reaper&&(n(a),this.setAttribute("aria-valuenow",t.currentTime+""),e.live||si(t,this.bufferEle))}),t.on(h,()=>{0!=t.reaper&&(e.live||si(t,this.bufferEle))}),t.on("durationchange",e=>{if(0==t.reaper)return;const r=or(t)?lr(t):e.data||t.duration;isNaN(r)||(this.setAttribute("aria-valuemax",r+""),this.setAttribute("aria-valuemin","0"))}),t.on(S,()=>{t.once("beforeplay",()=>{t.hasState(rt)&&!t.hasState(nt)&&(this.progress.style.width=hr(t)+"%")})}),t.on(m,()=>{if(!t.hasState(rt)||t.hasState(nt))return;const e=setInterval(()=>{if(t.hasState(nt))return r();this.progress.style.width=hr(t)+"%"},1e4);function r(){clearInterval(e),[v,i,S,A].forEach(e=>{t.removeEventListener(e,r)})}t.on([v,i,S,A],r)}),this.addEventListener(l,()=>{t.emit("timeline/gesture/end"),e.live?ui(this.proposedSeekBar,this.tooltipEle):ai(this.proposedSeekBar,this.tooltipEle)})}}class FlowplayerChaptersTimelineBar extends FlowplayerTimelineBar{constructor(t){super(t),this.handleChapters(t)}handleChapters(t){const e=document.createElement("div");let r;this.addEventListener("chapters:new",t=>{e.innerText="",this.querySelectorAll(".fp-chapter").forEach(t=>this.removeChild(t)),t.data&&t.data.forEach(t=>{const i=document.createElement("div");i.className="fp-chapter",i.style.left=t.left,i.style.bottom=i.style.top="0",i.style.width=t.width,i.title=t.title,i.onmouseover=()=>{e.innerText=t.title},i.onmouseleave=()=>{e.innerText=r||""},this.appendChild(i)})}),this.addEventListener("chapter:changed",i=>{var n;const s=i.data;s&&(e.parentNode||(null===(n=Pt(t,O))||void 0===n||n.insertAdjacentElement("beforebegin",e),e.classList.toggle("fp-togglable",!0),e.classList.toggle("fp-chapter-info",!0)),r=s,e.innerText=s)})}}class FlowplayerLiveStatus extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-live-status");const e=Mt("fp-live-text"),r=Mt("fp-live-indicator","fp-color");e.textContent="live",this.append(r,e),this.addEventListener(n,(function(){!function(t){try{if(!t.hasState("is-live-seeked"))return;t.emit("live"),t.dvr_offset=0,t.currentTime=ur(t)}catch(t){console.warn("failed to seek to now: %j",t)}}(t)}))}}class FlowplayerDuration extends FlowplayerComponent{constructor(t){let e;super(t),this.classList.add("fp-duration"),t.on(L,r=>{if(0==t.reaper||!r.data)return;e=r.data;const i=or(t)?NaN:r.data.duration||0;if(isNaN(i)||i>=Number.MAX_SAFE_INTEGER)return this.style.display="none";this.style.display="inline-block",this.innerText=Ut(i)}),t.on(h,()=>{0==t.reaper||e.live||function(t,e){t.duration&&(e.innerText=Ut(t.duration))}(t,this)})}}class FlowplayerElapsedTime extends FlowplayerComponent{constructor(t){let e;super(t),this.classList.add("fp-elapsed"),this.innerText=Ut(0),t.on(L,t=>{t.data&&(e=t.data)}),t.on("timeupdate",()=>{0!=t.reaper&&(e.live?function(t,e){e.innerText=Ut(t.currentTime)}(t,this):function(t,e){e.innerText=Ut(t.currentTime)}(t,this))})}}class FlowplayerControlButtons extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-btns","fp-small-switch");const e=pt(t,H),r=pt(t,j);e.addEventListener("click",(function(){t.togglePlay(),setTimeout((function(){r.focus&&r.focus()}),100)})),r.addEventListener("click",(function(){t.togglePlay(),setTimeout((function(){e.focus&&e.focus()}),100)})),this.append(e,r)}}class FlowplayerLeftRightZone extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add(e);const r=this.classList.contains("fp-left-zone")?-1:1,i=document.createElement("span"),n=pt(t,this.classList.contains("fp-left-zone")?q:"flowplayer-fast-forward-icon");n.removeAttribute("tabindex"),i.classList.add("fp-zone-seconds"),this.append(i,n);t.on(_,()=>{i.innerText=""}),t.on("seek:queued",t=>{const e=t.data;if(!e)return;if("number"!=typeof e.offset)return;const r=e.offset;if(0==r)return this.reset_zone();r>0&&this.classList.contains("fp-right-zone")||r<0&&!this.classList.contains("fp-right-zone")?this.render_zone_state(r):this.reset_zone()}),t.on("seek:cancel",()=>{this.reset_zone()}),this.reset_zone(),this.addEventListener(u,(function(e){isNaN(t.duration)||isNaN(t.currentTime)||16384&t.opt("ui")||t.hasState(nt)||!t.hasState("will-seek")&&!t.hasState(st)||t.enqueueSeek(5*r)&&(e.stopPropagation(),e.preventDefault())}))}reset_zone(){const t=this.querySelector(".fp-zone-seconds");t&&(t.innerText="")}render_zone_state(t){const e=this.querySelector(".fp-zone-seconds");e&&(e.innerText=Math.abs(t)+"")}}class FlowplayerHeaderLeftRight extends FlowplayerComponent{constructor(t,e,...r){super(t),this.className=e;const i=t.createComponents(...r);this.append(...i),"fp-left"!==e&&i.forEach(e=>{e.addEventListener(n,()=>t.toggleFullScreen())})}}class FlowplayerMiddleWait extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-wait"),Array(...Array(4)).map((t,e)=>e).forEach(()=>{this.append(document.createElement("b"))})}}class FlowplayerMiddleZone extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-middle-zone");const e=t.createComponents(G,"flowplayer-middle-buttons");this.append(...e)}}class FlowplayerMiddleButtons extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-switch"),[K,V].forEach(e=>{const r=pt(t,e);r.removeAttribute("tabindex"),this.append(r)})}}class FlowplayerVolumeControl extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-volume-control");const e=pt(t,W);this.append(e),!r().ios&&this.append(pt(t,x)),e instanceof FlowplayerIcon&&e.addEventListener(n,(function(){t.toggleMute()}))}}class FlowplayerHeader extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-header"),this.append(...t.createComponents("flowplayer-header-left-zone",F)),t.reaper&&t.reaper.set("header",this)}}class FlowplayerControls extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-controls","fp-togglable"),this.append(...t.createComponents("flowplayer-control-buttons",I,C,P,"flowplayer-control-duration","flowplayer-volume-control"))}}class FullscreenIcon extends FlowplayerIcon{constructor(t,e){super(t,e),this.setAttribute("role","button"),this.setAttribute("aria-label",t.i18n(e==Vr?"core.fullscreen":"core.fullscreen_exit"))}}class FlowplayerMiddle extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-middle"),this.append(...t.createComponents("flowplayer-middle-left-zone",B,"flowplayer-middle-right-zone")),this.setAttribute("tabindex","0"),this.setAttribute("role","button"),this.setAttribute("aria-label",t.i18n("core.play")),t.reaper&&t.reaper.set("middle",this),this.handleClick(t),this.handleTouch(t),[v,_].forEach(e=>t.once(e,()=>{this.removeAttribute("tabindex"),this.removeAttribute("role"),this.removeAttribute("aria-label")}))}handleClick(t){[n,s].forEach(e=>this.addEventListener(e,(function(e){if(!e.defaultPrevented)return e.preventDefault(),t.emit(e.type),!1}))),t.on(n,(function(e){setTimeout((function(){e.defaultPrevented||t.hasState(it)||t.togglePlay()}),0)})),t.on(s,(function(e){setTimeout((function(){e.defaultPrevented||t.toggleFullScreen()}),0)}))}handleTouch(t){let e=!1;this.addEventListener(u,(function(e){0!=e.cancelable&&(e.preventDefault(),t.emit(e.type,{source:e}))})),t.on(u,(function(r){setTimeout((function(){if(r.defaultPrevented)return;if(t.hasState(it))return;if(t.ended)return t.togglePlay(!0);const i=t.hasState(Z);e&&clearTimeout(e),(i||t.hasState(st)||t.hasState("no-autoplay"))&&(t.hasState(st)&&(t.setState(st,!1),t.setState("is-hovered",!1)),t.togglePlay(),i)||(t.setState(st,!0),t.paused||(e=setTimeout((function(){e=!1,t.setState(st,!1),t.setState("is-hovered",!1)}),2e3)))}),0)}))}}class FlowplayerUi extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-ui"),this.append(...t.createComponents(M,U,O))}}be.extensions.unshift.apply(be.extensions,[I18n,Analytics$1,Health,class Default{constructor(t){gt(t,D,FlowplayerUi),gt(t,O,FlowplayerControls),gt(t,I,FlowplayerLiveStatus),gt(t,"flowplayer-control-duration",FlowplayerDuration),gt(t,P,t.extensions.find(t=>t.name===Chapters.name)?FlowplayerChaptersTimelineBar:FlowplayerTimelineBar),gt(t,C,FlowplayerElapsedTime),gt(t,x,FlowplayerVolumeBar),gt(t,"flowplayer-volume-control",FlowplayerVolumeControl),gt(t,"flowplayer-control-buttons",FlowplayerControlButtons),gt(t,M,FlowplayerHeader),gt(t,N,FlowplayerPrimary),gt(t,"flowplayer-header-duration",FlowplayerHeaderDuration),gt(t,"flowplayer-header-left-zone",class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-left",N,"flowplayer-header-duration")}}),gt(t,F,class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-right fp-togglable","flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon")}}),gt(t,U,FlowplayerMiddle),gt(t,B,FlowplayerMiddleZone),gt(t,G,FlowplayerMiddleWait),gt(t,"flowplayer-middle-buttons",FlowplayerMiddleButtons),gt(t,"flowplayer-middle-right-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-right-zone")}}),gt(t,"flowplayer-middle-left-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-left-zone")}}),gt(t,j,class extends FlowplayerIcon{constructor(t){super(t,Xr),this.setAttribute("role","button")}}),gt(t,H,class extends FlowplayerIcon{constructor(t){super(t,Qr),this.setAttribute("role","button")}}),gt(t,K,class extends FlowplayerIcon{constructor(t){super(t,Wr)}}),gt(t,V,class extends FlowplayerIcon{constructor(t){super(t,zr)}}),gt(t,"flowplayer-fullscreen-enter-icon",class extends FullscreenIcon{constructor(t){super(t,Vr)}}),gt(t,"flowplayer-fullscreen-exit-icon",class extends FullscreenIcon{constructor(t){super(t,qr)}}),gt(t,"flowplayer-fast-forward-icon",class extends FlowplayerIcon{constructor(t){super(t,$r)}}),gt(t,q,class extends FlowplayerIcon{constructor(t){super(t,Jr)}}),gt(t,W,class extends FlowplayerIcon{constructor(t){super(t,Yr),this.classList.add("fp-volumebtn"),t.on("volumechange",()=>{const e=0==t.volume||t.muted;this.setAttribute("aria-label",e?t.i18n("unmute","unmute"):t.i18n("mute","mute"))})}})}init(t,e,r){pr(t,0,r),fr(t,e,r),function(t,e,r){"undefined"!=typeof window&&"ontouchstart"in window&&r.setState("is-touch-device",!0),r.setState("is-accessibility",!1)}(0,0,r)}}]);var di=Object.assign(be,{ui:ir,i18n:I18n}),ci=Ae(Le((function(t,e){var r;"undefined"!=typeof window&&(r=function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
16
16
  /*!*********************************************!*\
17
17
  !*** ./node_modules/eventemitter3/index.js ***!
18
18
  \*********************************************/
19
- /*! no static exports found */function(e,t,r){var n=Object.prototype.hasOwnProperty,i="~";function a(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,n,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new s(r,n||e,a),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function u(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(i=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,a=r.length,s=new Array(a);n<a;n++)s[n]=r[n].fn;return s},u.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,n,a,s){var o=i?i+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,r),!0;case 4:return c.fn.call(c.context,t,r,n),!0;case 5:return c.fn.call(c.context,t,r,n,a),!0;case 6:return c.fn.call(c.context,t,r,n,a,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var f,h=c.length;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,r);break;case 4:c[u].fn.call(c[u].context,t,r,n);break;default:if(!l)for(f=1,l=new Array(d-1);f<d;f++)l[f-1]=arguments[f];c[u].fn.apply(c[u].context,l)}}return!0},u.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,n){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return l(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||n&&!s.once||r&&s.context!==r||l(this,a);else{for(var o=0,u=[],c=s.length;o<c;o++)(s[o].fn!==t||n&&!s[o].once||r&&s[o].context!==r)&&u.push(s[o]);u.length?this._events[a]=1===u.length?u[0]:u:l(this,a)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&l(this,t)):(this._events=new a,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,e.exports=u},"./node_modules/url-toolkit/src/url-toolkit.js":
19
+ /*! no static exports found */function(t,e,r){var i=Object.prototype.hasOwnProperty,n="~";function s(){}function a(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function o(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new a(r,i||t,s),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function l(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function u(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),u.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)i.call(t,e)&&r.push(n?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},u.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,a=new Array(s);i<s;i++)a[i]=r[i].fn;return a},u.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},u.prototype.emit=function(t,e,r,i,s,a){var o=n?n+t:t;if(!this._events[o])return!1;var l,u,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,r),!0;case 4:return d.fn.call(d.context,e,r,i),!0;case 5:return d.fn.call(d.context,e,r,i,s),!0;case 6:return d.fn.call(d.context,e,r,i,s,a),!0}for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var h,f=d.length;for(u=0;u<f;u++)switch(d[u].once&&this.removeListener(t,d[u].fn,void 0,!0),c){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,e);break;case 3:d[u].fn.call(d[u].context,e,r);break;case 4:d[u].fn.call(d[u].context,e,r,i);break;default:if(!l)for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];d[u].fn.apply(d[u].context,l)}}return!0},u.prototype.on=function(t,e,r){return o(this,t,e,r,!1)},u.prototype.once=function(t,e,r){return o(this,t,e,r,!0)},u.prototype.removeListener=function(t,e,r,i){var s=n?n+t:t;if(!this._events[s])return this;if(!e)return l(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||i&&!a.once||r&&a.context!==r||l(this,s);else{for(var o=0,u=[],d=a.length;o<d;o++)(a[o].fn!==e||i&&!a[o].once||r&&a[o].context!==r)&&u.push(a[o]);u.length?this._events[s]=1===u.length?u[0]:u:l(this,s)}return this},u.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&l(this,e)):(this._events=new s,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=n,u.EventEmitter=u,t.exports=u},"./node_modules/url-toolkit/src/url-toolkit.js":
20
20
  /*!*****************************************************!*\
21
21
  !*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
22
22
  \*****************************************************/
23
- /*! no static exports found */function(e,t,r){var n,i,a,s,o;n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,i=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var n=o.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=o.normalizePath(n.path),o.buildURLFromParts(n)}var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var c=s.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=o.normalizePath(d)}else u.path=s.path,a.params||(u.params=s.params,a.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(a.path):a.path),o.buildURLFromParts(u)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o},"./node_modules/webworkify-webpack/index.js":
23
+ /*! no static exports found */function(t,e,r){var i,n,s,a,o;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,s=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=o.parseURL(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return r.alwaysNormalize?(s.path=o.normalizePath(s.path),o.buildURLFromParts(s)):e;var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var l=n.exec(a.path);a.netLoc=l[1],a.path=l[2]}a.netLoc&&!a.path&&(a.path="/");var u={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){var d=a.path,c=d.substring(0,d.lastIndexOf("/")+1)+s.path;u.path=o.normalizePath(c)}else u.path=a.path,s.params||(u.params=a.params,s.query||(u.query=a.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(s.path):s.path),o.buildURLFromParts(u)},parseURL:function(t){var e=i.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(s,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=o},"./node_modules/webworkify-webpack/index.js":
24
24
  /*!**************************************************!*\
25
25
  !*** ./node_modules/webworkify-webpack/index.js ***!
26
26
  \**************************************************/
27
- /*! no static exports found */function(e,t,r){function n(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var n=r(r.s=ENTRY_MODULE);return n.default||n}function i(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(e,t,n){var a={};a[n]=[];var s=t.toString(),o=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return a;for(var l,u=o[1],c=new RegExp("(\\\\n|\\W)"+i(u)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=c.exec(s);)"dll-reference"!==l[3]&&a[n].push(l[3]);for(c=new RegExp("\\("+i(u)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=c.exec(s);)e[l[2]]||(a[n].push(l[1]),e[l[2]]=r(l[1]).m),a[l[2]]=a[l[2]]||[],a[l[2]].push(l[4]);for(var d,f=Object.keys(a),h=0;h<f.length;h++)for(var p=0;p<a[f[h]].length;p++)d=a[f[h]][p],isNaN(1*d)||(a[f[h]][p]=1*a[f[h]][p]);return a}function s(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}e.exports=function(e,t){t=t||{};var i={main:r.m},o=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},n={main:[]},i={main:{}};s(r);)for(var o=Object.keys(r),l=0;l<o.length;l++){var u=o[l],c=r[u].pop();if(i[u]=i[u]||{},!i[u][c]&&e[u][c]){i[u][c]=!0,n[u]=n[u]||[],n[u].push(c);for(var d=a(e,e[u][c],u),f=Object.keys(d),h=0;h<f.length;h++)r[f[h]]=r[f[h]]||[],r[f[h]]=r[f[h]].concat(d[f[h]])}}return n}(i,e),l="";Object.keys(o).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;o[e][t];)t++;o[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+e+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+o[e].map((function(t){return JSON.stringify(t)+": "+i[e][t].toString()})).join(",")+"});\n"})),l=l+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+o.main.map((function(e){return JSON.stringify(e)+": "+i.main[e].toString()})).join(",")+"}))(self);";var u=new window.Blob([l],{type:"text/javascript"});if(t.bare)return u;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),d=new window.Worker(c);return d.objectURL=c,d}},"./src/config.ts":
27
+ /*! no static exports found */function(t,e,r){function i(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r.oe=function(t){throw console.error(t),t};var i=r(r.s=ENTRY_MODULE);return i.default||i}function n(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function s(t,e,i){var s={};s[i]=[];var a=e.toString(),o=a.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return s;for(var l,u=o[1],d=new RegExp("(\\\\n|\\W)"+n(u)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=d.exec(a);)"dll-reference"!==l[3]&&s[i].push(l[3]);for(d=new RegExp("\\("+n(u)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=d.exec(a);)t[l[2]]||(s[i].push(l[1]),t[l[2]]=r(l[1]).m),s[l[2]]=s[l[2]]||[],s[l[2]].push(l[4]);for(var c,h=Object.keys(s),f=0;f<h.length;f++)for(var p=0;p<s[h[f]].length;p++)c=s[h[f]][p],isNaN(1*c)||(s[h[f]][p]=1*s[h[f]][p]);return s}function a(t){return Object.keys(t).reduce((function(e,r){return e||t[r].length>0}),!1)}t.exports=function(t,e){e=e||{};var n={main:r.m},o=e.all?{main:Object.keys(n.main)}:function(t,e){for(var r={main:[e]},i={main:[]},n={main:{}};a(r);)for(var o=Object.keys(r),l=0;l<o.length;l++){var u=o[l],d=r[u].pop();if(n[u]=n[u]||{},!n[u][d]&&t[u][d]){n[u][d]=!0,i[u]=i[u]||[],i[u].push(d);for(var c=s(t,t[u][d],u),h=Object.keys(c),f=0;f<h.length;f++)r[h[f]]=r[h[f]]||[],r[h[f]]=r[h[f]].concat(c[h[f]])}}return i}(n,t),l="";Object.keys(o).filter((function(t){return"main"!==t})).forEach((function(t){for(var e=0;o[t][e];)e++;o[t].push(e),n[t][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+t+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+o[t].map((function(e){return JSON.stringify(e)+": "+n[t][e].toString()})).join(",")+"});\n"})),l=l+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+o.main.map((function(t){return JSON.stringify(t)+": "+n.main[t].toString()})).join(",")+"}))(self);";var u=new window.Blob([l],{type:"text/javascript"});if(e.bare)return u;var d=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),c=new window.Worker(d);return c.objectURL=d,c}},"./src/config.ts":
28
28
  /*!***********************!*\
29
29
  !*** ./src/config.ts ***!
30
30
  \***********************/
31
- /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(e,t,r){r.r(t),r.d(t,"hlsDefaultConfig",(function(){return b})),r.d(t,"mergeConfig",(function(){return A})),r.d(t,"enableStreamingMode",(function(){return S}));var n=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),i=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),a=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),d=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),f=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),h=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),p=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),g=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),m=r(/*! ./utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){T(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var b=_(_({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:h.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:n.default,bufferController:l.default,capLevelController:c.default,fpsController:d.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0},{cueHandler:v.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:s.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:i.default,audioTrackController:a.default,emeController:f.default});function A(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return y({},e,t)}function S(e){var t=e.loader;t!==p.default&&t!==h.default?(m.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):Object(p.fetchSupported)()&&(e.loader=p.default,e.progressive=!0,e.enableSoftwareAES=!0,m.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
31
+ /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,r){r.r(e),r.d(e,"hlsDefaultConfig",(function(){return b})),r.d(e,"mergeConfig",(function(){return S})),r.d(e,"enableStreamingMode",(function(){return A}));var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),d=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),c=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),h=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),p=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),g=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),v=r(/*! ./utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){_(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var b=T(T({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:f.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:l.default,capLevelController:d.default,fpsController:c.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0},{cueHandler:g.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:n.default,audioTrackController:s.default,emeController:h.default});function S(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return y({},t,e)}function A(t){var e=t.loader;e!==p.default&&e!==f.default?(v.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(p.fetchSupported)()&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,v.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
32
32
  /*!******************************************!*\
33
33
  !*** ./src/controller/abr-controller.ts ***!
34
34
  \******************************************/
35
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts");function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var d=function(){function e(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new i.default(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t,r,d,f=e.prototype;return f.registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(e,t){var r,n=t.frag;n.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!=(r=t.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},f.onLevelLoaded=function(e,t){var r=this.hls.config;t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,o=r.config,l=r.media;if(e&&l){var c=t?t.stats:e.stats,d=t?t.duration:e.duration;if(c.aborted)return u.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!l.paused&&l.playbackRate&&l.readyState){var f=performance.now()-c.loading.start,h=Math.abs(l.playbackRate);if(!(f<=500*d/h)){var p=r.levels,v=r.minAutoLevel,g=p[e.level],m=c.total||Math.max(c.loaded,Math.round(d*g.maxBitrate/8)),y=Math.max(1,c.bwEstimate?c.bwEstimate/8:1e3*c.loaded/f),E=(m-c.loaded)/y,_=l.currentTime,T=(s.BufferHelper.bufferInfo(l,_,o.maxBufferHole).end-_)/h;if(!(T>=2*d/h||E<=T)){var b,A=Number.POSITIVE_INFINITY;for(b=e.level-1;b>v&&!((A=d*p[b].maxBitrate/(6.4*y))<T);b--);if(!(A>=E)){var S=this.bwEstimator.getEstimate();u.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+(Object(n.isFiniteNumber)(S)?(S/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+E.toFixed(3)+" s\n Estimated load time for the next fragment: "+A.toFixed(3)+" s\n Time to underbuffer: "+T.toFixed(3)+" s"),r.nextLoadLevel=b,this.bwEstimator.sample(f,c.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),r.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:c})}}}}}},f.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.type===l.PlaylistLevelType.MAIN&&Object(n.isFiniteNumber)(r.sn)){var s=i?i.stats:r.stats,o=i?i.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,d=(u.loaded?u.loaded.duration:0)+o;u.loaded={bytes:c,duration:d},u.realBitrate=Math.round(8*c/d)}if(r.bitrateTest){var f={stats:s,frag:r,part:i,id:r.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,f),r.bitrateTest=!1}}},f.onFragBuffered=function(e,t){var r=t.frag,n=t.part,i=n?n.stats:r.stats;if(!i.aborted&&r.type===l.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var a=i.parsing.end-i.loading.start;this.bwEstimator.sample(a,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},f.onError=function(e,t){switch(t.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.maxAutoLevel,i=r.config,a=r.minAutoLevel,o=r.media,l=t?t.duration:e?e.duration:0,c=o?o.currentTime:0,d=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,h=(s.BufferHelper.bufferInfo(o,c,i.maxBufferHole).end-c)/d,p=this.findBestLevel(f,a,n,h,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(p>=0)return p;u.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=l?Math.min(l,i.maxStarvationDelay):i.maxStarvationDelay,g=i.abrBandWidthFactor,m=i.abrBandWidthUpFactor;if(!h){var y=this.bitrateTestDelay;y&&(v=(l?Math.min(l,i.maxLoadingDelay):i.maxLoadingDelay)-y,u.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),g=m=1)}return p=this.findBestLevel(f,a,n,h+v,g,m),Math.max(p,0)},f.findBestLevel=function(e,t,r,n,i,a){for(var s,o=this.fragCurrent,l=this.partCurrent,c=this.lastLoadedFragLevel,d=this.hls.levels,f=d[c],h=!(null==f||null===(s=f.details)||void 0===s||!s.live),p=null==f?void 0:f.codecSet,v=l?l.duration:o?o.duration:0,g=r;g>=t;g--){var m=d[g];if(m&&(!p||m.codecSet===p)){var y=m.details,E=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||v,_=void 0;_=g<=c?i*e:a*e;var T=d[g].maxBitrate,b=T*E/_;if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+g+"/"+Math.round(_)+"/"+T+"/"+E+"/"+n+"/"+b),_>T&&(!b||h&&!this.bitrateTestDelay||b<n))return g}}return-1},t=e,(r=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this.getNextABRAutoLevel();return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}}])&&c(t.prototype,r),d&&c(t,d),e}();t.default=d},"./src/controller/audio-stream-controller.ts":
35
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts");function d(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var c=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new n.default(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e,r,c,h=t.prototype;return h.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},h.onFragLoading=function(t,e){var r,i=e.frag;i.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},h.onLevelLoaded=function(t,e){var r=this.hls.config;e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},h._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,n=r.autoLevelEnabled,o=r.config,l=r.media;if(t&&l){var d=e?e.stats:t.stats,c=e?e.duration:t.duration;if(d.aborted)return u.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!l.paused&&l.playbackRate&&l.readyState){var h=performance.now()-d.loading.start,f=Math.abs(l.playbackRate);if(!(h<=500*c/f)){var p=r.levels,g=r.minAutoLevel,m=p[t.level],v=d.total||Math.max(d.loaded,Math.round(c*m.maxBitrate/8)),y=Math.max(1,d.bwEstimate?d.bwEstimate/8:1e3*d.loaded/h),E=(v-d.loaded)/y,T=l.currentTime,_=(a.BufferHelper.bufferInfo(l,T,o.maxBufferHole).end-T)/f;if(!(_>=2*c/f||E<=_)){var b,S=Number.POSITIVE_INFINITY;for(b=t.level-1;b>g&&!((S=c*p[b].maxBitrate/(6.4*y))<_);b--);if(!(S>=E)){var A=this.bwEstimator.getEstimate();u.logger.warn("Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+(Object(i.isFiniteNumber)(A)?(A/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+E.toFixed(3)+" s\n Estimated load time for the next fragment: "+S.toFixed(3)+" s\n Time to underbuffer: "+_.toFixed(3)+" s"),r.nextLoadLevel=b,this.bwEstimator.sample(h,d.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),r.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d})}}}}}},h.onFragLoaded=function(t,e){var r=e.frag,n=e.part;if(r.type===l.PlaylistLevelType.MAIN&&Object(i.isFiniteNumber)(r.sn)){var a=n?n.stats:r.stats,o=n?n.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],d=(u.loaded?u.loaded.bytes:0)+a.loaded,c=(u.loaded?u.loaded.duration:0)+o;u.loaded={bytes:d,duration:c},u.realBitrate=Math.round(8*d/c)}if(r.bitrateTest){var h={stats:a,frag:r,part:n,id:r.type};this.onFragBuffered(s.Events.FRAG_BUFFERED,h),r.bitrateTest=!1}}},h.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===l.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var s=n.parsing.end-n.loading.start;this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}},h.onError=function(t,e){switch(e.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},h.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},h.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,s=r.minAutoLevel,o=r.media,l=e?e.duration:t?t.duration:0,d=o?o.currentTime:0,c=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=(a.BufferHelper.bufferInfo(o,d,n.maxBufferHole).end-d)/c,p=this.findBestLevel(h,s,i,f,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(p>=0)return p;u.logger.trace((f?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,v=n.abrBandWidthUpFactor;if(!f){var y=this.bitrateTestDelay;y&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-y,u.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),m=v=1)}return p=this.findBestLevel(h,s,i,f+g,m,v),Math.max(p,0)},h.findBestLevel=function(t,e,r,i,n,s){for(var a,o=this.fragCurrent,l=this.partCurrent,d=this.lastLoadedFragLevel,c=this.hls.levels,h=c[d],f=!(null==h||null===(a=h.details)||void 0===a||!a.live),p=null==h?void 0:h.codecSet,g=l?l.duration:o?o.duration:0,m=r;m>=e;m--){var v=c[m];if(v&&(!p||v.codecSet===p)){var y=v.details,E=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||g,T=void 0;T=m<=d?n*t:s*t;var _=c[m].maxBitrate,b=_*E/T;if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(T)+"/"+_+"/"+E+"/"+i+"/"+b),T>_&&(!b||f&&!this.bitrateTestDelay||b<i))return m}}return-1},e=t,(r=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(!(-1===t||e&&e.canEstimate()))return t;var r=this.getNextABRAutoLevel();return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}}])&&d(e.prototype,r),c&&d(e,c),t}();e.default=c},"./src/controller/audio-stream-controller.ts":
36
36
  /*!***************************************************!*\
37
37
  !*** ./src/controller/audio-stream-controller.ts ***!
38
38
  \***************************************************/
39
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),f=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),v=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),g=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),m=r(/*! ../errors */"./src/errors.ts"),y=r(/*! ../utils/logger */"./src/utils/logger.ts");function E(){return(E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var T=function(e){var t,r;function T(t,r){var n;return(n=e.call(this,t,r,"[audio-stream-controller]")||this).videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.audioSwitch=!1,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n._registerListeners(),n}r=e,(t=T).prototype=Object.create(r.prototype),t.prototype.constructor=t,_(t,r);var b=T.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var e=this.hls;e.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(a.Events.ERROR,this.onError,this),e.on(a.Events.BUFFER_RESET,this.onBufferReset,this),e.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var e=this.hls;e.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(a.Events.ERROR,this.onError,this),e.off(a.Events.BUFFER_RESET,this.onBufferReset,this),e.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onInitPtsFound=function(e,t){var r=t.frag,n=t.id,a=t.initPTS;if("main"===n){var s=r.cc;this.initPTS[r.cc]=a,this.log("InitPTS for cc: "+s+" found from main: "+a),this.videoTrackCC=s,this.state===i.State.WAITING_INIT_PTS&&this.tick()}},b.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=i.State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=i.State.IDLE):(this.loadedmetadata=!1,this.state=i.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},b.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_TRACK:var t,r=this.levels,n=this.trackId,a=null==r||null===(t=r[n])||void 0===t?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=i.State.WAITING_INIT_PTS}break;case i.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=i.State.IDLE);break;case i.State.WAITING_INIT_PTS:var c=this.waitingData;if(c){var d=c.frag,f=c.part,h=c.cache,v=c.complete;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.state=i.State.FRAG_LOADING;var g={frag:d,part:f,payload:h.flush(),networkDetails:null};this._handleFragmentLoadProgress(g),v&&e.prototype._handleFragmentLoadComplete.call(this,g)}else if(this.videoTrackCC!==this.waitingVideoCC)y.logger.log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=s.BufferHelper.bufferInfo(this.mediaBuffer,this.media.currentTime,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(m.end,this.config.maxFragLookUpTolerance,d)<0&&(y.logger.log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+m.end+" is needed"),this.clearWaitingFragment())}}else this.state=i.State.IDLE}this.onTickEnd()},b.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=i.State.IDLE)},b.onTickEnd=function(){var e=this.media;if(e&&e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length&&(this.loadedmetadata=!0),this.lastCurrentTime=e.currentTime}},b.doTickIdle=function(){var e,t,r=this.hls,o=this.levels,l=this.media,u=this.trackId,c=r.config;if(o&&o[u]&&(l||!this.startFragRequested&&c.startFragPrefetch)){var d=this.getLoadPosition();if(Object(n.isFiniteNumber)(d)){var f=o[u].details;if(!f||f.live&&this.levelLastLoaded!==u||this.waitForCdnTuneIn(f))this.state=i.State.WAITING_TRACK;else{var h=f.initSegment,p=0;if(!h||h.data){var v=this.mediaBuffer?this.mediaBuffer:this.media,m=this.videoBuffer?this.videoBuffer:this.media,y=d<c.maxBufferHole?Math.max(g.MAX_START_GAP_JUMP,c.maxBufferHole):c.maxBufferHole,E=s.BufferHelper.bufferInfo(v,d,y),_=s.BufferHelper.bufferInfo(m,d,y),T=E.len,b=Math.min(c.maxBufferLength,c.maxMaxBufferLength),A=Math.max(b,_.len),S=this.audioSwitch;if(T>=A&&!S)return;if(!S&&this._streamEnded(E,f))return r.trigger(a.Events.BUFFER_EOS,{type:"audio"}),void(this.state=i.State.ENDED);var w=f.fragments[0].start;if(p=E.end,S&&(p=d,f.PTSKnown&&d<w&&(E.end>w||E.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),l.currentTime=w+.05)),!(h=this.getNextFragment(p,f)))return}"identity"!==(null===(e=h.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=h.decryptdata)&&void 0!==t&&t.key?this.loadFragment(h,f,p):this.loadKey(h,f)}}}},b.onMediaDetaching=function(){this.videoBuffer=null,e.prototype.onMediaDetaching.call(this)},b.onAudioTracksUpdated=function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(e){return new l.Level(e)}))},b.onAudioTrackSwitching=function(e,t){var r=!!t.url;this.trackId=t.id;var n=this.fragCurrent;null!=n&&n.loader&&n.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=i.State.IDLE):this.state=i.State.STOPPED,this.tick()},b.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0},b.onLevelLoaded=function(e,t){if(null===this.mainDetails){var r=this.mainDetails=t.details,n=this.levelLastLoaded;if(null!==n&&this.levels&&-1===this.startPosition&&r.live){var i=this.levels[n];if(!i.details||!i.details.fragments[0])return;Object(v.alignPDT)(i.details,r),this.setStartPosition(i.details,i.details.fragments[0].start)}}},b.onAudioTrackLoaded=function(e,t){var r,n=this.levels,a=t.details,s=t.id;if(n){this.log("Track "+s+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var o=n[s],l=0;if(a.live||null!==(r=o.details)&&void 0!==r&&r.live){var u;if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;!o.details&&null!==(u=this.mainDetails)&&void 0!==u&&u.hasProgramDateTime&&a.hasProgramDateTime?(Object(v.alignPDT)(a,this.mainDetails),l=a.fragments[0].start):l=this.alignPlaylists(a,o.details)}o.details=a,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(o.details,l),this.state!==i.State.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=i.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)},b._handleFragmentLoadProgress=function(e){var t,r=e.frag,n=e.part,a=e.payload,s=this.config,o=this.trackId,l=this.levels;if(l){var c=l[o];console.assert(c,"Audio track is defined on fragment load progress");var p=c.details;console.assert(p,"Audio track details are defined on fragment load progress");var v=s.defaultAudioCodec||c.audioCodec||"mp4a.40.2",g=this.transmuxer;g||(g=this.transmuxer=new f.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],E=null===(t=p.initSegment)||void 0===t?void 0:t.data;if(void 0!==m){var _=n?n.index:-1,T=-1!==_,b=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,_,T);g.push(a,E,v,"",r,n,p.totalduration,!1,b,m)}else y.logger.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new d.default,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=i.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},b._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},b.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},b.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},b.onFragBuffered=function(e,t){var r=t.frag,n=t.part;r.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,n)))},b.onError=function(t,r){switch(r.details){case m.ErrorDetails.FRAG_LOAD_ERROR:case m.ErrorDetails.FRAG_LOAD_TIMEOUT:case m.ErrorDetails.KEY_LOAD_ERROR:case m.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case m.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case m.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==i.State.ERROR&&this.state!==i.State.STOPPED&&(this.state=r.fatal?i.State.ERROR:i.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case m.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===i.State.PARSING||this.state===i.State.PARSED)){var n=this.mediaBuffer,a=this.media.currentTime;n&&s.BufferHelper.isBuffered(n,a)&&s.BufferHelper.isBuffered(n,a+.5)?(this.reduceMaxBufferLength(),this.state=i.State.IDLE):(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"))}}},b.onBufferFlushed=function(e,t){var r=t.type;if(r===c.ElementaryStreamTypes.AUDIO){var n=this.mediaBuffer?this.mediaBuffer:this.media;this.afterBufferFlushed(n,r,u.PlaylistLevelType.AUDIO)}},b._handleTransmuxComplete=function(e){var t,r="audio",n=this.hls,s=e.remuxResult,o=e.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var u=l.frag,d=l.part,f=s.audio,h=s.text,p=s.id3,v=s.initSegment;if(!this.fragContextChanged(u)){if(this.state=i.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=v&&v.tracks&&(this._bufferInitSegment(v.tracks,u,o),n.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:v.tracks})),f){var g=f.startPTS,m=f.endPTS,y=f.startDTS,_=f.endDTS;d&&(d.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:m,startDTS:y,endDTS:_}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,g,m,y,_),this.bufferFragmentData(f,u,d,o)}if(null!=p&&null!==(t=p.samples)&&void 0!==t&&t.length){var T=E({frag:u,id:r},p);n.trigger(a.Events.FRAG_PARSING_METADATA,T)}if(h){var b=E({frag:u,id:r},h);n.trigger(a.Events.FRAG_PARSING_USERDATA,b)}}},b._bufferInitSegment=function(e,t,r){if(this.state===i.State.PARSING){e.video&&delete e.video;var n=e.audio;if(n){n.levelCodec=n.codec,n.id="audio",this.log("Init audio buffer, container:"+n.container+", codecs[parsed]=["+n.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e);var s=n.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:s};this.hls.trigger(a.Events.BUFFER_APPENDING,o)}this.tick()}}},b.loadFragment=function(t,r,a){var s=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||s===o.FragmentState.NOT_LOADED||s===o.FragmentState.PARTIAL)&&("initSegment"===t.sn?this._loadInitSegment(t):r.live&&!Object(n.isFiniteNumber)(this.initPTS[t.cc])?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=i.State.WAITING_INIT_PTS):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,a)))},b.completeAudioSwitch=function(){var t=this.hls,r=this.media,n=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})},T}(i.default);t.default=T},"./src/controller/audio-track-controller.ts":
39
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),h=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),m=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),v=r(/*! ../errors */"./src/errors.ts"),y=r(/*! ../utils/logger */"./src/utils/logger.ts");function E(){return(E=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function T(t,e){return(T=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var _=function(t){var e,r;function _(e,r){var i;return(i=t.call(this,e,r,"[audio-stream-controller]")||this).videoBuffer=null,i.videoTrackCC=-1,i.waitingVideoCC=-1,i.audioSwitch=!1,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i._registerListeners(),i}r=t,(e=_).prototype=Object.create(r.prototype),e.prototype.constructor=e,T(e,r);var b=_.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onInitPtsFound=function(t,e){var r=e.frag,i=e.id,s=e.initPTS;if("main"===i){var a=r.cc;this.initPTS[r.cc]=s,this.log("InitPTS for cc: "+a+" found from main: "+s),this.videoTrackCC=a,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},b.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=n.State.STOPPED);var e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,e>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},b.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var e,r=this.levels,i=this.trackId,s=null==r||null===(e=r[i])||void 0===e?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var d=this.waitingData;if(d){var c=d.frag,h=d.part,f=d.cache,g=d.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.state=n.State.FRAG_LOADING;var m={frag:c,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(m),g&&t.prototype._handleFragmentLoadComplete.call(this,m)}else if(this.videoTrackCC!==this.waitingVideoCC)y.logger.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var v=a.BufferHelper.bufferInfo(this.mediaBuffer,this.media.currentTime,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(v.end,this.config.maxFragLookUpTolerance,c)<0&&(y.logger.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+v.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},b.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},b.onTickEnd=function(){var t=this.media;if(t&&t.readyState){var e=(this.mediaBuffer?this.mediaBuffer:t).buffered;!this.loadedmetadata&&e.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime}},b.doTickIdle=function(){var t,e,r=this.hls,o=this.levels,l=this.media,u=this.trackId,d=r.config;if(o&&o[u]&&(l||!this.startFragRequested&&d.startFragPrefetch)){var c=this.getLoadPosition();if(Object(i.isFiniteNumber)(c)){var h=o[u].details;if(!h||h.live&&this.levelLastLoaded!==u||this.waitForCdnTuneIn(h))this.state=n.State.WAITING_TRACK;else{var f=h.initSegment,p=0;if(!f||f.data){var g=this.mediaBuffer?this.mediaBuffer:this.media,v=this.videoBuffer?this.videoBuffer:this.media,y=c<d.maxBufferHole?Math.max(m.MAX_START_GAP_JUMP,d.maxBufferHole):d.maxBufferHole,E=a.BufferHelper.bufferInfo(g,c,y),T=a.BufferHelper.bufferInfo(v,c,y),_=E.len,b=Math.min(d.maxBufferLength,d.maxMaxBufferLength),S=Math.max(b,T.len),A=this.audioSwitch;if(_>=S&&!A)return;if(!A&&this._streamEnded(E,h))return r.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var L=h.fragments[0].start;if(p=E.end,A&&(p=c,h.PTSKnown&&c<L&&(E.end>L||E.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),l.currentTime=L+.05)),!(f=this.getNextFragment(p,h)))return}"identity"!==(null===(t=f.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=f.decryptdata)&&void 0!==e&&e.key?this.loadFragment(f,h,p):this.loadKey(f,h)}}}},b.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},b.onAudioTracksUpdated=function(t,e){var r=e.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(t){return new l.Level(t)}))},b.onAudioTrackSwitching=function(t,e){var r=!!e.url;this.trackId=e.id;var i=this.fragCurrent;null!=i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},b.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0},b.onLevelLoaded=function(t,e){if(null===this.mainDetails){var r=this.mainDetails=e.details,i=this.levelLastLoaded;if(null!==i&&this.levels&&-1===this.startPosition&&r.live){var n=this.levels[i];if(!n.details||!n.details.fragments[0])return;Object(g.alignPDT)(n.details,r),this.setStartPosition(n.details,n.details.fragments[0].start)}}},b.onAudioTrackLoaded=function(t,e){var r,i=this.levels,s=e.details,a=e.id;if(i){this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=i[a],l=0;if(s.live||null!==(r=o.details)&&void 0!==r&&r.live){var u;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed)return;!o.details&&null!==(u=this.mainDetails)&&void 0!==u&&u.hasProgramDateTime&&s.hasProgramDateTime?(Object(g.alignPDT)(s,this.mainDetails),l=s.fragments[0].start):l=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=n.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)},b._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,s=t.payload,a=this.config,o=this.trackId,l=this.levels;if(l){var d=l[o];console.assert(d,"Audio track is defined on fragment load progress");var p=d.details;console.assert(p,"Audio track details are defined on fragment load progress");var g=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",m=this.transmuxer;m||(m=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var v=this.initPTS[r.cc],E=null===(e=p.initSegment)||void 0===e?void 0:e.data;if(void 0!==v){var T=i?i.index:-1,_=-1!==T,b=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,s.byteLength,T,_);m.push(s,E,g,"",r,i,p.totalduration,!1,b,v)}else y.logger.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new c.default,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},b._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},b.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},b.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},b.onFragBuffered=function(t,e){var r=e.frag,i=e.part;r.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,i)))},b.onError=function(e,r){switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=r.fatal?n.State.ERROR:n.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var i=this.mediaBuffer,s=this.media.currentTime;i&&a.BufferHelper.isBuffered(i,s)&&a.BufferHelper.isBuffered(i,s+.5)?(this.reduceMaxBufferLength(),this.state=n.State.IDLE):(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"))}}},b.onBufferFlushed=function(t,e){var r=e.type;if(r===d.ElementaryStreamTypes.AUDIO){var i=this.mediaBuffer?this.mediaBuffer:this.media;this.afterBufferFlushed(i,r,u.PlaylistLevelType.AUDIO)}},b._handleTransmuxComplete=function(t){var e,r="audio",i=this.hls,a=t.remuxResult,o=t.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var u=l.frag,c=l.part,h=a.audio,f=a.text,p=a.id3,g=a.initSegment;if(!this.fragContextChanged(u)){if(this.state=n.State.PARSING,this.audioSwitch&&h&&this.completeAudioSwitch(),null!=g&&g.tracks&&(this._bufferInitSegment(g.tracks,u,o),i.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:g.tracks})),h){var m=h.startPTS,v=h.endPTS,y=h.startDTS,T=h.endDTS;c&&(c.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:m,endPTS:v,startDTS:y,endDTS:T}),u.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,m,v,y,T),this.bufferFragmentData(h,u,c,o)}if(null!=p&&null!==(e=p.samples)&&void 0!==e&&e.length){var _=E({frag:u,id:r},p);i.trigger(s.Events.FRAG_PARSING_METADATA,_)}if(f){var b=E({frag:u,id:r},f);i.trigger(s.Events.FRAG_PARSING_USERDATA,b)}}},b._bufferInitSegment=function(t,e,r){if(this.state===n.State.PARSING){t.video&&delete t.video;var i=t.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:"+i.container+", codecs[parsed]=["+i.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=i.initSegment;if(null!=a&&a.byteLength){var o={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:a};this.hls.trigger(s.Events.BUFFER_APPENDING,o)}this.tick()}}},b.loadFragment=function(e,r,s){var a=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===e.sn?this._loadInitSegment(e):r.live&&!Object(i.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,s)))},b.completeAudioSwitch=function(){var e=this.hls,r=this.media,i=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:i})},_}(n.default);e.default=_},"./src/controller/audio-track-controller.ts":
40
40
  /*!**************************************************!*\
41
41
  !*** ./src/controller/audio-track-controller.ts ***!
42
42
  \**************************************************/
43
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,c,d,f=a.prototype;return f.registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(n.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(n.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,e.prototype.destroy.call(this)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},f.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},f.onAudioTrackLoaded=function(e,t){var r=t.id,n=t.details,i=this.tracksInGroup[r];if(i){var a=i.details;i.details=t.details,this.log("audioTrack "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,a))}else this.warn("Invalid audio track id "+r)},f.onLevelLoading=function(e,t){this.switchLevel(t.level)},f.onLevelSwitching=function(e,t){this.switchLevel(t.level)},f.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r;var i=this.tracks.filter((function(e){return!r||e.groupId===r}));this.selectDefaultTrack&&!i.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var a={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},f.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=t[this.trackId];this.log("Now switching to audio-track index "+e);var i=t[e],a=i.id,s=i.groupId,o=void 0===s?"":s,l=i.name,u=i.type,c=i.url;if(this.trackId=e,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(n.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:l,type:u,url:c}),!i.details||i.details.live){var d=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(d)}}},f.selectInitialTrack=function(){var e=this.tracksInGroup;console.assert(e.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,r=this.findTrackId(t)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},f.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},f.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,i=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(n.Events.AUDIO_TRACK_LOADING,{url:a,id:r,groupId:i,deliveryDirectives:e||null})}},u=a,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}])&&o(u.prototype,c),d&&o(u,d),a}(a.default);t.default=u},"./src/controller/base-playlist-controller.ts":
43
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var u=function(t){var e,r;function s(e){var r;return(r=t.call(this,e,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=t,(e=s).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r);var u,d,c,h=s.prototype;return h.registerListeners=function(){var t=this.hls;t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},h.onManifestParsed=function(t,e){this.tracks=e.audioTracks||[]},h.onAudioTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.tracksInGroup[r];if(n){var s=n.details;n.details=e.details,this.log("audioTrack "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,s))}else this.warn("Invalid audio track id "+r)},h.onLevelLoading=function(t,e){this.switchLevel(e.level)},h.onLevelSwitching=function(t,e){this.switchLevel(e.level)},h.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){var r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r;var n=this.tracks.filter((function(t){return!r||t.groupId===r}));this.selectDefaultTrack&&!n.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var s={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},h.onError=function(e,r){t.prototype.onError.call(this,e,r),!r.fatal&&r.context&&r.context.type===a.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},h.setAudioTrack=function(t){var e=this.tracksInGroup;if(t<0||t>=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=e[this.trackId];this.log("Now switching to audio-track index "+t);var n=e[t],s=n.id,a=n.groupId,o=void 0===a?"":a,l=n.name,u=n.type,d=n.url;if(this.trackId=t,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(i.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:o,name:l,type:u,url:d}),!n.details||n.details.live){var c=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(c)}}},h.selectInitialTrack=function(){var t=this.tracksInGroup;console.assert(t.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,r=this.findTrackId(e)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},h.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1},h.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var r=e.id,n=e.groupId,s=e.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(i.Events.AUDIO_TRACK_LOADING,{url:s,id:r,groupId:n,deliveryDirectives:t||null})}},u=s,(d=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&o(u.prototype,d),c&&o(u,c),s}(s.default);e.default=u},"./src/controller/base-playlist-controller.ts":
44
44
  /*!****************************************************!*\
45
45
  !*** ./src/controller/base-playlist-controller.ts ***!
46
46
  \****************************************************/
47
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return l}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../types/level */"./src/types/level.ts"),a=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,t+":"),this.warn=s.logger.warn.bind(s.logger,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){t.fatal&&t.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var r=null==t?void 0:t.renditionReports;if(r)for(var a=0;a<r.length;a++){var s=r[a],o=""+s.URI;if(o===e.substr(-o.length)){var l=parseInt(s["LAST-MSN"]),u=parseInt(s["LAST-PART"]);if(t&&this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);void 0!==u&&c>t.partTarget&&(u+=1)}if(Object(n.isFiniteNumber)(l))return new i.HlsUrlParameters(l,Object(n.isFiniteNumber)(u)?u:void 0,i.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var n=this,i=t.details,s=t.stats,o=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(i.advancedDateTime=Date.now()-o,i.live||null!=r&&r.live){if(i.reloaded(r),r&&this.log("live playlist "+e+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:"MISSED")),r&&i.fragments.length>0&&a.mergeDetails(r,i),!this.canLoad||!i.live)return;var l,u=void 0,c=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var d=this.hls.config.lowLatencyMode,f=i.lastPartSn,h=i.endSN,p=i.lastPartIndex,v=f===h;-1!==p?(u=v?h+1:f,c=v?d?0:p:p+1):u=h+1;var g=i.age,m=g+i.ageHeader,y=Math.min(m-i.partTarget,1.5*i.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+i.age),y=0;else{var E=Math.floor(y/i.targetduration);u+=E,void 0!==c&&(c+=Math.round(y%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+c)}i.tuneInGoal=y}if(l=this.getDeliveryDirectives(i,t.deliveryDirectives,u,c),d||!v)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(i,t.deliveryDirectives,u,c);var _=Object(a.computeReloadInterval)(i,s);void 0!==u&&i.canBlockReload&&(_-=i.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(_)+" ms"),this.timer=self.setTimeout((function(){return n.loadPlaylist(l)}),_)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,n){var a=Object(i.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,n=t.part,a=i.HlsSkip.No),new i.HlsUrlParameters(r,n,a)},t.retryLoadingOrFail=function(e){var t,r=this,n=this.hls.config,i=this.retryCount<n.levelLoadingMaxRetry;if(i)if(this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&null!==(t=e.context)&&void 0!==t&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return i},e}()},"./src/controller/base-stream-controller.ts":
47
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return l}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/level */"./src/types/level.ts"),s=r(/*! ./level-helper */"./src/controller/level-helper.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=a.logger.log.bind(a.logger,e+":"),this.warn=a.logger.warn.bind(a.logger,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.onError=function(t,e){e.fatal&&e.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r)for(var s=0;s<r.length;s++){var a=r[s],o=""+a.URI;if(o===t.substr(-o.length)){var l=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(e&&this.hls.config.lowLatencyMode){var d=Math.min(e.age-e.partTarget,e.targetduration);void 0!==u&&d>e.partTarget&&(u+=1)}if(Object(i.isFiniteNumber)(l))return new n.HlsUrlParameters(l,Object(i.isFiniteNumber)(u)?u:void 0,n.HlsSkip.No)}}},e.loadPlaylist=function(t){},e.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},e.playlistLoaded=function(t,e,r){var i=this,n=e.details,a=e.stats,o=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&n.fragments.length>0&&s.mergeDetails(r,n),!this.canLoad||!n.live)return;var l,u=void 0,d=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var c=this.hls.config.lowLatencyMode,h=n.lastPartSn,f=n.endSN,p=n.lastPartIndex,g=h===f;-1!==p?(u=g?f+1:h,d=g?c?0:p:p+1):u=f+1;var m=n.age,v=m+n.ageHeader,y=Math.min(v-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var E=Math.floor(y/n.targetduration);u+=E,void 0!==d&&(d+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+d)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,d),c||!g)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,d);var T=Object(s.computeReloadInterval)(n,a);void 0!==u&&n.canBlockReload&&(T-=n.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(T)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),T)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,i){var s=Object(n.getSkipValue)(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,s=n.HlsSkip.No),new n.HlsUrlParameters(r,i,s)},e.retryLoadingOrFail=function(t){var e,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n)if(this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(e=t.context)&&void 0!==e&&e.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return n},t}()},"./src/controller/base-stream-controller.ts":
48
48
  /*!**************************************************!*\
49
49
  !*** ./src/controller/base-stream-controller.ts ***!
50
50
  \**************************************************/
51
- /*! exports provided: State, default */function(e,t,r){r.r(t),r.d(t,"State",(function(){return T})),r.d(t,"default",(function(){return b}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../task-loop */"./src/task-loop.ts"),a=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ./level-helper */"./src/controller/level-helper.ts"),d=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),v=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),g=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function E(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var T={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},b=function(e){var t,r;function i(t,r,n){var i;return(i=e.call(this)||this).hls=void 0,i.fragPrevious=null,i.fragCurrent=null,i.fragmentTracker=void 0,i.transmuxer=null,i._state=T.STOPPED,i.media=void 0,i.mediaBuffer=void 0,i.config=void 0,i.bitrateTest=!1,i.lastCurrentTime=0,i.nextLoadPosition=0,i.startPosition=0,i.loadedmetadata=!1,i.fragLoadError=0,i.retryDate=0,i.levels=null,i.fragmentLoader=void 0,i.levelLastLoaded=null,i.startFragRequested=!1,i.decrypter=void 0,i.initPTS=[],i.onvseeking=null,i.onvended=null,i.logPrefix="",i.log=void 0,i.warn=void 0,i.logPrefix=n,i.log=o.logger.log.bind(o.logger,n+":"),i.warn=o.logger.warn.bind(o.logger,n+":"),i.hls=t,i.fragmentLoader=new v.default(t.config),i.fragmentTracker=r,i.config=t.config,i.decrypter=new g.default(t,t.config),t.on(l.Events.KEY_LOADED,i.onKeyLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i)),i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,_(t,r);var b,A,S,w=i.prototype;return w.doTick=function(){this.onTickEnd()},w.onTickEnd=function(){},w.startLoad=function(e){},w.stopLoad=function(){this.fragmentLoader.abort();var e=this.fragCurrent;e&&this.fragmentTracker.removeFragment(e),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=T.STOPPED},w._streamEnded=function(e,t){var r=this.fragCurrent,n=this.fragmentTracker;if(!t.live&&r&&r.sn===t.endSN&&!e.nextStart){var i=n.getState(r);return i===a.FragmentState.PARTIAL||i===a.FragmentState.OK}return!1},w.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===T.STOPPED&&this.startLoad(n.startPosition)},w.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},w.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,a=this.state,o=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(i||r,o,e.maxBufferHole);if(this.log("media seeking to "+(Object(n.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+a),a===T.ENDED)this.resetLoadingState();else if(t&&!l.len){var u=e.maxFragLookUpTolerance,c=t.start-u,d=t.start+t.duration+u;(o<c||o>d)&&(t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.loader.abort()),this.resetLoadingState())}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tick()},w.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},w.onKeyLoaded=function(e,t){if(this.state===T.KEY_LOADING&&t.frag===this.fragCurrent&&this.levels){this.state=T.IDLE;var r=this.levels[t.frag.level].details;r&&this.loadFragment(t.frag,r,t.frag.start)}},w.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},w.onHandlerDestroyed=function(){this.state=T.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},w.loadKey=function(e,t){this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=T.KEY_LOADING,this.fragCurrent=e,this.hls.trigger(l.Events.KEY_LOADING,{frag:e})},w.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},w._loadFragForPlayback=function(e,t,r){var n=this;this._doFragLoad(e,t,r,(function(t){if(n.fragContextChanged(e))return n.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void n.fragmentTracker.removeFragment(e);e.stats.chunkCount++,n._handleFragmentLoadProgress(t)})).then((function(t){if(t){n.fragLoadError=0;var r=n.state;if(!n.fragContextChanged(e))return"payload"in t&&(n.log("Loaded fragment "+e.sn+" of level "+e.level),n.hls.trigger(l.Events.FRAG_LOADED,t),n.state===T.BACKTRACKING)?(n.fragmentTracker.backtrack(e,t),void n.resetFragmentLoading(e)):void n._handleFragmentLoadComplete(t);(r===T.FRAG_LOADING||r===T.BACKTRACKING||!n.fragCurrent&&r===T.PARSING)&&(n.fragmentTracker.removeFragment(e),n.state=T.IDLE)}})).catch((function(t){n.warn(t),n.resetFragmentLoading(e)}))},w.flushMainBuffer=function(e,t,r){void 0===r&&(r=null);var n={startOffset:e,endOffset:t,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,n)},w._loadInitSegment=function(e){var t=this;this._doFragLoad(e).then((function(r){if(!r||t.fragContextChanged(e)||!t.levels)throw new Error("init load aborted");return r})).then((function(r){var n=t.hls,i=r.payload,a=e.decryptdata;if(i&&i.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return t.decrypter.webCryptoDecrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).then((function(t){var i=self.performance.now();return n.trigger(l.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:s,tdecrypt:i}}),r.payload=t,r}))}return r})).then((function(r){var n=t.fragCurrent,i=t.hls,a=t.levels;if(!a)throw new Error("init load aborted, missing levels");var s=a[e.level].details;console.assert(s,"Level details are defined when init segment is loaded");var o=s.initSegment;console.assert(o,"Fragment initSegment is defined when init segment is loaded");var u=e.stats;t.state=T.IDLE,t.fragLoadError=0,o.data=new Uint8Array(r.payload),u.parsing.start=u.buffering.start=self.performance.now(),u.parsing.end=u.buffering.end=self.performance.now(),r.frag===n&&i.trigger(l.Events.FRAG_BUFFERED,{stats:u,frag:n,part:null,id:e.type}),t.tick()})).catch((function(r){t.warn(r),t.resetFragmentLoading(e)}))},w.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},w.fragBufferedComplete=function(e,t){var r=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" "+m.default.toString(s.BufferHelper.getBuffered(r))),this.state=T.IDLE,this.tick()},w._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,n=e.part,i=e.partsLoaded,a=!i||0===i.length||i.some((function(e){return!e})),s=new d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!a);t.flush(s)}},w._handleFragmentLoadProgress=function(e){},w._doFragLoad=function(e,t,r,i){var a=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var s=t.partList;if(s&&i){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var o=this.getNextPart(s,e,r);if(o>-1){var u=s[o];return this.log("Loading part sn: "+e.sn+" p: "+u.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+o+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=T.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,part:s[o],targetBufferTime:r}),this.doFragPartsLoad(e,s,o,i).catch((function(e){return a.handleFragLoadError(e)}))}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}return this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),Object(n.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=T.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragmentLoader.load(e,i).catch((function(e){return a.handleFragLoadError(e)}))},w.doFragPartsLoad=function(e,t,r,n){var i=this;return new Promise((function(a,s){var o=[];!function r(u){var c=t[u];i.fragmentLoader.loadPart(e,c,n).then((function(n){o[c.index]=n;var s=n.part;i.hls.trigger(l.Events.FRAG_LOADED,n);var d=t[u+1];if(!d||d.fragment!==e)return a({frag:e,part:s,partsLoaded:o});r(u+1)})).catch(s)}(r)}))},w.handleFragLoadError=function(e){var t=e.data;return t&&t.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(l.Events.ERROR,t),null},w._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===T.PARSING){var r=t.frag,n=t.part,i=t.level,a=self.performance.now();r.stats.parsing.end=a,n&&(n.stats.parsing.end=a),this.updateLevelTiming(r,n,i,e.partial)}else this.fragCurrent||(this.state=T.IDLE)},w.getCurrentContext=function(e){var t=this.levels,r=e.level,n=e.sn,i=e.part;if(!t||!t[r])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+r+". The current chunk will not be buffered."),null;var a=t[r],s=i>-1?c.getPartWith(a,n,i):null,o=s?s.fragment:c.getFragmentWithSN(a,n);return o?{frag:o,part:s,level:a}:null},w.bufferFragmentData=function(e,t,r,n){if(e&&this.state===T.PARSING){var i=e.data1,a=e.data2,s=i;if(i&&a&&(s=Object(f.appendUint8Array)(i,a)),s&&s.length){var o={type:e.type,frag:t,part:r,chunkMeta:n,parent:t.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,o),e.dropped&&e.independent&&!r&&this.flushBufferGap(t)}}},w.flushBufferGap=function(e){var t=this.media;if(t)if(s.BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,n=s.BufferHelper.bufferInfo(t,r,0),i=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*i),o=Math.max(Math.min(e.start-a,n.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},w.reduceMaxBufferLength=function(e){var t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},w.getNextFragment=function(e,t){var r=t.fragments,n=r.length;if(!n)return null;var i,a=this.config,s=r[0].start;if(!t.initSegment||t.initSegment.data||this.bitrateTest)if(t.live){var o=a.initialLiveManifestSize;if(n<o)return this.warn("Not enough fragments to start playback (have: "+n+", need: "+o+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(i=this.getInitialLiveFragment(t,r),this.startPosition=i?this.hls.liveSyncPosition||i.start:e)}else e<=s&&(i=r[0]);else i=t.initSegment;if(!i){var l=a.lowLatencyMode?t.partEnd:t.fragmentEnd;i=this.getFragmentAtPosition(e,l,t)}return i},w.getNextPart=function(e,t,r){for(var n=-1,i=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,n>-1&&r<l.start)break;var u=l.loaded;!u&&(i||l.independent||a)&&l.fragment===t&&(n=s),i=u}return n},w.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},w.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),n=Object(p.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var i=r.sn+1;if(i>=e.startSN&&i<=e.endSN){var a=t[i-e.startSN];r.cc===a.cc&&(n=a,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=Object(p.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(n=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n},w.getFragmentAtPosition=function(e,t,r){var n,i=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=i.maxFragLookUpTolerance,d=!!(i.lowLatencyMode&&r.partList&&u);if(d&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),e<t){var f=e>t-c?0:c;n=Object(p.findFragmentByPTS)(s,o,e,f)}else n=o[o.length-1];if(n){var h=n.sn-r.startSN,v=s&&n.level===s.level,g=o[h+1];if(this.fragmentTracker.getState(n)===a.FragmentState.BACKTRACKED){n=null;for(var m=h;o[m]&&this.fragmentTracker.getState(o[m])===a.FragmentState.BACKTRACKED;)n=s?o[m--]:o[--m];n||(n=g)}else s&&n.sn===s.sn&&!d&&v&&(n.sn<l&&this.fragmentTracker.getState(g)!==a.FragmentState.OK?(this.log("SN "+n.sn+" just loaded, load next one: "+g.sn),n=g):n=null)}return n},w.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,i=r.currentTime,a=e.fragments[0].start,s=e.edge,o=i>=a-t.maxFragLookUpTolerance&&i<=s;if(null!==n&&r.duration>n&&(i<n||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||i<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn("Playback: "+i.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+n.toFixed(3)),r.currentTime=n))}}},w.alignPlaylists=function(e,t){var r=this.levels,i=this.levelLastLoaded,a=null!==i?r[i]:null,s=0;return t&&e.fragments.length>0?(s=e.fragments[0].start,e.alignedSliding&&Object(n.isFiniteNumber)(s)?this.log("Live playlist sliding:"+s.toFixed(3)):s||(this.warn("["+this.constructor.name+"] Live playlist - outdated PTS, unknown sliding"),Object(h.alignStream)(this.fragPrevious,a,e))):(this.log("Live playlist - first load, unknown sliding"),Object(h.alignStream)(this.fragPrevious,a,e)),s},w.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},w.setStartPosition=function(e,t){var r=this.startPosition;if(-1===this.startPosition||-1===this.lastCurrentTime){var i=e.startTimeOffset;Object(n.isFiniteNumber)(i)?(i<0&&(this.log("Negative start time offset "+i+", count from end of last fragment"),i=t+e.totalduration+i),this.log("Start time offset found in playlist, adjust startPosition to "+i),this.startPosition=r=i):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},w.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},w.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&(this.warn("Fragment "+e.sn+(t?" part"+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},w.resetFragmentLoading=function(e){this.fragCurrent&&this.fragContextChanged(e)||(this.state=T.IDLE)},w.onFragmentOrKeyLoadError=function(e,t){if(!t.fatal){var r=t.frag;if(r&&r.type===e){var n=this.fragCurrent;console.assert(n&&r.sn===n.sn&&r.level===n.level&&r.urlId===n.urlId,"Frag load error must match current frag to retry");var i=this.config;if(this.fragLoadError+1<=i.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(r.level))return;var a=Math.min(Math.pow(2,this.fragLoadError)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=T.FRAG_LOADING_WAITING_RETRY}else t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=T.IDLE):(o.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=T.ERROR)}}},w.afterBufferFlushed=function(e,t,r){if(e){var n=s.BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,r),this.state===T.ENDED&&this.resetLoadingState()}},w.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=T.IDLE},w.resetLiveStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;if(null!=t&&t.live)return this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},w.updateLevelTiming=function(e,t,r,n){var i=this,a=r.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return i.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+u+") resetting transmuxer to fallback to playlist timing"),i.resetTransmuxer(),t||!1;var d=n?0:c.updateFragPTSDTS(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return i.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:r,drift:d,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)?(this.state=T.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:e,part:t})):this.resetLoadingState()},w.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},b=i,(A=[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])&&E(b.prototype,A),S&&E(b,S),i}(i.default)},"./src/controller/buffer-controller.ts":
51
+ /*! exports provided: State, default */function(t,e,r){r.r(e),r.d(e,"State",(function(){return _})),r.d(e,"default",(function(){return b}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../task-loop */"./src/task-loop.ts"),s=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),d=r(/*! ./level-helper */"./src/controller/level-helper.ts"),c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),h=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),f=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),m=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),v=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function E(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function T(t,e){return(T=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var _={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},b=function(t){var e,r;function n(e,r,i){var n;return(n=t.call(this)||this).hls=void 0,n.fragPrevious=null,n.fragCurrent=null,n.fragmentTracker=void 0,n.transmuxer=null,n._state=_.STOPPED,n.media=void 0,n.mediaBuffer=void 0,n.config=void 0,n.bitrateTest=!1,n.lastCurrentTime=0,n.nextLoadPosition=0,n.startPosition=0,n.loadedmetadata=!1,n.fragLoadError=0,n.retryDate=0,n.levels=null,n.fragmentLoader=void 0,n.levelLastLoaded=null,n.startFragRequested=!1,n.decrypter=void 0,n.initPTS=[],n.onvseeking=null,n.onvended=null,n.logPrefix="",n.log=void 0,n.warn=void 0,n.logPrefix=i,n.log=o.logger.log.bind(o.logger,i+":"),n.warn=o.logger.warn.bind(o.logger,i+":"),n.hls=e,n.fragmentLoader=new g.default(e.config),n.fragmentTracker=r,n.config=e.config,n.decrypter=new m.default(e,e.config),e.on(l.Events.KEY_LOADED,n.onKeyLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)),n}r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,T(e,r);var b,S,A,L=n.prototype;return L.doTick=function(){this.onTickEnd()},L.onTickEnd=function(){},L.startLoad=function(t){},L.stopLoad=function(){this.fragmentLoader.abort();var t=this.fragCurrent;t&&this.fragmentTracker.removeFragment(t),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=_.STOPPED},L._streamEnded=function(t,e){var r=this.fragCurrent,i=this.fragmentTracker;if(!e.live&&r&&r.sn===e.endSN&&!t.nextStart){var n=i.getState(r);return n===s.FragmentState.PARTIAL||n===s.FragmentState.OK}return!1},L.onMediaAttached=function(t,e){var r=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===_.STOPPED&&this.startLoad(i.startPosition)},L.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},L.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,r=this.media,n=this.mediaBuffer,s=this.state,o=r?r.currentTime:0,l=a.BufferHelper.bufferInfo(n||r,o,t.maxBufferHole);if(this.log("media seeking to "+(Object(i.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+s),s===_.ENDED)this.resetLoadingState();else if(e&&!l.len){var u=t.maxFragLookUpTolerance,d=e.start-u,c=e.start+e.duration+u;(o<d||o>c)&&(e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.loader.abort()),this.resetLoadingState())}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tick()},L.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},L.onKeyLoaded=function(t,e){if(this.state===_.KEY_LOADING&&e.frag===this.fragCurrent&&this.levels){this.state=_.IDLE;var r=this.levels[e.frag.level].details;r&&this.loadFragment(e.frag,r,e.frag.start)}},L.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},L.onHandlerDestroyed=function(){this.state=_.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,t.prototype.onHandlerDestroyed.call(this)},L.loadKey=function(t,e){this.log("Loading key for "+t.sn+" of ["+e.startSN+"-"+e.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=_.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(l.Events.KEY_LOADING,{frag:t})},L.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},L._loadFragForPlayback=function(t,e,r){var i=this;this._doFragLoad(t,e,r,(function(e){if(i.fragContextChanged(t))return i.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){i.fragLoadError=0;var r=i.state;if(!i.fragContextChanged(t))return"payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(l.Events.FRAG_LOADED,e),i.state===_.BACKTRACKING)?(i.fragmentTracker.backtrack(t,e),void i.resetFragmentLoading(t)):void i._handleFragmentLoadComplete(e);(r===_.FRAG_LOADING||r===_.BACKTRACKING||!i.fragCurrent&&r===_.PARSING)&&(i.fragmentTracker.removeFragment(t),i.state=_.IDLE)}})).catch((function(e){i.warn(e),i.resetFragmentLoading(t)}))},L.flushMainBuffer=function(t,e,r){void 0===r&&(r=null);var i={startOffset:t,endOffset:e,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)},L._loadInitSegment=function(t){var e=this;this._doFragLoad(t).then((function(r){if(!r||e.fragContextChanged(t)||!e.levels)throw new Error("init load aborted");return r})).then((function(r){var i=e.hls,n=r.payload,s=t.decryptdata;if(n&&n.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return e.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(e){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:a,tdecrypt:n}}),r.payload=e,r}))}return r})).then((function(r){var i=e.fragCurrent,n=e.hls,s=e.levels;if(!s)throw new Error("init load aborted, missing levels");var a=s[t.level].details;console.assert(a,"Level details are defined when init segment is loaded");var o=a.initSegment;console.assert(o,"Fragment initSegment is defined when init segment is loaded");var u=t.stats;e.state=_.IDLE,e.fragLoadError=0,o.data=new Uint8Array(r.payload),u.parsing.start=u.buffering.start=self.performance.now(),u.parsing.end=u.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:u,frag:i,part:null,id:t.type}),e.tick()})).catch((function(r){e.warn(r),e.resetFragmentLoading(t)}))},L.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},L.fragBufferedComplete=function(t,e){var r=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" "+v.default.toString(a.BufferHelper.getBuffered(r))),this.state=_.IDLE,this.tick()},L._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,s=!n||0===n.length||n.some((function(t){return!t})),a=new c.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);e.flush(a)}},L._handleFragmentLoadProgress=function(t){},L._doFragLoad=function(t,e,r,n){var s=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(t.start,r||0),this.config.lowLatencyMode&&e){var a=e.partList;if(a&&n){r>t.end&&e.fragmentHint&&(t=e.fragmentHint);var o=this.getNextPart(a,t,r);if(o>-1){var u=a[o];return this.log("Loading part sn: "+t.sn+" p: "+u.index+" cc: "+t.cc+" of playlist ["+e.startSN+"-"+e.endSN+"] parts [0-"+o+"-"+(a.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=_.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,part:a[o],targetBufferTime:r}),this.doFragPartsLoad(t,a,o,n).catch((function(t){return s.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(a,r))return Promise.resolve(null)}}return this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(e?"of ["+e.startSN+"-"+e.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),Object(i.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=_.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.fragmentLoader.load(t,n).catch((function(t){return s.handleFragLoadError(t)}))},L.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise((function(s,a){var o=[];!function r(u){var d=e[u];n.fragmentLoader.loadPart(t,d,i).then((function(i){o[d.index]=i;var a=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var c=e[u+1];if(!c||c.fragment!==t)return s({frag:t,part:a,partsLoaded:o});r(u+1)})).catch(a)}(r)}))},L.handleFragLoadError=function(t){var e=t.data;return e&&e.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(l.Events.ERROR,e),null},L._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===_.PARSING){var r=e.frag,i=e.part,n=e.level,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s),this.updateLevelTiming(r,i,n,t.partial)}else this.fragCurrent||(this.state=_.IDLE)},L.getCurrentContext=function(t){var e=this.levels,r=t.level,i=t.sn,n=t.part;if(!e||!e[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var s=e[r],a=n>-1?d.getPartWith(s,i,n):null,o=a?a.fragment:d.getFragmentWithSN(s,i);return o?{frag:o,part:a,level:s}:null},L.bufferFragmentData=function(t,e,r,i){if(t&&this.state===_.PARSING){var n=t.data1,s=t.data2,a=n;if(n&&s&&(a=Object(h.appendUint8Array)(n,s)),a&&a.length){var o={type:t.type,frag:e,part:r,chunkMeta:i,parent:e.type,data:a};this.hls.trigger(l.Events.BUFFER_APPENDING,o),t.dropped&&t.independent&&!r&&this.flushBufferGap(e)}}},L.flushBufferGap=function(t){var e=this.media;if(e)if(a.BufferHelper.isBuffered(e,e.currentTime)){var r=e.currentTime,i=a.BufferHelper.bufferInfo(e,r,0),n=t.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(t.start-s,i.end-s),r+s);t.start-o>s&&this.flushMainBuffer(o,t.start)}else this.flushMainBuffer(0,t.start)},L.reduceMaxBufferLength=function(t){var e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},L.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var n,s=this.config,a=r[0].start;if(!e.initSegment||e.initSegment.data||this.bitrateTest)if(e.live){var o=s.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(e,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:t)}else t<=a&&(n=r[0]);else n=e.initSegment;if(!n){var l=s.lowLatencyMode?e.partEnd:e.fragmentEnd;n=this.getFragmentAtPosition(t,l,e)}return n},L.getNextPart=function(t,e,r){for(var i=-1,n=!1,s=!0,a=0,o=t.length;a<o;a++){var l=t[a];if(s=s&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;!u&&(n||l.independent||s)&&l.fragment===e&&(i=a),n=u}return i},L.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},L.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=Object(p.findFragmentByPDT)(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=t.startSN&&n<=t.endSN){var s=e[n-t.startSN];r.cc===s.cc&&(i=s,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=Object(p.findFragWithCC)(e,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(i=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},L.getFragmentAtPosition=function(t,e,r){var i,n=this.config,a=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,d=n.maxFragLookUpTolerance,c=!!(n.lowLatencyMode&&r.partList&&u);if(c&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),t<e){var h=t>e-d?0:d;i=Object(p.findFragmentByPTS)(a,o,t,h)}else i=o[o.length-1];if(i){var f=i.sn-r.startSN,g=a&&i.level===a.level,m=o[f+1];if(this.fragmentTracker.getState(i)===s.FragmentState.BACKTRACKED){i=null;for(var v=f;o[v]&&this.fragmentTracker.getState(o[v])===s.FragmentState.BACKTRACKED;)i=a?o[v--]:o[--v];i||(i=m)}else a&&i.sn===a.sn&&!c&&g&&(i.sn<l&&this.fragmentTracker.getState(m)!==s.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+m.sn),i=m):i=null)}return i},L.synchronizeToLiveEdge=function(t){var e=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,s=t.fragments[0].start,a=t.edge,o=n>=s-e.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&r.readyState<4||n<a-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+a+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},L.alignPlaylists=function(t,e){var r=this.levels,n=this.levelLastLoaded,s=null!==n?r[n]:null,a=0;return e&&t.fragments.length>0?(a=t.fragments[0].start,t.alignedSliding&&Object(i.isFiniteNumber)(a)?this.log("Live playlist sliding:"+a.toFixed(3)):a||(this.warn("["+this.constructor.name+"] Live playlist - outdated PTS, unknown sliding"),Object(f.alignStream)(this.fragPrevious,s,t))):(this.log("Live playlist - first load, unknown sliding"),Object(f.alignStream)(this.fragPrevious,s,t)),a},L.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},L.setStartPosition=function(t,e){var r=this.startPosition;if(-1===this.startPosition||-1===this.lastCurrentTime){var n=t.startTimeOffset;Object(i.isFiniteNumber)(n)?(n<0&&(this.log("Negative start time offset "+n+", count from end of last fragment"),n=e+t.totalduration+n),this.log("Start time offset found in playlist, adjust startPosition to "+n),this.startPosition=r=n):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},L.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},L.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},L.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=_.IDLE)},L.onFragmentOrKeyLoadError=function(t,e){if(!e.fatal){var r=e.frag;if(r&&r.type===t){var i=this.fragCurrent;console.assert(i&&r.sn===i.sn&&r.level===i.level&&r.urlId===i.urlId,"Frag load error must match current frag to retry");var n=this.config;if(this.fragLoadError+1<=n.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(r.level))return;var s=Math.min(Math.pow(2,this.fragLoadError)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+t+" "+r.level+" failed to load, retrying in "+s+"ms"),this.retryDate=self.performance.now()+s,this.fragLoadError++,this.state=_.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=_.IDLE):(o.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=_.ERROR)}}},L.afterBufferFlushed=function(t,e,r){if(t){var i=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===_.ENDED&&this.resetLoadingState()}},L.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=_.IDLE},L.resetLiveStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;if(null!=e&&e.live)return this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},L.updateLevelTiming=function(t,e,r,i){var n=this,s=r.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(e,a){var o=t.elementaryStreams[a];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return n.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+u+") resetting transmuxer to fallback to playlist timing"),n.resetTransmuxer(),e||!1;var c=i?0:d.updateFragPTSDTS(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:s,level:r,drift:c,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1)?(this.state=_.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})):this.resetLoadingState()},L.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},b=n,(S=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}])&&E(b.prototype,S),A&&E(b,A),n}(n.default)},"./src/controller/buffer-controller.ts":
52
52
  /*!*********************************************!*\
53
53
  !*** ./src/controller/buffer-controller.ts ***!
54
54
  \*********************************************/
55
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return h}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),d=Object(l.getMediaSource)(),f=/([ha]vc.)(?:\.[^.,]+)+/,h=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.hls,r=t.media,n=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),r&&(t.updateMediaElementDuration(),e.trigger(i.Events.MEDIA_ATTACHED,{media:r})),n&&n.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null},t.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.BUFFER_RESET,this.onBufferReset,this),e.on(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(i.Events.BUFFER_EOS,this.onBufferEos,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(i.Events.FRAG_PARSED,this.onFragParsed,this),e.on(i.Events.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.BUFFER_RESET,this.onBufferReset,this),e.off(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(i.Events.BUFFER_EOS,this.onBufferEos,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(i.Events.FRAG_PARSED,this.onFragParsed,this),e.off(i.Events.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&d){var n=this.mediaSource=new d;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(i.Events.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this,t=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(r){var n=t[r];try{n&&(e.removeBufferListeners(r),e.mediaSource&&e.mediaSource.removeSourceBuffer(n),t[r]=void 0)}catch(e){a.logger.warn("[buffer-controller]: Failed to reset the "+r+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,n=Object.keys(this.sourceBuffer).length;Object.keys(t).forEach((function(e){if(n){var i=r.tracks[e];if(i&&"function"==typeof i.buffer.changeType){var a=t[e],s=a.codec,o=a.levelCodec,l=a.container;if((i.levelCodec||i.codec).replace(f,"$1")!==(o||s).replace(f,"$1")){var u=l+";codecs="+(o||s);r.appendChangeType(e,u)}}}else r.pendingTracks[e]=t[e]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,n=this.operationQueue,i={execute:function(){var i=r.sourceBuffer[e];i&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),i.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};n.append(i,e)},t.onBufferAppending=function(e,t){var r=this,n=this.hls,l=this.operationQueue,u=this.tracks,c=t.data,d=t.type,f=t.frag,h=t.part,p=t.chunkMeta,v=p.buffering[d],g=self.performance.now();v.start=g;var m=f.stats.buffering,y=h?h.stats.buffering:null;0===m.start&&(m.start=g),y&&0===y.start&&(y.start=g);var E=u.audio,_="audio"===d&&1===p.id&&"audio/mpeg"===(null==E?void 0:E.container),T={execute:function(){if(v.executeStart=self.performance.now(),_){var e=r.sourceBuffer[d];if(e){var t=f.start-e.timestampOffset;Math.abs(t)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+t+") sn: "+f.sn+")"),e.timestampOffset=f.start)}}r.appendExecutor(c,d)},onStart:function(){},onComplete:function(){var e=self.performance.now();v.executeEnd=v.end=e,0===m.first&&(m.first=e),y&&0===y.first&&(y.first=e);var t=r.sourceBuffer,n={};for(var a in t)n[a]=o.BufferHelper.getBuffered(t[a]);r.appendError=0,r.hls.trigger(i.Events.BUFFER_APPENDED,{type:d,frag:f,part:h,chunkMeta:p,parent:f.type,timeRanges:n})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",e);var t={type:s.ErrorTypes.MEDIA_ERROR,parent:f.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,t.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>n.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),n.trigger(i.Events.ERROR,t)}};l.append(T,d)},t.onBufferFlushing=function(e,t){var r=this,n=this.operationQueue,s=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(i.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?n.append(s(t.type),t.type):(n.append(s("audio"),"audio"),n.append(s("video"),"video"))},t.onFragParsed=function(e,t){var r=this,n=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:n.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers((function(){var e=self.performance.now();n.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:n.stats;r.hls.trigger(i.Events.FRAG_BUFFERED,{frag:n,part:s,stats:t,id:n.type})}),o)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,n){var i=r.sourceBuffer[n];return t.type&&t.type!==n||i&&!i.ended&&(i.ended=!0,a.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS")),e&&!(i&&!i.ended)}),!0)&&this.blockBuffers((function(){var e=r.mediaSource;e&&"open"===e.readyState&&e.endOfStream()}))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==t){var s=this.getSourceBufferTypes();if(s.length){var l=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(n.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,c=t.levelTargetDuration,d=Math.max(l,c),f=Math.floor(u/c)*c-d;s.forEach((function(r){var n=a[r];if(n){var s=o.BufferHelper.getBuffered(n);s.length>0&&f>s.start(0)&&(e.trigger(i.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),t.live&&e.trigger(i.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),e.trigger(i.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:r}))}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,s=e.fragments[0].start+e.totalduration,o=r.duration,l=Object(n.isFiniteNumber)(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(s>l&&s>o||!Object(n.isFiniteNumber)(o))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),i.duration=s)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var n=Math.max(0,r[0].start),i=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,i)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,n=Object.keys(r).length;if(n&&!e||2===n){this.createSourceBuffers(r),this.pendingTracks={};var a=Object.keys(this.sourceBuffer);if(0===a.length)return void this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(e){t.executeNext(e)}))}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var o in e)if(!t[o]){var l=e[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,c=l.container+";codecs="+u;a.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var d=t[o]=r.addSourceBuffer(c),f=o;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[o]={buffer:d,codec:u,container:l.container,levelCodec:l.levelCodec,id:l.id},n++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:c})}}n&&this.hls.trigger(i.Events.BUFFER_CREATED,{tracks:this.tracks})},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(e);r&&r.onError(t)},t.removeExecutor=function(e,t,r){var i=this.media,s=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!i||!s||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=Object(n.isFiniteNumber)(i.duration)?i.duration:1/0,c=Object(n.isFiniteNumber)(s.duration)?s.duration:1/0,d=Math.max(0,t),f=Math.min(r,u,c);f>d?(a.logger.log("[buffer-controller]: Removing ["+d+","+f+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(d,f)):o.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,n=this.sourceBuffer[t];if(!n)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);n.ended=!1,console.assert(!n.updating,t+" sourceBuffer must not be updating"),n.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(e);var n=this.operationQueue,i=t.map((function(e){return n.appendBlocker(e)}));Promise.all(i).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];t&&t.updating||n.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var n=this.sourceBuffer[e];if(n){var i=r.bind(this,e);this.listeners[e].push({event:t,listener:i}),n.addEventListener(t,i)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}()},"./src/controller/buffer-operation-queue.ts":
55
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),c=Object(l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function t(t){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=e.hls,r=e.media,i=e.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),r&&(e.updateMediaElementDuration(),t.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null},e.registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(n.Events.BUFFER_RESET,this.onBufferReset,this),t.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(n.Events.BUFFER_EOS,this.onBufferEos,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(n.Events.FRAG_PARSED,this.onFragParsed,this),t.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(n.Events.BUFFER_RESET,this.onBufferReset,this),t.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(n.Events.BUFFER_EOS,this.onBufferEos,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(n.Events.FRAG_PARSED,this.onFragParsed,this),t.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&c){var i=this.mediaSource=new c;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):s.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this,e=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(r){var i=e[r];try{i&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(i),e[r]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+r+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=Object.keys(this.sourceBuffer).length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var s=e[t],a=s.codec,o=s.levelCodec,l=s.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(o||a).replace(h,"$1")){var u=l+";codecs="+(o||a);r.appendChangeType(t,u)}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,d=e.data,c=e.type,h=e.frag,f=e.part,p=e.chunkMeta,g=p.buffering[c],m=self.performance.now();g.start=m;var v=h.stats.buffering,y=f?f.stats.buffering:null;0===v.start&&(v.start=m),y&&0===y.start&&(y.start=m);var E=u.audio,T="audio"===c&&1===p.id&&"audio/mpeg"===(null==E?void 0:E.container),_={execute:function(){if(g.executeStart=self.performance.now(),T){var t=r.sourceBuffer[c];if(t){var e=h.start-t.timestampOffset;Math.abs(e)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+e+") sn: "+h.sn+")"),t.timestampOffset=h.start)}}r.appendExecutor(d,c)},onStart:function(){},onComplete:function(){var t=self.performance.now();g.executeEnd=g.end=t,0===v.first&&(v.first=t),y&&0===y.first&&(y.first=t);var e=r.sourceBuffer,i={};for(var s in e)i[s]=o.BufferHelper.getBuffered(e[s]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:c,frag:h,part:f,chunkMeta:p,parent:h.type,timeRanges:i})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",t);var e={type:a.ErrorTypes.MEDIA_ERROR,parent:h.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=a.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,e.details=a.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(n.Events.ERROR,e)}};l.append(_,c)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:t})},onError:function(e){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):(i.append(a("audio"),"audio"),i.append(a("video"),"video"))},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})}),o)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return e.type&&e.type!==i||n&&!n.ended&&(n.ended=!0,s.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),t&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var t=r.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,s=this.sourceBuffer;if(r&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var l=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(i.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,d=e.levelTargetDuration,c=Math.max(l,d),h=Math.floor(u/d)*d-c;a.forEach((function(r){var i=s[r];if(i){var a=o.BufferHelper.getBuffered(i);a.length>0&&h>a.start(0)&&(t.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),e.live&&t.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),t.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:r}))}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,n=this.mediaSource,a=t.fragments[0].start+t.totalduration,o=r.duration,l=Object(i.isFiniteNumber)(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(a>l&&a>o||!Object(i.isFiniteNumber)(o))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var s=Object.keys(this.sourceBuffer);if(0===s.length)return void this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){e.executeNext(t)}))}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in t)if(!e[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,d=l.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+d+")");try{var c=e[o]=r.addSourceBuffer(d),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:c,codec:u,container:l.container,levelCodec:l.levelCodec,id:l.id},i++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:d})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",e),this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(t);r&&r.onError(e)},e.removeExecutor=function(t,e,r){var n=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!n||!a||!l)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=Object(i.isFiniteNumber)(n.duration)?n.duration:1/0,d=Object(i.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,e),h=Math.min(r,u,d);h>c?(s.logger.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(c,h)):o.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return s.logger.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,console.assert(!i.updating,e+" sourceBuffer must not be updating"),i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
56
56
  /*!**************************************************!*\
57
57
  !*** ./src/controller/buffer-operation-queue.ts ***!
58
58
  \**************************************************/
59
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return i}));var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t){var r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),r},t.executeNext=function(e){var t=this.buffers,r=this.queues,i=t[e],a=r[e];if(a.length){var s=a[0];try{s.execute()}catch(e){n.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(e),i&&i.updating||a.shift()}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}()},"./src/controller/cap-level-controller.ts":
59
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return n}));var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise((function(t){e=t})),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.buffers,r=this.queues,n=e[t],s=r[t];if(s.length){var a=s[0];try{a.execute()}catch(t){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(t),n&&n.updating||s.shift()}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
60
60
  /*!************************************************!*\
61
61
  !*** ./src/controller/cap-level-controller.ts ***!
62
62
  \************************************************/
63
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t,r,a,s=e.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){e.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,n=this.hls.levels;if(!n.length)return-1;var i=n.filter((function(n,i){return e.isLevelAllowed(i,r.restrictedLevels)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},e.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},e.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var n,i,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(n=o,!(i=e[s+1])||n.width!==i.width||n.height!==i.height)){a=s;break}}return a},t=e,a=[{key:"contentScaleFactor",get:function(){var e=1;try{e=self.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*e.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*e.contentScaleFactor}}])&&i(t.prototype,r),a&&i(t,a),e}();t.default=a},"./src/controller/eme-controller.ts":
63
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var s=function(){function t(t){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var e,r,s,a=t.prototype;return a.setStreamController=function(t){this.streamController=t},a.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var t=this.hls;t.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var t=this.hls;t.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(e,r){t.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},a.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null},a.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},a.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(i,n){return t.isLevelAllowed(n,r.restrictedLevels)&&n<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},t.isLevelAllowed=function(t,e){return void 0===e&&(e=[]),-1===e.indexOf(t)},t.getMaxLevelByMediaSize=function(t,e,r){if(!t||!t.length)return-1;for(var i,n,s=t.length-1,a=0;a<t.length;a+=1){var o=t[a];if((o.width>=e||o.height>=r)&&(i=o,!(n=t[a+1])||i.width!==n.width||i.height!==n.height)){s=a;break}}return s},e=t,s=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&n(e.prototype,r),s&&n(e,s),t}();e.default=s},"./src/controller/eme-controller.ts":
64
64
  /*!******************************************!*\
65
65
  !*** ./src/controller/eme-controller.ts ***!
66
66
  \******************************************/
67
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var l=function(){function e(e){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=e,this._config=e.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var t,r,l,u=e.prototype;return u.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},u._registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u._unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u.getLicenseServerUrl=function(e){switch(e){case s.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},u._attemptKeySystemAccess=function(e,t,r){var n=this,i=function(e,t,r,n){switch(e){case s.KeySystems.WIDEVINE:return function(e,t,r){var n={audioCapabilities:[],videoCapabilities:[]};return e.forEach((function(e){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||""})})),t.forEach((function(e){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||""})})),[n]}(t,r,n);default:throw new Error("Unknown key-system: "+e)}}(e,t,r,this._drmSystemOptions);a.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(e,i);this.mediaKeysPromise=o.then((function(t){return n._onMediaKeySystemAccessObtained(e,t)})),o.catch((function(t){a.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))},u._onMediaKeySystemAccessObtained=function(e,t){var r=this;a.logger.log('Access for key-system "'+e+'" obtained');var n={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(n);var i=Promise.resolve().then((function(){return t.createMediaKeys()})).then((function(t){return n.mediaKeys=t,a.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated(),t}));return i.catch((function(e){a.logger.error("Failed to create media-keys:",e)})),i},u._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},u._onNewMediaKeySession=function(e){var t=this;a.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},u._onKeySessionMessage=function(e,t){a.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){a.logger.log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t)}))},u.onMediaEncrypted=function(e){var t=this;if(a.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),!this.mediaKeysPromise)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){t._media&&(t._attemptSetMediaKeys(r),t._generateRequestWithPreferredKeySession(e.initDataType,e.initData))};this.mediaKeysPromise.then(r).catch(r)},u._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});a.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},u._generateRequestWithPreferredKeySession=function(e,t){var r=this,s=this._mediaKeysList[0];if(!s)return a.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(s.mediaKeysSessionInitialized)a.logger.warn("Key-Session already initialized but requested again");else{var o=s.mediaKeysSession;if(!o)return a.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return a.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});a.logger.log('Generating key-session request for "'+e+'" init data type'),s.mediaKeysSessionInitialized=!0,o.generateRequest(e,t).then((function(){a.logger.debug("Key-session generation succeeded")})).catch((function(e){a.logger.error("Error generating key-session request:",e),r.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},u._createLicenseXhr=function(e,t,r){var n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,e,t,r);var i=this._licenseXhrSetup;if(i)try{i.call(this.hls,n,e),i=void 0}catch(e){a.logger.error(e)}try{n.readyState||n.open("POST",e,!0),i&&i.call(this.hls,n,e)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return n},u._onLicenseRequestReadyStageChange=function(e,t,r,s){switch(e.readyState){case 4:if(200===e.status){this._requestLicenseFailureCount=0,a.logger.log("License request succeeded");var o=e.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,e,t)}catch(e){a.logger.error(e)}s(o)}else{if(a.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var u=3-this._requestLicenseFailureCount+1;a.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(r,s)}}},u._generateLicenseRequestChallenge=function(e,t){switch(e.mediaKeySystemDomain){case s.KeySystems.WIDEVINE:return t}throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},u._requestLicense=function(e,t){a.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return a.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var s=this.getLicenseServerUrl(r.mediaKeySystemDomain),o=this._createLicenseXhr(s,e,t);a.logger.log("Sending license request to URL: "+s);var l=this._generateLicenseRequestChallenge(r,e);o.send(l)}catch(e){a.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},u.onMediaAttached=function(e,t){if(this._emeEnabled){var r=t.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},u.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},u.onManifestParsed=function(e,t){if(this._emeEnabled){var r=t.levels.map((function(e){return e.audioCodec})).filter((function(e){return!!e})),n=t.levels.map((function(e){return e.videoCodec})).filter((function(e){return!!e}));this._attemptKeySystemAccess(s.KeySystems.WIDEVINE,r,n)}},t=e,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(t.prototype,r),l&&o(t,l),e}();t.default=l},"./src/controller/fps-controller.ts":
67
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(t){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=t,this._config=t.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var e,r,l,u=t.prototype;return u.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},u._registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u._unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u.getLicenseServerUrl=function(t){switch(t){case a.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+t+'"')},u._attemptKeySystemAccess=function(t,e,r){var i=this,n=function(t,e,r,i){switch(t){case a.KeySystems.WIDEVINE:return function(t,e,r){var i={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:r.audioRobustness||""})})),e.forEach((function(t){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:r.videoRobustness||""})})),[i]}(e,r,i);default:throw new Error("Unknown key-system: "+t)}}(t,e,r,this._drmSystemOptions);s.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(t,n);this.mediaKeysPromise=o.then((function(e){return i._onMediaKeySystemAccessObtained(t,e)})),o.catch((function(e){s.logger.error('Failed to obtain key-system "'+t+'" access:',e)}))},u._onMediaKeySystemAccessObtained=function(t,e){var r=this;s.logger.log('Access for key-system "'+t+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:t};this._mediaKeysList.push(i);var n=Promise.resolve().then((function(){return e.createMediaKeys()})).then((function(e){return i.mediaKeys=e,s.logger.log('Media-keys created for key-system "'+t+'"'),r._onMediaKeysCreated(),e}));return n.catch((function(t){s.logger.error("Failed to create media-keys:",t)})),n},u._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach((function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),t._onNewMediaKeySession(e.mediaKeysSession))}))},u._onNewMediaKeySession=function(t){var e=this;s.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(r){e._onKeySessionMessage(t,r.message)}),!1)},u._onKeySessionMessage=function(t,e){s.logger.log("Got EME message event, creating license request"),this._requestLicense(e,(function(e){s.logger.log("Received license data (length: "+(e?e.byteLength:e)+"), updating key-session"),t.update(e)}))},u.onMediaEncrypted=function(t){var e=this;if(s.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){e._media&&(e._attemptSetMediaKeys(r),e._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(r).catch(r)},u._attemptSetMediaKeys=function(t){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},u._generateRequestWithPreferredKeySession=function(t,e){var r=this,a=this._mediaKeysList[0];if(!a)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(a.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var o=a.mediaKeysSession;if(!o)return s.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!e)return s.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});s.logger.log('Generating key-session request for "'+t+'" init data type'),a.mediaKeysSessionInitialized=!0,o.generateRequest(t,e).then((function(){s.logger.debug("Key-session generation succeeded")})).catch((function(t){s.logger.error("Error generating key-session request:",t),r.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},u._createLicenseXhr=function(t,e,r){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,t,e,r);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,i,t),n=void 0}catch(t){s.logger.error(t)}try{i.readyState||i.open("POST",t,!0),n&&n.call(this.hls,i,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return i},u._onLicenseRequestReadyStageChange=function(t,e,r,a){switch(t.readyState){case 4:if(200===t.status){this._requestLicenseFailureCount=0,s.logger.log("License request succeeded");var o=t.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,t,e)}catch(t){s.logger.error(t)}a(o)}else{if(s.logger.error("License Request XHR failed ("+e+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var u=3-this._requestLicenseFailureCount+1;s.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(r,a)}}},u._generateLicenseRequestChallenge=function(t,e){switch(t.mediaKeySystemDomain){case a.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},u._requestLicense=function(t,e){s.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var a=this.getLicenseServerUrl(r.mediaKeySystemDomain),o=this._createLicenseXhr(a,t,e);s.logger.log("Sending license request to URL: "+a);var l=this._generateLicenseRequestChallenge(r,t);o.send(l)}catch(t){s.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},u.onMediaAttached=function(t,e){if(this._emeEnabled){var r=e.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},u.onMediaDetached=function(){var t=this._media,e=this._mediaKeysList;t&&(t.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map((function(t){if(t.mediaKeysSession)return t.mediaKeysSession.close().catch((function(){}))}))).then((function(){return t.setMediaKeys(null)})).catch((function(){})))},u.onManifestParsed=function(t,e){if(this._emeEnabled){var r=e.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),i=e.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a.KeySystems.WIDEVINE,r,i)}},e=t,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(e.prototype,r),l&&o(e,l),t}();e.default=l},"./src/controller/fps-controller.ts":
68
68
  /*!******************************************!*\
69
69
  !*** ./src/controller/fps-controller.ts ***!
70
70
  \******************************************/
71
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var a=performance.now();if(t){if(this.lastTime){var s=a-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/s,c=this.hls;if(c.trigger(n.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>c.config.fpsDroppedMonitoringThreshold*l){var d=c.currentLevel;i.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===c.autoLevelCapping||c.autoLevelCapping>=d)&&(d-=1,c.trigger(n.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}();t.default=a},"./src/controller/fragment-finders.ts":
71
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var s=performance.now();if(e){if(this.lastTime){var a=s-this.lastTime,o=r-this.lastDroppedFrames,l=e-this.lastDecodedFrames,u=1e3*o/a,d=this.hls;if(d.trigger(i.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>d.config.fpsDroppedMonitoringThreshold*l){var c=d.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===d.autoLevelCapping||d.autoLevelCapping>=c)&&(c-=1,d.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();e.default=s},"./src/controller/fragment-finders.ts":
72
72
  /*!********************************************!*\
73
73
  !*** ./src/controller/fragment-finders.ts ***!
74
74
  \********************************************/
75
- /*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(e,t,r){r.r(t),r.d(t,"findFragmentByPDT",(function(){return a})),r.d(t,"findFragmentByPTS",(function(){return s})),r.d(t,"fragmentWithinToleranceTest",(function(){return o})),r.d(t,"pdtWithinToleranceTest",(function(){return l})),r.d(t,"findFragWithCC",(function(){return u}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function a(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(n.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(l(t,r,a))return a}return null}function s(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var a=null;if(e?a=t[e.sn-t[0].sn+1]:0===r&&0===t[0].start&&(a=t[0]),a&&0===o(r,n,a))return a;var s=i.default.search(t,o.bind(null,r,n));return s||a}function o(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var n=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=e?1:r.start-n>e&&r.start?-1:0}function l(e,t,r){var n=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>e}function u(e,t){return i.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}},"./src/controller/fragment-tracker.ts":
75
+ /*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,e,r){r.r(e),r.d(e,"findFragmentByPDT",(function(){return s})),r.d(e,"findFragmentByPTS",(function(){return a})),r.d(e,"fragmentWithinToleranceTest",(function(){return o})),r.d(e,"pdtWithinToleranceTest",(function(){return l})),r.d(e,"findFragWithCC",(function(){return u}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!Object(i.isFiniteNumber)(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<t.length;++n){var s=t[n];if(l(e,r,s))return s}return null}function a(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var s=null;if(t?s=e[t.sn-e[0].sn+1]:0===r&&0===e[0].start&&(s=e[0]),s&&0===o(r,i,s))return s;var a=n.default.search(e,o.bind(null,r,i));return a||s}function o(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0);var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function l(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}function u(t,e){return n.default.search(t,(function(t){return t.cc<e?1:t.cc>e?-1:0}))}},"./src/controller/fragment-tracker.ts":
76
76
  /*!********************************************!*\
77
77
  !*** ./src/controller/fragment-tracker.ts ***!
78
78
  \********************************************/
79
- /*! exports provided: FragmentState, FragmentTracker */function(e,t,r){r.r(t),r.d(t,"FragmentState",(function(){return n})),r.d(t,"FragmentTracker",(function(){return s}));var n,i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");!function(e){e.NOT_LOADED="NOT_LOADED",e.BACKTRACKED="BACKTRACKED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK"}(n||(n={}));var s=function(){function e(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(i.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(i.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(i.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(i.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var r=this.activeFragment,n=this.activeParts;if(!r)return null;if(n)for(var i=n.length;i--;){var s=n[i],o=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==o&&e<=o)return i>9&&(this.activeParts=n.slice(i-9)),s}else if(r.start<=e&&void 0!==r.appendedPTS&&e<=r.appendedPTS)return r}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,n=Object.keys(r),i=n.length;i--;){var a=r[n[i]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r){var n=this;Object.keys(this.fragments).forEach((function(i){var a=n.fragments[i];if(a)if(a.buffered){var s=a.range[e];s&&s.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(a.body),r}))}else a.body.type===r&&n.removeFragment(a.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,n=e.frag,i=e.part;if(r&&"initSegment"!==n.sn){var a=l(n),s=this.fragments[a];s&&(Object.keys(r).forEach((function(e){var a=n.elementaryStreams[e];if(a){var o=r[e],l=null!==i||!0===a.partial;s.range[e]=t.getBufferedTimes(n,i,l,o)}})),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},t.getBufferedTimes=function(e,t,r,n){for(var i={time:[],partial:r},a=t?t.start:e.start,s=t?t.end:e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<n.length;u++){var c=n.start(u)-this.bufferPadding,d=n.end(u)+this.bufferPadding;if(l>=c&&o<=d){i.time.push({startPTS:Math.max(a,n.start(u)),endPTS:Math.min(s,n.end(u))});break}if(a<d&&s>c)i.partial=!0,i.time.push({startPTS:Math.max(a,n.start(u)),endPTS:Math.min(s,n.end(u))});else if(s<=c)break}return i},t.getPartialFragment=function(e){var t,r,n,i=null,a=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var c=l[u];c&&o(c)&&(r=c.body.start-s,n=c.body.end+s,e>=r&&e<=n&&(t=Math.min(e-r,n-e),a<=t&&(i=c.body,a=t)))})),i},t.getState=function(e){var t=l(e),r=this.fragments[t];return r?r.buffered?o(r)?n.PARTIAL:n.OK:r.backtrack?n.BACKTRACKED:n.APPENDING:n.NOT_LOADED},t.backtrack=function(e,t){var r=l(e),n=this.fragments[r];if(!n||n.backtrack)return null;var i=n.backtrack=t||n.loaded;return n.loaded=null,i},t.getBacktrackData=function(e){var t=l(e),r=this.fragments[t];if(r){var n,i=r.backtrack;if(null!=i&&null!==(n=i.payload)&&void 0!==n&&n.byteLength)return i;this.removeFragment(e)}return null},t.isTimeBuffered=function(e,t,r){for(var n,i,a=0;a<r.length;a++){if(n=r.start(a)-this.bufferPadding,i=r.end(a)+this.bufferPadding,e>=n&&t<=i)return!0;if(t<=n)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!n){var i=l(r);this.fragments[i]={body:r,loaded:t,backtrack:null,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,n=t.frag,i=t.part,s=t.timeRanges;if(n.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=n,i){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(i)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(e){var t=s[e];if(r.detectEvictedFragments(e,t),!i)for(var a=0;a<t.length;a++)n.appendedPTS=Math.max(t.end(a),n.appendedPTS||0)}))},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=l(e);return!!this.fragments[t]},t.removeFragment=function(e){var t=l(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},e}();function o(e){var t,r;return e.buffered&&((null===(t=e.range.video)||void 0===t?void 0:t.partial)||(null===(r=e.range.audio)||void 0===r?void 0:r.partial))}function l(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":
79
+ /*! exports provided: FragmentState, FragmentTracker */function(t,e,r){r.r(e),r.d(e,"FragmentState",(function(){return i})),r.d(e,"FragmentTracker",(function(){return a}));var i,n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(i||(i={}));var a=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){if(e===s.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var a=i[n],o=a?a.end:r.appendedPTS;if(a.start<=t&&void 0!==o&&t<=o)return n>9&&(this.activeParts=i.slice(n-9)),a}else if(r.start<=t&&void 0!==r.appendedPTS&&t<=r.appendedPTS)return r}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var s=r[i[n]];if((null==s?void 0:s.body.type)===e&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},e.detectEvictedFragments=function(t,e,r){var i=this;Object.keys(this.fragments).forEach((function(n){var s=i.fragments[n];if(s)if(s.buffered){var a=s.range[t];a&&a.time.some((function(t){var r=!i.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&i.removeFragment(s.body),r}))}else s.body.type===r&&i.removeFragment(s.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var s=l(i),a=this.fragments[s];a&&(Object.keys(r).forEach((function(t){var s=i.elementaryStreams[t];if(s){var o=r[t],l=null!==n||!0===s.partial;a.range[t]=e.getBufferedTimes(i,n,l,o)}})),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body))}},e.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},s=e?e.start:t.start,a=e?e.end:t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s,u=0;u<i.length;u++){var d=i.start(u)-this.bufferPadding,c=i.end(u)+this.bufferPadding;if(l>=d&&o<=c){n.time.push({startPTS:Math.max(s,i.start(u)),endPTS:Math.min(a,i.end(u))});break}if(s<c&&a>d)n.partial=!0,n.time.push({startPTS:Math.max(s,i.start(u)),endPTS:Math.min(a,i.end(u))});else if(a<=d)break}return n},e.getPartialFragment=function(t){var e,r,i,n=null,s=0,a=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var d=l[u];d&&o(d)&&(r=d.body.start-a,i=d.body.end+a,t>=r&&t<=i&&(e=Math.min(t-r,i-t),s<=e&&(n=d.body,s=e)))})),n},e.getState=function(t){var e=l(t),r=this.fragments[e];return r?r.buffered?o(r)?i.PARTIAL:i.OK:r.backtrack?i.BACKTRACKED:i.APPENDING:i.NOT_LOADED},e.backtrack=function(t,e){var r=l(t),i=this.fragments[r];if(!i||i.backtrack)return null;var n=i.backtrack=e||i.loaded;return i.loaded=null,n},e.getBacktrackData=function(t){var e=l(t),r=this.fragments[e];if(r){var i,n=r.backtrack;if(null!=n&&null!==(i=n.payload)&&void 0!==i&&i.byteLength)return n;this.removeFragment(t)}return null},e.isTimeBuffered=function(t,e,r){for(var i,n,s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,t>=i&&e<=n)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=l(r);this.fragments[n]={body:r,loaded:e,backtrack:null,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,a=e.timeRanges;if(i.type===s.PlaylistLevelType.MAIN)if(this.activeFragment=i,n){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(n)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach((function(t){var e=a[t];if(r.detectEvictedFragments(t,e),!n)for(var s=0;s<e.length;s++)i.appendedPTS=Math.max(e.end(s),i.appendedPTS||0)}))},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=l(t);return!!this.fragments[e]},e.removeFragment=function(t){var e=l(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),delete this.fragments[e]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function o(t){var e,r;return t.buffered&&((null===(e=t.range.video)||void 0===e?void 0:e.partial)||(null===(r=t.range.audio)||void 0===r?void 0:r.partial))}function l(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
80
80
  /*!******************************************!*\
81
81
  !*** ./src/controller/gap-controller.ts ***!
82
82
  \******************************************/
83
- /*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(e,t,r){r.r(t),r.d(t,"STALL_MINIMUM_DURATION_MS",(function(){return o})),r.d(t,"MAX_START_GAP_JUMP",(function(){return l})),r.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return u})),r.d(t,"SKIP_BUFFER_RANGE_START",(function(){return c})),r.d(t,"default",(function(){return d}));var n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,c=.05,d=function(){function e(e,t,r,n){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=n}var t=e.prototype;return t.destroy=function(){this.hls=this.fragmentTracker=this.media=null},t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,u=r.seeking,c=this.seeking&&!u,d=!this.seeking&&u;if(this.seeking=u,a===e){if((d||c)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&n.BufferHelper.getBuffered(r).length){var f=n.BufferHelper.bufferInfo(r,a,0),h=f.len>0,p=f.nextStart||0;if(h||p){if(u){var v=f.len>l,g=!p||p-a>l&&!this.fragmentTracker.getPartialFragment(a);if(v||g)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var m,y=Math.max(p,f.start||0)-a,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(null==E||null===(m=E.details)||void 0===m?void 0:m.live)?2*E.details.targetduration:l;if(y>0&&y<=_)return void this._trySkipBufferHole(null)}var T=self.performance.now();if(null!==i){var b=T-i;!u&&b>=o&&this._reportStall(f.len);var A=n.BufferHelper.bufferInfo(r,a,t.maxBufferHole);this._tryFixBufferStall(A,b)}else this.stalled=T}}}else if(this.moved=!0,null!==i){if(this.stallReported){var S=self.performance.now()-i;s.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(S)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,n=this.fragmentTracker,i=this.media.currentTime,a=n.getPartialFragment(i);a&&this._trySkipBufferHole(a)||e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,o=this.media,l=o.currentTime,d=0,f=n.BufferHelper.getBuffered(o),h=0;h<f.length;h++){var p=f.start(h);if(l+t.maxBufferHole>=d&&l<p){var v=Math.max(p+c,o.currentTime+u);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+v),this.moved=!0,this.stalled=null,o.currentTime=v,e&&r.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+v,frag:e}),v}d=f.end(h)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,n=r.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<e.nudgeMaxRetry){var l=n+o*e.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+n+" to "+l),r.currentTime=l,t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},e}()},"./src/controller/id3-track-controller.ts":
83
+ /*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,e,r){r.r(e),r.d(e,"STALL_MINIMUM_DURATION_MS",(function(){return o})),r.d(e,"MAX_START_GAP_JUMP",(function(){return l})),r.d(e,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return u})),r.d(e,"SKIP_BUFFER_RANGE_START",(function(){return d})),r.d(e,"default",(function(){return c}));var i=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,d=.05,c=function(){function t(t,e,r,i){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.hls=this.fragmentTracker=this.media=null},e.poll=function(t){var e=this.config,r=this.media,n=this.stalled,s=r.currentTime,u=r.seeking,d=this.seeking&&!u,c=!this.seeking&&u;if(this.seeking=u,s===t){if((c||d)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&i.BufferHelper.getBuffered(r).length){var h=i.BufferHelper.bufferInfo(r,s,0),f=h.len>0,p=h.nextStart||0;if(f||p){if(u){var g=h.len>l,m=!p||p-s>l&&!this.fragmentTracker.getPartialFragment(s);if(g||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var v,y=Math.max(p,h.start||0)-s,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=(null==E||null===(v=E.details)||void 0===v?void 0:v.live)?2*E.details.targetduration:l;if(y>0&&y<=T)return void this._trySkipBufferHole(null)}var _=self.performance.now();if(null!==n){var b=_-n;!u&&b>=o&&this._reportStall(h.len);var S=i.BufferHelper.bufferInfo(r,s,e.maxBufferHole);this._tryFixBufferStall(S,b)}else this.stalled=_}}}else if(this.moved=!0,null!==n){if(this.stallReported){var A=self.performance.now()-n;a.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(A)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media.currentTime,s=i.getPartialFragment(n);s&&this._trySkipBufferHole(s)||t.len>r.maxBufferHole&&e>1e3*r.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},e._reportStall=function(t){var e=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,a.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+t+")"),e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t}))},e._trySkipBufferHole=function(t){for(var e=this.config,r=this.hls,o=this.media,l=o.currentTime,c=0,h=i.BufferHelper.getBuffered(o),f=0;f<h.length;f++){var p=h.start(f);if(l+e.maxBufferHole>=c&&l<p){var g=Math.max(p+d,o.currentTime+u);return a.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,t&&r.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+g,frag:t}),g}c=h.end(f)}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=r.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<t.nudgeMaxRetry){var l=i+o*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+i+" to "+l),r.currentTime=l,e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+i+" after "+t.nudgeMaxRetry+" nudges"),e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},t}()},"./src/controller/id3-track-controller.ts":
84
84
  /*!************************************************!*\
85
85
  !*** ./src/controller/id3-track-controller.ts ***!
86
86
  \************************************************/
87
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners()},t._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(Object(i.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Object(i.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=t.frag,n=t.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<n.length;s++){var o=a.getID3Frames(n[s].data);if(o){var l=n[s].pts,u=s<n.length-1?n[s+1].pts:r.end;u-l<=0&&(u=l+.25);for(var c=0;c<o.length;c++){var d=o[c];if(!a.isTimeStampFrame(d)){var f=new i(l,u,"");f.value=d,this.id3Track.addCue(f)}}}}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset,a=t.type;if(!a||"audio"===a){var s=this.id3Track;s&&Object(i.removeCuesInRange)(s,r,n)}},e}();t.default=s},"./src/controller/latency-controller.ts":
87
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners()},e._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(Object(n.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return Object(n.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=e.frag,i=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var n=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,a=0;a<i.length;a++){var o=s.getID3Frames(i[a].data);if(o){var l=i[a].pts,u=a<i.length-1?i[a+1].pts:r.end;u-l<=0&&(u=l+.25);for(var d=0;d<o.length;d++){var c=o[d];if(!s.isTimeStampFrame(c)){var h=new n(l,u,"");h.value=c,this.id3Track.addCue(h)}}}}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,s=e.type;if(!s||"audio"===s){var a=this.id3Track;a&&Object(n.removeCuesInRange)(a,r,i)}},t}();e.default=a},"./src/controller/latency-controller.ts":
88
88
  /*!**********************************************!*\
89
89
  !*** ./src/controller/latency-controller.ts ***!
90
90
  \**********************************************/
91
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return o}));var n=r(/*! ../errors */"./src/errors.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t,r,o,l=e.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(i.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(i.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(i.Events.ERROR,this.onError)},l.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(e,t){t.details===n.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var n=this.config,i=n.lowLatencyMode,a=n.maxLiveSyncPlaybackRate;if(i&&1!==a){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+t.targetduration);if(t.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},l.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t=e,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,n=e.targetduration,i=this.config,a=i.liveSyncDuration,s=i.liveSyncDurationCount,o=i.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*n);var c=n;return u+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var n=r.edge,i=e-t-this.edgeStalled,a=n-r.totalduration,s=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,i),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return r?e.buffered.end(r-1):t.edge-this.currentTime}}])&&s(t.prototype,r),o&&s(t,o),e}()},"./src/controller/level-controller.ts":
91
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return o}));var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(){function t(t){var e=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var e,r,o,l=t.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},l.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(t,e){var r=e.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(t,e){e.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,s=i.maxLiveSyncPlaybackRate;if(n&&1!==s){var a=this.targetLatency;if(null!==a){var o=r-a,l=o<Math.min(this.maxLatency,a+e.targetduration);if(e.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,d))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},l.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},e=t,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,s=n.liveSyncDuration,a=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==s?s:a*i);var d=i;return u+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,n=t-e-this.edgeStalled,s=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),a)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return r?t.buffered.end(r-1):e.edge-this.currentTime}}])&&a(e.prototype,r),o&&a(e,o),t}()},"./src/controller/level-controller.ts":
92
92
  /*!********************************************!*\
93
93
  !*** ./src/controller/level-controller.ts ***!
94
94
  \********************************************/
95
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return p}));var n=r(/*! ../types/level */"./src/types/level.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),p=function(e){var t,r;function l(t){var r;return(r=e.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=e,(t=l).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r);var p,v,g,m=l.prototype;return m._registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(i.Events.ERROR,this.onError,this)},m._unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(i.Events.ERROR,this.onError,this)},m.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},m.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),e.prototype.startLoad.call(this)},m.onManifestLoaded=function(e,t){var r,l,u=[],c=[],d=[],f={},p=!1,v=!1,g=!1;if(t.levels.forEach((function(e){var t=e.attrs;p=p||!(!e.width||!e.height),v=v||!!e.videoCodec,g=g||!!e.audioCodec,h&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(l=f[e.bitrate])?l.url.push(e.url):(l=new n.Level(e),f[e.bitrate]=l,u.push(l)),t&&(t.AUDIO&&Object(o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&Object(o.addGroupId)(l,"text",t.SUBTITLES))})),(p||v)&&g&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,n=e.height;return!!t||!(!r||!n)}))),u=u.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||Object(s.isCodecSupportedInMp4)(t,"audio"))&&(!r||Object(s.isCodecSupportedInMp4)(r,"video"))})),t.audioTracks&&(c=t.audioTracks.filter((function(e){return!e.audioCodec||Object(s.isCodecSupportedInMp4)(e.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(c)),t.subtitles&&(d=t.subtitles,Object(o.assignTrackIdsByGroup)(d)),u.length>0){r=u[0].bitrate,u.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=u;for(var m=0;m<u.length;m++)if(u[m].bitrate===r){this._firstLevel=m,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=g&&!v,E={levels:u,audioTracks:c,subtitleTracks:d,firstLevel:this._firstLevel,stats:t.stats,audio:g,video:v,altAudio:!y&&c.some((function(e){return!!e.url}))};this.hls.trigger(i.Events.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},m.onError=function(t,r){if(e.prototype.onError.call(this,t,r),!r.fatal){var n=r.context,i=this._levels[this.currentLevelIndex];if(n&&(n.type===u.PlaylistContextType.AUDIO_TRACK&&i.audioGroupIds&&n.groupId===i.audioGroupIds[i.urlId]||n.type===u.PlaylistContextType.SUBTITLE_TRACK&&i.textGroupIds&&n.groupId===i.textGroupIds[i.urlId]))this.redundantFailover(this.currentLevelIndex);else{var s,o=!1,l=!0;switch(r.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var c=this._levels[r.frag.level];c?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=r.frag.level)):s=r.frag.level}break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:n&&(n.deliveryDirectives&&(l=!1),s=n.level),o=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:s=r.level,o=!0}void 0!==s&&this.recoverLevel(r,s,o,l)}}},m.recoverLevel=function(e,t,r,n){var i=e.details,a=this._levels[t];if(a.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(n){var s=a.url.length;if(s>1&&a.loadError<s)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){var o=0===t?this._levels.length-1:t-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(i+": switch to "+o),e.levelRetry=!0,this.hls.nextAutoLevel=o)}}},m.redundantFailover=function(e){var t=this._levels[e],r=t.url.length;if(r>1){var n=(t.urlId+1)%r;this.warn("Switching to redundant URL-id "+n),this._levels.forEach((function(e){e.urlId=n})),this.level=e}},m.onFragLoaded=function(e,t){var r=t.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var n=this._levels[r.level];void 0!==n&&(n.fragmentError=0,n.loadError=0)}},m.onLevelLoaded=function(e,t){var r,n,i=t.level,a=t.details,s=this._levels[i];if(!s)return this.warn("Invalid level index "+i),void(null!==(n=t.deliveryDirectives)&&void 0!==n&&n.skip&&(a.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(i,t,s.details)):null!==(r=t.deliveryDirectives)&&void 0!==r&&r.skip&&(a.deltaUpdateFailed=!0)},m.onAudioTrackSwitched=function(e,t){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var n=-1,i=this.hls.audioTracks[t.id].groupId,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===i){n=a;break}n!==r.urlId&&(r.urlId=n,this.startLoad())}},m.loadPlaylist=function(e){var t=this.currentLevelIndex,r=this._levels[t];if(this.canLoad&&r&&r.url.length>0){var n=r.urlId,a=r.url[n];if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+t+(e?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+n+" "+a),this.clearTimer(),this.hls.trigger(i.Events.LEVEL_LOADING,{url:a,level:t,id:n,deliveryDirectives:e||null})}},m.removeLevel=function(e,t){var r=function(e,r){return r!==t},n=this._levels.filter((function(n,i){return i!==e||n.url.length>1&&void 0!==t&&(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0)})).map((function(e,t){var r=e.details;return null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=n,this.hls.trigger(i.Events.LEVELS_UPDATED,{levels:n})},p=l,(v=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==e||null===(t=r[e])||void 0===t||!t.details)){if(e<0||e>=r.length){var n=e<0;if(this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:n,reason:"invalid level idx"}),n)return;e=Math.min(e,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,o=r[s],l=r[e];this.log("switching to level "+e+" from "+s),this.currentLevelIndex=e;var u=c({},l,{level:e,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(i.Events.LEVEL_SWITCHING,u);var d=l.details;if(!d||d.live){var f=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(f)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&d(p.prototype,v),g&&d(p,g),l}(l.default)},"./src/controller/level-helper.ts":
95
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return p}));var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function d(){return(d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function c(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),p=function(t){var e,r;function l(e){var r;return(r=t.call(this,e,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=t,(e=l).prototype=Object.create(r.prototype),e.prototype.constructor=e,h(e,r);var p,g,m,v=l.prototype;return v._registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.ERROR,this.onError,this)},v._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.ERROR,this.onError,this)},v.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},v.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},v.onManifestLoaded=function(t,e){var r,l,u=[],d=[],c=[],h={},p=!1,g=!1,m=!1;if(e.levels.forEach((function(t){var e=t.attrs;p=p||!(!t.width||!t.height),g=g||!!t.videoCodec,m=m||!!t.audioCodec,f&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0),(l=h[t.bitrate])?l.url.push(t.url):(l=new i.Level(t),h[t.bitrate]=l,u.push(l)),e&&(e.AUDIO&&Object(o.addGroupId)(l,"audio",e.AUDIO),e.SUBTITLES&&Object(o.addGroupId)(l,"text",e.SUBTITLES))})),(p||g)&&m&&(u=u.filter((function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!(!r||!i)}))),u=u.filter((function(t){var e=t.audioCodec,r=t.videoCodec;return(!e||Object(a.isCodecSupportedInMp4)(e,"audio"))&&(!r||Object(a.isCodecSupportedInMp4)(r,"video"))})),e.audioTracks&&(d=e.audioTracks.filter((function(t){return!t.audioCodec||Object(a.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(d)),e.subtitles&&(c=e.subtitles,Object(o.assignTrackIdsByGroup)(c)),u.length>0){r=u[0].bitrate,u.sort((function(t,e){return t.bitrate-e.bitrate})),this._levels=u;for(var v=0;v<u.length;v++)if(u[v].bitrate===r){this._firstLevel=v,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=m&&!g,E={levels:u,audioTracks:d,subtitleTracks:c,firstLevel:this._firstLevel,stats:e.stats,audio:m,video:g,altAudio:!y&&d.some((function(t){return!!t.url}))};this.hls.trigger(n.Events.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,reason:"no level with compatible codecs found in manifest"})},v.onError=function(e,r){if(t.prototype.onError.call(this,e,r),!r.fatal){var i=r.context,n=this._levels[this.currentLevelIndex];if(i&&(i.type===u.PlaylistContextType.AUDIO_TRACK&&n.audioGroupIds&&i.groupId===n.audioGroupIds[n.urlId]||i.type===u.PlaylistContextType.SUBTITLE_TRACK&&n.textGroupIds&&i.groupId===n.textGroupIds[n.urlId]))this.redundantFailover(this.currentLevelIndex);else{var a,o=!1,l=!0;switch(r.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var d=this._levels[r.frag.level];d?(d.fragmentError++,d.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=r.frag.level)):a=r.frag.level}break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:i&&(i.deliveryDirectives&&(l=!1),a=i.level),o=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:a=r.level,o=!0}void 0!==a&&this.recoverLevel(r,a,o,l)}}},v.recoverLevel=function(t,e,r,i){var n=t.details,s=this._levels[e];if(s.loadError++,r){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(i){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(e);else if(-1===this.manualLevelIndex){var o=0===e?this._levels.length-1:e-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(n+": switch to "+o),t.levelRetry=!0,this.hls.nextAutoLevel=o)}}},v.redundantFailover=function(t){var e=this._levels[t],r=e.url.length;if(r>1){var i=(e.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach((function(t){t.urlId=i})),this.level=t}},v.onFragLoaded=function(t,e){var r=e.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var i=this._levels[r.level];void 0!==i&&(i.fragmentError=0,i.loadError=0)}},v.onLevelLoaded=function(t,e){var r,i,n=e.level,s=e.details,a=this._levels[n];if(!a)return this.warn("Invalid level index "+n),void(null!==(i=e.deliveryDirectives)&&void 0!==i&&i.skip&&(s.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(n,e,a.details)):null!==(r=e.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0)},v.onAudioTrackSwitched=function(t,e){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[e.id].groupId,s=0;s<r.audioGroupIds.length;s++)if(r.audioGroupIds[s]===n){i=s;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},v.loadPlaylist=function(t){var e=this.currentLevelIndex,r=this._levels[e];if(this.canLoad&&r&&r.url.length>0){var i=r.urlId,s=r.url[i];if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+e+(t?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+i+" "+s),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:s,level:e,id:i,deliveryDirectives:t||null})}},v.removeLevel=function(t,e){var r=function(t,r){return r!==e},i=this._levels.filter((function(i,n){return n!==t||i.url.length>1&&void 0!==e&&(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0)})).map((function(t,e){var r=t.details;return null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e})),t}));this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},p=l,(g=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==t||null===(e=r[t])||void 0===e||!e.details)){if(t<0||t>=r.length){var i=t<0;if(this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:i,reason:"invalid level idx"}),i)return;t=Math.min(t,r.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=r[a],l=r[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var u=d({},l,{level:t,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,u);var c=l.details;if(!c||c.live){var h=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&c(p.prototype,g),m&&c(p,m),l}(l.default)},"./src/controller/level-helper.ts":
96
96
  /*!****************************************!*\
97
97
  !*** ./src/controller/level-helper.ts ***!
98
98
  \****************************************/
99
- /*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(e,t,r){r.r(t),r.d(t,"addGroupId",(function(){return a})),r.d(t,"assignTrackIdsByGroup",(function(){return s})),r.d(t,"updatePTS",(function(){return o})),r.d(t,"updateFragPTSDTS",(function(){return u})),r.d(t,"mergeDetails",(function(){return c})),r.d(t,"mapPartIntersection",(function(){return d})),r.d(t,"mapFragmentIntersection",(function(){return f})),r.d(t,"adjustSliding",(function(){return h})),r.d(t,"computeReloadInterval",(function(){return p})),r.d(t,"getFragmentWithSN",(function(){return v})),r.d(t,"getPartWith",(function(){return g}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function s(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function o(e,t,r){l(e[t],e[r])}function l(e,t){var r=t.startPTS;if(Object(n.isFiniteNumber)(r)){var i,a=0;t.sn>e.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&(i.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function u(e,t,r,a,s,o){a-r<=0&&(i.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,o=s+t.duration);var u=r,c=a,d=t.startPTS,f=t.endPTS;if(Object(n.isFiniteNumber)(d)){var h=Math.abs(d-r);Object(n.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,u=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),c=Math.min(a,f),a=Math.max(a,f),o=Math.max(o,t.endDTS)}t.duration=a-r;var p=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=u,t.startDTS=s,t.endPTS=a,t.minEndPTS=c,t.endDTS=o;var v,g=t.sn;if(!e||g<e.startSN||g>e.endSN)return 0;var m=g-e.startSN,y=e.fragments;for(y[m]=t,v=m;v>0;v--)l(y[v],y[v-1]);for(v=m;v<y.length-1;v++)l(y[v],y[v+1]);return e.fragmentHint&&l(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,p}function c(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment),e.fragmentHint&&delete e.fragmentHint.endPTS;var r,a=0;if(f(e,t,(function(e,i){e.relurl&&(a=e.cc-i.cc),Object(n.isFiniteNumber)(e.startPTS)&&Object(n.isFiniteNumber)(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.appendedPTS=e.appendedPTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(r=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,i.urlId=e.urlId})),t.skippedSegments&&(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed)){i.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var s=t.skippedSegments;s--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}var o=t.fragments;if(a){i.logger.warn("discontinuity sliding from playlist, take drift into account");for(var l=0;l<o.length;l++)o[l].cc+=a}t.skippedSegments&&(t.initSegment||(t.initSegment=e.initSegment),t.startCC=t.fragments[0].cc),d(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),r?u(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):h(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var c=t.advancedDateTime;if(t.advanced&&c){var p=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=p),t.driftEndTime=c,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function d(e,t,r){if(e&&t)for(var n=0,i=0,a=e.length;i<=a;i++){var s=e[i],o=t[i+n];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):n--}}function f(e,t,r){for(var n=t.skippedSegments,i=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=i;u<=a;u++){var c=l[s+u],d=o[u];n&&!d&&u<n&&(d=t.fragments[u]=c),c&&d&&r(c,d)}}function h(e,t){var r=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,i=t.fragments;if(!(r<0||r>=n.length)){var a=n[r].start;if(a){for(var s=t.skippedSegments;s<i.length;s++)i[s].start+=a;t.fragmentHint&&(t.fragmentHint.start+=a)}}}function p(e,t){var r,n=1e3*e.levelTargetDuration,i=n/2,a=e.age,s=a>0&&a<3*n,o=t.loading.end-t.loading.start,l=e.availabilityDelay;if(!1===e.updated)if(s){var u=333*e.misses;r=Math.max(Math.min(i,2*o),u),e.availabilityDelay=(e.availabilityDelay||0)+r}else r=i;else s?(l=Math.min(l||n/2,a),e.availabilityDelay=l,r=l+n-a):r=n-o;return Math.round(r)}function v(e,t){if(!e||!e.details)return null;var r=e.details,n=r.fragments[t-r.startSN];return n||((n=r.fragmentHint)&&n.sn===t?n:null)}function g(e,t,r){if(!e||!e.details)return null;var n=e.details.partList;if(n)for(var i=n.length;i--;){var a=n[i];if(a.index===r&&a.fragment.sn===t)return a}return null}},"./src/controller/stream-controller.ts":
99
+ /*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,e,r){r.r(e),r.d(e,"addGroupId",(function(){return s})),r.d(e,"assignTrackIdsByGroup",(function(){return a})),r.d(e,"updatePTS",(function(){return o})),r.d(e,"updateFragPTSDTS",(function(){return u})),r.d(e,"mergeDetails",(function(){return d})),r.d(e,"mapPartIntersection",(function(){return c})),r.d(e,"mapFragmentIntersection",(function(){return h})),r.d(e,"adjustSliding",(function(){return f})),r.d(e,"computeReloadInterval",(function(){return p})),r.d(e,"getFragmentWithSN",(function(){return g})),r.d(e,"getPartWith",(function(){return m}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,e,r){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(r);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(r)}}function a(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}function o(t,e,r){l(t[e],t[r])}function l(t,e){var r=e.startPTS;if(Object(i.isFiniteNumber)(r)){var n,s=0;e.sn>t.sn?(s=r-t.start,n=t):(s=t.start-r,n=e),n.duration!==s&&(n.duration=s)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function u(t,e,r,s,a,o){s-r<=0&&(n.logger.warn("Fragment should have a positive duration",e),s=r+e.duration,o=a+e.duration);var u=r,d=s,c=e.startPTS,h=e.endPTS;if(Object(i.isFiniteNumber)(c)){var f=Math.abs(c-r);Object(i.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(f,e.deltaPTS):e.deltaPTS=f,u=Math.max(r,c),r=Math.min(r,c),a=Math.min(a,e.startDTS),d=Math.min(s,h),s=Math.max(s,h),o=Math.max(o,e.endDTS)}e.duration=s-r;var p=r-e.start;e.appendedPTS=s,e.start=e.startPTS=r,e.maxStartPTS=u,e.startDTS=a,e.endPTS=s,e.minEndPTS=d,e.endDTS=o;var g,m=e.sn;if(!t||m<t.startSN||m>t.endSN)return 0;var v=m-t.startSN,y=t.fragments;for(y[v]=e,g=v;g>0;g--)l(y[g],y[g-1]);for(g=v;g<y.length-1;g++)l(y[g],y[g+1]);return t.fragmentHint&&l(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,p}function d(t,e){e.initSegment&&t.initSegment&&(e.initSegment=t.initSegment),t.fragmentHint&&delete t.fragmentHint.endPTS;var r,s=0;if(h(t,e,(function(t,n){t.relurl&&(s=t.cc-n.cc),Object(i.isFiniteNumber)(t.startPTS)&&Object(i.isFiniteNumber)(t.endPTS)&&(n.start=n.startPTS=t.startPTS,n.startDTS=t.startDTS,n.appendedPTS=t.appendedPTS,n.maxStartPTS=t.maxStartPTS,n.endPTS=t.endPTS,n.endDTS=t.endDTS,n.minEndPTS=t.minEndPTS,n.duration=t.endPTS-t.startPTS,n.duration&&(r=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,n.urlId=t.urlId})),e.skippedSegments&&(e.deltaUpdateFailed=e.fragments.some((function(t){return!t})),e.deltaUpdateFailed)){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var a=e.skippedSegments;a--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}var o=e.fragments;if(s){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var l=0;l<o.length;l++)o[l].cc+=s}e.skippedSegments&&(e.initSegment||(e.initSegment=t.initSegment),e.startCC=e.fragments[0].cc),c(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),r?u(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):f(t,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var d=e.advancedDateTime;if(e.advanced&&d){var p=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=p),e.driftEndTime=d,e.driftEnd=p}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function c(t,e,r){if(t&&e)for(var i=0,n=0,s=t.length;n<=s;n++){var a=t[n],o=e[n+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?r(a,o):i--}}function h(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,s=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=n;u<=s;u++){var d=l[a+u],c=o[u];i&&!c&&u<i&&(c=e.fragments[u]=d),d&&c&&r(d,c)}}function f(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments,n=e.fragments;if(!(r<0||r>=i.length)){var s=i[r].start;if(s){for(var a=e.skippedSegments;a<n.length;a++)n[a].start+=s;e.fragmentHint&&(e.fragmentHint.start+=s)}}}function p(t,e){var r,i=1e3*t.levelTargetDuration,n=i/2,s=t.age,a=s>0&&s<3*i,o=e.loading.end-e.loading.start,l=t.availabilityDelay;if(!1===t.updated)if(a){var u=333*t.misses;r=Math.max(Math.min(n,2*o),u),t.availabilityDelay=(t.availabilityDelay||0)+r}else r=n;else a?(l=Math.min(l||i/2,s),t.availabilityDelay=l,r=l+i-s):r=i-o;return Math.round(r)}function g(t,e){if(!t||!t.details)return null;var r=t.details,i=r.fragments[e-r.startSN];return i||((i=r.fragmentHint)&&i.sn===e?i:null)}function m(t,e,r){if(!t||!t.details)return null;var i=t.details.partList;if(i)for(var n=i.length;n--;){var s=i[n];if(s.index===r&&s.fragment.sn===e)return s}return null}},"./src/controller/stream-controller.ts":
100
100
  /*!*********************************************!*\
101
101
  !*** ./src/controller/stream-controller.ts ***!
102
102
  \*********************************************/
103
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return y}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../is-supported */"./src/is-supported.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),h=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=r(/*! ../errors */"./src/errors.ts"),v=r(/*! ../utils/logger */"./src/utils/logger.ts");function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var y=function(e){var t,r;function y(t,r){var n;return(n=e.call(this,t,r,"[stream-controller]")||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.stalled=!1,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}r=e,(t=y).prototype=Object.create(r.prototype),t.prototype.constructor=t,m(t,r);var E,_,T,b=y.prototype;return b._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(s.Events.ERROR,this.onError,this),e.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(s.Events.ERROR,this.onError,this),e.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},b.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var n=r.startLevel;-1===n&&(r.config.testBandwidth?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=i.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=i.State.STOPPED},b.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},b.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_LEVEL:var e,t=this.levels,r=this.level,n=null==t||null===(e=t[r])||void 0===e?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=i.State.IDLE;break}break;case i.State.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;(!o||s>=o||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=i.State.IDLE)}this.onTickEnd()},b.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},b.doTickIdle=function(){var e,t,r=this.hls,a=this.levelLastLoaded,u=this.levels,c=this.media,d=r.config,f=r.nextLoadLevel;if(null!==a&&(c||!this.startFragRequested&&d.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&u&&u[f]){var p=u[f];this.level=r.nextLoadLevel=f;var v=p.details;if(!v||this.state===i.State.WAITING_LEVEL||v.live&&this.levelLastLoaded!==f)this.state=i.State.WAITING_LEVEL;else{var g=this.getLoadPosition();if(Object(n.isFiniteNumber)(g)){var m=v.initSegment,y=0;if(!m||m.data||this.bitrateTest){var E,_=p.maxBitrate;E=_?Math.max(8*d.maxBufferSize/_,d.maxBufferLength):d.maxBufferLength,E=Math.min(E,d.maxMaxBufferLength);var T=g<d.maxBufferHole?Math.max(h.MAX_START_GAP_JUMP,d.maxBufferHole):d.maxBufferHole,b=o.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:c,g,T);if(b.len>=E)return;if(this._streamEnded(b,v)){var A={};return this.altAudio&&(A.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,A),void(this.state=i.State.ENDED)}if(y=b.end,(m=this.getNextFragment(y,v))&&this.fragmentTracker.getState(m)===l.FragmentState.OK&&this.nextLoadPosition>y&&(m=this.getNextFragment(this.nextLoadPosition,v)),!m)return}"identity"!==(null===(e=m.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=m.decryptdata)&&void 0!==t&&t.key?this.loadFragment(m,v,y):this.loadKey(m,v)}}}},b.loadFragment=function(t,r,n){var i,a=this.fragmentTracker.getState(t);if(this.fragCurrent=t,a===l.FragmentState.BACKTRACKED){var s=this.fragmentTracker.getBacktrackData(t);if(s)return this._handleFragmentLoadProgress(s),void this._handleFragmentLoadComplete(s);a=l.FragmentState.NOT_LOADED}a===l.FragmentState.NOT_LOADED||a===l.FragmentState.PARTIAL?"initSegment"===t.sn?this._loadInitSegment(t):this.bitrateTest?(t.bitrateTest=!0,this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,n)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null===(i=this.media)||void 0===i?void 0:i.buffered.length)&&this.fragmentTracker.removeAllFragments()},b.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},b.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},b.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},b.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},b.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,n=this.getAppendedFrag(t.currentTime);if(n&&n.start>1&&this.flushMainBuffer(0,n.start-1),!t.paused&&e){var i=e[this.hls.nextLoadLevel],a=this.fragLastKbps;r=a&&this.fragCurrent?this.fragCurrent.duration*i.maxBitrate/(1e3*a)+1:0}else r=0;var s=this.getBufferedFrag(t.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,c=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},b.abortCurrentFrag=function(){var e=this.fragCurrent;this.fragCurrent=null,null!=e&&e.loader&&e.loader.abort(),this.state===i.State.KEY_LOADING&&(this.state=i.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},b.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},b.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var n=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new h.default(this.config,n,this.fragmentTracker,this.hls)},b.onMediaDetaching=function(){var t=this.media;t&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},b.onMediaPlaying=function(){this.tick()},b.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;Object(n.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},b.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},b.onManifestParsed=function(e,t){var r,n=!1,i=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(n=!0),-1!==r.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=n&&i&&!Object(a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},b.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===i.State.IDLE){var n=r[t.level];(!n.details||n.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(n.details))&&(this.state=i.State.WAITING_LEVEL)}},b.onLevelLoaded=function(e,t){var r,n=this.levels,a=t.level,o=t.details,l=o.totalduration;if(n){this.log("Level "+a+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==i.State.FRAG_LOADING&&this.state!==i.State.FRAG_LOADING_WAITING_RETRY||u.level!==t.level&&u.loader&&(this.state=i.State.IDLE,u.loader.abort());var c=n[a],d=0;if(o.live||null!==(r=c.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,c.details)}if(c.details=o,this.levelLastLoaded=a,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:o,level:a}),this.state===i.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=i.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}else this.warn("Levels were reset while loading level "+a)},b._handleFragmentLoadProgress=function(e){var t,r=e.frag,n=e.part,i=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(o){var l=s.videoCodec,c=o.PTSKnown||!o.live,h=null===(t=o.initSegment)||void 0===t?void 0:t.data,p=this._getAudioCodec(s),v=this.transmuxer=this.transmuxer||new d.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=n?n.index:-1,m=-1!==g,y=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,i.byteLength,g,m),E=this.initPTS[r.cc];v.push(i,h,p,l,r,n,o.totalduration,c,y,E)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},b.onAudioTrackSwitching=function(e,t){var r=this.altAudio,n=!!t.url,i=t.id;if(!n){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;null!=a&&a.loader&&(this.log("Switching to main audio track, cancel main fragment load"),a.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:i})}},b.onAudioTrackSwitched=function(e,t){var r=t.id,n=!!this.hls.audioTracks[r].url;if(n){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=n,this.tick()},b.onBufferCreated=function(e,t){var r,n,i=t.tracks,a=!1;for(var s in i){var o=i[s];if("main"===o.id){if(n=s,r=o,"video"===s){var l=i[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},b.onFragBuffered=function(e,t){var r=t.frag,n=t.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===i.State.PARSED&&(this.state=i.State.IDLE));var a=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}},b.onError=function(e,t){switch(t.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t);break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==i.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=i.State.ERROR):t.levelRetry||this.state!==i.State.WAITING_LEVEL||(this.state=i.State.IDLE));break;case p.ErrorDetails.BUFFER_FULL_ERROR:"main"!==t.parent||this.state!==i.State.PARSING&&this.state!==i.State.PARSED||(this.media&&o.BufferHelper.isBuffered(this.media,this.media.currentTime)&&o.BufferHelper.isBuffered(this.media,this.media.currentTime+.5)?(this.reduceMaxBufferLength(),this.state=i.State.IDLE):(this.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.immediateLevelSwitch()))}},b.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){var r=o.BufferHelper.getBuffered(e);!this.loadedmetadata&&r.length?(this.loadedmetadata=!0,this.seekToStartPos()):t.poll(this.lastCurrentTime),this.lastCurrentTime=e.currentTime}},b.onFragLoadEmergencyAborted=function(){this.state=i.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},b.onBufferFlushed=function(e,t){var r=t.type;if(r!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var n=(r===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,u.PlaylistLevelType.MAIN)}},b.onLevelsUpdated=function(e,t){this.levels=t.levels},b.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},b.seekToStartPos=function(){var e=this.media,t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void v.logger.log("could not seek to "+r+", already seeking at "+t);var n=o.BufferHelper.getBuffered(e),i=(n.length?n.start(0):0)-r;i>0&&i<this.config.maxBufferHole&&(v.logger.log("adjusting start position by "+i+" to match buffer start"),r+=i,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}},b._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},b._loadBitrateTestFrag=function(e){var t=this;this._doFragLoad(e).then((function(r){var n=t.hls;if(r&&!n.nextLoadLevel&&!t.fragContextChanged(e)){t.fragLoadError=0,t.state=i.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(s.Events.FRAG_LOADED,r)}}))},b._handleTransmuxComplete=function(e){var t,r="main",a=this.hls,o=e.remuxResult,l=e.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(l.level);var d=u.frag,f=u.part,h=u.level,p=o.video,v=o.text,g=o.id3,m=o.initSegment,y=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(d)){if(this.state=i.State.PARSING,m){m.tracks&&(this._bufferInitSegment(h,m.tracks,d,l),a.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:d,id:r,tracks:m.tracks}));var E=m.initPTS,_=m.timescale;Object(n.isFiniteNumber)(E)&&(this.initPTS[d.cc]=E,a.trigger(s.Events.INIT_PTS_FOUND,{frag:d,id:r,initPTS:E,timescale:_}))}if(p&&!1!==o.independent){if(h.details){var T=p.startPTS,b=p.endPTS,A=p.startDTS,S=p.endDTS;if(f)f.elementaryStreams[p.type]={startPTS:T,endPTS:b,startDTS:A,endDTS:S};else if(p.dropped&&p.independent){if(this.getLoadPosition()+this.config.maxBufferHole<T)return void this.backtrack(d);d.setElementaryStreamInfo(p.type,d.start,b,d.start,S,!0)}d.setElementaryStreamInfo(p.type,T,b,A,S),this.bufferFragmentData(p,d,f,l)}}else if(!1===o.independent)return void this.backtrack(d);if(y){var w=y.startPTS,L=y.endPTS,k=y.startDTS,R=y.endDTS;f&&(f.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:w,endPTS:L,startDTS:k,endDTS:R}),d.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,w,L,k,R),this.bufferFragmentData(y,d,f,l)}if(null!=g&&null!==(t=g.samples)&&void 0!==t&&t.length){var D={frag:d,id:r,samples:g.samples};a.trigger(s.Events.FRAG_PARSING_METADATA,D)}if(v){var O={frag:d,id:r,samples:v.samples};a.trigger(s.Events.FRAG_PARSING_USERDATA,O)}}},b._bufferInitSegment=function(e,t,r,n){var a=this;if(this.state===i.State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var c=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===d.indexOf("firefox")&&(c="mp4a.40.5")),-1!==d.indexOf("android")&&"audio/mpeg"!==o.container&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),e.audioCodec&&e.audioCodec!==c&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(e.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var i=t[e].initSegment;null!=i&&i.byteLength&&a.hls.trigger(s.Events.BUFFER_APPENDING,{type:e,data:i,frag:r,part:null,chunkMeta:n,parent:r.type})})),this.tick()}},b.backtrack=function(e){this.resetTransmuxer(),this.flushBufferGap(e);var t=this.fragmentTracker.backtrack(e);this.fragPrevious=null,this.nextLoadPosition=e.start,t?this.resetFragmentLoading(e):this.state=i.State.BACKTRACKING},b.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(o.BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):o.BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){var n=this.fragPlaying,i=t.level;n&&t.sn===n.sn&&n.level===i&&t.urlId===n.urlId||(this.hls.trigger(s.Events.FRAG_CHANGED,{frag:t}),n&&n.level===i||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:i}),this.fragPlaying=t)}}},E=y,(_=[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getAppendedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;if(e){var t=this.getAppendedFrag(e.currentTime);return this.followingBufferedFrag(t)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&g(E.prototype,_),T&&g(E,T),y}(i.default)},"./src/controller/subtitle-stream-controller.ts":
103
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return y}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=r(/*! ../is-supported */"./src/is-supported.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=r(/*! ../errors */"./src/errors.ts"),g=r(/*! ../utils/logger */"./src/utils/logger.ts");function m(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var y=function(t){var e,r;function y(e,r){var i;return(i=t.call(this,e,r,"[stream-controller]")||this).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i.altAudio=!1,i.audioOnly=!1,i.fragPlaying=null,i.onvplaying=null,i.onvseeked=null,i.fragLastKbps=0,i.stalled=!1,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=t,(e=y).prototype=Object.create(r.prototype),e.prototype.constructor=e,v(e,r);var E,T,_,b=y.prototype;return b._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},b.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},b.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},b.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},b.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var t,e=this.levels,r=this.level,i=null==e||null===(t=e[r])||void 0===t?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var s,a=self.performance.now(),o=this.retryDate;(!o||a>=o||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=n.State.IDLE)}this.onTickEnd()},b.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},b.doTickIdle=function(){var t,e,r=this.hls,s=this.levelLastLoaded,u=this.levels,d=this.media,c=r.config,h=r.nextLoadLevel;if(null!==s&&(d||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&u&&u[h]){var p=u[h];this.level=r.nextLoadLevel=h;var g=p.details;if(!g||this.state===n.State.WAITING_LEVEL||g.live&&this.levelLastLoaded!==h)this.state=n.State.WAITING_LEVEL;else{var m=this.getLoadPosition();if(Object(i.isFiniteNumber)(m)){var v=g.initSegment,y=0;if(!v||v.data||this.bitrateTest){var E,T=p.maxBitrate;E=T?Math.max(8*c.maxBufferSize/T,c.maxBufferLength):c.maxBufferLength,E=Math.min(E,c.maxMaxBufferLength);var _=m<c.maxBufferHole?Math.max(f.MAX_START_GAP_JUMP,c.maxBufferHole):c.maxBufferHole,b=o.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:d,m,_);if(b.len>=E)return;if(this._streamEnded(b,g)){var S={};return this.altAudio&&(S.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,S),void(this.state=n.State.ENDED)}if(y=b.end,(v=this.getNextFragment(y,g))&&this.fragmentTracker.getState(v)===l.FragmentState.OK&&this.nextLoadPosition>y&&(v=this.getNextFragment(this.nextLoadPosition,g)),!v)return}"identity"!==(null===(t=v.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=v.decryptdata)&&void 0!==e&&e.key?this.loadFragment(v,g,y):this.loadKey(v,g)}}}},b.loadFragment=function(e,r,i){var n,s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,s===l.FragmentState.BACKTRACKED){var a=this.fragmentTracker.getBacktrackData(e);if(a)return this._handleFragmentLoadProgress(a),void this._handleFragmentLoadComplete(a);s=l.FragmentState.NOT_LOADED}s===l.FragmentState.NOT_LOADED||s===l.FragmentState.PARTIAL?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(e.bitrateTest=!0,this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):s===l.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null===(n=this.media)||void 0===n?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},b.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},b.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},b.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},b.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},b.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!e.paused&&t){var n=t[this.hls.nextLoadLevel],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*s)+1:0}else r=0;var a=this.getBufferedFrag(e.currentTime+r);if(a){var o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,d=Math.max(a.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}},b.abortCurrentFrag=function(){var t=this.fragCurrent;this.fragCurrent=null,null!=t&&t.loader&&t.loader.abort(),this.state===n.State.KEY_LOADING&&(this.state=n.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},b.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},b.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,i,this.fragmentTracker,this.hls)},b.onMediaDetaching=function(){var e=this.media;e&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},b.onMediaPlaying=function(){this.tick()},b.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;Object(i.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},b.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},b.onManifestParsed=function(t,e){var r,i=!1,n=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n&&!Object(s.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},b.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},b.onLevelLoaded=function(t,e){var r,i=this.levels,s=e.level,o=e.details,l=o.totalduration;if(i){this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==n.State.FRAG_LOADING&&this.state!==n.State.FRAG_LOADING_WAITING_RETRY||u.level!==e.level&&u.loader&&(this.state=n.State.IDLE,u.loader.abort());var d=i[s],c=0;if(o.live||null!==(r=d.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,d.details)}if(d.details=o,this.levelLastLoaded=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=n.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}else this.warn("Levels were reset while loading level "+s)},b._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,s=this.levels;if(s){var a=s[r.level],o=a.details;if(o){var l=a.videoCodec,d=o.PTSKnown||!o.live,f=null===(e=o.initSegment)||void 0===e?void 0:e.data,p=this._getAudioCodec(a),g=this.transmuxer=this.transmuxer||new c.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=i?i.index:-1,v=-1!==m,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,v),E=this.initPTS[r.cc];g.push(n,f,p,l,r,i,o.totalduration,d,y,E)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},b.onAudioTrackSwitching=function(t,e){var r=this.altAudio,i=!!e.url,n=e.id;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var s=this.fragCurrent;null!=s&&s.loader&&(this.log("Switching to main audio track, cancel main fragment load"),s.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})}},b.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},b.onBufferCreated=function(t,e){var r,i,n=e.tracks,s=!1;for(var a in n){var o=n[a];if("main"===o.id){if(i=a,r=o,"video"===a){var l=n[a];l&&(this.videoBuffer=l.buffer)}}else s=!0}s&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},b.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var s=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},b.onError=function(t,e){switch(e.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,e);break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(e.fatal?(this.warn(""+e.details),this.state=n.State.ERROR):e.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case p.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==n.State.PARSING&&this.state!==n.State.PARSED||(this.media&&o.BufferHelper.isBuffered(this.media,this.media.currentTime)&&o.BufferHelper.isBuffered(this.media,this.media.currentTime+.5)?(this.reduceMaxBufferLength(),this.state=n.State.IDLE):(this.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.immediateLevelSwitch()))}},b.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){var r=o.BufferHelper.getBuffered(t);!this.loadedmetadata&&r.length?(this.loadedmetadata=!0,this.seekToStartPos()):e.poll(this.lastCurrentTime),this.lastCurrentTime=t.currentTime}},b.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},b.onBufferFlushed=function(t,e){var r=e.type;if(r!==d.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===d.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,u.PlaylistLevelType.MAIN)}},b.onLevelsUpdated=function(t,e){this.levels=e.levels},b.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},b.seekToStartPos=function(){var t=this.media,e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void g.logger.log("could not seek to "+r+", already seeking at "+e);var i=o.BufferHelper.getBuffered(t),n=(i.length?i.start(0):0)-r;n>0&&n<this.config.maxBufferHole&&(g.logger.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+e),t.currentTime=r}},b._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},b._loadBitrateTestFrag=function(t){var e=this;this._doFragLoad(t).then((function(r){var i=e.hls;if(r&&!i.nextLoadLevel&&!e.fragContextChanged(t)){e.fragLoadError=0,e.state=n.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(a.Events.FRAG_LOADED,r)}}))},b._handleTransmuxComplete=function(t){var e,r="main",s=this.hls,o=t.remuxResult,l=t.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(l.level);var c=u.frag,h=u.part,f=u.level,p=o.video,g=o.text,m=o.id3,v=o.initSegment,y=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,v){v.tracks&&(this._bufferInitSegment(f,v.tracks,c,l),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:v.tracks}));var E=v.initPTS,T=v.timescale;Object(i.isFiniteNumber)(E)&&(this.initPTS[c.cc]=E,s.trigger(a.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:E,timescale:T}))}if(p&&!1!==o.independent){if(f.details){var _=p.startPTS,b=p.endPTS,S=p.startDTS,A=p.endDTS;if(h)h.elementaryStreams[p.type]={startPTS:_,endPTS:b,startDTS:S,endDTS:A};else if(p.dropped&&p.independent){if(this.getLoadPosition()+this.config.maxBufferHole<_)return void this.backtrack(c);c.setElementaryStreamInfo(p.type,c.start,b,c.start,A,!0)}c.setElementaryStreamInfo(p.type,_,b,S,A),this.bufferFragmentData(p,c,h,l)}}else if(!1===o.independent)return void this.backtrack(c);if(y){var L=y.startPTS,w=y.endPTS,k=y.startDTS,R=y.endDTS;h&&(h.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:L,endPTS:w,startDTS:k,endDTS:R}),c.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,L,w,k,R),this.bufferFragmentData(y,c,h,l)}if(null!=m&&null!==(e=m.samples)&&void 0!==e&&e.length){var D={frag:c,id:r,samples:m.samples};s.trigger(a.Events.FRAG_PARSING_METADATA,D)}if(g){var O={frag:c,id:r,samples:g.samples};s.trigger(a.Events.FRAG_PARSING_USERDATA,O)}}},b._bufferInitSegment=function(t,e,r,i){var s=this;if(this.state===n.State.PARSING){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var o=e.audio,l=e.video,u=e.audiovideo;if(o){var d=t.audioCodec,c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(d&&(d=-1!==d.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===c.indexOf("firefox")&&(d="mp4a.40.5")),-1!==c.indexOf("android")&&"audio/mpeg"!==o.container&&(d="mp4a.40.2",this.log("Android: force audio codec to "+d)),t.audioCodec&&t.audioCodec!==d&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+d+'"'),o.levelCodec=d,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(d||"")+"/"+(t.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=t.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},b.backtrack=function(t){this.resetTransmuxer(),this.flushBufferGap(t);var e=this.fragmentTracker.backtrack(t);this.fragPrevious=null,this.nextLoadPosition=t.start,e?this.resetFragmentLoading(t):this.state=n.State.BACKTRACKING},b.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(o.BufferHelper.isBuffered(t,r)?e=this.getAppendedFrag(r):o.BufferHelper.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n&&e.urlId===i.urlId||(this.hls.trigger(a.Events.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:n}),this.fragPlaying=e)}}},E=y,(T=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;if(t){var e=this.getAppendedFrag(t.currentTime);return this.followingBufferedFrag(e)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&m(E.prototype,T),_&&m(E,_),y}(n.default)},"./src/controller/subtitle-stream-controller.ts":
104
104
  /*!******************************************************!*\
105
105
  !*** ./src/controller/subtitle-stream-controller.ts ***!
106
106
  \******************************************************/
107
- /*! exports provided: SubtitleStreamController */function(e,t,r){r.r(t),r.d(t,"SubtitleStreamController",(function(){return h}));var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../types/level */"./src/types/level.ts");function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=function(e){var t,r;function h(t,r){var n;return(n=e.call(this,t,r,"[subtitle-stream-controller]")||this).levels=[],n.currentTrackId=-1,n.tracksBuffered=void 0,n.config=t.config,n.fragCurrent=null,n.fragPrevious=null,n.media=null,n.mediaBuffer=null,n.state=l.State.STOPPED,n.tracksBuffered=[],n._registerListeners(),n}r=e,(t=h).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r);var p,v,g,m=h.prototype;return m._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.ERROR,this.onError,this),e.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this)},m._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.ERROR,this.onError,this),e.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this)},m.startLoad=function(){this.stopLoad(),this.state=l.State.IDLE;var e=this.levels[this.currentTrackId];null!=e&&e.details&&(this.setInterval(500),this.tick())},m.onHandlerDestroyed=function(){this.state=l.State.STOPPED,this._unregisterListeners(),e.prototype.onHandlerDestroyed.call(this)},m.onSubtitleFragProcessed=function(e,t){var r=t.frag,n=t.success;if(this.fragPrevious=r,this.state=l.State.IDLE,n){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var a,s=r.start,o=0;o<i.length;o++)if(s>=i[o].start&&s<=i[o].end){a=i[o];break}var u=r.start+r.duration;a?a.end=u:(a={start:s,end:u},i.push(a))}}},m.onMediaAttached=function(e,t){var r=t.media;this.media=r,this.state=l.State.IDLE},m.onMediaDetaching=function(){var e=this;this.media&&(this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.currentTrackId=-1,this.levels.forEach((function(t){e.tracksBuffered[t.id]=[]})),this.media=null,this.mediaBuffer=null,this.state=l.State.STOPPED)},m.onError=function(e,t){var r,n=t.frag;n&&n.type===u.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=l.State.IDLE)},m.onSubtitleTracksUpdated=function(e,t){var r=this,n=t.subtitleTracks;this.tracksBuffered=[],this.levels=n.map((function(e){return new c.Level(e)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(e){r.tracksBuffered[e.id]=[]})),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(e,t){if(this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?(this.mediaBuffer=this.mediaBufferTimeRanges,this.setInterval(500)):this.mediaBuffer=null}else this.clearInterval()},m.onSubtitleTrackLoaded=function(e,t){var r,n=t.id,i=t.details,a=this.currentTrackId,s=this.levels;if(s.length&&i){var o=s[a];if(!(n>=s.length||n!==a)&&o){if(this.mediaBuffer=this.mediaBufferTimeRanges,i.live||null!==(r=o.details)&&void 0!==r&&r.live){if(i.deltaUpdateFailed)return;this.alignPlaylists(i,o.details)}o.details=i,this.levelLastLoaded=n,this.setInterval(500)}}},m._handleFragmentLoadComplete=function(e){var t=e.frag,r=e.payload,i=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).then((function(e){var r=performance.now();a.trigger(n.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:s,tdecrypt:r}})}))}},m.doTick=function(){if(this.media){if(this.state===l.State.IDLE){var e,t=this.config,r=this.currentTrackId,u=this.fragmentTracker,c=this.media,d=this.levels;if(!d.length||!d[r]||!d[r].details)return;var f=t.maxBufferHole,h=t.maxFragLookUpTolerance,p=Math.min(t.maxBufferLength,t.maxMaxBufferLength),v=a.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,c.currentTime,f),g=v.end;if(v.len>p)return;var m=d[r].details;console.assert(m,"Subtitle track details are defined on idle subtitle stream controller tick");var y,E=m.fragments,_=E.length,T=E[_-1].start+E[_-1].duration,b=this.fragPrevious;g<T?(b&&m.hasProgramDateTime&&(y=Object(s.findFragmentByPDT)(E,b.endProgramDateTime,h)),y||(y=Object(s.findFragmentByPTS)(b,E,g,h))):y=E[_-1],null!==(e=y)&&void 0!==e&&e.encrypted?(i.logger.log("Loading key for "+y.sn),this.state=l.State.KEY_LOADING,this.hls.trigger(n.Events.KEY_LOADING,{frag:y})):y&&u.getState(y)===o.FragmentState.NOT_LOADED&&this.loadFragment(y,m,g)}}else this.state=l.State.IDLE},m.loadFragment=function(t,r,n){this.fragCurrent=t,e.prototype.loadFragment.call(this,t,r,n)},m.stopLoad=function(){this.fragPrevious=null,e.prototype.stopLoad.call(this)},p=h,(v=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&d(p.prototype,v),g&&d(p,g),h}(l.default)},"./src/controller/subtitle-track-controller.ts":
107
+ /*! exports provided: SubtitleStreamController */function(t,e,r){r.r(e),r.d(e,"SubtitleStreamController",(function(){return f}));var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../types/level */"./src/types/level.ts");function c(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var f=function(t){var e,r;function f(e,r){var i;return(i=t.call(this,e,r,"[subtitle-stream-controller]")||this).levels=[],i.currentTrackId=-1,i.tracksBuffered=void 0,i.config=e.config,i.fragCurrent=null,i.fragPrevious=null,i.media=null,i.mediaBuffer=null,i.state=l.State.STOPPED,i.tracksBuffered=[],i._registerListeners(),i}r=t,(e=f).prototype=Object.create(r.prototype),e.prototype.constructor=e,h(e,r);var p,g,m,v=f.prototype;return v._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.ERROR,this.onError,this),t.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this)},v._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.ERROR,this.onError,this),t.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this)},v.startLoad=function(){this.stopLoad(),this.state=l.State.IDLE;var t=this.levels[this.currentTrackId];null!=t&&t.details&&(this.setInterval(500),this.tick())},v.onHandlerDestroyed=function(){this.state=l.State.STOPPED,this._unregisterListeners(),t.prototype.onHandlerDestroyed.call(this)},v.onSubtitleFragProcessed=function(t,e){var r=e.frag,i=e.success;if(this.fragPrevious=r,this.state=l.State.IDLE,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var s,a=r.start,o=0;o<n.length;o++)if(a>=n[o].start&&a<=n[o].end){s=n[o];break}var u=r.start+r.duration;s?s.end=u:(s={start:a,end:u},n.push(s))}}},v.onMediaAttached=function(t,e){var r=e.media;this.media=r,this.state=l.State.IDLE},v.onMediaDetaching=function(){var t=this;this.media&&(this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.currentTrackId=-1,this.levels.forEach((function(e){t.tracksBuffered[e.id]=[]})),this.media=null,this.mediaBuffer=null,this.state=l.State.STOPPED)},v.onError=function(t,e){var r,i=e.frag;i&&i.type===u.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=l.State.IDLE)},v.onSubtitleTracksUpdated=function(t,e){var r=this,i=e.subtitleTracks;this.tracksBuffered=[],this.levels=i.map((function(t){return new d.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){r.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},v.onSubtitleTrackSwitch=function(t,e){if(this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?(this.mediaBuffer=this.mediaBufferTimeRanges,this.setInterval(500)):this.mediaBuffer=null}else this.clearInterval()},v.onSubtitleTrackLoaded=function(t,e){var r,i=e.id,n=e.details,s=this.currentTrackId,a=this.levels;if(a.length&&n){var o=a[s];if(!(i>=a.length||i!==s)&&o){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||null!==(r=o.details)&&void 0!==r&&r.live){if(n.deltaUpdateFailed)return;this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=i,this.setInterval(500)}}},v._handleFragmentLoadComplete=function(t){var e=t.frag,r=t.payload,n=e.decryptdata,s=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).then((function(t){var r=performance.now();s.trigger(i.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:a,tdecrypt:r}})}))}},v.doTick=function(){if(this.media){if(this.state===l.State.IDLE){var t,e=this.config,r=this.currentTrackId,u=this.fragmentTracker,d=this.media,c=this.levels;if(!c.length||!c[r]||!c[r].details)return;var h=e.maxBufferHole,f=e.maxFragLookUpTolerance,p=Math.min(e.maxBufferLength,e.maxMaxBufferLength),g=s.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,d.currentTime,h),m=g.end;if(g.len>p)return;var v=c[r].details;console.assert(v,"Subtitle track details are defined on idle subtitle stream controller tick");var y,E=v.fragments,T=E.length,_=E[T-1].start+E[T-1].duration,b=this.fragPrevious;m<_?(b&&v.hasProgramDateTime&&(y=Object(a.findFragmentByPDT)(E,b.endProgramDateTime,f)),y||(y=Object(a.findFragmentByPTS)(b,E,m,f))):y=E[T-1],null!==(t=y)&&void 0!==t&&t.encrypted?(n.logger.log("Loading key for "+y.sn),this.state=l.State.KEY_LOADING,this.hls.trigger(i.Events.KEY_LOADING,{frag:y})):y&&u.getState(y)===o.FragmentState.NOT_LOADED&&this.loadFragment(y,v,m)}}else this.state=l.State.IDLE},v.loadFragment=function(e,r,i){this.fragCurrent=e,t.prototype.loadFragment.call(this,e,r,i)},v.stopLoad=function(){this.fragPrevious=null,t.prototype.stopLoad.call(this)},p=f,(g=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&c(p.prototype,g),m&&c(p,m),f}(l.default)},"./src/controller/subtitle-track-controller.ts":
108
108
  /*!*****************************************************!*\
109
109
  !*** ./src/controller/subtitle-track-controller.ts ***!
110
110
  \*****************************************************/
111
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,d,f,h=a.prototype;return h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=null,e.prototype.destroy.call(this)},h.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(n.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(n.Events.ERROR,this.onError,this)},h.onMediaAttached=function(e,t){var r=this;this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?(self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval((function(){r.trackChangeListener()}),500)):this.media.textTracks.addEventListener("change",this.trackChangeListener))},h.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?self.clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(e){Object(i.clearCurrentCues)(e)})),this.subtitleTrack=-1,this.media=null)},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},h.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},h.onSubtitleTrackLoaded=function(e,t){var r=t.id,n=t.details,i=this.trackId,a=this.tracksInGroup[i];if(a){var s=a.details;a.details=t.details,this.log("subtitle track "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,s))}else this.warn("Invalid subtitle track id "+r)},h.onLevelLoading=function(e,t){this.switchLevel(t.level)},h.onLevelSwitching=function(e,t){this.switchLevel(t.level)},h.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.textGroupIds){var r=t.textGroupIds[t.urlId];if(this.groupId!==r){var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=a;var s=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==s&&this.setSubtitleTrack(s,i)}}},h.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},h.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},h.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,i=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:i,deliveryDirectives:e||null})}},h.toggleTrackModes=function(e){var t=this,r=this.media,n=this.subtitleDisplay,i=this.trackId;if(r){var a=c(r.textTracks),s=a.filter((function(e){return e.groupId===t.groupId}));if(-1===e)[].slice.call(a).forEach((function(e){e.mode="disabled"}));else{var o=s[i];o&&(o.mode="disabled")}var l=s[e];l&&(l.mode=n?"showing":"hidden")}},h.setSubtitleTrack=function(e,t){var r,i=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!==(r=i[e])&&void 0!==r&&r.details)||e<-1||e>=i.length)){this.clearTimer();var a=i[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var s=a.id,o=a.groupId,l=void 0===o?"":o,u=a.name,c=a.type,d=a.url;this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:s,groupId:l,name:u,type:c,url:d});var f=this.switchParams(a.url,null==t?void 0:t.details);this.loadPlaylist(f)}else this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},h.onTextTracksChanged=function(){if(this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}},u=a,(d=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}])&&o(u.prototype,d),f&&o(u,f),a}(a.default);function c(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];"subtitles"===n.kind&&n.label&&t.push(e[r])}return t}t.default=u},"./src/controller/timeline-controller.ts":
111
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var u=function(t){var e,r;function s(e){var r;return(r=t.call(this,e,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}r=t,(e=s).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r);var u,c,h,f=s.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=null,t.prototype.destroy.call(this)},f.registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(i.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(i.Events.ERROR,this.onError,this)},f.onMediaAttached=function(t,e){var r=this;this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?(self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval((function(){r.trackChangeListener()}),500)):this.media.textTracks.addEventListener("change",this.trackChangeListener))},f.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?self.clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),d(this.media.textTracks).forEach((function(t){Object(n.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},f.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.trackId,s=this.tracksInGroup[n];if(s){var a=s.details;s.details=e.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,e,a))}else this.warn("Invalid subtitle track id "+r)},f.onLevelLoading=function(t,e){this.switchLevel(e.level)},f.onLevelSwitching=function(t,e){this.switchLevel(e.level)},f.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var r=e.textGroupIds[e.urlId];if(this.groupId!==r){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter((function(t){return!r||t.groupId===r}));this.tracksInGroup=s;var a=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,n)}}},f.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r<e.length;r++){var i=e[r];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1},f.onError=function(e,r){t.prototype.onError.call(this,e,r),!r.fatal&&r.context&&r.context.type===a.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.loadPlaylist=function(t){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var r=e.id,n=e.groupId,s=e.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADING,{url:s,id:r,groupId:n,deliveryDirectives:t||null})}},f.toggleTrackModes=function(t){var e=this,r=this.media,i=this.subtitleDisplay,n=this.trackId;if(r){var s=d(r.textTracks),a=s.filter((function(t){return t.groupId===e.groupId}));if(-1===t)[].slice.call(s).forEach((function(t){t.mode="disabled"}));else{var o=a[n];o&&(o.mode="disabled")}var l=a[t];l&&(l.mode=i?"showing":"hidden")}},f.setSubtitleTrack=function(t,e){var r,n=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(r=n[t])&&void 0!==r&&r.details)||t<-1||t>=n.length)){this.clearTimer();var s=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.id,o=s.groupId,l=void 0===o?"":o,u=s.name,d=s.type,c=s.url;this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:a,groupId:l,name:u,type:d,url:c});var h=this.switchParams(s.url,null==e?void 0:e.details);this.loadPlaylist(h)}else this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},f.onTextTracksChanged=function(){if(this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=d(this.media.textTracks),r=0;r<e.length;r++)if("hidden"===e[r].mode)t=r;else if("showing"===e[r].mode){t=r;break}this.subtitleTrack=t}},u=s,(c=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}])&&o(u.prototype,c),h&&o(u,h),s}(s.default);function d(t){for(var e=[],r=0;r<t.length;r++){var i=t[r];"subtitles"===i.kind&&i.label&&e.push(t[r])}return e}e.default=u},"./src/controller/timeline-controller.ts":
112
112
  /*!***********************************************!*\
113
113
  !*** ./src/controller/timeline-controller.ts ***!
114
114
  \***********************************************/
115
- /*! exports provided: TimelineController */function(e,t,r){r.r(t),r.d(t,"TimelineController",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),s=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=function(){function e(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new s.default(this,"textTrack1"),r=new s.default(this,"textTrack2"),n=new s.default(this,"textTrack3"),o=new s.default(this,"textTrack4");this.cea608Parser1=new a.default(1,t,r),this.cea608Parser2=new a.default(3,n,o)}e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(i.Events.FRAG_LOADING,this.onFragLoading,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(i.Events.FRAG_LOADING,this.onFragLoading,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,r,n,a){for(var s,o,l,u,c=!1,d=a.length;d--;){var f=a[d],h=(s=f[0],o=f[1],l=t,u=r,Math.min(o,u)-Math.max(s,l));if(h>=0&&(f[0]=Math.min(f[0],t),f[1]=Math.max(f[1],r),c=!0,h/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var p=this.captionsTracks[e];this.Cues.newCue(p,t,r,n)}else{var v=this.Cues.newCue(null,t,r,n);this.hls.trigger(i.Events.CUES_PARSED,{type:"captions",cues:v,track:e})}},t.onInitPtsFound=function(e,t){var r=this,n=t.frag,a=t.id,s=t.initPTS,o=t.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[n.cc]=s,this.timescale[n.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(e){r.onFragLoaded(i.Events.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var n=t.textTracks[r];if(n[e])return n}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,n=this.media,i=t[e],a=i.label,s=i.languageCode,o=this.getExistingTrack(e);if(o)r[e]=o,Object(l.clearCurrentCues)(r[e]),Object(l.sendAddTrackEvent)(r[e],n);else{var u=this.createTextTrack("captions",a,s);u&&(u[e]=!0,r[e]=u)}}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},t.createTextTrack=function(e,t,r){var n=this.media;if(n)return n.addTextTrack(e,t,r)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){Object(l.clearCurrentCues)(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)Object(l.clearCurrentCues)(t[r])}},t.onSubtitleTracksUpdated=function(e,t){var r=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some((function(e){return e.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var s=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,t){var n;if(t<o.length){for(var i=null,a=0;a<o.length;a++)if(h(o[a],e)){i=o[a];break}i&&(n=i)}n?Object(l.clearCurrentCues)(n):(n=r.createTextTrack("subtitles",e.name,e.lang))&&(n.mode="disabled"),n&&(n.groupId=e.groupId,r.textTracks.push(n))}))}else if(!s&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},t.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var n="textTrack"+t[1],i=r.captionsProperties[n];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)}}))},t.onFragLoading=function(e,t){var r=this.cea608Parser1,n=this.cea608Parser2,i=this.lastSn;if(this.enabled&&r&&n&&t.frag.type===c.PlaylistLevelType.MAIN){var a=t.frag.sn;a!==i+1&&(r.reset(),n.reset()),this.lastSn=a}},t.onFragLoaded=function(e,t){var r=t.frag,a=t.payload,s=this.initPTS,o=this.unparsedVttFrags;if(r.type===c.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!Object(n.isFiniteNumber)(s[r.cc]))return o.push(t),void(s.length&&this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var d=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,a):this._parseVTTs(r,a,f)}}else this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var r=this,n=this.hls;Object(u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(t){r._appendCues(t,e.level),n.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){d.logger.log("Failed to parse IMSC1: "+t),n.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e,t,r){var n=this,a=this.hls;Object(o.parseWebVTT)(t,this.initPTS[e.cc],this.timescale[e.cc],r,e.cc,e.start,(function(t){n._appendCues(t,e.level),a.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(r){n._fallbackToIMSC1(e,t),d.logger.log("Failed to parse VTT cue: "+r),a.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})}))},t._fallbackToIMSC1=function(e,t){var r=this,n=this.tracks[e.level];n.textCodec||Object(u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(){n.textCodec=u.IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){n.textCodec="wvtt"}))},t._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if("disabled"===n.mode)return;e.forEach((function(e){return Object(l.addCueToTrack)(n,e)}))}else{var a=this.tracks[t].default?"default":"subtitles"+t;r.trigger(i.Events.CUES_PARSED,{type:"subtitles",cues:e,track:a})}},t.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===c.PlaylistLevelType.SUBTITLE){if(!Object(n.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(i.Events.FRAG_LOADED,t)}},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&r&&n)for(var i=0;i<t.samples.length;i++){var a=t.samples[i].bytes;if(a){var s=this.extractCea608Data(a);r.addData(t.samples[i].pts,s[0]),n.addData(t.samples[i].pts,s[1])}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset,i=t.type;if(!i||"video"===i){var a=this.media;if(!a||a.currentTime<n)return;var s=this.captionsTracks;Object.keys(s).forEach((function(e){return Object(l.removeCuesInRange)(s[e],r,n)}))}},t.extractCea608Data=function(e){for(var t=31&e[0],r=2,n=[[],[]],i=0;i<t;i++){var a=e[r++],s=127&e[r++],o=127&e[r++],l=3&a;0===s&&0===o||0!=(4&a)&&(0!==l&&1!==l||(n[l].push(s),n[l].push(o)))}return n},e}();function h(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}},"./src/crypt/aes-crypto.ts":
115
+ /*! exports provided: TimelineController */function(t,e,r){r.r(e),r.d(e,"TimelineController",(function(){return h}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),d=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),h=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var e=new a.default(this,"textTrack1"),r=new a.default(this,"textTrack2"),i=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,e,r),this.cea608Parser2=new s.default(3,i,o)}t.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(n.Events.FRAG_LOADING,this.onFragLoading,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(n.Events.FRAG_LOADING,this.onFragLoading,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,r,i,s){for(var a,o,l,u,d=!1,c=s.length;c--;){var h=s[c],f=(a=h[0],o=h[1],l=e,u=r,Math.min(o,u)-Math.max(a,l));if(f>=0&&(h[0]=Math.min(h[0],e),h[1]=Math.max(h[1],r),d=!0,f/(r-e)>.5))return}if(d||s.push([e,r]),this.config.renderTextTracksNatively){var p=this.captionsTracks[t];this.Cues.newCue(p,e,r,i)}else{var g=this.Cues.newCue(null,e,r,i);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:g,track:t})}},e.onInitPtsFound=function(t,e){var r=this,i=e.frag,s=e.id,a=e.initPTS,o=e.timescale,l=this.unparsedVttFrags;"main"===s&&(this.initPTS[i.cc]=a,this.timescale[i.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(t){r.onFragLoaded(n.Events.FRAG_LOADED,t)})))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r<e.textTracks.length;r++){var i=e.textTracks[r];if(i[t])return i}return null},e.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},e.createNativeTrack=function(t){if(!this.captionsTracks[t]){var e=this.captionsProperties,r=this.captionsTracks,i=this.media,n=e[t],s=n.label,a=n.languageCode,o=this.getExistingTrack(t);if(o)r[t]=o,Object(l.clearCurrentCues)(r[t]),Object(l.sendAddTrackEvent)(r[t],i);else{var u=this.createTextTrack("captions",s,a);u&&(u[t]=!0,r[t]=u)}}},e.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var e=this.captionsProperties[t];if(e){var r={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=r,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},e.createTextTrack=function(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)},e.onMediaAttaching=function(t,e){this.media=e.media,this._cleanTracks()},e.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(e){Object(l.clearCurrentCues)(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},e._cleanTracks=function(){var t=this.media;if(t){var e=t.textTracks;if(e)for(var r=0;r<e.length;r++)Object(l.clearCurrentCues)(e[r])}},e.onSubtitleTracksUpdated=function(t,e){var r=this;this.textTracks=[];var i=e.subtitleTracks||[],s=i.some((function(t){return t.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,e){var i;if(e<o.length){for(var n=null,s=0;s<o.length;s++)if(f(o[s],t)){n=o[s];break}n&&(i=n)}i?Object(l.clearCurrentCues)(i):(i=r.createTextTrack("subtitles",t.name,t.lang))&&(i.mode="disabled"),i&&(i.groupId=t.groupId,r.textTracks.push(i))}))}else if(!a&&this.tracks&&this.tracks.length){var d=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},e.onManifestLoaded=function(t,e){var r=this;this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((function(t){var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(e){var i="textTrack"+e[1],n=r.captionsProperties[i];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}}))},e.onFragLoading=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2,n=this.lastSn;if(this.enabled&&r&&i&&e.frag.type===d.PlaylistLevelType.MAIN){var s=e.frag.sn;s!==n+1&&(r.reset(),i.reset()),this.lastSn=s}},e.onFragLoaded=function(t,e){var r=e.frag,s=e.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===d.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(i.isFiniteNumber)(a[r.cc]))return o.push(e),void(a.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var c=this.tracks[r.level],h=this.vttCCs;h[r.cc]||(h[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),c&&c.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,s):this._parseVTTs(r,s,h)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},e._parseIMSC1=function(t,e){var r=this,i=this.hls;Object(u.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(e){r._appendCues(e,t.level),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(e){c.logger.log("Failed to parse IMSC1: "+e),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))},e._parseVTTs=function(t,e,r){var i=this,s=this.hls;Object(o.parseWebVTT)(e,this.initPTS[t.cc],this.timescale[t.cc],r,t.cc,t.start,(function(e){i._appendCues(e,t.level),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(r){i._fallbackToIMSC1(t,e),c.logger.log("Failed to parse VTT cue: "+r),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:r})}))},e._fallbackToIMSC1=function(t,e){var r=this,i=this.tracks[t.level];i.textCodec||Object(u.parseIMSC1)(e,this.initPTS[t.cc],this.timescale[t.cc],(function(){i.textCodec=u.IMSC1_CODEC,r._parseIMSC1(t,e)}),(function(){i.textCodec="wvtt"}))},e._appendCues=function(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[e];if("disabled"===i.mode)return;t.forEach((function(t){return Object(l.addCueToTrack)(i,t)}))}else{var s=this.tracks[e].default?"default":"subtitles"+e;r.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:t,track:s})}},e.onFragDecrypted=function(t,e){var r=e.frag;if(r.type===d.PlaylistLevelType.SUBTITLE){if(!Object(i.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(e);this.onFragLoaded(n.Events.FRAG_LOADED,e)}},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i)for(var n=0;n<e.samples.length;n++){var s=e.samples[n].bytes;if(s){var a=this.extractCea608Data(s);r.addData(e.samples[n].pts,a[0]),i.addData(e.samples[n].pts,a[1])}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,n=e.type;if(!n||"video"===n){var s=this.media;if(!s||s.currentTime<i)return;var a=this.captionsTracks;Object.keys(a).forEach((function(t){return Object(l.removeCuesInRange)(a[t],r,i)}))}},e.extractCea608Data=function(t){for(var e=31&t[0],r=2,i=[[],[]],n=0;n<e;n++){var s=t[r++],a=127&t[r++],o=127&t[r++],l=3&s;0===a&&0===o||0!=(4&s)&&(0!==l&&1!==l||(i[l].push(a),i[l].push(o)))}return i},t}();function f(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
116
116
  /*!*********************************!*\
117
117
  !*** ./src/crypt/aes-crypto.ts ***!
118
118
  \*********************************/
119
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}()},"./src/crypt/aes-decryptor.ts":
119
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}()},"./src/crypt/aes-decryptor.ts":
120
120
  /*!************************************!*\
121
121
  !*** ./src/crypt/aes-decryptor.ts ***!
122
122
  \************************************/
123
- /*! exports provided: removePadding, default */function(e,t,r){r.r(t),r.d(t,"removePadding",(function(){return i})),r.d(t,"default",(function(){return a}));var n=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function i(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?Object(n.sliceUint8)(e,0,t-r):e}var a=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],i=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],f=new Uint32Array(256),h=0,p=0,v=0;for(v=0;v<256;v++)f[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var g=p^p<<1^p<<2^p<<3^p<<4;g=g>>>8^255&g^99,e[h]=g,t[g]=h;var m=f[h],y=f[m],E=f[y],_=257*f[g]^16843008*g;n[h]=_<<24|_>>>8,i[h]=_<<16|_>>>16,a[h]=_<<8|_>>>24,s[h]=_,_=16843009*E^65537*y^257*m^16843008*h,l[g]=_<<24|_>>>8,u[g]=_<<16|_>>>16,c[g]=_<<8|_>>>24,d[g]=_,h?(h=m^f[f[f[E^m]]],p^=f[f[p]]):h=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var a,s,o,l,u=this.ksRows=4*(i+6+1),c=this.keySchedule=new Uint32Array(u),d=this.invKeySchedule=new Uint32Array(u),f=this.sBox,h=this.rcon,p=this.invSubMix,v=p[0],g=p[1],m=p[2],y=p[3];for(a=0;a<u;a++)a<i?o=c[a]=t[a]:(l=o,a%i==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=h[a/i|0]<<24):i>6&&a%i==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),c[a]=o=(c[a-i]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],d[s]=s<4||a<=4?l:v[f[l>>>24]]^g[f[l>>>16&255]]^m[f[l>>>8&255]]^y[f[255&l]],d[s]=d[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var n,i,a,s,o,l,u,c,d,f,h,p,v,g,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,_=this.invSubMix,T=_[0],b=_[1],A=_[2],S=_[3],w=this.uint8ArrayToUint32Array_(r),L=w[0],k=w[1],R=w[2],D=w[3],O=new Int32Array(e),C=new Int32Array(O.length),I=this.networkToHostOrderSwap;t<O.length;){for(d=I(O[t]),f=I(O[t+1]),h=I(O[t+2]),p=I(O[t+3]),o=d^y[0],l=p^y[1],u=h^y[2],c=f^y[3],v=4,g=1;g<m;g++)n=T[o>>>24]^b[l>>16&255]^A[u>>8&255]^S[255&c]^y[v],i=T[l>>>24]^b[u>>16&255]^A[c>>8&255]^S[255&o]^y[v+1],a=T[u>>>24]^b[c>>16&255]^A[o>>8&255]^S[255&l]^y[v+2],s=T[c>>>24]^b[o>>16&255]^A[l>>8&255]^S[255&u]^y[v+3],o=n,l=i,u=a,c=s,v+=4;n=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&c]^y[v],i=E[l>>>24]<<24^E[u>>16&255]<<16^E[c>>8&255]<<8^E[255&o]^y[v+1],a=E[u>>>24]<<24^E[c>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[v+2],s=E[c>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[v+3],C[t]=I(n^L),C[t+1]=I(s^k),C[t+2]=I(a^R),C[t+3]=I(i^D),L=d,k=f,R=h,D=p,t+=4}return C.buffer},e}()},"./src/crypt/decrypter.ts":
123
+ /*! exports provided: removePadding, default */function(t,e,r){r.r(e),r.d(e,"removePadding",(function(){return n})),r.d(e,"default",(function(){return s}));var i=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var e=t.byteLength,r=e&&new DataView(t.buffer).getUint8(e-1);return r?Object(i.sliceUint8)(t,0,e-r):t}var s=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},e.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],c=o[3],h=new Uint32Array(256),f=0,p=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=p^p<<1^p<<2^p<<3^p<<4;m=m>>>8^255&m^99,t[f]=m,e[m]=f;var v=h[f],y=h[v],E=h[y],T=257*h[m]^16843008*m;i[f]=T<<24|T>>>8,n[f]=T<<16|T>>>16,s[f]=T<<8|T>>>24,a[f]=T,T=16843009*E^65537*y^257*v^16843008*f,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,c[m]=T,f?(f=v^h[h[h[E^v]]],p^=h[h[p]]):f=p=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i<e.length&&r;)r=e[i]===this.key[i],i++;if(!r){this.key=e;var n=this.keySize=e.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var s,a,o,l,u=this.ksRows=4*(n+6+1),d=this.keySchedule=new Uint32Array(u),c=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,p=this.invSubMix,g=p[0],m=p[1],v=p[2],y=p[3];for(s=0;s<u;s++)s<n?o=d[s]=e[s]:(l=o,s%n==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=f[s/n|0]<<24):n>6&&s%n==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),d[s]=o=(d[s-n]^l)>>>0);for(a=0;a<u;a++)s=u-a,l=3&a?d[s]:d[s-4],c[a]=a<4||s<=4?l:g[h[l>>>24]]^m[h[l>>>16&255]]^v[h[l>>>8&255]]^y[h[255&l]],c[a]=c[a]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,r){for(var i,n,s,a,o,l,u,d,c,h,f,p,g,m,v=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,_=T[0],b=T[1],S=T[2],A=T[3],L=this.uint8ArrayToUint32Array_(r),w=L[0],k=L[1],R=L[2],D=L[3],O=new Int32Array(t),I=new Int32Array(O.length),C=this.networkToHostOrderSwap;e<O.length;){for(c=C(O[e]),h=C(O[e+1]),f=C(O[e+2]),p=C(O[e+3]),o=c^y[0],l=p^y[1],u=f^y[2],d=h^y[3],g=4,m=1;m<v;m++)i=_[o>>>24]^b[l>>16&255]^S[u>>8&255]^A[255&d]^y[g],n=_[l>>>24]^b[u>>16&255]^S[d>>8&255]^A[255&o]^y[g+1],s=_[u>>>24]^b[d>>16&255]^S[o>>8&255]^A[255&l]^y[g+2],a=_[d>>>24]^b[o>>16&255]^S[l>>8&255]^A[255&u]^y[g+3],o=i,l=n,u=s,d=a,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[g+1],s=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],a=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],I[e]=C(i^w),I[e+1]=C(a^k),I[e+2]=C(s^R),I[e+3]=C(n^D),w=c,k=h,R=f,D=p,e+=4}return I.buffer},t}()},"./src/crypt/decrypter.ts":
124
124
  /*!********************************!*\
125
125
  !*** ./src/crypt/decrypter.ts ***!
126
126
  \********************************/
127
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return u}));var n=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),i=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),a=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(e,t,r){var n=(void 0===r?{}:r).removePKCS7Padding,i=void 0===n||n;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=e,this.config=t,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var t=e.prototype;return t.destroy=function(){this.observer=null},t.isSync=function(){return this.config.enableSoftwareAES},t.flush=function(){var e=this.currentResult;if(e){var t=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Object(a.removePadding)(t):t}this.reset()},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,n){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(e),t,r);var i=this.flush();i&&n(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(e),t,r).then(n)},t.softwareDecrypt=function(e,t,r){var n=this.currentIV,i=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=Object(o.appendUint8Array)(s,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;n&&(r=n);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new a.default),c.expandKey(t);var d=i;return this.currentResult=c.decrypt(u.buffer,0,r),this.currentIV=Object(l.sliceUint8)(u,-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,r){var a=this,s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new i.default(s,t)),this.fastAesKey.expandKey().then((function(t){return s?new n.default(s,r).decrypt(e.buffer,t):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return a.onWebCryptoError(n,e,t,r)}))},t.onWebCryptoError=function(e,t,r,n){return s.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",e),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,n)},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=Object(l.sliceUint8)(e,0,r),this.remainderData=Object(l.sliceUint8)(e,r)),t},t.logOnce=function(e){this.logEnabled&&(s.logger.log("[decrypter.ts]: "+e),this.logEnabled=!1)},e}()},"./src/crypt/fast-aes-key.ts":
127
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return u}));var i=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(t,e,r){var i=(void 0===r?{}:r).removePKCS7Padding,n=void 0===i||i;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=t,this.config=e,this.removePKCS7Padding=n,n)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(t){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var e=t.prototype;return e.destroy=function(){this.observer=null},e.isSync=function(){return this.config.enableSoftwareAES},e.flush=function(){var t=this.currentResult;if(t){var e=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Object(s.removePadding)(e):e}this.reset()},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,r,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),e,r);var n=this.flush();n&&i(n.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),e,r).then(i)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,n=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=Object(o.appendUint8Array)(a,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new s.default),d.expandKey(e);var c=n;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=Object(l.sliceUint8)(u,-16).buffer,c||null},e.webCryptoDecrypt=function(t,e,r){var s=this,a=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new n.default(a,e)),this.fastAesKey.expandKey().then((function(e){return a?new i.default(a,r).decrypt(t.buffer,e):Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){return s.onWebCryptoError(i,t,e,r)}))},e.onWebCryptoError=function(t,e,r,i){return a.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(e,r,i)},e.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=Object(l.sliceUint8)(t,0,r),this.remainderData=Object(l.sliceUint8)(t,r)),e},e.logOnce=function(t){this.logEnabled&&(a.logger.log("[decrypter.ts]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
128
128
  /*!***********************************!*\
129
129
  !*** ./src/crypt/fast-aes-key.ts ***!
130
130
  \***********************************/
131
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}()},"./src/demux/aacdemuxer.ts":
131
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
132
132
  /*!*********************************!*\
133
133
  !*** ./src/demux/aacdemuxer.ts ***!
134
134
  \*********************************/
135
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),i=r(/*! ./adts */"./src/demux/adts.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){var t,r;function n(t,r){var n;return(n=e.call(this)||this).observer=void 0,n.config=void 0,n.observer=t,n.config=r,n}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=n.prototype;return l.resetInitSegment=function(t,r,n){e.prototype.resetInitSegment.call(this,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(i.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(e,t){return i.canParse(e,t)},l.appendFrame=function(e,t,r){return i.initTrackConfig(e,this.observer,t,r,e.manifestCodec),i.appendFrame(e,t,r,this.initPTS,this.frameIndex)},n}(n.default);l.minProbeByteLength=9,t.default=l},"./src/demux/adts.ts":
135
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ./adts */"./src/demux/adts.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,r;function i(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,o(e,r);var l=i.prototype;return l.resetInitSegment=function(e,r,i){t.prototype.resetInitSegment.call(this,e,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},i.probe=function(t){if(!t)return!1;for(var e=(a.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(n.probe(t,e))return s.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(t,e){return n.canParse(t,e)},l.appendFrame=function(t,e,r){return n.initTrackConfig(t,this.observer,e,r,t.manifestCodec),n.appendFrame(t,e,r,this.initPTS,this.frameIndex)},i}(i.default);l.minProbeByteLength=9,e.default=l},"./src/demux/adts.ts":
136
136
  /*!***************************!*\
137
137
  !*** ./src/demux/adts.ts ***!
138
138
  \***************************/
139
- /*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(e,t,r){r.r(t),r.d(t,"getAudioConfig",(function(){return s})),r.d(t,"isHeaderPattern",(function(){return o})),r.d(t,"getHeaderLength",(function(){return l})),r.d(t,"getFullFrameLength",(function(){return u})),r.d(t,"canGetFrameLength",(function(){return c})),r.d(t,"isHeader",(function(){return d})),r.d(t,"canParse",(function(){return f})),r.d(t,"probe",(function(){return h})),r.d(t,"initTrackConfig",(function(){return p})),r.d(t,"getFrameDuration",(function(){return v})),r.d(t,"parseFrameHeader",(function(){return g})),r.d(t,"appendFrame",(function(){return m}));var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts");function s(e,t,r,s){var o,l,u,c,d=navigator.userAgent.toLowerCase(),f=s,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&t[r+2])>>>6);var p=(60&t[r+2])>>>2;if(!(p>h.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,n.logger.log("manifest codec:"+s+", ADTS type:"+o+", samplingIndex:"+p),/firefox/i.test(d)?p>=6?(o=5,c=new Array(4),l=p-3):(o=2,c=new Array(2),l=p):-1!==d.indexOf("android")?(o=2,c=new Array(2),l=p):(o=5,c=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&p>=6?l=p-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(p>=6&&1===u||/vivaldi/i.test(d))||!s&&1===u)&&(o=2,c=new Array(2)),l=p)),c[0]=o<<3,c[0]|=(14&p)>>1,c[1]|=(1&p)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&l)>>1,c[2]=(1&l)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:h[p],channelCount:u,codec:"mp4a.40."+o,manifestCodec:f};e.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function c(e,t){return t+5<e.length}function d(e,t){return t+1<e.length&&o(e,t)}function f(e,t){return c(e,t)&&o(e,t)&&u(e,t)<=e.length-t}function h(e,t){if(d(e,t)){var r=l(e,t);if(t+r>=e.length)return!1;var n=u(e,t);if(n<=r)return!1;var i=t+n;return i===e.length||d(e,i)}return!1}function p(e,t,r,i,a){if(!e.samplerate){var o=s(t,r,i,a);if(!o)return;e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,n.logger.log("parsed codec:"+e.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function v(e){return 9216e4/e}function g(e,t,r,n,i){var a=e.length,s=l(e,t),o=u(e,t);if((o-=s)>0&&t+s+o<=a)return{headerLength:s,frameLength:o,stamp:r+n*i}}function m(e,t,r,n,i){var a=g(t,r,n,i,v(e.samplerate));if(a){var s=a.stamp,o=a.headerLength,l=a.frameLength,u={unit:t.subarray(r+o,r+o+l),pts:s,dts:s};return e.samples.push(u),{sample:u,length:l+o}}}},"./src/demux/base-audio-demuxer.ts":
139
+ /*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,e,r){r.r(e),r.d(e,"getAudioConfig",(function(){return a})),r.d(e,"isHeaderPattern",(function(){return o})),r.d(e,"getHeaderLength",(function(){return l})),r.d(e,"getFullFrameLength",(function(){return u})),r.d(e,"canGetFrameLength",(function(){return d})),r.d(e,"isHeader",(function(){return c})),r.d(e,"canParse",(function(){return h})),r.d(e,"probe",(function(){return f})),r.d(e,"initTrackConfig",(function(){return p})),r.d(e,"getFrameDuration",(function(){return g})),r.d(e,"parseFrameHeader",(function(){return m})),r.d(e,"appendFrame",(function(){return v}));var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../events */"./src/events.ts");function a(t,e,r,a){var o,l,u,d,c=navigator.userAgent.toLowerCase(),h=a,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&e[r+2])>>>6);var p=(60&e[r+2])>>>2;if(!(p>f.length-1))return u=(1&e[r+2])<<2,u|=(192&e[r+3])>>>6,i.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+p),/firefox/i.test(c)?p>=6?(o=5,d=new Array(4),l=p-3):(o=2,d=new Array(2),l=p):-1!==c.indexOf("android")?(o=2,d=new Array(2),l=p):(o=5,d=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&p>=6?l=p-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(p>=6&&1===u||/vivaldi/i.test(c))||!a&&1===u)&&(o=2,d=new Array(2)),l=p)),d[0]=o<<3,d[0]|=(14&p)>>1,d[1]|=(1&p)<<7,d[1]|=u<<3,5===o&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:f[p],channelCount:u,codec:"mp4a.40."+o,manifestCodec:h};t.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function o(t,e){return 255===t[e]&&240==(246&t[e+1])}function l(t,e){return 1&t[e+1]?7:9}function u(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function d(t,e){return e+5<t.length}function c(t,e){return e+1<t.length&&o(t,e)}function h(t,e){return d(t,e)&&o(t,e)&&u(t,e)<=t.length-e}function f(t,e){if(c(t,e)){var r=l(t,e);if(e+r>=t.length)return!1;var i=u(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||c(t,n)}return!1}function p(t,e,r,n,s){if(!t.samplerate){var o=a(e,r,n,s);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function g(t){return 9216e4/t}function m(t,e,r,i,n){var s=t.length,a=l(t,e),o=u(t,e);if((o-=a)>0&&e+a+o<=s)return{headerLength:a,frameLength:o,stamp:r+i*n}}function v(t,e,r,i,n){var s=m(e,r,i,n,g(t.samplerate));if(s){var a=s.stamp,o=s.headerLength,l=s.frameLength,u={unit:e.subarray(r+o,r+o+l),pts:a,dts:a};return t.samples.push(u),{sample:u,length:l+o}}}},"./src/demux/base-audio-demuxer.ts":
140
140
  /*!*****************************************!*\
141
141
  !*** ./src/demux/base-audio-demuxer.ts ***!
142
142
  \*****************************************/
143
- /*! exports provided: initPTSFn, default */function(e,t,r){r.r(t),r.d(t,"initPTSFn",(function(){return u}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),l=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(){},t.resetContiguity=function(){},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=Object(s.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,n,l=i.getID3Data(e,0),c=l?l.length:0,d=this._audioTrack,f=this._id3Track,h=l?i.getTimeStamp(l):void 0,p=e.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=u(h,t)),l&&l.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:l}),n=this.initPTS;c<p;){if(this.canParse(e,c)){var v=this.appendFrame(d,e,c);v?(this.frameIndex++,n=v.sample.pts,r=c+=v.length):c=p}else i.canParse(e,c)?(l=i.getID3Data(e,c),f.samples.push({pts:n,dts:n,data:l}),r=c+=l.length):c++;if(c===p&&r!==p){var g=Object(o.sliceUint8)(e,r);this.cachedData?this.cachedData=Object(s.appendUint8Array)(this.cachedData,g):this.cachedData=g}}return{audioTrack:d,avcTrack:Object(a.dummyTrack)(),id3Track:f,textTrack:Object(a.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(a.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(a.dummyTrack)()}},t.destroy=function(){},e}(),u=function(e,t){return Object(n.isFiniteNumber)(e)?90*e:9e4*t};t.default=l},"./src/demux/chunk-cache.ts":
143
+ /*! exports provided: initPTSFn, default */function(t,e,r){r.r(e),r.d(e,"initPTSFn",(function(){return u}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),l=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(){},e.resetContiguity=function(){},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=Object(a.appendUint8Array)(this.cachedData,t),this.cachedData=null);var r,i,l=n.getID3Data(t,0),d=l?l.length:0,c=this._audioTrack,h=this._id3Track,f=l?n.getTimeStamp(l):void 0,p=t.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=u(f,e)),l&&l.length>0&&h.samples.push({pts:this.initPTS,dts:this.initPTS,data:l}),i=this.initPTS;d<p;){if(this.canParse(t,d)){var g=this.appendFrame(c,t,d);g?(this.frameIndex++,i=g.sample.pts,r=d+=g.length):d=p}else n.canParse(t,d)?(l=n.getID3Data(t,d),h.samples.push({pts:i,dts:i,data:l}),r=d+=l.length):d++;if(d===p&&r!==p){var m=Object(o.sliceUint8)(t,r);this.cachedData?this.cachedData=Object(a.appendUint8Array)(this.cachedData,m):this.cachedData=m}}return{audioTrack:c,avcTrack:Object(s.dummyTrack)(),id3Track:h,textTrack:Object(s.dummyTrack)()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(s.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(s.dummyTrack)()}},e.destroy=function(){},t}(),u=function(t,e){return Object(i.isFiniteNumber)(t)?90*t:9e4*e};e.default=l},"./src/demux/chunk-cache.ts":
144
144
  /*!**********************************!*\
145
145
  !*** ./src/demux/chunk-cache.ts ***!
146
146
  \**********************************/
147
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),n=0,i=0;i<e.length;i++){var a=e[i];r.set(a,n),n+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}()},"./src/demux/dummy-demuxed-track.ts":
147
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n<t.length;n++){var s=t[n];r.set(s,i),i+=s.length}return r}(e,r),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
148
148
  /*!******************************************!*\
149
149
  !*** ./src/demux/dummy-demuxed-track.ts ***!
150
150
  \******************************************/
151
- /*! exports provided: dummyTrack */function(e,t,r){function n(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}r.r(t),r.d(t,"dummyTrack",(function(){return n}))},"./src/demux/exp-golomb.ts":
151
+ /*! exports provided: dummyTrack */function(t,e,r){function i(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}r.r(e),r.d(e,"dummyTrack",(function(){return i}))},"./src/demux/exp-golomb.ts":
152
152
  /*!*********************************!*\
153
153
  !*** ./src/demux/exp-golomb.ts ***!
154
154
  \*********************************/
155
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,n=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");n.set(e.subarray(r,r+i)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,n=0,i=0,a=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),d=this.skipBits.bind(this),f=this.skipEG.bind(this),h=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();var v=o();if(l(5),d(3),o(),h(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){var g=u();if(3===g&&d(1),h(),h(),d(1),c())for(t=3!==g?8:12,r=0;r<t;r++)c()&&p(r<6?16:64)}h();var m=u();if(0===m)u();else if(1===m)for(d(1),f(),f(),e=u(),r=0;r<e;r++)f();h(),d(1);var y=u(),E=u(),_=l(1);0===_&&d(1),d(1),c()&&(n=u(),i=u(),a=u(),s=u());var T=[1,1];if(c()&&c())switch(o()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*n-2*i),height:(2-_)*(E+1)*16-(_?2:4)*(a+s),pixelRatio:T}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}();t.default=i},"./src/demux/id3.ts":
155
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw new Error("no bytes available");i.set(t.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},e.skipBits=function(t){var e;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),(e=t-e)>0&&this.bitsAvailable?r<<e|this.readBits(e):r},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)0!==r&&(r=(e+this.readEG()+256)%256),e=0===r?e:r},e.readSPS=function(){var t,e,r,i=0,n=0,s=0,a=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),c=this.skipBits.bind(this),h=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();var g=o();if(l(5),c(3),o(),f(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var m=u();if(3===m&&c(1),f(),f(),c(1),d())for(e=3!==m?8:12,r=0;r<e;r++)d()&&p(r<6?16:64)}f();var v=u();if(0===v)u();else if(1===v)for(c(1),h(),h(),t=u(),r=0;r<t;r++)h();f(),c(1);var y=u(),E=u(),T=l(1);0===T&&c(1),c(1),d()&&(i=u(),n=u(),s=u(),a=u());var _=[1,1];if(d()&&d())switch(o()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-T)*(E+1)*16-(T?2:4)*(s+a),pixelRatio:_}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}();e.default=n},"./src/demux/id3.ts":
156
156
  /*!**************************!*\
157
157
  !*** ./src/demux/id3.ts ***!
158
158
  \**************************/
159
- /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(e,t,r){r.r(t),r.d(t,"isHeader",(function(){return i})),r.d(t,"isFooter",(function(){return a})),r.d(t,"getID3Data",(function(){return s})),r.d(t,"canParse",(function(){return l})),r.d(t,"getTimeStamp",(function(){return u})),r.d(t,"isTimeStampFrame",(function(){return c})),r.d(t,"getID3Frames",(function(){return f})),r.d(t,"decodeFrame",(function(){return h})),r.d(t,"utf8ArrayToStr",(function(){return y})),r.d(t,"testables",(function(){return E}));var n,i=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},a=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s=function(e,t){for(var r=t,n=0;i(e,t);)n+=10,n+=o(e,t+6),a(e,t+10)&&(n+=10),t+=n;if(n>0)return e.subarray(r,r+n)},o=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},l=function(e,t){return i(e,t)&&o(e,t+6)+10<=e.length-t},u=function(e){for(var t=f(e),r=0;r<t.length;r++){var n=t[r];if(c(n))return m(n)}},c=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},d=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},f=function(e){for(var t=0,r=[];i(e,t);){for(var n=o(e,t+6),s=(t+=10)+n;t+8<s;){var l=d(e.subarray(t)),u=h(l);u&&r.push(u),t+=l.size+10}a(e,t)&&(t+=10)}return r},h=function(e){return"PRIV"===e.type?p(e):"W"===e.type[0]?g(e):v(e)},p=function(e){if(!(e.size<2)){var t=y(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},v=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var n=y(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=y(e.data.subarray(1));return{key:e.type,data:i}}},g=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var n=y(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=y(e.data);return{key:e.type,data:i}},m=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}},y=function(e,t){void 0===t&&(t=!1);var r=_();if(r){var n=r.decode(e);if(t){var i=n.indexOf("\0");return-1!==i?n.substring(0,i):n}return n.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",c=0;c<l;){if(0===(a=e[c++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[c++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[c++],o=e[c++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u},E={decodeTextFrame:v};function _(){return n||void 0===self.TextDecoder||(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":
159
+ /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,e,r){r.r(e),r.d(e,"isHeader",(function(){return n})),r.d(e,"isFooter",(function(){return s})),r.d(e,"getID3Data",(function(){return a})),r.d(e,"canParse",(function(){return l})),r.d(e,"getTimeStamp",(function(){return u})),r.d(e,"isTimeStampFrame",(function(){return d})),r.d(e,"getID3Frames",(function(){return h})),r.d(e,"decodeFrame",(function(){return f})),r.d(e,"utf8ArrayToStr",(function(){return y})),r.d(e,"testables",(function(){return E}));var i,n=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},s=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},a=function(t,e){for(var r=e,i=0;n(t,e);)i+=10,i+=o(t,e+6),s(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},o=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},l=function(t,e){return n(t,e)&&o(t,e+6)+10<=t.length-e},u=function(t){for(var e=h(t),r=0;r<e.length;r++){var i=e[r];if(d(i))return v(i)}},d=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},c=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=o(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},h=function(t){for(var e=0,r=[];n(t,e);){for(var i=o(t,e+6),a=(e+=10)+i;e+8<a;){var l=c(t.subarray(e)),u=f(l);u&&r.push(u),e+=l.size+10}s(t,e)&&(e+=10)}return r},f=function(t){return"PRIV"===t.type?p(t):"W"===t.type[0]?m(t):g(t)},p=function(t){if(!(t.size<2)){var e=y(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}}},g=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data.subarray(1));return{key:t.type,data:n}}},m=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,r=y(t.data.subarray(e),!0);e+=r.length+1;var i=y(t.data.subarray(e));return{key:t.type,info:r,data:i}}var n=y(t.data);return{key:t.type,data:n}},v=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(t,e){void 0===e&&(e=!1);var r=T();if(r){var i=r.decode(t);if(e){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var s,a,o,l=t.length,u="",d=0;d<l;){if(0===(s=t[d++])&&e)return u;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(s);break;case 12:case 13:a=t[d++],u+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[d++],o=t[d++],u+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&o)<<0)}}return u},E={decodeTextFrame:g};function T(){return i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts":
160
160
  /*!*********************************!*\
161
161
  !*** ./src/demux/mp3demuxer.ts ***!
162
162
  \*********************************/
163
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),i=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=n.prototype;return l.resetInitSegment=function(t,r,n){e.prototype.resetInitSegment.call(this,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(e){if(!e)return!1;for(var t=(i.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(s.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(e,t){return s.canParse(e,t)},l.appendFrame=function(e,t,r){if(null!==this.initPTS)return s.appendFrame(e,t,r,this.initPTS,this.frameIndex)},n}(n.default);l.minProbeByteLength=4,t.default=l},"./src/demux/mp4demuxer.ts":
163
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(t){var e,r;function i(){return t.apply(this,arguments)||this}r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,o(e,r);var l=i.prototype;return l.resetInitSegment=function(e,r,i){t.prototype.resetInitSegment.call(this,e,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},i.probe=function(t){if(!t)return!1;for(var e=(n.getID3Data(t,0)||[]).length,r=t.length;e<r;e++)if(a.probe(t,e))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(t,e){return a.canParse(t,e)},l.appendFrame=function(t,e,r){if(null!==this.initPTS)return a.appendFrame(t,e,r,this.initPTS,this.frameIndex)},i}(i.default);l.minProbeByteLength=4,e.default=l},"./src/demux/mp4demuxer.ts":
164
164
  /*!*********************************!*\
165
165
  !*** ./src/demux/mp4demuxer.ts ***!
166
166
  \*********************************/
167
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),i=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=function(){function e(e,t){this.remainderData=null,this.config=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.resetContiguity=function(){},e.probe=function(e){return Object(n.findBox)({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length>0},t.demux=function(e){var t=e,r=Object(i.dummyTrack)();if(this.config.progressive){this.remainderData&&(t=Object(n.appendUint8Array)(this.remainderData,e));var a=Object(n.segmentValidRange)(t);this.remainderData=a.remainder,r.samples=a.valid||new Uint8Array}else r.samples=t;return{audioTrack:Object(i.dummyTrack)(),avcTrack:r,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},t.flush=function(){var e=Object(i.dummyTrack)();return e.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(i.dummyTrack)(),avcTrack:e,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}();a.minProbeByteLength=1024,t.default=a},"./src/demux/mpegaudio.ts":
167
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=function(){function t(t,e){this.remainderData=null,this.config=void 0,this.config=e}var e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(){},e.resetContiguity=function(){},t.probe=function(t){return Object(i.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.demux=function(t){var e=t,r=Object(n.dummyTrack)();if(this.config.progressive){this.remainderData&&(e=Object(i.appendUint8Array)(this.remainderData,t));var s=Object(i.segmentValidRange)(e);this.remainderData=s.remainder,r.samples=s.valid||new Uint8Array}else r.samples=e;return{audioTrack:Object(n.dummyTrack)(),avcTrack:r,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},e.flush=function(){var t=Object(n.dummyTrack)();return t.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(n.dummyTrack)(),avcTrack:t,id3Track:Object(n.dummyTrack)(),textTrack:Object(n.dummyTrack)()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}();s.minProbeByteLength=1024,e.default=s},"./src/demux/mpegaudio.ts":
168
168
  /*!********************************!*\
169
169
  !*** ./src/demux/mpegaudio.ts ***!
170
170
  \********************************/
171
- /*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(e,t,r){r.r(t),r.d(t,"appendFrame",(function(){return l})),r.d(t,"parseHeader",(function(){return u})),r.d(t,"isHeaderPattern",(function(){return c})),r.d(t,"isHeader",(function(){return d})),r.d(t,"canParse",(function(){return f})),r.d(t,"probe",(function(){return h}));var n=null,i=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t,r,n,i){if(!(r+24>t.length)){var a=u(t,r);if(a&&r+a.frameLength<=t.length){var s=n+i*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength}}}}function u(e,t){var r=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,c=e[t+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==c){var d=e[t+2]>>1&1,f=e[t+3]>>6,h=1e3*i[14*(3===r?3-l:3===l?3:4)+u-1],p=a[3*(3===r?0:2===r?1:2)+c],v=3===f?1:2,g=s[r][l],m=o[l],y=8*g*m,E=Math.floor(g*h/p+d)*m;if(null===n){var _=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);n=_?parseInt(_[1]):0}return!!n&&n<=87&&2===l&&h>=224e3&&0===f&&(e[t+3]=128|e[t+3]),{sampleRate:p,channelCount:v,frameLength:E,samplesPerFrame:y}}}function c(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function d(e,t){return t+1<e.length&&c(e,t)}function f(e,t){return c(e,t)&&4<=e.length-t}function h(e,t){if(t+1<e.length&&c(e,t)){var r=u(e,t),n=4;null!=r&&r.frameLength&&(n=r.frameLength);var i=t+n;return i===e.length||d(e,i)}return!1}},"./src/demux/sample-aes.ts":
171
+ /*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,e,r){r.r(e),r.d(e,"appendFrame",(function(){return l})),r.d(e,"parseHeader",(function(){return u})),r.d(e,"isHeaderPattern",(function(){return d})),r.d(e,"isHeader",(function(){return c})),r.d(e,"canParse",(function(){return h})),r.d(e,"probe",(function(){return f}));var i=null,n=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(t,e,r,i,n){if(!(r+24>e.length)){var s=u(e,r);if(s&&r+s.frameLength<=e.length){var a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(r,r+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength}}}}function u(t,e){var r=t[e+1]>>3&3,l=t[e+1]>>1&3,u=t[e+2]>>4&15,d=t[e+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==d){var c=t[e+2]>>1&1,h=t[e+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+u-1],p=s[3*(3===r?0:2===r?1:2)+d],g=3===h?1:2,m=a[r][l],v=o[l],y=8*m*v,E=Math.floor(m*f/p+c)*v;if(null===i){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=T?parseInt(T[1]):0}return!!i&&i<=87&&2===l&&f>=224e3&&0===h&&(t[e+3]=128|t[e+3]),{sampleRate:p,channelCount:g,frameLength:E,samplesPerFrame:y}}}function d(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function c(t,e){return e+1<t.length&&d(t,e)}function h(t,e){return d(t,e)&&4<=t.length-e}function f(t,e){if(e+1<t.length&&d(t,e)){var r=u(t,e),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=e+i;return n===t.length||c(t,n)}return!1}},"./src/demux/sample-aes.ts":
172
172
  /*!*********************************!*\
173
173
  !*** ./src/demux/sample-aes.ts ***!
174
174
  \*********************************/
175
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),i=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),a=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new n.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,t)},t.decryptAacSample=function(e,t,r,n){var i=e[t].unit,a=i.subarray(16,i.length-i.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(s,(function(a){var s=new Uint8Array(a);i.set(s,16),n||o.decryptAacSamples(e,t+1,r)}))},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var n=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,n),!n)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,i=32;i<=e.length-16;i+=160,n+=16)r.set(e.subarray(i,i+16),n);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),n=0,i=32;i<=e.length-16;i+=160,n+=16)e.set(r.subarray(n,n+16),i);return e},t.decryptAvcSample=function(e,t,r,n,a,s){var o=Object(i.discardEPB)(a.data),l=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(l.buffer,(function(i){a.data=u.getAvcDecryptedUnit(o,i),s||u.decryptAvcSamples(e,t,r+1,n)}))},t.decryptAvcSamples=function(e,t,r,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void n();for(var i=e[t].units;!(r>=i.length);r++){var a=i[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,n,a,s),!s)return}}}},e}();t.default=a},"./src/demux/transmuxer-interface.ts":
175
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),s=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(t,e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t,e){this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,e)},e.decryptAacSample=function(t,e,r,i){var n=t[e].unit,s=n.subarray(16,n.length-n.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length),o=this;this.decryptBuffer(a,(function(s){var a=new Uint8Array(s);n.set(a,16),i||o.decryptAacSamples(t,e+1,r)}))},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(t,e,r,i),!i)return}}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n<=t.length-16;n+=160,i+=16)r.set(t.subarray(n,n+16),i);return r},e.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,n=32;n<=t.length-16;n+=160,i+=16)t.set(r.subarray(i,i+16),n);return t},e.decryptAvcSample=function(t,e,r,i,s,a){var o=Object(n.discardEPB)(s.data),l=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(l.buffer,(function(n){s.data=u.getAvcDecryptedUnit(o,n),a||u.decryptAvcSamples(t,e,r+1,i)}))},e.decryptAvcSamples=function(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(t,e,r,i,s,a),!a)return}}}},t}();e.default=s},"./src/demux/transmuxer-interface.ts":
176
176
  /*!*******************************************!*\
177
177
  !*** ./src/demux/transmuxer-interface.ts ***!
178
178
  \*******************************************/
179
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return d}));var n=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},d=function(){function e(e,t,r,l){var d=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=e,this.id=t,this.onTransmuxComplete=r,this.onFlush=l;var f=e.config,h=function(t,r){(r=r||{}).frag=d.frag,r.id=d.id,e.trigger(t,r)};this.observer=new u.EventEmitter,this.observer.on(i.Events.FRAG_DECRYPTED,h),this.observer.on(i.Events.ERROR,h);var p={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},v=navigator.vendor;if(f.enableWorker&&"undefined"!=typeof Worker){var g;s.logger.log("demuxing in webworker");try{g=this.worker=n(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(t){e.trigger(i.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(t.message+" ("+t.filename+":"+t.lineno+")")})},g.postMessage({cmd:"init",typeSupported:p,vendor:v,id:t,config:JSON.stringify(f)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new a.default(this.observer,p,f,v),this.worker=null}}else this.transmuxer=new a.default(this.observer,p,f,v)}var t=e.prototype;return t.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.observer=null},t.push=function(e,t,r,n,i,o,l,u,c,d){var f=this;c.transmuxing.start=self.performance.now();var h=this.transmuxer,p=this.worker,v=o?o.start:i.start,g=i.decryptdata,m=this.frag,y=!(m&&i.cc===m.cc),E=!(m&&c.level===m.level),_=m?c.sn-m.sn:-1,T=this.part?c.part-this.part.index:1,b=!E&&(1===_||0===_&&1===T),A=self.performance.now();(E||_||0===i.stats.parsing.start)&&(i.stats.parsing.start=A),!o||!T&&b||(o.stats.parsing.start=A);var S=new a.TransmuxState(y,b,u,E,v);if(!b||y){s.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+y+"\n trackSwitch: "+E+"\n contiguous: "+b+"\n accurateTimeOffset: "+u+"\n timeOffset: "+v);var w=new a.TransmuxConfig(r,n,t,l,d);this.configureTransmuxer(w)}if(this.frag=i,this.part=o,p)p.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:c,state:S},e instanceof ArrayBuffer?[e]:[]);else if(h){var L=h.push(e,g,c,S);Object(a.isPromise)(L)?L.then((function(e){f.handleTransmuxComplete(e)})):this.handleTransmuxComplete(L)}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);Object(a.isPromise)(i)?i.then((function(r){t.handleFlushResult(r,e)})):this.handleFlushResult(i,e)}},t.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}()},"./src/demux/transmuxer-worker.ts":
179
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return c}));var i=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),d=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},c=function(){function t(t,e,r,l){var c=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=t,this.id=e,this.onTransmuxComplete=r,this.onFlush=l;var h=t.config,f=function(e,r){(r=r||{}).frag=c.frag,r.id=c.id,t.trigger(e,r)};this.observer=new u.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var p={mp4:d.isTypeSupported("video/mp4"),mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(h.enableWorker&&"undefined"!=typeof Worker){var m;a.logger.log("demuxing in webworker");try{m=this.worker=i(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),m.addEventListener("message",this.onwmsg),m.onerror=function(e){t.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},m.postMessage({cmd:"init",typeSupported:p,vendor:g,id:e,config:JSON.stringify(h)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),m&&self.URL.revokeObjectURL(m.objectURL),this.transmuxer=new s.default(this.observer,p,h,g),this.worker=null}}else this.transmuxer=new s.default(this.observer,p,h,g)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.observer=null},e.push=function(t,e,r,i,n,o,l,u,d,c){var h=this;d.transmuxing.start=self.performance.now();var f=this.transmuxer,p=this.worker,g=o?o.start:n.start,m=n.decryptdata,v=this.frag,y=!(v&&n.cc===v.cc),E=!(v&&d.level===v.level),T=v?d.sn-v.sn:-1,_=this.part?d.part-this.part.index:1,b=!E&&(1===T||0===T&&1===_),S=self.performance.now();(E||T||0===n.stats.parsing.start)&&(n.stats.parsing.start=S),!o||!_&&b||(o.stats.parsing.start=S);var A=new s.TransmuxState(y,b,u,E,g);if(!b||y){a.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+"\n discontinuity: "+y+"\n trackSwitch: "+E+"\n contiguous: "+b+"\n accurateTimeOffset: "+u+"\n timeOffset: "+g);var L=new s.TransmuxConfig(r,i,e,l,c);this.configureTransmuxer(L)}if(this.frag=n,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:m,chunkMeta:d,state:A},t instanceof ArrayBuffer?[t]:[]);else if(f){var w=f.push(t,m,d,A);Object(s.isPromise)(w)?w.then((function(t){h.handleTransmuxComplete(t)})):this.handleTransmuxComplete(w)}},e.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:t});else if(r){var n=r.flush(t);Object(s.isPromise)(n)?n.then((function(r){e.handleFlushResult(r,t)})):this.handleFlushResult(n,t)}},e.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},e.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},e.configureTransmuxer=function(t){var e=this.worker,r=this.transmuxer;e?e.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},e.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
180
180
  /*!****************************************!*\
181
181
  !*** ./src/demux/transmuxer-worker.ts ***!
182
182
  \****************************************/
183
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return o}));var n=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(e){var t=new s.EventEmitter,r=function(t,r){e.postMessage({event:t,data:r})};t.on(i.Events.FRAG_DECRYPTED,r),t.on(i.Events.ERROR,r),e.addEventListener("message",(function(i){var s=i.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.transmuxer=new n.default(t,s.typeSupported,o,s.vendor),Object(a.enableLogs)(o.debug),r("init",null);break;case"configure":e.transmuxer.configure(s.config);break;case"demux":var u=e.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(n.isPromise)(u)?u.then((function(t){l(e,t)})):l(e,u);break;case"flush":var d=s.chunkMeta,f=e.transmuxer.flush(d);Object(n.isPromise)(f)?f.then((function(t){c(e,t,d)})):c(e,f,d)}}))}function l(e,t){if((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment){var r,n=[],i=t.remuxResult,a=i.audio,s=i.video;a&&u(n,a),s&&u(n,s),e.postMessage({event:"transmuxComplete",data:t},n)}}function u(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(e,t,r){t.forEach((function(t){l(e,t)})),e.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
183
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return o}));var i=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(t){var e=new a.EventEmitter,r=function(e,r){t.postMessage({event:e,data:r})};e.on(n.Events.FRAG_DECRYPTED,r),e.on(n.Events.ERROR,r),t.addEventListener("message",(function(n){var a=n.data;switch(a.cmd){case"init":var o=JSON.parse(a.config);t.transmuxer=new i.default(e,a.typeSupported,o,a.vendor),Object(s.enableLogs)(o.debug),r("init",null);break;case"configure":t.transmuxer.configure(a.config);break;case"demux":var u=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(i.isPromise)(u)?u.then((function(e){l(t,e)})):l(t,u);break;case"flush":var c=a.chunkMeta,h=t.transmuxer.flush(c);Object(i.isPromise)(h)?h.then((function(e){d(t,e,c)})):d(t,h,c)}}))}function l(t,e){if((r=e.remuxResult).audio||r.video||r.text||r.id3||r.initSegment){var r,i=[],n=e.remuxResult,s=n.audio,a=n.video;s&&u(i,s),a&&u(i,a),t.postMessage({event:"transmuxComplete",data:e},i)}}function u(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function d(t,e,r){e.forEach((function(e){l(t,e)})),t.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
184
184
  /*!*********************************!*\
185
185
  !*** ./src/demux/transmuxer.ts ***!
186
186
  \*********************************/
187
- /*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(e,t,r){r.r(t),r.d(t,"default",(function(){return y})),r.d(t,"isPromise",(function(){return _})),r.d(t,"TransmuxConfig",(function(){return T})),r.d(t,"TransmuxState",(function(){return b}));var n,i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),d=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),f=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),h=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),p=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),v=r(/*! ../utils/logger */"./src/utils/logger.ts");try{n=self.performance.now.bind(self.performance)}catch(e){v.logger.debug("Unable to use Performance API on this environment"),n=self.Date.now}var g=[{demux:u.default,remux:d.default},{demux:l.default,remux:f.default},{demux:o.default,remux:d.default},{demux:c.default,remux:d.default}],m=1024;g.forEach((function(e){var t=e.demux;m=Math.max(m,t.minProbeByteLength)}));var y=function(){function e(e,t,r,n){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new h.default,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var a=this,s=r.transmuxing;s.executeStart=n();var o=new Uint8Array(e),l=this.cache,u=this.config,c=this.currentTransmuxState,d=this.transmuxConfig;i&&(this.currentTransmuxState=i);var f=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(f&&"AES-128"===f.method){var h=this.getDecrypter();if(!u.enableSoftwareAES)return this.decryptionPromise=h.webCryptoDecrypt(o,f.key.buffer,f.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var v=h.softwareDecrypt(o,f.key.buffer,f.iv.buffer);if(!v)return s.executeEnd=n(),E(r);o=new Uint8Array(v)}var g=i||c,m=g.contiguous,y=g.discontinuity,_=g.trackSwitch,T=g.accurateTimeOffset,b=g.timeOffset,A=d.audioCodec,S=d.videoCodec,w=d.defaultInitPts,L=d.duration,k=d.initSegmentData;if((y||_)&&this.resetInitSegment(k,A,S,L),y&&this.resetInitialTimestamp(w),m||this.resetContiguity(),this.needsProbing(o,y,_)){if(l.dataLength){var R=l.flush();o=Object(p.appendUint8Array)(R,o)}this.configureTransmuxer(o,d)}var D=this.transmux(o,f,b,T,r),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,s.executeEnd=n(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=n();var s=this.decrypter,o=this.cache,l=this.currentTransmuxState,u=this.decryptionPromise;if(u)return u.then((function(){return t.flush(e)}));var c=[],d=l.timeOffset;if(s){var f=s.flush();f&&c.push(this.push(f,null,e))}var h=o.dataLength;o.reset();var p=this.demuxer,v=this.remuxer;if(!p||!v)return h>=m&&this.observer.emit(i.Events.ERROR,i.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=n(),[E(e)];var g=p.flush(d);return _(g)?g.then((function(r){return t.flushRemux(c,r,e),c})):(this.flushRemux(c,g,e),c)},t.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.avcTrack,s=t.id3Track,o=t.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,c=l.timeOffset;v.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,a,s,o,c,u,!0);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=n()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,n){var i=this.demuxer,a=this.remuxer;i&&a&&(i.resetInitSegment(t,r,n),a.resetInitSegment(e,t,r))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,n,i){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,n,i):this.transmuxUnencrypted(e,r,n,i)},t.transmuxUnencrypted=function(e,t,r,n){var i=this.demuxer.demux(e,t,!1,!this.config.progressive),a=i.audioTrack,s=i.avcTrack,o=i.id3Track,l=i.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1),chunkMeta:n}},t.transmuxSampleAes=function(e,t,r,n,i){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.avcTrack,e.id3Track,e.textTrack,r,n,!1),chunkMeta:i}}))},t.configureTransmuxer=function(e,t){for(var r,n=this.config,i=this.observer,a=this.typeSupported,s=this.vendor,o=t.audioCodec,u=t.defaultInitPts,c=t.duration,d=t.initSegmentData,h=t.videoCodec,p=0,m=g.length;p<m;p++)if(g[p].demux.probe(e)){r=g[p];break}r||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:f.default});var y=this.demuxer,E=this.remuxer,_=r.remux,T=r.demux;E&&E instanceof _||(this.remuxer=new _(i,n,a,s)),y&&y instanceof T||(this.demuxer=new T(i,n,a),this.probe=T.probe),this.resetInitSegment(d,o,h,c),this.resetInitialTimestamp(u)},t.needsProbing=function(e,t,r){return!this.demuxer||!this.remuxer||t||r},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new s.default(this.observer,this.config)),e},e}(),E=function(e){return{remuxResult:{},chunkMeta:e}};function _(e){return"then"in e&&e.then instanceof Function}var T=function(e,t,r,n,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=n,this.defaultInitPts=i},b=function(e,t,r,n,i){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=i}},"./src/demux/tsdemuxer.ts":
187
+ /*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,r){r.r(e),r.d(e,"default",(function(){return y})),r.d(e,"isPromise",(function(){return T})),r.d(e,"TransmuxConfig",(function(){return _})),r.d(e,"TransmuxState",(function(){return b}));var i,n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),d=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),c=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),p=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),g=r(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(t){g.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var m=[{demux:u.default,remux:c.default},{demux:l.default,remux:h.default},{demux:o.default,remux:c.default},{demux:d.default,remux:c.default}],v=1024;m.forEach((function(t){var e=t.demux;v=Math.max(v,e.minProbeByteLength)}));var y=function(){function t(t,e,r,i){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new f.default,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,n){var s=this,a=r.transmuxing;a.executeStart=i();var o=new Uint8Array(t),l=this.cache,u=this.config,d=this.currentTransmuxState,c=this.transmuxConfig;n&&(this.currentTransmuxState=n);var h=function(t,e){var r=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e),r}(o,e);if(h&&"AES-128"===h.method){var f=this.getDecrypter();if(!u.enableSoftwareAES)return this.decryptionPromise=f.webCryptoDecrypt(o,h.key.buffer,h.iv.buffer).then((function(t){var e=s.push(t,null,r);return s.decryptionPromise=null,e})),this.decryptionPromise;var g=f.softwareDecrypt(o,h.key.buffer,h.iv.buffer);if(!g)return a.executeEnd=i(),E(r);o=new Uint8Array(g)}var m=n||d,v=m.contiguous,y=m.discontinuity,T=m.trackSwitch,_=m.accurateTimeOffset,b=m.timeOffset,S=c.audioCodec,A=c.videoCodec,L=c.defaultInitPts,w=c.duration,k=c.initSegmentData;if((y||T)&&this.resetInitSegment(k,S,A,w),y&&this.resetInitialTimestamp(L),v||this.resetContiguity(),this.needsProbing(o,y,T)){if(l.dataLength){var R=l.flush();o=Object(p.appendUint8Array)(R,o)}this.configureTransmuxer(o,c)}var D=this.transmux(o,h,b,_,r),O=this.currentTransmuxState;return O.contiguous=!0,O.discontinuity=!1,O.trackSwitch=!1,a.executeEnd=i(),D},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=i();var a=this.decrypter,o=this.cache,l=this.currentTransmuxState,u=this.decryptionPromise;if(u)return u.then((function(){return e.flush(t)}));var d=[],c=l.timeOffset;if(a){var h=a.flush();h&&d.push(this.push(h,null,t))}var f=o.dataLength;o.reset();var p=this.demuxer,g=this.remuxer;if(!p||!g)return f>=v&&this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[E(t)];var m=p.flush(c);return T(m)?m.then((function(r){return e.flushRemux(d,r,t),d})):(this.flushRemux(d,m,t),d)},e.flushRemux=function(t,e,r){var n=e.audioTrack,s=e.avcTrack,a=e.id3Track,o=e.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,d=l.timeOffset;g.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(n,s,a,o,d,u,!0);t.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=i()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(e,r,i),s.resetInitSegment(t,e,r))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},e.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),s=n.audioTrack,a=n.avcTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(s,a,o,l,e,r,!1),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,n){var s=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,r,i,!1),chunkMeta:n}}))},e.configureTransmuxer=function(t,e){for(var r,i=this.config,n=this.observer,s=this.typeSupported,a=this.vendor,o=e.audioCodec,u=e.defaultInitPts,d=e.duration,c=e.initSegmentData,f=e.videoCodec,p=0,v=m.length;p<v;p++)if(m[p].demux.probe(t)){r=m[p];break}r||(g.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:h.default});var y=this.demuxer,E=this.remuxer,T=r.remux,_=r.demux;E&&E instanceof T||(this.remuxer=new T(n,i,s,a)),y&&y instanceof _||(this.demuxer=new _(n,i,s),this.probe=_.probe),this.resetInitSegment(c,o,f,d),this.resetInitialTimestamp(u)},e.needsProbing=function(t,e,r){return!this.demuxer||!this.remuxer||e||r},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.observer,this.config)),t},t}(),E=function(t){return{remuxResult:{},chunkMeta:t}};function T(t){return"then"in t&&t.then instanceof Function}var _=function(t,e,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},b=function(t,e,r,i,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n}},"./src/demux/tsdemuxer.ts":
188
188
  /*!********************************!*\
189
189
  !*** ./src/demux/tsdemuxer.ts ***!
190
190
  \********************************/
191
- /*! exports provided: discardEPB, default */function(e,t,r){r.r(t),r.d(t,"discardEPB",(function(){return _}));var n=r(/*! ./adts */"./src/demux/adts.ts"),i=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),a=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),s=r(/*! ./id3 */"./src/demux/id3.ts"),o=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../errors */"./src/errors.ts"),f={video:1,audio:2,id3:3,text:4},h=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return!(r<0||(r&&c.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},e.syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:f[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",n),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3",n),this._txtTrack=e.createTrack("text",n),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},t.demux=function(t,r,n,i){var a;void 0===n&&(n=!1),void 0===i&&(i=!1),n||(this.sampleAes=null);var s=this._avcTrack,o=this._audioTrack,f=this._id3Track,h=s.pid,p=s.pesData,y=o.pid,E=f.pid,_=o.pesData,T=f.pesData,b=!1,A=this.pmtParsed,S=this._pmtId,w=t.length;if(this.remainderData&&(w=(t=Object(u.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),w<188&&!i)return this.remainderData=t,{audioTrack:o,avcTrack:s,id3Track:f,textTrack:this._txtTrack};var L=Math.max(0,e.syncOffset(t));(w-=(w+L)%188)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,w,t.buffer.byteLength-w));for(var k=L;k<w;k+=188)if(71===t[k]){var R=!!(64&t[k+1]),D=((31&t[k+1])<<8)+t[k+2],O=void 0;if((48&t[k+3])>>4>1){if((O=k+5+t[k+4])===k+188)continue}else O=k+4;switch(D){case h:R&&(p&&(a=m(p))&&this.parseAVCPES(a,!1),p={data:[],size:0}),p&&(p.data.push(t.subarray(O,k+188)),p.size+=k+188-O);break;case y:R&&(_&&(a=m(_))&&(o.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),_={data:[],size:0}),_&&(_.data.push(t.subarray(O,k+188)),_.size+=k+188-O);break;case E:R&&(T&&(a=m(T))&&this.parseID3PES(a),T={data:[],size:0}),T&&(T.data.push(t.subarray(O,k+188)),T.size+=k+188-O);break;case 0:R&&(O+=t[O]+1),S=this._pmtId=v(t,O);break;case S:R&&(O+=t[O]+1);var C=g(t,O,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,n);(h=C.avc)>0&&(s.pid=h),(y=C.audio)>0&&(o.pid=y,o.isAAC=C.isAAC),(E=C.id3)>0&&(f.pid=E),b&&!A&&(c.logger.log("reparse from beginning"),b=!1,k=L-188),A=this.pmtParsed=!0;break;case 17:case 8191:break;default:b=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});s.pesData=p,o.pesData=_,f.pesData=T;var I={audioTrack:o,avcTrack:s,id3Track:f,textTrack:this._txtTrack};return i&&this.extractRemainingSamples(I),I},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,n=e.avcTrack,i=e.id3Track,a=n.pesData,s=r.pesData,o=i.pesData;a&&(t=m(a))?(this.parseAVCPES(t,!0),n.pesData=null):n.pesData=a,s&&(t=m(s))?(r.isAAC?this.parseAACPES(t):this.parseMPEGPES(t),r.pesData=null):(null!=s&&s.size&&c.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=s),o&&(t=m(o))?(this.parseID3PES(t),i.pesData=null):i.pesData=o},t.demuxSampleAes=function(e,t,r){var n=this.demux(e,r,!0,!this.config.progressive),i=this.sampleAes=new o.default(this.observer,this.config,t);return this.decrypt(n,i)},t.decrypt=function(e,t){return new Promise((function(r){var n=e.audioTrack,i=e.avcTrack;n.samples&&n.isAAC?t.decryptAacSamples(n.samples,0,(function(){i.samples?t.decryptAvcSamples(i.samples,0,0,(function(){r(e)})):r(e)})):i.samples&&t.decryptAvcSamples(i.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},t.parseAVCPES=function(e,t){var r,n=this,i=this._avcTrack,o=this.parseAVCNALu(e.data),l=this.avcSample,u=!1;e.data=null,l&&o.length&&!i.audFound&&(y(l,i),l=this.avcSample=p(!1,e.pts,e.dts,"")),o.forEach((function(t){switch(t.type){case 1:r=!0,l||(l=n.avcSample=p(!0,e.pts,e.dts,"")),l.frame=!0;var o=t.data;if(u&&o.length>4){var c=new a.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(l.key=!0)}break;case 5:r=!0,l||(l=n.avcSample=p(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:r=!0;var d=new a.default(_(t.data));d.readUByte();for(var f=0,h=0,v=!1,g=0;!v&&d.bytesAvailable>1;){f=0;do{f+=g=d.readUByte()}while(255===g);h=0;do{h+=g=d.readUByte()}while(255===g);if(4===f&&0!==d.bytesAvailable){if(v=!0,181===d.readUByte()&&49===d.readUShort()&&1195456820===d.readUInt()&&3===d.readUByte()){for(var m=d.readUByte(),T=31&m,b=[m,d.readUByte()],A=0;A<T;A++)b.push(d.readUByte()),b.push(d.readUByte()),b.push(d.readUByte());E(n._txtTrack.samples,{type:3,pts:e.pts,bytes:b})}}else if(5===f&&0!==d.bytesAvailable){if(v=!0,h>16){for(var S=[],w=0;w<16;w++)S.push(d.readUByte().toString(16)),3!==w&&5!==w&&7!==w&&9!==w||S.push("-");for(var L=h-16,k=new Uint8Array(L),R=0;R<L;R++)k[R]=d.readUByte();E(n._txtTrack.samples,{pts:e.pts,payloadType:f,uuid:S.join(""),userData:Object(s.utf8ArrayToStr)(k),userDataBytes:k})}}else if(h<d.bytesAvailable)for(var D=0;D<h;D++)d.readUByte()}break;case 7:if(r=!0,u=!0,!i.sps){var O=new a.default(t.data).readSPS();i.width=O.width,i.height=O.height,i.pixelRatio=O.pixelRatio,i.sps=[t.data],i.duration=n._duration;for(var C=t.data.subarray(1,4),I="avc1.",x=0;x<3;x++){var P=C[x].toString(16);P.length<2&&(P="0"+P),I+=P}i.codec=I}break;case 8:r=!0,i.pps||(i.pps=[t.data]);break;case 9:r=!1,i.audFound=!0,l&&y(l,i),l=n.avcSample=p(!1,e.pts,e.dts,"");break;case 12:r=!1;break;default:r=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}l&&r&&l.units.push(t)})),t&&l&&(y(l,i),this.avcSample=null)},t.getLastNalUnit=function(){var e,t,r=this.avcSample;if(!r||0===r.units.length){var n=this._avcTrack.samples;r=n[n.length-1]}if(null!==(e=r)&&void 0!==e&&e.units){var i=r.units;t=i[i.length-1]}return t},t.parseAVCNALu=function(e){var t,r,n=e.byteLength,i=this._avcTrack,a=i.naluState||0,s=a,o=[],l=0,u=-1,c=0;for(-1===a&&(u=0,c=31&e[0],a=0,l=1);l<n;)if(t=e[l++],a)if(1!==a)if(t)if(1===t){if(u>=0){var d={data:e.subarray(u,l-a-1),type:c};o.push(d)}else{var f=this.getLastNalUnit();if(f&&(s&&l<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),(r=l-a-1)>0)){var h=new Uint8Array(f.data.byteLength+r);h.set(f.data,0),h.set(e.subarray(0,r),f.data.byteLength),f.data=h}}l<n?(u=l,c=31&e[l],a=0):a=-1}else a=0;else a=3;else a=t?0:2;else a=t?0:1;if(u>=0&&a>=0){var p={data:e.subarray(u,n),type:c,state:a};o.push(p)}if(0===o.length){var v=this.getLastNalUnit();if(v){var g=new Uint8Array(v.data.byteLength+e.byteLength);g.set(v.data,0),g.set(e,v.data.byteLength),v.data=g}}return i.naluState=a,o},t.parseAACPES=function(e){var t,r,i,a,s=this._audioTrack,o=this.aacLastPTS,u=this.aacOverFlow,f=e.data;if(u){var h=new Uint8Array(u.byteLength+f.byteLength);h.set(u,0),h.set(f,u.byteLength),f=h}for(t=0,r=f.length;t<r-1&&!n.isHeader(f,t);t++);if(!t||(t<r-1?(i="AAC PES did not start with ADTS header,offset:"+t,a=!1):(i="no ADTS header found in AAC PES",a=!0),c.logger.warn("parsing error:"+i),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:i}),!a)){n.initTrackConfig(s,this.observer,f,t,this.audioCodec);var p,v=0,g=n.getFrameDuration(s.samplerate);if(void 0!==e.pts)p=e.pts;else{if(null===o)return void c.logger.warn("[tsdemuxer]: AAC PES unknown PTS");p=o}if(u&&null!==o){var m=o+g;Math.abs(m-p)>1&&(c.logger.log("[tsdemuxer]: AAC: align PTS for overlapping frames by "+Math.round((m-p)/90)),p=m)}for(var y=null;t<r;){if(n.isHeader(f,t)){if(t+5<r){var E=n.appendFrame(s,f,t,p,v);if(E){t+=E.length,y=E.sample.pts,v++;continue}}break}t++}this.aacOverFlow=t<r?f.subarray(t,r):null,this.aacLastPTS=y}},t.parseMPEGPES=function(e){var t=e.data,r=t.length,n=0,a=0,s=e.pts;if(void 0!==s)for(;a<r;)if(i.isHeader(t,a)){var o=i.appendFrame(this._audioTrack,t,a,s,n);if(!o)break;a+=o.length,n++}else a++;else c.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e){void 0!==e.pts?this._id3Track.samples.push(e):c.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function p(e,t,r,n){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:n,length:0}}function v(e,t){return(31&e[t+10])<<8|e[t+11]}function g(e,t,r,n){var i={audio:-1,avc:-1,id3:-1,isAAC:!0},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var s=(31&e[t+1])<<8|e[t+2];switch(e[t]){case 207:if(!n){c.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===i.audio&&(i.audio=s);break;case 21:-1===i.id3&&(i.id3=s);break;case 219:if(!n){c.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===i.avc&&(i.avc=s);break;case 3:case 4:r?-1===i.audio&&(i.audio=s,i.isAAC=!1):c.logger.log("MPEG audio found, not supported in this browser");break;case 36:c.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return i}function m(e){var t,r,n,i,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var u=t[7];192&u&&(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&u?i-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(c.logger.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i);var d=(n=t[8])+9;if(e.size<=d)return null;e.size-=d;for(var f=new Uint8Array(e.size),h=0,p=o.length;h<p;h++){var v=(t=o[h]).byteLength;if(d){if(d>v){d-=v;continue}t=t.subarray(d),v-=d,d=0}f.set(t,s),s+=v}return r&&(r-=n+3),{data:f,pts:i,dts:a,len:r}}return null}function y(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,n=r.length;if(!n)return void t.dropped++;var i=r[n-1];e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}e.debug.length&&c.logger.log(e.pts+"/"+e.dts+":"+e.debug)}function E(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var n=r-1;n>=0;n--)if(t.pts<e[n].pts){e.splice(n,0,t);break}}else e.push(t)}function _(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(0===r.length)return e;var i=t-r.length,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}h.minProbeByteLength=188,t.default=h},"./src/errors.ts":
191
+ /*! exports provided: discardEPB, default */function(t,e,r){r.r(e),r.d(e,"discardEPB",(function(){return T}));var i=r(/*! ./adts */"./src/demux/adts.ts"),n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=r(/*! ./id3 */"./src/demux/id3.ts"),o=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../errors */"./src/errors.ts"),h={video:1,audio:2,id3:3,text:4},f=function(){function t(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return!(r<0||(r&&d.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},t.syncOffset=function(t){for(var e=Math.min(1e3,t.length-564),r=0;r<e;){if(71===t[r]&&71===t[r+188]&&71===t[r+376])return r;r++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:h[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",i),this._audioTrack=t.createTrack("audio",i),this._id3Track=t.createTrack("id3",i),this._txtTrack=t.createTrack("text",i),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=e,this.videoCodec=r,this._duration=i},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},e.demux=function(e,r,i,n){var s;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,h=this._id3Track,f=a.pid,p=a.pesData,y=o.pid,E=h.pid,T=o.pesData,_=h.pesData,b=!1,S=this.pmtParsed,A=this._pmtId,L=e.length;if(this.remainderData&&(L=(e=Object(u.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),L<188&&!n)return this.remainderData=e,{audioTrack:o,avcTrack:a,id3Track:h,textTrack:this._txtTrack};var w=Math.max(0,t.syncOffset(e));(L-=(L+w)%188)<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));for(var k=w;k<L;k+=188)if(71===e[k]){var R=!!(64&e[k+1]),D=((31&e[k+1])<<8)+e[k+2],O=void 0;if((48&e[k+3])>>4>1){if((O=k+5+e[k+4])===k+188)continue}else O=k+4;switch(D){case f:R&&(p&&(s=v(p))&&this.parseAVCPES(s,!1),p={data:[],size:0}),p&&(p.data.push(e.subarray(O,k+188)),p.size+=k+188-O);break;case y:R&&(T&&(s=v(T))&&(o.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),T={data:[],size:0}),T&&(T.data.push(e.subarray(O,k+188)),T.size+=k+188-O);break;case E:R&&(_&&(s=v(_))&&this.parseID3PES(s),_={data:[],size:0}),_&&(_.data.push(e.subarray(O,k+188)),_.size+=k+188-O);break;case 0:R&&(O+=e[O]+1),A=this._pmtId=g(e,O);break;case A:R&&(O+=e[O]+1);var I=m(e,O,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,i);(f=I.avc)>0&&(a.pid=f),(y=I.audio)>0&&(o.pid=y,o.isAAC=I.isAAC),(E=I.id3)>0&&(h.pid=E),b&&!S&&(d.logger.log("reparse from beginning"),b=!1,k=w-188),S=this.pmtParsed=!0;break;case 17:case 8191:break;default:b=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});a.pesData=p,o.pesData=T,h.pesData=_;var C={audioTrack:o,avcTrack:a,id3Track:h,textTrack:this._txtTrack};return n&&this.extractRemainingSamples(C),C},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.avcTrack,n=t.id3Track,s=i.pesData,a=r.pesData,o=n.pesData;s&&(e=v(s))?(this.parseAVCPES(e,!0),i.pesData=null):i.pesData=s,a&&(e=v(a))?(r.isAAC?this.parseAACPES(e):this.parseMPEGPES(e),r.pesData=null):(null!=a&&a.size&&d.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=a),o&&(e=v(o))?(this.parseID3PES(e),n.pesData=null):n.pesData=o},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new o.default(this.observer,this.config,e);return this.decrypt(i,n)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,n=t.avcTrack;i.samples&&i.isAAC?e.decryptAacSamples(i.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){r(t)})):r(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},e.parseAVCPES=function(t,e){var r,i=this,n=this._avcTrack,o=this.parseAVCNALu(t.data),l=this.avcSample,u=!1;t.data=null,l&&o.length&&!n.audFound&&(y(l,n),l=this.avcSample=p(!1,t.pts,t.dts,"")),o.forEach((function(e){switch(e.type){case 1:r=!0,l||(l=i.avcSample=p(!0,t.pts,t.dts,"")),l.frame=!0;var o=e.data;if(u&&o.length>4){var d=new s.default(o).readSliceType();2!==d&&4!==d&&7!==d&&9!==d||(l.key=!0)}break;case 5:r=!0,l||(l=i.avcSample=p(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:r=!0;var c=new s.default(T(e.data));c.readUByte();for(var h=0,f=0,g=!1,m=0;!g&&c.bytesAvailable>1;){h=0;do{h+=m=c.readUByte()}while(255===m);f=0;do{f+=m=c.readUByte()}while(255===m);if(4===h&&0!==c.bytesAvailable){if(g=!0,181===c.readUByte()&&49===c.readUShort()&&1195456820===c.readUInt()&&3===c.readUByte()){for(var v=c.readUByte(),_=31&v,b=[v,c.readUByte()],S=0;S<_;S++)b.push(c.readUByte()),b.push(c.readUByte()),b.push(c.readUByte());E(i._txtTrack.samples,{type:3,pts:t.pts,bytes:b})}}else if(5===h&&0!==c.bytesAvailable){if(g=!0,f>16){for(var A=[],L=0;L<16;L++)A.push(c.readUByte().toString(16)),3!==L&&5!==L&&7!==L&&9!==L||A.push("-");for(var w=f-16,k=new Uint8Array(w),R=0;R<w;R++)k[R]=c.readUByte();E(i._txtTrack.samples,{pts:t.pts,payloadType:h,uuid:A.join(""),userData:Object(a.utf8ArrayToStr)(k),userDataBytes:k})}}else if(f<c.bytesAvailable)for(var D=0;D<f;D++)c.readUByte()}break;case 7:if(r=!0,u=!0,!n.sps){var O=new s.default(e.data).readSPS();n.width=O.width,n.height=O.height,n.pixelRatio=O.pixelRatio,n.sps=[e.data],n.duration=i._duration;for(var I=e.data.subarray(1,4),C="avc1.",P=0;P<3;P++){var x=I[P].toString(16);x.length<2&&(x="0"+x),C+=x}n.codec=C}break;case 8:r=!0,n.pps||(n.pps=[e.data]);break;case 9:r=!1,n.audFound=!0,l&&y(l,n),l=i.avcSample=p(!1,t.pts,t.dts,"");break;case 12:r=!1;break;default:r=!1,l&&(l.debug+="unknown NAL "+e.type+" ")}l&&r&&l.units.push(e)})),e&&l&&(y(l,n),this.avcSample=null)},e.getLastNalUnit=function(){var t,e,r=this.avcSample;if(!r||0===r.units.length){var i=this._avcTrack.samples;r=i[i.length-1]}if(null!==(t=r)&&void 0!==t&&t.units){var n=r.units;e=n[n.length-1]}return e},e.parseAVCNALu=function(t){var e,r,i=t.byteLength,n=this._avcTrack,s=n.naluState||0,a=s,o=[],l=0,u=-1,d=0;for(-1===s&&(u=0,d=31&t[0],s=0,l=1);l<i;)if(e=t[l++],s)if(1!==s)if(e)if(1===e){if(u>=0){var c={data:t.subarray(u,l-s-1),type:d};o.push(c)}else{var h=this.getLastNalUnit();if(h&&(a&&l<=4-a&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-a)),(r=l-s-1)>0)){var f=new Uint8Array(h.data.byteLength+r);f.set(h.data,0),f.set(t.subarray(0,r),h.data.byteLength),h.data=f}}l<i?(u=l,d=31&t[l],s=0):s=-1}else s=0;else s=3;else s=e?0:2;else s=e?0:1;if(u>=0&&s>=0){var p={data:t.subarray(u,i),type:d,state:s};o.push(p)}if(0===o.length){var g=this.getLastNalUnit();if(g){var m=new Uint8Array(g.data.byteLength+t.byteLength);m.set(g.data,0),m.set(t,g.data.byteLength),g.data=m}}return n.naluState=s,o},e.parseAACPES=function(t){var e,r,n,s,a=this._audioTrack,o=this.aacLastPTS,u=this.aacOverFlow,h=t.data;if(u){var f=new Uint8Array(u.byteLength+h.byteLength);f.set(u,0),f.set(h,u.byteLength),h=f}for(e=0,r=h.length;e<r-1&&!i.isHeader(h,e);e++);if(!e||(e<r-1?(n="AAC PES did not start with ADTS header,offset:"+e,s=!1):(n="no ADTS header found in AAC PES",s=!0),d.logger.warn("parsing error:"+n),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:n}),!s)){i.initTrackConfig(a,this.observer,h,e,this.audioCodec);var p,g=0,m=i.getFrameDuration(a.samplerate);if(void 0!==t.pts)p=t.pts;else{if(null===o)return void d.logger.warn("[tsdemuxer]: AAC PES unknown PTS");p=o}if(u&&null!==o){var v=o+m;Math.abs(v-p)>1&&(d.logger.log("[tsdemuxer]: AAC: align PTS for overlapping frames by "+Math.round((v-p)/90)),p=v)}for(var y=null;e<r;){if(i.isHeader(h,e)){if(e+5<r){var E=i.appendFrame(a,h,e,p,g);if(E){e+=E.length,y=E.sample.pts,g++;continue}}break}e++}this.aacOverFlow=e<r?h.subarray(e,r):null,this.aacLastPTS=y}},e.parseMPEGPES=function(t){var e=t.data,r=e.length,i=0,s=0,a=t.pts;if(void 0!==a)for(;s<r;)if(n.isHeader(e,s)){var o=n.appendFrame(this._audioTrack,e,s,a,i);if(!o)break;s+=o.length,i++}else s++;else d.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):d.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function p(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function g(t,e){return(31&t[e+10])<<8|t[e+11]}function m(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<s;){var a=(31&t[e+1])<<8|t[e+2];switch(t[e]){case 207:if(!i){d.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=a);break;case 21:-1===n.id3&&(n.id3=a);break;case 219:if(!i){d.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=a);break;case 3:case 4:r?-1===n.audio&&(n.audio=a,n.isAAC=!1):d.logger.log("MPEG audio found, not supported in this browser");break;case 36:d.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return n}function v(t){var e,r,i,n,s,a=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var u=e[7];192&u&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?n-(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(d.logger.warn(Math.round((n-s)/9e4)+"s delta between PTS and DTS, align them"),n=s):s=n);var c=(i=e[8])+9;if(t.size<=c)return null;t.size-=c;for(var h=new Uint8Array(t.size),f=0,p=o.length;f<p;f++){var g=(e=o[f]).byteLength;if(c){if(c>g){c-=g;continue}e=e.subarray(c),g-=c,c=0}h.set(e,a),a+=g}return r&&(r-=i+3),{data:h,pts:n,dts:s,len:r}}return null}function y(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&d.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function E(t,e){var r=t.length;if(r>0){if(e.pts>=t[r-1].pts)t.push(e);else for(var i=r-1;i>=0;i--)if(e.pts<t[i].pts){t.splice(i,0,e);break}}else t.push(e)}function T(t){for(var e=t.byteLength,r=[],i=1;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var n=e-r.length,s=new Uint8Array(n),a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=t[a];return s}f.minProbeByteLength=188,e.default=f},"./src/errors.ts":
192
192
  /*!***********************!*\
193
193
  !*** ./src/errors.ts ***!
194
194
  \***********************/
195
- /*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){var n,i;r.r(t),r.d(t,"ErrorTypes",(function(){return n})),r.d(t,"ErrorDetails",(function(){return i})),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(n||(n={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"}(i||(i={}))},"./src/events.ts":
195
+ /*! exports provided: ErrorTypes, ErrorDetails */function(t,e,r){var i,n;r.r(e),r.d(e,"ErrorTypes",(function(){return i})),r.d(e,"ErrorDetails",(function(){return n})),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(i||(i={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(n||(n={}))},"./src/events.ts":
196
196
  /*!***********************!*\
197
197
  !*** ./src/events.ts ***!
198
198
  \***********************/
199
- /*! exports provided: Events */function(e,t,r){var n;r.r(t),r.d(t,"Events",(function(){return n})),function(e){e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached"}(n||(n={}))},"./src/hls.ts":
199
+ /*! exports provided: Events */function(t,e,r){var i;r.r(e),r.d(e,"Events",(function(){return i})),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(i||(i={}))},"./src/hls.ts":
200
200
  /*!********************!*\
201
201
  !*** ./src/hls.ts ***!
202
202
  \********************/
203
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return y}));var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),i=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),a=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),d=r(/*! ./is-supported */"./src/is-supported.ts"),f=r(/*! ./utils/logger */"./src/utils/logger.ts"),h=r(/*! ./config */"./src/config.ts"),p=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),v=r(/*! ./events */"./src/events.ts"),g=r(/*! ./errors */"./src/errors.ts");function m(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var y=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this._media=null,this.url=null;var r=this.config=Object(h.mergeConfig)(e.DefaultConfig,t);this.userConfig=t,Object(f.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(h.enableStreamingMode)(r);var n=r.abrController,d=r.bufferController,v=r.capLevelController,g=r.fpsController,m=this.abrController=new n(this),y=this.bufferController=new d(this),E=this.capLevelController=new v(this),_=new g(this),T=new i.default(this),b=new a.default(this),A=new s.default(this),S=this.levelController=new l.default(this),w=new u.FragmentTracker(this),L=this.streamController=new c.default(this,w);E.setStreamController(L),_.setStreamController(L);var k=[S,L];this.networkControllers=k;var R=[T,b,m,y,E,_,A,w];this.audioTrackController=this.createController(r.audioTrackController,null,k),this.createController(r.audioStreamController,w,k),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,k),this.createController(r.subtitleStreamController,w,k),this.createController(r.timelineController,null,R),this.emeController=this.createController(r.emeController,null,R),this.latencyController=this.createController(o.default,null,R),this.coreComponents=R}e.isSupported=function(){return Object(d.isSupported)()};var t,r,y,E=e.prototype;return E.createController=function(e,t,r){if(e){var n=t?new e(this,t):new e(this);return r&&r.push(n),n}return null},E.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},E.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},E.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},E.off=function(e,t,r,n){void 0===r&&(r=this),this._emitter.off(e,t,r,n)},E.listeners=function(e){return this._emitter.listeners(e)},E.emit=function(e,t,r){return this._emitter.emit(e,t,r)},E.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){f.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(v.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},E.listenerCount=function(e){return this._emitter.listenerCount(e)},E.destroy=function(){f.logger.log("destroy"),this.trigger(v.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0},E.attachMedia=function(e){f.logger.log("attachMedia"),this._media=e,this.trigger(v.Events.MEDIA_ATTACHING,{media:e})},E.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(v.Events.MEDIA_DETACHING,void 0),this._media=null},E.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=n.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});f.logger.log("loadSource:"+i),t&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.Events.MANIFEST_LOADING,{url:e})},E.startLoad=function(e){void 0===e&&(e=-1),f.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},E.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},E.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},E.recoverMediaError=function(){f.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},E.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},t=e,y=[{key:"version",get:function(){return"1.0.2"}},{key:"Events",get:function(){return v.Events}},{key:"ErrorTypes",get:function(){return g.ErrorTypes}},{key:"ErrorDetails",get:function(){return g.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:h.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}],(r=[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){f.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){f.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){f.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){f.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){f.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(f.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n<r;n++)if(e[n].maxBitrate>t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&m(t.prototype,r),y&&m(t,y),e}();y.defaultConfig=void 0},"./src/is-supported.ts":
203
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return y}));var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),a=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),d=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),c=r(/*! ./is-supported */"./src/is-supported.ts"),h=r(/*! ./utils/logger */"./src/utils/logger.ts"),f=r(/*! ./config */"./src/config.ts"),p=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),g=r(/*! ./events */"./src/events.ts"),m=r(/*! ./errors */"./src/errors.ts");function v(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var y=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this._media=null,this.url=null;var r=this.config=Object(f.mergeConfig)(t.DefaultConfig,e);this.userConfig=e,Object(h.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(f.enableStreamingMode)(r);var i=r.abrController,c=r.bufferController,g=r.capLevelController,m=r.fpsController,v=this.abrController=new i(this),y=this.bufferController=new c(this),E=this.capLevelController=new g(this),T=new m(this),_=new n.default(this),b=new s.default(this),S=new a.default(this),A=this.levelController=new l.default(this),L=new u.FragmentTracker(this),w=this.streamController=new d.default(this,L);E.setStreamController(w),T.setStreamController(w);var k=[A,w];this.networkControllers=k;var R=[_,b,v,y,E,T,S,L];this.audioTrackController=this.createController(r.audioTrackController,null,k),this.createController(r.audioStreamController,L,k),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,k),this.createController(r.subtitleStreamController,L,k),this.createController(r.timelineController,null,R),this.emeController=this.createController(r.emeController,null,R),this.latencyController=this.createController(o.default,null,R),this.coreComponents=R}t.isSupported=function(){return Object(c.isSupported)()};var e,r,y,E=t.prototype;return E.createController=function(t,e,r){if(t){var i=e?new t(this,e):new t(this);return r&&r.push(i),i}return null},E.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},E.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},E.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},E.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},E.listeners=function(t){return this._emitter.listeners(t)},E.emit=function(t,e,r){return this._emitter.emit(t,e,r)},E.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){h.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(g.Events.ERROR,{type:m.ErrorTypes.OTHER_ERROR,details:m.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},E.listenerCount=function(t){return this._emitter.listenerCount(t)},E.destroy=function(){h.logger.log("destroy"),this.trigger(g.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},E.attachMedia=function(t){h.logger.log("attachMedia"),this._media=t,this.trigger(g.Events.MEDIA_ATTACHING,{media:t})},E.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},E.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});h.logger.log("loadSource:"+n),e&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(g.Events.MANIFEST_LOADING,{url:t})},E.startLoad=function(t){void 0===t&&(t=-1),h.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},E.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},E.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},E.recoverMediaError=function(){h.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},E.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},e=t,y=[{key:"version",get:function(){return"1.0.2"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return m.ErrorTypes}},{key:"ErrorDetails",get:function(){return m.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:f.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}],(r=[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){h.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){h.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){h.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){h.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){h.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(h.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i<r;i++)if(t[i].maxBitrate>e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping;return-1===e&&t&&t.length?t.length-1:e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&v(e.prototype,r),y&&v(e,y),t}();y.defaultConfig=void 0},"./src/is-supported.ts":
204
204
  /*!*****************************!*\
205
205
  !*** ./src/is-supported.ts ***!
206
206
  \*****************************/
207
- /*! exports provided: isSupported, changeTypeSupported */function(e,t,r){r.r(t),r.d(t,"isSupported",(function(){return a})),r.d(t,"changeTypeSupported",(function(){return s}));var n=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function i(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e=Object(n.getMediaSource)();if(!e)return!1;var t=i(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}function s(){var e,t=i();return"function"==typeof(null==t||null===(e=t.prototype)||void 0===e?void 0:e.changeType)}},"./src/loader/fragment-loader.ts":
207
+ /*! exports provided: isSupported, changeTypeSupported */function(t,e,r){r.r(e),r.d(e,"isSupported",(function(){return s})),r.d(e,"changeTypeSupported",(function(){return a}));var i=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(i.getMediaSource)();if(!t)return!1;var e=n(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!s}function a(){var t,e=n();return"function"==typeof(null==e||null===(t=e.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/fragment-loader.ts":
208
208
  /*!***************************************!*\
209
209
  !*** ./src/loader/fragment-loader.ts ***!
210
210
  \***************************************/
211
- /*! exports provided: default, LoadError */function(e,t,r){r.r(t),r.d(t,"default",(function(){return d})),r.d(t,"LoadError",(function(){return h}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../errors */"./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return s(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function s(e,t,r){return(s=o()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i}).apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var c=Math.pow(2,17),d=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,n=e.url;if(!n)return Promise.reject(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(n,l){r.loader&&r.loader.destroy();var u=r.loader=e.loader=s?new s(a):new o(a),d=f(e),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};e.stats=u.stats,u.load(d,p,{onSuccess:function(t,i,a,s){r.resetLoader(e,u),n({frag:e,part:null,payload:t.data,networkDetails:s})},onError:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(r,n,i,a){t&&t({frag:e,part:null,payload:i,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){n.loader&&n.loader.destroy();var d=n.loader=e.loader=s?new s(a):new o(a),p=f(e,t),v={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=d.stats,d.load(p,v,{onSuccess:function(i,a,s,o){n.resetLoader(e,d),n.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s){n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r,networkDetails:s}))},onAbort:function(r,a,s){e.stats.aborted=t.stats.aborted,n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:s}))},onTimeout:function(r,a,s){n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:s}))}})}))},t.updateStatsFromPart=function(e,t){var r=e.stats,n=t.stats,i=n.total;if(r.loaded+=n.loaded,i){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/i),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=n.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function f(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return Object(n.isFiniteNumber)(a)&&Object(n.isFiniteNumber)(s)&&(i.rangeStart=a,i.rangeEnd=s),i}var h=function(e){var t,r;function n(t){for(var r,n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];return(r=e.call.apply(e,[this].concat(i))||this).data=void 0,r.data=t,r}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r),n}(a(Error))},"./src/loader/fragment.ts":
211
+ /*! exports provided: default, LoadError */function(t,e,r){r.r(e),r.d(e,"default",(function(){return c})),r.d(e,"LoadError",(function(){return f}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../errors */"./src/errors.ts");function s(t){var e="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return a(t,arguments,u(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,t)})(t)}function a(t,e,r){return(a=o()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&l(n,r.prototype),n}).apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var d=Math.pow(2,17),c=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,i=t.url;if(!i)return Promise.reject(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(i,l){r.loader&&r.loader.destroy();var u=r.loader=t.loader=a?new a(s):new o(s),c=h(t),p={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:d};t.stats=u.stats,u.load(c,p,{onSuccess:function(e,n,s,a){r.resetLoader(t,u),i({frag:t,part:null,payload:e.data,networkDetails:a})},onError:function(e,i,s){r.resetLoader(t,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:e,networkDetails:s}))},onAbort:function(e,i,s){r.resetLoader(t,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(e,i,s){r.resetLoader(t,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(r,i,n,s){e&&e({frag:t,part:null,payload:n,networkDetails:s})}})}))},e.loadPart=function(t,e,r){var i=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(l,u){i.loader&&i.loader.destroy();var c=i.loader=t.loader=a?new a(s):new o(s),p=h(t,e),g={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:d};e.stats=c.stats,c.load(p,g,{onSuccess:function(n,s,a,o){i.resetLoader(t,c),i.updateStatsFromPart(t,e);var u={frag:t,part:e,payload:n.data,networkDetails:o};r(u),l(u)},onError:function(r,s,a){i.resetLoader(t,c),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:r,networkDetails:a}))},onAbort:function(r,s,a){t.stats.aborted=e.stats.aborted,i.resetLoader(t,c),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,networkDetails:a}))},onTimeout:function(r,s,a){i.resetLoader(t,c),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,networkDetails:a}))}})}))},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var s=Math.round(t.duration/e.duration),a=Math.min(Math.round(r.loaded/n),s),o=(s-a)*Math.round(r.loaded/a);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function h(t,e){void 0===e&&(e=null);var r=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:r.url,rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,a=r.byteRangeEndOffset;return Object(i.isFiniteNumber)(s)&&Object(i.isFiniteNumber)(a)&&(n.rangeStart=s,n.rangeEnd=a),n}var f=function(t){var e,r;function i(e){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return(r=t.call.apply(t,[this].concat(n))||this).data=void 0,r.data=e,r}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,l(e,r),i}(s(Error))},"./src/loader/fragment.ts":
212
212
  /*!********************************!*\
213
213
  !*** ./src/loader/fragment.ts ***!
214
214
  \********************************/
215
- /*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(e,t,r){r.r(t),r.d(t,"ElementaryStreamTypes",(function(){return n})),r.d(t,"BaseSegment",(function(){return h})),r.d(t,"Fragment",(function(){return p})),r.d(t,"Part",(function(){return v}));var n,i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),e}!function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"}(n||(n={}));var h=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[n.AUDIO]=null,t[n.VIDEO]=null,t[n.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),n=[];1===r.length?n[0]=t?t.byteRangeEndOffset:0:n[0]=parseInt(r[1]),n[1]=parseInt(r[0])+n[0],this._byteRange=n},f(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),p=function(e){function t(t,r){var n;return(n=e.call(this,r)||this)._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new l.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.type=t,n}u(t,e);var r=t.prototype;return r.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,n,i,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,i)):s[e]={startPTS:t,endPTS:r,startDTS:n,endDTS:i,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[n.AUDIO]=null,e[n.VIDEO]=null,e[n.AUDIOVIDEO]=null},f(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&s.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(i.isFiniteNumber)(this.programDateTime))return null;var e=Object(i.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null===(e=this.decryptdata)||void 0===e||!e.keyFormat||!this.decryptdata.uri)}}]),t}(h),v=function(e){function t(t,r,n,i,a){var s;(s=e.call(this,n)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new l.LoadStats,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=i;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),f(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(h)},"./src/loader/key-loader.ts":
215
+ /*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,e,r){r.r(e),r.d(e,"ElementaryStreamTypes",(function(){return i})),r.d(e,"BaseSegment",(function(){return f})),r.d(e,"Fragment",(function(){return p})),r.d(e,"Part",(function(){return g}));var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,d(t,e)}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function h(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(i||(i={}));var f=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},h(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),p=function(t){function e(e,r){var i;return(i=t.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkey=void 0,i.type=void 0,i.loader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new l.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.type=e,i}u(e,t);var r=e.prototype;return r.createInitializationVector=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e},r.setDecryptDataFromLevelKey=function(t,e){var r=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((r=o.LevelKey.fromURI(t.uri)).method=t.method,r.iv=this.createInitializationVector(e),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(t,e,r,i,n,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:s}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null},h(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var t=this.sn;"number"!=typeof t&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&a.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),t=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,t)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(n.isFiniteNumber)(this.programDateTime))return null;var t=Object(n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;return!(null===(t=this.decryptdata)||void 0===t||!t.keyFormat||!this.decryptdata.uri)}}]),e}(f),g=function(t){function e(e,r,i,n,s){var a;(a=t.call(this,i)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new l.LoadStats,a.duration=e.decimalFloatingPoint("DURATION"),a.gap=e.bool("GAP"),a.independent=e.bool("INDEPENDENT"),a.relurl=e.enumeratedString("URI"),a.fragment=r,a.index=n;var o=e.enumeratedString("BYTERANGE");return o&&a.setByteRange(o,s),s&&(a.fragOffset=s.fragOffset+s.duration),a}return u(e,t),h(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(f)},"./src/loader/key-loader.ts":
216
216
  /*!**********************************!*\
217
217
  !*** ./src/loader/key-loader.ts ***!
218
218
  \**********************************/
219
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return s}));var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function e(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){this.hls.on(n.Events.KEY_LOADING,this.onKeyLoading,this)},t._unregisterListeners=function(){this.hls.off(n.Events.KEY_LOADING,this.onKeyLoading)},t.destroy=function(){for(var e in this._unregisterListeners(),this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={}},t.onKeyLoading=function(e,t){var r=t.frag,i=r.type,s=this.loaders[i];if(r.decryptdata){var o=r.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(s&&(a.logger.warn("abort previous key loader for type:"+i),s.abort()),!o)return void a.logger.warn("key uri is falsy");var u=l.loader,c=r.loader=this.loaders[i]=new u(l);this.decrypturl=o,this.decryptkey=null;var d={url:o,frag:r,responseType:"arraybuffer"},f={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},h={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(d,f,h)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(n.Events.KEY_LOADED,{frag:r}))}else a.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){var i=r.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=null,delete this.loaders[i.type],this.hls.trigger(n.Events.KEY_LOADED,{frag:i})):a.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},t.loadtimeout=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}()},"./src/loader/level-details.ts":
219
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return a}));var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function t(t){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){this.hls.on(i.Events.KEY_LOADING,this.onKeyLoading,this)},e._unregisterListeners=function(){this.hls.off(i.Events.KEY_LOADING,this.onKeyLoading)},e.destroy=function(){for(var t in this._unregisterListeners(),this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={}},e.onKeyLoading=function(t,e){var r=e.frag,n=r.type,a=this.loaders[n];if(r.decryptdata){var o=r.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(a&&(s.logger.warn("abort previous key loader for type:"+n),a.abort()),!o)return void s.logger.warn("key uri is falsy");var u=l.loader,d=r.loader=this.loaders[n]=new u(l);this.decrypturl=o,this.decryptkey=null;var c={url:o,frag:r,responseType:"arraybuffer"},h={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(c,h,f)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(i.Events.KEY_LOADED,{frag:r}))}else s.logger.warn("Missing decryption data on fragment in onKeyLoading")},e.loadsuccess=function(t,e,r){var n=r.frag;n.decryptdata?(this.decryptkey=n.decryptdata.key=new Uint8Array(t.data),n.loader=null,delete this.loaders[n.type],this.hls.trigger(i.Events.KEY_LOADED,{frag:n})):s.logger.error("after key load, decryptdata unset")},e.loaderror=function(t,e){var r=e.frag,s=r.loader;s&&s.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.loadtimeout=function(t,e){var r=e.frag,s=r.loader;s&&s.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},t}()},"./src/loader/level-details.ts":
220
220
  /*!*************************************!*\
221
221
  !*** ./src/loader/level-details.ts ***!
222
222
  \*************************************/
223
- /*! exports provided: LevelDetails */function(e,t,r){r.r(t),r.d(t,"LevelDetails",(function(){return a}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.initSegment=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=e}var t,r,a;return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},t=e,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(n.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!==(e=this.fragments)&&void 0!==e&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&i(t.prototype,r),a&&i(t,a),e}()},"./src/loader/level-key.ts":
223
+ /*! exports provided: LevelDetails */function(t,e,r){r.r(e),r.d(e,"LevelDetails",(function(){return s}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var s=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.initSegment=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=t}var e,r,s;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},e=t,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(i.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&n(e.prototype,r),s&&n(e,s),t}()},"./src/loader/level-key.ts":
224
224
  /*!*********************************!*\
225
225
  !*** ./src/loader/level-key.ts ***!
226
226
  \*********************************/
227
- /*! exports provided: LevelKey */function(e,t,r){r.r(t),r.d(t,"LevelKey",(function(){return a}));var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e,t){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=t?Object(n.buildAbsoluteURL)(e,t,{alwaysNormalize:!0}):e}var t,r,a;return e.fromURL=function(t,r){return new e(t,r)},e.fromURI=function(t){return new e(t)},t=e,(r=[{key:"uri",get:function(){return this._uri}}])&&i(t.prototype,r),a&&i(t,a),e}()},"./src/loader/load-stats.ts":
227
+ /*! exports provided: LevelKey */function(t,e,r){r.r(e),r.d(e,"LevelKey",(function(){return s}));var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var s=function(){function t(t,e){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=e?Object(i.buildAbsoluteURL)(t,e,{alwaysNormalize:!0}):t}var e,r,s;return t.fromURL=function(e,r){return new t(e,r)},t.fromURI=function(e){return new t(e)},e=t,(r=[{key:"uri",get:function(){return this._uri}}])&&n(e.prototype,r),s&&n(e,s),t}()},"./src/loader/load-stats.ts":
228
228
  /*!**********************************!*\
229
229
  !*** ./src/loader/load-stats.ts ***!
230
230
  \**********************************/
231
- /*! exports provided: LoadStats */function(e,t,r){r.r(t),r.d(t,"LoadStats",(function(){return n}));var n=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
231
+ /*! exports provided: LoadStats */function(t,e,r){r.r(e),r.d(e,"LoadStats",(function(){return i}));var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
232
232
  /*!***********************************!*\
233
233
  !*** ./src/loader/m3u8-parser.ts ***!
234
234
  \***********************************/
235
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return g}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),s=r(/*! ./level-details */"./src/loader/level-details.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),d=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,h=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),v=/\.(mp4|m4s|m4v|m4a)$/i,g=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.id===t)return n}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).substr(-4)}return e},e.resolve=function(e,t){return i.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var n,i=[],a={},s=!1;for(d.lastIndex=0;null!=(n=d.exec(t));)if(n[1]){var o=new l.AttrList(n[1]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:e.resolve(n[2],r)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),m((o.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=e.convertAVC1ToAVCOTI(u.videoCodec)),i.push(u)}else if(n[3]){var f=new l.AttrList(n[3]);f["DATA-ID"]&&(s=!0,a[f["DATA-ID"]]=f)}return{levels:i,sessionData:s?a:null}},e.parseMasterPlaylistMedia=function(t,r,n,i){var a;void 0===i&&(i=[]);var s=[],o=0;for(f.lastIndex=0;null!==(a=f.exec(t));){var u=new l.AttrList(a[1]);if(u.TYPE===n){var c={attrs:u,bitrate:0,id:o++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:n,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?e.resolve(u.URI,r):""};if(i.length){var d=e.findGroup(i,c.groupId)||i[0];y(c,d,"audioCodec"),y(c,d,"textCodec")}s.push(c)}}return s},e.parseLevelPlaylist=function(e,t,r,c,d){var f,g,m,y=new s.LevelDetails(t),_=y.fragments,T=0,b=0,A=0,S=0,w=null,L=new a.Fragment(c,t),k=-1;for(h.lastIndex=0,y.m3u8=e;null!==(f=h.exec(e));){var R=f[1];if(R){L.duration=parseFloat(R);var D=(" "+f[2]).slice(1);L.title=D||null,L.tagList.push(D?["INF",R,D]:["INF",R])}else if(f[3])Object(n.isFiniteNumber)(L.duration)&&(L.start=A,m&&(L.levelkey=m),L.sn=T,L.level=r,L.cc=S,L.urlId=d,_.push(L),L.relurl=(" "+f[3]).slice(1),E(L,w),w=L,A+=L.duration,T++,b=0,(L=new a.Fragment(c,t)).start=A,L.sn=T,L.cc=S,L.level=r);else if(f[4]){var O=(" "+f[4]).slice(1);w?L.setByteRange(O,w):L.setByteRange(O)}else if(f[5])L.rawProgramDateTime=(" "+f[5]).slice(1),L.tagList.push(["PROGRAM-DATE-TIME",L.rawProgramDateTime]),-1===k&&(k=_.length);else{if(!(f=f[0].match(p))){u.logger.warn("No matches on slow regex match for level playlist!");continue}for(g=1;g<f.length&&void 0===f[g];g++);var C=(" "+f[g]).slice(1),I=(" "+f[g+1]).slice(1),x=f[g+2]?(" "+f[g+2]).slice(1):"";switch(C){case"PLAYLIST-TYPE":y.type=I.toUpperCase();break;case"MEDIA-SEQUENCE":T=y.startSN=parseInt(I);break;case"SKIP":var P=new l.AttrList(I),M=P.decimalInteger("SKIPPED-SEGMENTS");if(Object(n.isFiniteNumber)(M)){y.skippedSegments=M;for(var F=M;F--;)_.unshift(null);T+=M}var N=P.enumeratedString("RECENTLY-REMOVED-DATERANGES");N&&(y.recentlyRemovedDateranges=N.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(I);break;case"VERSION":y.version=parseInt(I);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(I||x)&&L.tagList.push(x?[I,x]:[I]);break;case"DIS":S++;case"GAP":L.tagList.push([C]);break;case"BITRATE":L.tagList.push([C,I]);break;case"DISCONTINUITY-SEQ":S=parseInt(I);break;case"KEY":var U,B=new l.AttrList(I),j=B.enumeratedString("METHOD"),G=B.URI,H=B.hexadecimalInteger("IV"),K=B.enumeratedString("KEYFORMATVERSIONS"),V=B.enumeratedString("KEYID"),W=null!=(U=B.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(W)>-1){u.logger.warn("Keyformat "+W+" is not supported from the manifest");continue}if("identity"!==W)continue;j&&(m=o.LevelKey.fromURL(t,G),G&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(j)>=0&&(m.method=j,m.keyFormat=W,V&&(m.keyID=V),K&&(m.keyFormatVersions=K),m.iv=H));break;case"START":var q=new l.AttrList(I).decimalFloatingPoint("TIME-OFFSET");Object(n.isFiniteNumber)(q)&&(y.startTimeOffset=q);break;case"MAP":var z=new l.AttrList(I);L.relurl=z.URI,z.BYTERANGE&&L.setByteRange(z.BYTERANGE),L.level=r,L.sn="initSegment",m&&(L.levelkey=m),y.initSegment=L,(L=new a.Fragment(c,t)).rawProgramDateTime=y.initSegment.rawProgramDateTime;break;case"SERVER-CONTROL":var Y=new l.AttrList(I);y.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),y.holdBack=Y.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var X=new l.AttrList(I);y.partTarget=X.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=y.partList;Q||(Q=y.partList=[]);var Z=b>0?Q[Q.length-1]:void 0,J=b++,$=new a.Part(new l.AttrList(I),L,t,J,Z);Q.push($),L.duration+=$.duration;break;case"PRELOAD-HINT":var ee=new l.AttrList(I);y.preloadHint=ee;break;case"RENDITION-REPORT":var te=new l.AttrList(I);y.renditionReports=y.renditionReports||[],y.renditionReports.push(te);break;default:u.logger.warn("line parsed but not handled: "+f)}}}w&&!w.relurl?(_.pop(),A-=w.duration,y.partList&&(y.fragmentHint=w)):y.partList&&(E(L,w),L.cc=S,y.fragmentHint=L);var re=_.length,ne=_[0],ie=_[re-1];if((A+=y.skippedSegments*y.targetduration)>0&&re&&ie){y.averagetargetduration=A/re;var ae=ie.sn;y.endSN="initSegment"!==ae?ae:0,ne&&(y.startCC=ne.cc,y.initSegment||y.fragments.every((function(e){return e.relurl&&function(e){var t,r;return v.test(null!=(t=null===(r=i.parseURL(e))||void 0===r?void 0:r.path)?t:"")}(e.relurl)}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(L=new a.Fragment(c,t)).relurl=ie.relurl,L.level=r,L.sn="initSegment",y.initSegment=L,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(A+=y.fragmentHint.duration),y.totalduration=A,y.endCC=S,k>0&&function(e,t){for(var r=e[t],n=t;n--;){var i=e[n];if(!i)return;i.programDateTime=r.programDateTime-1e3*i.duration,r=i}}(_,k),y},e}();function m(e,t){["video","audio","text"].forEach((function(r){var n=e.filter((function(e){return Object(c.isCodecType)(e,r)}));if(n.length){var i=n.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=i.length>0?i[0]:n[0],e=e.filter((function(e){return-1===n.indexOf(e)}))}})),t.unknownCodecs=e}function y(e,t,r){var n=t[r];n&&(e[r]=n)}function E(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(n.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
235
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return m}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ./fragment */"./src/loader/fragment.ts"),a=r(/*! ./level-details */"./src/loader/level-details.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),c=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,h=/#EXT-X-MEDIA:(.*)/g,f=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),g=/\.(mp4|m4s|m4v|m4a)$/i,m=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r<t.length;r++){var i=t[r];if(i.id===e)return i}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).substr(-4)}return t},t.resolve=function(t,e){return n.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(e,r){var i,n=[],s={},a=!1;for(c.lastIndex=0;null!=(i=c.exec(e));)if(i[1]){var o=new l.AttrList(i[1]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(i[2],r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),v((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),n.push(u)}else if(i[3]){var h=new l.AttrList(i[3]);h["DATA-ID"]&&(a=!0,s[h["DATA-ID"]]=h)}return{levels:n,sessionData:a?s:null}},t.parseMasterPlaylistMedia=function(e,r,i,n){var s;void 0===n&&(n=[]);var a=[],o=0;for(h.lastIndex=0;null!==(s=h.exec(e));){var u=new l.AttrList(s[1]);if(u.TYPE===i){var d={attrs:u,bitrate:0,id:o++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:i,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?t.resolve(u.URI,r):""};if(n.length){var c=t.findGroup(n,d.groupId)||n[0];y(d,c,"audioCodec"),y(d,c,"textCodec")}a.push(d)}}return a},t.parseLevelPlaylist=function(t,e,r,d,c){var h,m,v,y=new a.LevelDetails(e),T=y.fragments,_=0,b=0,S=0,A=0,L=null,w=new s.Fragment(d,e),k=-1;for(f.lastIndex=0,y.m3u8=t;null!==(h=f.exec(t));){var R=h[1];if(R){w.duration=parseFloat(R);var D=(" "+h[2]).slice(1);w.title=D||null,w.tagList.push(D?["INF",R,D]:["INF",R])}else if(h[3])Object(i.isFiniteNumber)(w.duration)&&(w.start=S,v&&(w.levelkey=v),w.sn=_,w.level=r,w.cc=A,w.urlId=c,T.push(w),w.relurl=(" "+h[3]).slice(1),E(w,L),L=w,S+=w.duration,_++,b=0,(w=new s.Fragment(d,e)).start=S,w.sn=_,w.cc=A,w.level=r);else if(h[4]){var O=(" "+h[4]).slice(1);L?w.setByteRange(O,L):w.setByteRange(O)}else if(h[5])w.rawProgramDateTime=(" "+h[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),-1===k&&(k=T.length);else{if(!(h=h[0].match(p))){u.logger.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m<h.length&&void 0===h[m];m++);var I=(" "+h[m]).slice(1),C=(" "+h[m+1]).slice(1),P=h[m+2]?(" "+h[m+2]).slice(1):"";switch(I){case"PLAYLIST-TYPE":y.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":_=y.startSN=parseInt(C);break;case"SKIP":var x=new l.AttrList(C),M=x.decimalInteger("SKIPPED-SEGMENTS");if(Object(i.isFiniteNumber)(M)){y.skippedSegments=M;for(var F=M;F--;)T.unshift(null);_+=M}var N=x.enumeratedString("RECENTLY-REMOVED-DATERANGES");N&&(y.recentlyRemovedDateranges=N.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(C);break;case"VERSION":y.version=parseInt(C);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(C||P)&&w.tagList.push(P?[C,P]:[C]);break;case"DIS":A++;case"GAP":w.tagList.push([I]);break;case"BITRATE":w.tagList.push([I,C]);break;case"DISCONTINUITY-SEQ":A=parseInt(C);break;case"KEY":var U,B=new l.AttrList(C),G=B.enumeratedString("METHOD"),j=B.URI,H=B.hexadecimalInteger("IV"),K=B.enumeratedString("KEYFORMATVERSIONS"),V=B.enumeratedString("KEYID"),q=null!=(U=B.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){u.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(v=o.LevelKey.fromURL(e,j),j&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(v.method=G,v.keyFormat=q,V&&(v.keyID=V),K&&(v.keyFormatVersions=K),v.iv=H));break;case"START":var W=new l.AttrList(C).decimalFloatingPoint("TIME-OFFSET");Object(i.isFiniteNumber)(W)&&(y.startTimeOffset=W);break;case"MAP":var z=new l.AttrList(C);w.relurl=z.URI,z.BYTERANGE&&w.setByteRange(z.BYTERANGE),w.level=r,w.sn="initSegment",v&&(w.levelkey=v),y.initSegment=w,(w=new s.Fragment(d,e)).rawProgramDateTime=y.initSegment.rawProgramDateTime;break;case"SERVER-CONTROL":var Y=new l.AttrList(C);y.canBlockReload=Y.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=Y.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&Y.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=Y.optionalFloat("PART-HOLD-BACK",0),y.holdBack=Y.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var X=new l.AttrList(C);y.partTarget=X.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=y.partList;Q||(Q=y.partList=[]);var $=b>0?Q[Q.length-1]:void 0,J=b++,Z=new s.Part(new l.AttrList(C),w,e,J,$);Q.push(Z),w.duration+=Z.duration;break;case"PRELOAD-HINT":var tt=new l.AttrList(C);y.preloadHint=tt;break;case"RENDITION-REPORT":var et=new l.AttrList(C);y.renditionReports=y.renditionReports||[],y.renditionReports.push(et);break;default:u.logger.warn("line parsed but not handled: "+h)}}}L&&!L.relurl?(T.pop(),S-=L.duration,y.partList&&(y.fragmentHint=L)):y.partList&&(E(w,L),w.cc=A,y.fragmentHint=w);var rt=T.length,it=T[0],nt=T[rt-1];if((S+=y.skippedSegments*y.targetduration)>0&&rt&&nt){y.averagetargetduration=S/rt;var st=nt.sn;y.endSN="initSegment"!==st?st:0,it&&(y.startCC=it.cc,y.initSegment||y.fragments.every((function(t){return t.relurl&&function(t){var e,r;return g.test(null!=(e=null===(r=n.parseURL(t))||void 0===r?void 0:r.path)?e:"")}(t.relurl)}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(w=new s.Fragment(d,e)).relurl=nt.relurl,w.level=r,w.sn="initSegment",y.initSegment=w,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(S+=y.fragmentHint.duration),y.totalduration=S,y.endCC=A,k>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(T,k),y},t}();function v(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return Object(d.isCodecType)(t,r)}));if(i.length){var n=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function y(t,e,r){var i=e[r];i&&(t[r]=i)}function E(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),Object(i.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
236
236
  /*!***************************************!*\
237
237
  !*** ./src/loader/playlist-loader.ts ***!
238
238
  \***************************************/
239
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function d(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var f=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,n=t.loader,i=new(r||n)(t);return e.loader=i,this.loaders[e.type]=i,i},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,n=t.level,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:null,level:n,responseType:"text",type:u.PlaylistContextType.LEVEL,url:i,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:a})},t.load=function(e){var t,r,n,i,a,o,l=this.hls.config,c=this.getInternalLoader(e);if(c){var d=c.context;if(d&&d.url===e.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),c.abort()}switch(e.type){case u.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,i=l.manifestLoadingRetryDelay,a=l.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:r=0,n=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,i=l.levelLoadingRetryDelay,a=l.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(e),null!==(t=e.deliveryDirectives)&&void 0!==t&&t.part&&(e.type===u.PlaylistContextType.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===u.PlaylistContextType.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o)){var f=o.partTarget,h=o.targetduration;f&&h&&(n=Math.min(1e3*Math.max(3*f,.8*h),n))}var p={timeout:n,maxRetry:r,retryDelay:i,maxRetryDelay:a,highWaterMark:0},v={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(e,p,v)},t.loadsuccess=function(e,t,r,n){if(void 0===n&&(n=null),r.isSidxRequest)return this.handleSidxRequest(e,r),void this.handlePlaylistLoaded(e,t,r,n);this.resetInternalLoader(r.type);var i=e.data;0===i.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,r,n):this.handleMasterPlaylist(e,t,r,n)):this.handleManifestParsingError(e,r,"no EXTM3U delimiter",n)},t.loaderror=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!1,e)},t.loadtimeout=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!0)},t.handleMasterPlaylist=function(e,t,r,n){var a=this.hls,o=e.data,u=d(e,r),f=l.default.parseMasterPlaylist(o,u),h=f.levels,p=f.sessionData;if(h.length){var v=h.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),g=h.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",v),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",g),E=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.some((function(e){return!e.url}))||!h[0].audioCodec||h[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),a.trigger(i.Events.MANIFEST_LOADED,{levels:h,audioTracks:m,subtitles:y,captions:E,url:u,stats:t,networkDetails:n,sessionData:p})}else this.handleManifestParsingError(e,r,"no level found in manifest",n)},t.handleTrackOrLevelPlaylist=function(e,t,r,s){var o=this.hls,f=r.id,h=r.level,p=r.type,v=d(e,r),g=Object(n.isFiniteNumber)(f)?f:0,m=Object(n.isFiniteNumber)(h)?h:g,y=function(e){switch(e.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(r),E=l.default.parseLevelPlaylist(e.data,v,m,y,g);if(E.fragments.length){if(p===u.PlaylistContextType.MANIFEST){var _={attrs:new c.AttrList({}),bitrate:0,details:E,name:"",url:v};o.trigger(i.Events.MANIFEST_LOADED,{levels:[_],audioTracks:[],url:v,stats:t,networkDetails:s,sessionData:null})}if(t.parsing.end=performance.now(),E.needSidxRanges){var T=E.initSegment.url;this.load({url:T,isSidxRequest:!0,type:p,level:h,levelDetails:E,id:f,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=E,this.handlePlaylistLoaded(e,t,r,s)}else o.trigger(i.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:v,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},t.handleSidxRequest=function(e,t){var r=Object(o.parseSegmentIndex)(new Uint8Array(e.data));if(r){var n=r.references,i=t.levelDetails;n.forEach((function(e,t){var r=e.info,n=i.fragments[t];0===n.byteRange.length&&n.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))})),i.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},t.handleManifestParsingError=function(e,t,r,n){this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===u.PlaylistContextType.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:n})},t.handleNetworkError=function(e,t,r,n){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,l=!1,c=this.getInternalLoader(e);switch(e.type){case u.PlaylistContextType.MANIFEST:o=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case u.PlaylistContextType.LEVEL:o=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=r?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);var d={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,networkDetails:t};n&&(d.response=n),this.hls.trigger(i.Events.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,n){var a=r.type,s=r.level,o=r.id,l=r.groupId,c=r.loader,d=r.levelDetails,f=r.deliveryDirectives;if(null!=d&&d.targetduration){if(c)switch(d.live&&(c.getCacheAge&&(d.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(d.ageHeader)||(d.ageHeader=0)),a){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(i.Events.LEVEL_LOADED,{details:d,level:s||0,id:o||0,stats:t,networkDetails:n,deliveryDirectives:f});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(i.Events.AUDIO_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:f});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:f})}}else this.handleManifestParsingError(e,r,"invalid target duration",n)},e}();t.default=f},"./src/polyfills/number.ts":
239
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function c(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var h=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return t.loader=n,this.loaders[t.type]=n,n},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:u.PlaylistContextType.LEVEL,url:n,deliveryDirectives:s})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:s})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,s=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:s})},e.load=function(t){var e,r,i,n,s,o,l=this.hls.config,d=this.getInternalLoader(t);if(d){var c=d.context;if(c&&c.url===t.url)return void a.logger.trace("[playlist-loader]: playlist request ongoing");a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),d.abort()}switch(t.type){case u.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,i=l.manifestLoadingTimeOut,n=l.manifestLoadingRetryDelay,s=l.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:r=0,i=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,i=l.levelLoadingTimeOut,n=l.levelLoadingRetryDelay,s=l.levelLoadingMaxRetryTimeout}if(d=this.createInternalLoader(t),null!==(e=t.deliveryDirectives)&&void 0!==e&&e.part&&(t.type===u.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===u.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var h=o.partTarget,f=o.targetduration;h&&f&&(i=Math.min(1e3*Math.max(3*h,.8*f),i))}var p={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:s,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(t,p,g)},e.loadsuccess=function(t,e,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this.handleSidxRequest(t,r),void this.handlePlaylistLoaded(t,e,r,i);this.resetInternalLoader(r.type);var n=t.data;0===n.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,e,r,i):this.handleMasterPlaylist(t,e,r,i)):this.handleManifestParsingError(t,r,"no EXTM3U delimiter",i)},e.loaderror=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!1,t)},e.loadtimeout=function(t,e,r){void 0===r&&(r=null),this.handleNetworkError(e,r,!0)},e.handleMasterPlaylist=function(t,e,r,i){var s=this.hls,o=t.data,u=c(t,r),h=l.default.parseMasterPlaylist(o,u),f=h.levels,p=h.sessionData;if(f.length){var g=f.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),m=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),v=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",m),E=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");v.length&&(v.some((function(t){return!t.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(a.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new d.AttrList({}),bitrate:0,url:""}))),s.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:v,subtitles:y,captions:E,url:u,stats:e,networkDetails:i,sessionData:p})}else this.handleManifestParsingError(t,r,"no level found in manifest",i)},e.handleTrackOrLevelPlaylist=function(t,e,r,a){var o=this.hls,h=r.id,f=r.level,p=r.type,g=c(t,r),m=Object(i.isFiniteNumber)(h)?h:0,v=Object(i.isFiniteNumber)(f)?f:m,y=function(t){switch(t.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(r),E=l.default.parseLevelPlaylist(t.data,g,v,y,m);if(E.fragments.length){if(p===u.PlaylistContextType.MANIFEST){var T={attrs:new d.AttrList({}),bitrate:0,details:E,name:"",url:g};o.trigger(n.Events.MANIFEST_LOADED,{levels:[T],audioTracks:[],url:g,stats:e,networkDetails:a,sessionData:null})}if(e.parsing.end=performance.now(),E.needSidxRanges){var _=E.initSegment.url;this.load({url:_,isSidxRequest:!0,type:p,level:f,levelDetails:E,id:h,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=E,this.handlePlaylistLoaded(t,e,r,a)}else o.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},e.handleSidxRequest=function(t,e){var r=Object(o.parseSegmentIndex)(new Uint8Array(t.data));if(r){var i=r.references,n=e.levelDetails;i.forEach((function(t,e){var r=t.info,i=n.fragments[e];0===i.byteRange.length&&i.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))})),n.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},e.handleManifestParsingError=function(t,e,r,i){this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===u.PlaylistContextType.MANIFEST,url:t.url,reason:r,response:t,context:e,networkDetails:i})},e.handleNetworkError=function(t,e,r,i){void 0===r&&(r=!1),a.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,l=!1,d=this.getInternalLoader(t);switch(t.type){case u.PlaylistContextType.MANIFEST:o=r?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case u.PlaylistContextType.LEVEL:o=r?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=r?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=r?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(t.type);var c={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:d,context:t,networkDetails:e};i&&(c.response=i),this.hls.trigger(n.Events.ERROR,c)},e.handlePlaylistLoaded=function(t,e,r,i){var s=r.type,a=r.level,o=r.id,l=r.groupId,d=r.loader,c=r.levelDetails,h=r.deliveryDirectives;if(null!=c&&c.targetduration){if(d)switch(c.live&&(d.getCacheAge&&(c.ageHeader=d.getCacheAge()||0),d.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),s){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:c,level:a||0,id:o||0,stats:e,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:c,id:o||0,groupId:l||"",stats:e,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:c,id:o||0,groupId:l||"",stats:e,networkDetails:i,deliveryDirectives:h})}}else this.handleManifestParsingError(t,r,"invalid target duration",i)},t}();e.default=h},"./src/polyfills/number.ts":
240
240
  /*!*********************************!*\
241
241
  !*** ./src/polyfills/number.ts ***!
242
242
  \*********************************/
243
- /*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(e,t,r){r.r(t),r.d(t,"isFiniteNumber",(function(){return n})),r.d(t,"MAX_SAFE_INTEGER",(function(){return i}));var n=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},i=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
243
+ /*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,e,r){r.r(e),r.d(e,"isFiniteNumber",(function(){return i})),r.d(e,"MAX_SAFE_INTEGER",(function(){return n}));var i=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
244
244
  /*!*********************************!*\
245
245
  !*** ./src/remux/aac-helper.ts ***!
246
246
  \*********************************/
247
- /*! exports provided: default */function(e,t,r){r.r(t);var n=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}();t.default=n},"./src/remux/mp4-generator.ts":
247
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=function(){function t(){}return t.getSilentFrame=function(t,e){switch(t){case"mp4a.40.2":if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},t}();e.default=i},"./src/remux/mp4-generator.ts":
248
248
  /*!************************************!*\
249
249
  !*** ./src/remux/mp4-generator.ts ***!
250
250
  \************************************/
251
- /*! exports provided: default */function(e,t,r){r.r(t);var n=Math.pow(2,32)-1,i=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:n};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))},e.box=function(e){for(var t=8,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var a=n.length,s=a;a--;)t+=n[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(n[a],t),t+=n[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(n+1)),a=Math.floor(r%(n+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))},e.moov=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(n))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(n+1)),a=Math.floor(r%(n+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,n,i=t.samples||[],a=new Uint8Array(4+i.length);for(r=0;r<i.length;r++)n=i[r].flags,a[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,n,i,a=[],s=[];for(r=0;r<t.sps.length;r++)i=(n=t.sps[r]).byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(r=0;r<t.pps.length;r++)i=(n=t.pps[r]).byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(n));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,a=t.width,s=t.height,o=Math.floor(i/(n+1)),l=Math.floor(i%(n+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,s=Math.floor(r/(n+1)),o=Math.floor(r%(n+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var n,i,a,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,f=new Uint8Array(d);for(r+=8+d,f.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<c;n++)a=(i=u[n]).duration,s=i.size,o=i.flags,l=i.cts,f.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),n=new Uint8Array(e.FTYP.byteLength+r.byteLength);return n.set(e.FTYP),n.set(r,e.FTYP.byteLength),n},e}();i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0,t.default=i},"./src/remux/mp4-remuxer.ts":
251
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=Math.pow(2,32)-1,n=function(){function t(){}return t.init=function(){var e;for(e in t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);t.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,l,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,n))},t.box=function(t){for(var e=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var s=i.length,a=s;s--;)e+=i[s].byteLength;var o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),s=0,e=8;s<a;s++)o.set(i[s],e),e+=i[s].byteLength;return o},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){r*=e;var n=Math.floor(r/(i+1)),s=Math.floor(r%(i+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var n=Math.floor(r/(i+1)),s=Math.floor(r%(i+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,a)},t.sdtp=function(e){var r,i,n=e.samples||[],s=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,s[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,n,s=[],a=[];for(r=0;r<e.sps.length;r++)n=(i=e.sps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)n=(i=e.pps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(a))),l=e.width,u=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,n=e.duration*e.timescale,s=e.width,a=e.height,o=Math.floor(n/(i+1)),l=Math.floor(n%(i+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},t.traf=function(e,r){var n=t.sdtp(e),s=e.id,a=Math.floor(r/(i+1)),o=Math.floor(r%(i+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(e,n.length+16+20+8+16+8+8),n)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,n,s,a,o,l,u=e.samples||[],d=u.length,c=12+16*d,h=new Uint8Array(c);for(r+=8+c,h.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)s=(n=u[i]).duration,a=n.size,o=n.flags,l=n.cts,h.set([s>>>24&255,s>>>16&255,s>>>8&255,255&s,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return t.box(t.types.trun,h)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();n.types=void 0,n.HDLR_TYPES=void 0,n.STTS=void 0,n.STSC=void 0,n.STCO=void 0,n.STSZ=void 0,n.VMHD=void 0,n.SMHD=void 0,n.STSD=void 0,n.FTYP=void 0,n.DINF=void 0,e.default=n},"./src/remux/mp4-remuxer.ts":
252
252
  /*!**********************************!*\
253
253
  !*** ./src/remux/mp4-remuxer.ts ***!
254
254
  \**********************************/
255
- /*! exports provided: default, normalizePts */function(e,t,r){r.r(t),r.d(t,"default",(function(){return p})),r.d(t,"normalizePts",(function(){return v}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),a=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var d=null,f=null,h=!1,p=function(){function e(e,t,r,n){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===d){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);d=i?parseInt(i[1]):0}if(null===f){var a=navigator.userAgent.match(/Safari\/(\d+)/i);f=a?parseInt(a[1]):0}h=!!d&&d<75||!!f&&f<600}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var n=r.pts-e;return n<-4294967296?(t=!0,v(e,r.pts)):n>0?e:r.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,n,i,a,s){var o,u,c,d,f,h,p=i,g=i,m=e.pid>-1,y=t.pid>-1,E=e.samples.length>0,_=t.samples.length>1;if((!m||E)&&(!y||_)||this.ISGenerated||s){this.ISGenerated||(c=this.generateIS(e,t,i));var T=this.isVideoContiguous;if(_&&!T&&this.config.forceKeyFrameOnDiscontinuity){var b=t.samples.length,A=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples);if(h=!0,A>0){l.logger.warn("[mp4-remuxer]: Dropped "+A+" out of "+b+" video samples due to a missing keyframe");var S=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(A),t.dropped+=A,g+=(t.samples[0].pts-S)/(t.timescale||9e4)}else-1===A&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+b+" video samples"),h=!1)}if(this.ISGenerated){if(E&&_){var w=this.getVideoStartPts(t.samples),L=(v(e.samples[0].pts,w)-w)/t.inputTimeScale;p+=Math.max(0,L),g+=Math.max(0,-L)}if(E){if(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),delete(c=this.generateIS(e,t,i)).video),u=this.remuxAudio(e,p,this.isAudioContiguous,a,_?g:void 0),_){var k=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,i)),o=this.remuxVideo(t,g,T,k)}}else _&&(o=this.remuxVideo(t,g,T,0));o&&void 0!==h&&(o.independent=h)}}return this.ISGenerated&&(r.samples.length&&(f=this.remuxID3(r,i)),n.samples.length&&(d=this.remuxText(n,i))),{audio:u,video:o,initSegment:c,independent:h,text:d,id3:f}},t.generateIS=function(e,t,r){var i,s,o,l=e.samples,u=t.samples,c=this.typeSupported,d={},f=!Object(n.isFiniteNumber)(this._initPTS),h="audio/mp4";if(f&&(i=s=1/0),e.config&&l.length&&(e.timescale=e.samplerate,e.isAAC||(c.mpeg?(h="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),d.audio={id:"audio",container:h,codec:e.codec,initSegment:!e.isAAC&&c.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(o=e.inputTimeScale,i=s=l[0].pts-Math.round(o*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},f)){o=t.inputTimeScale;var p=this.getVideoStartPts(u),g=Math.round(o*r);s=Math.min(s,v(u[0].dts,p)-g),i=Math.min(i,p-g)}if(Object.keys(d).length)return this.ISGenerated=!0,f&&(this._initPTS=i,this._initDTS=s),{tracks:d,initPTS:i,timescale:o}},t.remuxVideo=function(e,t,r,n){var i,f,p,m=e.inputTimeScale,y=e.samples,E=[],_=y.length,T=this._initPTS,b=this.nextAvcDts,A=8,S=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,L=0,k=!1;r&&null!==b||(b=t*m-(y[0].pts-v(y[0].dts,y[0].pts)));for(var R=0;R<_;R++){var D=y[R];D.pts=v(D.pts-T,b),D.dts=v(D.dts-T,b),D.dts>D.pts&&(L=Math.max(Math.min(L,D.pts-D.dts),-18e3)),D.dts<y[R>0?R-1:R].dts&&(k=!0)}k&&y.sort((function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n})),f=y[0].dts,p=y[y.length-1].dts;var O=Math.round((p-f)/(_-1));if(L<0){if(L<-2*O){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(u.toMsFromMpegTsClock)(-O,!0)+" ms");for(var C=L,I=0;I<_;I++)y[I].dts=C=Math.max(C,y[I].pts-O),y[I].pts=Math.max(C,y[I].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(u.toMsFromMpegTsClock)(L,!0)+" ms to overcome this issue");for(var x=0;x<_;x++)y[x].dts=y[x].dts+L}f=y[0].dts}if(r){var P=f-b,M=P>O;if(M||P<-1){M?l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(P,!0)+" ms ("+P+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected"),f=b;var F=y[0].pts-P;y[0].dts=f,y[0].pts=F,l.logger.log("Video: First PTS/DTS adjusted: "+Object(u.toMsFromMpegTsClock)(F,!0)+"/"+Object(u.toMsFromMpegTsClock)(f,!0)+", delta: "+Object(u.toMsFromMpegTsClock)(P,!0)+" ms")}}h&&(f=Math.max(0,f));for(var N=0,U=0,B=0;B<_;B++){for(var j=y[B],G=j.units,H=G.length,K=0,V=0;V<H;V++)K+=G[V].data.length;U+=K,N+=H,j.length=K,j.dts=Math.max(j.dts,f),j.pts=Math.max(j.pts,j.dts,0),S=Math.min(j.pts,S),w=Math.max(j.pts,w)}p=y[_-1].dts;var W,q=U+4*N+8;try{W=new Uint8Array(q)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:q,reason:"fail allocating video mdat "+q})}var z=new DataView(W.buffer);z.setUint32(0,q),W.set(a.default.types.mdat,4);for(var Y=0;Y<_;Y++){for(var X=y[Y],Q=X.units,Z=0,J=0,$=Q.length;J<$;J++){var ee=Q[J],te=ee.data,re=ee.data.byteLength;z.setUint32(A,re),A+=4,W.set(te,A),A+=re,Z+=4+re}if(Y<_-1)i=y[Y+1].dts-X.dts;else{var ne=this.config,ie=X.dts-y[Y>0?Y-1:Y].dts;if(ne.stretchShortVideoTrack&&null!==this.nextAudioPts){var ae=Math.floor(ne.maxBufferHole*m),se=(n?S+n*m:this.nextAudioPts)-X.pts;se>ae?((i=se-ie)<0&&(i=ie),l.logger.log("[mp4-remuxer]: It is approximately "+se/90+" ms to the next segment; using duration "+i/90+" ms for the last video frame.")):i=ie}else i=ie}var oe=Math.round(X.pts-X.dts);E.push(new g(X.key,i,Z,oe))}if(E.length&&d&&d<70){var le=E[0].flags;le.dependsOn=2,le.isNonSync=0}console.assert(void 0!==i,"mp4SampleDuration must be computed"),this.nextAvcDts=b=p+i,this.isVideoContiguous=!0;var ue={data1:a.default.moof(e.sequenceNumber++,f,c({},e,{samples:E})),data2:W,startPTS:S/m,endPTS:(w+i)/m,startDTS:f/m,endDTS:b/m,type:"video",hasAudio:!1,hasVideo:!0,nb:E.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(W.length,"MDAT length must not be zero"),ue},t.remuxAudio=function(e,t,r,n,u){var d,f=e.inputTimeScale,h=f/(e.samplerate?e.samplerate:f),p=e.isAAC?1024:1152,m=p*h,y=this._initPTS,E=!e.isAAC&&this.typeSupported.mpeg,_=[],T=e.samples,b=E?0:8,A=this.nextAudioPts||-1,S=t*f;if(this.isAudioContiguous=r=r||T.length&&A>0&&(n&&Math.abs(S-A)<9e3||Math.abs(v(T[0].pts-y,S)-A)<20*m),T.forEach((function(e){e.pts=e.dts=v(e.pts-y,S)})),!r||A<0){if(!(T=T.filter((function(e){return e.pts>=0}))).length)return;A=0===u?0:n?Math.max(0,S):T[0].pts}if(e.isAAC)for(var w=this.config.maxAudioFramesDrift,L=0,k=A;L<T.length;){var R=T[L],D=R.pts,O=D-k,C=Math.abs(1e3*O/f);if(O<=-w*m&&void 0!==u)r||L>0?(l.logger.warn("[mp4-remuxer]: Dropping 1 audio frame @ "+(k/f).toFixed(3)+"s due to "+Math.round(C)+" ms overlap."),T.splice(L,1)):(l.logger.warn("Audio frame @ "+(D/f).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/f)+" ms."),k=D+m,L++);else if(O>=w*m&&C<1e4&&void 0!==u){var I=Math.floor(O/m);k=D-I*m,l.logger.warn("[mp4-remuxer]: Injecting "+I+" audio frame @ "+(k/f).toFixed(3)+"s due to "+Math.round(1e3*O/f)+" ms gap.");for(var x=0;x<I;x++){var P=Math.max(k,0);(d=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),d=R.unit.subarray()),T.splice(L,0,{unit:d,pts:P,dts:P}),k+=m,L++}R.pts=R.dts=k,k+=m,L++}else R.pts=R.dts=k,k+=m,L++}for(var M,F=null,N=null,U=0,B=T.length;B--;)U+=T[B].unit.byteLength;for(var j=0,G=T.length;j<G;j++){var H=T[j],K=H.unit,V=H.pts;if(null!==N)_[j-1].duration=Math.round((V-N)/h);else{var W=Math.round(1e3*(V-A)/f),q=0;if(r&&e.isAAC){if(W>0&&W<1e4)q=Math.round((V-A)/m),l.logger.log("[mp4-remuxer]: "+W+" ms hole between AAC samples detected,filling it"),q>0&&((d=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(d=K.subarray()),U+=q*d.length);else if(W<-12){l.logger.log("[mp4-remuxer]: drop overlapping AAC sample, expected/parsed/delta:"+(A/f).toFixed(3)+"s/"+(V/f).toFixed(3)+"s/"+-W+"ms"),U-=K.byteLength;continue}V=A}if(F=V,!(U>0))return;U+=b;try{M=new Uint8Array(U)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:U,reason:"fail allocating audio mdat "+U})}E||(new DataView(M.buffer).setUint32(0,U),M.set(a.default.types.mdat,4));for(var z=0;z<q;z++)(d=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating the current frame instead"),d=K.subarray()),M.set(d,b),b+=d.byteLength,_.push(new g(!0,1024,d.byteLength,0))}M.set(K,b);var Y=K.byteLength;b+=Y,_.push(new g(!0,p,Y,0)),N=V}var X=_.length;if(X){var Q=_[_.length-1];this.nextAudioPts=A=N+h*Q.duration;var Z=E?new Uint8Array(0):a.default.moof(e.sequenceNumber++,F/h,c({},e,{samples:_}));e.samples=[];var J=F/f,$=A/f,ee={data1:Z,data2:M,startPTS:J,endPTS:$,startDTS:J,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:X};return this.isAudioContiguous=!0,console.assert(M.length,"MDAT length must not be zero"),ee}},t.remuxEmptyAudio=function(e,t,r,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,u=(null!==o?o:n.startDTS*a)+this._initDTS,c=n.endDTS*a+this._initDTS,d=1024*s,f=Math.ceil((c-u)/d),h=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),h){for(var p=[],v=0;v<f;v++){var g=u+v*d;p.push({unit:h,pts:g,dts:g})}return e.samples=p,this.remuxAudio(e,t,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},t.remuxID3=function(e,t){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,i=this._initPTS,a=this._initDTS,s=0;s<r;s++){var o=e.samples[s];o.pts=v(o.pts-i,t*n)/n,o.dts=v(o.dts-a,t*n)/n}var l=e.samples;return e.samples=[],{samples:l}}},t.remuxText=function(e,t){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,i=this._initPTS,a=0;a<r;a++){var s=e.samples[a];s.pts=v(s.pts-i,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}},e}();function v(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}var g=function(e,t,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=n,this.flags=new m(e)},m=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts":
255
+ /*! exports provided: default, normalizePts */function(t,e,r){r.r(e),r.d(e,"default",(function(){return p})),r.d(e,"normalizePts",(function(){return g}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function d(){return(d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var c=null,h=null,f=!1,p=function(){function t(t,e,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===c){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);c=n?parseInt(n[1]):0}if(null===h){var s=navigator.userAgent.match(/Safari\/(\d+)/i);h=s?parseInt(s[1]):0}f=!!c&&c<75||!!h&&h<600}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,g(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&l.logger.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,n,s,a){var o,u,d,c,h,f,p=n,m=n,v=t.pid>-1,y=e.pid>-1,E=t.samples.length>0,T=e.samples.length>1;if((!v||E)&&(!y||T)||this.ISGenerated||a){this.ISGenerated||(d=this.generateIS(t,e,n));var _=this.isVideoContiguous;if(T&&!_&&this.config.forceKeyFrameOnDiscontinuity){var b=e.samples.length,S=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples);if(f=!0,S>0){l.logger.warn("[mp4-remuxer]: Dropped "+S+" out of "+b+" video samples due to a missing keyframe");var A=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(S),e.dropped+=S,m+=(e.samples[0].pts-A)/(e.timescale||9e4)}else-1===S&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+b+" video samples"),f=!1)}if(this.ISGenerated){if(E&&T){var L=this.getVideoStartPts(e.samples),w=(g(t.samples[0].pts,L)-L)/e.inputTimeScale;p+=Math.max(0,w),m+=Math.max(0,-w)}if(E){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),delete(d=this.generateIS(t,e,n)).video),u=this.remuxAudio(t,p,this.isAudioContiguous,s,T?m:void 0),T){var k=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,n)),o=this.remuxVideo(e,m,_,k)}}else T&&(o=this.remuxVideo(e,m,_,0));o&&void 0!==f&&(o.independent=f)}}return this.ISGenerated&&(r.samples.length&&(h=this.remuxID3(r,n)),i.samples.length&&(c=this.remuxText(i,n))),{audio:u,video:o,initSegment:d,independent:f,text:c,id3:h}},e.generateIS=function(t,e,r){var n,a,o,l=t.samples,u=e.samples,d=this.typeSupported,c={},h=!Object(i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(h&&(n=a=1/0),t.config&&l.length&&(t.timescale=t.samplerate,t.isAAC||(d.mpeg?(f="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3")),c.audio={id:"audio",container:f,codec:t.codec,initSegment:!t.isAAC&&d.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},h&&(o=t.inputTimeScale,n=a=l[0].pts-Math.round(o*r))),e.sps&&e.pps&&u.length&&(e.timescale=e.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:s.default.initSegment([e]),metadata:{width:e.width,height:e.height}},h)){o=e.inputTimeScale;var p=this.getVideoStartPts(u),m=Math.round(o*r);a=Math.min(a,g(u[0].dts,p)-m),n=Math.min(n,p-m)}if(Object.keys(c).length)return this.ISGenerated=!0,h&&(this._initPTS=n,this._initDTS=a),{tracks:c,initPTS:n,timescale:o}},e.remuxVideo=function(t,e,r,i){var n,h,p,v=t.inputTimeScale,y=t.samples,E=[],T=y.length,_=this._initPTS,b=this.nextAvcDts,S=8,A=Number.POSITIVE_INFINITY,L=Number.NEGATIVE_INFINITY,w=0,k=!1;r&&null!==b||(b=e*v-(y[0].pts-g(y[0].dts,y[0].pts)));for(var R=0;R<T;R++){var D=y[R];D.pts=g(D.pts-_,b),D.dts=g(D.dts-_,b),D.dts>D.pts&&(w=Math.max(Math.min(w,D.pts-D.dts),-18e3)),D.dts<y[R>0?R-1:R].dts&&(k=!0)}k&&y.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),h=y[0].dts,p=y[y.length-1].dts;var O=Math.round((p-h)/(T-1));if(w<0){if(w<-2*O){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(u.toMsFromMpegTsClock)(-O,!0)+" ms");for(var I=w,C=0;C<T;C++)y[C].dts=I=Math.max(I,y[C].pts-O),y[C].pts=Math.max(I,y[C].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(u.toMsFromMpegTsClock)(w,!0)+" ms to overcome this issue");for(var P=0;P<T;P++)y[P].dts=y[P].dts+w}h=y[0].dts}if(r){var x=h-b,M=x>O;if(M||x<-1){M?l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(x,!0)+" ms ("+x+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(u.toMsFromMpegTsClock)(-x,!0)+" ms ("+x+"dts) overlapping between fragments detected"),h=b;var F=y[0].pts-x;y[0].dts=h,y[0].pts=F,l.logger.log("Video: First PTS/DTS adjusted: "+Object(u.toMsFromMpegTsClock)(F,!0)+"/"+Object(u.toMsFromMpegTsClock)(h,!0)+", delta: "+Object(u.toMsFromMpegTsClock)(x,!0)+" ms")}}f&&(h=Math.max(0,h));for(var N=0,U=0,B=0;B<T;B++){for(var G=y[B],j=G.units,H=j.length,K=0,V=0;V<H;V++)K+=j[V].data.length;U+=K,N+=H,G.length=K,G.dts=Math.max(G.dts,h),G.pts=Math.max(G.pts,G.dts,0),A=Math.min(G.pts,A),L=Math.max(G.pts,L)}p=y[T-1].dts;var q,W=U+4*N+8;try{q=new Uint8Array(W)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:W,reason:"fail allocating video mdat "+W})}var z=new DataView(q.buffer);z.setUint32(0,W),q.set(s.default.types.mdat,4);for(var Y=0;Y<T;Y++){for(var X=y[Y],Q=X.units,$=0,J=0,Z=Q.length;J<Z;J++){var tt=Q[J],et=tt.data,rt=tt.data.byteLength;z.setUint32(S,rt),S+=4,q.set(et,S),S+=rt,$+=4+rt}if(Y<T-1)n=y[Y+1].dts-X.dts;else{var it=this.config,nt=X.dts-y[Y>0?Y-1:Y].dts;if(it.stretchShortVideoTrack&&null!==this.nextAudioPts){var st=Math.floor(it.maxBufferHole*v),at=(i?A+i*v:this.nextAudioPts)-X.pts;at>st?((n=at-nt)<0&&(n=nt),l.logger.log("[mp4-remuxer]: It is approximately "+at/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=nt}else n=nt}var ot=Math.round(X.pts-X.dts);E.push(new m(X.key,n,$,ot))}if(E.length&&c&&c<70){var lt=E[0].flags;lt.dependsOn=2,lt.isNonSync=0}console.assert(void 0!==n,"mp4SampleDuration must be computed"),this.nextAvcDts=b=p+n,this.isVideoContiguous=!0;var ut={data1:s.default.moof(t.sequenceNumber++,h,d({},t,{samples:E})),data2:q,startPTS:A/v,endPTS:(L+n)/v,startDTS:h/v,endDTS:b/v,type:"video",hasAudio:!1,hasVideo:!0,nb:E.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(q.length,"MDAT length must not be zero"),ut},e.remuxAudio=function(t,e,r,i,u){var c,h=t.inputTimeScale,f=h/(t.samplerate?t.samplerate:h),p=t.isAAC?1024:1152,v=p*f,y=this._initPTS,E=!t.isAAC&&this.typeSupported.mpeg,T=[],_=t.samples,b=E?0:8,S=this.nextAudioPts||-1,A=e*h;if(this.isAudioContiguous=r=r||_.length&&S>0&&(i&&Math.abs(A-S)<9e3||Math.abs(g(_[0].pts-y,A)-S)<20*v),_.forEach((function(t){t.pts=t.dts=g(t.pts-y,A)})),!r||S<0){if(!(_=_.filter((function(t){return t.pts>=0}))).length)return;S=0===u?0:i?Math.max(0,A):_[0].pts}if(t.isAAC)for(var L=this.config.maxAudioFramesDrift,w=0,k=S;w<_.length;){var R=_[w],D=R.pts,O=D-k,I=Math.abs(1e3*O/h);if(O<=-L*v&&void 0!==u)r||w>0?(l.logger.warn("[mp4-remuxer]: Dropping 1 audio frame @ "+(k/h).toFixed(3)+"s due to "+Math.round(I)+" ms overlap."),_.splice(w,1)):(l.logger.warn("Audio frame @ "+(D/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/h)+" ms."),k=D+v,w++);else if(O>=L*v&&I<1e4&&void 0!==u){var C=Math.floor(O/v);k=D-C*v,l.logger.warn("[mp4-remuxer]: Injecting "+C+" audio frame @ "+(k/h).toFixed(3)+"s due to "+Math.round(1e3*O/h)+" ms gap.");for(var P=0;P<C;P++){var x=Math.max(k,0);(c=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount))||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),c=R.unit.subarray()),_.splice(w,0,{unit:c,pts:x,dts:x}),k+=v,w++}R.pts=R.dts=k,k+=v,w++}else R.pts=R.dts=k,k+=v,w++}for(var M,F=null,N=null,U=0,B=_.length;B--;)U+=_[B].unit.byteLength;for(var G=0,j=_.length;G<j;G++){var H=_[G],K=H.unit,V=H.pts;if(null!==N)T[G-1].duration=Math.round((V-N)/f);else{var q=Math.round(1e3*(V-S)/h),W=0;if(r&&t.isAAC){if(q>0&&q<1e4)W=Math.round((V-S)/v),l.logger.log("[mp4-remuxer]: "+q+" ms hole between AAC samples detected,filling it"),W>0&&((c=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount))||(c=K.subarray()),U+=W*c.length);else if(q<-12){l.logger.log("[mp4-remuxer]: drop overlapping AAC sample, expected/parsed/delta:"+(S/h).toFixed(3)+"s/"+(V/h).toFixed(3)+"s/"+-q+"ms"),U-=K.byteLength;continue}V=S}if(F=V,!(U>0))return;U+=b;try{M=new Uint8Array(U)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:U,reason:"fail allocating audio mdat "+U})}E||(new DataView(M.buffer).setUint32(0,U),M.set(s.default.types.mdat,4));for(var z=0;z<W;z++)(c=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount))||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating the current frame instead"),c=K.subarray()),M.set(c,b),b+=c.byteLength,T.push(new m(!0,1024,c.byteLength,0))}M.set(K,b);var Y=K.byteLength;b+=Y,T.push(new m(!0,p,Y,0)),N=V}var X=T.length;if(X){var Q=T[T.length-1];this.nextAudioPts=S=N+f*Q.duration;var $=E?new Uint8Array(0):s.default.moof(t.sequenceNumber++,F/f,d({},t,{samples:T}));t.samples=[];var J=F/h,Z=S/h,tt={data1:$,data2:M,startPTS:J,endPTS:Z,startDTS:J,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:X};return this.isAudioContiguous=!0,console.assert(M.length,"MDAT length must not be zero"),tt}},e.remuxEmptyAudio=function(t,e,r,i){var s=t.inputTimeScale,a=s/(t.samplerate?t.samplerate:s),o=this.nextAudioPts,u=(null!==o?o:i.startDTS*s)+this._initDTS,d=i.endDTS*s+this._initDTS,c=1024*a,h=Math.ceil((d-u)/c),f=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var p=[],g=0;g<h;g++){var m=u+g*c;p.push({unit:f,pts:m,dts:m})}return t.samples=p,this.remuxAudio(t,e,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e.remuxID3=function(t,e){var r=t.samples.length;if(r){for(var i=t.inputTimeScale,n=this._initPTS,s=this._initDTS,a=0;a<r;a++){var o=t.samples[a];o.pts=g(o.pts-n,e*i)/i,o.dts=g(o.dts-s,e*i)/i}var l=t.samples;return t.samples=[],{samples:l}}},e.remuxText=function(t,e){var r=t.samples.length;if(r){for(var i=t.inputTimeScale,n=this._initPTS,s=0;s<r;s++){var a=t.samples[s];a.pts=g(a.pts-n,e*i)/i}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}},t}();function g(t,e){var r;if(null===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t}var m=function(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new v(t)},v=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
256
256
  /*!******************************************!*\
257
257
  !*** ./src/remux/passthrough-remuxer.ts ***!
258
258
  \******************************************/
259
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndDTS=null},t.resetNextTimestamp=function(){this.lastEndDTS=null},t.resetInitSegment=function(e,t,r){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=Object(i.parseInitSegment)(e);t||(t=u(n.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=u(n.video,a.ElementaryStreamTypes.VIDEO));var o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?o.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:s.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},t.remux=function(e,t,r,a,o){var u=this.initPTS,c=this.lastEndDTS,d={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};Object(n.isFiniteNumber)(c)||(c=this.lastEndDTS=o||0);var f=t.samples;if(!f||!f.length)return d;var h={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(f),p=this.initData),!p||!p.length)return s.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1),Object(n.isFiniteNumber)(u)||(this.initPTS=h.initPTS=u=l(p,f,c));var v=Object(i.getDuration)(f,p),g=c,m=v+g;Object(i.offsetStartDTS)(p,f,u),v>0?this.lastEndDTS=m:(s.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!p.audio,E=!!p.video,_="";y&&(_+="audio"),E&&(_+="video");var T={data1:f,startPTS:g,startDTS:g,endPTS:m,endDTS:m,type:_,hasAudio:y,hasVideo:E,nb:1,dropped:0};return d.audio="audio"===T.type?T:void 0,d.video="audio"!==T.type?T:void 0,d.text=a,d.id3=r,d.initSegment=h,d},e}(),l=function(e,t,r){return Object(i.getStartDTS)(e,t)-r};function u(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}t.default=o},"./src/task-loop.ts":
259
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function t(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndDTS=null},e.resetNextTimestamp=function(){this.lastEndDTS=null},e.resetInitSegment=function(t,e,r){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(t),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Object(n.parseInitSegment)(t);e||(e=u(i.audio,s.ElementaryStreamTypes.AUDIO)),r||(r=u(i.video,s.ElementaryStreamTypes.VIDEO));var o={};i.audio&&i.video?o.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?o.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:a.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},e.remux=function(t,e,r,s,o){var u=this.initPTS,d=this.lastEndDTS,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};Object(i.isFiniteNumber)(d)||(d=this.lastEndDTS=o||0);var h=e.samples;if(!h||!h.length)return c;var f={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(h),p=this.initData),!p||!p.length)return a.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object(i.isFiniteNumber)(u)||(this.initPTS=f.initPTS=u=l(p,h,d));var g=Object(n.getDuration)(h,p),m=d,v=g+m;Object(n.offsetStartDTS)(p,h,u),g>0?this.lastEndDTS=v:(a.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!p.audio,E=!!p.video,T="";y&&(T+="audio"),E&&(T+="video");var _={data1:h,startPTS:m,startDTS:m,endPTS:v,endDTS:v,type:T,hasAudio:y,hasVideo:E,nb:1,dropped:0};return c.audio="audio"===_.type?_:void 0,c.video="audio"!==_.type?_:void 0,c.text=s,c.id3=r,c.initSegment=f,c},t}(),l=function(t,e,r){return Object(n.getStartDTS)(t,e)-r};function u(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=o},"./src/task-loop.ts":
260
260
  /*!**************************!*\
261
261
  !*** ./src/task-loop.ts ***!
262
262
  \**************************/
263
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},t.doTick=function(){},e}()},"./src/types/level.ts":
263
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},e.doTick=function(){},t}()},"./src/types/level.ts":
264
264
  /*!****************************!*\
265
265
  !*** ./src/types/level.ts ***!
266
266
  \****************************/
267
- /*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(e,t,r){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i;function a(e,t){var r=e.canSkipUntil,n=e.canSkipDateRanges,a=e.endSN;return r&&(void 0!==t?t-a:0)<r?n?i.v2:i.Yes:i.No}r.r(t),r.d(t,"HlsSkip",(function(){return i})),r.d(t,"getSkipValue",(function(){return a})),r.d(t,"HlsUrlParameters",(function(){return s})),r.d(t,"Level",(function(){return o})),function(e){e.No="",e.Yes="YES",e.v2="v2"}(i||(i={}));var s=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.toString()},e}(),o=function(){function e(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this.attrs=e.attrs,this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}var t,r,i;return t=e,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.details=void 0,this._urlId=t)}}])&&n(t.prototype,r),i&&n(t,i),e}()},"./src/types/loader.ts":
267
+ /*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,e,r){function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var n;function s(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,s=t.endSN;return r&&(void 0!==e?e-s:0)<r?i?n.v2:n.Yes:n.No}r.r(e),r.d(e,"HlsSkip",(function(){return n})),r.d(e,"getSkipValue",(function(){return s})),r.d(e,"HlsUrlParameters",(function(){return a})),r.d(e,"Level",(function(){return o})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(n||(n={}));var a=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.toString()},t}(),o=function(){function t(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var e,r,n;return e=t,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.details=void 0,this._urlId=e)}}])&&i(e.prototype,r),n&&i(e,n),t}()},"./src/types/loader.ts":
268
268
  /*!*****************************!*\
269
269
  !*** ./src/types/loader.ts ***!
270
270
  \*****************************/
271
- /*! exports provided: PlaylistContextType, PlaylistLevelType */function(e,t,r){var n,i;r.r(t),r.d(t,"PlaylistContextType",(function(){return n})),r.d(t,"PlaylistLevelType",(function(){return i})),function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(n||(n={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(i||(i={}))},"./src/types/transmuxer.ts":
271
+ /*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,e,r){var i,n;r.r(e),r.d(e,"PlaylistContextType",(function(){return i})),r.d(e,"PlaylistLevelType",(function(){return n})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(i||(i={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(n||(n={}))},"./src/types/transmuxer.ts":
272
272
  /*!*********************************!*\
273
273
  !*** ./src/types/transmuxer.ts ***!
274
274
  \*********************************/
275
- /*! exports provided: ChunkMetadata */function(e,t,r){r.r(t),r.d(t,"ChunkMetadata",(function(){return n}));var n=function(e,t,r,n,i,a){void 0===n&&(n=0),void 0===i&&(i=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=n,this.part=i,this.partial=a}},"./src/utils/attr-list.ts":
275
+ /*! exports provided: ChunkMetadata */function(t,e,r){r.r(e),r.d(e,"ChunkMetadata",(function(){return i}));var i=function(t,e,r,i,n,s){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===s&&(s=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=n,this.partial=s}},"./src/utils/attr-list.ts":
276
276
  /*!********************************!*\
277
277
  !*** ./src/utils/attr-list.ts ***!
278
278
  \********************************/
279
- /*! exports provided: AttrList */function(e,t,r){r.r(t),r.d(t,"AttrList",(function(){return a}));var n=/^(\d+)x(\d+)$/,i=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=n.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(i.lastIndex=0;null!==(t=i.exec(e));){var n=t[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),r[t[1]]=n}return r},e}()},"./src/utils/binary-search.ts":
279
+ /*! exports provided: AttrList */function(t,e,r){r.r(e),r.d(e,"AttrList",(function(){return s}));var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&(this[r]=e[r])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r}return null},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=i.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(n.lastIndex=0;null!==(e=n.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}()},"./src/utils/binary-search.ts":
280
280
  /*!************************************!*\
281
281
  !*** ./src/utils/binary-search.ts ***!
282
282
  \************************************/
283
- /*! exports provided: default */function(e,t,r){r.r(t),t.default={search:function(e,t){for(var r=0,n=e.length-1,i=null,a=null;r<=n;){var s=t(a=e[i=(r+n)/2|0]);if(s>0)r=i+1;else{if(!(s<0))return a;n=i-1}}return null}}},"./src/utils/buffer-helper.ts":
283
+ /*! exports provided: default */function(t,e,r){r.r(e),e.default={search:function(t,e){for(var r=0,i=t.length-1,n=null,s=null;r<=i;){var a=e(s=t[n=(r+i)/2|0]);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null}}},"./src/utils/buffer-helper.ts":
284
284
  /*!************************************!*\
285
285
  !*** ./src/utils/buffer-helper.ts ***!
286
286
  \************************************/
287
- /*! exports provided: BufferHelper */function(e,t,r){r.r(t),r.d(t,"BufferHelper",(function(){return a}));var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var n=e.getBuffered(t),i=0;i<n.length;i++)if(r>=n.start(i)&&r<=n.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,n){try{if(t){var i,a=e.getBuffered(t),s=[];for(i=0;i<a.length;i++)s.push({start:a.start(i),end:a.end(i)});return this.bufferedInfo(s,r,n)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(r)for(var i=0;i<e.length;i++){var a=n.length;if(a){var s=n[a-1].end;e[i].start-s<r?e[i].end>s&&(n[a-1].end=e[i].end):n.push(e[i])}else n.push(e[i])}else n=e;for(var o,l=0,u=t,c=t,d=0;d<n.length;d++){var f=n[d].start,h=n[d].end;if(t+r>=f&&t<h)u=f,l=(c=h)-t;else if(t+r<f){o=f;break}}return{len:l,start:u||0,end:c||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return n.logger.log("failed to get media.buffered",e),i}},e}()},"./src/utils/cea-608-parser.ts":
287
+ /*! exports provided: BufferHelper */function(t,e,r){r.r(e),r.d(e,"BufferHelper",(function(){return s}));var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var n,s=t.getBuffered(e),a=[];for(n=0;n<s.length;n++)a.push({start:s.start(n),end:s.end(n)});return this.bufferedInfo(a,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,e,r){t.sort((function(t,e){var r=t.start-e.start;return r||e.end-t.end}));var i=[];if(r)for(var n=0;n<t.length;n++){var s=i.length;if(s){var a=i[s-1].end;t[n].start-a<r?t[n].end>a&&(i[s-1].end=t[n].end):i.push(t[n])}else i.push(t[n])}else i=t;for(var o,l=0,u=e,d=e,c=0;c<i.length;c++){var h=i[c].start,f=i[c].end;if(e+r>=h&&e<f)u=h,l=(d=f)-e;else if(e+r<h){o=h;break}}return{len:l,start:u||0,end:d||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return i.logger.log("failed to get media.buffered",t),n}},t}()},"./src/utils/cea-608-parser.ts":
288
288
  /*!*************************************!*\
289
289
  !*** ./src/utils/cea-608-parser.ts ***!
290
290
  \*************************************/
291
- /*! exports provided: Row, CaptionScreen, default */function(e,t,r){r.r(t),r.d(t,"Row",(function(){return g})),r.d(t,"CaptionScreen",(function(){return m}));var n,i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},s=function(e){var t=e;return a.hasOwnProperty(e)&&(t=a[e]),String.fromCharCode(t)},o={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},u={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},d=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(e){e[e.ERROR=0]="ERROR",e[e.TEXT=1]="TEXT",e[e.WARNING=2]="WARNING",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.DATA=3]="DATA"}(n||(n={}));var f=function(){function e(){this.time=null,this.verboseLevel=n.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&i.logger.log(this.time+" ["+e+"] "+t)},e}(),h=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},p=function(){function e(e,t,r,n,i){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=n||"black",this.flash=i||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var n=t[r];e.hasOwnProperty(n)&&(this[n]=e[n])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),v=function(){function e(e,t,r,n,i,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new p(t,r,n,i,a)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),g=function(){function e(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<100;t++)this.chars.push(new v);this.logger=e,this.pos=0,this.currPenState=new p}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<100;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<100;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<100;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(n.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(n.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=s(e);this.pos>=100?this.logger.log(n.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<100;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<100;r++){var n=this.chars[r].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),m=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<15;t++)this.rows.push(new g(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(n.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(n.INFO,"pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<15;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var s=a.rows[i].cueStartTime,o=this.logger.time;if(s&&null!==o&&s<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[i+l])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var c=e.indent,d=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)},t.setBkgData=function(e){this.logger.log(n.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(n.TEXT,this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(n.INFO,"Rolling up")}else this.logger.log(n.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",n=-1,i=0;i<15;i++){var a=this.rows[i].getTextString();a&&(n=i+1,e?t.push("Row "+n+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),y=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new m(r),this.nonDisplayedMemory=new m(r),this.lastOutputScreen=new m(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(n.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(n.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(n.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(n.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(n.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(n.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(n.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(n.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(n.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(n.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(n.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(n.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(n.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(n.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(this.logger.log(n.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(n.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(n.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(n.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),E=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new f;this.channels=[null,new y(e,t,n),new y(e+1,r,n)],this.cmdHistory={a:null,b:null},this.logger=n}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i,a,s=!1;this.logger.time=e;for(var o=0;o<t.length;o+=2)if(i=127&t[o],a=127&t[o+1],0!==i||0!==a){if(this.logger.log(n.DATA,"["+h([t[o],t[o+1]])+"] -> ("+h([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(s=this.parseChars(i,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(s):this.logger.log(n.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(n.WARNING,"Couldn't parse cleaned data "+h([i,a])+" orig: "+h([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(T(e,t,r))return _(null,null,r),this.logger.log(n.DEBUG,"Repeated command ("+h([e,t])+") is dropped"),!0;var i=20===e||21===e||23===e?1:2,a=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?a.ccRCL():33===t?a.ccBS():34===t?a.ccAOF():35===t?a.ccAON():36===t?a.ccDER():37===t?a.ccRU(2):38===t?a.ccRU(3):39===t?a.ccRU(4):40===t?a.ccFON():41===t?a.ccRDC():42===t?a.ccTR():43===t?a.ccRTD():44===t?a.ccEDM():45===t?a.ccCR():46===t?a.ccENM():47===t&&a.ccEOC():a.ccTO(t-32),_(e,t,r),this.currentChannel=i,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(n.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(n.DEBUG,"MIDROW ("+h([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,n=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(T(e,t,n))return _(null,null,n),!0;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?o[e]:u[e]:1===i?l[e]:c[e];var a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(r,t)),_(e,t,n),this.currentChannel=i,!0)},t.interpretPAC=function(e,t){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,n.underline=1==(1&r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n},t.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=17===o?t+80:18===o?t+112:t+144,this.logger.log(n.INFO,"Special char '"+s(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]),a){var l=h(a);this.logger.log(n.DEBUG,"Char codes = "+l.join(",")),_(e,t,this.cmdHistory)}return a},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(r=Math.floor((t-32)/2),n.background=d[r],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var i=e<=23?1:2;return this.channels[i].setBkgData(n),_(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}();function _(e,t,r){r.a=e,r.b=t}function T(e,t,r){return r.a===e&&r.b===t}t.default=E},"./src/utils/codecs.ts":
291
+ /*! exports provided: Row, CaptionScreen, default */function(t,e,r){r.r(e),r.d(e,"Row",(function(){return m})),r.d(e,"CaptionScreen",(function(){return v}));var i,n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},a=function(t){var e=t;return s.hasOwnProperty(t)&&(e=s[t]),String.fromCharCode(e)},o={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},u={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},d={25:2,26:4,29:6,30:8,31:10,27:13,28:15},c=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(i||(i={}));var h=function(){function t(){this.time=null,this.verboseLevel=i.ERROR}return t.prototype.log=function(t,e){this.verboseLevel>=t&&n.logger.log(this.time+" ["+t+"] "+e)},t}(),f=function(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r].toString(16));return e},p=function(){function t(t,e,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var e=t.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],r=0;r<e.length;r++){var i=e[r];t.hasOwnProperty(i)&&(this[i]=t[i])}},e.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),g=function(){function t(t,e,r,i,n,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(e,r,i,n,s)}var e=t.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,e){this.uchar=t,this.penState.copy(e)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),m=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var e=0;e<100;e++)this.chars.push(new g);this.logger=t,this.pos=0,this.currPenState=new p}var e=t.prototype;return e.equals=function(t){for(var e=!0,r=0;r<100;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<100;e++)this.chars[e].copy(t.chars[e])},e.isEmpty=function(){for(var t=!0,e=0;e<100;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(i.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(i.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){t>=144&&this.backSpace();var e=a(t);this.pos>=100?this.logger.log(i.ERROR,"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))},e.clearFromPos=function(t){var e;for(e=t;e<100;e++)this.chars[e].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],e=!0,r=0;r<100;r++){var i=this.chars[r].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),v=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new m(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=t.prototype;return e.reset=function(){for(var t=0;t<15;t++)this.rows[t].clear();this.currRow=14},e.equals=function(t){for(var e=!0,r=0;r<15;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e},e.copy=function(t){for(var e=0;e<15;e++)this.rows[e].copy(t.rows[e])},e.isEmpty=function(){for(var t=!0,e=0;e<15;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t},e.backSpace=function(){this.rows[this.currRow].backSpace()},e.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},e.insertChar=function(t){this.rows[this.currRow].insertChar(t)},e.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},e.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},e.setCursor=function(t){this.logger.log(i.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},e.setPAC=function(t){this.logger.log(i.INFO,"pacData = "+JSON.stringify(t));var e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(var r=0;r<15;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[n].cueStartTime,o=this.logger.time;if(a&&null!==o&&a<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[e-this.nrRollUpRows+l+1].copy(s.rows[n+l])}}this.currRow=e;var u=this.rows[this.currRow];if(null!==t.indent){var d=t.indent,c=Math.max(d-1,0);u.setCursor(t.indent),t.color=u.chars[c].penState.foreground}var h={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(h)},e.setBkgData=function(t){this.logger.log(i.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(i.TEXT,this.getDisplayText());var t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(i.INFO,"Rolling up")}else this.logger.log(i.DEBUG,"roll_up but nrRollUpRows not set yet")},e.getDisplayText=function(t){t=t||!1;for(var e=[],r="",i=-1,n=0;n<15;n++){var s=this.rows[n].getTextString();s&&(i=n+1,t?e.push("Row "+i+": '"+s+"'"):e.push(s.trim()))}return e.length>0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},e.getTextAndFormat=function(){return this.rows},t}(),y=function(){function t(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new v(r),this.nonDisplayedMemory=new v(r),this.lastOutputScreen=new v(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(i.INFO,"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=0;e<t.length;e++)this.writeScreen.insertChar(t[e]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(i.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(i.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(i.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(i.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(i.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(i.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(i.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(i.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(i.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(i.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(i.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(i.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(i.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){if(this.logger.log(i.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(i.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(i.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(i.INFO,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),E=function(){function t(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new h;this.channels=[null,new y(t,e,i),new y(t+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var r,n,s,a=!1;this.logger.time=t;for(var o=0;o<e.length;o+=2)if(n=127&e[o],s=127&e[o+1],0!==n||0!==s){if(this.logger.log(i.DATA,"["+f([e[o],e[o+1]])+"] -> ("+f([n,s])+")"),(r=this.parseCmd(n,s))||(r=this.parseMidrow(n,s)),r||(r=this.parsePAC(n,s)),r||(r=this.parseBackgroundAttributes(n,s)),!r&&(a=this.parseChars(n,s))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(i.WARNING,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(i.WARNING,"Couldn't parse cleaned data "+f([n,s])+" orig: "+f([e[o],e[o+1]]))}},e.parseCmd=function(t,e){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(_(t,e,r))return T(null,null,r),this.logger.log(i.DEBUG,"Repeated command ("+f([t,e])+") is dropped"),!0;var n=20===t||21===t||23===t?1:2,s=this.channels[n];return 20===t||21===t||28===t||29===t?32===e?s.ccRCL():33===e?s.ccBS():34===e?s.ccAOF():35===e?s.ccAON():36===e?s.ccDER():37===e?s.ccRU(2):38===e?s.ccRU(3):39===e?s.ccRU(4):40===e?s.ccFON():41===e?s.ccRDC():42===e?s.ccTR():43===e?s.ccRTD():44===e?s.ccEDM():45===e?s.ccCR():46===e?s.ccENM():47===e&&s.ccEOC():s.ccTO(e-32),T(t,e,r),this.currentChannel=n,!0},e.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(i.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(e),this.logger.log(i.DEBUG,"MIDROW ("+f([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var r,i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(_(t,e,i))return T(null,null,i),!0;var n=t<=23?1:2;r=e>=64&&e<=95?1===n?o[t]:u[t]:1===n?l[t]:d[t];var s=this.channels[n];return!!s&&(s.setPAC(this.interpretPAC(r,e)),T(t,e,i),this.currentChannel=n,!0)},e.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},e.parseChars=function(t,e){var r,n,s=null,o=null;if(t>=25?(r=2,o=t-8):(r=1,o=t),o>=17&&o<=19?(n=17===o?e+80:18===o?e+112:e+144,this.logger.log(i.INFO,"Special char '"+a(n)+"' in channel "+r),s=[n]):t>=32&&t<=127&&(s=0===e?[t]:[t,e]),s){var l=f(s);this.logger.log(i.DEBUG,"Char codes = "+l.join(",")),T(t,e,this.cmdHistory)}return s},e.parseBackgroundAttributes=function(t,e){var r;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var i={};16===t||24===t?(r=Math.floor((e-32)/2),i.background=c[r],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(i),T(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var e=this.channels[t];e&&e.reset()}this.cmdHistory={a:null,b:null}},e.cueSplitAtTime=function(t){for(var e=0;e<this.channels.length;e++){var r=this.channels[e];r&&r.cueSplitAtTime(t)}},t}();function T(t,e,r){r.a=t,r.b=e}function _(t,e,r){return r.a===t&&r.b===e}e.default=E},"./src/utils/codecs.ts":
292
292
  /*!*****************************!*\
293
293
  !*** ./src/utils/codecs.ts ***!
294
294
  \*****************************/
295
- /*! exports provided: isCodecType, isCodecSupportedInMp4 */function(e,t,r){r.r(t),r.d(t,"isCodecType",(function(){return i})),r.d(t,"isCodecSupportedInMp4",(function(){return a}));var n={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function i(e,t){var r=n[t];return!!r&&!0===r[e.slice(0,4)]}function a(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},"./src/utils/cues.ts":
295
+ /*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,e,r){r.r(e),r.d(e,"isCodecType",(function(){return n})),r.d(e,"isCodecSupportedInMp4",(function(){return s}));var i={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function n(t,e){var r=i[e];return!!r&&!0===r[t.slice(0,4)]}function s(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
296
296
  /*!***************************!*\
297
297
  !*** ./src/utils/cues.ts ***!
298
298
  \***************************/
299
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),i=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),a=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),s=/\s/,o={newCue:function(e,t,r,o){for(var l,u,c,d,f,h=[],p=self.VTTCue||self.TextTrackCue,v=0;v<o.rows.length;v++)if(c=!0,d=0,f="",!(l=o.rows[v]).isEmpty()){for(var g=0;g<l.chars.length;g++)s.test(l.chars[g].uchar)&&c?d++:(f+=l.chars[g].uchar,c=!1);l.cueStartTime=t,t===r&&(r+=1e-4),d>=16?d--:d++;var m=Object(n.fixLineBreaks)(f.trim()),y=Object(i.generateCueId)(t,r,m);e&&e.cues&&e.cues.getCueById(y)||((u=new p(t,r,m)).id=y,u.line=v+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*d/32)),h.push(u))}return e&&h.length&&(h.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),h.forEach((function(t){return Object(a.addCueToTrack)(e,t)}))),h}};t.default=o},"./src/utils/discontinuities.ts":
299
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/,o={newCue:function(t,e,r,o){for(var l,u,d,c,h,f=[],p=self.VTTCue||self.TextTrackCue,g=0;g<o.rows.length;g++)if(d=!0,c=0,h="",!(l=o.rows[g]).isEmpty()){for(var m=0;m<l.chars.length;m++)a.test(l.chars[m].uchar)&&d?c++:(h+=l.chars[m].uchar,d=!1);l.cueStartTime=e,e===r&&(r+=1e-4),c>=16?c--:c++;var v=Object(i.fixLineBreaks)(h.trim()),y=Object(n.generateCueId)(e,r,v);t&&t.cues&&t.cues.getCueById(y)||((u=new p(e,r,v)).id=y,u.line=g+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*c/32)),f.push(u))}return t&&f.length&&(f.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),f.forEach((function(e){return Object(s.addCueToTrack)(t,e)}))),f}};e.default=o},"./src/utils/discontinuities.ts":
300
300
  /*!**************************************!*\
301
301
  !*** ./src/utils/discontinuities.ts ***!
302
302
  \**************************************/
303
- /*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT */function(e,t,r){r.r(t),r.d(t,"findFirstFragWithCC",(function(){return s})),r.d(t,"shouldAlignOnDiscontinuities",(function(){return o})),r.d(t,"findDiscontinuousReferenceFrag",(function(){return l})),r.d(t,"adjustSlidingStart",(function(){return c})),r.d(t,"alignStream",(function(){return d})),r.d(t,"alignPDT",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./logger */"./src/utils/logger.ts"),a=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function s(e,t){for(var r=null,n=0,i=e.length;n<i;n++){var a=e[n];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function l(e,t){var r=e.fragments,n=t.fragments;if(n.length&&r.length){var a=s(r,n[0].cc);if(a&&(!a||a.startPTS))return a;i.logger.log("No frag in previous level to align on")}else i.logger.log("No fragments to align")}function u(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function c(e,t){for(var r=t.fragments,n=0,i=r.length;n<i;n++)u(r[n],e);t.fragmentHint&&u(t.fragmentHint,e),t.alignedSliding=!0}function d(e,t,r){t&&(function(e,t,r){if(o(e,r,t)){var a=l(r.details,t);a&&Object(n.isFiniteNumber)(a.start)&&(i.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),c(a.start,t))}}(e,r,t),!r.alignedSliding&&t.details&&f(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||Object(a.adjustSliding)(t.details,r))}function f(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,s=(a-r)/1e3+t.fragments[0].start;s&&Object(n.isFiniteNumber)(s)&&(i.logger.log("Adjusting PTS using programDateTime delta "+(a-r)+"ms, sliding:"+s.toFixed(3)+" "+e.url+" "),c(s,e))}}},"./src/utils/ewma-bandwidth-estimator.ts":
303
+ /*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT */function(t,e,r){r.r(e),r.d(e,"findFirstFragWithCC",(function(){return a})),r.d(e,"shouldAlignOnDiscontinuities",(function(){return o})),r.d(e,"findDiscontinuousReferenceFrag",(function(){return l})),r.d(e,"adjustSlidingStart",(function(){return d})),r.d(e,"alignStream",(function(){return c})),r.d(e,"alignPDT",(function(){return h}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./logger */"./src/utils/logger.ts"),s=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,e){for(var r=null,i=0,n=t.length;i<n;i++){var s=t[i];if(s&&s.cc===e){r=s;break}}return r}function o(t,e,r){return!(!e.details||!(r.endCC>r.startCC||t&&t.cc<r.startCC))}function l(t,e){var r=t.fragments,i=e.fragments;if(i.length&&r.length){var s=a(r,i[0].cc);if(s&&(!s||s.startPTS))return s;n.logger.log("No frag in previous level to align on")}else n.logger.log("No fragments to align")}function u(t,e){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function d(t,e){for(var r=e.fragments,i=0,n=r.length;i<n;i++)u(r[i],t);e.fragmentHint&&u(e.fragmentHint,t),e.alignedSliding=!0}function c(t,e,r){e&&(function(t,e,r){if(o(t,r,e)){var s=l(r.details,e);s&&Object(i.isFiniteNumber)(s.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),d(s.start,e))}}(t,r,e),!r.alignedSliding&&e.details&&h(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||Object(s.adjustSliding)(e.details,r))}function h(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-r)/1e3+e.fragments[0].start;a&&Object(i.isFiniteNumber)(a)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(s-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),d(a,t))}}},"./src/utils/ewma-bandwidth-estimator.ts":
304
304
  /*!***********************************************!*\
305
305
  !*** ./src/utils/ewma-bandwidth-estimator.ts ***!
306
306
  \***********************************************/
307
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../utils/ewma */"./src/utils/ewma.ts"),i=function(){function e(e,t,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(e),this.fast_=new n.default(t)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new n.default(e,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new n.default(t,i.getEstimate(),i.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/r;this.fast_.sample(r,n),this.slow_.sample(r,n)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();t.default=i},"./src/utils/ewma.ts":
307
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/ewma */"./src/utils/ewma.ts"),n=function(){function t(t,e,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new i.default(t),this.fast_=new i.default(e)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new i.default(t,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new i.default(e,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.destroy=function(){},t}();e.default=n},"./src/utils/ewma.ts":
308
308
  /*!***************************!*\
309
309
  !*** ./src/utils/ewma.ts ***!
310
310
  \***************************/
311
- /*! exports provided: default */function(e,t,r){r.r(t);var n=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}();t.default=n},"./src/utils/fetch-loader.ts":
311
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}();e.default=i},"./src/utils/fetch-loader.ts":
312
312
  /*!***********************************!*\
313
313
  !*** ./src/utils/fetch-loader.ts ***!
314
314
  \***********************************/
315
- /*! exports provided: fetchSupported, default */function(e,t,r){r.r(t),r.d(t,"fetchSupported",(function(){return d}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function o(e,t,r){return(o=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&u(i,r.prototype),i}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var f=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||h,this.controller=new self.AbortController,this.stats=new i.LoadStats}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t};return e.rangeEnd&&(r.headers=new self.Headers({Range:"bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)})),r}(e,this.controller.signal),o=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,e,i.response)}),t.timeout),self.fetch(this.request).then((function(r){if(i.response=i.loader=r,!r.ok){var s=r.status,u=r.statusText;throw new p(u||"fetch, bad network response",s,r)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),o&&Object(n.isFiniteNumber)(t.highWaterMark)?i.loadProgressively(r,a,e,t.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(s){var l=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=s[u];var c={url:l.url,data:s};o&&!Object(n.isFiniteNumber)(t.highWaterMark)&&o(a,e,s,l),r.onSuccess(c,a,e,l)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=t.code||0;r.onError({code:n,text:t.message},e,t.details)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.loadProgressively=function(e,t,r,n,i){void 0===n&&(n=0);var s=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return s.dataLength&&i(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return t.loaded+=u,u<n||s.dataLength?(s.push(l),s.dataLength>=n&&i(t,r,s.flush(),e)):i(t,r,l,e),a()})).catch((function(){return Promise.reject()}))}()},e}();function h(e,t){return new self.Request(e.url,t)}var p=function(e){var t,r;function n(t,r,n){var i;return(i=e.call(this,t)||this).code=void 0,i.details=void 0,i.code=r,i.details=n,i}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,u(t,r),n}(s(Error));t.default=f},"./src/utils/imsc1-ttml-parser.ts":
315
+ /*! exports provided: fetchSupported, default */function(t,e,r){r.r(e),r.d(e,"fetchSupported",(function(){return c}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return o(t,arguments,d(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),u(i,t)})(t)}function o(t,e,r){return(o=l()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&u(n,r.prototype),n}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var h=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||f,this.controller=new self.AbortController,this.stats=new n.LoadStats}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var n=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e};return t.rangeEnd&&(r.headers=new self.Headers({Range:"bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)})),r}(t,this.controller.signal),o=r.onProgress,l="arraybuffer"===t.responseType,u=l?"byteLength":"length";this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(s,t,n.response)}),e.timeout),self.fetch(this.request).then((function(r){if(n.response=n.loader=r,!r.ok){var a=r.status,u=r.statusText;throw new p(u||"fetch, bad network response",a,r)}return s.loading.first=Math.max(self.performance.now(),s.loading.start),s.total=parseInt(r.headers.get("Content-Length")||"0"),o&&Object(i.isFiniteNumber)(e.highWaterMark)?n.loadProgressively(r,s,t,e.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(a){var l=n.response;self.clearTimeout(n.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),s.loaded=s.total=a[u];var d={url:l.url,data:a};o&&!Object(i.isFiniteNumber)(e.highWaterMark)&&o(s,t,a,l),r.onSuccess(d,s,t,l)})).catch((function(e){if(self.clearTimeout(n.requestTimeout),!s.aborted){var i=e.code||0;r.onError({code:i,text:e.message},t,e.details)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&n(e,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return e.loaded+=u,u<i||a.dataLength?(a.push(l),a.dataLength>=i&&n(e,r,a.flush(),t)):n(e,r,l,t),s()})).catch((function(){return Promise.reject()}))}()},t}();function f(t,e){return new self.Request(t.url,e)}var p=function(t){var e,r;function i(e,r,i){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,u(e,r),i}(a(Error));e.default=h},"./src/utils/imsc1-ttml-parser.ts":
316
316
  /*!****************************************!*\
317
317
  !*** ./src/utils/imsc1-ttml-parser.ts ***!
318
318
  \****************************************/
319
- /*! exports provided: IMSC1_CODEC, parseIMSC1 */function(e,t,r){r.r(t),r.d(t,"IMSC1_CODEC",(function(){return c})),r.d(t,"parseIMSC1",(function(){return p}));var n=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ./vttcue */"./src/utils/vttcue.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var c="stpp.ttml.im1t",d=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,f=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,h={left:"start",center:"center",right:"end",start:"start",end:"end"};function p(e,t,r,i,c){var d=Object(n.findBox)(new Uint8Array(e),["mdat"]);if(0!==d.length){var f=d[0],p=Object(s.utf8ArrayToStr)(new Uint8Array(e,f.start,f.end-f.start)),_=Object(o.toTimescaleFromScale)(t,1,r);try{i(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(n).reduce((function(e,t){return e[t]=r.getAttribute("ttp:"+t)||n[t],e}),{}),s="preserve"!==r.getAttribute("xml:space"),o=g(v(r,"styling","style")),c=g(v(r,"layout","region")),d=v(r,"body","[begin]");return[].map.call(d,(function(e){var r=function e(t,r){return[].slice.call(t.childNodes).reduce((function(t,n,i){var a;return"br"===n.nodeName&&i?t+"\n":null!==(a=n.childNodes)&&void 0!==a&&a.length?e(n,r):r?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}(e,s);if(!r||!e.hasAttribute("begin"))return null;var n=E(e.getAttribute("begin"),i),d=E(e.getAttribute("dur"),i),f=E(e.getAttribute("end"),i);if(null===n)throw y(e);if(null===f){if(null===d)throw y(e);f=n+d}var p=new a.default(n-t,f-t,r);p.id=Object(l.generateCueId)(p.startTime,p.endTime,p.text);var v=c[e.getAttribute("region")],g=o[e.getAttribute("style")];p.position=10,p.size=80;var _=function(e,t){var r="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(n,i){var a=m(t,r,i)||m(e,r,i);return a&&(n[i]=a),n}),{})}(v,g),T=_.textAlign;if(T){var b=h[T];b&&(p.lineAlign=b),p.align=T}return u(p,_),p})).filter((function(e){return null!==e}))}(p,_))}catch(e){c(e)}}else c(new Error("Could not parse IMSC1 mdat"))}function v(e,t,r){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(r)):[]}function g(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function m(e,t,r){return e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function y(e){return new Error("Could not parse ttml timestamp "+e)}function E(e,t){if(!e)return null;var r=Object(i.parseTimeStamp)(e);return null===r&&(d.test(e)?r=function(e,t){var r=d.exec(e),n=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/t.frameRate}(e,t):f.test(e)&&(r=function(e,t){var r=f.exec(e),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),r}},"./src/utils/logger.ts":
319
+ /*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,e,r){r.r(e),r.d(e,"IMSC1_CODEC",(function(){return d})),r.d(e,"parseIMSC1",(function(){return p}));var i=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ./vttcue */"./src/utils/vttcue.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}var d="stpp.ttml.im1t",c=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,h=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function p(t,e,r,n,d){var c=Object(i.findBox)(new Uint8Array(t),["mdat"]);if(0!==c.length){var h=c[0],p=Object(a.utf8ArrayToStr)(new Uint8Array(t,h.start,h.end-h.start)),T=Object(o.toTimescaleFromScale)(e,1,r);try{n(function(t,e){var r=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((function(t,e){return t[e]=r.getAttribute("ttp:"+e)||i[e],t}),{}),a="preserve"!==r.getAttribute("xml:space"),o=m(g(r,"styling","style")),d=m(g(r,"layout","region")),c=g(r,"body","[begin]");return[].map.call(c,(function(t){var r=function t(e,r){return[].slice.call(e.childNodes).reduce((function(e,i,n){var s;return"br"===i.nodeName&&n?e+"\n":null!==(s=i.childNodes)&&void 0!==s&&s.length?t(i,r):r?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent}),"")}(t,a);if(!r||!t.hasAttribute("begin"))return null;var i=E(t.getAttribute("begin"),n),c=E(t.getAttribute("dur"),n),h=E(t.getAttribute("end"),n);if(null===i)throw y(t);if(null===h){if(null===c)throw y(t);h=i+c}var p=new s.default(i-e,h-e,r);p.id=Object(l.generateCueId)(p.startTime,p.endTime,p.text);var g=d[t.getAttribute("region")],m=o[t.getAttribute("style")];p.position=10,p.size=80;var T=function(t,e){var r="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(i,n){var s=v(e,r,n)||v(t,r,n);return s&&(i[n]=s),i}),{})}(g,m),_=T.textAlign;if(_){var b=f[_];b&&(p.lineAlign=b),p.align=_}return u(p,T),p})).filter((function(t){return null!==t}))}(p,T))}catch(t){d(t)}}else d(new Error("Could not parse IMSC1 mdat"))}function g(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function m(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function v(t,e,r){return t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function E(t,e){if(!t)return null;var r=Object(n.parseTimeStamp)(t);return null===r&&(c.test(t)?r=function(t,e){var r=c.exec(t),i=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/e.frameRate}(t,e):h.test(t)&&(r=function(t,e){var r=h.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),r}},"./src/utils/logger.ts":
320
320
  /*!*****************************!*\
321
321
  !*** ./src/utils/logger.ts ***!
322
322
  \*****************************/
323
- /*! exports provided: enableLogs, logger */function(e,t,r){r.r(t),r.d(t,"enableLogs",(function(){return o})),r.d(t,"logger",(function(){return l}));var n=function(){},i={trace:n,debug:n,log:n,warn:n,info:n,error:n},a=i;function s(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):n}function o(e){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];r.forEach((function(t){a[t]=e[t]?e[t].bind(e):s(t)}))}(e,"debug","log","info","warn","error");try{a.log()}catch(e){a=i}}else a=i}var l=i},"./src/utils/mediakeys-helper.ts":
323
+ /*! exports provided: enableLogs, logger */function(t,e,r){r.r(e),r.d(e,"enableLogs",(function(){return o})),r.d(e,"logger",(function(){return l}));var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},s=n;function a(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):i}function o(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach((function(e){s[e]=t[e]?t[e].bind(t):a(e)}))}(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=n}}else s=n}var l=n},"./src/utils/mediakeys-helper.ts":
324
324
  /*!***************************************!*\
325
325
  !*** ./src/utils/mediakeys-helper.ts ***!
326
326
  \***************************************/
327
- /*! exports provided: KeySystems, requestMediaKeySystemAccess */function(e,t,r){var n;r.r(t),r.d(t,"KeySystems",(function(){return n})),r.d(t,"requestMediaKeySystemAccess",(function(){return i})),function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(n||(n={}));var i="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
327
+ /*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,e,r){var i;r.r(e),r.d(e,"KeySystems",(function(){return i})),r.d(e,"requestMediaKeySystemAccess",(function(){return n})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(i||(i={}));var n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
328
328
  /*!*****************************************!*\
329
329
  !*** ./src/utils/mediasource-helper.ts ***!
330
330
  \*****************************************/
331
- /*! exports provided: getMediaSource */function(e,t,r){function n(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,"getMediaSource",(function(){return n}))},"./src/utils/mp4-tools.ts":
331
+ /*! exports provided: getMediaSource */function(t,e,r){function i(){return self.MediaSource||self.WebKitMediaSource}r.r(e),r.d(e,"getMediaSource",(function(){return i}))},"./src/utils/mp4-tools.ts":
332
332
  /*!********************************!*\
333
333
  !*** ./src/utils/mp4-tools.ts ***!
334
334
  \********************************/
335
- /*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(e,t,r){r.r(t),r.d(t,"bin2str",(function(){return o})),r.d(t,"readUint16",(function(){return l})),r.d(t,"readUint32",(function(){return u})),r.d(t,"writeUint32",(function(){return c})),r.d(t,"findBox",(function(){return d})),r.d(t,"parseSegmentIndex",(function(){return f})),r.d(t,"parseInitSegment",(function(){return h})),r.d(t,"getStartDTS",(function(){return p})),r.d(t,"getDuration",(function(){return v})),r.d(t,"computeRawDurationFromSamples",(function(){return g})),r.d(t,"offsetStartDTS",(function(){return m})),r.d(t,"segmentValidRange",(function(){return y})),r.d(t,"appendUint8Array",(function(){return E}));var n=r(/*! ./typed-array */"./src/utils/typed-array.ts"),i=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=Math.pow(2,32)-1,s=[].push;function o(e){return String.fromCharCode.apply(null,e)}function l(e,t){"data"in e&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function u(e,t){"data"in e&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r}function c(e,t,r){"data"in e&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function d(e,t){var r,n,i,a=[];if(!t.length)return a;"data"in e?(r=e.data,n=e.start,i=e.end):(n=0,i=(r=e).byteLength);for(var l=n;l<i;){var c=u(r,l),f=c>1?l+c:i;if(o(r.subarray(l+4,l+8))===t[0])if(1===t.length)a.push({data:r,start:l+8,end:f});else{var h=d({data:r,start:l+8,end:f},t.slice(1));h.length&&s.apply(a,h)}l=f}return a}function f(e){var t=d(e,["moov"])[0],r=t?t.end:null,n=d(e,["sidx"]);if(!n||!n[0])return null;var i=[],a=n[0],s=a.data[0],o=0===s?8:16,c=u(a,o);o+=4,o+=0===s?8:16,o+=2;var f=a.end+0,h=l(a,o);o+=2;for(var p=0;p<h;p++){var v=o,g=u(a,v);v+=4;var m=2147483647&g;if(1==(2147483648&g)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=u(a,v);v+=4,i.push({referenceSize:m,subsegmentDuration:y,info:{duration:y/c,start:f,end:f+m-1}}),f+=m,o=v+=4}return{earliestPresentationTime:0,timescale:c,version:s,referencesCount:h,references:i,moovEndOffset:r}}function h(e){for(var t=[],r=d(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=d(a,["tkhd"])[0];if(s){var l=s.data[s.start],c=0===l?12:20,f=u(s,c),h=d(a,["mdia","mdhd"])[0];if(h){var p=u(h,c=0===(l=h.data[h.start])?12:20),v=d(a,["mdia","hdlr"])[0];if(v){var g=o(v.data.subarray(v.start+8,v.start+12)),m={soun:i.ElementaryStreamTypes.AUDIO,vide:i.ElementaryStreamTypes.VIDEO}[g];if(m){var y=d(a,["mdia","minf","stbl","stsd"])[0],E=void 0;y&&(E=o(y.data.subarray(y.start+12,y.start+16))),t[f]={timescale:p,type:m},t[m]={timescale:p,id:f,codec:E}}}}}}return d(e,["moov","mvex","trex"]).forEach((function(e){var r=u(e,4),n=t[r];n&&(n.default={duration:u(e,12),flags:u(e,20)})})),t}function p(e,t){return d(t,["moof","traf"]).reduce((function(t,r){var n=d(r,["tfdt"])[0],i=n.data[n.start],a=d(r,["tfhd"]).reduce((function(t,r){var a=u(r,4),s=e[a];if(s){var o=u(n,4);1===i&&(o*=Math.pow(2,32),o+=u(n,8));var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)||0}function v(e,t){for(var r=0,n=0,a=0,s=d(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],c=d(l,["tfhd"])[0],h=t[u(c,4)];if(h){var p=h.default,v=u(c,0)|(null==p?void 0:p.flags),m=null==p?void 0:p.duration;8&v&&(m=u(c,2&v?12:8));for(var y=h.timescale||9e4,E=d(l,["trun"]),_=0;_<E.length;_++)r=m?m*u(E[_],4):g(E[_]),h.type===i.ElementaryStreamTypes.VIDEO?n+=r/y:h.type===i.ElementaryStreamTypes.AUDIO&&(a+=r/y)}}if(0===n&&0===a){var T=f(e);if(null!=T&&T.references)return T.references.reduce((function(e,t){return e+t.info.duration||0}),0)}return n||a}function g(e){var t=u(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var n=0,i=u(e,4),a=0;a<i;a++)256&t&&(n+=u(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return n}function m(e,t,r){d(t,["moof","traf"]).forEach((function(t){d(t,["tfhd"]).forEach((function(n){var i=u(n,4),s=e[i];if(s){var o=s.timescale||9e4;d(t,["tfdt"]).forEach((function(e){var t=e.data[e.start],n=u(e,4);if(0===t)c(e,4,n-r*o);else{n*=Math.pow(2,32),n+=u(e,8),n-=r*o,n=Math.max(n,0);var i=Math.floor(n/(a+1)),s=Math.floor(n%(a+1));c(e,4,i),c(e,8,s)}}))}}))}))}function y(e){var t={valid:null,remainder:null},r=d(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=Object(n.sliceUint8)(e,0,i.start-8),t.remainder=Object(n.sliceUint8)(e,i.start-8),t}function E(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}},"./src/utils/output-filter.ts":
335
+ /*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,e,r){r.r(e),r.d(e,"bin2str",(function(){return o})),r.d(e,"readUint16",(function(){return l})),r.d(e,"readUint32",(function(){return u})),r.d(e,"writeUint32",(function(){return d})),r.d(e,"findBox",(function(){return c})),r.d(e,"parseSegmentIndex",(function(){return h})),r.d(e,"parseInitSegment",(function(){return f})),r.d(e,"getStartDTS",(function(){return p})),r.d(e,"getDuration",(function(){return g})),r.d(e,"computeRawDurationFromSamples",(function(){return m})),r.d(e,"offsetStartDTS",(function(){return v})),r.d(e,"segmentValidRange",(function(){return y})),r.d(e,"appendUint8Array",(function(){return E}));var i=r(/*! ./typed-array */"./src/utils/typed-array.ts"),n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=Math.pow(2,32)-1,a=[].push;function o(t){return String.fromCharCode.apply(null,t)}function l(t,e){"data"in t&&(e+=t.start,t=t.data);var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function u(t,e){"data"in t&&(e+=t.start,t=t.data);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return r<0?4294967296+r:r}function d(t,e,r){"data"in t&&(e+=t.start,t=t.data),t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function c(t,e){var r,i,n,s=[];if(!e.length)return s;"data"in t?(r=t.data,i=t.start,n=t.end):(i=0,n=(r=t).byteLength);for(var l=i;l<n;){var d=u(r,l),h=d>1?l+d:n;if(o(r.subarray(l+4,l+8))===e[0])if(1===e.length)s.push({data:r,start:l+8,end:h});else{var f=c({data:r,start:l+8,end:h},e.slice(1));f.length&&a.apply(s,f)}l=h}return s}function h(t){var e=c(t,["moov"])[0],r=e?e.end:null,i=c(t,["sidx"]);if(!i||!i[0])return null;var n=[],s=i[0],a=s.data[0],o=0===a?8:16,d=u(s,o);o+=4,o+=0===a?8:16,o+=2;var h=s.end+0,f=l(s,o);o+=2;for(var p=0;p<f;p++){var g=o,m=u(s,g);g+=4;var v=2147483647&m;if(1==(2147483648&m)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=u(s,g);g+=4,n.push({referenceSize:v,subsegmentDuration:y,info:{duration:y/d,start:h,end:h+v-1}}),h+=v,o=g+=4}return{earliestPresentationTime:0,timescale:d,version:a,referencesCount:f,references:n,moovEndOffset:r}}function f(t){for(var e=[],r=c(t,["moov","trak"]),i=0;i<r.length;i++){var s=r[i],a=c(s,["tkhd"])[0];if(a){var l=a.data[a.start],d=0===l?12:20,h=u(a,d),f=c(s,["mdia","mdhd"])[0];if(f){var p=u(f,d=0===(l=f.data[f.start])?12:20),g=c(s,["mdia","hdlr"])[0];if(g){var m=o(g.data.subarray(g.start+8,g.start+12)),v={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[m];if(v){var y=c(s,["mdia","minf","stbl","stsd"])[0],E=void 0;y&&(E=o(y.data.subarray(y.start+12,y.start+16))),e[h]={timescale:p,type:v},e[v]={timescale:p,id:h,codec:E}}}}}}return c(t,["moov","mvex","trex"]).forEach((function(t){var r=u(t,4),i=e[r];i&&(i.default={duration:u(t,12),flags:u(t,20)})})),e}function p(t,e){return c(e,["moof","traf"]).reduce((function(e,r){var i=c(r,["tfdt"])[0],n=i.data[i.start],s=c(r,["tfhd"]).reduce((function(e,r){var s=u(r,4),a=t[s];if(a){var o=u(i,4);1===n&&(o*=Math.pow(2,32),o+=u(i,8));var l=o/(a.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==s&&isFinite(s)&&(null===e||s<e)?s:e}),null)||0}function g(t,e){for(var r=0,i=0,s=0,a=c(t,["moof","traf"]),o=0;o<a.length;o++){var l=a[o],d=c(l,["tfhd"])[0],f=e[u(d,4)];if(f){var p=f.default,g=u(d,0)|(null==p?void 0:p.flags),v=null==p?void 0:p.duration;8&g&&(v=u(d,2&g?12:8));for(var y=f.timescale||9e4,E=c(l,["trun"]),T=0;T<E.length;T++)r=v?v*u(E[T],4):m(E[T]),f.type===n.ElementaryStreamTypes.VIDEO?i+=r/y:f.type===n.ElementaryStreamTypes.AUDIO&&(s+=r/y)}}if(0===i&&0===s){var _=h(t);if(null!=_&&_.references)return _.references.reduce((function(t,e){return t+e.info.duration||0}),0)}return i||s}function m(t){var e=u(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,n=u(t,4),s=0;s<n;s++)256&e&&(i+=u(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function v(t,e,r){c(e,["moof","traf"]).forEach((function(e){c(e,["tfhd"]).forEach((function(i){var n=u(i,4),a=t[n];if(a){var o=a.timescale||9e4;c(e,["tfdt"]).forEach((function(t){var e=t.data[t.start],i=u(t,4);if(0===e)d(t,4,i-r*o);else{i*=Math.pow(2,32),i+=u(t,8),i-=r*o,i=Math.max(i,0);var n=Math.floor(i/(s+1)),a=Math.floor(i%(s+1));d(t,4,n),d(t,8,a)}}))}}))}))}function y(t){var e={valid:null,remainder:null},r=c(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var n=r[r.length-1];return e.valid=Object(i.sliceUint8)(t,0,n.start-8),e.remainder=Object(i.sliceUint8)(t,n.start-8),e}function E(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}},"./src/utils/output-filter.ts":
336
336
  /*!************************************!*\
337
337
  !*** ./src/utils/output-filter.ts ***!
338
338
  \************************************/
339
- /*! exports provided: default */function(e,t,r){r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[]},e}()},"./src/utils/texttrack-utils.ts":
339
+ /*! exports provided: default */function(t,e,r){r.r(e),r.d(e,"default",(function(){return i}));var i=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function(t,e,r){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[]},t}()},"./src/utils/texttrack-utils.ts":
340
340
  /*!**************************************!*\
341
341
  !*** ./src/utils/texttrack-utils.ts ***!
342
342
  \**************************************/
343
- /*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(e,t,r){r.r(t),r.d(t,"sendAddTrackEvent",(function(){return i})),r.d(t,"addCueToTrack",(function(){return a})),r.d(t,"clearCurrentCues",(function(){return s})),r.d(t,"removeCuesInRange",(function(){return o})),r.d(t,"getCuesInRange",(function(){return l}));var n=r(/*! ./logger */"./src/utils/logger.ts");function i(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function a(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){n.logger.debug("[texttrack-utils]: "+r);var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}"disabled"===r&&(e.mode=r)}function s(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues){for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}}function o(e,t,r){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length){for(var i=l(e.cues,t,r),a=0;a<i.length;a++)e.removeCue(i[a]);"disabled"===n&&(e.mode=n)}}function l(e,t,r){var n=[],i=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var n=0,i=r;n<=i;){var a=Math.floor((i+n)/2);if(t<e[a].startTime)i=a-1;else{if(!(t>e[a].startTime&&n<r))return a;n=a+1}}return e[n].startTime-t<t-e[i].startTime?n:i}(e,t);if(i>-1)for(var a=i,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)n.push(o);else if(o.startTime>r)return n}return n}},"./src/utils/time-ranges.ts":
343
+ /*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,e,r){r.r(e),r.d(e,"sendAddTrackEvent",(function(){return n})),r.d(e,"addCueToTrack",(function(){return s})),r.d(e,"clearCurrentCues",(function(){return a})),r.d(e,"removeCuesInRange",(function(){return o})),r.d(e,"getCuesInRange",(function(){return l}));var i=r(/*! ./logger */"./src/utils/logger.ts");function n(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function s(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}"disabled"===r&&(t.mode=r)}function a(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues){for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}}function o(t,e,r){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&t.cues.length){for(var n=l(t.cues,e,r),s=0;s<n.length;s++)t.removeCue(n[s]);"disabled"===i&&(t.mode=i)}}function l(t,e,r){var i=[],n=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;for(var i=0,n=r;i<=n;){var s=Math.floor((n+i)/2);if(e<t[s].startTime)n=s-1;else{if(!(e>t[s].startTime&&i<r))return s;i=s+1}}return t[i].startTime-e<e-t[n].startTime?i:n}(t,e);if(n>-1)for(var s=n,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":
344
344
  /*!**********************************!*\
345
345
  !*** ./src/utils/time-ranges.ts ***!
346
346
  \**********************************/
347
- /*! exports provided: default */function(e,t,r){r.r(t),t.default={toString:function(e){for(var t="",r=e.length,n=0;n<r;n++)t+="["+e.start(n).toFixed(3)+","+e.end(n).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts":
347
+ /*! exports provided: default */function(t,e,r){r.r(e),e.default={toString:function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+","+t.end(i).toFixed(3)+"]";return e}}},"./src/utils/timescale-conversion.ts":
348
348
  /*!*******************************************!*\
349
349
  !*** ./src/utils/timescale-conversion.ts ***!
350
350
  \*******************************************/
351
- /*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(e,t,r){function n(e,t,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var i=e*t*r;return n?Math.round(i):i}function i(e,t,r,i){return void 0===r&&(r=1),void 0===i&&(i=!1),n(e,t,1/r,i)}function a(e,t){return void 0===t&&(t=!1),n(e,1e3,1/9e4,t)}function s(e,t){return void 0===t&&(t=1),n(e,9e4,1/t)}r.r(t),r.d(t,"toTimescaleFromBase",(function(){return n})),r.d(t,"toTimescaleFromScale",(function(){return i})),r.d(t,"toMsFromMpegTsClock",(function(){return a})),r.d(t,"toMpegTsClockFromTimescale",(function(){return s}))},"./src/utils/typed-array.ts":
351
+ /*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,e,r){function i(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function n(t,e,r,n){return void 0===r&&(r=1),void 0===n&&(n=!1),i(t,e,1/r,n)}function s(t,e){return void 0===e&&(e=!1),i(t,1e3,1/9e4,e)}function a(t,e){return void 0===e&&(e=1),i(t,9e4,1/e)}r.r(e),r.d(e,"toTimescaleFromBase",(function(){return i})),r.d(e,"toTimescaleFromScale",(function(){return n})),r.d(e,"toMsFromMpegTsClock",(function(){return s})),r.d(e,"toMpegTsClockFromTimescale",(function(){return a}))},"./src/utils/typed-array.ts":
352
352
  /*!**********************************!*\
353
353
  !*** ./src/utils/typed-array.ts ***!
354
354
  \**********************************/
355
- /*! exports provided: sliceUint8 */function(e,t,r){function n(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}r.r(t),r.d(t,"sliceUint8",(function(){return n}))},"./src/utils/vttcue.ts":
355
+ /*! exports provided: sliceUint8 */function(t,e,r){function i(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}r.r(e),r.d(e,"sliceUint8",(function(){return i}))},"./src/utils/vttcue.ts":
356
356
  /*!*****************************!*\
357
357
  !*** ./src/utils/vttcue.ts ***!
358
358
  \*****************************/
359
- /*! exports provided: default */function(e,t,r){r.r(t),t.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function n(e){return r(t,e)}function i(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=1;i<arguments.length;i++){var a=arguments[i];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,d=t,f=a,h=s,p=null,v="",g=!0,m="auto",y="start",E=50,_="middle",T=50,b="middle";Object.defineProperty(o,"id",i({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",i({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",i({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",i({},l,{get:function(){return f},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",i({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",i({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",i({},l,{get:function(){return v},set:function(t){var n=function(t){return r(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");v=n,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",i({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",i({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",i({},l,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",i({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",i({},l,{get:function(){return _},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",i({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",i({},l,{get:function(){return b},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts":
359
+ /*! exports provided: default */function(t,e,r){r.r(e),e.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){return r(e,t)}function n(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var a in s)t[a]=s[a]}return t}function s(e,s,a){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",d=!1,c=e,h=s,f=a,p=null,g="",m=!0,v="auto",y="start",E=50,T="middle",_=50,b="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return u},set:function(t){u=""+t}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return d},set:function(t){d=!!t}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return c},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");c=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return h},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");h=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(t){p=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return g},set:function(e){var i=function(e){return r(t,e)}(e);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return m},set:function(t){m=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return v},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return E},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return T},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return _},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return b},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");b=e,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}()},"./src/utils/vttparser.ts":
360
360
  /*!********************************!*\
361
361
  !*** ./src/utils/vttparser.ts ***!
362
362
  \********************************/
363
- /*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(e,t,r){r.r(t),r.d(t,"parseTimeStamp",(function(){return a})),r.d(t,"fixLineBreaks",(function(){return d})),r.d(t,"VTTParser",(function(){return f}));var n=r(/*! ./vttcue */"./src/utils/vttcue.ts"),i=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function a(e){function t(e,t,r,n){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(n||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var s=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var n=0;n<r.length;++n)if(t===r[n]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},e}();function o(e,t,r,n){var i=n?e.split(n):[e];for(var a in i)if("string"==typeof i[a]){var s=i[a].split(r);2===s.length&&t(s[0],s[1])}}var l=new n.default(0,0,""),u="middle"===l.align?"middle":"center";function c(e,t,r){var n=e;function i(){var t=a(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function c(){e=e.replace(/^\s+/,"")}if(c(),t.startTime=i(),c(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.substr(3),c(),t.endTime=i(),c(),function(e,t){var n=new s;o(e,(function(e,t){var i;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){n.set(e,r[a].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":i=t.split(","),n.integer(e,i[0]),n.percent(e,i[0])&&n.set("snapToLines",!1),n.alt(e,i[0],["auto"]),2===i.length&&n.alt("lineAlign",i[1],["start",u,"end"]);break;case"position":i=t.split(","),n.percent(e,i[0]),2===i.length&&n.alt("positionAlign",i[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",u,"end","left","right"])}}),/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var i=n.get("line","auto");"auto"===i&&-1===l.line&&(i=-1),t.line=i,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",u);var a=n.get("position","auto");"auto"===a&&50===l.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function d(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var f=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new i,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=d(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var n=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),n}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var s=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:i=r(),t.state){case"HEADER":/:/.test(i)?o(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new n.default(0,0,""),t.state="CUE",-1===i.indexOf("--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{c(i,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=-1!==i.indexOf("--\x3e");if(!i||l&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw new Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this},e}()},"./src/utils/webvtt-parser.ts":
363
+ /*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,e,r){r.r(e),r.d(e,"parseTimeStamp",(function(){return s})),r.d(e,"fixLineBreaks",(function(){return c})),r.d(e,"VTTParser",(function(){return h}));var i=r(/*! ./vttcue */"./src/utils/vttcue.ts"),n=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function s(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}var a=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,r){for(var i=0;i<r.length;++i)if(e===r[i]){this.set(t,e);break}},e.integer=function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},e.percent=function(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var r=parseFloat(e);if(r>=0&&r<=100)return this.set(t,r),!0}return!1},t}();function o(t,e,r,i){var n=i?t.split(i):[t];for(var s in n)if("string"==typeof n[s]){var a=n[s].split(r);2===a.length&&e(a[0],a[1])}}var l=new i.default(0,0,""),u="middle"===l.align?"middle":"center";function d(t,e,r){var i=t;function n(){var e=s(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function d(){t=t.replace(/^\s+/,"")}if(d(),e.startTime=n(),d(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.substr(3),d(),e.endTime=n(),d(),function(t,e){var i=new a;o(t,(function(t,e){var n;switch(t){case"region":for(var s=r.length-1;s>=0;s--)if(r[s].id===e){i.set(t,r[s].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),i.integer(t,n[0]),i.percent(t,n[0])&&i.set("snapToLines",!1),i.alt(t,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",u,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",u,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===l.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",u);var s=i.get("position","auto");"auto"===s&&50===l.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function c(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var h=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new n,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=c(t);r<t.length&&"\r"!==t[r]&&"\n"!==t[r];)++r;var i=t.substr(0,r);return"\r"===t[r]&&++r,"\n"===t[r]&&++r,e.buffer=t.substr(r),i}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{var n="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;var s=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var a=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(a?a=!1:n=r(),e.state){case"HEADER":/:/.test(n)?o(n,(function(t,e){}),/:/):n||(e.state="ID");continue;case"NOTE":n||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){e.state="NOTE";break}if(!n)continue;if(e.cue=new i.default(0,0,""),e.state="CUE",-1===n.indexOf("--\x3e")){e.cue.id=n;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{d(n,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var l=-1!==n.indexOf("--\x3e");if(!n||l&&(a=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=n;continue;case"BADCUE":n||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this},e.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw new Error("Malformed WebVTT signature.")}catch(t){this.onparsingerror&&this.onparsingerror(t)}return this.onflush&&this.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
364
364
  /*!************************************!*\
365
365
  !*** ./src/utils/webvtt-parser.ts ***!
366
366
  \************************************/
367
- /*! exports provided: generateCueId, parseWebVTT */function(e,t,r){r.r(t),r.d(t,"generateCueId",(function(){return d})),r.d(t,"parseWebVTT",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(e,t,r){return void 0===r&&(r=0),e.substr(r,t.length)===t},c=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function d(e,t,r){return c(e.toString())+c(t.toString())+c(r)}function f(e,t,r,c,f,h,p,v){var g,m=new i.VTTParser,y=Object(a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(l,"\n").split("\n"),E=[],_=Object(s.toMpegTsClockFromTimescale)(t,r),T="00:00.000",b=0,A=0,S=!0,w=!1;m.oncue=function(e){var t=c[f],r=c.ccOffset,n=(b-_)/9e4;if(null!=t&&t.new&&(void 0!==A?r=c.ccOffset=t.start:function(e,t,r){var n=e[t],i=e[n.prevCC];if(!i||!i.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!==(a=i)&&void 0!==a&&a.new;){var a;e.ccOffset+=n.start-i.start,n.new=!1,i=e[(n=i).prevCC]}e.presentationOffset=r}(c,f,n)),n&&(r=n-c.presentationOffset),w){var i=e.endTime-e.startTime,a=Object(o.normalizePts)(9e4*(e.startTime+r-A),9e4*h)/9e4;e.startTime=a,e.endTime=a+i}var s=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(s)),e.id||(e.id=d(e.startTime,e.endTime,s)),e.endTime>0&&E.push(e)},m.onparsingerror=function(e){g=e},m.onflush=function(){g?v(g):p(E)},y.forEach((function(e){if(S){if(u(e,"X-TIMESTAMP-MAP=")){S=!1,w=!0,e.substr(16).split(",").forEach((function(e){u(e,"LOCAL:")?T=e.substr(6):u(e,"MPEGTS:")&&(b=parseInt(e.substr(7)))}));try{A=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(n.isFiniteNumber)(t)&&Object(n.isFiniteNumber)(r)&&Object(n.isFiniteNumber)(i)&&Object(n.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*i,t+=36e5*a}(T)/1e3}catch(e){w=!1,g=e}return}""===e&&(S=!1)}m.parse(e+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts":
367
+ /*! exports provided: generateCueId, parseWebVTT */function(t,e,r){r.r(e),r.d(e,"generateCueId",(function(){return c})),r.d(e,"parseWebVTT",(function(){return h}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(t,e,r){return void 0===r&&(r=0),t.substr(r,e.length)===e},d=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()};function c(t,e,r){return d(t.toString())+d(e.toString())+d(r)}function h(t,e,r,d,h,f,p,g){var m,v=new n.VTTParser,y=Object(s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),E=[],T=Object(a.toMpegTsClockFromTimescale)(e,r),_="00:00.000",b=0,S=0,A=!0,L=!1;v.oncue=function(t){var e=d[h],r=d.ccOffset,i=(b-T)/9e4;if(null!=e&&e.new&&(void 0!==S?r=d.ccOffset=e.start:function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!==(s=n)&&void 0!==s&&s.new;){var s;t.ccOffset+=i.start-n.start,i.new=!1,n=t[(i=n).prevCC]}t.presentationOffset=r}(d,h,i)),i&&(r=i-d.presentationOffset),L){var n=t.endTime-t.startTime,s=Object(o.normalizePts)(9e4*(t.startTime+r-S),9e4*f)/9e4;t.startTime=s,t.endTime=s+n}var a=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(a)),t.id||(t.id=c(t.startTime,t.endTime,a)),t.endTime>0&&E.push(t)},v.onparsingerror=function(t){m=t},v.onflush=function(){m?g(m):p(E)},y.forEach((function(t){if(A){if(u(t,"X-TIMESTAMP-MAP=")){A=!1,L=!0,t.substr(16).split(",").forEach((function(t){u(t,"LOCAL:")?_=t.substr(6):u(t,"MPEGTS:")&&(b=parseInt(t.substr(7)))}));try{S=function(t){var e=parseInt(t.substr(-3)),r=parseInt(t.substr(-6,2)),n=parseInt(t.substr(-9,2)),s=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(i.isFiniteNumber)(e)&&Object(i.isFiniteNumber)(r)&&Object(i.isFiniteNumber)(n)&&Object(i.isFiniteNumber)(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*r,e+=6e4*n,e+=36e5*s}(_)/1e3}catch(t){L=!1,m=t}return}""===t&&(A=!1)}v.parse(t+"\n")})),v.flush()}},"./src/utils/xhr-loader.ts":
368
368
  /*!*********************************!*\
369
369
  !*** ./src/utils/xhr-loader.ts ***!
370
370
  \*********************************/
371
- /*! exports provided: default */function(e,t,r){r.r(t);var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m,s=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new i.LoadStats,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var i=this.xhrSetup;try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),r.send()}},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===i){t.onreadystatechange=null,t.onprogress=null;var s=t.status;if(s>=200&&s<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===e.responseType?(o=t.response).byteLength:(o=t.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,e,o,t),!this.callbacks)return;var c={url:t.responseURL,data:o};this.callbacks.onSuccess(c,r,e,t)}else r.retry>=a.maxRetry||s>=400&&s<499?(n.logger.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:t.statusText},e,t)):(n.logger.warn(s+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},t.loadtimeout=function(){n.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},e}();t.default=s}}).default},e.exports=r())})));var rn=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const nn="com.widevine.alpha";const an="application/vnd.apple.mpegURL",sn=[an,"application/x-mpegurl"],on=document.createElement("video").canPlayType(an);function ln({src:e="",type:t="",drm:r},n){const i=(null==n?void 0:n.hls)||{},a="native"in i&&i.native;return(!on||!a)&&(!(r&&!Object.keys(r).find(e=>{return t=e,[nn].filter((function(e){return e===t})).length;var t}))&&(!(!t||!sn.includes(t))||function(e){const{pathname:t}=Yt(e);return t.endsWith(".m3u8")}(e)))}var un="audio:set",cn="audio:update",dn="audio:tracks";const fn=[tn.Events.SUBTITLE_TRACKS_UPDATED,tn.Events.SUBTITLE_TRACK_SWITCH,tn.Events.LEVEL_SWITCHED];function hn(e,t){fn.forEach((function(r){e.on(r,(function(){!function(e,t){var r;const n=e.levels[e.currentLevel];if(!n||!e.subtitleTracks.length||n.attrs.SUB)return;const i=null===(r=null==n?void 0:n.attrs)||void 0===r?void 0:r.SUBTITLES;if(!i)return t.emit("tracks:text:all",[]);const a=e.subtitleTracks.filter((function(e){return e.groupId==i})).map((function(e){return t.textTracks[e.id]}));t.emit("tracks:text:all",a)}(e,t)}))}))}var pn=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});function vn(e,t,r){if(!e.reaper||!r.src)return;e.hls&&(e.emit("recover",{type:"hls"}),e.hls.destroy());const i="live"in t==0,a={is_audio_only:!1,fragDuration:-1};if(r.drm&&!zt()&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return e.emit(n,{message:"Secure page required for DRM"});const s=e.hls=new tn(function(e){return Object.assign(Object.assign({autoStartLoad:!1},e.hls),{startPosition:e.start_time||-1})}(t)),o={retry_count:0,previous_url:"",previous_content:""};s.subtitleDisplay=!1,s.attachMedia(e),s.loadSource(r.src),e.emit("hls:attached",{hls:s}),function(e,t){e.on(tn.Events.AUDIO_TRACKS_UPDATED,(function(e,r){t.emit(dn,r.audioTracks)})),e.on(tn.Events.AUDIO_TRACK_SWITCHING,(function(e,r){t.emit(cn,r)})),e.on(tn.Events.MANIFEST_PARSED,(function(e,r){r.audioTracks&&t.emit(dn,r.audioTracks)})),e.on(tn.Events.LEVEL_SWITCHED,(function(r,n){const i=e.levels[n.level];i&&t.emit(dn,e.audioTracks.filter((function(e){return e.groupId&&~(i.audioGroupIds||[]).indexOf(e.groupId)})))}))}(s,e),hn(s,e);const l=function(e){var t;const r=null===(t=e.data)||void 0===t?void 0:t.level;"number"==typeof r&&(s.levels[r]||-1===r?s.nextLevel=r:console.error(new Error("skipping invalid quality: "+e.data)))},u=function(e){var t;const r=null===(t=e.data)||void 0===t?void 0:t.id;"number"==typeof r&&r!=s.audioTrack&&setTimeout((function(){s.audioTrack=r}),0)};e.on("quality:set",l),e.on(un,u),e.on("src",(function(){e.hls&&e.hls.destroy(),e.off("quality:set",l),e.off(un,u)})),e.on("audioonlysource",(function(){a.is_audio_only=!0})),e.on(A,(function(){s&&s.destroy()})),e.on("remotesession:started",()=>{e.hls&&e.hls.stopLoad()}),e.on("remotesession:ended",()=>{e.hls&&gn(e)}),i&&s.on(tn.Events.LEVEL_LOADED,(function(t,r){e.setOpts({live:r.details.live})})),s.on(tn.Events.MANIFEST_PARSED,(function(r,n){const i=n.levels.slice(0).reduce((e,t,r)=>[...e,{level:r,text:t.name||t.width+"",width:t.width,height:t.height,videoCodec:t.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((e,t)=>t.width-e.width);e.emit("qualities",i),function(e,t,r){if(!e.hls)return;void 0!==t.start_quality&&(ce.HIGH&t.start_quality&&(e.hls.startLevel=r[0].level),ce.LOW&t.start_quality&&(e.hls.startLevel=r[r.length-1].level),ce.MEDIUM&t.start_quality&&(e.hls.startLevel=r[Math.ceil(r.length/2)-1].level));if("none"===t.preload&&!t.autoplay)return;gn(e,t.start_time||-1)}(e,t,i.slice(0,-1));const a=i.find(e=>!!e.videoCodec);a||e.emit("audioonlysource"),!e.opt("ratio")&&a&&0!=a.width&&0!=a.height&&e.setOpts({ratio:a.width+":"+a.height})})),s.on(tn.Events.INIT_PTS_FOUND,(function(e,t){a.fragDuration=t.frag.duration})),s.on(tn.Events.ERROR,(function(t,r){!function(e,t,r,i){if(0==e.reaper)return;if(0==t.fatal)return;switch(t.type){case tn.ErrorTypes.MEDIA_ERROR:return function(e,t){var r;e.emit(n,{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=e.hls)||void 0===r||r.destroy()}(e);case tn.ErrorTypes.NETWORK_ERROR:return function(e,t){var r;const i=(null===(r=t.networkDetails)||void 0===r?void 0:r.status)||"";e.emit(n,{fatal:!0,code:"http:"+i.toString(),message:pn[i]||"an error occurred while loading this video"})}(e,t);case tn.ErrorTypes.KEY_SYSTEM_ERROR:(function(e,t){var r;e.emit(n,{fatal:!0,message:pn[t.details]||"an error occurred while accessing this video"}),null===(r=e.hls)||void 0===r||r.destroy()})(e,t)}}(e,r,e.original_src,s.config)})),s.on(tn.Events.LEVEL_PTS_UPDATED,(function(t,r){var n;if("video"!==r.type&&(!a.is_audio_only||"audio"!==r.type))return;const i=null===(n=null==r?void 0:r.details)||void 0===n?void 0:n.fragments;if(!i)return;const s=i[0].start||0,o=i[i.length-1].start+i[i.length-1].duration;e.emit("dvr/window",o-s)})),s.on(tn.Events.LEVEL_SWITCHING,(t,r)=>{const n=s.levels[s.currentLevel],i=s.levels[r.level];e.emit("qualitychange",{before:n,after:i,kind:"hls"})}),s.on(tn.Events.LEVEL_UPDATED,(e,t)=>{t.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=t.details.url;const r=o.previous_content;if(o.previous_content=t.details.m3u8,r===t.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(s.levels[t.level].url.length<2)return;s.levelController.redundantFailover(s.currentLevel)}});const c=e.opt("start_time");c&&e.once(f,(function(){e.currentTime=c})),"none"!==t.preload||t.autoplay||e.once("beforeplay",()=>{gn(e,t.start_time||-1)})}function gn(e,t){var r;e.setState(Y,!0),null===(r=e.hls)||void 0===r||r.startLoad(t)}class HLS{init(){}onload(e,t,r,n){vn(r,e,n)}wants(e,t,r){return tn.isSupported()&&ln(t,r)}}HLS.events=rn,HLS.version=tn.version,Qe(window,HLS);const mn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),yn=(...e)=>e.reduce((e,t)=>mn(t)?(Object.keys(t).forEach(r=>{if(mn(e[r])&&mn(t[r]))return e[r]=yn(e[r],t[r]);e[r]=t[r]}),e):e,{});class Pipe{constructor(e){this.data=e}static of(e){return new Pipe(e)}static maybe(e,t,...r){return null==e?e:t.apply(e,[e,...r])}tap(e,...t){return e.apply(this,[this.data,...t]),new Pipe(this.data)}fmap(e,...t){const r=e.apply(this,[this.data,...t]);return new Pipe(r)}unwrap(){return this.data}}function En(e){return fetch(e).then(e=>e.json())}function _n(){let e=[].join.call(arguments,"/");return"/"!==e[0]&&(e="/"+e),Tn()+"/web/public/native/config"+e}const Tn=()=>"https://ljsp.lwcdn.com";function bn(e){return~e.indexOf("/")?e:"/media/"+e}var An={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function Sn(e){const t=e.ima,r=e.duration;if(!t||!r)return e;const n=null==t?void 0:t.ads;return Array.isArray(n)&&(t.ads=n.map((function(e){return"number"==typeof e.percentage&&(e.time=e.percentage*r),e}))),e}function wn(e,t){var r,n;t="object"==typeof t?t:{};const i={title:null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.title,description:null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.description},a={ima:{parameters:function({media_id:e,duration:t,title:r,tags:n,category_name:i,ad_keywords:a}){return{ad_keywords:a||"",media_id:e||"",category:i||"",media_name:r||"",media_tags:n||"",media_duration:t||-1}}((null==e?void 0:e.metadata)||{})}},s=t.embed||{};return delete s.src,yn(a,i,e,(delete(o=t).src,delete o.metadata,delete o.title,delete o.description,delete o.duration,delete o.poster,o),s);var o}const Ln=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function kn(e){return"object"==typeof e&&"ovp/base64"==e.type}function Rn(e,t){return function(e,t){return!(~e.indexOf(".")||!Ln.test(e))&&(t.type="video/ovp",!0)}(e,t)||kn(t)}function Dn(e){try{return function(e){return null===e?{}:JSON.parse(e)}(decodeURIComponent(atob(e).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(e){return{err:e.message}}}function On(e){const t=e.split(/[^0-9]/).map(e=>parseInt(e,10));return Date.UTC(t[0],t[1]-1,t[2],t[3],t[4],t[5])}function Cn(e){return e.live}var In=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function xn(e,t){const r=null==t?void 0:t.src;if(kn(t))return function(e,t){const r=Dn(t.src||"");if(function(e){return"string"==typeof e.err}(r))return console.error(r.err);Pn(e,r)}(e,t);r&&Pipe.of(r).fmap(bn).fmap(_n).fmap(e=>fetch(e)).fmap(t=>t.then(e=>Promise.all([e.status,e.json()])).then(([t,r])=>200==t?Pn(e,r):Mn(e,r)))}function Pn(e,t){return e.emit("ovp:media:changed",t),function(e){return Array.isArray(e.playlist)}(t)?function(e,t){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),Mn(e,{status:415});e.emit("ovp:request:playlist:complete",function(e,t){const r=Object.assign({},e),n=(null==e?void 0:e.playlist)||{},i=yn(t,n),a=((null==i?void 0:i.playlist)||[]).map(e=>wn(e,r));return Object.assign(i,{playlist:a})}(e.opts,t))}(e,t):Cn(t)?function(e,t){var r,n;const i=(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.live_start_time)||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.starttime);i&&(t.live_start_time=Pipe.of(i).fmap(On).unwrap());e.emit("ovp:live:countdown:start",Pipe.of(t).fmap(wn,e.opts).fmap(Sn).unwrap())}(e,t):function(e,t){e.emit("ovp:request:media:complete",Pipe.of(t).fmap(wn,e.opts).fmap(Sn).unwrap())}(e,t)}function Mn(e,t){return t.message?e.emit("ovp:error",t):t.status?e.emit("ovp:error",new Error(An[t.status])):e.emit("ovp:error",t)}const Fn={};function Nn(e,t,r){"object"!=typeof Fn[t]&&(Fn[t]=r);const n=e.opts,i=(null==n?void 0:n.metadata)||{};i.player_id=t,n.metadata=i,r.title&&delete r.title,r.description&&delete r.description;const a=Object.assign(n,r);e.setOpts(a),r.autoplay&&e.togglePlay(!0)}let Un=!1;function Bn(e,t,r){jn()||Pipe.of("recommendation").fmap(_n,t,r).fmap(En).fmap(t=>t.then(t=>function(e,t){const r=t.playlist;if(e.opts.recommendations=r,!r.length)return;e.emit("recommendationsready",{playlist:r.map((function(e){var t;return{poster:e.poster,src:e.src,title:null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.title,metadata:e.metadata||{}}}))})}(e,t)).catch(Gn))}function jn(){return Un}function Gn(e){Un=!0,console.error("Failed to load recommendations: %j",e)}function Hn(e){return e&&e.live_start_time&&e.live_start_time-Date.now()>0}function Kn(e,t){let r=0;function n(){return function(e,t){const r=Date.now()-t;return Math.floor((e-r)/1e3)}(t.live_start_time||0,t.server_time_offset||0)}function i(){const i=n();if(i<0||isNaN(i)||0===e.reaper)return clearInterval(r),function(e,t){e.emit("ovp:live:countdown:complete");const r=Re(e,K);r&&r.remove(),e.root.classList.remove("is-livecountdown"),e.emit("ovp:request:media:complete",t)}(e,t);!function(e,t,r,n){r.classList.add("is-livecountdown"),t.emit("ovp:live:countdown:tick",{remaining_time:Vn(n+1)}),t.hasState(X)||t.setState(X,!0)}(0,e,e.root,i)}var a;a=t,gr().then(e=>Object.assign(a,{server_time_offset:e})),i(),r=setInterval(i,250)}function Vn(e){const t=function(e){"number"!=typeof e&&(e=parseInt(e,10)),e=Math.round(e);const t=Math.floor(e/86400);e-=86400*t;const r=Math.floor(e/3600);e-=3600*r;const n=Math.floor(e/60);return{days:t,hours:r,minutes:n,seconds:e-=60*n}}(e);let r="";return t.days&&(r+=t.days+":"),r+Ie(t.hours)+":"+Ie(t.minutes)+":"+Ie(t.seconds)}class WebsocketBridge{constructor(e){this.manualDisconnect=!1,this.video=e,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(e){return new WebsocketBridge(e)}connect(e){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+e),this.current_media_id=e,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(e){JSON.parse(e.data).forEach(e=>{this.video.emit("ovp:message:realtime",e)})}reconnect(e){this.cleanup(),this.connect(e)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(e){super(e),this.classList.add("fp-livecountdown");const t=Oe("fp-inner");this.append(t);const r=document.createElement("p");r.innerText=e.i18n("ovp.starting_in"),t.append(r);const n=document.createElement("p");n.classList.add("fp-countdown"),t.append(n),e.on("ovp:live:countdown:tick",t=>{const r=t.detail.remaining_time;e.root.classList.add("is-livecountdown"),n.innerText=r})}}const Wn=["*.lwcdn.com","*.flowplayer.com"];class OVP{constructor(e){ue(e,K,FlowplayerLiveCountdown)}onload(e,t,r,n){if("string"==typeof n.src)return"string"!=typeof e.player_id||0===n.src.indexOf(e.player_id)||kn(n)||(n.src=[e.player_id,n.src].join("/")),xn(r,n)}wants(e,t,r){return Rn(e,t)}init(e,t,r){const i=new WebsocketBridge(r);let a=Object.assign({},e);const s=function(e){if(!a)return e;delete a.src;const t=yn(e,a);return a=!1,t};r.on("ovp:error",(function(e){r.emit(n,e.data)})),r.on("ovp:request:start",(function(){r.setState(J,!0),e.recommendations&&(e.recommendations=!1)})),r.on("ovp:media:changed",(function({data:e}){var t;const r=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id;(null==e?void 0:e.live)&&r&&(i.disconnect(),i.connect(r))})),r.on("ovp:message:realtime",(function({data:t}){var n;const i=null==t?void 0:t.event,a=null==t?void 0:t.value,s=r.opt("metadata",{live_start_time:""});switch(i){case"METADATA":{const t=Object.assign(s,a),i=Object.assign(e,{metadata:t});i.live&&(null===(n=null==i?void 0:i.metadata)||void 0===n?void 0:n.live_start_time)&&(i.live_start_time=On(i.metadata.live_start_time)),r.setOpts(i);break}}})),r.on("beforeplay",(function(t){const r=e;if(Cn(r)){if(qn(r))return;t.preventDefault()}})),r.on("ovp:request:media:complete",(function(e){const t=e.data;if(!t)return;if(0==r.reaper||"object"!=typeof e.data||Hn(e.data))return;const n=s(t);r.setOpts(n),r.setAttrs(n),n.src&&r.setSrc(n.src),n.autoplay&&r.togglePlay(!0)})),r.on(S,(function({data:n}){var i,a;if("string"==typeof e.src&&Rn(e.src,{}))return;if(e.src&&zn(e.src))return;if((null==n?void 0:n.domains)&&(null==n?void 0:n.domains.length)&&!((e,t)=>{const r=e.split(".").reverse();return t.concat(Wn).some(e=>{const t=e.split(".").reverse(),n="*"===t[t.length-1];return n&&t.pop(),(n||t.length===r.length)&&t.every((e,t)=>r[t]===e)})})(function(){try{return window.location.hostname!==window.parent.location.hostname?Yt(document.referrer).hostname:document.location.hostname}catch(e){return window.location.hostname}}(),n.domains))return at({root:t,video:r,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(i=n.metadata)||void 0===i?void 0:i.player_id}.`,reason:"domain"}});const s=null==n?void 0:n.brand_color;return s&&r.root.style.setProperty("--fp-brand-color","#"==s[0]?s:"#"+s),"string"==typeof e.player_id&&(null===(a=null==e?void 0:e.metadata)||void 0===a?void 0:a.player_id)!==e.player_id?function(e,t){if("object"==typeof Fn[t])return console.debug("using Cache(%s)",t),Nn(e,t,Fn[t]);Pipe.of(t).fmap(_n).fmap(En).fmap(r=>r.then(r=>Nn(e,t,r)).catch(console.error))}(r,e.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(e){const t=e.data;if(!t||0==r.reaper)return;const{playlist:n}=t,i=ve(t,["playlist"]),a=s({playlist:i});Array.isArray(a.playlist)&&(a.playlist=i),r.setOpts(a);const o={type:"flowplayer/playlist",items:n};r.setSrc(o)})),r.on("ovp:live:countdown:start",(function(n){const i=n.data;if(!i||0==r.reaper)return;const a=s(i);if(r.setOpts(a),r.setAttrs(a),!Hn(i))return r.emit("ovp:request:media:complete",i);Re(r,K)||(t.appendChild(le(r,K)),Kn(r,e))})),r.on("timeupdate",(function(){var t,n,i;const a=e;Cn(a)?qn(a)||(r.togglePlay(!1),r.emit(_)):e.recommendations&&((null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.media_id)||Array.isArray(e.recommendations)||r.currentTime/r.duration<.8||jn()||(null===(n=null==e?void 0:e.metadata)||void 0===n?void 0:n.media_id)&&(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.player_id)&&Bn(r,e.metadata.media_id,e.metadata.player_id))})),r.on(A,(function(){i.disconnect()}))}}function qn(e){var t,r;const n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.live_stop_time;if(!n)return!0;return!!(null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.allow_after_stop_time)||On(n)>Date.now()}OVP.events=In;const zn=e=>{var t;if(e&&Array.isArray(e))return"object"==typeof e[0]&&"ovp/base64"===(null===(t=e[0])||void 0===t?void 0:t.type)};Qe(window,OVP);
372
- /*! native-plugin.js / 1.16.7 / 8017b3e4c408cd0f212db2300242817be04b6d2c / 2022-02-21T14:19:14+02:00 / (c) Flowplayer AB */
373
- var Yn=Et(_t((function(e,t){window,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=112)}([function(e,t,r){t.a={AD_INIT:"ad-initialized",AD_PLAYBACK_ERROR:"ad-playback-error",AD_TEARDOWN:"ad-teardown",AD_VIDEOTAG_ATTACHED:"ad-videotag-attached",AD_BLOCKED:"ad-blocked",AD_REQUEST_ERROR:"ad-request-error",AD_REQUESTED:"ad-requested",AD_REQUEST_COMPLETED:"ad-request-completed",AD_PAUSE_CONTENT:"ad-pause-content",AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_PAUSED:"ad-paused",AD_RESUMED:"ad-resumed",AD_WAITING:"ad-waiting",AD_PROGRESS:"ad-progress",AD_SKIPPED:"ad-skipped",AD_MUTED:"ad-muted",AD_VOLUME_CHANGED:"ad-volume-changed",AD_FULLSCREEN:"ad-fullscreen",AD_TIMEOUT:"ad-timeout",AD_BREAK_COMPLETED:"ad-break-completed",AD_POSTROLL_FINISHED:"ad-postroll-finished",AD_PREROLL_FINSIHED:"ad-preroll-finished",AD_MIDROLL_FINISHED:"ad-midroll-finished",VPAID_INIT:"vpaid-init",IMA_ADAPTER_INIT:"ad-ima-adapter-init",IMA_BEFORE_ADS_REQUEST:"ad-ima-before-ads-request",IMA_ADS_RENDERING_SETTINGS:"ad-ima-rendeding-settings",ADAPTER_INIT_FAILED:"ad-adapter-init-failed",AD_PLAY_REQUESTED:"ad-play-requested",RELOAD_AD_REQUESTED:"reload-ad-requested"}},function(e,t,r){e.exports=r(83)},function(e,t){function r(e,t,r,n,i,a,s){try{var o=e[a](s),l=o.value}catch(e){return void r(e)}o.done?t(l):Promise.resolve(l).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var s=e.apply(t,n);function o(e){r(s,i,a,o,l,"next",e)}function l(e){r(s,i,a,o,l,"throw",e)}o(void 0)}))}}},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,r){var n=r(28);e.exports=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},i=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),i.forEach((function(t){n(e,t,r[t])}))}return e}},function(e,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(t){return"function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?e.exports=n=function(e){return r(e)}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)},n(t)}e.exports=n},function(e,t,r){var n,i,a,s;function o(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}s=function(){return function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,r,n)}return r[s].exports}for(var a=!1,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){var n=1e3,i=6e4,a=60*i,s=24*a;function o(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}t.exports=function(e,t){t=t||{};var r,u,c=l(e);if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*a;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}(e);if("number"===c&&!1===isNaN(e))return t.long?(r=e,(u=Math.abs(r))>=s?o(r,u,s,"day"):u>=a?o(r,u,a,"hour"):u>=i?o(r,u,i,"minute"):u>=n?o(r,u,n,"second"):r+" ms"):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=a?Math.round(e/a)+"h":t>=i?Math.round(e/i)+"m":t>=n?Math.round(e/n)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],2:[function(e,t,r){var n,i,a=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function l(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var u,c=[],d=!1,f=-1;function h(){d&&u&&(d=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!d){var e=l(h);d=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,d=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function g(){}a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new v(e,t)),1!==c.length||d||l(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=g,a.addListener=g,a.once=g,a.off=g,a.removeListener=g,a.removeAllListeners=g,a.emit=g,a.prependListener=g,a.prependOnceListener=g,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],3:[function(e,t,r){t.exports=function(t){function r(e){for(var t=0,r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){var t;function s(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];if(s.enabled){var a=s,o=Number(new Date),l=o-(t||o);a.diff=l,a.prev=t,a.curr=o,t=o,r[0]=n.coerce(r[0]),"string"!=typeof r[0]&&r.unshift("%O");var u=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,(function(e,t){if("%%"===e)return e;u++;var i=n.formatters[t];if("function"==typeof i){var s=r[u];e=i.call(a,s),r.splice(u,1),u--}return e})),n.formatArgs.call(a,r);var c=a.log||n.log;c.apply(a,r)}}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=r(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){var e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){var r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){var e=[].concat(o(n.names.map(s)),o(n.skips.map(s).map((function(e){return"-"+e})))).join(",");return n.enable(""),e},n.enable=function(e){var t;n.save(e),n.names=[],n.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){var a=n.instances[t];a.enabled=n.enabled(a.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),Object.keys(t).forEach((function(e){n[e]=t[e]})),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=r,n.enable(n.load()),n}},{ms:1}],4:[function(e,t,r){(function(n){r.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":l(console))&&console.log&&(e=console).log.apply(e,arguments)},r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),this.useColors){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))})),e.splice(i,0,r)}},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){var e;try{e=r.storage.getItem("debug")}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e},r.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(r),t.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":3,_process:2}]},{},[4])(4)},"object"===l(t)&&void 0!==e?e.exports=s():(i=[],void 0===(a="function"==typeof(n=s)?n.apply(t,i):n)||(e.exports=a))},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(t)}e.exports=r},function(e,t,r){r.d(t,"a",(function(){return o}));var n=r(4),i=r.n(n),a=r(3),s=r.n(a),o=function(){function e(t,r){i()(this,e),this._nextIndex=0,this._postroll=0,this._loadPending=!1,this._opts=r||{},this.reset(t)}return s()(e,null,[{key:"of",value:function(t,r){return new e(t,r)}}]),s()(e,[{key:"toJSON",value:function(){var e=(this._ads||[]).slice(this._nextIndex);return this._postroll&&e.push(this._postroll),e}},{key:"reset",value:function(e){this.setAds(e),this._nextIndex=0,this._postrollActive=!1}},{key:"resetCounter",value:function(){this._nextIndex=0,this._postrollActive=!1}},{key:"setAds",value:function(e){this._ads=e||[],this.sort()}},{key:"getAds",value:function(){return this._ads}},{key:"getNextAd",value:function(e){return this._ads[this._nextIndex]||e}},{key:"getCurrentAd",value:function(){return this._postrollActive?this._postroll:this._loadPending?0:this._ads[this._nextIndex-1]}},{key:"getPostroll",value:function(){return this._postroll}},{key:"isDrained",value:function(){return this._nextIndex+1>this._ads.length}},{key:"setPostrollActive",value:function(){this._postrollActive=!0}},{key:"updateContentDuration",value:function(e){this._opts.content_duration=e}},{key:"increment",value:function(){++this._nextIndex}},{key:"decrement",value:function(){this._nextIndex>0&&--this._nextIndex}},{key:"getNextIndex",value:function(){return this._nextIndex}},{key:"getCurrentType",value:function(){return this.getCurrentAd()&&e.kindOf(this.getCurrentAd().time)}},{key:"sort",value:function(){var e=this;this._postroll=this._ads.filter((function(e){return-1===e.time}))[0],this._ads=this._ads.filter((function(t){return t!==e._postroll})).sort((function(t,r){return t.time===r.time?e._ads.indexOf(t)-e._ads.indexOf(r):t.time-r.time}))}},{key:"shallPlayAd",value:function(e){if(this._loadPending)return!1;var t=this.getCurrentAd()||this.getNextAd();return!!(t&&t.time<=e&&-1!==t.time)}},{key:"shallPlayNext",value:function(){var e=this.getNextAd(),t=this.getCurrentAd();return!(!e||!t||e.time!==t.time)}},{key:"waitForLoad",value:function(e,t,r){if(this._loadPending=!1,!t)return!1;var n=r?this._opts.preload_advance:0;return t.time>=0?this._loadPending=e<t.time-n:-1===t.time&&(this._loadPending=this._opts.content_duration>0&&-1!==e?e<this._opts.content_duration-n:-1!==e),this._loadPending}}],[{key:"hasPreroll",value:function(e){return!!e.find((function(e){return 0===e.time}))}},{key:"isOutstream",value:function(t){return e.hasPreroll(t)&&!!t[0].outstream}},{key:"kindOf",value:function(e){switch(e){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}]),e}()},function(e,t){var r=e.exports={version:"2.6.11"};"number"==typeof __e&&(__e=r)},function(e,t,r){var n=r(6),i=r(17);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?i(e):t}},function(e,t,r){var n=r(52);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}},function(e,t){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,r){e.exports=!r(23)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(e,t,r){var n=r(13),i=r(10),a=r(22),s=r(61),o=r(34),l=function(e,t,r){var u,c,d,f,h=e&l.F,p=e&l.G,v=e&l.S,g=e&l.P,m=e&l.B,y=p?n:v?n[t]||(n[t]={}):(n[t]||{}).prototype,E=p?i:i[t]||(i[t]={}),_=E.prototype||(E.prototype={});for(u in p&&(r=t),r)d=((c=!h&&y&&void 0!==y[u])?y:r)[u],f=m&&c?o(d,n):g&&"function"==typeof d?o(Function.call,d):d,y&&s(y,u,d,e&l.U),E[u]!=d&&a(E,u,f),g&&_[u]!=d&&(_[u]=d)};n.core=i,l.F=1,l.G=2,l.S=4,l.P=8,l.B=16,l.W=32,l.U=64,l.R=128,e.exports=l},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,r){var n=r(86),i=r(87),a=r(88);e.exports=function(e,t){return n(e)||i(e,t)||a()}},function(e,t,r){e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r=function(e,t){var r,n,i,a=e[1]||"",s=e[3];if(!s)return a;if(t&&"function"==typeof btoa){var o=(r=s,n=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),"/*# ".concat(i," */")),l=s.sources.map((function(e){return"/*# sourceURL=".concat(s.sourceRoot).concat(e," */")}));return[a].concat(l).concat([o]).join("\n")}return[a].join("\n")}(t,e);return t[2]?"@media ".concat(t[2],"{").concat(r,"}"):r})).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var n={},i=0;i<this.length;i++){var a=this[i][0];null!=a&&(n[a]=!0)}for(var s=0;s<e.length;s++){var o=e[s];null!=o[0]&&n[o[0]]||(r&&!o[2]?o[2]=r:r&&(o[2]="(".concat(o[2],") and (").concat(r,")")),t.push(o))}},t}},function(e,t,r){var n,i={},a=function(){var e={};return function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}e[t]=r}return e[t]}}();function s(e,t){for(var r=[],n={},i=0;i<e.length;i++){var a=e[i],s=t.base?a[0]+t.base:a[0],o={css:a[1],media:a[2],sourceMap:a[3]};n[s]?n[s].parts.push(o):r.push(n[s]={id:s,parts:[o]})}return r}function o(e,t){for(var r=0;r<e.length;r++){var n=e[r],a=i[n.id],s=0;if(a){for(a.refs++;s<a.parts.length;s++)a.parts[s](n.parts[s]);for(;s<n.parts.length;s++)a.parts.push(v(n.parts[s],t))}else{for(var o=[];s<n.parts.length;s++)o.push(v(n.parts[s],t));i[n.id]={id:n.id,refs:1,parts:o}}}}function l(e){var t=document.createElement("style");if(void 0===e.attributes.nonce){var n=r.nc;n&&(e.attributes.nonce=n)}if(Object.keys(e.attributes).forEach((function(r){t.setAttribute(r,e.attributes[r])})),"function"==typeof e.insert)e.insert(t);else{var i=a(e.insert||"head");if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(t)}return t}var u,c=(u=[],function(e,t){return u[e]=t,u.filter(Boolean).join("\n")});function d(e,t,r,n){var i=r?"":n.css;if(e.styleSheet)e.styleSheet.cssText=c(t,i);else{var a=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(a,s[t]):e.appendChild(a)}}function f(e,t,r){var n=r.css,i=r.media,a=r.sourceMap;if(i&&e.setAttribute("media",i),a&&btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var h=null,p=0;function v(e,t){var r,n,i;if(t.singleton){var a=p++;r=h||(h=l(t)),n=d.bind(null,r,a,!1),i=d.bind(null,r,a,!0)}else r=l(t),n=f.bind(null,r,t),i=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(r)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else i()}}e.exports=function(e,t){(t=t||{}).attributes="object"==typeof t.attributes?t.attributes:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=(void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n));var r=s(e,t);return o(r,t),function(e){for(var n=[],a=0;a<r.length;a++){var l=r[a],u=i[l.id];u&&(u.refs--,n.push(u))}e&&o(s(e,t),t);for(var c=0;c<n.length;c++){var d=n[c];if(0===d.refs){for(var f=0;f<d.parts.length;f++)d.parts[f]();delete i[d.id]}}}}},function(e,t,r){r.d(t,"b",(function(){return U})),r.d(t,"a",(function(){return N}));var n=r(47),i=r.n(n),a=r(4),s=r.n(a),o=r(3),l=r.n(o),u=r(28),c=r.n(u),d=r(7),f=r.n(d),h=r(18),p=r.n(h),v={ok:f()("fpads:analytics:request-queue"),err:f()("fpads:analytics:request-queue:err"),warn:f()("fpads:analytics:request-queue:warn")},g=function(){function e(){s()(this,e),this.pending=[],this.open=[],this.stats={failures:0,ttl:0}}return l()(e,null,[{key:"of",value:function(){return new e}},{key:"is_empty",value:function(e){return 0==e.pending.size}},{key:"is_high_water",value:function(t){return t.open.size==e.MAX_OPEN_REQUESTS}},{key:"maybe_spawn_req",value:function(t){if(e.is_empty(t))return v.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(e.is_high_water(t))return v.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),t;try{e.request(t,e.lpop(t))}catch(e){v.err(e)}}},{key:"increment_failures",value:function(t){return t.stats.failures++,t.stats.failures>e.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+e.REQUEST_TTL_MS),t}},{key:"handle_error",value:function(t,r){e.rm(t,r),e.increment_failures(t)}},{key:"request",value:function(t,r){var n=p()(r,3),i=n[0],a=n[1],s=n[2];if(v.ok("Request[".concat(s.event_type,"] request"),s,t.stats),Date.now()<t.stats.ttl)return v.warn("Request[".concat(s.event_type,"] skipping because too many errors too quickly"),t.stats);var o=new XMLHttpRequest;t.open.push(o),o.timeout=e.REQUEST_TIMEOUT_MS,o.ontimeout=function(){e.handle_error(t,o),v.warn("Request[".concat(s.event_type,"] timed out in ").concat(o.timeout,"ms"),t.stats)},o.onerror=function(r){e.handle_error(t,o),r&&v.err(r),v.warn("Request[".concat(s.event_type,"] encountered an Error"),o.responseText,t.stats)},o.onreadystatechange=function(){o.readyState==XMLHttpRequest.DONE&&e.rm(t,o),Math.floor(o.status/100)},o.onload=function(){e.rm(t,o),t.stats.failures&&t.stats.failures--,v.ok("Request[".concat(s.event_type,"] :ok"),o.stats)},o.open(a,i),o.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{o.send(JSON.stringify(s))}catch(e){v.err(e)}}},{key:"rpush",value:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return n.forEach((function(r){if(t.pending.length>=e.HIGH_WATER_PENDING)return v.warn("Too many open requests, skipping",t.stats);t.pending.push(r),e.maybe_spawn_req(t)})),t}},{key:"lpop",value:function(e){return e.pending.shift()}},{key:"rm",value:function(e,t){var r=e.open.lastIndexOf(t);return~r&&e.open.splice(r,1),e}}]),e}();g.MAX_OPEN_REQUESTS=3,g.MAX_PENDING=5,g.REQUEST_TIMEOUT_MS=4e3,g.REQUEST_TTL_MS=5e3,g.MAX_FAILURE_COUNT=3;var m=r(48),y=r.n(m),E=r(49),_=r(7)("fpads:device"),T=y.a.parse(window.navigator.userAgent),b=T.platform,A=T.os,S=T.browser;_(T);var w=function(e){return e&&e.toLowerCase()},L={rnd:Math.random().toString(36).substr(2,32),os:w(A.name+(A.versionName?" ".concat(A.versionName):"")),device:w(b.type),browser:w(S.name),browser_version:(S&&S.version?S.version:"unknown").split(".").shift(),plugin_version:E.version},k=r(0),R="https://fp-eu-w1-aai.flowplayer.com/in",D="POST",O=[k.a.AD_REQUESTED,k.a.AD_REQUEST_ERROR,k.a.AD_REQUEST_COMPLETED,k.a.AD_COMPLETED,k.a.AD_STARTED,k.a.AD_ERROR,k.a.AD_SKIPPED],C=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],I=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],x=f()("fpads:analytics"),P=g.of(),M=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Object.assign.apply(Object,[{}].concat(t))},F=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return Object.keys(e).filter((function(e){return~r.indexOf(e)})).reduce((function(t,r){return Object.assign(t,c()({},r,e[r]))}),{})},N=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s()(this,e),this.metadata=M(L,r.metadata||{}),this.emitter=t,this.events=r.events||[],this.required_keys=r.required_keys||[],this.optional_keys=r.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),x(this),this.wireup()}return l()(e,null,[{key:"of",value:function(t,r){return new e(t,r)}},{key:"ensure_required_keys",value:function(e,t){return e.required_keys.filter((function(e){return!(e in t)}))}},{key:"pluck_valid_keys",value:function(e,t){return F.apply(void 0,[t].concat(i()(e.valid_keys)))}},{key:"mergeMetadata",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.metadata=e.pluck_valid_keys(t,M(t.metadata,r,{player_version:window.flowplayer.version})),t}}]),l()(e,[{key:"wireup",value:function(){var t=this;t.events.forEach((function(r){t.emitter.on(r,(function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=M(t.metadata,{event_type:r},n),a=e.pluck_valid_keys(t,i),s=e.ensure_required_keys(t,a);if(x("Event[".concat(r,"]"),{payload:a,observation:n}),s.length)return x("Analytics.validate_metadata() failed for \n Event[".concat(r,"]\n missing keys: ").concat(s),a);g.rpush(P,[R,D,a])}))}))}},{key:"destroy",value:function(){this.metadata=void 0,this.emitter=void 0,this.events=void 0,this.required_keys=void 0,this.optional_keys=void 0,this.valid_keys=void 0}}]),e}(),U=function(e){return N.of(e,{required_keys:C,optional_keys:I,events:O})}},function(e,t,r){var n=r(55),i=r(60);e.exports=r(14)?function(e,t,r){return n.f(e,t,i(1,r))}:function(e,t,r){return e[t]=r,e}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){var r=0,n=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+n).toString(36))}},function(e,t,r){var n=r(10),i=r(13),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return a[e]||(a[e]=void 0!==t?t:{})})("versions",[]).push({version:n.version,mode:r(63)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(e,t,r){var n=r(27),i=r(37);e.exports=function(e){return n(i(e))}},function(e,t,r){var n=r(36);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==n(e)?e.split(""):Object(e)}},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t,r){r(8);var n=r(85);function i(t,r,a){return"undefined"!=typeof Reflect&&Reflect.get?e.exports=i=Reflect.get:e.exports=i=function(e,t,r){var i=n(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(r):a.value}},i(t,r,a||t)}e.exports=i},function(e,t,r){var n,i="object"==typeof Reflect?Reflect:null,a=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(){void 0!==a&&e.removeListener("error",a),r([].slice.call(arguments))}var a;"error"!==t&&(a=function(r){e.removeListener(t,i),n(r)},e.once("error",a)),e.once(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var l=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var i,a,s,o;if(u(r),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),s=a[t]),void 0===s)s=a[t]=r,++e._eventsCount;else if("function"==typeof s?s=a[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,o=l,console&&console.warn&&console.warn(o)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):g(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function g(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)a(l,this,t);else{var u=l.length,c=g(l,u);for(r=0;r<u;++r)a(c[r],this,t)}return!0},o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)},o.prototype.once=function(e,t){return u(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,a,s;if(u(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length-1;a>=0;a--)if(r[a]===t||r[a].listener===t){s=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,a=Object.keys(r);for(n=0;n<a.length;++n)"removeListener"!==(i=a[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){var n=r(89),i=r(90),a=r(45);e.exports={formats:a,parse:i,stringify:n}},function(e,t,r){r.d(t,"a",(function(){return f}));var n=r(1),i=r.n(n),a=r(2),s=r.n(a),o=(new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"}));function l(e){return Object.assign({muted:!1,timeout:250,inline:!1},e)}function u(e,t){var r=e.muted,n=e.timeout,i=e.inline,a=t(),s=a.element,o=a.source,l=void 0,u=void 0,c=void 0;return s.muted=r,!0===r&&s.setAttribute("muted","muted"),!0===i&&s.setAttribute("playsinline","playsinline"),s.src=o,new Promise((function(e){l=s.play(),u=setTimeout((function(){c(!1,new Error("Timeout "+n+" ms has been reached"))}),n),c=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(u),e({result:t,error:r})},void 0!==l?l.then((function(){return c(!0)})).catch((function(e){return c(!1,e)})):c(!0)}))}var c=function(e){return u(e=l(e),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(o)}}))},d=void 0;function f(){return h.apply(this,arguments)}function h(){return(h=s()(i.a.mark((function e(){var t,r=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=!(r.length>0&&void 0!==r[0])||r[0],!d){e.next=3;break}return e.abrupt("return",d);case 3:return e.next=5,c({timeout:500,muted:t});case 5:return d=e.sent,e.abrupt("return",d);case 7:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}},function(e,t){var r={}.hasOwnProperty;e.exports=function(e,t){return r.call(e,t)}},function(e,t,r){var n=r(64);e.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,r){var n=r(66),i=r(70);e.exports=Object.keys||function(e){return n(e,i)}},function(e,t){var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,r){var n=r(39),i=Math.min;e.exports=function(e){return e>0?i(n(e),9007199254740991):0}},function(e,t){var r=Math.ceil,n=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?n:r)(e)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,r){var n=r(37);e.exports=function(e){return Object(n(e))}},function(e,t,r){var n=r(14),i=r(35),a=r(26),s=r(40).f;e.exports=function(e){return function(t){for(var r,o=a(t),l=i(o),u=l.length,c=0,d=[];u>c;)r=l[c++],n&&!s.call(o,r)||d.push(e?[r,o[r]]:o[r]);return d}}},function(e,t,r){var n=r(25)("wks"),i=r(24),a=r(13).Symbol,s="function"==typeof a;(e.exports=function(e){return n[e]||(n[e]=s&&a[e]||(s?a:i)("Symbol."+e))}).store=n},function(e,t,r){var n=Object.prototype.hasOwnProperty,i=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var i=t[n],a=i.obj[i.prop],s=Object.keys(a),o=0;o<s.length;++o){var l=s[o],u=a[l];"object"==typeof u&&null!==u&&-1===r.indexOf(u)&&(t.push({obj:a,prop:l}),r.push(u))}return function(e){for(var t;e.length;){var r=e.pop();if(t=r.obj[r.prop],Array.isArray(t)){for(var n=[],i=0;i<t.length;++i)void 0!==t[i]&&n.push(t[i]);r.obj[r.prop]=n}}return t}(t)},decode:function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},encode:function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),r="",n=0;n<t.length;++n){var a=t.charCodeAt(n);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?r+=t.charAt(n):a<128?r+=i[a]:a<2048?r+=i[192|a>>6]+i[128|63&a]:a<55296||a>=57344?r+=i[224|a>>12]+i[128|a>>6&63]+i[128|63&a]:(n+=1,a=65536+((1023&a)<<10|1023&t.charCodeAt(n)),r+=i[240|a>>18]+i[128|a>>12&63]+i[128|a>>6&63]+i[128|63&a])}return r},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,r,i){if(!r)return t;if("object"!=typeof r){if(Array.isArray(t))t.push(r);else{if("object"!=typeof t)return[t,r];(i.plainObjects||i.allowPrototypes||!n.call(Object.prototype,r))&&(t[r]=!0)}return t}if("object"!=typeof t)return[t].concat(r);var s=t;return Array.isArray(t)&&!Array.isArray(r)&&(s=a(t,i)),Array.isArray(t)&&Array.isArray(r)?(r.forEach((function(r,a){n.call(t,a)?t[a]&&"object"==typeof t[a]?t[a]=e(t[a],r,i):t.push(r):t[a]=r})),t):Object.keys(r).reduce((function(t,a){var s=r[a];return n.call(t,a)?t[a]=e(t[a],s,i):t[a]=s,t}),s)}}},function(e,t,r){var n=String.prototype.replace,i=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return n.call(e,i,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(e,t,r){r.d(t,"a",(function(){return n})),new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"});var n=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"})},function(e,t,r){var n=r(91),i=r(92),a=r(93);e.exports=function(e){return n(e)||i(e)||a()}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),a=e.getVersionPrecision(r),s=Math.max(i,a),o=0,l=e.map([t,r],(function(t){var r=s-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(o=s-Math.min(i,a)),s-=1;s>=o;){if(l[0][s]>l[1][s])return 1;if(l[0][s]===l[1][s]){if(s===o)return 0;s-=1}else if(l[0][s]<l[1][s])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},a=r(18),s=function(){function e(){}var t;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},(t=[{key:"BROWSER_MAP",get:function(){return a.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return a.ENGINE_MAP}},{key:"OS_MAP",get:function(){return a.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return a.PLATFORMS_MAP}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e,t),e}();t.default=s,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=l(r(92)),i=l(r(93)),a=l(r(94)),s=l(r(95)),o=l(r(17));function l(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=n.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=i.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=s.default.find((function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return Object.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},a=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(i[t]=s,a+=1):"object"==typeof s&&(r[t]=s,n+=1)})),n>0){var s=Object.keys(r),o=s.find((function(e){return t.isOS(e)}));if(o){var l=this.satisfies(r[o]);if(void 0!==l)return l}var u=s.find((function(e){return t.isPlatform(e)}));if(u){var c=this.satisfies(r[u]);if(void 0!==c)return c}}if(a>0){var d=Object.keys(i).find((function(e){return t.isBrowser(e,!0)}));if(void 0!==d)return this.compareVersion(i[d])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=o.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(o.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e){return this.isBrowser(e)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},a=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(a,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(a,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},a=r(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:a.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.WindowsPhone,version:t}}},{test:[/windows/i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:a.OS_MAP.Windows,version:t,versionName:r}}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:a.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:a.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:a.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:a.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:a.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:a.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:a.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:a.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},a=r(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:a.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:a.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:a.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:a.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:a.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:a.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:a.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},a=r(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:a.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:a.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:a.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:a.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:a.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:a.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:a.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=s,e.exports=t.default}})},function(e){e.exports=JSON.parse('{"name":"@flowplayer/ads","version":"1.16.7","description":"","main":"index.js","scripts":{"lint":"eslint src","test:debug":"DEBUG=collector:* jest -i","test":"jest -i","dev":"NODE_ENV=development TARGET=unlocked webpack-dev-server --progress --colors --port 8844 --host 0.0.0.0","prod":"webpack -p","build":"webpack","prepublish":"rm -rf dist/ && NO_DEMOS=true npm run build:unlocked && npx uglifyjs dist/native.js","build:locked":"TARGET=locked webpack","build:unlocked":"TARGET=unlocked webpack","collector":"node node_modules/.bin/collector","rel":"git tag -d production && git push origin :production && git tag production && git push origin --tags","test:browserstack":"jest -i --testMatch=**/test/browserstack/*.spec.js","test:unit":"jest -i --env jsdom --testMatch \'<rootDir>/test/unit/**/*.spec.js\'"},"husky":{"hooks":{"pre-commit":"yarn lint","post-merge":"yarn"}},"jest":{"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)(spec|test).js?(x)"],"testURL":"https://flowplayer.com/videos/fake","moduleNameMapper":{"<%TARGET%>":"<rootDir>/test/jest/transform.js"},"globalSetup":"./test/jest/setup","globalTeardown":"./test/jest/teardown","testEnvironment":"./test/jest/browserstack","bail":true},"author":"","license":"ISC","devDependencies":{"@babel/core":"^7.1.0","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/plugin-syntax-object-rest-spread":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.1.0","@babel/runtime":"^7.0.0","@flowplayer/collector":"^0.2.2","babel-core":"^7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","babel-loader":"^8.0.2","chai":"^4.1.2","css-loader":"^3.1.0","eslint":"^5.5.0","eslint-import-resolver-webpack":"^0.12.0","eslint-plugin-import":"^2.14.0","git-rev-sync":"^2.0.0","handlebars":"^4.7.7","handlebars-loader":"^1.7.0","html-webpack-plugin":"^4.0.3","husky":"^4.3.0","jest":"^26.4.2","moment":"^2.19.2","sass":"^1.49.0","sass-loader":"^8.0.0","style-loader":"^1.0.0","webpack":"^4.37.0","webpack-cli":"^3.1.1","webpack-dev-server":"^3.1.11"},"dependencies":{"bean":"^1.0.15","bowser":"^2.7.0","can-autoplay":"^3.0.0","core-js":"^2.5.7","debug":"^4.0.1","es6-event-emitter":"^1.10.2"}}')},function(e,t,r){function n(e,t){var r=!1,n=function(){var n,i=(n=e.getBoundingClientRect()).top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)+n.height&&n.right<=(window.innerWidth||document.documentElement.clientWidth)+n.width;i!==r&&t(i),r=i};return setTimeout(n),document.addEventListener("scroll",n),function(){return document.removeEventListener("scroll",n)}}r.d(t,"a",(function(){return n}))},function(e,t,r){r.d(t,"a",(function(){return ae}));var n=r(1),i=r.n(n),a=r(2),s=r.n(a),o=r(5),l=r.n(o),u=r(4),c=r.n(u),d=r(3),f=r.n(d),h=r(11),p=r.n(h),v=r(8),g=r.n(v),m=r(12),y=r.n(m),E=r(17),_=r.n(E),T=r(29),b=r.n(T),A=r(0),S=r(6),w=r.n(S),L=r(7)("fpads:timers"),k=-1,R=function(){function e(){c()(this,e),this.intervals={},this.timers={}}return f()(e,null,[{key:"of",value:function(){return new e}},{key:"id",value:function(){return++k}},{key:"createTimeout",value:function(t,r,n){var i=setTimeout((function(){delete t.timers[i],n()}),r);if(L("TimerRegistry.createTimeout() -> ".concat(i),t.timers),"object"==w()(i)){var a=e.id();return t.timers[a]=i,a}return t.timers[i]=i,i}},{key:"removeTimeout",value:function(e,t){return L("TimerRegistry.removeTimeout() -> ".concat(t),e.timers),clearTimeout(e.timers[t]),delete e.timers[t],e}},{key:"createInterval",value:function(t,r,n){var i=setInterval(n,r);if(L("TimerRegistry.createInterval() -> ".concat(i),t.intervals),"object"==w()(i)){var a=e.id();return t.intervals[a]=i,a}return t.intervals[i]=i,i}},{key:"removeInterval",value:function(e,t){return L("TimerRegistry.removeInterval() -> ".concat(t),e.intervals),clearInterval(e.intervals[t]),delete e.intervals[t],e}},{key:"empty",value:function(t){if(t)return L("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach((function(r){return e.removeInterval(t,r)})),Object.keys(t.timers).forEach((function(r){return e.removeTimeout(t,r)})),t}}]),e}(),D=r(9),O=function(e,t){var r="".concat(e,"() not implemented by the adapter");if(t)throw new Error(r);console.warning(r)},C=function(){function e(){c()(this,e)}var t,r,n;return f()(e,[{key:"initialize",value:function(e){O("initialize",!0)}},{key:"reset",value:function(){O("reset",!0)}},{key:"destroy",value:function(){O("destroy",!0)}},{key:"stop",value:function(){O("stop",!0)}},{key:"initAd",value:(n=s()(i.a.mark((function e(t,r){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O("initAd",!0);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"playAd",value:(r=s()(i.a.mark((function e(){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O("playAd",!0);case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"pause",value:function(){O("pause",!1)}},{key:"resume",value:function(){O("resume",!1)}},{key:"volume",value:function(e){O("volume",!1)}},{key:"contentComplete",value:(t=s()(i.a.mark((function e(){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O("contentComplete",!1);case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onResize",value:function(e){O("onResize",!1)}},{key:"isUiDisabled",value:function(){return!1}},{key:"getAdPodInfo",value:function(){return null}},{key:"isAdPod",value:function(){return!1}},{key:"canDismissNonLinear",value:function(){return!1}}]),e}(),I=r(7)("fpads:adapter:base"),x=function(e){function t(e){var r;return c()(this,t),(r=p()(this,g()(t).call(this))).eventHandler=e,r.opts={},r._prepared=void 0,r._initialized=void 0,r._videoTag=void 0,r._dimensions=void 0,r._sharedVideoTag=void 0,r._autoplayResult=void 0,r._adLinear=!0,r._paused=!0,r}var r,n,a;return y()(t,e),f()(t,[{key:"destroy",value:function(){this.eventHandler=void 0,this._videoTag=void 0}},{key:"stop",value:function(){}},{key:"isReady",value:function(){return!!this._initialized}},{key:"init",value:(a=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(I("init",this._videoTag,t),this.opts=t,this._dimensions={width:t.width,height:t.height},this._prepared=!0,this._initialized||!this._videoTag){e.next=7;break}return e.next=7,this.initAdapter();case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"setVideoTag",value:(n=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._videoTag=t,this._initialized||!this._prepared){e.next=4;break}return e.next=4,this.initAdapter();case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"initAdapter",value:(r=s()(i.a.mark((function e(){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I("initAdapter",this.opts),e.prev=1,e.next=4,this.initialize(this.opts);case 4:this._initialized=!0,e.next=12;break;case 7:e.prev=7,e.t0=e.catch(1),I("initAdapter failed:",e.t0),this._prepared=!1,this.eventHandler.trigger(A.a.ADAPTER_INIT_FAILED);case 12:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return r.apply(this,arguments)})},{key:"setIOSPlaysInline",value:function(e){I("setIOSPlaysInline",e),this._sharedVideoTag=!e,this.initialize(l()({},this.opts,{DisableCustomPlaybackForIOS10Plus:e}))}},{key:"resize",value:function(e){var t=e.width,r=e.height,n=e.linear,i=e.silent,a=e.resize_non_linear;!1===n&&(t+=10,r+=10),this._adLinear=void 0===n?this._adLinear:n,this.onResize({width:t,height:r,linear:this._adLinear,silent:i,resize_non_linear:a}),this._dimensions={width:t,height:r,linear:n}}},{key:"dimensions",get:function(){return this._dimensions}},{key:"videoTag",get:function(){return this._videoTag}},{key:"adLinear",get:function(){return this._adLinear}},{key:"sharedVideoTag",get:function(){return this._sharedVideoTag}},{key:"paused",get:function(){return this._paused}}]),t}(C);function P(e){try{return e.getAdPodInfo().getPodIndex()}catch(e){return}}var M=r(7)("fpads:adapter:ima"),F=function(e){function t(e){var r;return c()(this,t),(r=p()(this,g()(t).call(this,e)))._adHandlers=[],r._timers=R.of(),r._started=!1,r._volumeLevel=0,r._adLoaded=!1,r._currentDuration=0,r._currentRemaining=0,r._currentDisplayTs=0,r}var r,n,a,o;return y()(t,e),f()(t,[{key:"destroy",value:function(){b()(g()(t.prototype),"destroy",this).call(this),R.empty(this._timers),this._adHandlers&&this._adHandlers.forEach((function(e){return e()})),this._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),this._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),this._adsManager=void 0}},{key:"stop",value:function(){b()(g()(t.prototype),"stop",this).call(this),this._adsManager&&this._adsManager.stop()}},{key:"initialize",value:function(e){var r=this,n=this.isAdPod(),i=this._adLoaded||n;this.cleanup();var a=this;this.opts=e,this._volumeLevel=e.volume;var s=google.ima.settings;e.NumRedirects=e.NumRedirects||e.redirects,Object.keys(e).forEach((function(t){void 0!==s["set".concat(t)]&&s["set".concat(t)](e[t])}));var o={VpaidMode:google.ima.ImaSdkSettings.VpaidMode.INSECURE,DisableCustomPlaybackForIOS10Plus:!0};Object.keys(o).filter((function(t){return void 0===e[t]})).forEach((function(e){return s["set".concat(e)](o[e])})),this._adDisplayContainer=new google.ima.AdDisplayContainer(e.container,this.videoTag),this._adDisplayContainer.initialize(),this._adsLoader=new google.ima.AdsLoader(this._adDisplayContainer),M("ima.initialise(:wait -> ADS_MANAGER_LOADED)",l()({},e,{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(function(n){M("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",l()({},e,{volume:r.videoTag.volume,muted:r.videoTag.muted}));var i=new google.ima.AdsRenderingSettings;M("ima.rendering(preload: %s)",!!e.preload_ads),i.useStyledNonLinearAds=!0,i.enablePreloading=!!e.preload_ads,"number"==typeof e.media_timeout&&(i.loadVideoTimeout=e.media_timeout),i.restoreCustomPlaybackStateOnAdBreakComplete=!e.DisableCustomPlaybackForIOS10Plus,r.sharedVideoTag&&(i.playAdsAfterTime=r.videoTag.currentTime),r.eventHandler.trigger(A.a.IMA_ADS_RENDERING_SETTINGS,i);var s=r._adsManager=n.getAdsManager(r.videoTag,i);r.eventHandler.trigger(A.a.IMA_ADAPTER_INIT,s),s.addEventListener(google.ima.AdEvent.Type.LOADED,(function(){M("debug(ima.adsManager): google.ima.AdEvent.Type.LOADED")})),s.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,(function(){M("debug(ima.adsManager): google.ima.AdErrorEvent.Type.AD_ERROR")})),s.addEventListener(google.ima.AdEvent.Type.STARTED,(function(){M("debug(ima.adsManager): google.ima.AdEvent.Type.STARTED")})),s.addEventListener(google.ima.AdEvent.Type.STARTED,(function(e){a.debugEvent(e);var n=e.getAd();a._currentDuration=n.getDuration(),a._currentDisplayTs=Date.now(),r.emitWithAd(A.a.AD_STARTED,n),n.isLinear()&&t.pollRemaining({ima:a,adsManager:s})})),s.addEventListener(google.ima.AdEvent.Type.COMPLETE,(function(e){a.debugEvent(e),a.emitWithAd(A.a.AD_COMPLETED,e.getAd()),R.empty(r._timers)})),s.addEventListener(google.ima.AdEvent.Type.SKIPPED,(function(e){a.debugEvent(e),a.emitWithAd(A.a.AD_SKIPPED,e.getAd())})),s.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,(function(e){a.debugEvent(e),a.emitWithAd(A.a.AD_PAUSE_CONTENT,e.getAd())})),s.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,(function(e){a.debugEvent(e),a._started=!1,a._currentDisplayTs=0,a.eventHandler.trigger(A.a.AD_BREAK_COMPLETED)})),s.addEventListener(google.ima.AdEvent.Type.VOLUME_CHANGED,(function(e){M("IMA::volume(type: %s, event: %o)",e.type,e);var t=s.getVolume();a._volumeLevel=t,a.eventHandler.trigger(A.a.AD_VOLUME_CHANGED,t)}));var o=function(e){a._paused=e,a.eventHandler.trigger(e?A.a.AD_PAUSED:A.a.AD_RESUMED)};s.addEventListener(google.ima.AdEvent.Type.PAUSED,(function(){return o(!0)})),s.addEventListener(google.ima.AdEvent.Type.RESUMED,(function(){return o(!1)})),s.addEventListener(google.ima.AdEvent.Type.STARTED,(function(){return o(!1)})),s.addEventListener(google.ima.AdEvent.Type.VOLUME_MUTED,(function(e){M("IMA::volume(type: %s, event: %o)",e.type,e),a.eventHandler.trigger(A.a.AD_MUTED)})),s.init(r.opts.width,r.opts.height,google.ima.ViewMode.NORMAL),M("ima.initialise: done initializing")})),i&&(M("Event(reload: %s)",A.a.RELOAD_AD_REQUESTED),a.eventHandler.trigger(A.a.RELOAD_AD_REQUESTED,n)),this.eventHandler.trigger(A.a.AD_INIT,this)}},{key:"destroyManager",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"unknown";if(!this._adsManager)return M("ima::destroyManager(:skip, label: %s)",e);M("ima::destroyManager(:ok, label: %s)",e),this._adsManager.destroy()}},{key:"reset",value:function(){this.destroyManager("reset"),R.empty(this._timers),this.clearAdHandlers(),this._started=!1,this._adLoaded=!1}},{key:"cleanup",value:function(){this.destroyManager("cleanup"),this._adsLoader&&this._adsLoader.destroy(),this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adLoaded=!1}},{key:"waitForAdsManager",value:function(){var e=this;return new Promise((function(t){M("ima.waitForAdsManager:",e._adsManager),e.once(e._adsLoader,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(function(){M("ima.waitForAdsManager(:ok)",e._adsManager),t(e._adsManager)}))}))}},{key:"initAd",value:(o=s()(i.a.mark((function e(t){var r,n=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:5e3,M("ima.initAd(adTag: ".concat(t,", timeout: ").concat(r,")")),e.prev=2,e.next=5,this.requestAd(t,r);case 5:this._adLoaded=!0,e.next=13;break;case 8:throw e.prev=8,e.t0=e.catch(2),M("ima.initAd:",e.t0),this._adLoaded=!1,e.t0;case 13:return e.prev=13,R.empty(this._timers),e.finish(13);case 16:case"end":return e.stop()}}),e,this,[[2,8,13,16]])}))),function(e){return o.apply(this,arguments)})},{key:"requestAd",value:(a=s()(i.a.mark((function e(t,r){var n,a,o,u,c,d,f,h,p,v=this;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.destroyManager("requestAd"),n=this,o=this.opts.autoplay,u=void 0!==o&&o,c=Date.now(),d=this.videoTag.muted,this._volumeLevel=this.videoTag.volume,f=d||0==this._volumeLevel,n._all_ads_completed=!1,M("ima.requestAd(%o)",l()({},this.opts,{autoplay:u,muted:d,timeout:r,adTag:t,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers(),(h=new google.ima.AdsRequest).adTagUrl=t,h.linearAdSlotWidth=this.opts.width,h.linearAdSlotHeight=this.opts.height,this.opts.disable_non_linear_ads||(h.nonLinearAdSlotWidth=this.opts.width),this.opts.disable_non_linear_ads||(h.nonLinearAdSlotHeight=this.opts.height-50),h.setAdWillAutoPlay(u),h.setAdWillPlayMuted(f),h.vastLoadTimeout=r,this.eventHandler.trigger(A.a.IMA_BEFORE_ADS_REQUEST,{request:h}),this._adsLoader.requestAds(h),p=new Promise(function(){var e=s()(i.a.mark((function e(t,s){var o,l,u,d,h;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=function(){clearTimeout(u),t.apply(void 0,arguments)},l=function(){clearTimeout(u),s.apply(void 0,arguments)},v.once(v._adsLoader,google.ima.AdErrorEvent.Type.AD_ERROR,(function(e){v.emitError(A.a.AD_REQUEST_ERROR,e),l(new Error("Ad load failed"))})),u=setTimeout((function(){var e=new Error("Ad internal timeout reached");v.eventHandler.trigger(A.a.AD_TIMEOUT,e),s(e)}),1.5*(r+(v.opts.media_timeout||5e3))),e.next=6,n.waitForAdsManager();case 6:if(d=e.sent,v.volume(f?0:v._volumeLevel),n.eventHandler.trigger(A.a.AD_VOLUME_CHANGED,v._volumeLevel),!(h=v.cuepoints())||!h.length||0===h[0]){e.next=12;break}return e.abrupt("return",o({ad:!1,adsManager:d}));case 12:v.once(d,google.ima.AdErrorEvent.Type.AD_ERROR,(function(e){v.emitError(A.a.AD_PLAYBACK_ERROR,e),l(e)})),v.once(d,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,(function(){v._all_ads_completed=!0,o()})),v.once(d,google.ima.AdEvent.Type.LOADED,(function(e){v.eventHandler.trigger(A.a.AD_REQUEST_COMPLETED,{request_load_time:Date.now()-c}),a=e.getAd(),M("ima.requestAd: AD_REQUEST_COMPLETED",a.getContentType()),"application/javascript"==a.getContentType()&&v.eventHandler.trigger(A.a.VPAID_INIT,a),o()})),v.once(d,google.ima.AdEvent.Type.CLICK,(function(){M("ima.requestAd: click event"),n.pause()}));case 16:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",p);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"playAd",value:(n=s()(i.a.mark((function e(){var t;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(M("ima.playAd()",this),this._adsManager&&this._adLoaded){e.next=3;break}return e.abrupt("return");case 3:if(t=this._adsManager.getCurrentAd()){e.next=6;break}return e.abrupt("return");case 6:if(!this.sharedVideoTag||t.isLinear()){e.next=8;break}return e.abrupt("return");case 8:return e.prev=8,e.next=11,this.startAndWaitForAdCompletion(this._adsManager,t.isLinear());case 11:e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(8),M("ima.playAd",e.t0),e.t0;case 17:return e.prev=17,this._adLoaded=!1,R.empty(this._timers),e.finish(17);case 21:case"end":return e.stop()}}),e,this,[[8,13,17,21]])}))),function(){return n.apply(this,arguments)})},{key:"startAndWaitForAdCompletion",value:function(e,r){var n=this;if(!this._started){M("ima.startAndWaitForAdCompletion(manager: %o)",{volume:e.getVolume()});var a=this;return new Promise((function(o,l){var u=!1;a.once(e,google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,(function(){if(M("ima.startAndWaitForAdCompletion: CONTENT_RESUME_REQUESTED <<< happened"),a._started=!1,u)return M("ima.startAndWaitForAdCompletion: Content resume requested, but trying to recover from ad error");o()})),a.once(e,google.ima.AdErrorEvent.Type.AD_ERROR,function(){var e=s()(i.a.mark((function e(r){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return M("ima.startAndWaitForAdCompletion: beginning error recovery ->",r),u=!0,e.prev=2,e.next=5,t.pollForFatalError({err:r,ima:a});case 5:e.sent.ok&&(u=!1),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(2),a._started=!1,l(r);case 14:case"end":return e.stop()}}),e,this,[[2,10]])})));return function(t){return e.apply(this,arguments)}}()),r&&(n._started=!0),e.start(),n.eventHandler.trigger(A.a.AD_PLAY_REQUESTED)}))}}},{key:"pause",value:function(){M("ima.pause()"),this._adsManager&&this._adsManager.pause()}},{key:"resume",value:function(){M("ima.resume()"),this._adsManager&&this._adsManager.resume()}},{key:"volume",value:function(e){try{return arguments.length>0&&"number"==typeof e&&this._adsManager.setVolume(e),this._volumeLevel=this._adsManager.getVolume()}catch(e){M("ima.volume() failed (%o)",e)}}},{key:"onResize",value:function(e){var t=e.width,r=e.height,n=e.linear,i=e.silent,a=e.resize_non_linear;this.opts&&(t||r)&&(n&&(this.opts.width=t,this.opts.height=r),this._adsManager&&(n||a)&&(i||M("ima.onResize %s x %s",t,r),this._adsManager.resize(t,r,google.ima.ViewMode.NORMAL)))}},{key:"currentAd",value:function(){return this._adsManager&&this._adsManager.getCurrentAd()}},{key:"isAdPod",value:function(){return this.cuepoints()&&this.cuepoints().length>1}},{key:"cuepoints",value:function(){return this._adsManager&&this._adsManager.getCuePoints()}},{key:"contentComplete",value:(r=s()(i.a.mark((function e(){var r=this;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(M("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete(),this.cuepoints()&&-1!==this.cuepoints().indexOf(-1)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,new Promise((function(e){t.race(r.eventHandler,[A.a.AD_BREAK_COMPLETED,A.a.AD_ERROR],e)}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"isUiDisabled",value:function(){return this.currentAd()&&this.currentAd().isUiDisabled()}},{key:"getAdPodInfo",value:function(){try{return this.currentAd()&&this.currentAd().getAdPodInfo()}catch(e){return null}}},{key:"canDismissNonLinear",value:function(){var e=this.currentAd();if(!e||e.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;var t=Date.now(),r=e.getMinSuggestedDuration();return t-this._currentDisplayTs>1e3*r}},{key:"once",value:function(e,t,r){this._adHandlers.push(function(e,t,r){var n=function n(i){r(i),e.removeEventListener(t,n)};return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}}(e,t,r))}},{key:"clearAdHandlers",value:function(){M("ima.clearAdHandlers"),this._adHandlers.forEach((function(e){return e()})),this._adHandlers=[]}},{key:"emitWithAd",value:function(e,t){var r={ad_type:D.a.kindOf(P(t)),ad:{duration:t.getDuration(),width:t.getWidth(),height:t.getHeight()},volume:this._adsManager.getVolume(),vast_ad_id:t.getAdId(),linear:t.isLinear(),mime_type:t.getContentType(),ima_event:!0};M("emitWithAd::event(name: ".concat(e,", data: %o, ad: %o)"),r,t),this.eventHandler.trigger(e,r)}},{key:"emitError",value:function(e,t){var r={vast_error_type:t.getError().getType(),reason:t.getError().getMessage(),vast_error:t.getError().getErrorCode()};M("ima.error(".concat(e,")"),r),this.eventHandler.trigger(e,r)}},{key:"debugEvent",value:function(e){try{var t=e.getAd();if(!t)return;M("ima.event.".concat(e.type," ->"),{event:e,data:e.getAdData(),position:P(t),ad:t})}catch(e){}}}],[{key:"unwrapError",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return"function"==typeof e.getMessage?e.getMessage():e.message?e.message:t}},{key:"pollForFatalError",value:function(e){var r,n=e.err,i=e.ima;try{var a=n.getError(),s=t.unwrapError(a.getInnerError(),a);r={reason:s,type:a.getType(),code:a.getErrorCode()},M("ima.pollForFatalError",r)}catch(n){M("ima.pollForFatalError",n)}var o=i._currentRemaining;return new Promise((function(e,t){var n=setTimeout((function(){M("ima.pollForFatalError: Ad errored and not progressing, reject"),i.eventHandler&&i.eventHandler.trigger(A.a.AD_PLAYBACK_ERROR,r),t(new Error("Ad not progressing"))}),2500);i.eventHandler.once(A.a.AD_PROGRESS,(function(t){-1!==t.remaining&&t.remaining<o&&(M("ima.pollForFatalError: Ad still progressing even though errored, skip error rejection"),clearTimeout(n),e({ok:1}))}))}))}},{key:"pollRemaining",value:function(e){var t=e.ima,r=e.adsManager;return M("ima.pollRemaining"),R.createInterval(t._timers,250,(function(){t._currentRemaining=r.getRemainingTime(),t.eventHandler.trigger(A.a.AD_PROGRESS,{remaining:t._currentRemaining,duration:t._currentDuration})}))}},{key:"race",value:function(e,t,r){t.forEach((function(n){e.on(n,(function n(){t.forEach((function(t){return e.removeListener(t,n)}));for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];r(a)}))}))}}]),t}(x),N=function(){function e(){c()(this,e)}return f()(e,null,[{key:"create",value:function(e,t){return e.adapter?new e.adapter(t):new F(t)}}]),e}(),U=r(30),B=r(18),j=r.n(B),G=r(31),H=r.n(G),K=r(7)("fpads:macros"),V=/\[([\s\S]+?)\]/g,W=function(){function e(t,r){c()(this,e),this.vars=t,this.pattern=r}return f()(e,null,[{key:"of",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V;return new e(t,r)}},{key:"run",value:function(e){try{return e()}catch(e){return void console.error(e)}}},{key:"merge",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t){return Object.assign(e,t)}),{})}},{key:"cast",value:function(t){var r=w()(t);return"undefined"===r?"":("function"===r&&(t=e.run(t)),encodeURIComponent(t))}},{key:"normalize",value:function(e){return e.trim()}},{key:"process_obj",value:function(t,r,n){return Object.keys(t).reduce((function(i,a){var s=e.process_str(a,r,n,!0),o=t[a];return null===o?(i[s]=o,i):"object"==w()(o)?(i[s]=e.process_obj(o,r,n),i):"string"==typeof o?(i[s]=e.process_str(o,r,n),i):void console.error(new Error("".concat(o," at ").concat(a," not a handled Macro type")))}),{})}},{key:"process_str",value:function(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return t.replace(r.pattern,(function(t,r){var a=e.normalize(r);if(!(a in n)||void 0===n[a])return t;var s=n[a],o=i?s:e.cast(s);return K("Macro.replace(raw: %s, macro: %s, value: %s)",i,r,o),o}))}}]),f()(e,[{key:"fork",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.pattern,n=e.merge(this.vars,t);return e.of(n,r)}},{key:"compile",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.merge(this.vars,r),i=t.split("?"),a=j()(i,2),s=a[0],o=a[1],l=H.a.parse(o||"",{strictNullHandling:!0,decoder:function(e){return e}}),u=H.a.stringify(e.process_obj(l,this,n),{encode:!1,strictNullHandling:!0});return e.process_str(s,this,n,!0)+"?"+u}}]),e}();function q(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{width:0,height:0};try{var i=document.createElement("a");i.href=t=window.location!=window.parent.location?document.referrer:document.location.href,r=i.hostname}catch(e){console.error(e)}var a=n.width,s=n.height,o=e||{},u=o.video_source,c="object"==w()(window.__flowplayerAdParameters)?window.__flowplayerAdParameters:{};return l()({random:Date.now(),page_url:t,domain:r,player_width:a,player_height:s,video_url:u,videourl:u},c)}function z(e){return Y.apply(this,arguments)}function Y(){return(Y=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("function"==typeof t){e.next=2;break}return e.abrupt("return",t);case 2:return e.prev=2,e.next=5,t();case 5:return e.abrupt("return",e.sent);case 8:return e.prev=8,e.t0=e.catch(2),e.abrupt("return","");case 11:case"end":return e.stop()}}),e,this,[[2,8]])})))).apply(this,arguments)}function X(e){return Q.apply(this,arguments)}function Q(){return(Q=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=w()(t),e.next="function"===e.t0||"string"===e.t0?3:"object"===e.t0?7:8;break;case 3:return e.next=5,z(t);case 5:return e.t1=e.sent,e.abrupt("return",[e.t1]);case 7:return e.abrupt("return",Array.isArray(t)?Promise.all(t.map(z)):X(t.adTag||[]));case 8:throw new Error("\n unhandled ads type ".concat(w()(t),":\n ").concat(JSON.stringify(t),"\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n "));case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}Object.assign(W,{patterns:{BRACKETS:V,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g}});var Z=Object.prototype,J=Object.getPrototypeOf;function $(e){return null!==e&&"object"===w()(e)&&J(e)===Z}var ee=r(7)("fpads:ads:state"),te={IDLE:0,INITIALIZING:1,FETCHING_AD:2,AD_AVAILABLE:4,BREAK_ACTIVE:8,PLAYING:16,FATAL_ERROR:32},re=function(){function e(){c()(this,e),this._state=0}return f()(e,null,[{key:"of",value:function(){return new e}}]),f()(e,[{key:"reset",value:function(){this._state=0}},{key:"toString",value:function(){var e=this;return 0==this._state?"AdState(None)":"AdState("+Object.keys(te).reduce((function(t,r){return e.hasAny(te[r])?t+r+": "+!!e.hasAny(te[r])+" ":t}),"").trim()+")"}},{key:"toggleState",value:function(e,t){return void 0===e&&ee(new Error("AdState cannot toggleState for `undefined`")),null==w()(t)?this._state^=e:t?void(this._state|=e):this._state&=~e}},{key:"hasAll",value:function(e){return this._state==(this._state|e)}},{key:"hasAny",value:function(e){return this._state&e}},{key:"state",get:function(){return this._state}}]),e}(),ne=r(7)("fpads:ads"),ie={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10},ae=function(e){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return c()(this,t),(e=p()(this,g()(t).call(this))).adapter=N.create(r,_()(_()(e))),e.opts=l()({},ie),e.analytics=void 0,e._state=re.of(),e._schedule=void 0,e._lastAd=void 0,e._macros=W.of(r.parameters||{}),e.wireup(),e}var r,n,a,o,u,d,h,v;return y()(t,e),f()(t,[{key:"reset",value:function(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}},{key:"destroy",value:function(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy(),this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}},{key:"stop",value:function(){this.adapter&&this.adapter.stop()}},{key:"wireup",value:function(){var e=this,t=function(){return e._state.toggleState(te.PLAYING,!0)};this.on(A.a.AD_PLAY_REQUESTED,t),this.on(A.a.AD_STARTED,t),this.on(A.a.AD_RESUMED,t);var r=function(){return e._state.toggleState(te.PLAYING,!1)};this.on(A.a.AD_BREAK_COMPLETED,r),this.on(A.a.AD_TEARDOWN,r),this.on(A.a.AD_PLAYBACK_ERROR,r),this.on(A.a.AD_REQUEST_ERROR,r),this.on(A.a.AD_PAUSED,r),this.on(A.a.AD_SKIPPED,r),this.on(A.a.AD_COMPLETED,r),this.on(A.a.AD_BREAK_COMPLETED,(function(){e._state.toggleState(te.BREAK_ACTIVE,!1)})),this.on(A.a.ADAPTER_INIT_FAILED,(function(){console.error("Adapter init failed"),r(),e._state.toggleState(te.FATAL_ERROR,!0)})),this.on(A.a.RELOAD_AD_REQUESTED,function(){var t=s()(i.a.mark((function t(n){return i.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ne("Ads.on(RELOAD_AD_REQUESTED)",n),r(),!n){t.next=4;break}return t.abrupt("return",e._schedule.reset(e._schedule.getAds()));case 4:e._state.hasAny(te.AD_AVAILABLE)&&(e._schedule.decrement(),e._state.toggleState(te.AD_AVAILABLE,!1));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}())}},{key:"initialize",value:(v=s()(i.a.mark((function e(t){var r,n,a=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},n=a.length>2?a[2]:void 0,ne("Ads.initialize():",t,r,n),this._state.toggleState(te.INITIALIZING,!0),this.opts=Object.assign({},this.opts,r),Array.isArray(t)&&this.setSchedule(t),e.next=8,this.adapter.init(this.opts);case 8:if(this._macros=this._macros.fork(Object.assign({},r.parameters||{},{autoplay:r.autoplay,muted:r.muted})),!this.adapter.isReady()){e.next=12;break}return e.next=12,this.adapterInitialized(n);case 12:return e.abrupt("return",this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"setVideoTag",value:(h=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ne("Ads.setVideoTag():",t),e.next=3,this.adapter.setVideoTag(t);case 3:if(this.trigger(A.a.AD_VIDEOTAG_ATTACHED,t),!this.adapter.isReady()){e.next=7;break}return e.next=7,this.adapterInitialized();case 7:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"waitForVideoTag",value:function(){var e=this;return new Promise((function(t){var r=e.adapter.videoTag;if(r)return t(r);e.on(A.a.AD_VIDEOTAG_ATTACHED,(function(r){e.once(A.a.AD_INIT,(function(){return t(r)}))}))}))}},{key:"adapterInitialized",value:(d=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ne("Ads.adapterInitialized()"),this._state.toggleState(te.INITIALIZING,!1),this._state.toggleState(te.BREAK_ACTIVE,this.hasPreroll()),e.next=5,this.setCurrentTime(0,t);case 5:this.checkIfBreakComplete(),t&&!this.opts.autoplay||this.trigger(A.a.AD_TEARDOWN);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"fetchNextAd",value:(u=s()(i.a.mark((function e(t){var r,n,a=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=a.length>1&&void 0!==a[1]?a[1]:0,this.adapter.isReady()){e.next=3;break}return e.abrupt("return");case 3:if(!(r>50)){e.next=7;break}throw this._state.toggleState(te.FATAL_ERROR,!0),this._state.toggleState(te.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");case 7:if(!(n=this._schedule.getNextAd()||this._schedule.getPostroll())||this.adapter.canDismissNonLinear()||-1===t){e.next=10;break}return e.abrupt("return",!1);case 10:if(!this._schedule.waitForLoad(t,n,this.opts.preload_ads)){e.next=13;break}return this._state.toggleState(te.FETCHING_AD,!1),e.abrupt("return",!1);case 13:if(n===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),n){e.next=18;break}return this._state.toggleState(te.FETCHING_AD,!1),e.abrupt("return",!1);case 18:return ne("Ads.fetchNextAd",n),this._state.toggleState(te.FETCHING_AD,!0),e.prev=20,e.next=23,this.requestAd(n);case 23:return this._state.toggleState(te.AD_AVAILABLE,!0),this._state.toggleState(te.FETCHING_AD,!1),e.abrupt("return",this);case 28:if(e.prev=28,e.t0=e.catch(20),ne("Ads.fetchNextAd(err: %o, ad: %o)",e.t0,n),this.setLastAd(n),n===this._schedule.getPostroll()){e.next=36;break}return e.next=35,this.fetchNextAd(t,++r);case 35:return e.abrupt("return",e.sent);case 36:case"end":return e.stop()}}),e,this,[[20,28]])}))),function(e){return u.apply(this,arguments)})},{key:"skipAdsOnSeek",value:function(e){for(var t=this._schedule.getNextAd();t&&t.time<e;)this._schedule.increment(),t=this._schedule.getNextAd()}},{key:"setCurrentTime",value:(o=s()(i.a.mark((function e(t,r){var n,a,s=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=s.length>2&&void 0!==s[2]&&s[2],this._schedule){e.next=3;break}return e.abrupt("return");case 3:if(this.adapter.isReady()){e.next=5;break}return e.abrupt("return");case 5:if(!this._state.hasAny(te.FETCHING_AD)){e.next=7;break}return e.abrupt("return");case 7:if(!this._state.hasAny(te.PLAYING)||!this.adapter.adLinear){e.next=9;break}return e.abrupt("return");case 9:if(a=0===t&&0===this._schedule.getNextIndex(),e.prev=10,n&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(t),this._state.hasAny(te.AD_AVAILABLE)){e.next=15;break}return e.next=15,this.fetchNextAd(t);case 15:if(this._state.hasAny(te.AD_AVAILABLE)&&this.shallPlayAd(t)&&!r){e.next=17;break}return e.abrupt("return");case 17:return e.next=19,this.playAd();case 19:return e.next=21,this.setCurrentTime(t);case 21:this.checkIfBreakComplete(),e.next=27;break;case 24:e.prev=24,e.t0=e.catch(10),ne("setCurrentTime: Error(from: setCurrentTime, message: %s)",e.t0.message);case 27:return e.prev=27,a&&this.trigger(A.a.AD_PREROLL_FINSIHED),e.finish(27);case 30:case"end":return e.stop()}}),e,this,[[10,24,27,30]])}))),function(e,t){return o.apply(this,arguments)})},{key:"playAd",value:(a=s()(i.a.mark((function e(){var t;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._state.hasAny(te.AD_AVAILABLE)){e.next=2;break}return e.abrupt("return");case 2:return this._state.toggleState(te.AD_AVAILABLE,!1),this._state.toggleState(te.BREAK_ACTIVE,!0),e.prev=4,t=this._schedule.getCurrentAd(),e.next=8,this.adapter.playAd();case 8:t&&this.setLastAd(t),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(4),console.error("Ads.playAd: error",e.t0);case 14:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(){return a.apply(this,arguments)})},{key:"checkIfBreakComplete",value:function(){if(!this._state.hasAny(te.BREAK_ACTIVE))return ne("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());ne("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(te.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger(A.a.AD_BREAK_COMPLETED)}},{key:"resetScheduleCounter",value:function(){this._schedule&&this._schedule.resetCounter()}},{key:"setSchedule",value:function(e,t){if(!isNaN(t)&&this._schedule&&this._schedule.updateContentDuration(t),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(e);this._schedule=D.a.of(e,{preload_advance:this.opts.preload_advance,content_duration:isNaN(t)?0:t})}},{key:"toJSON",value:function(){return this._schedule?this._schedule.toJSON():[]}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._state){if(e===A.a.AD_BREAK_COMPLETED&&this._state.hasAny(te.BREAK_ACTIVE)&&!this.adapter.isAdPod())return ne("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if($(t)&&(t=Object.assign({},this.adapter.opts||{},this._schedule.getCurrentAd()||{},{ad_type:this.ad_type},t)).ima_event&&"preroll"===t.ad_type&&(t.ad_type=this.ad_type),this.adapter.videoTag){var r=document.createEvent("Event");r.initEvent(e,!1,!1),r.data=t,this.adapter.videoTag.dispatchEvent(r)}U.EventEmitter.prototype.emit.apply(this,[e,t])}}},{key:"shouldRestartContent",value:function(){var e=this.getLastAd();return!e.outstream&&!1!==e.restart}},{key:"finished",value:(n=s()(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ne("Ads.finished"),!(this.adapter.sharedVideoTag&&this._state.hasAny(te.PLAYING)&&this.adapter.adLinear)){e.next=3;break}return e.abrupt("return");case 3:if(ne("Ads.finished: trying to play postroll"),e.prev=4,this._schedule.getPostroll()){e.next=10;break}return ne("Ads.finished: no postroll found"),e.next=9,this.adapter.contentComplete();case 9:return e.abrupt("return",e.sent);case 10:if(this._state.hasAny(te.AD_AVAILABLE)){e.next=13;break}return e.next=13,this.fetchNextAd(-1);case 13:return e.next=15,this.playAd();case 15:this.adapter.contentComplete(),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),ne("Ads.finished: postroll failed:",e.t0);case 21:return e.prev=21,this.trigger(A.a.AD_POSTROLL_FINISHED),this.checkIfBreakComplete(),"function"==typeof t&&t(),e.finish(21);case 26:case"end":return e.stop()}}),e,this,[[4,18,21,26]])}))),function(e){return n.apply(this,arguments)})},{key:"hasPreroll",value:function(){return this._schedule&&D.a.hasPreroll(this._schedule.getAds())}},{key:"shallPlayAd",value:function(e){return(!this.adapter||!this.adapter.isAdPod())&&!(!this._state||this._state.hasAny(te.FATAL_ERROR))&&this._schedule.shallPlayAd(e)}},{key:"setLastAd",value:function(e){return this._lastAd=e,this}},{key:"getLastAd",value:function(){return this._lastAd||{}}},{key:"mergeMacros",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._macros=this._macros.fork(Object.assign({},e)),this}},{key:"pause",value:function(){this.adapter&&this.adapter.pause()}},{key:"resume",value:function(){this.adapter&&this.adapter.resume()}},{key:"resize",value:function(e){this.adapter&&this.adapter.resize(e)}},{key:"requestAd",value:(r=s()(i.a.mark((function e(t){var r,n,a,s,o,l=arguments;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=l.length>1&&void 0!==l[1]?l[1]:0,n=l.length>2&&void 0!==l[2]?l[2]:this.opts.timeout,this._state){e.next=4;break}return e.abrupt("return");case 4:return ne("Ads.requestAd(ad: %o)",{ad:t,timeout:n,idx:r}),e.next=7,X(t);case 7:if(void 0!==(a=e.sent)[r]){e.next=10;break}return e.abrupt("return",Promise.reject(new Error("Ad failed, no fallbacks left")));case 10:if(a[r]){e.next=14;break}return e.next=13,this.requestAd(a,r+1,n);case 13:return e.abrupt("return",e.sent);case 14:return this.trigger(A.a.AD_REQUESTED,t),s=this._macros.compile(a[r],q(this.opts,this.adapter.dimensions)),e.prev=16,e.next=19,this.adapter.initAd(s,n);case 19:return o=e.sent,e.abrupt("return",{ok:o});case 23:return e.prev=23,e.t0=e.catch(16),ne("Ads.requestAd(:fallback, idx: ".concat(r,", length: ").concat(a.length,", adTag: ").concat(a[r],")\nError "),{adTag:a,err:e.t0}),e.abrupt("return",this.requestAd(a,r+1,n));case 27:case"end":return e.stop()}}),e,this,[[16,23]])}))),function(e){return r.apply(this,arguments)})},{key:"resetSchedule",value:function(e){this._schedule&&this._schedule.reset(e)}},{key:"ad_type",get:function(){return this._schedule&&this._schedule.getCurrentType()}},{key:"paused",get:function(){return this.adapter&&this.adapter.paused}},{key:"adPlaying",get:function(){return this._state&&this._state.hasAny(te.PLAYING)}},{key:"adBreak",get:function(){return this._state&&this._state.hasAny(te.BREAK_ACTIVE)}}]),t}(U.EventEmitter)},function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(t,n)}e.exports=r},function(e,t,r){r(54),e.exports=r(10).Object.assign},function(e,t,r){var n=r(15);n(n.S+n.F,"Object",{assign:r(65)})},function(e,t,r){var n=r(56),i=r(57),a=r(59),s=Object.defineProperty;t.f=r(14)?Object.defineProperty:function(e,t,r){if(n(e),t=a(t,!0),n(r),i)try{return s(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t,r){var n=r(16);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t,r){e.exports=!r(14)&&!r(23)((function(){return 7!=Object.defineProperty(r(58)("div"),"a",{get:function(){return 7}}).a}))},function(e,t,r){var n=r(16),i=r(13).document,a=n(i)&&n(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t,r){var n=r(16);e.exports=function(e,t){if(!n(e))return e;var r,i;if(t&&"function"==typeof(r=e.toString)&&!n(i=r.call(e)))return i;if("function"==typeof(r=e.valueOf)&&!n(i=r.call(e)))return i;if(!t&&"function"==typeof(r=e.toString)&&!n(i=r.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,r){var n=r(13),i=r(22),a=r(33),s=r(24)("src"),o=r(62),l=(""+o).split("toString");r(10).inspectSource=function(e){return o.call(e)},(e.exports=function(e,t,r,o){var u="function"==typeof r;u&&(a(r,"name")||i(r,"name",t)),e[t]!==r&&(u&&(a(r,s)||i(r,s,e[t]?""+e[t]:l.join(String(t)))),e===n?e[t]=r:o?e[t]?e[t]=r:i(e,t,r):(delete e[t],i(e,t,r)))})(Function.prototype,"toString",(function(){return"function"==typeof this&&this[s]||o.call(this)}))},function(e,t,r){e.exports=r(25)("native-function-to-string",Function.toString)},function(e,t){e.exports=!1},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,r){var n=r(14),i=r(35),a=r(71),s=r(40),o=r(41),l=r(27),u=Object.assign;e.exports=!u||r(23)((function(){var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=u({},e)[r]||Object.keys(u({},t)).join("")!=n}))?function(e,t){for(var r=o(e),u=arguments.length,c=1,d=a.f,f=s.f;u>c;)for(var h,p=l(arguments[c++]),v=d?i(p).concat(d(p)):i(p),g=v.length,m=0;g>m;)h=v[m++],n&&!f.call(p,h)||(r[h]=p[h]);return r}:u},function(e,t,r){var n=r(33),i=r(26),a=r(67)(!1),s=r(69)("IE_PROTO");e.exports=function(e,t){var r,o=i(e),l=0,u=[];for(r in o)r!=s&&n(o,r)&&u.push(r);for(;t.length>l;)n(o,r=t[l++])&&(~a(u,r)||u.push(r));return u}},function(e,t,r){var n=r(26),i=r(38),a=r(68);e.exports=function(e){return function(t,r,s){var o,l=n(t),u=i(l.length),c=a(s,u);if(e&&r!=r){for(;u>c;)if((o=l[c++])!=o)return!0}else for(;u>c;c++)if((e||c in l)&&l[c]===r)return e||c||0;return!e&&-1}}},function(e,t,r){var n=r(39),i=Math.max,a=Math.min;e.exports=function(e,t){return(e=n(e))<0?i(e+t,0):a(e,t)}},function(e,t,r){var n=r(25)("keys"),i=r(24);e.exports=function(e){return n[e]||(n[e]=i(e))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,r){r(73),e.exports=r(10).Object.values},function(e,t,r){var n=r(15),i=r(42)(!1);n(n.S,"Object",{values:function(e){return i(e)}})},function(e,t,r){r(75),e.exports=r(10).Object.entries},function(e,t,r){var n=r(15),i=r(42)(!0);n(n.S,"Object",{entries:function(e){return i(e)}})},function(e,t,r){r(77),e.exports=r(10).Array.find},function(e,t,r){var n=r(15),i=r(78)(5),a=!0;"find"in[]&&Array(1).find((function(){a=!1})),n(n.P+n.F*a,"Array",{find:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}}),r(82)("find")},function(e,t,r){var n=r(34),i=r(27),a=r(41),s=r(38),o=r(79);e.exports=function(e,t){var r=1==e,l=2==e,u=3==e,c=4==e,d=6==e,f=5==e||d,h=t||o;return function(t,o,p){for(var v,g,m=a(t),y=i(m),E=n(o,p,3),_=s(y.length),T=0,b=r?h(t,_):l?h(t,0):void 0;_>T;T++)if((f||T in y)&&(g=E(v=y[T],T,m),e))if(r)b[T]=g;else if(g)switch(e){case 3:return!0;case 5:return v;case 6:return T;case 2:b.push(v)}else if(c)return!1;return d?-1:u||c?c:b}}},function(e,t,r){var n=r(80);e.exports=function(e,t){return new(n(e))(t)}},function(e,t,r){var n=r(16),i=r(81),a=r(43)("species");e.exports=function(e){var t;return i(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!i(t.prototype)||(t=void 0),n(t)&&null===(t=t[a])&&(t=void 0)),void 0===t?Array:t}},function(e,t,r){var n=r(36);e.exports=Array.isArray||function(e){return"Array"==n(e)}},function(e,t,r){var n=r(43)("unscopables"),i=Array.prototype;null==i[n]&&r(22)(i,n,{}),e.exports=function(e){i[n][e]=!0}},function(e,t,r){var n=function(){return this||"object"==typeof self&&self}()||Function("return this")(),i=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,a=i&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,e.exports=r(84),i)n.regeneratorRuntime=a;else try{delete n.regeneratorRuntime}catch(e){n.regeneratorRuntime=void 0}},function(e,t){!function(t){var r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag",l="object"==typeof e,u=t.regeneratorRuntime;if(u)l&&(e.exports=u);else{(u=t.regeneratorRuntime=l?e.exports:{}).wrap=v;var c={},d={};d[a]=function(){return this};var f=Object.getPrototypeOf,h=f&&f(f(L([])));h&&h!==r&&n.call(h,a)&&(d=h);var p=E.prototype=m.prototype=Object.create(d);y.prototype=p.constructor=E,E.constructor=y,E[o]=y.displayName="GeneratorFunction",u.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},u.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(p),e},u.awrap=function(e){return{__await:e}},_(T.prototype),T.prototype[s]=function(){return this},u.AsyncIterator=T,u.async=function(e,t,r,n){var i=new T(v(e,t,r,n));return u.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},_(p),p[o]="Generator",p[a]=function(){return this},p.toString=function(){return"[object Generator]"},u.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},u.values=L,w.prototype={constructor:w,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(o&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:L(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}}}function v(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),s=new w(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=b(s,r);if(o){if(o===c)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=g(e,t,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===c)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}(e,r,s),a}function g(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}function m(){}function y(){}function E(){}function _(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function T(e){var t;this._invoke=function(r,i){function a(){return new Promise((function(t,a){!function t(r,i,a,s){var o=g(e[r],e,i);if("throw"!==o.type){var l=o.arg,u=l.value;return u&&"object"==typeof u&&n.call(u,"__await")?Promise.resolve(u.__await).then((function(e){t("next",e,a,s)}),(function(e){t("throw",e,a,s)})):Promise.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return t("throw",e,a,s)}))}s(o.arg)}(r,i,t,a)}))}return t=t?t.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=g(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())},function(e,t,r){var n=r(8);e.exports=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=n(e)););return e}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){var r=[],n=!0,i=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(i)throw a}}return r}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,r){var n=r(44),i=r(45),a={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},s=Date.prototype.toISOString,o={delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,serializeDate:function(e){return s.call(e)},skipNulls:!1,strictNullHandling:!1},l=function e(t,r,i,a,s,l,u,c,d,f,h,p){var v=t;if("function"==typeof u)v=u(r,v);else if(v instanceof Date)v=f(v);else if(null===v){if(a)return l&&!p?l(r,o.encoder):r;v=""}if("string"==typeof v||"number"==typeof v||"boolean"==typeof v||n.isBuffer(v))return l?[h(p?r:l(r,o.encoder))+"="+h(l(v,o.encoder))]:[h(r)+"="+h(String(v))];var g,m=[];if(void 0===v)return m;if(Array.isArray(u))g=u;else{var y=Object.keys(v);g=c?y.sort(c):y}for(var E=0;E<g.length;++E){var _=g[E];s&&null===v[_]||(m=Array.isArray(v)?m.concat(e(v[_],i(r,_),i,a,s,l,u,c,d,f,h,p)):m.concat(e(v[_],r+(d?"."+_:"["+_+"]"),i,a,s,l,u,c,d,f,h,p)))}return m};e.exports=function(e,t){var r=e,s=t?n.assign({},t):{};if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");var u=void 0===s.delimiter?o.delimiter:s.delimiter,c="boolean"==typeof s.strictNullHandling?s.strictNullHandling:o.strictNullHandling,d="boolean"==typeof s.skipNulls?s.skipNulls:o.skipNulls,f="boolean"==typeof s.encode?s.encode:o.encode,h="function"==typeof s.encoder?s.encoder:o.encoder,p="function"==typeof s.sort?s.sort:null,v=void 0!==s.allowDots&&s.allowDots,g="function"==typeof s.serializeDate?s.serializeDate:o.serializeDate,m="boolean"==typeof s.encodeValuesOnly?s.encodeValuesOnly:o.encodeValuesOnly;if(void 0===s.format)s.format=i.default;else if(!Object.prototype.hasOwnProperty.call(i.formatters,s.format))throw new TypeError("Unknown format option provided.");var y,E,_=i.formatters[s.format];"function"==typeof s.filter?r=(E=s.filter)("",r):Array.isArray(s.filter)&&(y=E=s.filter);var T,b=[];if("object"!=typeof r||null===r)return"";T=s.arrayFormat in a?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var A=a[T];y||(y=Object.keys(r)),p&&y.sort(p);for(var S=0;S<y.length;++S){var w=y[S];d&&null===r[w]||(b=b.concat(l(r[w],w,A,c,d,f?h:null,E,p,v,g,_,m)))}var L=b.join(u),k=!0===s.addQueryPrefix?"?":"";return L.length>0?k+L:""}},function(e,t,r){var n=r(44),i=Object.prototype.hasOwnProperty,a={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:n.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},s=function(e,t,r){if(e){var n=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,s=/(\[[^[\]]*])/.exec(n),o=s?n.slice(0,s.index):n,l=[];if(o){if(!r.plainObjects&&i.call(Object.prototype,o)&&!r.allowPrototypes)return;l.push(o)}for(var u=0;null!==(s=a.exec(n))&&u<r.depth;){if(u+=1,!r.plainObjects&&i.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;l.push(s[1])}return s&&l.push("["+n.slice(s.index)+"]"),function(e,t,r){for(var n=t,i=e.length-1;i>=0;--i){var a,s=e[i];if("[]"===s)a=(a=[]).concat(n);else{a=r.plainObjects?Object.create(null):{};var o="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,l=parseInt(o,10);!isNaN(l)&&s!==o&&String(l)===o&&l>=0&&r.parseArrays&&l<=r.arrayLimit?(a=[])[l]=n:a[o]=n}n=a}return n}(l,t,r)}};e.exports=function(e,t){var r=t?n.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||n.isRegExp(r.delimiter)?r.delimiter:a.delimiter,r.depth="number"==typeof r.depth?r.depth:a.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:a.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:a.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:a.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:a.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:a.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:a.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:a.strictNullHandling,""===e||null==e)return r.plainObjects?Object.create(null):{};for(var o="string"==typeof e?function(e,t){for(var r={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=n.split(t.delimiter,s),l=0;l<o.length;++l){var u,c,d=o[l],f=d.indexOf("]="),h=-1===f?d.indexOf("="):f+1;-1===h?(u=t.decoder(d,a.decoder),c=t.strictNullHandling?null:""):(u=t.decoder(d.slice(0,h),a.decoder),c=t.decoder(d.slice(h+1),a.decoder)),i.call(r,u)?r[u]=[].concat(r[u]).concat(c):r[u]=c}return r}(e,r):e,l=r.plainObjects?Object.create(null):{},u=Object.keys(o),c=0;c<u.length;++c){var d=u[c],f=s(d,o[d],r);l=n.merge(l,f,r)}return n.compact(l)}},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t,r){var n=r(97);e.exports=function(e,t){if(null==e)return{};var r,i,a=n(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}},function(e,t,r){var n=r(52);function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function a(t,r,s){return i()?e.exports=a=Reflect.construct:e.exports=a=function(e,t,r){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return r&&n(a,r.prototype),a},a.apply(null,arguments)}e.exports=a},function(e,t,r){r.r(t),r.d(t,"default",(function(){return ie}));var n={};r.r(n),r.d(n,"STICKY_CONTROLS",(function(){return T})),r.d(n,"NO_FULLSCREEN",(function(){return b})),r.d(n,"NO_AD_INDICATOR",(function(){return A})),r.d(n,"AD_ATTRIBUTION",(function(){return S})),r.d(n,"AD_CHOICES",(function(){return w})),r.d(n,"REMAINING_TIME",(function(){return L})),r.d(n,"VOLUME_BAR",(function(){return k}));var i=r(5),a=r.n(i),s=r(6),o=r.n(s),l=r(94),u=r.n(l),c=r(1),d=r.n(c),f=r(2),h=r.n(f),p=r(4),v=r.n(p),g=r(3),m=r.n(g),y=r(95),E=r.n(y),_=(r(98),r(100),r(102),r(104),r(0)),T=1,b=2,A=4,S=8,w=16,L=32,k=64;function R(e,t,r){for(var n=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);n.length;){if(null==e)return r;var i=n.shift();if("string"!=typeof i)return r;e=e[i]}return null==e?r:e}var D="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,O="function"==typeof requestAnimationFrame?requestAnimationFrame:setTimeout,C=function(){var e,t=document.createElement("div");return(e=t.classList).add.apply(e,arguments),t},I=r(7)("fpads:native:ui"),x="is-ad-showing",P="is-ad-linear",M="is-ad-nonlinear",F="ad-playing",N="no-fullscreen",U="ad-hide-first-frame",B=function(){function e(t){var r,n,i,a,s=this,o=t.root,l=t.content,u=t.config,c=t.initial,d=t.ads;v()(this,e),Object.assign(this,{root:o,content:l,initial:c,ads:d,config:u}),this.progress={percent:0},this.animation=(r=function(e){if(s.halt_animation())return s.animation.running=!1;s.set_progress_bar(Math.round(s.progress.percent)),requestAnimationFrame(s.animation)},n=Math.ceil(1e3/60),i=0,a=null,function(){var e=Date.now()-i;null===a&&(a=O((function(){a=null,r.apply(this,arguments),i=Date.now()}),n-e))}),d.ui=this,this.render().wireup(),l.on("reap",(function(e){return s.destroy()}))}return m()(e,null,[{key:"of",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return E()(e,r)}},{key:"as_progress",value:function(e){var t=e.remaining,r=e.duration;return{percent:Math.min(100,Math.max(0,(r-t)/r*100))}}},{key:"clone",value:function(e,t,r){var n=t.querySelector(r);if(n){var i=n.cloneNode(!0);return e.append(i),i}}},{key:"createCustomElement",value:function(e,t,r){var n=new(window.customElements.get(r))(t);return e.append(n),n}}]),m()(e,[{key:"halt_animation",value:function(){return!this.progress_bar||0==this.content.reaper||!this.wrapper||!this.wrapper.classList.contains(F)}},{key:"animate",value:function(){this.animation.running||function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];e.apply(void 0,r)}(this.animation)}},{key:"resize",value:function(e){if(e.linear)return this.toggle(a()({on:!0},e));I("UI.resize(): ",e),this.adContainer.style.width=e.width+"px",this.wrapper.style.height=e.height+"px";var t=this.root.querySelector(".fp-controls"),r=t?e.height+t.clientHeight:e.height;this.wrapper.style.marginTop="-".concat(r,"px")}},{key:"set_progress_bar",value:function(e){this.progress_bar&&(this.progress_bar.style.width="".concat(e,"%"))}},{key:"reset_styles",value:function(){var e=this;this.progress.percent=0,"height width marginLeft marginTop".split(" ").forEach((function(t){e.wrapper.style[t]="",e.adContainer.style[t]=""}));try{window.emit("resize")}catch(e){}}},{key:"reset",value:function(){return this.wrapper.className="fp-ad-container",this.reset_styles(),this.progress={percent:0},this}},{key:"isShowing",value:function(){return this.root.classList.contains(x)}},{key:"hideFirstFrame",value:function(){return this.root.classList.toggle(U,!0),this}},{key:"showFirstFrame",value:function(){return this.root.classList.toggle(U,!1),this}},{key:"toggle",value:function(e){var t=e.on,r=e.linear;if(this.root)return I("UI.toggle(): ",arguments[0]),this.showFirstFrame(),t||this.reset(),r&&this.reset_styles(),this.root.classList.toggle(x,t),this.root.classList.toggle(P,t&&r),this.root.classList.toggle(M,t&&!r),this}},{key:"addClass",value:function(){var e;this.wrapper&&(e=this.wrapper.classList).add.apply(e,arguments)}},{key:"removeClass",value:function(){var e;this.wrapper&&(e=this.wrapper.classList).remove.apply(e,arguments)}},{key:"render",value:function(){var t=this,r=document.createDocumentFragment(),n=this,i=R(this,"config.ima.flags",R(this,"config.ima.ui",0));return this.wrapper=C("fp-ad-container"),this.ad_wrapper=C("fp-ad-wrapper"),this.adContainer=C("fp-ad"),this.controls=C("fp-ad-controls"),this.progress_wrapper=C("fp-ad-progress-wrapper"),this.progress_bar=C("fp-ad-progress","fp-color"),this.waiting=e.createCustomElement(this.wrapper,this.content,"flowplayer-wait"),this.play_btn=e.createCustomElement(this.controls,this.content,"flowplayer-control-buttons"),this.volume_btn=e.createCustomElement(this.controls,this.content,"flowplayer-volume-icon"),this.volume_bar=e.createCustomElement(this.controls,this.content,"flowplayer-volume-bar"),this.fs_btn=e.createCustomElement(this.controls,this.content,"flowplayer-header-right-zone"),k&i&&this.root.classList.toggle("ad-volume-bar"),this.fs_btn&&this.fs_btn.classList.remove("fp-togglable"),this.root.classList.toggle("is-ad-controls-sticky",T&i),this.root.classList.toggle("is-ad-attribution",S&i),this.root.classList.toggle(N,b&i),D&&this.content.once([_.a.AD_BREAK_COMPLETED,_.a.AD_REQUEST_ERROR,_.a.AD_STARTED],(function(e){t.root.classList.toggle(N,b&i||e.type===_.a.AD_STARTED)})),!R(this,"config.ima.indicator",!0)||A&i||(this.indicator=C("ad-indicator"),this.controls.prepend(this.indicator),this.indicator.classList.add("fp-color-text")),L&i&&(this.remaining=C("fp-ad-remaining"),this.remaining.classList.add("fp-color-text"),this.controls.prepend(this.remaining)),w&i&&(this.root.classList.toggle("is-ad-choices",!0),this.ad_choices=C("fp-ad-choices"),this.ad_choices.textContext="AdChoices",this.ad_choices.addEventListener("click",(function(e){e.preventDefault(),n.ads.pause(),window.open("https://adssettings.google.com","_blank")}))),this.ad_wrapper.append(this.adContainer),this.progress_wrapper.append(this.progress_bar),r.appendChild(this.wrapper),this.wrapper.append(this.ad_wrapper,this.controls,this.progress_wrapper),this.ad_choices&&this.wrapper.appendChild(this.ad_choices),this.content.renderPlugin(r),this}},{key:"ad_loading",value:function(e){I("ad_loading",e),this.wrapper&&this.wrapper.classList.toggle("is-waiting",e)}},{key:"update_time_remaining",value:function(e){this.remaining&&(this.remaining.textContent=function(e){var t,r=Math.floor(e/60);return r+":"+(t=e-=60*r,(t=parseInt(t,10))>=10?t:"0"+t)}(e))}},{key:"update_ad_indicator",value:function(){if(this.indicator){var e=this.maybe_adapter((function(e){return e.getAdPodInfo()}));if(e){I("IMA -> ",e);var t=this.content.i18n("ads.indicator","ADS");this.indicator.textContent="".concat(t," ").concat(e.getAdPosition()," / ").concat(e.getTotalAds())}}}},{key:"wireup",value:function(){var t=this;this.ads.on(_.a.AD_REQUESTED,(function(e){t.ad_loading(!0)})),this.ads.on(_.a.AD_VOLUME_CHANGED,(function(e){I("Event(%s, level: %o)",_.a.AD_VOLUME_CHANGED,e),t.content.muted||(t.content.volume=e)})),this.ads.on(_.a.AD_STARTED,(function(e){t.playback_changed(!0),t.update_ad_indicator()})),this.ads.on(_.a.AD_COMPLETED,(function(e){t.set_progress_bar(0)})),this.ads.on(_.a.AD_PAUSED,(function(e){return t.playback_changed(!1)})),this.ads.on(_.a.AD_RESUMED,(function(e){return t.playback_changed(!0)})),this.ads.on(_.a.AD_PROGRESS,(function(r){t.update_time_remaining(r.remaining,r.duration),t.progress=e.as_progress(r)})),this.volume_btn&&this.volume_btn.addEventListener("click",(function(){return t.maybe_adapter((function(e){t.content.muted=e.volume()>0,e.volume(t.content.muted?0:0==t.content.volume?.1:t.content.volume)}))}))}},{key:"playback_changed",value:function(e){this.ad_loading(!1),e&&this.animate(),this.wrapper.classList.toggle(F,e),this.wrapper.classList.toggle("ad-paused",!e),this.wrapper.classList.toggle("ad-ui-disabled",this.maybe_adapter((function(e){return e.isUiDisabled()})))}},{key:"maybe_adapter",value:function(e){return this.ads&&this.ads.adapter?e(this.ads.adapter):0}},{key:"destroy",value:function(){this.ads.ui=this.root=this.content=this.config=this.wrapper=this.adContainer=0}},{key:"classList",get:function(){return this.wrapper.classList}}]),e}();function j(e){return{width:e.clientWidth,height:e.clientHeight}}function G(e,t,r){return"number"==typeof r&&(r+="px"),e.style.setProperty(t,r),e}r(7)("fpads:dom");var H=r(7)("fpads:plugin:native"),K={on:!0},V={on:!1},W=[_.a.AD_PLAYBACK_ERROR,_.a.AD_TEARDOWN,_.a.AD_BREAK_COMPLETED],q=function(){function e(){v()(this,e)}var t,r,n,i;return m()(e,null,[{key:"user_gesture",value:function(){return flowplayer.events.BEFORE_PLAY}},{key:"snapshot",value:function(e,t){return{muted:!(t||!e.muted),volume:e.volume}}},{key:"start_from_user_gesture",value:function(t){var r=t.content,n=t.ads,i=t.config,a=t.ui,s=t.state,o=t.initial,l=t.adContainer,u=t.ima,c=e.user_gesture();r.once(c,function(){var t=h()(d.a.mark((function t(c){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.in_viewport||"touchend"!=c.type){t.next=2;break}return t.abrupt("return");case 2:if(n.shallPlayAd(0)){t.next=4;break}return t.abrupt("return");case 4:return!D&&c.preventDefault(),e.add_time_listeners({ads:n,content:r,ui:a,state:s}),H("LifeCycle.user_gesture(:intercept) -> shallPlayAd(0: %s)",n.shallPlayAd(0)),i.muted=o.muted,t.next=10,e.start({ads:n,content:r,state:s,adContainer:l,ima:u,config:i});case 10:e.update_time({ads:n,content:r,ui:a});case 11:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}())}},{key:"init",value:(i=h()(d.a.mark((function t(r){var n,i,a,s,o,l,u,c,f,h,p,v;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.config,i=r.root,a=r.content,s=r.ads,o=r.ima,a.autoplay=!1,l=n.autoplay===(flowplayer.autoplay||flowplayer.autoplay_options).AUDIO_REQUIRED,u=e.snapshot(a,l),c=flowplayer,f=c.events,a.on(f.VOLUME_CHANGE,(function(){u.volume=a.volume,u.muted=a.muted})),h=B.of({ads:s,content:a,config:n,initial:u,root:a.root}),p=h.adContainer,v={listening:!1,preload:R(n,"ima.preload_ads",!1)},H("LifeCycle.initial()",{initial:u}),s.setVideoTag(a),!n.autoplay){t.next=18;break}return H("Trying to autoplay"),h.hideFirstFrame(),t.next=16,e.peek_content(a,l);case 16:t.sent?(H("Can autoplay, start ad"),a.opts.autoplay=!0,e.start({ads:s,content:a,state:v,adContainer:p,ima:o,config:n})):(H("cannot autoplay(audioRequired: %s), fallback to poster state",l),n.autoplay=!1,h.showFirstFrame(),a.setState("is-starting",!0));case 18:n.autoplay||s.hasPreroll()&&e.start_from_user_gesture({content:a,ads:s,config:n,ui:h,state:v,initial:u,adContainer:p,ima:o}),!n.autoplay&&s.hasPreroll()&&v.preload&&e.start({ads:s,content:a,state:v,adContainer:p,ima:o,config:n}),e.ui_listeners({config:n,root:i,content:a,ads:s,state:v,adContainer:p,ui:h,ima:o,initial:u}),a.on(f.SOURCE,(function(){a.once(f.BEFORE_PLAY,(function(){return s.resetScheduleCounter()}))}));case 22:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"start",value:(n=h()(d.a.mark((function e(t){var r,n,i,s,o,l,c,f,h,p,v;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.ads,n=t.content,i=t.adContainer,s=t.ima,o=t.state,l=t.config,c=void 0===l?{}:l,!o.started){e.next=3;break}return e.abrupt("return");case 3:return o.started=!0,s.ads,f=u()(s,["ads"]),h=c.dimensions||j(n.root),p=R(c,"muted",n.muted),v=Object.assign(a()({container:i,volume:p?0:R(c,"volume",n.volume),muted:p,autoplay:R(c,"autoplay",!1),video_source:n.original_src,DisableCustomPlaybackForIOS10Plus:R(c,"fake_fullscreen",D),preload_ads:R(c,"ima.preload_ads",!1)},f,h)),H("LifeCycle.start():",v,o),e.next=11,r.initialize(!1,v,o.preload);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"ui_listeners",value:function(t){var r=t.config,n=t.root,i=t.content,s=t.ads,o=t.initial,l=t.adContainer,u=t.state,c=t.ui,f=t.ima;H("LifeCycle.ui_listeners()");var p=flowplayer,v=p.events,g=p.states;i.once(v.PLAYING,function(){var t=h()(d.a.mark((function t(o){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=2;break}return t.abrupt("return");case 2:if(H("LifeCycle.ui_listeners() -> content started playing"),e.add_time_listeners({ads:s,content:i,ui:c,state:u}),s.shallPlayAd(0)&&s.adapter.adLinear){t.next=9;break}return H("LifeCycle.ui_listeners() -> no more preroll ads -> resume content"),t.next=8,e.start({ads:s,content:i,state:u,adContainer:l,ima:f,config:r});case 8:return t.abrupt("return",t.sent);case 9:return i.pause(),t.next=12,e.start({ads:s,content:i,state:u,adContainer:l,ima:f,config:r});case 12:if(s.shallPlayAd(0)&&s.adapter.adLinear){t.next=14;break}return t.abrupt("return");case 14:c.toggle(a()({},K,{linear:!0})),n.classList.add(g.WAITING),e.update_time({ads:s,content:i,ui:c});case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()),i.on([v.PORTRAIT,v.LANDSCAPE,v.RESIZE],(function(){if(s){var e=i.clientWidth||i.parentNode.clientWidth||n.clientWidth,t=i.clientHeight||i.parentNode.clientHeight||n.clientHeight;s.resize({height:t,width:e})}})),i.on(v.ENDED,(function(e){s&&(H("LifeCycle.ui_listeners(:%s, event: %o)",e.type,e.data),e.data&&e.data.from===s||(e.preventDefault(),s.finished((function(){i.emit(v.ENDED,{from:s})}))))})),s.on(_.a.AD_REQUESTED,(function(){n.classList.toggle(g.WAITING,!0)})),s.once(_.a.AD_STARTED,(function(){var e=flowplayer.events;i.on([e.BEFORE_PLAY,e.BEFORE_PAUSE],(function(t){if(s.adBreak&&s.adapter.adLinear){t.preventDefault();var r=R(t,"data.forced",!1)?t.type===e.BEFORE_PLAY:!s.adPlaying;r&&s.paused&&s.resume(),r||s.paused||s.pause()}}))})),s.on(_.a.AD_STARTED,(function(e){var t=e.linear,r=e.ad,l=e.ad_type;if(H("Ad[linear: ".concat(t,", currentTime: ").concat(i.currentTime,"] starting"),r),"preroll"==l&&!t&&i.paused&&i.play(),"preroll"==l&&t&&i.currentTime>0&&!i.opt("start_time")&&!i.opt("live")&&(H("Preroll[rewind: true]",i.currentTime),i.currentTime=0),s.resize({width:r.width,height:r.height,linear:t,resize_non_linear:!0}),c.resize({linear:t,resizeContainerAlso:!0,width:t?void 0:r.width,height:t?void 0:r.height}),n.classList.remove(g.WAITING),c.toggle(a()({},K,{linear:t,ad:r})),!t)try{i.togglePlay(!0),i.volume=o.volume,i.muted=o.muted}catch(e){H(e)}})),s.on(_.a.AD_PAUSE_CONTENT,(function(){c.resize({linear:!0,resizeContainerAlso:!0,width:void 0,height:void 0})})),W.forEach((function(t){return s.on(t,(function(r){return e.teardown({root:n,content:i,ui:c,initial:o,err:r,event:t})}))}))}},{key:"add_time_listeners",value:function(t){var r=t.ads,n=t.content,i=t.ui,a=t.state,s=flowplayer.events;a.listening||(n.on([s.TIME_UPDATE,s.SEEKED,s.PLAYING,s.SEEKING],(function(t){r&&(r.adPlaying&&r.adapter.adLinear&&!r.adapter.sharedVideoTag&&!n.paused&&n.pause(),e.update_time({ads:r,content:n,ui:i,seek:t.type===s.SEEKING}))})),a.listening=!0)}},{key:"update_time",value:function(e){var t=e.ads,r=e.content,n=e.seek,i=void 0!==n&&n;t&&t.setCurrentTime(r.currentTime,void 0,i)}},{key:"teardown",value:(r=h()(d.a.mark((function t(r){var n,i,a,s,o,l,u,c,f,h;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.root,i=r.content,a=r.ui,s=r.event,o=r.err,l=void 0===o?{}:o,a.isShowing()||i.paused){t.next=3;break}return t.abrupt("return",{noop:1});case 3:if(u=flowplayer,c=u.states,n.classList.add("is-seamless"),a.classList.remove("is-vpaid"),n.classList.remove(c.WAITING),H("LifeCycle.teardown(event: %s)",s),l.reason&&H("LifeCycle.teardown(:err, reason: %s) %o",l.reason),a.toggle(V),f=i.ads,h=f.getLastAd(),f.shouldRestartContent()){t.next=15;break}return H("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),t.abrupt("return",e.on_content_playing(n));case 15:if(!(i.currentTime>0&&i.currentTime>=i.duration||"postroll"==f.ad_type||!1===h.restart)){t.next=18;break}return H("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),t.abrupt("return",e.on_content_playing(n));case 18:if(""===i.currentSrc&&i.setSrc(i.original_src),!i.paused||!f.shouldRestartContent()){t.next=23;break}return H("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),t.next=23,i.togglePlay(!0);case 23:if(i.paused){t.next=26;break}return H("Lifecycle.teardown(:ok)","restarted video content"),t.abrupt("return",e.on_content_playing(n));case 26:case"end":return t.stop()}}),t,this)}))),function(e){return r.apply(this,arguments)})},{key:"on_content_playing",value:function(e){e.classList.remove("is-seamless")}},{key:"maybe_blocked",value:function(e){H("google.ima not found in window"),[].slice.call(document.getElementsByTagName("script")).filter((function(e){return t=e.src,(r=document.createElement("a")).href=t,"imasdk.googleapis.com/js/sdkloader/ima3.js"=="".concat(r.host).concat(r.pathname);var t,r})).length>0&&e.emit(_.a.AD_BLOCKED)}},{key:"peek_content",value:(t=h()(d.a.mark((function t(r,n){var i,a,s,o,l,u;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=[r.muted,r.volume],H("LifeCycle::peek_content(:muted => %s, :volume => %s)",a=i[0],s=i[1]),o=function(){return new Promise((function(e){return setTimeout(e,0,!1)}))},l=function(){return new Promise((function(e){return setTimeout((function(){return e(r.play())}))}))},u=function(){return new Promise((function(e){return setTimeout((function(){return e(r.pause())}))}))},n&&(r.muted=!1,r.volume=r.volume?r.volume:1),t.prev=6,t.next=9,e.wait_for_source(r);case 9:return r.volume&&(r.volume=.01),H("LifeCycle::peek_content::play"),t.next=13,l();case 13:return H("LifeCycle::peek_content::pause"),t.next=16,u();case 16:return r.volume=s,H("LifeCycle::peek_content::true"),t.abrupt("return",!0);case 21:if(t.prev=21,t.t0=t.catch(6),r.volume=s,!n){t.next=30;break}return r.muted=!1,0==r.volume&&(r.volume=1),t.next=29,o();case 29:return t.abrupt("return",t.sent);case 30:if(!a&&s){t.next=35;break}return H("LifeCycle::peek_content::false"),t.next=34,o();case 34:return t.abrupt("return",t.sent);case 35:return H("LifeCycle::peek_content::recover"),r.muted=!0,t.next=39,e.peek_content(r);case 39:if(!t.sent){t.next=41;break}return t.abrupt("return",!0);case 41:return r.muted=a,H("LifeCycle::peek_content::false"),t.next=45,o();case 45:return t.abrupt("return",t.sent);case 46:case"end":return t.stop()}}),t,this,[[6,21]])}))),function(e,r){return t.apply(this,arguments)})},{key:"wait_for_source",value:function(e){return H("LifeCycle::wait_for_source"),new Promise((function(t,r){var n=0,i=setInterval((function(){if(++n>40)return clearInterval(i),r(new Error("No source in ".concat(2e3,"ms, giving up")));e.currentSrc&&(t(),clearInterval(i))}),50)}))}}]),e}();q.TERMINAL_EVENTS=W;var z=r(51),Y=r(21),X="function"==typeof requestAnimationFrame?requestAnimationFrame:setTimeout;function Q(e){var t=0,r=null;return function(){for(var n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];var s=Date.now()-t;null===r&&(r=X((function(){r=null,e.apply(void 0,i),t=Date.now()}),16-s))}}r(106);var Z=r(32),J=r(46),$=r(50),ee=r(7)("fpads:native:outstream"),te={OUTSTREAM_VISIBLE:"ads-outstream-visible",OUTSTREAM_VIEWPORT_UPDATE:"ads-outstream-viewport-update",OUTSTREAM_TEARDOWN:"ads-outstream-teardown",OUTSTREAM_ENDSCREEN_READY:"ads-outstream-endscreen-ready"},re=function(){function e(t){var r=this,n=t.ads,i=t.container,a=t.video,s=t.ima;v()(this,e),n.outstream=this,this.video=a,this.ads=n,this.container=i,this.ima=s,this.aspect_ratio=i.aspect_ratio.style.paddingTop,this.dimensions=function(e){if(e.clientWidth>0||e.clientHeight)return j(e);var t={height:e.style.height};G(e,"opacity",0),G(e,"display","absolute"),G(e,"display","inline-block"),G(e,"height","auto");var r=j(e);return G(e,"height",t.height),G(e,"opacity",1),r}(this.container),ee("creating Outstream instance"),this.hide(),this.poll_viewport_exit=e.fps_60_visibilty_checker({outstream:this}),this.setup();var o=Object($.a)(this.container,function(){var e=h()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:return o(),e.next=5,r.begin_life_cycle();case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}())}var t;return m()(e,null,[{key:"of",value:function(t){return new e(t)}},{key:"fps_60_visibilty_checker",value:function(e){var t=e.outstream;return Q((function(){if(!t.disposed){var e=t.percent_in_viewport();if(t.ads.emit(te.OUTSTREAM_VIEWPORT_UPDATE,{percent:e}),!(e>.5&&t.ads.adPlaying))return e>.5?t.ads.resume():void t.ads.pause()}}))}}]),m()(e,[{key:"hide",value:function(){return this}},{key:"restore_aspect_ratio",value:function(){return ee("Outstream.restore_aspect_ratio(".concat(this.aspect_ratio,")")),this.container.aspect_ratio.style.paddingTop=this.aspect_ratio,this}},{key:"percent_in_viewport",value:function(){return e=this.video.root.getBoundingClientRect(),t=window.innerHeight,(r=e.y)>t||r+e.height<0?0:e.y<0?(e.height+r)/e.height:t-e.y>e.height?1:Math.abs((t-e.y)/e.height);var e,t,r}},{key:"show",value:function(){this.container.removeClass(e.CLASS.HIDDEN),this.container.addClass(e.CLASS.SHOWING),this.ui.toggle({linear:!0,on:!0})}},{key:"begin_life_cycle",value:(t=h()(d.a.mark((function e(){var t,r,n,i,s,o=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Z.a(!1);case 2:return t=e.sent,r=t.error,n=t.result,e.next=7,Z.a(!0);case 7:return i=e.sent,s=i.result,this.attach_ad_listeners(),this.ui.initial={can_autoplay:!(!n&&!s),muted:!n},ee("Outstream.show() :autoplay >> ",this,{error:r,can_autoplay_audio:n}),r&&this.video&&!n&&(this.video.muted=!0,this.video.volume=0),e.next=15,this.ads.setVideoTag(this.video);case 15:return this.ads.on(_.a.AD_PAUSE_CONTENT,(function(e){var t=e.linear;o.ads.resize({width:o.dimensions.width,height:o.dimensions.height,linear:t})})),e.next=18,q.start({ads:this.ads,content:this.video,adContainer:this.adContainer,ima:this.ima,state:{},opts:a()({},this.video.opts,{muted:!0,dimensions:this.dimensions})});case 18:q.update_time({content:this.video,ads:this.ads,ui:this.ui});case 19:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"attach_ad_listeners",value:function(){var e=this,t=this,r=t.ads;r.once(_.a.AD_PAUSE_CONTENT,(function(){t.show(),t.poll_viewport_exit(),document.addEventListener("scroll",t.poll_viewport_exit),window.emit("resize")})),t.ima.always_show_controls||r.on(_.a.VPAID_INIT,(function(){return t.ui.addClass("is-vpaid")}));var n=function r(n){q.TERMINAL_EVENTS.forEach((function(e){return t.ads.removeListener(e,r)}));var i,a,s=(i=te.OUTSTREAM_TEARDOWN,(a=document.createEvent("Event")).initEvent(i,!1,!0),a);ee("Outstream(:teardown)",s),e.video.dispatchEvent(s)};q.TERMINAL_EVENTS.forEach((function(e){return t.ads.once(e,n)})),this.video.once(te.OUTSTREAM_TEARDOWN,(function(e){setTimeout((function(){if(e.defaultPrevented)return t.handle_endscreen();t.dispose()}),0)}))}},{key:"handle_endscreen",value:function(){this.reset_ui(),this.ads.reset(),this.ui.wireup(),q.ui_listeners(a()({},this,{content:this.video,root:this.video.root,state:{started:!0},initial:{muted:!0}}))}},{key:"empty_src",value:function(){this.video.setSrc({type:"video/mp4",src:URL.createObjectURL(J.a)})}},{key:"setup",value:function(){this.container.addClass(e.CLASS.IS),this.container.addClass(e.CLASS.HIDDEN),this.empty_src(),this.ui=B.of({root:this.video.root,content:this.video,ads:this.ads,config:this.video.opts}),this.adContainer=this.ui.adContainer}},{key:"poll_viewport_exit",value:function(){this.ads.adPlaying&&this.ads.pause()}},{key:"reset_ui",value:function(){var t=this.container;t.removeClass(e.CLASS.SHOWING),t.removeClass(e.CLASS.IS),document.removeEventListener("scroll",this.poll_viewport_exit),this.ui.toggle({on:!1})}},{key:"dispose",value:function(){if(!this.disposed){var t=this.container,r=this.video;this.reset_ui(),t.addClass(e.CLASS.IS),t.addClass(e.CLASS.DONE),this.video=this.container=this.ads=0,this.disposed=1,r.destroy()}}}]),e}();re.CLASS={IS:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"},re.events=re.EVENT=te;var ne=r(9);function ie(e,t,r){if(!("google"in window))return q.maybe_blocked(r);var i=e.autoplay;r.autoplay=e.autoplay=!1;var s=r.ads=new z.a,o=s.analytics=Object(Y.b)(s),l=!1;s.resize(j(t)),flowplayer.ads||(flowplayer.ads={}),flowplayer.ads.version="1.16.7",flowplayer.ads.commit="8017b3e4c408cd0f212db2300242817be04b6d2c",flowplayer.ads.events=_.a,flowplayer.ads.ui=n,D&&(r.on([flowplayer.events.FULLSCREEN_ENTER,flowplayer.events.FULLSREEN_EXIT,"webkitendfullscreen"],(function(e){var t=e.type===flowplayer.events.FULLSCREEN_ENTER;r.ads.adapter.setIOSPlaysInline(!t)})),s.on(_.a.AD_POSTROLL_FINISHED,(function(){s.adapter.sharedVideoTag&&s.once(_.a.AD_BREAK_COMPLETED,(function(){r.src=r.original_src,r.once(flowplayer.events.CAN_PLAY,(function(e){r.pause()})),r.webkitExitFullscreen()}))}))),flowplayer.Outstream=re,r.on(flowplayer.events.REAP,(function(){s&&s.destroy(),o=s=void 0})),r.on(flowplayer.events.SOURCE,(function(){s&&s.stop()})),r.on(flowplayer.events.CONFIG,(function(n){var u=n.data,c=u.ima||{};if(Array.isArray(c.ads)){var d=u.duration||r.duration;if(c.ads=function(e,t){return Array.isArray(e)&&e.map((function(e,r){return"number"==typeof e.time||e.lazy?e:isNaN(e.percentage)?(console.warn("Ad[index: ".concat(r,"] passed without 'time' property or 'percentage' properties")),e):isNaN(t)?(console.warn("Ad[index: ".concat(r,"] passed with 'percentage' property but both content and config 'duration' was ").concat(t)),e):"number"==typeof e.percentage?(e.time=Math.floor(e.percentage*t),e):e}),[])}(c.ads,d),s.setSchedule(c.ads,d),u.metadata&&Y.a.mergeMetadata(o,u.metadata),u.metadata&&s.mergeMacros(u.metadata),u.metadata&&c.parameters&&(c.parameters=a()({},c.parameters,u.metadata)),Y.a.mergeMetadata(o,{muted:u.muted||!1,autoplay:u.autoplay||!1}),!l){if(l=!0,e.lang&&!c.Locale&&(c.Locale=e.lang),ne.a.isOutstream(c.ads))return re.of({container:t,video:r,ads:s,ima:c});q.init({config:a()({},e,{autoplay:i}),root:t,content:r,ads:s,ima:c})}}else void 0!==i?e.autoplay=i:delete e.autoplay}))}Object.assign(_.a,re.events),window.addEventListener("resize",Q((function(){null!=("undefined"==typeof flowplayer?"undefined":o()(flowplayer))&&Array.isArray(flowplayer.instances)&&flowplayer.instances.forEach((function(e){return e.ads&&e.ads.resize(j(e))}))}))),ie.events=_.a,ie.ui=n,ie.Outstream=re,ie.version="1.16.7",ie.commit="8017b3e4c408cd0f212db2300242817be04b6d2c"},function(e,t){e.exports=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}},function(e,t,r){var n=r(99);"string"==typeof n&&(n=[[e.i,n,""]]),r(20)(n,{insert:"head",singleton:!1}),n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(19)(!1)).push([e.i,'.fp-ad-container .fp-color{background-color:gold}.fp-ad-container .fp-color-text{color:gold;font-weight:700;line-height:1.8em}.fp-ad-container{position:absolute;z-index:-1;background:#333;top:0;left:0;right:0;bottom:0;opacity:0}.fp-ad-controls{position:absolute;direction:ltr;top:100%;left:0;margin-top:-3.2em;height:3em;z-index:1000;display:none;padding:.72em 0em .72em 2em;justify-content:space-between;align-items:center;font-weight:500;text-align:right}.fp-ad-controls .fp-volumebtn:after{filter:drop-shadow(0 0 2px rgba(0, 0, 0, 0.4))}.fp-ad-controls .fp-secondary{filter:drop-shadow(0 0 2px rgba(0, 0, 0, 0.4));position:relative;left:0;top:0}.is-small .ad-indicator{display:none}.is-small .fp-ad-controls>*{transform:scale(0.8)}.is-tiny .fp-ad-controls>*{transform:scale(0.7)}.fp-ad-controls .fp-fullscreen,.fp-ad-controls .fp-fullscreen-exit{visibility:visible !important;position:relative;top:.2em}.fp-ad-controls .fp-volumebtn{margin-right:2.38em}.fp-ad-controls .fp-btns,.fp-ad-controls .ad-indicator,.fp-ad-controls .fp-volume{margin-right:1em}.no-fullscreen .fp-ad-controls .fp-fullscreen,.no-fullscreen .fp-ad-controls .fp-fullscreen-exit{visibility:hidden !important;height:0;width:0}.fp-ad-controls .ad-indicator:before{margin-right:.5em}.fp-ad-controls .fp-volumebtn{width:1.12em}.fp-ad-controls .fp-volume{display:none;margin-left:-2em}.fp-ad-controls .fp-skip-next{display:none}.ad-volume-bar .fp-volume{display:flex}.fp-ad-controls .fp-volumebtn{height:100%}.fp-ad-controls .fp-volumebtn:after{font-size:230% !important;line-height:inherit !important}.fp-ad-controls .fp-btns{width:1.8em}.fp-ad-container.ad-paused .fp-small-play{display:inline-block}.fp-ad-container.ad-playing .fp-small-pause{display:inline-block}.fp-ad-container.ad-playing .fp-small-play{display:none}.fp-ad-container .fp-volume-mute-unmute{height:100%}.fp-ad-remaining:after{content:"·";margin-left:.5em;margin-right:.5em}.fp-ad-progress-wrapper{direction:ltr}.fp-ad-progress{height:.2em;top:100%;margin-top:-0.2em;width:0%;position:absolute;transition:width .2s}.logo-on-right .fp-secondary>*{margin:0}.fp-ad-choises-icon{display:none}.is-ad-attribution .fp-ad-container::after{content:"Advertisement";position:absolute;width:100%;text-align:center;z-index:10;color:gray;background-color:rgba(255,255,255,.2);font-size:11px;font-weight:500}.is-ad-choices .fp-ad-choices{position:absolute;width:77px;height:15px;right:0;border-bottom-left-radius:8px;padding-left:5px;color:#000;background-color:rgba(255,255,255,.7);font-size:11px;font-weight:500;z-index:11}.is-ad-choices .fp-ad-choices::after{content:" ";background-image:url("data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjI1MDAiIHZpZXdCb3g9Ii4yIDAgMTkuNCAyMCIgd2lkdGg9IjI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTIuMiAyMGMxIDAgMS43LS41IDIuNC0uOS42LS4zIDEuMi0uNyAxLjktMSAzLjItMS43IDYuNC0zLjUgOS42LTUuMyAxLS41IDIuMy0xIDMtMS45LjItLjMuNS0uNy40LTEuMi0uMy0xLjEtMS43LTEuNS0yLjYtMi0yLjItMS4yLTQuNS0yLjUtNi43LTMuNy0uOC0uNS0yLTEuNC0zLS43LS40LjItLjYuNC0uNy43LS4xLjQgMCAuOSAwIDEuM3YzLjJjMCAuOS0uMSAxLjYuNSAyIC4yLjEuNi4yLjkuMSAxLS40LjctMi4yLjctMy42di0xLjFjMS43LjkgMy40IDEuOCA1LjEgMi42LjYuMyAxLjYuNiAxLjggMS40LjIuOS0xLjcgMS42LTIuMyAxLjlsLTYuOSAzLjljLS41LjMtMS44IDEuMy0yLjYgMS0uMy0uMS0uNS0uNC0uNS0uNi0uMS0uNC0uMS0xLS4xLTEuNXYtMy4yLTUuNGMwLS44LS4xLTEuOC4yLTIuMy43LTEgMi4zLjggMi44LS44LjEtLjQtLjEtLjgtLjMtMS0uNC0uNi0yLjItMS41LTIuOS0xLjctLjItLjEtLjctLjItMS0uMi0xLjcuMy0xLjMgMy0xLjMgNXY5LjljMCAxLjUtLjIgMy41LjQgNC40LjMuNS42LjUgMS4yLjd6bTUuMi02LjVjMS41IDAgMS42LTEuOS4yLTIuMi0uOC0uMS0xLjQuNy0xLjIgMS40LjIuNS41LjYgMSAuOHoiIGZpbGw9IiMwMGFlY2QiLz48L3N2Zz4=");background-size:contain;display:inline-block;position:absolute;width:13px;height:13.747px;right:1px;top:1px}.ad-hide-first-frame .fp-wait{opacity:1}.ad-hide-first-frame .fp-engine{display:none}.ad-hide-first-frame>.fp-ui .fp-switch{display:none}',""])},function(e,t,r){var n=r(101);"string"==typeof n&&(n=[[e.i,n,""]]),r(20)(n,{insert:"head",singleton:!1}),n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(19)(!1)).push([e.i,".is-ad-linear .fp-ad-container{z-index:1;opacity:1}.is-ad-linear.is-hovered .fp-ad div{background-image:linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent 15%),linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 20%)}.is-ad-linear.is-hovered .fp-ad-controls,.is-ad-linear.is-ad-controls-sticky .fp-ad-controls,.is-ad-linear .ad-paused .fp-ad-controls{display:flex}.is-ad-linear .fp-ad-container.ad-ui-disabled .fp-ad-controls,.is-ad-linear .fp-ad-container.ad-ui-disabled .fp-ad-progress{display:none !important}.ad-paused .fp-ad-controls .fp-btns svg.fp-small-play{display:inline}.ad-paused .fp-ad-controls .fp-btns svg.fp-small-pause{display:none}.ad-playing .fp-ad-controls .fp-btns svg.fp-small-pause{display:inline}.ad-playing .fp-ad-controls .fp-btns svg.fp-small-play{display:none}.fp-ad-container.ad-paused .fp-wait,.fp-ad-container.ad-playing .fp-wait{display:none !important}.fp-ad-container.is-waiting .fp-ad-controls,.fp-ad-container.is-waiting .fp-ad-progress{display:none}.fp-ad-container.is-waiting .fp-wait{position:absolute;height:2em;opacity:1;top:50%;z-index:1;width:4em;left:50%;margin-left:-2em;margin-top:-1em}",""])},function(e,t,r){var n=r(103);"string"==typeof n&&(n=[[e.i,n,""]]),r(20)(n,{insert:"head",singleton:!1}),n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(19)(!1)).push([e.i,".is-ad-nonlinear .fp-ad-controls,.is-ad-nonlinear .fp-ad-progress{display:none}.is-ad-nonlinear .fp-ad-container{background:transparent}.is-ad-nonlinear.is-ad-showing .fp-ad-container{left:0%;top:100%;width:100%;z-index:1;opacity:1}.is-ad-nonlinear.is-ad-showing .fp-ad-wrapper{position:relative}.is-ad-nonlinear.is-ad-showing .fp-ad{margin:0 auto}",""])},function(e,t,r){var n=r(105);"string"==typeof n&&(n=[[e.i,n,""]]),r(20)(n,{insert:"head",singleton:!1}),n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(19)(!1)).push([e.i,".fp-ad-container.is-vpaid .fp-ad-controls{display:none}",""])},function(e,t,r){var n=r(107);"string"==typeof n&&(n=[[e.i,n,""]]),r(20)(n,{insert:"head",singleton:!1}),n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(19)(!1)).push([e.i,".flowplayer.is-outstream{background:transparent}.flowplayer.is-outstream .fp-ui{visibility:hidden}.flowplayer.is-outstream-hidden>video,.flowplayer.is-outstream-done>video{display:none}.flowplayer.is-outstream-visible{height:auto}.flowplayer.is-outstream-visible .fp-ad-container{left:0px;top:0px}",""])},,,,,function(e,t,r){r(53),r(72),r(74),r(76),e.exports=r(96)}]).default})));const{samsung_tv:Xn}=r();class Ads{init(e,t,r){if(it.from_token(e.token||"").is_granted(it.permissions.ADS)&&!Xn)return Yn(e,t,r)}}return Qe(window,Object.assign(Ads,Yn)),en.extensions.push(HLS,OVP,Ads),Object.assign(en,{hls:HLS,ads:Ads,ovp:OVP}),en}));
371
+ /*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m,a=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,e.url)}catch(t){r.open("GET",e.url,!0),n(r,e.url)}r.readyState||r.open("GET",e.url,!0)}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var n=e.readyState,s=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){e.onreadystatechange=null,e.onprogress=null;var a=e.status;if(a>=200&&a<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===t.responseType?(o=e.response).byteLength:(o=e.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o};this.callbacks.onSuccess(d,r,t,e)}else r.retry>=s.maxRetry||a>=400&&a<499?(i.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e)):(i.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},e.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},t}();e.default=a}}).default},t.exports=r())})));var hi=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const fi="com.widevine.alpha";const pi="application/vnd.apple.mpegURL",gi=[pi,"application/x-mpegurl"],mi=document.createElement("video").canPlayType(pi);function vi({src:t="",type:e="",drm:r},i){const n=(null==i?void 0:i.hls)||{},s="native"in n&&n.native;return(!mi||!s)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[fi].filter((function(t){return t===e})).length;var e}))&&(!(!e||!gi.includes(e))||function(t){const{pathname:e}=Ze(t);return e.endsWith(".m3u8")}(t)))}var yi="audio:set",Ei="audio:update",Ti="audio:tracks";const _i=[ci.Events.SUBTITLE_TRACKS_UPDATED,ci.Events.SUBTITLE_TRACK_SWITCH,ci.Events.LEVEL_SWITCHED];function bi(t,e){_i.forEach((function(r){t.on(r,(function(){!function(t,e){var r;const i=t.levels[t.currentLevel];if(!i||!t.subtitleTracks.length||i.attrs.SUB)return;const n=null===(r=null==i?void 0:i.attrs)||void 0===r?void 0:r.SUBTITLES;if(!n)return e.emit("tracks:text:all",[]);const s=t.subtitleTracks.filter((function(t){return t.groupId==n})).map((function(t){return e.textTracks[t.id]}));e.emit("tracks:text:all",s)}(t,e)}))}))}var Si=Object.assign(Object.assign({},{404:"the video was not found",403:"access to this video was denied",410:"the video no longer exists",0:"no internet connection detected"}),{keySystemNoKeys:"no keys",keySystemNoAccess:"no access to key system",keySystemNoSession:"no session for key system",keySystemLicenseRequestFailed:"license request failed",keyLoadError:"decrypt key load failed",keyLoadTimeOut:"decrypt key load timed outs"});function Ai(t,e,r){if(!t.reaper||!r.src)return;t.hls&&(t.emit("recover",{type:"hls"}),t.hls.destroy());const n="live"in e==0,s={is_audio_only:!1,fragDuration:-1};if(r.drm&&!Je()&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit(i,{message:"Secure page required for DRM"});const a=t.hls=new ci(function(t){return Object.assign(Object.assign({autoStartLoad:!1},t.hls),{startPosition:t.start_time||-1})}(e)),o={retry_count:0,previous_url:"",previous_content:""};a.subtitleDisplay=!1,a.attachMedia(t),a.loadSource(r.src),t.emit("hls:attached",{hls:a}),function(t,e){t.on(ci.Events.AUDIO_TRACKS_UPDATED,(function(t,r){e.emit(Ti,r.audioTracks)})),t.on(ci.Events.AUDIO_TRACK_SWITCHING,(function(t,r){e.emit(Ei,r)})),t.on(ci.Events.MANIFEST_PARSED,(function(t,r){r.audioTracks&&e.emit(Ti,r.audioTracks)})),t.on(ci.Events.LEVEL_SWITCHED,(function(r,i){const n=t.levels[i.level];n&&e.emit(Ti,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(a,t),bi(a,t);const l=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(a.levels[r]||-1===r?a.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},u=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=a.audioTrack&&setTimeout((function(){a.audioTrack=r}),0)};t.on("quality:set",l),t.on(yi,u),t.on(S,(function(){t.hls&&t.hls.destroy(),t.off("quality:set",l),t.off(yi,u)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on(A,(function(){a&&a.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&Li(t)}),n&&a.on(ci.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),a.on(ci.Events.MANIFEST_PARSED,(function(r,i){const n=i.levels.slice(0).reduce((t,e,r)=>[...t,{level:r,text:e.name||e.width+"",width:e.width,height:e.height,videoCodec:e.videoCodec||""}],[{text:"AUTO",level:-1,width:0,height:0,videoCodec:""}]).sort((t,e)=>e.width-t.width);t.emit("qualities",n),function(t,e,r){if(!t.hls)return;void 0!==e.start_quality&&(mt.HIGH&e.start_quality&&(t.hls.startLevel=r[0].level),mt.LOW&e.start_quality&&(t.hls.startLevel=r[r.length-1].level),mt.MEDIUM&e.start_quality&&(t.hls.startLevel=r[Math.ceil(r.length/2)-1].level));if("none"===e.preload&&!e.autoplay)return;Li(t,e.start_time||-1)}(t,e,n.slice(0,-1));const s=n.find(t=>!!t.videoCodec);s||t.emit("audioonlysource"),!t.opt("ratio")&&s&&0!=s.width&&0!=s.height&&t.setOpts({ratio:s.width+":"+s.height})})),a.on(ci.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),a.on(ci.Events.ERROR,(function(e,r){!function(t,e,r,n){if(0==t.reaper)return;if(0==e.fatal)return;switch(e.type){case ci.ErrorTypes.MEDIA_ERROR:return function(t,e){var r;t.emit(i,{fatal:!0,message:"Unrecoverable error occurred while playing media"}),null===(r=t.hls)||void 0===r||r.destroy()}(t);case ci.ErrorTypes.NETWORK_ERROR:return function(t,e){var r;const n=(null===(r=e.networkDetails)||void 0===r?void 0:r.status)||"";t.emit(i,{fatal:!0,code:"http:"+n.toString(),message:Si[n]||"an error occurred while loading this video"})}(t,e);case ci.ErrorTypes.KEY_SYSTEM_ERROR:(function(t,e){var r;t.emit(i,{fatal:!0,message:Si[e.details]||"an error occurred while accessing this video"}),null===(r=t.hls)||void 0===r||r.destroy()})(t,e)}}(t,r,t.original_src,a.config)})),a.on(ci.Events.LEVEL_PTS_UPDATED,(function(e,r){var i;if("video"!==r.type&&(!s.is_audio_only||"audio"!==r.type))return;const n=null===(i=null==r?void 0:r.details)||void 0===i?void 0:i.fragments;if(!n)return;const a=n[0].start||0,o=n[n.length-1].start+n[n.length-1].duration;t.emit("dvr/window",o-a)})),a.on(ci.Events.LEVEL_SWITCHING,(e,r)=>{const i=a.levels[a.currentLevel],n=a.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})}),a.on(ci.Events.LEVEL_UPDATED,(t,e)=>{e.details.url!==o.previous_url&&(o.retry_count=0),o.previous_url=e.details.url;const r=o.previous_content;if(o.previous_content=e.details.m3u8,r===e.details.m3u8){if(o.retry_count++,o.retry_count<3)return;if(a.levels[e.level].url.length<2)return;a.levelController.redundantFailover(a.currentLevel)}});const d=t.opt("start_time");d&&t.once(h,(function(){t.currentTime=d})),"none"!==e.preload||e.autoplay||t.once("beforeplay",()=>{Li(t,e.start_time||-1)})}function Li(t,e){var r;t.setState(J,!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){Ai(r,t,i)}wants(t,e,r){return ci.isSupported()&&vi(e,r)}}HLS.events=hi,HLS.version=ci.version,ee(window,HLS);const wi=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),ki=(...t)=>t.reduce((t,e)=>wi(e)?(Object.keys(e).forEach(r=>{if(wi(t[r])&&wi(e[r]))return t[r]=ki(t[r],e[r]);t[r]=e[r]}),t):t,{});class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...r){return null==t?t:e.apply(t,[t,...r])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const r=t.apply(this,[this.data,...e]);return new Pipe(r)}unwrap(){return this.data}}function Ri(t){return fetch(t).then(t=>t.json())}function Di(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),Oi()+"/web/public/native/config"+t}const Oi=()=>"https://ljsp.lwcdn.com";function Ii(t){return~t.indexOf("/")?t:"/media/"+t}var Ci={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function Pi(t){const e=t.ima,r=t.duration;if(!e||!r)return t;const i=null==e?void 0:e.ads;return Array.isArray(i)&&(e.ads=i.map((function(t){return"number"==typeof t.percentage&&(t.time=t.percentage*r),t}))),t}function xi(t,e){var r,i;e="object"==typeof e?e:{};const n={title:null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.title,description:null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.description},s={ima:{parameters:function({media_id:t,duration:e,title:r,tags:i,category_name:n,ad_keywords:s}){return{ad_keywords:s||"",media_id:t||"",category:n||"",media_name:r||"",media_tags:i||"",media_duration:e||-1}}((null==t?void 0:t.metadata)||{})}},a=e.embed||{};return delete a.src,ki(s,n,t,(delete(o=e).src,delete o.metadata,delete o.title,delete o.description,delete o.duration,delete o.poster,o),a);var o}const Mi=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function Fi(t){return"object"==typeof t&&"ovp/base64"==t.type}function Ni(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!Mi.test(t))&&(e.type="video/ovp",!0))}(t,e)||Fi(e)}function Ui(t){try{return function(t){return null===t?{}:JSON.parse(t)}(decodeURIComponent(atob(t).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join("")))}catch(t){return{err:t.message}}}function Bi(t){const e=t.split(/[^0-9]/).map(t=>parseInt(t,10));return Date.UTC(e[0],e[1]-1,e[2],e[3],e[4],e[5])}function Gi(t){return t.live}var ji=Object.freeze({__proto__:null,OVP_ERROR:"ovp:error",OVP_MEDIA_REQUEST_START:"ovp:request:start",OVP_MEDIA_REQUEST_COMPLETE:"ovp:request:media:complete",OVP_PLAYLIST_REQUEST_COMPLETE:"ovp:request:playlist:complete",LIVE_COUNTDOWN_TICK:"ovp:live:countdown:tick",LIVE_COUNTDOWN_START:"ovp:live:countdown:start",LIVE_COUNTDOWN_COMPLETE:"ovp:live:countdown:complete",OVP_MEDIA_CHANGED:"ovp:media:changed",OVP_REALTIME_MESSAGE:"ovp:message:realtime"});function Hi(t,e){const r=null==e?void 0:e.src;if(Fi(e))return function(t,e){const r=Ui(e.src||"");if(function(t){return"string"==typeof t.err}(r))return console.error(r.err);Ki(t,r)}(t,e);r&&Pipe.of(r).fmap(Ii).fmap(Di).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,r])=>200==e?Ki(t,r):Vi(t,r)))}function Ki(t,e){return t.emit("ovp:media:changed",e),function(t){return Array.isArray(t.playlist)}(e)?function(t,e){if("function"!=typeof window.flowplayer.playlist)return console.warn("OVP responded with Playlist media but the playlist plugin does not exist"),Vi(t,{status:415});t.emit("ovp:request:playlist:complete",function(t,e){const r=Object.assign({},t),i=(null==t?void 0:t.playlist)||{},n=ki(e,i),s=((null==n?void 0:n.playlist)||[]).map(t=>xi(t,r));return Object.assign(n,{playlist:s})}(t.opts,e))}(t,e):Gi(e)?function(t,e){var r,i;const n=(null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.live_start_time)||(null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.starttime);n&&(e.live_start_time=Pipe.of(n).fmap(Bi).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(xi,t.opts).fmap(Pi).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(xi,t.opts).fmap(Pi).unwrap())}(t,e)}function Vi(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(Ci[e.status])):t.emit("ovp:error",e)}const qi={};function Wi(t,e,r){"object"!=typeof qi[e]&&(qi[e]=r);const i=t.opts,n=(null==i?void 0:i.metadata)||{};n.player_id=e,i.metadata=n,r.title&&delete r.title,r.description&&delete r.description;const s=Object.assign(i,r);t.setOpts(s),r.autoplay&&t.togglePlay(!0)}let zi=!1;function Yi(t,e,r){Xi()||Pipe.of("recommendation").fmap(Di,e,r).fmap(Ri).fmap(e=>e.then(e=>function(t,e){const r=e.playlist;if(t.opts.recommendations=r,!r.length)return;t.emit("recommendationsready",{playlist:r.map((function(t){var e;return{poster:t.poster,src:t.src,title:null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.title,metadata:t.metadata||{}}}))})}(t,e)).catch(Qi))}function Xi(){return zi}function Qi(t){zi=!0,console.error("Failed to load recommendations: %j",t)}function $i(t){return t&&t.live_start_time&&t.live_start_time-Date.now()>0}function Ji(t,e){let r=0;function i(){return function(t,e){const r=Date.now()-e;return Math.floor((t-r)/1e3)}(e.live_start_time||0,e.server_time_offset||0)}function n(){const n=i();if(n<0||isNaN(n)||0===t.reaper)return clearInterval(r),function(t,e){t.emit("ovp:live:countdown:complete");const r=Pt(t,z);r&&r.remove(),t.root.classList.remove("is-livecountdown"),t.emit("ovp:request:media:complete",e)}(t,e);!function(t,e,r,i){r.classList.add("is-livecountdown"),e.emit("ovp:live:countdown:tick",{remaining_time:Zi(i+1)}),e.hasState(Z)||e.setState(Z,!0)}(0,t,t.root,n)}var s;s=e,wr().then(t=>Object.assign(s,{server_time_offset:t})),n(),r=setInterval(n,250)}function Zi(t){const e=function(t){"number"!=typeof t&&(t=parseInt(t,10)),t=Math.round(t);const e=Math.floor(t/86400);t-=86400*e;const r=Math.floor(t/3600);t-=3600*r;const i=Math.floor(t/60);return{days:e,hours:r,minutes:i,seconds:t-=60*i}}(t);let r="";return e.days&&(r+=e.days+":"),r+Nt(e.hours)+":"+Nt(e.minutes)+":"+Nt(e.seconds)}class WebsocketBridge{constructor(t){this.manualDisconnect=!1,this.video=t,this.onClose=this.onClose.bind(this),this.onMessage=this.onMessage.bind(this)}static of(t){return new WebsocketBridge(t)}connect(t){this.client=new WebSocket("wss://player.ws.flowplayer.com?mediaId="+t),this.current_media_id=t,this.wireup()}onClose(){this.manualDisconnect?this.manualDisconnect=!1:this.current_media_id&&this.reconnect(this.current_media_id)}onMessage(t){JSON.parse(t.data).forEach(t=>{this.video.emit("ovp:message:realtime",t)})}reconnect(t){this.cleanup(),this.connect(t)}wireup(){this.client&&(this.client.addEventListener("message",this.onMessage),this.client.addEventListener("close",this.onClose))}cleanup(){this.client&&(this.client.removeEventListener("message",this.onMessage),this.client.removeEventListener("close",this.onClose),this.client=void 0)}disconnect(){this.client&&(this.manualDisconnect=!0,this.client.close())}}class FlowplayerLiveCountdown extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-livecountdown");const e=Mt("fp-inner");this.append(e);const r=document.createElement("p");r.innerText=t.i18n("ovp.starting_in"),e.append(r);const i=document.createElement("p");i.classList.add("fp-countdown"),e.append(i),t.on("ovp:live:countdown:tick",e=>{const r=e.detail.remaining_time;t.root.classList.add("is-livecountdown"),i.innerText=r})}}const tn=["*.lwcdn.com","*.flowplayer.com"];class OVP{constructor(t){gt(t,z,FlowplayerLiveCountdown)}onload(t,e,r,i){if("string"==typeof i.src)return"string"!=typeof t.player_id||0===i.src.indexOf(t.player_id)||Fi(i)||(i.src=[t.player_id,i.src].join("/")),Hi(r,i)}wants(t,e,r){return Ni(t,e)}init(t,e,r){const n=new WebsocketBridge(r);let s=Object.assign({},t);const a=function(t){if(!s)return t;delete s.src;const e=ki(t,s);return s=!1,e};r.on("ovp:error",(function(t){r.emit(i,t.data)})),r.on("ovp:request:start",(function(){r.setState(it,!0),t.recommendations&&(t.recommendations=!1)})),r.on("ovp:media:changed",(function({data:t}){var e;const r=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id;(null==t?void 0:t.live)&&r&&(n.disconnect(),n.connect(r))})),r.on("ovp:message:realtime",(function({data:e}){var i;const n=null==e?void 0:e.event,s=null==e?void 0:e.value,a=r.opt("metadata",{live_start_time:""});switch(n){case"METADATA":{const e=Object.assign(a,s),n=Object.assign(t,{metadata:e});n.live&&(null===(i=null==n?void 0:n.metadata)||void 0===i?void 0:i.live_start_time)&&(n.live_start_time=Bi(n.metadata.live_start_time)),r.setOpts(n);break}}})),r.on("beforeplay",(function(e){const r=t;if(Gi(r)){if(en(r))return;e.preventDefault()}})),r.on("ovp:request:media:complete",(function(t){const e=t.data;if(!e)return;if(0==r.reaper||"object"!=typeof t.data||$i(t.data))return;const i=a(e);r.setOpts(i),r.setAttrs(i),i.src&&r.setSrc(i.src),i.autoplay&&r.togglePlay(!0)})),r.on(L,(function({data:i}){var n,s;if("string"==typeof t.src&&Ni(t.src,{}))return;if(t.src&&rn(t.src))return;if((null==i?void 0:i.domains)&&(null==i?void 0:i.domains.length)&&!((t,e)=>{const r=t.split(".").reverse();return e.concat(tn).some(t=>{const e=t.split(".").reverse(),i="*"===e[e.length-1];return i&&e.pop(),(i||e.length===r.length)&&e.every((t,e)=>r[e]===t)})})(function(){try{return window.location.hostname!==window.parent.location.hostname?Ze(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}(),i.domains))return de({root:e,video:r,data:{details:`Hostname ${window.location.hostname} is not allowed to load player ${null===(n=i.metadata)||void 0===n?void 0:n.player_id}.`,reason:"domain"}});const a=null==i?void 0:i.brand_color;return a&&r.root.style.setProperty("--fp-brand-color","#"==a[0]?a:"#"+a),"string"==typeof t.player_id&&(null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.player_id)!==t.player_id?function(t,e){if("object"==typeof qi[e])return console.debug("using Cache(%s)",e),Wi(t,e,qi[e]);Pipe.of(e).fmap(Di).fmap(Ri).fmap(r=>r.then(r=>Wi(t,e,r)).catch(console.error))}(r,t.player_id):void 0})),r.on("ovp:request:playlist:complete",(function(t){const e=t.data;if(!e||0==r.reaper)return;const{playlist:i}=e,n=_t(e,["playlist"]),s=a({playlist:n});Array.isArray(s.playlist)&&(s.playlist=n),r.setOpts(s);const o={type:"flowplayer/playlist",items:i};r.setSrc(o)})),r.on("ovp:live:countdown:start",(function(i){const n=i.data;if(!n||0==r.reaper)return;const s=a(n);if(r.setOpts(s),r.setAttrs(s),!$i(n))return r.emit("ovp:request:media:complete",n);Pt(r,z)||(e.appendChild(pt(r,z)),Ji(r,t))})),r.on("timeupdate",(function(){var e,i,n;const s=t;Gi(s)?en(s)||(r.togglePlay(!1),r.emit(T)):t.recommendations&&(null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.media_id)&&(Array.isArray(t.recommendations)||r.currentTime/r.duration<.8||Xi()||(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.media_id)&&(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.player_id)&&Yi(r,t.metadata.media_id,t.metadata.player_id))})),r.on(A,(function(){n.disconnect()}))}}function en(t){var e,r;const i=null===(e=null==t?void 0:t.metadata)||void 0===e?void 0:e.live_stop_time;if(!i)return!0;return!!(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.allow_after_stop_time)||Bi(i)>Date.now()}OVP.events=ji;const rn=t=>{var e;if(t&&Array.isArray(t))return"object"==typeof t[0]&&"ovp/base64"===(null===(e=t[0])||void 0===e?void 0:e.type)};function nn(t){return{width:t.clientWidth,height:t.clientHeight}}function sn(t,e,r){return"number"==typeof r&&(r+="px"),t.style.setProperty(e,r),t}ee(window,OVP);const an="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,on=Er("ads/lifecycle"),ln=["ad-playback-error","ad-teardown","ad-break-completed"];async function un({config:t,root:e,content:r,ads:i,ima:n}){r.autoplay=!1;const s=t.autoplay===vt.AUDIO_REQUIRED,a=function(t,e){return{muted:!(e||!t.muted),volume:t.volume}}(r,s);r.on("volumechange",()=>{a.volume=r.volume,a.muted=r.muted});const o=pt(r,"flowplayer-ad-ui"),l=o.adContainer;e.append(o);const u={listening:!1,preload:null==n?void 0:n.preload_ads};if(on("initial",a),i.setVideoTag(r),t.autoplay){on("Trying to autoplay"),o.hideFirstFrame(e);await async function t(e,r){const[i,n]=[e.muted,e.volume];on("Lifecycle::peek_content(:muted => %s, :volume => %s)",i,n);const s=()=>new Promise(t=>setTimeout(t,0,!1));r&&(e.muted=!1,e.volume=e.volume?e.volume:1);try{return await async function(t){return on("Lifecycle::wait_for_source"),new Promise((e,r)=>{let i=0;const n=setInterval(()=>{if(++i>40)return clearInterval(n),r(new Error("No source in 2000ms, giving up"));t.currentSrc&&(e(null),clearInterval(n))},50)})}(e),e.volume&&(e.volume=.01),on("Lifecycle::peek_content::play"),await new Promise(t=>setTimeout(()=>t(e.play()))),on("Lifecycle::peek_content::pause"),await new Promise(t=>setTimeout(()=>t(e.pause()))),e.volume=n,on("Lifecycle::peek_content::true"),!0}catch(a){return e.volume=n,r?(e.muted=!1,0==e.volume&&(e.volume=1),await s()):i||!n?(on("Lifecycle::peek_content::false"),await s()):(on("Lifecycle::peek_content::recover"),e.muted=!0,!!await t(e)||(e.muted=i,on("Lifecycle::peek_content::false"),await s()))}}(r,s)?(on("Can autoplay, start ad"),r.opts.autoplay=1,dn({ads:i,content:r,state:u,adContainer:l,ima:n,config:t})):(on("cannot autoplay(audioRequired: %s), fallback to poster state",s),t.autoplay=0,o.showFirstFrame(e),r.setState("is-starting",!0))}t.autoplay||i.hasPreroll()&&function({content:t,ads:e,config:r,state:i,initial:n,adContainer:s,ima:a}){t.once("beforeplay",(async function(o){(t.hasState(at)||"touchend"!=o.type)&&e.shallPlayAd(0)&&(!an&&o.preventDefault(),fn({ads:e,content:t,state:i}),on("user_gesture(:intercept) -> shallPlayAd(0: %s)",e.shallPlayAd(0)),r.muted=n.muted,await dn({ads:e,content:t,state:i,adContainer:s,ima:a,config:r}),pn({ads:e,content:t}))}))}({content:r,ads:i,config:t,state:u,initial:a,adContainer:l,ima:n}),!t.autoplay&&i.hasPreroll()&&u.preload&&dn({ads:i,content:r,state:u,adContainer:l,ima:n,config:t}),hn({config:t,root:e,content:r,ads:i,state:u,adContainer:l,ui:o,ima:n,initial:a}),r.on(S,()=>{r.once("beforeplay",()=>i.resetScheduleCounter())})}async function dn({ads:t,content:e,adContainer:r,ima:i,state:n,config:s}){var a;if(n.started)return;n.started=!0;const o=_t(i,["ads"]),l=nn(e.root),u=(null==s?void 0:s.muted)||e.muted,d=Object.assign(Object.assign(Object.assign({container:r,volume:u?0:e.volume,muted:u,autoplay:(null==s?void 0:s.autoplay)||!1,video_source:e.original_src,DisableCustomPlaybackForIOS10Plus:an,preload_ads:null===(a=null==s?void 0:s.ima)||void 0===a?void 0:a.preload_ads},o),l));on("start():",d,n),await t.initialize(!1,d,n.preload)}function cn(t,e){var r,i;return{content_width:t.clientWidth||(null===(r=t.parentNode)||void 0===r?void 0:r.clientWidth)||e.clientWidth,content_height:t.clientHeight||(null===(i=t.parentNode)||void 0===i?void 0:i.clientHeight)||e.clientHeight}}function hn({config:t,root:e,content:r,ads:i,initial:n,adContainer:s,state:a,ui:o,ima:l}){on("addUIListeners()"),r.once(v,async n=>{if(i){if(on("addUIListeners() -> content started playing"),fn({ads:i,content:r,state:a}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return on("addUIListeners() -> no more preroll ads -> resume content"),await dn({ads:i,content:r,state:a,adContainer:s,ima:l,config:t});r.pause(),await dn({ads:i,content:r,state:a,adContainer:s,ima:l,config:t}),i.shallPlayAd(0)&&i.adapter.isLinearAd()&&(o.classList.add("on","linear"),e.classList.add(it),pn({ads:i,content:r}))}}),r.on([k,w],(function(){if(!i)return;const{content_width:t,content_height:n}=cn(r,e);i.resize({height:n,width:t})})),r.on("resize",t=>{if(!i||!t.detail)return;const{width:e,height:r}=t.detail.contentRect;i.resize({width:e,height:r})}),r.on(T,t=>{var e;i&&(on("ui_listeners(:%s, event: %o)",t.type,t.detail),(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.from)!==i&&(t.preventDefault(),i.finished((function(){r.emit(T,{from:i})}))))}),i.on("ad-requested",()=>{e.classList.toggle(it,!0)}),i.once("ad-started",()=>{r.on(["beforeplay","beforepause"],t=>{var e;if(!i.adBreak||!i.adapter.isLinearAd())return;t.preventDefault();const r=(null===(e=t.detail)||void 0===e?void 0:e.forced)?"beforeplay"===t.type:!i.adPlaying;r&&i.paused&&i.resume(),r||i.paused||i.pause()})}),i.on("ad-started",t=>{const s=t.detail,{linear:a,ad:l,ad_type:u}=s;let d;if(on(`Ad[linear: ${a}, currentTime: ${r.currentTime}] starting`,l),"preroll"==u&&!a&&r.paused&&r.play(),"preroll"==u&&a&&r.currentTime>0&&!r.opt("start_time")&&!r.opt("live")&&(on("Preroll[rewind: true]",r.currentTime),r.currentTime=0),a&&(d=cn(r,e)),i.resize({width:d?d.content_width:l.width,height:d?d.content_height:l.height,linear:a,resize_non_linear:!0}),o.resize({linear:a,resizeContainerAlso:!0,width:a?void 0:l.width,height:a?void 0:l.height}),e.classList.remove(it),o.classList.add("on"),o.classList.toggle("linear",a),o.classList.toggle("non-linear",!a),!a){on("non-linear ad / restarting content");try{r.togglePlay(!0),r.volume=n.volume,r.muted=n.muted}catch(t){on(t)}}}),i.on("ad-pause-content",()=>{o.resize({linear:!0,width:0,height:0})}),ln.forEach(t=>i.on(t,n=>async function({root:t,content:e,ads:r,ui:i,eventName:n,err:s={reason:""}}){if(!i.classList.contains("on")&&!e.paused)return;t.classList.add("is-seamless"),i.classList.remove("is-vpaid"),t.classList.remove(it),on("teardown(event: %s)",n),s.reason&&on("teardown(:err, reason: %s) %o",s.reason);i.classList.remove("on");const a=r.getLastAd();if(i.showFirstFrame(t),!r.shouldRestartContent())return on("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),gn(t);if(e.currentTime>0&&e.currentTime>=e.duration||"postroll"==r.ad_type||!1===(null==a?void 0:a.restart))return on("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),gn(t);""===e.currentSrc&&e.setSrc(e.original_src);e.paused&&r.shouldRestartContent()&&(on("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await e.togglePlay(!0));if(!e.paused)return on("Lifecycle.teardown(:ok)","restarted video content"),gn(t)}({root:e,content:r,ads:i,ui:o,err:n.detail,eventName:t})))}function fn({ads:t,content:e,state:r}){r.listening||(e.on(["timeupdate",_,v,b],r=>{t.adPlaying&&t.adapter.isLinearAd()&&!t.adapter.isSharedVideoTag()&&!e.paused&&e.pause(),pn({ads:t,content:e,seek:r.type===b})}),r.listening=!0)}function pn({ads:t,content:e,seek:r=!1}){t&&t.setCurrentTime(e.currentTime,void 0,r)}function gn(t){t.classList.remove("is-seamless")}const mn=Er("ads/timers");class TimerRegistry{constructor(t={},e={}){this.intervals=t,this.timers=e}}let vn=-1;function yn(t,e,r){const i=setInterval(r,e);if(mn("TimerRegistry.createInterval() -> "+i,t.intervals),"object"==typeof i){const e=++vn;return t.intervals[e]=e,e}return t.intervals[i]=i,i}function En(t){if(t)return mn("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach(e=>function(t,e){return mn("TimerRegistry.removeInterval() -> "+e,t.intervals),clearInterval(t.intervals[e]),delete t.intervals[e],t}(t,e)),Object.keys(t.timers).forEach(e=>function(t,e){return mn("TimerRegistry.removeTimeout() -> "+e,t.timers),clearTimeout(t.timers[e]),delete t.timers[e],t}(t,e)),t}class Schedule{constructor(t,e={}){this._ads=t,this._opts=e,this._nextIndex=0,this._postroll=void 0,this._loadPending=!1,this._postrollActive=!1,this.reset(this._ads)}toJSON(){const t=(this._ads||[]).slice(this._nextIndex);return this._postroll&&t.push(this._postroll),t}reset(t){this.setAds(t),this._nextIndex=0,this._postrollActive=!1}resetCounter(){this._nextIndex=0,this._postrollActive=!1}setAds(t){this._ads=t||[],this.sort()}getAds(){return this._ads}getNextAd(t){return this._ads[this._nextIndex]||t}getCurrentAd(){return this._postrollActive?this._postroll:this._loadPending?0:this._ads[this._nextIndex-1]}getPostroll(){return this._postroll}isDrained(){return this._nextIndex+1>this._ads.length}setPostrollActive(){this._postrollActive=!0}updateContentDuration(t){this._opts.content_duration=t}increment(){++this._nextIndex}decrement(){this._nextIndex>0&&--this._nextIndex}getNextIndex(){return this._nextIndex}getCurrentType(){const t=this.getCurrentAd();if(t)return Schedule.kindOf(t.time)}sort(){this._postroll=this._ads.find(t=>-1===t.time),this._ads=this._ads.filter(t=>t!==this._postroll).sort((t,e)=>t.time===e.time?this._ads.indexOf(t)-this._ads.indexOf(e):t.time-e.time)}shallPlayAd(t){if(this._loadPending)return!1;const e=this.getCurrentAd()||this.getNextAd();return!!(e&&e.time<=t&&-1!==e.time)}shallPlayNext(){const t=this.getNextAd(),e=this.getCurrentAd();return!(!t||!e||t.time!==e.time)}waitForLoad(t,e,r){if(this._loadPending=!1,!e)return!1;const i=r?this._opts.preload_advance:0;return e.time>=0?this._loadPending=t<e.time-i:-1===e.time&&(this._loadPending=this._opts.content_duration>0&&-1!==t?t<this._opts.content_duration-i:-1!==t),this._loadPending}static hasPreroll(t){return!!t.find(t=>0===t.time)}static isOutstream(t){return Schedule.hasPreroll(t)&&!!t[0].outstream}static kindOf(t){switch(t){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}function Tn(t){try{return t.getAdPodInfo().getPodIndex()}catch(t){return}}class IMA{constructor(t){this.eventHandler=t,this.log=Er("ads/adapter/ima"),this.google=window.google,this._adHandlers=[],this._timers=new TimerRegistry,this._started=!1,this._volumeLevel=0,this._adLoaded=!1,this._paused=!1,this._all_ads_completed=!1,this._currentDuration=0,this._currentRemaining=0,this._currentDisplayTs=0,this._iosPlaysInline=!1,this.sharedVideoTag=!1,this._isInitialized=!1,this._prepared=!1,this.opts={}}async init(t){this.log("init",this.videoTag,t),this.opts=t,this._dimensions={width:t.width,height:t.height,linear:t.linear},this._prepared=!0,!this._isInitialized&&this.videoTag&&await this.initAdapter()}async initAdapter(){this.log("initAdapter",this.opts);try{await this.initialize(this.opts),this._isInitialized=!0}catch(t){this.log("initAdapter failed:",t),this._prepared=!1,this.eventHandler.trigger("ad-adapter-init-failed")}}isReady(){return!!this._isInitialized}setIOSPlaysInline(t){this.log("setIOSPlaysInline",t),this.sharedVideoTag=!t,this.initialize(Object.assign(Object.assign({},this.opts),{DisableCustomPlaybackForIOS10Plus:t}))}getIOSPlaysInline(){return this._iosPlaysInline}setVideoTag(t){this.videoTag=t}isLinearAd(){return!!this._adLinear}isSharedVideoTag(){return!!this.sharedVideoTag}getVideoTag(){return this.videoTag}getDimensions(){return this._dimensions||{}}getOpts(){return this.opts}isPaused(){return this._paused}destroy(){En(this._timers),this._adHandlers&&this._adHandlers.forEach(t=>t()),this._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),this._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),this._adsManager=void 0}stop(){this._adsManager&&this._adsManager.stop()}initialize(t){const e=this.isAdPod(),r=this._adLoaded||e;if(this.cleanup(),!this.videoTag)return console.warn("videoTag not set during initialization");this.opts=t,this._volumeLevel=t.volume;const i=this.google.ima.settings;t.NumRedirects=t.NumRedirects||t.redirects;const n={VpaidMode:this.google.ima.ImaSdkSettings.VpaidMode.INSECURE,DisableCustomPlaybackForIOS10Plus:!0};if(i.setVpaidMode(t.VpaidMode||n.VpaidMode),i.setDisableCustomPlaybackForIOS10Plus(t.DisableCustomPlaybackForIOS10Plus||n.DisableCustomPlaybackForIOS10Plus),"NumRedirects"in t&&i.setNumRedirects(t.NumRedirects),"AutoPlayAdBreaks"in t&&i.setAutoPlayAdBreaks(t.AutoPlayAdBreaks),"Locale"in t&&i.setLocale(t.Locale),"Ppid"in t&&i.setPpid(t.Ppid),!document.body.contains(t.container))throw new Error("AdDisplayContainer was not found in the document.body");this._adDisplayContainer=new this.google.ima.AdDisplayContainer(t.container,this.videoTag),this._adDisplayContainer.initialize(),this._adsLoader=new this.google.ima.AdsLoader(this._adDisplayContainer),this.log("ima.initialise(:wait -> ADS_MANAGER_LOADED)",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(!this.videoTag)return;this.log("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted}));const r=new this.google.ima.AdsRenderingSettings;this.log("ima.rendering(preload: %s)",!!t.preload_ads),r.useStyledNonLinearAds=!0,r.enablePreloading=!!t.preload_ads,"number"==typeof t.media_timeout&&(r.loadVideoTimeout=t.media_timeout),r.restoreCustomPlaybackStateOnAdBreakComplete=!t.DisableCustomPlaybackForIOS10Plus,this.sharedVideoTag&&(r.playAdsAfterTime=this.videoTag.currentTime),this.eventHandler.trigger("ad-ima-rendering-settings",r);const i=this._adsManager=e.getAdsManager(this.videoTag,r);this.eventHandler.trigger("ad-ima-adapter-init",i),i.addEventListener(this.google.ima.AdEvent.Type.LOADED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.LOADED")}),i.addEventListener(this.google.ima.AdErrorEvent.Type.AD_ERROR,()=>{this.log("debug(ima.adsManager): google.ima.AdErrorEvent.Type.AD_ERROR")}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.STARTED")}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,t=>{this.debugEvent(t);const e=t.getAd();e&&(this._currentDuration=e.getDuration(),this._currentDisplayTs=Date.now(),this.emitWithAd("ad-started",e),e.isLinear()&&IMA.pollRemaining({ima:this,adsManager:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.COMPLETE,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd("ad-completed",e),En(this._timers)}),i.addEventListener(this.google.ima.AdEvent.Type.SKIPPED,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd("ad-skipped",e)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd("ad-pause-content",e)});const n=()=>{this._started=!1,this._currentDisplayTs=0,this.eventHandler.trigger("ad-break-completed")};i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,t=>{this.debugEvent(t),n()}),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_CHANGED,t=>{this.log("IMA::volume(type: %s, event: %o)",t);const e=i.getVolume();this._volumeLevel=e,this.eventHandler.trigger("ad-volume-changed",e)});const s=t=>{this._paused=t,this.eventHandler.trigger(t?"ad-paused":"ad-resumed")};i.addEventListener(this.google.ima.AdEvent.Type.PAUSED,()=>s(!0)),i.addEventListener(this.google.ima.AdEvent.Type.RESUMED,()=>s(!1)),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>s(!1)),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_MUTED,t=>{this.log("IMA::volume(type: %s, event: %o)","mute",t),this.eventHandler.trigger("ad-muted")});const{width:a,height:o}=t;a&&o&&(i.init(a,o,this.google.ima.ViewMode.NORMAL),this.log("ima.initialise: done initializing"))}),r&&(this.log("Event(reload: %s)","reload-ad-requested"),this.eventHandler.trigger("reload-ad-requested",e)),this.eventHandler.trigger("ad-initialized",this)}destroyManager(t="unknown"){if(!this._adsManager)return this.log("ima::destroyManager(:skip, label: %s)",t);this.log("ima::destroyManager(:ok, label: %s)",t),this._adsManager.destroy()}reset(){this.destroyManager("reset"),En(this._timers),this.clearAdHandlers(),this._started=!1,this._adLoaded=!1}cleanup(){this.destroyManager("cleanup"),this._adsLoader&&this._adsLoader.destroy(),this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adLoaded=!1}waitForAdsManager(){return new Promise(t=>{this.log("ima.waitForAdsManager:",this._adsManager),this.once(this._adsLoader,this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,()=>{this.log("ima.waitForAdsManager(:ok)",this._adsManager),t(this._adsManager)})})}async initAd(t,e=5e3){this.log(`ima.initAd(adTag: ${t}, timeout: ${e})`);try{await this.requestAd(t,e),this._adLoaded=!0}catch(t){throw this.log("ima.initAd:",t),this._adLoaded=!1,t}finally{En(this._timers)}}async requestAd(t,e){if(this.destroyManager("requestAd"),!this.videoTag)return;const{autoplay:r=!1}=this.opts,i=Date.now(),n=this.videoTag.muted;this._volumeLevel=this.videoTag.volume;const s=n||0==this._volumeLevel;this._all_ads_completed=!1,this.log("ima.requestAd(%o)",Object.assign(Object.assign({},this.opts),{autoplay:r,muted:n,timeout:e,adTag:t,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers();const a=new this.google.ima.AdsRequest;a.adTagUrl=t;const{height:o,width:l}=this.opts;if(l&&(a.linearAdSlotWidth=l),o&&(a.linearAdSlotHeight=o),!this.opts.disable_non_linear_ads&&l&&(a.nonLinearAdSlotWidth=l),!this.opts.disable_non_linear_ads&&o&&(a.nonLinearAdSlotHeight=o-50),a.setAdWillAutoPlay(r),a.setAdWillPlayMuted(s),a.vastLoadTimeout=e,this.eventHandler.trigger("ad-ima-before-ads-request",{request:a}),!this._adsLoader)return;this._adsLoader.requestAds(a);return new Promise(async(t,r)=>{const n=e=>{clearTimeout(o),t(e)},a=t=>{clearTimeout(o),r(t)};this.once(this._adsLoader,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{this.emitError("ad-request-error",t),a(new Error("Ad load failed"))});const o=setTimeout(()=>{const t=new Error("Ad internal timeout reached");this.eventHandler.trigger("ad-timeout",t),r(t)},1.5*(e+(this.opts.media_timeout||5e3))),l=await this.waitForAdsManager();this.volume(s?0:this._volumeLevel),this.eventHandler.trigger("ad-volume-changed",this._volumeLevel);const u=this.cuepoints();if(u&&u.length&&0!==u[0])return n({ad:!1,adsManager:l});this.once(l,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{this.emitError("ad-playback-error",t),a(t)}),this.once(l,this.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{this._all_ads_completed=!0,n(null)}),this.once(l,this.google.ima.AdEvent.Type.LOADED,t=>{this.eventHandler.trigger("ad-request-completed",{request_load_time:Date.now()-i});const e=t.getAd();e&&(this.log("ima.requestAd: AD_REQUEST_COMPLETED",e.getContentType()),"application/javascript"==e.getContentType()&&this.eventHandler.trigger("vpaid-init",e),n(null))}),this.once(l,this.google.ima.AdEvent.Type.CLICK,()=>{this.log("ima.requestAd: click event"),this.pause()})})}async playAd(){if(this.log("ima.playAd()",this),!this._adsManager||!this._adLoaded)return;const t=this.currentAd();if(t&&(!this.sharedVideoTag||t.isLinear()))try{await this.startAndWaitForAdCompletion(this._adsManager,t.isLinear())}catch(t){throw this.log("ima.playAd",t),t}finally{this._adLoaded=!1,En(this._timers)}}startAndWaitForAdCompletion(t,e){if(!this._started)return this.log("ima.startAndWaitForAdCompletion(manager: %o)",{volume:t.getVolume()}),new Promise((r,i)=>{let n=!1;this.once(t,this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{if(this.log("ima.startAndWaitForAdCompletion: CONTENT_RESUME_REQUESTED <<< happened"),this._started=!1,n)return this.log("ima.startAndWaitForAdCompletion: Content resume requested, but trying to recover from ad error");r()}),this.once(t,this.google.ima.AdErrorEvent.Type.AD_ERROR,async t=>{this.log("ima.startAndWaitForAdCompletion: beginning error recovery ->",t),n=!0;try{const{ok:e}=await IMA.pollForFatalError({err:t,ima:this});e&&(n=!1)}catch(e){this._started=!1,i(t)}}),e&&(this._started=!0),t.start(),this.eventHandler.trigger("ad-play-requested")})}pause(){this.log("ima.pause()"),this._adsManager&&this._adsManager.pause()}resume(){this.log("ima.resume()"),this._adsManager&&this._adsManager.resume()}volume(t){if(this._adsManager)try{return arguments.length>0&&"number"==typeof t&&this._adsManager.setVolume(t),this._volumeLevel=this._adsManager.getVolume()}catch(t){this.log("ima.volume() failed (%o)",t)}}onResize({width:t,height:e,linear:r,silent:i,resize_non_linear:n}){this._adsManager&&(this._adLinear=void 0===r?this._adLinear:r,this.opts&&(t||e)&&(!1===r&&(t+=10,e+=10),this._dimensions={width:t,height:e,linear:r},r&&(this.opts.width=t,this.opts.height=e),(this._adLinear||n)&&(i||this.log("ima.onResize %s x %s",t,e),this._adsManager.resize(t,e,this.google.ima.ViewMode.NORMAL))))}getAdInfo(){const t=this.currentAd();if(t)return{duration:t.getDuration(),currentTime:this._currentRemaining}}currentAd(){const t=this._adsManager;if(t)return t.getCurrentAd()}isAdPod(){const t=this.cuepoints();return!!(t&&t.length>1)}cuepoints(){return this._adsManager&&this._adsManager.getCuePoints()}async contentComplete(){this.log("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete();const t=this.cuepoints();t&&-1!==t.indexOf(-1)&&await new Promise(t=>{IMA.race(this.eventHandler,["ad-break-completed","ad-error"],t)})}isUiDisabled(){try{const t=this.currentAd();return t&&t.isUiDisabled()}catch(t){return null}}getAdPodInfo(){try{const t=this.currentAd();return t&&t.getAdPodInfo()}catch(t){return null}}canDismissNonLinear(){const t=this.currentAd();if(!t||t.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;const e=Date.now(),r=t.getMinSuggestedDuration();return e-this._currentDisplayTs>1e3*r}static unwrapError(t,e){if(!t)return"";if("function"==typeof t.getMessage){return t.getMessage()}return t.message?t.message:e||""}static pollForFatalError({err:t,ima:e}){let r;try{const e=t.getError(),i=e.getInnerError(),n=i?IMA.unwrapError(i,e.message):"";r={reason:n,type:e.getType(),code:e.getErrorCode()}}catch(t){}const i=e._currentRemaining;return new Promise((t,n)=>{const s=setTimeout(()=>{e.eventHandler&&e.eventHandler.trigger("ad-playback-error",r),n(new Error("Ad not progressing"))},2500);e.eventHandler.once("ad-progress",e=>{const r=e.detail.remaining;-1!==r&&r<i&&(clearTimeout(s),t({ok:1}))})})}static pollRemaining({ima:t,adsManager:e}){let r=-1;return yn(t._timers,250,(function(){t._currentRemaining=e.getRemainingTime(),r!=t._currentRemaining&&(r=t._currentRemaining,t.eventHandler.trigger("ad-progress",{remaining:t._currentRemaining,duration:t._currentDuration}))}))}once(t,e,r){this._adHandlers.push(function(t,e,r){const i=n=>{r(n),t.removeEventListener(e,i)};return t.addEventListener(e,i),()=>t.removeEventListener(e,i)}(t,e,r))}static race(t,e,r){e.forEach(i=>{const n=(...i)=>{e.forEach(e=>t.removeListener(e,n)),r(i)};t.on(i,n)})}clearAdHandlers(){this.log("ima.clearAdHandlers"),this._adHandlers.forEach(t=>t()),this._adHandlers=[]}emitWithAd(t,e){if(this.log("ima.emitWithAd",t,e),!this._adsManager)return;const r=Tn(e),i=r?Schedule.kindOf(r):"unknown",n=function(t){try{return t.getAdPodInfo().getAdPosition()}catch(t){return}}(e),s=function(t){try{return t.getAdPodInfo().getTotalAds()}catch(t){return}}(e),a={ad_type:i,ad:{duration:e.getDuration(),width:e.getWidth(),height:e.getHeight(),position:n,totals:s},volume:this._adsManager.getVolume(),vast_ad_id:e.getAdId(),linear:e.isLinear(),mime_type:e.getContentType(),ima_event:!0};this.log(`emitWithAd::event(name: ${t}, data: %o, ad: %o)`,a,e),this.eventHandler.trigger(t,a)}emitError(t,e){const r={vast_error_type:e.getError().getType(),reason:e.getError().getMessage(),vast_error:e.getError().getErrorCode()};this.log(`ima.error(${t})`,r),this.eventHandler.trigger(t,r)}debugEvent(t){try{const e=t.getAd();if(!e)return;this.log(`ima.event.${t.type} ->`,{event:t,data:t.getAdData(),position:Tn(e),ad:e})}catch(t){}}}var _n=String.prototype.replace,bn=/%20/g,Sn="RFC3986",An={default:Sn,formatters:{RFC1738:function(t){return _n.call(t,bn,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:Sn},Ln=Object.prototype.hasOwnProperty,wn=Array.isArray,kn=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),Rn=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(r[i]=t[i]);return r},Dn={arrayToObject:Rn,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],i=0;i<e.length;++i)for(var n=e[i],s=n.obj[n.prop],a=Object.keys(s),o=0;o<a.length;++o){var l=a[o],u=s[l];"object"==typeof u&&null!==u&&-1===r.indexOf(u)&&(e.push({obj:s,prop:l}),r.push(u))}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(wn(r)){for(var i=[],n=0;n<r.length;++n)void 0!==r[n]&&i.push(r[n]);e.obj[e.prop]=i}}}(e),t},decode:function(t,e,r){var i=t.replace(/\+/g," ");if("iso-8859-1"===r)return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch(t){return i}},encode:function(t,e,r,i,n){if(0===t.length)return t;var s=t;if("symbol"==typeof t?s=Symbol.prototype.toString.call(t):"string"!=typeof t&&(s=String(t)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var a="",o=0;o<s.length;++o){var l=s.charCodeAt(o);45===l||46===l||95===l||126===l||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||n===An.RFC1738&&(40===l||41===l)?a+=s.charAt(o):l<128?a+=kn[l]:l<2048?a+=kn[192|l>>6]+kn[128|63&l]:l<55296||l>=57344?a+=kn[224|l>>12]+kn[128|l>>6&63]+kn[128|63&l]:(o+=1,l=65536+((1023&l)<<10|1023&s.charCodeAt(o)),a+=kn[240|l>>18]+kn[128|l>>12&63]+kn[128|l>>6&63]+kn[128|63&l])}return a},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(wn(t)){for(var r=[],i=0;i<t.length;i+=1)r.push(e(t[i]));return r}return e(t)},merge:function t(e,r,i){if(!r)return e;if("object"!=typeof r){if(wn(e))e.push(r);else{if(!e||"object"!=typeof e)return[e,r];(i&&(i.plainObjects||i.allowPrototypes)||!Ln.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(r);var n=e;return wn(e)&&!wn(r)&&(n=Rn(e,i)),wn(e)&&wn(r)?(r.forEach((function(r,n){if(Ln.call(e,n)){var s=e[n];s&&"object"==typeof s&&r&&"object"==typeof r?e[n]=t(s,r,i):e.push(r)}else e[n]=r})),e):Object.keys(r).reduce((function(e,n){var s=r[n];return Ln.call(e,n)?e[n]=t(e[n],s,i):e[n]=s,e}),n)}},On=Object.prototype.hasOwnProperty,In={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Cn=Array.isArray,Pn=String.prototype.split,xn=Array.prototype.push,Mn=function(t,e){xn.apply(t,Cn(e)?e:[e])},Fn=Date.prototype.toISOString,Nn=An.default,Un={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Dn.encode,encodeValuesOnly:!1,format:Nn,formatter:An.formatters[Nn],indices:!1,serializeDate:function(t){return Fn.call(t)},skipNulls:!1,strictNullHandling:!1},Bn=function t(e,r,i,n,s,a,o,l,u,d,c,h,f,p){var g,m=e;if("function"==typeof o?m=o(r,m):m instanceof Date?m=d(m):"comma"===i&&Cn(m)&&(m=Dn.maybeMap(m,(function(t){return t instanceof Date?d(t):t}))),null===m){if(n)return a&&!f?a(r,Un.encoder,p,"key",c):r;m=""}if("string"==typeof(g=m)||"number"==typeof g||"boolean"==typeof g||"symbol"==typeof g||"bigint"==typeof g||Dn.isBuffer(m)){if(a){var v=f?r:a(r,Un.encoder,p,"key",c);if("comma"===i&&f){for(var y=Pn.call(String(m),","),E="",T=0;T<y.length;++T)E+=(0===T?"":",")+h(a(y[T],Un.encoder,p,"value",c));return[h(v)+"="+E]}return[h(v)+"="+h(a(m,Un.encoder,p,"value",c))]}return[h(r)+"="+h(String(m))]}var _,b=[];if(void 0===m)return b;if("comma"===i&&Cn(m))_=[{value:m.length>0?m.join(",")||null:void 0}];else if(Cn(o))_=o;else{var S=Object.keys(m);_=l?S.sort(l):S}for(var A=0;A<_.length;++A){var L=_[A],w="object"==typeof L&&void 0!==L.value?L.value:m[L];if(!s||null!==w){var k=Cn(m)?"function"==typeof i?i(r,L):r:r+(u?"."+L:"["+L+"]");Mn(b,t(w,k,i,n,s,a,o,l,u,d,c,h,f,p))}}return b},Gn=Object.prototype.hasOwnProperty,jn=Array.isArray,Hn={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Dn.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Kn=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},Vn=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},qn=function(t,e,r,i){if(t){var n=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,s=/(\[[^[\]]*])/g,a=r.depth>0&&/(\[[^[\]]*])/.exec(n),o=a?n.slice(0,a.index):n,l=[];if(o){if(!r.plainObjects&&Gn.call(Object.prototype,o)&&!r.allowPrototypes)return;l.push(o)}for(var u=0;r.depth>0&&null!==(a=s.exec(n))&&u<r.depth;){if(u+=1,!r.plainObjects&&Gn.call(Object.prototype,a[1].slice(1,-1))&&!r.allowPrototypes)return;l.push(a[1])}return a&&l.push("["+n.slice(a.index)+"]"),function(t,e,r,i){for(var n=i?e:Vn(e,r),s=t.length-1;s>=0;--s){var a,o=t[s];if("[]"===o&&r.parseArrays)a=[].concat(n);else{a=r.plainObjects?Object.create(null):{};var l="["===o.charAt(0)&&"]"===o.charAt(o.length-1)?o.slice(1,-1):o,u=parseInt(l,10);r.parseArrays||""!==l?!isNaN(u)&&o!==l&&String(u)===l&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(a=[])[u]=n:"__proto__"!==l&&(a[l]=n):a={0:n}}n=a}return n}(l,e,r,i)}},Wn=function(t,e){var r=function(t){if(!t)return Hn;if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=void 0===t.charset?Hn.charset:t.charset;return{allowDots:void 0===t.allowDots?Hn.allowDots:!!t.allowDots,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:Hn.allowPrototypes,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:Hn.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:Hn.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:Hn.comma,decoder:"function"==typeof t.decoder?t.decoder:Hn.decoder,delimiter:"string"==typeof t.delimiter||Dn.isRegExp(t.delimiter)?t.delimiter:Hn.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:Hn.depth,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:Hn.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:Hn.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:Hn.plainObjects,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:Hn.strictNullHandling}}(e);if(""===t||null==t)return r.plainObjects?Object.create(null):{};for(var i="string"==typeof t?function(t,e){var r,i={},n=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,s=e.parameterLimit===1/0?void 0:e.parameterLimit,a=n.split(e.delimiter,s),o=-1,l=e.charset;if(e.charsetSentinel)for(r=0;r<a.length;++r)0===a[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===a[r]?l="utf-8":"utf8=%26%2310003%3B"===a[r]&&(l="iso-8859-1"),o=r,r=a.length);for(r=0;r<a.length;++r)if(r!==o){var u,d,c=a[r],h=c.indexOf("]="),f=-1===h?c.indexOf("="):h+1;-1===f?(u=e.decoder(c,Hn.decoder,l,"key"),d=e.strictNullHandling?null:""):(u=e.decoder(c.slice(0,f),Hn.decoder,l,"key"),d=Dn.maybeMap(Vn(c.slice(f+1),e),(function(t){return e.decoder(t,Hn.decoder,l,"value")}))),d&&e.interpretNumericEntities&&"iso-8859-1"===l&&(d=Kn(d)),c.indexOf("[]=")>-1&&(d=jn(d)?[d]:d),Gn.call(i,u)?i[u]=Dn.combine(i[u],d):i[u]=d}return i}(t,r):t,n=r.plainObjects?Object.create(null):{},s=Object.keys(i),a=0;a<s.length;++a){var o=s[a],l=qn(o,i[o],r,"string"==typeof t);n=Dn.merge(n,l,r)}return Dn.compact(n)},zn=function(t,e){var r,i=t,n=function(t){if(!t)return Un;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||Un.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=An.default;if(void 0!==t.format){if(!On.call(An.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var i=An.formatters[r],n=Un.filter;return("function"==typeof t.filter||Cn(t.filter))&&(n=t.filter),{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:Un.addQueryPrefix,allowDots:void 0===t.allowDots?Un.allowDots:!!t.allowDots,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:Un.charsetSentinel,delimiter:void 0===t.delimiter?Un.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:Un.encode,encoder:"function"==typeof t.encoder?t.encoder:Un.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:Un.encodeValuesOnly,filter:n,format:r,formatter:i,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:Un.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:Un.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:Un.strictNullHandling}}(e);"function"==typeof n.filter?i=(0,n.filter)("",i):Cn(n.filter)&&(r=n.filter);var s,a=[];if("object"!=typeof i||null===i)return"";s=e&&e.arrayFormat in In?e.arrayFormat:e&&"indices"in e?e.indices?"indices":"repeat":"indices";var o=In[s];r||(r=Object.keys(i)),n.sort&&r.sort(n.sort);for(var l=0;l<r.length;++l){var u=r[l];n.skipNulls&&null===i[u]||Mn(a,Bn(i[u],u,o,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset))}var d=a.join(n.delimiter),c=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?c+="utf8=%26%2310003%3B&":c+="utf8=%E2%9C%93&"),d.length>0?c+d:""};const Yn=Er("fpads:macros"),Xn=/\[([\s\S]+?)\]/g;class Macros{constructor(t={},e=Xn){this.vars=t,this.pattern=e}static run(t){try{return t()}catch(t){return void console.error(t)}}static merge(...t){return t.reduce((t,e)=>Object.assign(t,e),{})}static cast(t){return void 0===t?"":"function"==typeof t?encodeURIComponent(Macros.run(t)||""):"string"==typeof t?encodeURIComponent(t):""}static normalize(t){return t.trim()}static process_obj(t,e,r){return Object.keys(t).reduce((i,n)=>{const s=Macros.process_str(n,e,r,!0),a=t[n];return null===a?(i[s]=a,i):"object"==typeof a?(i[s]=Macros.process_obj(a,e,r),i):"string"==typeof a?(i[s]=Macros.process_str(a,e,r),i):(console.error(new Error(`${a} at ${n} not a handled Macro type`)),i)},{})}static process_str(t,e,r,i=!1){return t.replace(e.pattern,(t,e)=>{const n=Macros.normalize(e);if(!(n in r)||void 0===r[n])return t;const s=r[n],a=i?s:Macros.cast(s);return Yn("Macro.replace(raw: %s, macro: %s, value: %s)",i,e,a),a})}fork(t={},e=this.pattern){const r=Macros.merge(this.vars,t);return new Macros(r,e)}compile(t,e={}){const r=Macros.merge(this.vars,e),[i,n]=t.split("?"),s=Wn(n||"",{strictNullHandling:!0,decoder:t=>t}),a=zn(Macros.process_obj(s,this,r),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,r,!0)+"?"+a}}function Qn(t,e={width:0,height:0}){let r,i;try{const t=document.createElement("a");t.href=r=window.location!=window.parent.location?document.referrer:document.location.href,i=t.hostname}catch(t){console.error(t)}const{width:n,height:s}=e,{video_source:a}=t||{},o=function(){const t=window;return"object"==typeof t.__flowplayerAdParameters?t.__flowplayerAdParameters:{}}();return Object.assign({random:Date.now(),page_url:r,domain:i,player_width:n,player_height:s,video_url:a,videourl:a},o)}async function $n(t){if("function"!=typeof t)return t;try{return await t()}catch(t){return""}}Macros.patterns={BRACKETS:Xn,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const Jn=Object.prototype,Zn=Object.getPrototypeOf;const ts=Er("fpads:ads:state");var es;!function(t){t[t.IDLE=0]="IDLE",t[t.INITIALIZING=1]="INITIALIZING",t[t.FETCHING_AD=2]="FETCHING_AD",t[t.AD_AVAILABLE=4]="AD_AVAILABLE",t[t.BREAK_ACTIVE=8]="BREAK_ACTIVE",t[t.PLAYING=16]="PLAYING",t[t.FATAL_ERROR=32]="FATAL_ERROR"}(es||(es={}));class AdsState{constructor(t=0){this._state=t}static of(){return new AdsState}reset(){this._state=0}toggleState(t,e){return void 0===t&&ts(new Error("AdState cannot toggleState for `undefined`")),null==typeof e?this._state^=t:e?void(this._state|=t):this._state&=~t}hasAll(t){return this._state==(this._state|t)}hasAny(t){return!!(this._state&t)}get state(){return this._state}}const rs={ok:Er("fpads:analytics:request-queue"),err:Er("fpads:analytics:request-queue:err"),warn:Er("fpads:analytics:request-queue:warn")};class RequestQueue{constructor(t=[],e=[],r={failures:0,ttl:0}){this.pending=t,this.open=e,this.stats=r}static of(){return new RequestQueue}static is_empty(t){return 0==t.pending.length}static is_high_water(t){return t.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(t){if(RequestQueue.is_empty(t))return rs.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(RequestQueue.is_high_water(t))return rs.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),t;try{const e=RequestQueue.lpop(t);e&&RequestQueue.request(t,e)}catch(t){rs.err(t)}}static increment_failures(t){return t.stats.failures++,t.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),t}static handle_error(t,e){RequestQueue.rm(t,e),RequestQueue.increment_failures(t)}static request(t,[e,r,i]){if(rs.ok(`Request[${i.event_type}] request`,i,t.stats),Date.now()<t.stats.ttl)return rs.warn(`Request[${i.event_type}] skipping because too many errors too quickly`,t.stats);const n=new XMLHttpRequest;t.open.push(n),n.timeout=RequestQueue.REQUEST_TIMEOUT_MS,n.ontimeout=function(){RequestQueue.handle_error(t,n),rs.warn(`Request[${i.event_type}] timed out in ${n.timeout}ms`,t.stats)},n.onerror=function(e){RequestQueue.handle_error(t,n),e&&rs.err(e),rs.warn(`Request[${i.event_type}] encountered an Error`,n.responseText,t.stats)},n.onreadystatechange=function(){n.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(t,n),Math.floor(n.status/100)},n.onload=function(){RequestQueue.rm(t,n),t.stats.failures&&t.stats.failures--,rs.ok(`Request[${i.event_type}] :ok`,n.status)},n.open(r,e),n.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{n.send(JSON.stringify(i))}catch(t){rs.err(t)}}static rpush(t,...e){return e.forEach(e=>{if(RequestQueue.is_high_water(t))return rs.warn("Too many open requests, skipping",t.stats);t.pending.push(e),RequestQueue.maybe_spawn_req(t)}),t}static lpop(t){return t.pending.shift()}static rm(t,e){const r=t.open.lastIndexOf(e);return~r&&t.open.splice(r,1),t}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;const is={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},ns={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},ss={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},as={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},os={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(t,e){const r=e.match(t);return r&&r.length>0&&r[1]||""}static getSecondMatch(t,e){const r=e.match(t);return r&&r.length>1&&r[2]||""}static matchAndReturnConst(t,e,r){if(t.test(e))return r}static getWindowsVersionName(t){switch(t){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0}static getVersionPrecision(t){return t.split(".").length}static compareVersions(t,e,r=!1){const i=Utils.getVersionPrecision(t),n=Utils.getVersionPrecision(e);let s=Math.max(i,n),a=0;const o=Utils.map([t,e],t=>{const e=s-Utils.getVersionPrecision(t),r=t+new Array(e+1).join(".0");return Utils.map(r.split("."),t=>new Array(20-t.length).join("0")+t).reverse()});for(r&&(a=s-Math.min(i,n)),s-=1;s>=a;){if(o[0][s]>o[1][s])return 1;if(o[0][s]===o[1][s]){if(s===a)return 0;s-=1}else if(o[0][s]<o[1][s])return-1}}static map(t,e){const r=[];let i;if(Array.prototype.map)return Array.prototype.map.call(t,e);for(i=0;i<t.length;i+=1)r.push(e(t[i]));return r}static find(t,e){let r,i;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(r=0,i=t.length;r<i;r+=1){const i=t[r];if(e(i,r))return i}}static assign(t,...e){const r=t;let i,n;if(Object.assign)return Object.assign(t,...e);for(i=0,n=e.length;i<n;i+=1){const t=e[i];if("object"==typeof t&&null!==t){Object.keys(t).forEach(e=>{r[e]=t[e]})}}return t}static getBrowserAlias(t){return is[t]}static getBrowserTypeByAlias(t){return ns[t]||""}}const ls=/version\/(\d+(\.?_?\d+)+)/i,us=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},r=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/opr\/|opios/i],describe(t){const e={name:"Opera"},r=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/Whale/i],describe(t){const e={name:"NAVER Whale Browser"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/MZBrowser/i],describe(t){const e={name:"MZ Browser"},r=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/focus/i],describe(t){const e={name:"Focus"},r=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/swing/i],describe(t){const e={name:"Swing"},r=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(t){const e={name:"Opera Touch"},r=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/yabrowser/i],describe(t){const e={name:"Yandex Browser"},r=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/Maxthon|mxios/i],describe(t){const e={name:"Maxthon"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/epiphany/i],describe(t){const e={name:"Epiphany"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/puffin/i],describe(t){const e={name:"Puffin"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/sleipnir/i],describe(t){const e={name:"Sleipnir"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/k-meleon/i],describe(t){const e={name:"K-Meleon"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/micromessenger/i],describe(t){const e={name:"WeChat"},r=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/qqbrowser/i],describe(t){const e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},r=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/msie|trident/i],describe(t){const e={name:"Internet Explorer"},r=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/\sedg\//i],describe(t){const e={name:"Microsoft Edge"},r=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/edg([ea]|ios)/i],describe(t){const e={name:"Microsoft Edge"},r=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/vivaldi/i],describe(t){const e={name:"Vivaldi"},r=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/seamonkey/i],describe(t){const e={name:"SeaMonkey"},r=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/sailfish/i],describe(t){const e={name:"Sailfish"},r=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return r&&(e.version=r),e}},{test:[/silk/i],describe(t){const e={name:"Amazon Silk"},r=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/phantom/i],describe(t){const e={name:"PhantomJS"},r=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/slimerjs/i],describe(t){const e={name:"SlimerJS"},r=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e={name:"BlackBerry"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/(web|hpw)[o0]s/i],describe(t){const e={name:"WebOS Browser"},r=Utils.getFirstMatch(ls,t)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/bada/i],describe(t){const e={name:"Bada"},r=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/tizen/i],describe(t){const e={name:"Tizen"},r=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/qupzilla/i],describe(t){const e={name:"QupZilla"},r=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/firefox|iceweasel|fxios/i],describe(t){const e={name:"Firefox"},r=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/electron/i],describe(t){const e={name:"Electron"},r=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/MiuiBrowser/i],describe(t){const e={name:"Miui"},r=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/chromium/i],describe(t){const e={name:"Chromium"},r=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/chrome|crios|crmo/i],describe(t){const e={name:"Chrome"},r=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/GSA/i],describe(t){const e={name:"Google Search"},r=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test(t){const e=!t.test(/like android/i),r=t.test(/android/i);return e&&r},describe(t){const e={name:"Android Browser"},r=Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},r=Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},r=Utils.getFirstMatch(ls,t);return r&&(e.version=r),e}},{test:[/.*/i],describe(t){const e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(e,t),version:Utils.getSecondMatch(e,t)}}}];var ds=[{test:[/Roku\/DVP/],describe(t){const e=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:as.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:as.WindowsPhone,version:e}}},{test:[/windows /i],describe(t){const e=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),r=Utils.getWindowsVersionName(e);return{name:as.Windows,version:e,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:as.iOS},r=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return r&&(e.version=r),e}},{test:[/macintosh/i],describe(t){const e=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),r=Utils.getMacOSVersionName(e),i={name:as.MacOS,version:e};return r&&(i.versionName=r),i}},{test:[/(ipod|iphone|ipad)/i],describe(t){const e=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:as.iOS,version:e}}},{test(t){const e=!t.test(/like android/i),r=t.test(/android/i);return e&&r},describe(t){const e=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),r=Utils.getAndroidVersionName(e),i={name:as.Android,version:e};return r&&(i.versionName=r),i}},{test:[/(web|hpw)[o0]s/i],describe(t){const e=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),r={name:as.WebOS};return e&&e.length&&(r.version=e),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||Utils.getFirstMatch(/\bbb(\d+)/i,t);return{name:as.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:as.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:as.Tizen,version:e}}},{test:[/linux/i],describe:()=>({name:as.Linux})},{test:[/CrOS/],describe:()=>({name:as.ChromeOS})},{test:[/PlayStation 4/],describe(t){const e=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:as.PlayStation4,version:e}}}],cs=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(t){const e=Utils.getFirstMatch(/(can-l01)/i,t)&&"Nova",r={type:ss.mobile,vendor:"Huawei"};return e&&(r.model=e),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:ss.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:ss.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:ss.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:ss.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:ss.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:ss.tablet})},{test(t){const e=t.test(/ipod|iphone/i),r=t.test(/like (ipod|iphone)/i);return e&&!r},describe(t){const e=Utils.getFirstMatch(/(ipod|iphone)/i,t);return{type:ss.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:ss.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:ss.mobile})},{test:t=>"blackberry"===t.getBrowserName(!0),describe:()=>({type:ss.mobile,vendor:"BlackBerry"})},{test:t=>"bada"===t.getBrowserName(!0),describe:()=>({type:ss.mobile})},{test:t=>"windows phone"===t.getBrowserName(),describe:()=>({type:ss.mobile,vendor:"Microsoft"})},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:()=>({type:ss.tablet})},{test:t=>"android"===t.getOSName(!0),describe:()=>({type:ss.mobile})},{test:t=>"macos"===t.getOSName(!0),describe:()=>({type:ss.desktop,vendor:"Apple"})},{test:t=>"windows"===t.getOSName(!0),describe:()=>({type:ss.desktop})},{test:t=>"linux"===t.getOSName(!0),describe:()=>({type:ss.desktop})},{test:t=>"playstation 4"===t.getOSName(!0),describe:()=>({type:ss.tv})},{test:t=>"roku"===t.getOSName(!0),describe:()=>({type:ss.tv})}],hs=[{test:t=>"microsoft edge"===t.getBrowserName(!0),describe(t){if(/\sedg\//i.test(t))return{name:os.Blink};const e=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:os.EdgeHTML,version:e}}},{test:[/trident/i],describe(t){const e={name:os.Trident},r=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:t=>t.test(/presto/i),describe(t){const e={name:os.Presto},r=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test(t){const e=t.test(/gecko/i),r=t.test(/like gecko/i);return e&&!r},describe(t){const e={name:os.Gecko},r=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:os.Blink})},{test:[/(apple)?webkit/i],describe(t){const e={name:os.WebKit},r=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}}];class Parser{constructor(t,e=!1){if(null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}getUA(){return this._ua}test(t){return t.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const t=Utils.find(us,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const t=Utils.find(ds,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os}getOSName(t){const{name:e}=this.getOS();return t?String(e).toLowerCase()||"":e||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(t=!1){const{type:e}=this.getPlatform();return t?String(e).toLowerCase()||"":e||""}parsePlatform(){this.parsedResult.platform={};const t=Utils.find(cs,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const t=Utils.find(hs,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(t){const e={};let r=0;const i={};let n=0;if(Object.keys(t).forEach(s=>{const a=t[s];"string"==typeof a?(i[s]=a,n+=1):"object"==typeof a&&(e[s]=a,r+=1)}),r>0){const t=Object.keys(e),r=Utils.find(t,t=>this.isOS(t));if(r){const t=this.satisfies(e[r]);if(void 0!==t)return t}const i=Utils.find(t,t=>this.isPlatform(t));if(i){const t=this.satisfies(e[i]);if(void 0!==t)return t}}if(n>0){const t=Object.keys(i),e=Utils.find(t,t=>this.isBrowser(t,!0));if(void 0!==e)return this.compareVersion(i[e])}}isBrowser(t,e=!1){const r=this.getBrowserName().toLowerCase();let i=t.toLowerCase();const n=Utils.getBrowserTypeByAlias(i);return e&&n&&(i=n.toLowerCase()),i===r}compareVersion(t){let e=[0],r=t,i=!1;const n=this.getBrowserVersion();if("string"==typeof n)return">"===t[0]||"<"===t[0]?(r=t.substr(1),"="===t[1]?(i=!0,r=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?r=t.substr(1):"~"===t[0]&&(i=!0,r=t.substr(1)),e.indexOf(Utils.compareVersions(n,r,i))>-1}isOS(t){return this.getOSName(!0)===String(t).toLowerCase()}isPlatform(t){return this.getPlatformType(!0)===String(t).toLowerCase()}isEngine(t){return this.getEngineName(!0)===String(t).toLowerCase()}is(t,e=!1){return this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)}some(t=[]){return t.some(t=>this.is(t))}}
372
+ /*!
373
+ * Bowser - a browser detector
374
+ * https://github.com/lancedikson/bowser
375
+ * MIT License | (c) Dustin Diaz 2012-2015
376
+ * MIT License | (c) Denis Demchenko 2015-2019
377
+ */const fs=class Bowser{static getParser(t,e=!1){if("string"!=typeof t)throw new Error("UserAgent should be a string");return new Parser(t,e)}static parse(t){return new Parser(t).getResult()}static get BROWSER_MAP(){return ns}static get ENGINE_MAP(){return os}static get OS_MAP(){return as}static get PLATFORMS_MAP(){return ss}}.parse(window.navigator.userAgent),{platform:ps,os:gs,browser:ms}=fs,vs=t=>t&&t.toLowerCase();var ys={rnd:Math.random().toString(36).substr(2,32),os:vs(gs.name+(gs.versionName?" "+gs.versionName:"")),device:vs(ps.type),browser:vs(ms.name),browser_version:(ms&&ms.version?ms.version:"unknown").split(".").shift(),plugin_version:"3.1.0-rc.2"};const Es="https://fp-eu-w1-aai.flowplayer.com/in",Ts="POST",_s=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],bs=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Ss=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],As=Er("ads/analytics"),Ls=RequestQueue.of(),ws=(...t)=>Object.assign({},...t);class Analytics{constructor(t,e={}){this.emitter=t,this.metadata=ws(ys,e.metadata||{}),this.emitter=t,this.events=e.events||[],this.required_keys=e.required_keys||[],this.optional_keys=e.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),As(this),this.wireup()}static of(t,e){return new Analytics(t,e)}static ensure_required_keys(t,e){return t.required_keys.filter(t=>!(t in e))}static pluck_valid_keys(t,e){return((t,...e)=>Object.keys(t).filter(t=>~e.indexOf(t)).reduce((e,r)=>Object.assign(e,{[r]:t[r]}),{}))(e,...t.valid_keys)}static mergeMetadata(t,e={}){return t.metadata=Analytics.pluck_valid_keys(t,ws(t.metadata,e,{player_version:"3.1.0-rc.2"})),t}wireup(){this.events.forEach(t=>{this.emitter.on(t,e=>{const r=e.detail,i=ws(this.metadata,{event_type:t},r),n=Analytics.pluck_valid_keys(this,i),s=Analytics.ensure_required_keys(this,n);if(As(`Event[${t}]`,{payload:n,observation:r}),s.length)return As(`Analytics.validate_metadata() failed for\n Event[${t}]\n missing keys: ${s}`,n);RequestQueue.rpush(Ls,[Es,Ts,n])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const ks=Er("ads/controller"),Rs={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends class EventBus{constructor(t=document.createElement("div"),e=[]){this._bus=t,this._listeners=e}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(t,e){const r=new CustomEvent(t,{detail:e||{}});this._bus.dispatchEvent(r)}on(t,e){this._listeners.push([t,e]),this._bus.addEventListener(t,e,{passive:!0})}once(t,e){this._bus.addEventListener(t,e,{once:!0})}removeListener(t,e){this._bus.removeEventListener(t,e)}}{constructor(t={}){var e;super(),this.adapter=function(t,e){return t.adapter?new t.adapter(e):new IMA(e)}(t,this),this.opts=Object.assign(Object.assign({},Rs),t),this.analytics=(e=this,Analytics.of(e,{required_keys:bs,optional_keys:Ss,events:_s})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(t.parameters||{}),this.wireup()}reset(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}destroy(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy();this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}stop(){this.adapter&&this.adapter.stop()}wireup(){const t=()=>{var t;const e=new CustomEvent("ad/playing");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(es.PLAYING,!0)};this.on("ad-play-requested",t),this.on("ad-started",t),this.on("ad-resumed",t);const e=()=>{var t;const e=new CustomEvent("ad/paused");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(es.PLAYING,!1)};this.on("ad-break-completed",e),this.on("ad-teardown",e),this.on("ad-playback-error",e),this.on("ad-request-error",e),this.on("ad-paused",e),this.on("ad-skipped",e),this.on("ad-completed",e),this.on("ad-break-completed",()=>{var t;const e=new CustomEvent("ad/complete");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(es.BREAK_ACTIVE,!1)}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),e(),this._state.toggleState(es.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async t=>{if(ks("Ads.on(RELOAD_AD_REQUESTED)",t),this._schedule){if(e(),t)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(es.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(es.AD_AVAILABLE,!1))}})}async initialize(t,e={},r){return ks("Ads.initialize():",t,e,r),this._state.toggleState(es.INITIALIZING,!0),Object.assign(this.opts,e),Array.isArray(t)&&this.setSchedule(t),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},e.parameters||{},{autoplay:e.autoplay,muted:e.muted})),this.adapter.isReady()&&await this.adapterInitialized(r),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(t){ks("Ads.setVideoTag():",t),await this.adapter.setVideoTag(t),this.trigger("ad-videotag-attached",t),this.adapter.isReady()&&await this.adapterInitialized(),t.on("request/ad/pause",()=>this.adapter.pause()),t.on("request/ad/play",()=>this.adapter.resume()),t.on("request/ad/muteunmute",()=>{var e;t.muted=(null!==(e=this.adapter.volume())&&void 0!==e?e:0)>0,this.adapter.volume(t.muted?0:0==t.volume?.1:t.volume)})}waitForVideoTag(){return new Promise(t=>{const e=this.adapter.getVideoTag();if(e)return t(e);this.on("ad-videotag-attached",e=>{this.once("ad-initialized",()=>t(e))})})}async adapterInitialized(t){ks("Ads.adapterInitialized()"),this._state.toggleState(es.INITIALIZING,!1),this._state.toggleState(es.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,t),this.checkIfBreakComplete(),t&&!this.opts.autoplay||this.trigger("ad-teardown")}async fetchNextAd(t,e=0){var r,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(e>50)throw this._state.toggleState(es.FATAL_ERROR,!0),this._state.toggleState(es.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");const n=(null===(r=this._schedule)||void 0===r?void 0:r.getNextAd())||(null===(i=this._schedule)||void 0===i?void 0:i.getPostroll());if(!n||this.adapter.canDismissNonLinear()||-1===t)if(this._schedule.waitForLoad(t,n,this.opts.preload_ads))this._state.toggleState(es.FETCHING_AD,!1);else if(n===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),n){ks("Ads.fetchNextAd",n),this._state.toggleState(es.FETCHING_AD,!0);try{return await this.requestAd(n),this._state.toggleState(es.AD_AVAILABLE,!0),void this._state.toggleState(es.FETCHING_AD,!1)}catch(r){if(ks("Ads.fetchNextAd(err: %o, ad: %o)",r,n),this.setLastAd(n),n!==this._schedule.getPostroll())return await this.fetchNextAd(t,++e)}}else this._state.toggleState(es.FETCHING_AD,!1)}skipAdsOnSeek(t){if(!this._schedule)return;let e=this._schedule.getNextAd();for(;e&&e.time<t;)this._schedule.increment(),e=this._schedule.getNextAd()}async setCurrentTime(t,e=!1,r=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(es.FETCHING_AD))return;if(this._state.hasAny(es.PLAYING)&&this.adapter.isLinearAd())return;const i=0===t&&0===this._schedule.getNextIndex();try{if(r&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(t),this._state.hasAny(es.AD_AVAILABLE)||await this.fetchNextAd(t),!this._state.hasAny(es.AD_AVAILABLE)||!this.shallPlayAd(t)||e)return;await this.playAd(),await this.setCurrentTime(t),this.checkIfBreakComplete()}catch(t){ks("setCurrentTime: Error(from: setCurrentTime, message: %s)",t.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var t;if(this._state.hasAny(es.AD_AVAILABLE)){this._state.toggleState(es.AD_AVAILABLE,!1),this._state.toggleState(es.BREAK_ACTIVE,!0);try{const e=null===(t=this._schedule)||void 0===t?void 0:t.getCurrentAd();await this.adapter.playAd(),e&&this.setLastAd(e)}catch(t){console.error("Ads.playAd: error",t)}}}checkIfBreakComplete(){if(!this._state.hasAny(es.BREAK_ACTIVE))return ks("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());ks("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(es.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger("ad-break-completed")}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(t,e){if(e&&!isNaN(e)&&this._schedule&&this._schedule.updateContentDuration(e),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(t);this._schedule=new Schedule(t,{preload_advance:this.opts.preload_advance,content_duration:e?0:e})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(t,e={}){var r;if(!this.adapter.getVideoTag())return;if(!this._state)return;if("ad-break-completed"===t&&this._state.hasAny(es.BREAK_ACTIVE)&&!this.adapter.isAdPod())return ks("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=e)||"object"!=typeof i||Zn(i)!==Jn)return this.dispatch(t,e);var i;const n=Object.assign({},this.adapter.getOpts()||{},(null===(r=this._schedule)||void 0===r?void 0:r.getCurrentAd())||{},{ad_type:this.ad_type},e);return e.ima_event&&"preroll"===e.ad_type&&(n.ad_type=this.ad_type),this.dispatch(t,n)}dispatch(t,e){const r=this.adapter.getVideoTag();if(r){ks(":dispatch",t,e);try{const i={event:"ads/"+t,detail:{outstream:e.outstream,ad_type:e.ad_type,ad_break_time:e.time,ad_remaining_seconds:e.remaining,ad_muted:e.muted,ad_duration_seconds:e.duration,ad_error_reason:e.reason,ad_vast_error:e.vast_error,ad_vast_error_type:e.vast_error_type,ad_request_load_type:e.request_load_time}};r.dispatchEvent(new CustomEvent(mr,{detail:i}))}catch(t){ks(":error",t)}Wt(r,t,e),this.emit(t,e)}}get ad_type(){return this._schedule&&this._schedule.getCurrentType()}shouldRestartContent(){if(this.adapter.isAdPod())return!0;const t=this.getLastAd();return!!t&&(!t.outstream&&!1!==t.restart)}async finished(t){if(this._schedule&&(ks("Ads.finished"),!(this.adapter.isSharedVideoTag()&&this._state.hasAny(es.PLAYING)&&this.adapter.isLinearAd()))){ks("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return ks("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(es.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(t){ks("Ads.finished: postroll failed:",t)}finally{this.trigger("ad-postroll-finished"),this.checkIfBreakComplete(),"function"==typeof t&&t()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(t){var e;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(es.FATAL_ERROR))&&!!(null===(e=this._schedule)||void 0===e?void 0:e.shallPlayAd(t)))}setLastAd(t){return this._lastAd=t,this}getLastAd(){return this._lastAd}mergeMacros(t={}){return this._macros=this._macros.fork(Object.assign({},t)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(t){this.adapter&&this.adapter.onResize(t)}async requestAd(t,e=0,r=this.opts.timeout){if(!this._state)return;ks("Ads.requestAd(ad: %o)",{ad:t,timeout:r,idx:e});const i=await async function t(e){if("function"==typeof e)return[await $n(e)];if("string"==typeof e)return[await $n(e)];if(Array.isArray(e)){const t=e;return await Promise.all(t.map($n))}if("object"==typeof e&&e&&e.adTag)return await t(e.adTag);throw new Error(`\n unhandled ads type ${typeof e}:\n ${JSON.stringify(e)}\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n `)}(t);if(void 0===i[e])return Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[e])return await this.requestAd(i,e+1,r);this.trigger("ad-requested",t);const n=this._macros.compile(i[e],Qn(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(n,r)}catch(t){return ks(`Ads.requestAd(:fallback, idx: ${e}, length: ${i.length}, adTag: ${i[e]})\nError `,{adTag:i,err:t}),this.requestAd(i,e+1,r)}}resetSchedule(t){this._schedule&&this._schedule.reset(t)}get adPlaying(){return this._state&&this._state.hasAny(es.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(es.BREAK_ACTIVE)}}var Ds=new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),Os=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});function Is(t){return Object.assign({muted:!1,timeout:250,inline:!1},t)}function Cs(t,e){var r=t.muted,i=t.timeout,n=t.inline,s=e(),a=s.element,o=s.source,l=void 0,u=void 0,d=void 0;return a.muted=r,!0===r&&a.setAttribute("muted","muted"),!0===n&&a.setAttribute("playsinline","playsinline"),a.src=o,new Promise((function(t){l=a.play(),u=setTimeout((function(){d(!1,new Error("Timeout "+i+" ms has been reached"))}),i),d=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;a.remove(),a.srcObject=null,clearTimeout(u),t({result:e,error:r})},void 0!==l?l.then((function(){return d(!0)})).catch((function(t){return d(!1,t)})):d(!0)}))}var Ps={audio:function(t){return Cs(t=Is(t),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Ds)}}))},video:function(t){return Cs(t=Is(t),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(Os)}}))}};let xs=void 0;async function Ms(t=!0){return xs||(xs=await Ps.video({timeout:500,muted:t}),xs)}const Fs=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"}),Ns=["progress","duration"];class AdUI extends HTMLElement{constructor(t,e=document.createElement("div")){super(),this.player=t,this.adContainer=e,this.render(),t.addEventListener("ad/playing",t=>this.updateState(t.type)),t.addEventListener("ad/paused",t=>this.updateState(t.type)),t.addEventListener("ad/complete",t=>this.updateState(t.type))}static get observedAttributes(){return Ns}updateState(t){this.classList.toggle("ad-paused","ad/paused"==t),this.classList.toggle("ad-playing","ad/playing"==t)}hideFirstFrame(t){t.classList.toggle("ad-hide-first-frame",!0)}showFirstFrame(t){t.classList.toggle("ad-hide-first-frame",!1)}resize(t){const e=this.style;t.linear?t.width&&(e.width=t.width+"px"):t.width?this.adContainer.style.width=t.width+"px":e.removeProperty("width"),t.height?e.height=t.height+"px":e.removeProperty("height")}attributeChangedCallback(t,e,r){switch(t){case"duration":return this.onDurationChange(parseFloat(r));case"progress":return this.onProgress(parseFloat(e),parseFloat(r))}}onDurationChange(t){}onProgress(t,e){}render(){this.adContainer.classList.add("fp-ad-container"),this.append(this.adContainer);const t=pt(this.player,"flowplayer-ad-controls"),e=pt(this.player,"flowplayer-ad-countdown");this.append(t,e)}}const Us=Er("fpads:native:outstream"),Bs={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Gs,js;!function(t){t.OUTSTREAM_VISIBLE="ads-outstream-visible",t.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",t.OUTSTREAM_TEARDOWN="ads-outstream-teardown",t.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Gs||(Gs={})),function(t){t[t.None=0]="None",t[t.Booting=1]="Booting",t[t.Ready=2]="Ready",t[t.Disposed=3]="Disposed"}(js||(js={}));class Outstream{constructor({ads:t,root:e,content:r,ima:i}){this.state=js.None,Us("creating Outstream instance"),this.content=r,this.ads=t,this.root=e,this.ima=i,this.aspectRatio=r.videoHeight/r.videoWidth,this.dimensions=function(t){if(t.clientWidth>0||t.clientHeight)return nn(t);const e={height:t.style.height};sn(t,"opacity",0),sn(t,"display","absolute"),sn(t,"display","inline-block"),sn(t,"height","auto");const r=nn(t);return sn(t,"height",e.height),sn(t,"opacity",1),r}(this.root),this.adUi=new AdUI(r),this.adContainer=this.adUi.adContainer,this.initialVolumeState={},e.classList.add(Bs.OUTSTREAM),e.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",t=>{var e;if(this.state==js.Disposed)return;const r=!!(null===(e=t.detail)||void 0===e?void 0:e.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:r}))}),r.on("resize",t=>{if(this.state==js.Disposed)return;const e=t.detail;e&&(this.dimensions={width:e.contentRect.width,height:e.contentRect.height},this.ads.resize(this.dimensions))}),r.on("intersectionchange",t=>{if(this.state==js.Disposed)return;const e=t.detail;if(e)switch(this.state){case js.Booting:return Us(":boot skipping intersectionchange");case js.None:return this.state=js.Booting,this.begin_life_cycle();case js.Ready:if(e.ratio>=.5&&this.ads.adPlaying)return;e.ratio>=.5&&this.ads.resume(),e.ratio<.5&&this.ads.pause()}}),this.setup()}hide(){return this}restore_aspect_ratio(){return Us(`Outstream.restore_aspect_ratio(${this.aspectRatio})`),this.content.setOpts({ratio:this.aspectRatio}),this}show(){this.root.classList.remove(Outstream.CLASS.HIDDEN),this.root.classList.add(Outstream.CLASS.SHOWING),this.adUi.classList.add("linear","on")}async begin_life_cycle(){this.state=js.Ready;const{error:t,result:e}=await Ms(!1),{result:r}=await Ms(!0);this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!e&&!r),muted:!e},Us("Outstream.show() :autoplay >> sound="+e),t&&this.content&&!e&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await dn({ads:this.ads,content:this.content,adContainer:this.adContainer,ima:this.ima,state:{listening:!1},config:this.content.opts}),pn({content:this.content,ads:this.ads}),this.state=js.Ready}attach_ad_listeners(){const t=this.ads;t.once("ad-pause-content",()=>{this.show(),this.ads.adPlaying&&this.ads.pause()}),this.ima.always_show_controls||t.on("vpaid-init",()=>this.adUi.classList.add("is-vpaid"));const e=()=>{ln.forEach(t=>this.ads.removeListener(t,e));const t=new CustomEvent(Gs.OUTSTREAM_TEARDOWN);Us("Outstream(:teardown)",t),this.content.dispatchEvent(t)};ln.forEach(t=>this.ads.once(t,e)),this.content.once(Gs.OUTSTREAM_TEARDOWN,t=>{setTimeout(()=>{if(t.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),hn({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adContainer,ima:this.ima,content:this.content,root:this.content.root,state:{started:!0,listening:!1},initial:{muted:!0,volume:1}})}empty_src(){this.content.setSrc({type:"video/mp4",src:URL.createObjectURL(Fs)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.empty_src()}reset_ui(){const t=this.root;t.classList.remove(Outstream.CLASS.SHOWING),t.classList.remove(Outstream.CLASS.OUTSTREAM),this.adUi.classList.remove("on")}dispose(){if(this.state==js.Disposed)return;const t=this.root,e=this.content;this.reset_ui(),t.classList.add(Outstream.CLASS.OUTSTREAM),t.classList.add(Outstream.CLASS.DONE);this.video=this.container=this.ads=0,this.state=js.Disposed,e.destroy(),t.innerHTML=""}}function Hs(t){return t&&"number"==typeof t.time}function Ks(t){return t&&"number"==typeof t.percent&&"number"!=typeof t.time}function Vs(t,e,r){if(!("google"in window))return console.warn("google.ima unavailable");const i=t.autoplay;r.autoplay=!1,t.autoplay=0;const n=r.ads=new AdsController,s=n.analytics;let a=!1;n.resize(nn(e)),an&&(r.on([d,c,"webkitendfullscreen"],t=>{var e;const i=t.type===d;null===(e=null==r?void 0:r.ads)||void 0===e||e.adapter.setIOSPlaysInline(!i)}),n.on("ad-postroll-finished",()=>{n.adapter.isSharedVideoTag()&&n.once("ad-break-completed",()=>{r.src=r.original_src,r.once(E,()=>{r.pause()}),r.webkitExitFullscreen()})})),r.on(A,(function(){n&&n.destroy()})),r.on(S,()=>{n&&n.stop()}),r.on(L,(function({detail:o}){const l=o.ima;if(!l)return;if(!Array.isArray(l.ads))return void(void 0!==i?t.autoplay=i:delete t.autoplay);const u=o.duration||r.duration;if(l.ads=function(t,e){return Array.isArray(t)?t.filter(t=>Hs(t)||Ks(t)).reduce((t,r)=>{if(Hs(r))return t.push(r),t;if(r.lazy)return t.push(r),t;if(Ks(r)){const i=Object.assign({},r);return i.time=Math.floor(r.percentage*e),t.push(i),t}return t},[]):(console.warn("AdSchedule was not an Array"),[])}(l.ads,u),n.setSchedule(l.ads,u),o.metadata&&Analytics.mergeMetadata(s,o.metadata),o.metadata&&n.mergeMacros(o.metadata),o.metadata&&l.parameters&&(l.parameters=Object.assign(Object.assign({},l.parameters),o.metadata)),Analytics.mergeMetadata(s,{muted:o.muted||!1,autoplay:o.autoplay||!1}),!a){if(a=!0,t.lang&&!l.Locale&&(l.Locale=t.lang),Schedule.isOutstream(l.ads))return new Outstream({root:e,content:r,ads:n,ima:l});un({config:Object.assign(Object.assign({},t),{autoplay:i}),root:e,content:r,ads:n,ima:l})}}))}Outstream.CLASS=Bs;class AdControls extends HTMLElement{constructor(t){super(),this.player=t,this.render(),t.on("ad-started",t=>{if(!this.indicatorControl)return;const{position:e,totals:r}=t.detail.ad;this.indicatorControl.textContent=`ADS ${e} / ${r}`})}render(){this.classList.add("fp-ad-controls"),this.indicatorControl=document.createElement("div"),this.indicatorControl.classList.add("ad-indicator","fp-color-text"),this.indicatorControl.textContent="ADS";const t=document.createElement("div");t.classList.add("ad-playback-controls");const e=pt(this.player,j);e.addEventListener("click",()=>this.player.emit("request/ad/play"));const r=pt(this.player,H);r.addEventListener("click",()=>this.player.emit("request/ad/pause")),t.append(e,r);const i=pt(this.player,W);i.addEventListener("click",()=>this.player.emit("request/ad/muteunmute"));const n=pt(this.player,F);this.append(this.indicatorControl,t,i,n)}}class AdCountdown extends HTMLElement{constructor(t){super(),this.player=t,t.on("ad-progress",t=>{const{duration:e,remaining:r}=t.detail;this.setAttribute("duration",e+""),this.setAttribute("remaining",r+"")}),this.addEventListener("animationend",()=>{const t=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",t)})}static get observedAttributes(){return["remaining"]}attributeChangedCallback(t,e){switch(t){case"remaining":return this.onRemaining(e)}}onRemaining(t){const e=parseFloat(this.getAttribute("duration")||"0");t||(t=e+"");const r=parseFloat(t),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const n=((e-r)/e*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",n),this.classList.add("go")})}}const{samsung_tv:qs}=r();class Ads{constructor(t){this.umd=t,gt(t,"flowplayer-ad-ui",AdUI),gt(t,"flowplayer-ad-controls",AdControls),gt(t,"flowplayer-ad-countdown",AdCountdown)}init(t,e,r){if(ue.from_token(t.token||"").is_granted(ue.permissions.ADS)&&!qs)return Vs(t,e,r)}}return ee(window,Ads),di.extensions.push(HLS,OVP,Ads),Object.assign(di,{hls:HLS,ads:Ads,ovp:OVP}),di}));