@flowplayer/player 3.4.1 → 3.4.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/core.js +1 -1
- package/default.js +1 -1
- package/embed.js +27 -27
- package/package.json +1 -1
- package/plugins/ads.js +2 -2
- package/plugins/airplay.js +1 -1
- package/plugins/analytics.js +1 -1
- package/plugins/asel.js +1 -1
- package/plugins/float-on-scroll.js +1 -1
- package/plugins/health.js +1 -1
- package/plugins/hls.js +1 -1
- package/plugins/ovp.js +1 -1
- package/plugins/playlist.js +1 -1
- package/plugins/qsel.js +1 -1
- package/plugins/share.js +1 -1
- package/plugins/speed.js +1 -1
- package/plugins/subtitles.js +1 -1
package/embed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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="mousemove",d="touchmove",c="touchend",h="fullscreenenter",f="fullscreenexit",p="loadedmetadata",g="loadeddata",v="progress",m="loadstart",y="pause",E="playing",T="waiting",b="canplay",_="ended",S="seeked",A="seeking",L="reap",w="config",D="landscape",R="portrait";var k=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:u,TOUCH_START:"touchstart",TOUCH_MOVE:d,TOUCH_END:c,TOUCH_CANCEL:"touchcancel",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_ENTER:h,FULLSCREEN_EXIT:f,FULLSCREEN_CHANGE:"fullscreenchange",WEBKIT_NEEDKEY:"webkitneedkey",METADATA:p,DATA:g,PROGRESS:v,TIME_UPDATE:"timeupdate",LOAD_START:m,VOLUME_CHANGE:"volumechange",PAUSE:y,PLAYING:E,PLAY:"play",WAITING:T,CAN_PLAY:b,ENDED:_,SEEKED:S,SEEKING:A,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:L,CONFIG:w,QUALITIES:"qualities",SET_QUALITY:"quality:set",NON_RECOVERABLE_ERROR:"error:fatal",RECOMMENDATIONS_READY:"recommendationsready",AUDIO_ONLY_SOURCE:"audioonlysource",LANDSCAPE:D,PORTRAIT:R,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 O="flowplayer-ui",I="flowplayer-control",C="flowplayer-live-status",P="flowplayer-elapsed-time",x="flowplayer-timeline-bar",M="flowplayer-volume-bar",F="flowplayer-header",N="flowplayer-header-right-zone",U="flowplayer-primary",B="flowplayer-middle",j="flowplayer-middle-zone",G="flowplayer-wait",H="flowplayer-small-play-icon",V="flowplayer-small-pause-icon",K="flowplayer-play-icon",q="flowplayer-pause-icon",W="flowplayer-rewind-icon",z="flowplayer-volume-icon",Y="flowplayer-live-countdown";var X=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:O,CONTROL:I,CONTROL_BUTTONS:"flowplayer-control-buttons",LIVE_STATUS:C,ELAPSED:P,TIMELINE:x,CONTROL_DURATION:"flowplayer-control-duration",VOLUME_CONTROL:"flowplayer-volume-control",VOLUME_BAR:M,HEADER:F,HEADER_LEFT_ZONE:"flowplayer-header-left-zone",HEADER_RIGHT_ZONE:N,PRIMARY:U,HEADER_DURATION:"flowplayer-header-duration",MIDDLE:B,MIDDLE_ZONE:j,WAIT:G,MIDDLE_BUTTONS:"flowplayer-middle-buttons",MIDDLE_LEFT_ZONE:"flowplayer-middle-left-zone",MIDDLE_RIGHT_ZONE:"flowplayer-middle-right-zone",ENDSCREEN_INTERSTITIAL:"flowplayer-endscreen-interstitial",ENDSCREEN_UP_NEXT:"flowplayer-endscreen-up-next",ENDSCREEN_GRID:"flowplayer-endscreen-grid",PLAYLIST_INTERSTITIAL:"flowplayer-playlist-interstitial",AIRPLAY_ICON:"flowplayer-airplay-icon",CHROMECAST_ICON:"flowplayer-chromecast-icon",SMALL_PLAY_ICON:H,SMALL_PAUSE_ICON:V,PLAY_ICON:K,PAUSE_ICON:q,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:W,SHARE_ICON:"flowplayer-share-icon",VOLUME_ICON:z,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:Y,PLAYLIST_CONTROLS:"flowplayer-playlist-controls",THUMBNAILS_CAROUSEL:"flowplayer-thumbnails-carousel",ERROR_COMPONENT:"flowplayer-error"});const Q="is-playing",$="is-paused",Z="is-loaded",J="is-loading",tt="is-starting",et="is-seeking",rt="is-ended",it="is-waiting",nt="is-live-seeked",st="no-timeline",at="is-touched",ot="is-in-viewport";var lt=Object.freeze({__proto__:null,PLAYING:Q,FULLSCREEN:"is-fullscreen",PAUSED:$,MUTED:"is-muted",LOADED:Z,LOADING:J,STARTING:tt,SEEKING:et,GRABBING:"is-grabbing",DISABLED:"is-disabled",SMALL:"is-small",TINY:"is-tiny",RTL:"is-rtl",ENDED:rt,LIVE:"is-live",ERRORED:"is-error",WAITING:it,AUTOPLAY:"is-autoplay",NO_AUTOPLAY:"no-autoplay",SEAMLESS:"is-seamless",TOGGLING:"is-toggling",LIVE_SEEKED:nt,NO_DVR:st,HAS_POSTER:"has-poster",MENU_OPENED:"has-menu-opened",TOUCHED:at,HOVERED:"is-hovered",TOUCH_DEVICE:"is-touch-device",WILL_SEEK:"will-seek",SEEKABLE:"is-seekable",IN_VIEWPORT:ot});function ut(t){this.message=t}ut.prototype=new Error,ut.prototype.name="InvalidCharacterError";var dt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ut("'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 ct=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(dt(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 dt(e)}};function ht(t){this.message=t}ht.prototype=new Error,ht.prototype.name="InvalidTokenError";var ft=function(t,e){if("string"!=typeof t)throw new ht("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ct(t.split(".")[r]))}catch(t){throw new ht("Invalid token specified: "+t.message)}};ft.InvalidTokenError=ht;const pt=new Map,gt=(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),vt=(t,e,r)=>{window.customElements.get(e)||window.customElements.define(e,r),t.customElements.get(e)||t.customElements.set(e,e)};var mt,yt;!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"}(yt||(yt={}));function Et(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 Promise.resolve();if(!r)return Promise.resolve(t.pause());if(0==t.reaper)return Promise.resolve();const n=t.reaper.get("__pending_play");return 0!=t.paused||n?n?(n.src!==bt(t.original_src)&&Tt(t),n):(function(t){return(0==t.networkState||0==t.readyState)&&t.currentSrc==bt(t.original_src)}(t)&&Tt(t),(t=>t.autoplay&&yt.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(tt,!1),t.play().catch(e=>(console.warn("[flowplayer/play] attempting muted autoplay\n%s",e.message),t.muted=!0,t.volume=0,t.play())))):Promise.resolve()}function Tt(t){t.currentSrc.match(/^blob:/)||t.load()}function bt(t){const e=document.createElement("a");return e.href=t,e.href}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 St(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 At(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const Lt=t=>{var{src:e}=t,r=_t(t,["src"]);return[Object.assign({src:e,type:e?At("video/"+St(e)):""},r)]};function wt(t){return Lt({src:t})}function Dt(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)]:Lt(Object.assign({src:e},i))}var Rt;function kt(t,e,r,i={safari:!1}){const n=function(t){return"string"==typeof t?wt(t):Array.isArray(t)||"object"!=typeof t?t.reduce((function(t,e){return"string"==typeof e&&(e=wt(e)),"object"!=typeof e||Array.isArray(e)||(e=Dt(e)),t.concat(e)}),[]):Dt(t)}(r);return t.currentSrc&&(t.innerHTML="",t.setOpts({live:!1}),t.live_state.dvr=void 0,t.live_state.dvr_window=void 0,delete t.opts.live,delete t.opts.duration),[et,Q,$,J,Z,nt].forEach(e=>t.setState(e,!1)),e.autoplay||t.setState(tt,!0),Array(...Array(n.length)).map((t,e)=>e).some(r=>{const s=n[r];if(Rt.Ok==function(t,e,r){t.emit("src",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 t.setOpts({is_native:!i}),i?(i.onload(e,t.root,t,r),Rt.Ok):Rt.Err}(t,e,s)||Rt.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 Rt.Err;if(r.drm&&(!r.drm["com.apple.fps.1_0"]||!i.safari))return Rt.Err;"string"==typeof r.src&&(t.preload=e.autoplay?"auto":null!==(n=e.preload)&&void 0!==n?n:"auto",t.src=r.src,e.autoplay&&i.safari&&t.load(),"none"!==t.preload&&t.setState(J,!0));return Rt.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"}(Rt||(Rt={}));const Ot=[L,A,"src","seek:cancel"];var It;function Ct(t,e,r){return isNaN(t.duration)||isNaN(t.currentTime)?{}:(e.offset+=r,0==e.offset?Pt(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,Pt(t,e))}),1e3),function(t,e){t.setState("will-seek",!0),t.setState(It.BACKWARD,e.offset<0),t.setState(It.FORWARD,e.offset>0)}(t,e),t.emit("seek:queued",e),e))}function Pt(t,e){e.timer&&clearTimeout(e.timer),e.timer=e.offset=0,function(t){t.setState(It.FORWARD,!1),t.setState(It.BACKWARD,!1),t.setState("will-seek",!1)}(t)}function xt(t,e){const r=t._customElements.get(e);return r&&t.root.querySelector(r)||void 0}function Mt(){if("undefined"==typeof document)return!1;const t=document.documentElement;return t&&"rtl"==t.getAttribute("dir")}function Ft(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function Nt(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 Ut(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function Bt(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+":"+Ut(i)+":"+Ut(t)):e+Ut(i)+":"+Ut(t)}!function(t){t.FORWARD="forward",t.BACKWARD="backward"}(It||(It={}));const jt=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 jt.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 Ht=[1e7]+""+-1e3+-4e3+-8e3+-1e11,Vt=()=>"undefined"==typeof crypto?"":Ht.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 qt=["touchstart","touchmove"];function Wt(t,e){const r=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(r,"data",{get:()=>e}),r}function zt(t,e,r){const i=Wt(e,r);return t.dispatchEvent(i),t}function Yt(t,e,r){const i=Wt(e,r);return t.dispatchEvent(i),i}function Xt(t,e,r,i){Array.isArray(e)?e.forEach(e=>Qt(t,e,r,i)):Qt(t,e,r,i)}function Qt(t,e,r,i){if(n=e,!~qt.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 $t(t,e,r,i){return Xt(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])})}keys(){var t;const e=[];for(var r=0;r<this.implementation.length;r++)(null===(t=this.implementation.key(r))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(r));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}class InMemoryStorage{constructor(){this.pairs=[]}get length(){return this.pairs.length}clear(){this.pairs=[]}getItem(t){var e;return(null===(e=this.pairs.find(e=>e[0]===t))||void 0===e?void 0:e[1])||null}key(t){return this.pairs[t][0]||null}removeItem(t){this.pairs=this.pairs.filter(e=>e[0]!==t)}setItem(t,e){this.removeItem(t),this.pairs.push([t,e])}}const Zt={preload:"none",rtl:!1,controls:!0},Jt=["loop","muted","preload"];function te(t,i,n){let s;n.live_state={dvr_window:void 0,get dvr(){return s},set dvr(e){e!==s&&(s=e,n.setState(st,!(!t.live||e)))}},n._storage=new PlayerStorage(["localStorage","sessionStorage"].map(t=>{try{const e=window[t];return e.getItem(""),e}catch(e){return console.debug(`Access to window.${t} denied, trying next option`),null}}).find(t=>!!t)||new InMemoryStorage),n.toJSON=function(){return{duration:n.duration,volume:n.volume,currentTime:n.currentTime,states:n.root.className}},n.setSrc=function(e){return kt(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[Q]=!1),n.playerState=r,zt(n,"state",n.playerState),n},n.createComponents=function(...t){return Array.from({length:t.length}).map((e,r)=>gt(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)=>(zt(n,t,e),n),n.on=(t,e)=>(Xt(n,t,e),n),n.once=(t,e)=>($t(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)=>Yt(n,t,e),n.togglePlay=function(e){return Et(n,t,e)},n.toggleMute=function(t){t=null==t?!n.muted:!!t,n.muted=t,n.muted||n.volume||(n.volume=1),zt(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(),zt(n,L)}),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?Nt(Zt,e):r,Nt(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:Nt(e[n],r,t(e,r,i,n+1))}(r,t,e||""):e||""},n.setOpts=function(e){Object.assign(t,e),t.live&&!n.hasState("is-live")&&(n.setState(st,!0),zt(n,"live")),"disabled"in e&&void 0!==e.disabled&&n.toggleDisable(e.disabled),"muted"in e&&void 0!==e.muted&&n.toggleMute(e.muted),"dvr"in t&&(n.live_state.dvr=n.opt("dvr"));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 Mt();const e=t.getAttribute("dir");return e?"rtl"==e:Mt()}(i))),n.setState("is-live",!!t.live),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+"')":"",zt(n,w,t)},n.renderPlugin=function(t){Yt(n,"renderplugin",t).defaultPrevented||n.root.appendChild(t)};const a={offset:0,timer:0};var o,l;l=a,(o=n).on(Ot,(function(){Pt(o,l)})),n.enqueueSeek=function(t){if(0!=n.opts.seekable&&!(1==n.opts.disabled&&t>0))return Ct(n,a,t)},n.deviceId=function(){return function(t){if(Kt)return Kt;try{const e=t.getItem("flowplayer/uuid");if(e)return e;const r=Vt();return t.setItem("flowplayer/uuid",r),r}catch(t){return Kt=Vt()}}(n._storage)}}function ee(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}var re="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function ie(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 ne(){return"undefined"!=typeof window?window:void 0!==re?re:{}}const se=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function ae(t,e){return!!~se.indexOf(t)||t.indexOf(e)===t.length-e.length}ae.check_whitelist=function(t){return!!~se.indexOf(t)};const oe="production";function le(t,e){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};e=e||{};try{i=ft(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&&le.validate(r),r}function ue(t){try{return le.validate(t),{success:!0,message:""}}catch(t){return{success:!1,message:t.message}}}var de;function ce(t){return{grant:t,is_granted:e=>(t&e)===e}}function he({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://docs.flowplayer.com/troubleshooting/player#"+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)}le.validate=function(t){if("string"==typeof t&&(t=le(t)),!t||!t.raw){if(ae.check_whitelist(window.location.hostname)||"dev"===oe.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=ae.bind(null,e);if("dev"!==oe.toString()&&t.data.domain&&t.data.domain.length&&!t.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==oe.toString()&&1e3*t.exp-Date.now()<0)throw new Error("Expired token");return!0},le.id=function(t){if(t)return"string"==typeof t&&(t=le(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"}(de||(de={})),ce.of=ce,ce.from_token=function(t){const e=le(t,{require_valid_token:!0});return ce.of(e.data.acl)},ce.permissions=de;function fe(t,e){const r=e.clientWidth;e.classList.toggle("is-small",r<600),e.classList.toggle("is-tiny",r<400)}function pe(t,e,i){let n=!0;e.classList.add("flowplayer"),fe(0,e),Xt(i,[m,"resize"],(function(){fe(0,e)})),Xt(i,"state",(function(){Object.entries(i.playerState).forEach((function([t,r]){e.classList.toggle(t,r)}))})),Xt(i,"timeupdate",(function(){i.setState(it,!i.hasState("is-casting")&&!i.hasState(tt)&&i.readyState<3)})),Xt(i,_,(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(et,!0),$t(i,S,(function(){e===i.src&&(i.setState(et,!1),i.pause(),i.setState(tt,!0))})),i.currentTime=0}$t(i,"timeupdate",(function(){i.setState(rt,!1)})),i.transitionState(rt,Q,t.loop||t.rewind?0:300)}}),0)})),Xt(i,[A,S],(function(t){i.setState(et,t.type==A),i.setState($,i.paused),i.setState(Q,!i.paused)})),Xt(i,"remotesession:ended",(function(t){setTimeout(()=>i.currentTime=t.detail.currentTime,0)})),Xt(i,_,(function(){i.setState(Q,!1),n=!0})),Xt(i,v,()=>{if(!i.opts.live||!i.opts.is_native)return;const t=i.seekable;0!=t.length&&i.emit("dvr/window",t.end(t.length-1)-t.start(0))}),Xt(i,r().ios?p:g,(function(){var t,e;i.setState(Z,!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")})),Xt(i,[T,b,m],(function(e){if(!i.hasState(et)&&(e.type!=b||t.autoplay||i.setState(it,!1),e.type!=m||"none"!=i.opt("preload")||t.autoplay)){if(e.type==m&&t.autoplay)return $t(i,E,(function(){i.setState(it,!1)}));e.type==T&&([Q,$,tt].forEach((function(t){i.setState(t,!1)})),i.hasState(Z)||i.setState(J,!0)),i.setState(rt,!1),i.setState(it,e.type==T)}})),Xt(i,[E,y],(function(e){setTimeout(()=>{const t=new CustomEvent("flowplayer/"+e.type,{detail:i});document.dispatchEvent(t)},0);const r=e.type==E,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(tt,!1),s||i.hasState(et))return;const o=r?Q:$,l=r?$:Q;i.transitionState(o,l,a?0:300),r&&i.setState("no-autoplay",!1)}))}const ge=[0].concat(Array.from({length:100}).map((t,e)=>(e+1)/100));function ve(t,e,r){if(!window.IntersectionObserver)return;const i={should_resume:!!t.autoplay,has_user_gesture:!1,locked:!1};[c,n].forEach(t=>$t(r,t,()=>i.has_user_gesture=!0)),Xt(r,"play",(function(){i.locked||(i.should_resume=!0)})),Xt(r,"src",(function(){i.should_resume=!!t.autoplay})),Xt(r,y,(function(){i.locked||(i.should_resume=!1)}));const s=()=>{setTimeout(()=>{r.setState(tt,!0),r.setState("is-autoplay",!1)},100)};Xt(r,b,(function(e){if(t.autoplay)return r.hasState(ot)&&i.should_resume?r.togglePlay(!0).catch(s):void(t.autopause||r.hasState(ot)||!i.should_resume||$t(r,"viewenter",()=>{t.autoplay&&i.should_resume&&r.togglePlay(!0).catch(s)}))}));const a=new IntersectionObserver(t=>{t.forEach(t=>{setTimeout(()=>{const e=t.intersectionRatio,i=r.hasState(ot);if(r.setState(ot,e>=.2),r.emit("intersectionchange",{ratio:e}),i===r.hasState(ot))return;const n=r.hasState(ot)?"viewenter":"viewleave";r.emit(n)},0)})},{threshold:ge});a.observe(e),r.on(L,()=>a.disconnect()),t.autopause&&(Xt(r,"viewenter",(function(){i.should_resume&&t.autopause&&!me()&&r.togglePlay(!0)})),Xt(r,"viewleave",(function(){if(!t.autopause||me())return;const e=!r.paused;i.locked=!0,r.pause(),setTimeout((function(){i.should_resume=e,i.locked=!1}),0)})))}function me(){return e.find(t=>t.hasState("is-casting"))}function ye(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(L,()=>r.disconnect())}function Ee(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 Te(t,e,r){const i=!!t.ratio,n=document.createElement("div");n.classList.add("fp-ratio"),e.append(n);let s=Ee(t.ratio||.5625);n.style.paddingTop=100*s+"%";const a=[g,p];r.on(a,(function(){if(i)return;const t=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth;t&&r.setOpts({ratio:t})})),r.on(w,(function(){const e=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth,i=Ee((null==t?void 0:t.ratio)||e||.5625);s!==i&&(s=i,n.style.paddingTop=100*i+"%")}))}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(E,this.render),null===(e=this.player)||void 0===e||e.once(_,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(E,this.render),null===(i=this.player)||void 0===i||i.off(_,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(be).forEach(([t,e])=>{n.style.setProperty(t,e,"important")}),i.appendChild(n)}}const be={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)"},_e="flowplayer/"+E;function Se(t){const e=e=>{e.detail!==t&&!1===t.opt("multiplay")&&t.togglePlay(!1)};t.on(L,()=>document.removeEventListener(_e,e)),document.addEventListener(_e,e)}function Ae(t,e){const r=[];t.addEventListener("contextmenu",i=>{const n=i.timeStamp;for(r.push(n);r.length>3;)r.shift();r.length>=3&&r.every(t=>t-n<3e3)&&(console.debug("flowplayer/debug rendering info"),function(t,e){var r;!function(t){const e=t.querySelector(".debug-info");null==e||e.remove()}(t);const i=document.createElement("div");i.classList.add("debug-info");const n=Le("flowplayer.version","3.4.1");i.append(n);const s=null===(r=null==e?void 0:e.hls)||void 0===r?void 0:r.constructor;if(s&&s.version){const t=Le("hls.version",s.version);i.append(t)}t.appendChild(i)}(t,e))})}const Le=(t,e)=>{const r=document.createElement("div");r.classList.add("row",t);const i=document.createElement("span");i.classList.add("attr"),i.textContent=t;const n=document.createElement("span");return n.textContent=e,n.classList.add("value"),r.append(i,n),r};const we=function(){const t=ne(),e=t.flowplayer?t.flowplayer:{extensions:[]};return Array.isArray(e.extensions)||(e.extensions=[]),e}();function De(r,i){if("function"==typeof r)return t.push(...[...arguments].filter(t=>"function"==typeof t)),De;"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=ue(i.token);if(!a.success)return he({root:n,data:{reason:"token",details:a.message}});const o=new Map,l=ee(i,n);l.reaper=o,l._customElements=pt,Object.defineProperty(l,"token",{value:"string"==typeof i.token?le.id(i.token):"",writable:!1}),l.addEventListener(L,()=>{o.clear(),l.reaper=0,delete l.root}),l.root=n,i.token&&ce.from_token(i.token).is_granted(ce.permissions.DEVELOPER_PLAN)&&t.push(ExplorerPlan),!~e.indexOf(l)&&e.push(l),te(i,n,l),l.setAttrs(i),l.plugins=De.extensions.map(t=>new t(De,l)),pe(i,n,l),ve(i,n,l),ye(n,l),Te(i,n,l),Se(l),Ae(n,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(p),u>2&&l.currentSrc&&l.emit(b),l.emit("mount"),l.on("error:fatal",(function(t){he({root:n,video:l,data:t.data||{}})})),l}Object.assign(De,we),function(i){Array.isArray(i.extensions)&&i.extensions.forEach(e=>t.push(e)),i.customElements=pt,i.defaultElements=X,i.version="3.4.1",i.commit="465b355ad41710b2549a1de946bfd490968fd17d",i.instances=e,i.extensions=t,i.support=r,i.events=k,i.states=lt,i.jwt=ft,i.autoplay=yt,i.quality=mt}(De),"object"==typeof document&&setTimeout(zt,0,document,"flowplayer:umd",De);var Re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ke(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Oe(t){var e={exports:{}};return t(e,e.exports),e.exports}var Ie=Oe((function(t,e){var r=Re&&Re.__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}})),Ce=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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(Ie),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})),Pe=Oe((function(t,e){var r=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var i=r(Ce);e.default=i.default.of()})),xe=Oe((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 "))}))}})),Me=Oe((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})),Fe=Oe((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"})),Ne=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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=Re&&Re.__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=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var o=a(Pe),l=a(Ce),u=n(xe),d=n(Ie),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=Me.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=Fe.Verb,t}();e.default=c})),Ue=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0,e.API=e.Tracker=void 0;var a=s(Ne);e.Tracker=a.default;var o=n(xe);e.API=o})),Be="ping",je="display",Ge="view";const He=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],Ve=["created","position"],Ke=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function qe(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 We(t,e,r){if(!e.segment_duration&&!qe(t,e))return;const i=function(t,e,r){const i=e.last_idx,n=r?99:ze(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(Be,{position:i})}function ze(t,e){return Math.min(Math.floor(t.currentTime/e.segment_duration),99)}const Ye="vod",Xe="live",Qe=[je,Be,Ge];function $e(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(Be,{position:60*e.ticks}))}(t,e);case"vod":return We(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 Je(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(t){return!1}}class Analytics$1{init(t,e,r){if(!ce.from_token(t.token||"").is_granted(ce.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const i=r.analytics={ticker:void 0,last_media_id:"",ended:!1},n={locked:!1,ttl:6e3,task:()=>{$e(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,player_version:"3.4.1"},a=Ue.Tracker.of(r,{verb:Ue.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:Qe,required_keys:He,optional_keys:Ke.concat(Ve).slice(0),metadata:s});r.on(L,(function(){a&&a.destroy()})),r.on(w,(function(e){if(!a)return;const n=Nt(e,"data.metadata",{});if(!n.media_id)return;const s=Nt(a,"metadata.media_id");if(s&&n.media_id==s)return;const o=Nt(t,"analytics",{});a.put(n),a.put(o);const l=Nt(t,"metadata.live_start_time",t.live)?Xe:Ye;a.put({video_type:l,source:t.source||Je()||""}),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(je)}));let o=0;r.on(E,(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(Ge),o=0})).catch((function(){o=0}));i.last_media_id=a.metadata.media_id,r.emit(Ge)})),r.on("timeupdate",(function(){var e;a&&(o||Ze(r)||i.ended||(!t.live&&r.currentTime+.25>=r.duration&&$e(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(S,(function(){a&&i.ticker&&"vod"==i.ticker.kind&&function(t,e){qe(t,e),e.last_idx=ze(t,e)}(r,i.ticker)})),r.on(_,(function(){a&&function(t,e){e.ended||(e.ended=!0,$e(t,e.ticker))}(r,i)}))}}var tr;function er(t){switch(t){case tr.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case tr.MEDIA_ERR_NETWORK:return"a network error occurred";case tr.MEDIA_ERR_DECODE:return"unable to decode media content";case tr.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case tr.NO_INTERNET:return"no internet connection detected";case tr.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}function rr(){}function ir(){return"https:"===location.protocol}function nr(t){const e=document.createElement("a");return e.href=t,e}function sr(t){try{return!!new URL(t)}catch(t){return!1}}ie(ne(),Analytics$1),"undefined"!=typeof window&&window.matchMedia&&[D,R].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"}(tr||(tr={}));function ar(t,e){if(e.message)return e.message;if(e.stack)return e.stack;const r=e.code||-1,i=er(r);return t.i18n("media_errors."+r,i)}const or=()=>!0===(navigator||{}).onLine;function lr(t,e,r){const n=r.togglePlay;r.on(i,(function(t){const e=t.data||r.error,s="Error: %s\n"+(null===(a=(new Error).stack)||void 0===a?void 0:a.split("\n").slice(2).join("\n"));var a;setTimeout((function(){const a=xt(r,O);if(t.defaultPrevented||!a||r.root.querySelector("#qul_error"))return;if("AbortError"==e.name)return;r.setState("is-error",!0),r.togglePlay=rr;const o=function(t,e){return{code:"http:0"===e.code?ur(t):e.code,message:ar(t,e)}}(r,e);console.error(s,o.message);let l=xt(r,"flowplayer-error");l||(l=gt(r,"flowplayer-error"),a.append(l)),zt(l,i,{data:e,formatted_data:o}),r.once(m,()=>{r.togglePlay=n,r.setState("is-error",!1),null==l||l.remove()})}))}))}function ur(t){return function(t){try{return ir()&&"http:"==nr(t).protocol}catch(t){return!1}}(t.original_src)?{code:tr.MIXED_CONTENT}:or()?{code:tr.MEDIA_ERR_NETWORK}:or()?{code:tr.UNKNOWN}:{code:tr.NO_INTERNET}}var dr=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 cr(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")),hr(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(at)||t.setState(at,!0)}(r,e)),!document.fullscreenEnabled)return;const n=a();if(t)return n.requestFullscreen();i()===n&&document.exitFullscreen()},hr(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?h:f),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 hr(t){return r().ios&&"function"==typeof t.webkitEnterFullScreen&&"function"==typeof t.webkitExitFullScreen}function fr(t,e){const r=t.seekable;if("object"!=typeof t.opts||0==r.length)return{head:0,tail:0};const i=r.end(r.length-1),n=e||t.live_state.dvr_window;return{head:i,tail:"number"!=typeof n||i-n<0?r.start(0):i-n}}function pr(t){return t.opt("live",!1)||t.duration>=Number.MAX_SAFE_INTEGER}function gr(t){return isFinite(t.duration)?t.duration:0==t.seekable.length?0:fr(t).head}function vr(t){return function(t){return fr(t).head}(t)-.5}function mr(t,e,r){if(!r.reaper)return;const i=document.createDocumentFragment(),n=gt(r,O);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=Ft("fp-footer");e.append(i),r.on(w,(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=Ft("fp-title");t.innerText=s,i.append(t)}if("string"==typeof n){const t=n.split(" "),e=Ft("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),lr(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)}))}),cr(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=>{t.live&&!1!==r.live_state.dvr&&function(t,e,r){if(0==e)return!0;const i=fr(t,r);return i.head-i.tail>=e}(r,t.seconds_to_dvr||60,e.detail)&&(r.live_state.dvr=r.seekable.length>0,r.live_state.dvr_window=e.detail)}),r.on("live",()=>{const t=setInterval(()=>{if(r.opts.live&&!r.hasState("is-error")&&0!=r.reaper||clearInterval(t),0==r.seekable.length)return;const e=function(t){var e;const r=t.currentTime,i=fr(t),n=!t.hasState("is-chromecast-playing")&&(null===(e=t.hls)||void 0===e?void 0:e.liveSyncPosition);return{progress:Math.min(100,Math.max(0,(r-i.tail)/(i.head-i.tail)*100)),is_live:r-(n||i.head)>=-10}}(r);r.hasState(nt)==e.is_live&&r.setState(nt,!e.is_live),r.live_state.dvr&&r.emit("dvr",e.progress)},200)}),r.on(p,(function(){r.setOpts({live:pr(r)})})),r.on("durationchange",(function(t){const e=pr(r),i=e?gr(r):t.data||r.duration;isNaN(i)||r.setOpts({live:e,duration:i})})),r.on(w,(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;[u,d].forEach(t=>n.addEventListener(t,(function(t){r.hasState("is-touch-device")&&t.type===u||("number"==typeof a&&clearTimeout(a),r.setState("is-hovered",!0),a=0==r.paused&&setTimeout((function(){r.setState("is-hovered",!1)}),2e3))})))}function yr(t,e,r){if(ce.from_token(t.token||"").is_granted(ce.permissions.NO_METERING))return;const i=le.id(t.token||"");i&&r.once(E,()=>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 Er={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=Er;const Tr="health:record",br="rebuffer";var _r=Object.freeze({__proto__:null,RECORD:Tr,REBUFFER:br});function Sr(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const s=(null==e?void 0:e.debug)||r;s&&t.match(s)&&console.log(`flowplayer/${t} -- ${i}`,...n)};return i.log=i,i}const Ar=navigator;function Lr(t){var e,r;const i=null===(e=t.hls)||void 0===e?void 0:e.bandwidthEstimate;return i?1e-6*i:(null===(r=Ar.connection)||void 0===r?void 0:r.downlink)||-1}function wr(t,e){return function(t,e){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,e)}(t,JSON.stringify({events:e}))}const Dr="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),Rr=window,kr=Rr._flowplayerTimekeeper||(Rr._flowplayerTimekeeper={});async function Or(){const t=kr.cachedServerOffset;if(t)return t;const e=kr.pendingRequest||(kr.pendingRequest=fetch(Dr)),r=await e,i=parseInt(r.headers.get("age")||"0"),n=await r.json(),s=Date.now()-n.millisUtc-1e3*i;return kr.cachedServerOffset=s,kr.cachedServerOffset}const Ir=t=>{switch(t){case!0:return yt.ON;case!1:return yt.OFF;default:return t}},Cr=[];function Pr(t){if(t.suspended)return;const e=Cr.slice(0);Cr.length=0,0!=e.length&&(t.logger.log(`:dispatch events={${e.length}}`),wr("https://ihi.flowplayer.com/v1/health/events",e))}async function xr(t,e,r){const i=await Fr();Cr.push(Object.assign(e,i)),t.logger.log(":enqueue",e.event,e),Cr.length<10&&!r||Pr(t)}const Mr=()=>{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}},Fr=async()=>{const t=Date.now();try{return{adjusted_time:t-await Or(),client_time:t}}catch(e){return{client_time:t}}},Nr=(t,e)=>Object.assign(t,{detail:e}),Ur=(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.4.1",commit:"465b355ad41710b2549a1de946bfd490968fd17d",ima_sdk_version:Mr(),preload:t.opt("preload"),autoplay:Ir(t.opt("autoplay")),live:t.opt("live"),dvr:!!t.live_state.dvr,source:t.original_src,downlink_mbs:Lr(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")}),Br=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 jr(t,e,r,i){const n=Ur(e,t.eventInfo(r)),{before:s,after:a}=i;xr(t,((t,e,r)=>Object.assign(t,{state:{before:e,after:r}}))(n,Br(s),Br(a)))}const Gr=(t,e)=>{let r=null;return(...i)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>e(...i),t)}},Hr=Vt();class Health{constructor(t,e){this.session_id=Hr,this.suspended=!1,this.logger=Sr("health",e.opts),this.media_session_id=Vt(),this.analyticsLoop=setInterval(()=>Pr(this),2e3),e.on(L,()=>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(()=>Pr(this),2e3)}init(t,e,r){!function(t){t.on(T,(function(e){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(br)}))}(r),r.on(Tr,({detail:t})=>{const e=Ur(r,this.eventInfo(t.event));Object.assign(e,t.detail||{}),xr(this,e)}),[b,m,a,p,g,v,T,br].forEach(t=>{r.on(t,t=>{xr(this,Ur(r,this.eventInfo(t.type)))})}),[E,y,A,S,_,h,f].forEach(t=>{r.on(t,t=>{xr(this,Ur(r,this.eventInfo(t.type)))})}),r.on("volumechange",Gr(800,t=>{const e=Ur(r,this.eventInfo(t.type));xr(this,Nr(e,{volume:parseFloat(r.volume.toFixed(2)),muted:r.muted}))})),r.on("resize",Gr(800,t=>{const i=Ur(r,this.eventInfo(t.type));xr(this,Nr(i,{height:e.clientHeight,width:e.clientWidth}))})),r.on("hls/failover",t=>{const e=Ur(r,this.eventInfo(t.type)),i=t.detail,{reason:n,from:s}=i;xr(this,Nr(e,{reason:n,from:s}))}),r.on("qualitychange",({type:t,detail:e})=>{switch(e.kind){case"hls":return jr(this,r,t,e)}});let n=Date.now()+5e3;r.on("timeupdate",t=>{if(Date.now()<n)return;n=Date.now()+5e3;const e=Ur(r,this.eventInfo(t.type));var i;xr(this,Nr(e,{duration:(i=r.duration,Number.isFinite(i)?i:i===1/0?-1:void 0)}))}),r.addEventListener(i,t=>{const e=Ur(r,this.eventInfo(t.type)),i=t.error||r.error;if(!i)return xr(this,e,!0);const n=i.code,s={error_message:i.message||er(n),error_code:n,error_stack:i.stack||""};return xr(this,Nr(e,s),!0)}),r.on("src",t=>{var e;const i=null===(e=t.detail)||void 0===e?void 0:e.src;if("string"!=typeof i)return;if(!sr(r.original_src))return;if(!sr(i))return;if(i==r.original_src)return;this.media_session_id=Vt();xr(this,Ur(r,this.eventInfo(t.type))),Pr(this)}),r.on("visibilitychange",t=>{xr(this,Ur(r,this.eventInfo(t.type))),Pr(this)})}}Health.events=_r,Health._UNLOAD_SUBSCRIBED=!1,ie(window,Health);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(w,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(w,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)?Bt(r):""})}}const Vr={name:"fp-fullscreen",translation_key:"core.fullscreen"},Kr={name:"fp-fullscreen-exit",translation_key:"core.exit_fullscreen"},qr={name:"fp-play",translation_key:"core.play"},Wr={name:"fp-pause",translation_key:"core.pause"},zr={translation_key:"core.mute",name:"fp-volume-mute-unmute"},Yr={translation_key:"core.play",name:"fp-small-play"},Xr={translation_key:"core.pause",name:"fp-small-pause"},Qr={name:"fp-fast-forward"},$r={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 Jr;function ti(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(Jr.GRABBING),a.remove(Jr.TOUCHING);const o=e.onseek||rr,l=e.onstart||rr,h=e.onend||rr,f=e.onmouse||rr,p=e.ontouch||rr,g=e.ontouchend||rr;function v(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 m(e){const r=v(e);r!=n&&(o(t,r),n=r)}return t.addEventListener("touchstart",(function(e){ei(t,e)&&(a.add(Jr.TOUCHING),ri(t.parentElement)&&(a.add(Jr.GRABBING),p(t,v(e)),l(t,v(e)),m(e)))}),Zr),t.addEventListener(d,(function(e){m(e),f(t,v(e))}),Zr),t.addEventListener(c,(function(e){setTimeout((function(){a.remove(Jr.TOUCHING)}),500),ei(t,e)&&(a.remove(Jr.GRABBING),g(t,v(e)),h(t,v(e)),i=0)}),Zr),t.addEventListener("touchcancel",(function(){a.remove(Jr.GRABBING,Jr.TOUCHING),i=0}),Zr),t.addEventListener("mousedown",(function(e){a.contains(Jr.TOUCHING)||(document.addEventListener(u,m),a.add(Jr.GRABBING),l(t,v(e)),e.preventDefault(),m(e))})),t.addEventListener(u,(function(e){a.contains(Jr.TOUCHING)||f(t,v(e))})),document.addEventListener("mouseup",(function(e){a.contains(Jr.TOUCHING)||(document.removeEventListener(u,m),a.contains(Jr.GRABBING)&&(a.remove(Jr.GRABBING),h(t,v(e)),i=0))})),t}function ei(t,e){const r=e.target;return!!r&&(r&&!r.closest(t.id)||!ri(t.parentElement)||!t.classList.contains(Jr.TOUCHING))}function ri(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"}(Jr||(Jr={}));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),ti(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(Jr.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 ii(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 ni(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 si(t,e){t.style.width="0",e.style.display="none"}function ai(t,e,r){if(!e.seekable||0==e.seekable.length)return;ii(r,t);const i=fr(e),n=(100-Math.max(0,Math.min(t,100)))/100*(i.head-i.tail);r.innerText="-"+Bt(n)}function oi(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=fr(t);return r.tail+e*(r.head-r.tail)}(e,t)}function li(t,e){t.style.width="0",e.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(t){let e;super(t),this.bufferEle=Ft("fp-buffer"),this.progress=Ft("fp-progress","fp-color"),this.tooltipEle=Ft("fp-timestamp"),this.proposedSeekBar=Ft("fp-hover"),this.dragger=Ft("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 i=requestAnimationFrame;let n=void 0;const s=()=>{0==t.reaper||e.live||(!function(t,e){e.style.width=t.currentTime/t.duration*100+"%"}(t,this.progress),n=void 0,t.paused||this.classList.contains(Jr.GRABBING)||n||(n=setTimeout(s,200)))},a=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);ti(this,{onseek:(r,i)=>{if(a())switch(!!e.live){case!0:ai(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),ii(this.tooltipEle,i)}},onstart:()=>{a()&&(t.emit("timeline/gesture/start"),!t.hasState("is-casting")&&t.setState(et,!0),e.live||function(t){t.style.display="block"}(this.tooltipEle))},onend:function(r,n){i(s),0!=e.seekable&&e.live&&oi(n,t)},ontouch:function(){t.paused||(r=!0,t.pause())},ontouchend:()=>{r&&(r=!1,t.play()),e.live?li(this.proposedSeekBar,this.tooltipEle):si(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>t.emit("timeline/gesture/end"),0)},onmouse:(r,i)=>{if(a()&&(t.emit("timeline/gesture/move",{percent:i}),!this.classList.contains(Jr.GRABBING)))switch(!!e.live){case!0:!function(t,e){e.style.width=t+"%"}(i,this.proposedSeekBar),ai(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;ii(r,t),r.innerHTML="";const i=document.createElement("span");i.innerText=Bt(t/100*e.duration),r.append(i)}(i,t,this.tooltipEle)}}}),t.on(w,(function(t){t.data&&(e=t.data)})),t.on(E,()=>i(s)),t.on(v,()=>{0==t.reaper||e.live||ni(t,this.bufferEle)}),t.on("dvr",t=>{this.progress.style.width=t.detail+"%"}),t.on("timeupdate",()=>{0!=t.reaper&&(i(s),this.setAttribute("aria-valuenow",t.currentTime+""),e.live||ni(t,this.bufferEle))}),t.on(p,()=>{0!=t.reaper&&(e.live||ni(t,this.bufferEle))}),t.on("durationchange",e=>{if(0==t.reaper)return;const r=pr(t)?gr(t):e.data||t.duration;isNaN(r)||(this.setAttribute("aria-valuemax",r+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener(l,()=>{t.emit("timeline/gesture/end"),e.live?li(this.proposedSeekBar,this.tooltipEle):si(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=xt(t,I))||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=Ft("fp-live-text"),r=Ft("fp-live-indicator","fp-color");e.textContent="live",this.append(r,e),this.addEventListener(n,(function(){!function(t){try{t.dvr_offset=0,t.currentTime=vr(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(w,r=>{if(0==t.reaper||!r.data)return;e=r.data;const i=pr(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=Bt(i)}),t.on(p,()=>{0==t.reaper||e.live||function(t,e){t.duration&&(e.innerText=Bt(t.duration))}(t,this)})}}class FlowplayerElapsedTime extends FlowplayerComponent{constructor(t){let e;super(t),this.classList.add("fp-elapsed"),this.innerText=Bt(0),t.on(w,t=>{t.data&&(e=t.data)}),t.on("timeupdate",()=>{0!=t.reaper&&(e.live?function(t,e){e.innerText=Bt(t.currentTime)}(t,this):function(t,e){e.innerText=Bt(t.currentTime)}(t,this))})}}class FlowplayerControlButtons extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-btns","fp-small-switch");const e=gt(t,V),r=gt(t,H);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=gt(t,this.classList.contains("fp-left-zone")?W:"flowplayer-fast-forward-icon");n.removeAttribute("tabindex"),i.classList.add("fp-zone-seconds"),this.append(i,n);t.on(S,()=>{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(c,(function(e){isNaN(t.duration)||isNaN(t.currentTime)||16384&t.opt("ui")||t.hasState(st)||!t.hasState("will-seek")&&!t.hasState(at)||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 FlowplayerError extends FlowplayerComponent{constructor(t){super(t),this.className="fp-error",this.message=document.createElement("p"),this.message.className="error-message",this.append(this.message),this.addEventListener("error",t=>{const e=t.detail;e&&(this.message.textContent=e.formatted_data.message)})}}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,q].forEach(e=>{const r=gt(t,e);r.removeAttribute("tabindex"),this.append(r)})}}class FlowplayerVolumeControl extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-volume-control");const e=gt(t,z);this.append(e),!r().ios&&this.append(gt(t,M)),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",N)),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",C,P,x,"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",j,"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),[E,S].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&&!t.hasState("is-endscreen"))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(c,(function(e){e.cancelable&&!t.hasState("is-endscreen")&&(e.preventDefault(),t.emit(e.type,{source:e}))})),t.on(c,(function(r){setTimeout((function(){if(r.defaultPrevented)return;if(t.hasState(it))return;if(t.ended)return t.togglePlay(!0);const i=t.hasState(tt);e&&clearTimeout(e),(i||t.hasState(at)||t.hasState("no-autoplay"))&&(t.hasState(at)&&(t.setState(at,!1),t.setState("is-hovered",!1)),t.togglePlay(),i)||(t.setState(at,!0),t.paused||(e=setTimeout((function(){e=!1,t.setState(at,!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(F,B,I))}}De.extensions.unshift.apply(De.extensions,[I18n,Analytics$1,Health,class Default{constructor(t){vt(t,O,FlowplayerUi),vt(t,"flowplayer-error",FlowplayerError),vt(t,I,FlowplayerControls),vt(t,C,FlowplayerLiveStatus),vt(t,"flowplayer-control-duration",FlowplayerDuration),vt(t,x,t.extensions.find(t=>"Chapters"===t.name)?FlowplayerChaptersTimelineBar:FlowplayerTimelineBar),vt(t,P,FlowplayerElapsedTime),vt(t,M,FlowplayerVolumeBar),vt(t,"flowplayer-volume-control",FlowplayerVolumeControl),vt(t,"flowplayer-control-buttons",FlowplayerControlButtons),vt(t,F,FlowplayerHeader),vt(t,U,FlowplayerPrimary),vt(t,"flowplayer-header-duration",FlowplayerHeaderDuration),vt(t,"flowplayer-header-left-zone",class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-left",U,"flowplayer-header-duration")}}),vt(t,N,class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-right fp-togglable","flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon")}}),vt(t,B,FlowplayerMiddle),vt(t,j,FlowplayerMiddleZone),vt(t,G,FlowplayerMiddleWait),vt(t,"flowplayer-middle-buttons",FlowplayerMiddleButtons),vt(t,"flowplayer-middle-right-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-right-zone")}}),vt(t,"flowplayer-middle-left-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-left-zone")}}),vt(t,H,class extends FlowplayerIcon{constructor(t){super(t,Yr),this.setAttribute("role","button")}}),vt(t,V,class extends FlowplayerIcon{constructor(t){super(t,Xr),this.setAttribute("role","button")}}),vt(t,K,class extends FlowplayerIcon{constructor(t){super(t,qr)}}),vt(t,q,class extends FlowplayerIcon{constructor(t){super(t,Wr)}}),vt(t,"flowplayer-fullscreen-enter-icon",class extends FullscreenIcon{constructor(t){super(t,Vr)}}),vt(t,"flowplayer-fullscreen-exit-icon",class extends FullscreenIcon{constructor(t){super(t,Kr)}}),vt(t,"flowplayer-fast-forward-icon",class extends FlowplayerIcon{constructor(t){super(t,Qr)}}),vt(t,W,class extends FlowplayerIcon{constructor(t){super(t,$r)}}),vt(t,z,class extends FlowplayerIcon{constructor(t){super(t,zr),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){yr(t,0,r),mr(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 ui=Object.assign(De,{ui:dr,i18n:I18n}),di=ke(Oe((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":
|
|
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="mousemove",d="touchmove",c="touchend",h="fullscreenenter",f="fullscreenexit",p="loadedmetadata",g="loadeddata",v="progress",m="loadstart",y="pause",E="playing",T="waiting",_="canplay",b="ended",S="seeked",A="seeking",L="reap",w="config",D="landscape",R="portrait";var k=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:u,TOUCH_START:"touchstart",TOUCH_MOVE:d,TOUCH_END:c,TOUCH_CANCEL:"touchcancel",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_ENTER:h,FULLSCREEN_EXIT:f,FULLSCREEN_CHANGE:"fullscreenchange",WEBKIT_NEEDKEY:"webkitneedkey",METADATA:p,DATA:g,PROGRESS:v,TIME_UPDATE:"timeupdate",LOAD_START:m,VOLUME_CHANGE:"volumechange",PAUSE:y,PLAYING:E,PLAY:"play",WAITING:T,CAN_PLAY:_,ENDED:b,SEEKED:S,SEEKING:A,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:L,CONFIG:w,QUALITIES:"qualities",SET_QUALITY:"quality:set",NON_RECOVERABLE_ERROR:"error:fatal",RECOMMENDATIONS_READY:"recommendationsready",AUDIO_ONLY_SOURCE:"audioonlysource",LANDSCAPE:D,PORTRAIT:R,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 O="flowplayer-ui",I="flowplayer-control",C="flowplayer-live-status",P="flowplayer-elapsed-time",x="flowplayer-timeline-bar",M="flowplayer-volume-bar",F="flowplayer-header",N="flowplayer-header-right-zone",U="flowplayer-primary",B="flowplayer-middle",j="flowplayer-middle-zone",G="flowplayer-wait",H="flowplayer-small-play-icon",V="flowplayer-small-pause-icon",K="flowplayer-play-icon",q="flowplayer-pause-icon",W="flowplayer-rewind-icon",z="flowplayer-volume-icon",Y="flowplayer-live-countdown";var X=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:O,CONTROL:I,CONTROL_BUTTONS:"flowplayer-control-buttons",LIVE_STATUS:C,ELAPSED:P,TIMELINE:x,CONTROL_DURATION:"flowplayer-control-duration",VOLUME_CONTROL:"flowplayer-volume-control",VOLUME_BAR:M,HEADER:F,HEADER_LEFT_ZONE:"flowplayer-header-left-zone",HEADER_RIGHT_ZONE:N,PRIMARY:U,HEADER_DURATION:"flowplayer-header-duration",MIDDLE:B,MIDDLE_ZONE:j,WAIT:G,MIDDLE_BUTTONS:"flowplayer-middle-buttons",MIDDLE_LEFT_ZONE:"flowplayer-middle-left-zone",MIDDLE_RIGHT_ZONE:"flowplayer-middle-right-zone",ENDSCREEN_INTERSTITIAL:"flowplayer-endscreen-interstitial",ENDSCREEN_UP_NEXT:"flowplayer-endscreen-up-next",ENDSCREEN_GRID:"flowplayer-endscreen-grid",PLAYLIST_INTERSTITIAL:"flowplayer-playlist-interstitial",AIRPLAY_ICON:"flowplayer-airplay-icon",CHROMECAST_ICON:"flowplayer-chromecast-icon",SMALL_PLAY_ICON:H,SMALL_PAUSE_ICON:V,PLAY_ICON:K,PAUSE_ICON:q,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:W,SHARE_ICON:"flowplayer-share-icon",VOLUME_ICON:z,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:Y,PLAYLIST_CONTROLS:"flowplayer-playlist-controls",THUMBNAILS_CAROUSEL:"flowplayer-thumbnails-carousel",ERROR_COMPONENT:"flowplayer-error"});const Q="is-playing",$="is-paused",Z="is-loaded",J="is-loading",tt="is-starting",et="is-seeking",rt="is-ended",it="is-waiting",nt="is-live-seeked",st="no-timeline",at="is-touched",ot="is-in-viewport";var lt=Object.freeze({__proto__:null,PLAYING:Q,FULLSCREEN:"is-fullscreen",PAUSED:$,MUTED:"is-muted",LOADED:Z,LOADING:J,STARTING:tt,SEEKING:et,GRABBING:"is-grabbing",DISABLED:"is-disabled",SMALL:"is-small",TINY:"is-tiny",RTL:"is-rtl",ENDED:rt,LIVE:"is-live",ERRORED:"is-error",WAITING:it,AUTOPLAY:"is-autoplay",NO_AUTOPLAY:"no-autoplay",SEAMLESS:"is-seamless",TOGGLING:"is-toggling",LIVE_SEEKED:nt,NO_DVR:st,HAS_POSTER:"has-poster",MENU_OPENED:"has-menu-opened",TOUCHED:at,HOVERED:"is-hovered",TOUCH_DEVICE:"is-touch-device",WILL_SEEK:"will-seek",SEEKABLE:"is-seekable",IN_VIEWPORT:ot});function ut(t){this.message=t}ut.prototype=new Error,ut.prototype.name="InvalidCharacterError";var dt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ut("'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 ct=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(dt(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 dt(e)}};function ht(t){this.message=t}ht.prototype=new Error,ht.prototype.name="InvalidTokenError";var ft=function(t,e){if("string"!=typeof t)throw new ht("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ct(t.split(".")[r]))}catch(t){throw new ht("Invalid token specified: "+t.message)}};ft.InvalidTokenError=ht;const pt=new Map,gt=(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),vt=(t,e,r)=>{window.customElements.get(e)||window.customElements.define(e,r),t.customElements.get(e)||t.customElements.set(e,e)};var mt,yt;!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"}(yt||(yt={}));function Et(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 Promise.resolve();if(!r)return Promise.resolve(t.pause());if(0==t.reaper)return Promise.resolve();const n=t.reaper.get("__pending_play");return 0!=t.paused||n?n?(n.src!==_t(t.original_src)&&Tt(t),n):(function(t){return(0==t.networkState||0==t.readyState)&&t.currentSrc==_t(t.original_src)}(t)&&Tt(t),(t=>t.autoplay&&yt.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(tt,!1),t.play().catch(e=>(console.warn("[flowplayer/play] attempting muted autoplay\n%s",e.message),t.muted=!0,t.volume=0,t.play())))):Promise.resolve()}function Tt(t){t.currentSrc.match(/^blob:/)||t.load()}function _t(t){const e=document.createElement("a");return e.href=t,e.href}function bt(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 St(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 At(t){switch(t){case"video/mpd":return"application/dash+xml";case"video/m3u8":return"application/x-mpegurl";default:return t}}const Lt=t=>{var{src:e}=t,r=bt(t,["src"]);return[Object.assign({src:e,type:e?At("video/"+St(e)):""},r)]};function wt(t){return Lt({src:t})}function Dt(t){var{src:e,type:r}=t,i=bt(t,["src","type"]);return e&&r?[Object.assign({src:e,type:r},i)]:r&&!e?[Object.assign({type:r},i)]:Lt(Object.assign({src:e},i))}var Rt;function kt(t,e,r,i={safari:!1}){const n=function(t){return"string"==typeof t?wt(t):Array.isArray(t)||"object"!=typeof t?t.reduce((function(t,e){return"string"==typeof e&&(e=wt(e)),"object"!=typeof e||Array.isArray(e)||(e=Dt(e)),t.concat(e)}),[]):Dt(t)}(r);return t.currentSrc&&(t.innerHTML=""),t.setOpts({live:!1}),t.live_state.dvr=void 0,t.live_state.dvr_window=void 0,delete t.opts.live,delete t.opts.duration,delete e.live_start_time,[et,Q,$,J,Z,nt].forEach(e=>t.setState(e,!1)),e.autoplay||t.setState(tt,!0),Array(...Array(n.length)).map((t,e)=>e).some(r=>{const s=n[r];if(Rt.Ok==function(t,e,r){t.emit("src",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 t.setOpts({is_native:!i}),i?(i.onload(e,t.root,t,r),Rt.Ok):Rt.Err}(t,e,s)||Rt.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 Rt.Err;if(r.drm&&(!r.drm["com.apple.fps.1_0"]||!i.safari))return Rt.Err;"string"==typeof r.src&&(t.preload=e.autoplay?"auto":null!==(n=e.preload)&&void 0!==n?n:"auto",t.src=r.src,e.autoplay&&i.safari&&t.load(),"none"!==t.preload&&t.setState(J,!0));return Rt.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"}(Rt||(Rt={}));const Ot=[L,A,"src","seek:cancel"];var It;function Ct(t,e,r){return isNaN(t.duration)||isNaN(t.currentTime)?{}:(e.offset+=r,0==e.offset?Pt(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,Pt(t,e))}),1e3),function(t,e){t.setState("will-seek",!0),t.setState(It.BACKWARD,e.offset<0),t.setState(It.FORWARD,e.offset>0)}(t,e),t.emit("seek:queued",e),e))}function Pt(t,e){e.timer&&clearTimeout(e.timer),e.timer=e.offset=0,function(t){t.setState(It.FORWARD,!1),t.setState(It.BACKWARD,!1),t.setState("will-seek",!1)}(t)}function xt(t,e){const r=t._customElements.get(e);return r&&t.root.querySelector(r)||void 0}function Mt(){if("undefined"==typeof document)return!1;const t=document.documentElement;return t&&"rtl"==t.getAttribute("dir")}function Ft(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function Nt(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 Ut(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function Bt(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+":"+Ut(i)+":"+Ut(t)):e+Ut(i)+":"+Ut(t)}!function(t){t.FORWARD="forward",t.BACKWARD="backward"}(It||(It={}));const jt=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 jt.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 Ht=[1e7]+""+-1e3+-4e3+-8e3+-1e11,Vt=()=>"undefined"==typeof crypto?"":Ht.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 qt=["touchstart","touchmove"];function Wt(t,e){const r=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(r,"data",{get:()=>e}),r}function zt(t,e,r){const i=Wt(e,r);return t.dispatchEvent(i),t}function Yt(t,e,r){const i=Wt(e,r);return t.dispatchEvent(i),i}function Xt(t,e,r,i){Array.isArray(e)?e.forEach(e=>Qt(t,e,r,i)):Qt(t,e,r,i)}function Qt(t,e,r,i){if(n=e,!~qt.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 $t(t,e,r,i){return Xt(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])})}keys(){var t;const e=[];for(var r=0;r<this.implementation.length;r++)(null===(t=this.implementation.key(r))||void 0===t?void 0:t.startsWith("flowplayer/"))&&e.push(this.implementation.key(r));return e}removeItem(t){try{this.implementation.removeItem("flowplayer/"+t)}catch(t){}}getItem(t){try{return this.implementation.getItem("flowplayer/"+t)}catch(t){return null}}setItem(t,e){try{this.implementation.setItem("flowplayer/"+t,e)}catch(t){}}clear(){try{this.keys().forEach(t=>this.implementation.removeItem(t))}catch(t){}}get length(){try{return this.keys().length}catch(t){return 0}}key(t){try{return this.implementation.key(t)}catch(t){return null}}}class InMemoryStorage{constructor(){this.pairs=[]}get length(){return this.pairs.length}clear(){this.pairs=[]}getItem(t){var e;return(null===(e=this.pairs.find(e=>e[0]===t))||void 0===e?void 0:e[1])||null}key(t){return this.pairs[t][0]||null}removeItem(t){this.pairs=this.pairs.filter(e=>e[0]!==t)}setItem(t,e){this.removeItem(t),this.pairs.push([t,e])}}const Zt={preload:"none",rtl:!1,controls:!0},Jt=["loop","muted","preload"];function te(t,i,n){let s;n.live_state={dvr_window:void 0,get dvr(){return s},set dvr(e){s=e;const r=!(!t.live||e);n.hasState(st)!=r&&n.setState(st,r)}},n._storage=new PlayerStorage(["localStorage","sessionStorage"].map(t=>{try{const e=window[t];return e.getItem(""),e}catch(e){return console.debug(`Access to window.${t} denied, trying next option`),null}}).find(t=>!!t)||new InMemoryStorage),n.toJSON=function(){return{duration:n.duration,volume:n.volume,currentTime:n.currentTime,states:n.root.className}},n.setSrc=function(e){return kt(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[Q]=!1),n.playerState=r,zt(n,"state",n.playerState),n},n.createComponents=function(...t){return Array.from({length:t.length}).map((e,r)=>gt(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)=>(zt(n,t,e),n),n.on=(t,e)=>(Xt(n,t,e),n),n.once=(t,e)=>($t(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)=>Yt(n,t,e),n.togglePlay=function(e){return Et(n,t,e)},n.toggleMute=function(t){t=null==t?!n.muted:!!t,n.muted=t,n.muted||n.volume||(n.volume=1),zt(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(),zt(n,L)}),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?Nt(Zt,e):r,Nt(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:Nt(e[n],r,t(e,r,i,n+1))}(r,t,e||""):e||""},n.setOpts=function(e){Object.assign(t,e),t.live&&!n.hasState("is-live")&&(n.setState(st,!0),zt(n,"live")),"disabled"in e&&void 0!==e.disabled&&n.toggleDisable(e.disabled),"muted"in e&&void 0!==e.muted&&n.toggleMute(e.muted),"dvr"in t&&(n.live_state.dvr=n.opt("dvr"));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 Mt();const e=t.getAttribute("dir");return e?"rtl"==e:Mt()}(i))),n.setState("is-live",!!t.live),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+"')":"",zt(n,w,t)},n.renderPlugin=function(t){Yt(n,"renderplugin",t).defaultPrevented||n.root.appendChild(t)};const a={offset:0,timer:0};var o,l;l=a,(o=n).on(Ot,(function(){Pt(o,l)})),n.enqueueSeek=function(t){if(0!=n.opts.seekable&&!(1==n.opts.disabled&&t>0))return Ct(n,a,t)},n.deviceId=function(){return function(t){if(Kt)return Kt;try{const e=t.getItem("flowplayer/uuid");if(e)return e;const r=Vt();return t.setItem("flowplayer/uuid",r),r}catch(t){return Kt=Vt()}}(n._storage)}}function ee(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}var re="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function ie(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 ne(){return"undefined"!=typeof window?window:void 0!==re?re:{}}const se=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function ae(t,e){return!!~se.indexOf(t)||t.indexOf(e)===t.length-e.length}ae.check_whitelist=function(t){return!!~se.indexOf(t)};const oe="production";function le(t,e){const r={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};e=e||{};try{i=ft(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&&le.validate(r),r}function ue(t){try{return le.validate(t),{success:!0,message:""}}catch(t){return{success:!1,message:t.message}}}var de;function ce(t){return{grant:t,is_granted:e=>(t&e)===e}}function he({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://docs.flowplayer.com/troubleshooting/player#"+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)}le.validate=function(t){if("string"==typeof t&&(t=le(t)),!t||!t.raw){if(ae.check_whitelist(window.location.hostname)||"dev"===oe.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=ae.bind(null,e);if("dev"!==oe.toString()&&t.data.domain&&t.data.domain.length&&!t.data.domain.some(r))throw new Error("Domain not allowed");if("dev"!==oe.toString()&&1e3*t.exp-Date.now()<0)throw new Error("Expired token");return!0},le.id=function(t){if(t)return"string"==typeof t&&(t=le(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"}(de||(de={})),ce.of=ce,ce.from_token=function(t){const e=le(t,{require_valid_token:!0});return ce.of(e.data.acl)},ce.permissions=de;function fe(t,e){const r=e.clientWidth;e.classList.toggle("is-small",r<600),e.classList.toggle("is-tiny",r<400)}function pe(t,e,i){let n=!0;e.classList.add("flowplayer"),fe(0,e),Xt(i,[m,"resize"],(function(){fe(0,e)})),Xt(i,"state",(function(){Object.entries(i.playerState).forEach((function([t,r]){e.classList.toggle(t,r)}))})),Xt(i,"timeupdate",(function(){i.setState(it,!i.hasState("is-casting")&&!i.hasState(tt)&&i.readyState<3)})),Xt(i,b,(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(et,!0),$t(i,S,(function(){e===i.src&&(i.setState(et,!1),i.pause(),i.setState(tt,!0))})),i.currentTime=0}$t(i,"timeupdate",(function(){i.setState(rt,!1)})),i.transitionState(rt,Q,t.loop||t.rewind?0:300)}}),0)})),Xt(i,[A,S],(function(t){i.setState(et,t.type==A),i.setState($,i.paused),i.setState(Q,!i.paused)})),Xt(i,"remotesession:ended",(function(t){setTimeout(()=>i.currentTime=t.detail.currentTime,0)})),Xt(i,b,(function(){i.setState(Q,!1),n=!0})),Xt(i,v,()=>{if(!i.opts.live||!i.opts.is_native)return;const t=i.seekable;0!=t.length&&i.emit("dvr/window",t.end(t.length-1)-t.start(0))}),Xt(i,r().ios?p:g,(function(){var t,e;i.setState(Z,!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")})),Xt(i,[T,_,m],(function(e){if(!i.hasState(et)&&(e.type!=_||t.autoplay||i.setState(it,!1),e.type!=m||"none"!=i.opt("preload")||t.autoplay)){if(e.type==m&&t.autoplay)return $t(i,E,(function(){i.setState(it,!1)}));e.type==T&&([Q,$,tt].forEach((function(t){i.setState(t,!1)})),i.hasState(Z)||i.setState(J,!0)),i.setState(rt,!1),i.setState(it,e.type==T)}})),Xt(i,[E,y],(function(e){setTimeout(()=>{const t=new CustomEvent("flowplayer/"+e.type,{detail:i});document.dispatchEvent(t)},0);const r=e.type==E,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(tt,!1),s||i.hasState(et))return;const o=r?Q:$,l=r?$:Q;i.transitionState(o,l,a?0:300),r&&i.setState("no-autoplay",!1)}))}const ge=[0].concat(Array.from({length:100}).map((t,e)=>(e+1)/100));function ve(t,e,r){if(!window.IntersectionObserver)return;const i={should_resume:!!t.autoplay,has_user_gesture:!1,locked:!1};[c,n].forEach(t=>$t(r,t,()=>i.has_user_gesture=!0)),Xt(r,"play",(function(){i.locked||(i.should_resume=!0)})),Xt(r,"src",(function(){i.should_resume=!!t.autoplay})),Xt(r,y,(function(){i.locked||(i.should_resume=!1)}));const s=()=>{setTimeout(()=>{r.setState(tt,!0),r.setState("is-autoplay",!1)},100)};Xt(r,_,(function(e){if(t.autoplay)return r.hasState(ot)&&i.should_resume?r.togglePlay(!0).catch(s):void(t.autopause||r.hasState(ot)||!i.should_resume||$t(r,"viewenter",()=>{t.autoplay&&i.should_resume&&r.togglePlay(!0).catch(s)}))}));const a=new IntersectionObserver(t=>{t.forEach(t=>{setTimeout(()=>{const e=t.intersectionRatio,i=r.hasState(ot);if(r.setState(ot,e>=.2),r.emit("intersectionchange",{ratio:e}),i===r.hasState(ot))return;const n=r.hasState(ot)?"viewenter":"viewleave";r.emit(n)},0)})},{threshold:ge});a.observe(e),r.on(L,()=>a.disconnect()),t.autopause&&(Xt(r,"viewenter",(function(){i.should_resume&&t.autopause&&!me()&&r.togglePlay(!0)})),Xt(r,"viewleave",(function(){if(!t.autopause||me())return;const e=!r.paused;i.locked=!0,r.pause(),setTimeout((function(){i.should_resume=e,i.locked=!1}),0)})))}function me(){return e.find(t=>t.hasState("is-casting"))}function ye(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(L,()=>r.disconnect())}function Ee(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 Te(t,e,r){const i=!!t.ratio,n=document.createElement("div");n.classList.add("fp-ratio"),e.append(n);let s=Ee(t.ratio||.5625);n.style.paddingTop=100*s+"%";const a=[g,p];r.on(a,(function(){if(i)return;const t=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth;t&&r.setOpts({ratio:t})})),r.on(w,(function(){const e=r.videoHeight&&r.videoWidth&&r.videoHeight/r.videoWidth,i=Ee((null==t?void 0:t.ratio)||e||.5625);s!==i&&(s=i,n.style.paddingTop=100*i+"%")}))}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(E,this.render),null===(e=this.player)||void 0===e||e.once(b,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(E,this.render),null===(i=this.player)||void 0===i||i.off(b,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(_e).forEach(([t,e])=>{n.style.setProperty(t,e,"important")}),i.appendChild(n)}}const _e={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)"},be="flowplayer/"+E;function Se(t){const e=e=>{e.detail!==t&&!1===t.opt("multiplay")&&t.togglePlay(!1)};t.on(L,()=>document.removeEventListener(be,e)),document.addEventListener(be,e)}function Ae(t,e){const r=[];t.addEventListener("contextmenu",i=>{const n=i.timeStamp;for(r.push(n);r.length>3;)r.shift();r.length>=3&&r.every(t=>t-n<3e3)&&(console.debug("flowplayer/debug rendering info"),function(t,e){var r;!function(t){const e=t.querySelector(".debug-info");null==e||e.remove()}(t);const i=document.createElement("div");i.classList.add("debug-info");const n=Le("flowplayer.version","3.4.2");i.append(n);const s=null===(r=null==e?void 0:e.hls)||void 0===r?void 0:r.constructor;if(s&&s.version){const t=Le("hls.version",s.version);i.append(t)}t.appendChild(i)}(t,e))})}const Le=(t,e)=>{const r=document.createElement("div");r.classList.add("row",t);const i=document.createElement("span");i.classList.add("attr"),i.textContent=t;const n=document.createElement("span");return n.textContent=e,n.classList.add("value"),r.append(i,n),r};const we=function(){const t=ne(),e=t.flowplayer?t.flowplayer:{extensions:[]};return Array.isArray(e.extensions)||(e.extensions=[]),e}();function De(r,i){if("function"==typeof r)return t.push(...[...arguments].filter(t=>"function"==typeof t)),De;"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=ue(i.token);if(!a.success)return he({root:n,data:{reason:"token",details:a.message}});const o=new Map,l=ee(i,n);l.reaper=o,l._customElements=pt,Object.defineProperty(l,"token",{value:"string"==typeof i.token?le.id(i.token):"",writable:!1}),l.addEventListener(L,()=>{o.clear(),l.reaper=0,delete l.root}),l.root=n,i.token&&ce.from_token(i.token).is_granted(ce.permissions.DEVELOPER_PLAN)&&t.push(ExplorerPlan),!~e.indexOf(l)&&e.push(l),te(i,n,l),l.setAttrs(i),l.plugins=De.extensions.map(t=>new t(De,l)),pe(i,n,l),ve(i,n,l),ye(n,l),Te(i,n,l),Se(l),Ae(n,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(p),u>2&&l.currentSrc&&l.emit(_),l.emit("mount"),l.on("error:fatal",(function(t){he({root:n,video:l,data:t.data||{}})})),l}Object.assign(De,we),function(i){Array.isArray(i.extensions)&&i.extensions.forEach(e=>t.push(e)),i.customElements=pt,i.defaultElements=X,i.version="3.4.2",i.commit="01d44d5db5202dd3a2d8dea07785c5a796e4a648",i.instances=e,i.extensions=t,i.support=r,i.events=k,i.states=lt,i.jwt=ft,i.autoplay=yt,i.quality=mt}(De),"object"==typeof document&&setTimeout(zt,0,document,"flowplayer:umd",De);var Re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ke(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Oe(t){var e={exports:{}};return t(e,e.exports),e.exports}var Ie=Oe((function(t,e){var r=Re&&Re.__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}})),Ce=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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(Ie),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})),Pe=Oe((function(t,e){var r=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var i=r(Ce);e.default=i.default.of()})),xe=Oe((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 "))}))}})),Me=Oe((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})),Fe=Oe((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"})),Ne=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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=Re&&Re.__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=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var o=a(Pe),l=a(Ce),u=n(xe),d=n(Ie),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=Me.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=Fe.Verb,t}();e.default=c})),Ue=Oe((function(t,e){var r=Re&&Re.__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=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=Re&&Re.__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=Re&&Re.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0,e.API=e.Tracker=void 0;var a=s(Ne);e.Tracker=a.default;var o=n(xe);e.API=o})),Be="ping",je="display",Ge="view";const He=["sitegroup_id","session_id","media_id","site_id","player_id","video_type"],Ve=["created","position"],Ke=["player_version","created","source","category","category_id","autoplay","muted","customer_user_id"];function qe(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 We(t,e,r){if(!e.segment_duration&&!qe(t,e))return;const i=function(t,e,r){const i=e.last_idx,n=r?99:ze(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(Be,{position:i})}function ze(t,e){return Math.min(Math.floor(t.currentTime/e.segment_duration),99)}const Ye="vod",Xe="live",Qe=[je,Be,Ge];function $e(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(Be,{position:60*e.ticks}))}(t,e);case"vod":return We(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 Je(){try{return window.location!==window.parent.location?document.referrer:document.location.href}catch(t){return!1}}class Analytics$1{init(t,e,r){if(!ce.from_token(t.token||"").is_granted(ce.permissions.ANALYTICS))return;if(r.hasState("consent-no-tracking"))return;if(r.analytics)return;const i=r.analytics={ticker:void 0,last_media_id:"",ended:!1},n={locked:!1,ttl:6e3,task:()=>{$e(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,player_version:"3.4.2"},a=Ue.Tracker.of(r,{verb:Ue.Tracker.verb.POST,url:"https://ptm.flowplayer.com/:video_type/:sitegroup_id/:event_type",events:Qe,required_keys:He,optional_keys:Ke.concat(Ve).slice(0),metadata:s});r.on(L,(function(){a&&a.destroy()})),r.on(w,(function(e){if(!a)return;const n=Nt(e,"data.metadata",{});if(!n.media_id)return;const s=Nt(a,"metadata.media_id");if(s&&n.media_id==s)return;const o=Nt(t,"analytics",{});a.put(n),a.put(o);const l=Nt(t,"metadata.live_start_time",t.live)?Xe:Ye;a.put({video_type:l,source:t.source||Je()||""}),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(je)}));let o=0;r.on(E,(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(Ge),o=0})).catch((function(){o=0}));i.last_media_id=a.metadata.media_id,r.emit(Ge)})),r.on("timeupdate",(function(){var e;a&&(o||Ze(r)||i.ended||(!t.live&&r.currentTime+.25>=r.duration&&$e(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(S,(function(){a&&i.ticker&&"vod"==i.ticker.kind&&function(t,e){qe(t,e),e.last_idx=ze(t,e)}(r,i.ticker)})),r.on(b,(function(){a&&function(t,e){e.ended||(e.ended=!0,$e(t,e.ticker))}(r,i)}))}}var tr;function er(t){switch(t){case tr.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case tr.MEDIA_ERR_NETWORK:return"a network error occurred";case tr.MEDIA_ERR_DECODE:return"unable to decode media content";case tr.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case tr.NO_INTERNET:return"no internet connection detected";case tr.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}function rr(){}function ir(){return"https:"===location.protocol}function nr(t){const e=document.createElement("a");return e.href=t,e}function sr(t){try{return!!new URL(t)}catch(t){return!1}}ie(ne(),Analytics$1),"undefined"!=typeof window&&window.matchMedia&&[D,R].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"}(tr||(tr={}));function ar(t,e){if(e.message)return e.message;if(e.stack)return e.stack;const r=e.code||-1,i=er(r);return t.i18n("media_errors."+r,i)}const or=()=>!0===(navigator||{}).onLine;function lr(t,e,r){const n=r.togglePlay;r.on(i,(function(t){const e=t.data||r.error,s="Error: %s\n"+(null===(a=(new Error).stack)||void 0===a?void 0:a.split("\n").slice(2).join("\n"));var a;setTimeout((function(){const a=xt(r,O);if(t.defaultPrevented||!a||r.root.querySelector("#qul_error"))return;if("AbortError"==e.name)return;r.setState("is-error",!0),r.togglePlay=rr;const o=function(t,e){return{code:"http:0"===e.code?ur(t):e.code,message:ar(t,e)}}(r,e);console.error(s,o.message);let l=xt(r,"flowplayer-error");l||(l=gt(r,"flowplayer-error"),a.append(l)),zt(l,i,{data:e,formatted_data:o}),r.once(m,()=>{r.togglePlay=n,r.setState("is-error",!1),null==l||l.remove()})}))}))}function ur(t){return function(t){try{return ir()&&"http:"==nr(t).protocol}catch(t){return!1}}(t.original_src)?{code:tr.MIXED_CONTENT}:or()?{code:tr.MEDIA_ERR_NETWORK}:or()?{code:tr.UNKNOWN}:{code:tr.NO_INTERNET}}var dr=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 cr(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")),hr(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(at)||t.setState(at,!0)}(r,e)),!document.fullscreenEnabled)return;const n=a();if(t)return n.requestFullscreen();i()===n&&document.exitFullscreen()},hr(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?h:f),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 hr(t){return r().ios&&"function"==typeof t.webkitEnterFullScreen&&"function"==typeof t.webkitExitFullScreen}function fr(t,e){const r=t.seekable;if("object"!=typeof t.opts||0==r.length)return{head:0,tail:0};const i=r.end(r.length-1),n=e||t.live_state.dvr_window;return{head:i,tail:"number"!=typeof n||i-n<0?r.start(0):i-n}}function pr(t){return t.opt("live",!1)||t.duration>=Number.MAX_SAFE_INTEGER}function gr(t){return isFinite(t.duration)?t.duration:0==t.seekable.length?0:fr(t).head}function vr(t){return function(t){return fr(t).head}(t)-.5}function mr(t,e,r){if(!r.reaper)return;const i=document.createDocumentFragment(),n=gt(r,O);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=Ft("fp-footer");e.append(i),r.on(w,(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=Ft("fp-title");t.innerText=s,i.append(t)}if("string"==typeof n){const t=n.split(" "),e=Ft("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),lr(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)}))}),cr(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=>{t.live&&!1!==r.live_state.dvr&&function(t,e,r){if(0==e)return!0;const i=fr(t,r);return i.head-i.tail>=e}(r,t.seconds_to_dvr||60,e.detail)&&(r.live_state.dvr=r.seekable.length>0,r.live_state.dvr_window=e.detail)}),r.on("live",()=>{const t=setInterval(()=>{if(r.opts.live&&!r.hasState("is-error")&&0!=r.reaper||clearInterval(t),0==r.seekable.length)return;const e=function(t){var e;const r=t.currentTime,i=fr(t),n=!t.hasState("is-chromecast-playing")&&(null===(e=t.hls)||void 0===e?void 0:e.liveSyncPosition);return{progress:Math.min(100,Math.max(0,(r-i.tail)/(i.head-i.tail)*100)),is_live:r-(n||i.head)>=-10}}(r);r.hasState(nt)==e.is_live&&r.setState(nt,!e.is_live),r.live_state.dvr&&r.emit("dvr",e.progress)},200)}),r.on(p,(function(){r.setOpts({live:pr(r)})})),r.on("durationchange",(function(t){const e=pr(r),i=e?gr(r):t.data||r.duration;isNaN(i)||r.setOpts({live:e,duration:i})})),r.on(w,(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;[u,d].forEach(t=>n.addEventListener(t,(function(t){r.hasState("is-touch-device")&&t.type===u||("number"==typeof a&&clearTimeout(a),r.setState("is-hovered",!0),a=0==r.paused&&setTimeout((function(){r.setState("is-hovered",!1)}),2e3))})))}function yr(t,e,r){if(ce.from_token(t.token||"").is_granted(ce.permissions.NO_METERING))return;const i=le.id(t.token||"");i&&r.once(E,()=>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 Er={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=Er;const Tr="health:record",_r="rebuffer";var br=Object.freeze({__proto__:null,RECORD:Tr,REBUFFER:_r});function Sr(t,e){const r=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...n)=>{const s=(null==e?void 0:e.debug)||r;s&&t.match(s)&&console.log(`flowplayer/${t} -- ${i}`,...n)};return i.log=i,i}const Ar=navigator;function Lr(t){var e,r;const i=null===(e=t.hls)||void 0===e?void 0:e.bandwidthEstimate;return i?1e-6*i:(null===(r=Ar.connection)||void 0===r?void 0:r.downlink)||-1}function wr(t,e){return function(t,e){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,e)}(t,JSON.stringify({events:e}))}const Dr="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),Rr=window,kr=Rr._flowplayerTimekeeper||(Rr._flowplayerTimekeeper={});async function Or(){const t=kr.cachedServerOffset;if(t)return t;const e=kr.pendingRequest||(kr.pendingRequest=fetch(Dr)),r=await e,i=parseInt(r.headers.get("age")||"0"),n=await r.json(),s=Date.now()-n.millisUtc-1e3*i;return kr.cachedServerOffset=s,kr.cachedServerOffset}const Ir=t=>{switch(t){case!0:return yt.ON;case!1:return yt.OFF;default:return t}},Cr=[];function Pr(t){if(t.suspended)return;const e=Cr.slice(0);Cr.length=0,0!=e.length&&(t.logger.log(`:dispatch events={${e.length}}`),wr("https://ihi.flowplayer.com/v1/health/events",e))}async function xr(t,e,r){const i=await Fr();Cr.push(Object.assign(e,i)),t.logger.log(":enqueue",e.event,e),Cr.length<10&&!r||Pr(t)}const Mr=()=>{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}},Fr=async()=>{const t=Date.now();try{return{adjusted_time:t-await Or(),client_time:t}}catch(e){return{client_time:t}}},Nr=(t,e)=>Object.assign(t,{detail:e}),Ur=(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.4.2",commit:"01d44d5db5202dd3a2d8dea07785c5a796e4a648",ima_sdk_version:Mr(),preload:t.opt("preload"),autoplay:Ir(t.opt("autoplay")),live:t.opt("live"),dvr:!!t.live_state.dvr,source:t.original_src,downlink_mbs:Lr(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")}),Br=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 jr(t,e,r,i){const n=Ur(e,t.eventInfo(r)),{before:s,after:a}=i;xr(t,((t,e,r)=>Object.assign(t,{state:{before:e,after:r}}))(n,Br(s),Br(a)))}const Gr=(t,e)=>{let r=null;return(...i)=>{null!==r&&(clearTimeout(r),r=null),r=setTimeout(()=>e(...i),t)}},Hr=Vt();class Health{constructor(t,e){this.session_id=Hr,this.suspended=!1,this.logger=Sr("health",e.opts),this.media_session_id=Vt(),this.analyticsLoop=setInterval(()=>Pr(this),2e3),e.on(L,()=>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(()=>Pr(this),2e3)}init(t,e,r){!function(t){t.on(T,(function(e){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(_r)}))}(r),r.on(Tr,({detail:t})=>{const e=Ur(r,this.eventInfo(t.event));Object.assign(e,t.detail||{}),xr(this,e)}),[_,m,a,p,g,v,T,_r].forEach(t=>{r.on(t,t=>{xr(this,Ur(r,this.eventInfo(t.type)))})}),[E,y,A,S,b,h,f].forEach(t=>{r.on(t,t=>{xr(this,Ur(r,this.eventInfo(t.type)))})}),r.on("volumechange",Gr(800,t=>{const e=Ur(r,this.eventInfo(t.type));xr(this,Nr(e,{volume:parseFloat(r.volume.toFixed(2)),muted:r.muted}))})),r.on("resize",Gr(800,t=>{const i=Ur(r,this.eventInfo(t.type));xr(this,Nr(i,{height:e.clientHeight,width:e.clientWidth}))})),r.on("hls/failover",t=>{const e=Ur(r,this.eventInfo(t.type)),i=t.detail,{reason:n,from:s}=i;xr(this,Nr(e,{reason:n,from:s}))}),r.on("qualitychange",({type:t,detail:e})=>{switch(e.kind){case"hls":return jr(this,r,t,e)}});let n=Date.now()+5e3;r.on("timeupdate",t=>{if(Date.now()<n)return;n=Date.now()+5e3;const e=Ur(r,this.eventInfo(t.type));var i;xr(this,Nr(e,{duration:(i=r.duration,Number.isFinite(i)?i:i===1/0?-1:void 0)}))}),r.addEventListener(i,t=>{const e=Ur(r,this.eventInfo(t.type)),i=t.error||r.error;if(!i)return xr(this,e,!0);const n=i.code,s={error_message:i.message||er(n),error_code:n,error_stack:i.stack||""};return xr(this,Nr(e,s),!0)}),r.on("src",t=>{var e;const i=null===(e=t.detail)||void 0===e?void 0:e.src;if("string"!=typeof i)return;if(!sr(r.original_src))return;if(!sr(i))return;if(i==r.original_src)return;this.media_session_id=Vt();xr(this,Ur(r,this.eventInfo(t.type))),Pr(this)}),r.on("visibilitychange",t=>{xr(this,Ur(r,this.eventInfo(t.type))),Pr(this)})}}Health.events=br,Health._UNLOAD_SUBSCRIBED=!1,ie(window,Health);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(w,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(w,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)?Bt(r):""})}}const Vr={name:"fp-fullscreen",translation_key:"core.fullscreen"},Kr={name:"fp-fullscreen-exit",translation_key:"core.exit_fullscreen"},qr={name:"fp-play",translation_key:"core.play"},Wr={name:"fp-pause",translation_key:"core.pause"},zr={translation_key:"core.mute",name:"fp-volume-mute-unmute"},Yr={translation_key:"core.play",name:"fp-small-play"},Xr={translation_key:"core.pause",name:"fp-small-pause"},Qr={name:"fp-fast-forward"},$r={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),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),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=>{var e;const r=t.root.querySelector("details[open].fp-menu-container");r&&(r.open=!1,null===(e=r.querySelector("summary"))||void 0===e||e.removeAttribute("aria-expanded"),t.root.classList.toggle("has-menu-opened",!1))}),this.active_menu=void 0)}));const Zr={passive:!0};var Jr;function ti(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(Jr.GRABBING),a.remove(Jr.TOUCHING);const o=e.onseek||rr,l=e.onstart||rr,h=e.onend||rr,f=e.onmouse||rr,p=e.ontouch||rr,g=e.ontouchend||rr;function v(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 m(e){const r=v(e);r!=n&&(o(t,r),n=r)}return t.addEventListener("touchstart",(function(e){ei(t,e)&&(a.add(Jr.TOUCHING),ri(t.parentElement)&&(a.add(Jr.GRABBING),p(t,v(e)),l(t,v(e)),m(e)))}),Zr),t.addEventListener(d,(function(e){m(e),f(t,v(e))}),Zr),t.addEventListener(c,(function(e){setTimeout((function(){a.remove(Jr.TOUCHING)}),500),ei(t,e)&&(a.remove(Jr.GRABBING),g(t,v(e)),h(t,v(e)),i=0)}),Zr),t.addEventListener("touchcancel",(function(){a.remove(Jr.GRABBING,Jr.TOUCHING),i=0}),Zr),t.addEventListener("mousedown",(function(e){a.contains(Jr.TOUCHING)||(document.addEventListener(u,m),a.add(Jr.GRABBING),l(t,v(e)),e.preventDefault(),m(e))})),t.addEventListener(u,(function(e){a.contains(Jr.TOUCHING)||f(t,v(e))})),document.addEventListener("mouseup",(function(e){a.contains(Jr.TOUCHING)||(document.removeEventListener(u,m),a.contains(Jr.GRABBING)&&(a.remove(Jr.GRABBING),h(t,v(e)),i=0))})),t}function ei(t,e){const r=e.target;return!!r&&(r&&!r.closest(t.id)||!ri(t.parentElement)||!t.classList.contains(Jr.TOUCHING))}function ri(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"}(Jr||(Jr={}));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),ti(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(Jr.GRABBING)||e&&"number"==typeof r&&(4&r)>0||this.adjustVolumeSlider(t.volume)})}adjustVolumeSlider(t){this.setAttribute("aria-valuenow",t.toString()),this.setAttribute("aria-valuetext",Math.round(100*t)+"%");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 ii(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 ni(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 si(t,e){t.style.width="0",e.style.display="none"}function ai(t,e,r){if(!e.seekable||0==e.seekable.length)return;ii(r,t);const i=fr(e),n=(100-Math.max(0,Math.min(t,100)))/100*(i.head-i.tail);r.innerText="-"+Bt(n)}function oi(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=fr(t);return r.tail+e*(r.head-r.tail)}(e,t)}function li(t,e){t.style.width="0",e.style.display="none"}class FlowplayerTimelineBar extends FlowplayerComponent{constructor(t){let e;super(t),this.bufferEle=Ft("fp-buffer"),this.progress=Ft("fp-progress","fp-color"),this.tooltipEle=Ft("fp-timestamp"),this.proposedSeekBar=Ft("fp-hover"),this.dragger=Ft("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.setAttribute("aria-valuenow","0"),this.progress.append(this.dragger),this.append(this.bufferEle,this.progress,this.proposedSeekBar,this.tooltipEle);let r=!1;const i=requestAnimationFrame;let n=void 0;const s=()=>{0==t.reaper||e.live||(!function(t,e){e.style.width=t.currentTime/t.duration*100+"%"}(t,this.progress),n=void 0,t.paused||this.classList.contains(Jr.GRABBING)||n||(n=setTimeout(s,200)))},a=()=>!!this.player.opt("seekable",!0)&&!isNaN(this.player.duration);ti(this,{onseek:(r,i)=>{if(a())switch(!!e.live){case!0:ai(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),ii(this.tooltipEle,i)}},onstart:()=>{a()&&(t.emit("timeline/gesture/start"),!t.hasState("is-casting")&&t.setState(et,!0),e.live||function(t){t.style.display="block"}(this.tooltipEle))},onend:function(r,n){i(s),0!=e.seekable&&e.live&&oi(n,t)},ontouch:function(){t.paused||(r=!0,t.pause())},ontouchend:()=>{r&&(r=!1,t.play()),e.live?li(this.proposedSeekBar,this.tooltipEle):si(this.proposedSeekBar,this.tooltipEle),setTimeout(()=>t.emit("timeline/gesture/end"),0)},onmouse:(r,i)=>{if(a()&&(t.emit("timeline/gesture/move",{percent:i}),!this.classList.contains(Jr.GRABBING)))switch(!!e.live){case!0:!function(t,e){e.style.width=t+"%"}(i,this.proposedSeekBar),ai(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;ii(r,t),r.innerHTML="";const i=document.createElement("span");i.innerText=Bt(t/100*e.duration),r.append(i)}(i,t,this.tooltipEle)}}}),t.on(w,(function(t){t.data&&(e=t.data)})),t.on(E,()=>i(s)),t.on(v,()=>{0==t.reaper||e.live||ni(t,this.bufferEle)}),t.on("dvr",t=>{this.progress.style.width=t.detail+"%"}),t.on("timeupdate",()=>{0!=t.reaper&&(i(s),this.setAttribute("aria-valuenow",t.currentTime+""),this.setAttribute("aria-valuetext",Math.round(t.currentTime)+t.i18n("core.sec","sec")),e.live||ni(t,this.bufferEle))}),t.on(p,()=>{0!=t.reaper&&(e.live||ni(t,this.bufferEle))}),t.on("durationchange",e=>{if(0==t.reaper)return;const r=pr(t)?gr(t):e.data||t.duration;isNaN(r)||(this.setAttribute("aria-valuemax",r+""),this.setAttribute("aria-valuemin","0"))}),this.addEventListener(l,()=>{t.emit("timeline/gesture/end"),e.live?li(this.proposedSeekBar,this.tooltipEle):si(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=xt(t,I))||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=Ft("fp-live-text"),r=Ft("fp-live-indicator","fp-color");e.textContent="live",this.append(r,e),this.addEventListener(n,(function(){!function(t){try{t.dvr_offset=0,t.currentTime=vr(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"),this.setAttribute("aria-hidden","true"),t.on(w,r=>{if(0==t.reaper||!r.data)return;e=r.data;const i=pr(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=Bt(i)}),t.on(p,()=>{0==t.reaper||e.live||function(t,e){t.duration&&(e.innerText=Bt(t.duration))}(t,this)})}}class FlowplayerElapsedTime extends FlowplayerComponent{constructor(t){let e;super(t),this.classList.add("fp-elapsed"),this.innerText=Bt(0),this.setAttribute("aria-hidden","true"),t.on(w,t=>{t.data&&(e=t.data)}),t.on("timeupdate",()=>{0!=t.reaper&&(e.live?function(t,e){e.innerText=Bt(t.currentTime)}(t,this):function(t,e){e.innerText=Bt(t.currentTime)}(t,this))})}}class FlowplayerControlButtons extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-btns","fp-small-switch");const e=gt(t,V),r=gt(t,H);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=gt(t,this.classList.contains("fp-left-zone")?W:"flowplayer-fast-forward-icon");n.removeAttribute("tabindex"),i.classList.add("fp-zone-seconds"),this.append(i,n);t.on(S,()=>{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(c,(function(e){isNaN(t.duration)||isNaN(t.currentTime)||16384&t.opt("ui")||t.hasState(st)||!t.hasState("will-seek")&&!t.hasState(at)||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 FlowplayerError extends FlowplayerComponent{constructor(t){super(t),this.className="fp-error",this.message=document.createElement("p"),this.message.className="error-message",this.append(this.message),this.addEventListener("error",t=>{const e=t.detail;e&&(this.message.textContent=e.formatted_data.message)})}}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,q].forEach(e=>{const r=gt(t,e);r.removeAttribute("tabindex"),this.append(r)})}}class FlowplayerVolumeControl extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-volume-control");const e=gt(t,z);this.append(e),!r().ios&&this.append(gt(t,M)),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",N)),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",C,P,x,"flowplayer-control-duration","flowplayer-volume-control"))}}class FullscreenIcon extends FlowplayerIcon{constructor(t,e){super(t,e),this.setAttribute("role","button")}}class FlowplayerMiddle extends FlowplayerComponent{constructor(t){super(t),this.classList.add("fp-middle"),this.append(...t.createComponents("flowplayer-middle-left-zone",j,"flowplayer-middle-right-zone")),this.setAttribute("tabindex","0"),t.reaper&&t.reaper.set("middle",this),this.handleClick(t),this.handleTouch(t),[E,S].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&&!t.hasState("is-endscreen"))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(c,(function(e){e.cancelable&&!t.hasState("is-endscreen")&&(e.preventDefault(),t.emit(e.type,{source:e}))})),t.on(c,(function(r){setTimeout((function(){if(r.defaultPrevented)return;if(t.hasState(it))return;if(t.ended)return t.togglePlay(!0);const i=t.hasState(tt);e&&clearTimeout(e),(i||t.hasState(at)||t.hasState("no-autoplay"))&&(t.hasState(at)&&(t.setState(at,!1),t.setState("is-hovered",!1)),t.togglePlay(),i)||(t.setState(at,!0),t.paused||(e=setTimeout((function(){e=!1,t.setState(at,!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(F,B,I))}}De.extensions.unshift.apply(De.extensions,[I18n,Analytics$1,Health,class Default{constructor(t){vt(t,O,FlowplayerUi),vt(t,"flowplayer-error",FlowplayerError),vt(t,I,FlowplayerControls),vt(t,C,FlowplayerLiveStatus),vt(t,"flowplayer-control-duration",FlowplayerDuration),vt(t,x,t.extensions.find(t=>"Chapters"===t.name)?FlowplayerChaptersTimelineBar:FlowplayerTimelineBar),vt(t,P,FlowplayerElapsedTime),vt(t,M,FlowplayerVolumeBar),vt(t,"flowplayer-volume-control",FlowplayerVolumeControl),vt(t,"flowplayer-control-buttons",FlowplayerControlButtons),vt(t,F,FlowplayerHeader),vt(t,U,FlowplayerPrimary),vt(t,"flowplayer-header-duration",FlowplayerHeaderDuration),vt(t,"flowplayer-header-left-zone",class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-left",U,"flowplayer-header-duration")}}),vt(t,N,class extends FlowplayerHeaderLeftRight{constructor(t){super(t,"fp-right fp-togglable","flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon")}}),vt(t,B,FlowplayerMiddle),vt(t,j,FlowplayerMiddleZone),vt(t,G,FlowplayerMiddleWait),vt(t,"flowplayer-middle-buttons",FlowplayerMiddleButtons),vt(t,"flowplayer-middle-right-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-right-zone")}}),vt(t,"flowplayer-middle-left-zone",class extends FlowplayerLeftRightZone{constructor(t){super(t,"fp-left-zone")}}),vt(t,H,class extends FlowplayerIcon{constructor(t){super(t,Yr),this.setAttribute("role","button")}}),vt(t,V,class extends FlowplayerIcon{constructor(t){super(t,Xr),this.setAttribute("role","button")}}),vt(t,K,class extends FlowplayerIcon{constructor(t){super(t,qr),this.setAttribute("role","button")}}),vt(t,q,class extends FlowplayerIcon{constructor(t){super(t,Wr),this.setAttribute("role","button")}}),vt(t,"flowplayer-fullscreen-enter-icon",class extends FullscreenIcon{constructor(t){super(t,Vr)}}),vt(t,"flowplayer-fullscreen-exit-icon",class extends FullscreenIcon{constructor(t){super(t,Kr)}}),vt(t,"flowplayer-fast-forward-icon",class extends FlowplayerIcon{constructor(t){super(t,Qr)}}),vt(t,W,class extends FlowplayerIcon{constructor(t){super(t,$r)}}),vt(t,z,class extends FlowplayerIcon{constructor(t){super(t,zr),this.classList.add("fp-volumebtn"),this.setAttribute("role","switch"),t.on("volumechange",()=>{const e=0==t.volume||t.muted;this.setAttribute("aria-label",t.i18n("core.muted","Muted")),this.setAttribute("aria-checked",e?"true":"false")})}})}init(t,e,r){yr(t,0,r),mr(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 ui=Object.assign(De,{ui:dr,i18n:I18n}),di=ke(Oe((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":
|
|
2
2
|
/*!*********************************************!*\
|
|
3
3
|
!*** ./node_modules/eventemitter3/index.js ***!
|
|
4
4
|
\*********************************************/
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
/*!***********************!*\
|
|
15
15
|
!*** ./src/config.ts ***!
|
|
16
16
|
\***********************/
|
|
17
|
-
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,r){r.r(e),r.d(e,"hlsDefaultConfig",(function(){return S})),r.d(e,"mergeConfig",(function(){return A})),r.d(e,"enableStreamingMode",(function(){return L}));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(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),g=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function E(){return(E=Object.assign?Object.assign.bind():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){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
|
|
17
|
+
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,e,r){r.r(e),r.d(e,"hlsDefaultConfig",(function(){return S})),r.d(e,"mergeConfig",(function(){return A})),r.d(e,"enableStreamingMode",(function(){return L}));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(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),g=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function E(){return(E=Object.assign?Object.assign.bind():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){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){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?T(Object(r),!0).forEach((function(e){b(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function b(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var S=_(_({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!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:p.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,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:v.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!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,cmcdController:f.default});function A(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 E({},t,e)}function L(t){var e=t.loader;e!==g.default&&e!==p.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(g.fetchSupported)()&&(t.loader=g.default,t.progressive=!0,t.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
18
18
|
/*!******************************************!*\
|
|
19
19
|
!*** ./src/controller/abr-controller.ts ***!
|
|
20
20
|
\******************************************/
|
|
21
|
-
/*! 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,v=p[t.level],m=d.total||Math.max(d.loaded,Math.round(c*v.maxBitrate/8)),y=Math.max(1,d.bwEstimate?d.bwEstimate/8:1e3*d.loaded/h),E=(m-d.loaded)/y,T=l.currentTime,
|
|
21
|
+
/*! 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,v=p[t.level],m=d.total||Math.max(d.loaded,Math.round(c*v.maxBitrate/8)),y=Math.max(1,d.bwEstimate?d.bwEstimate/8:1e3*d.loaded/h),E=(m-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)}}},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,v=n.abrBandWidthFactor,m=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"),v=m=1)}return p=this.findBestLevel(h,s,i,f+g,v,m),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,v=r;v>=e;v--){var m=c[v];if(m&&(!p||m.codecSet===p)){var y=m.details,E=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||g,T=void 0;T=v<=d?n*t:s*t;var _=c[v].maxBitrate,b=_*E/T;if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+v+"/"+Math.round(T)+"/"+_+"/"+E+"/"+i+"/"+b),T>_&&(!b||f&&!this.bitrateTestDelay||b<i))return v}}return-1},e=t,(r=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;var r=this.getNextABRAutoLevel();return-1!==t&&this.hls.levels[r].loadError?t:(-1!==t&&(r=Math.min(t,r)),r)},set:function(t){this._nextAutoLevel=t}}])&&d(e.prototype,r),c&&d(e,c),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.default=c},"./src/controller/audio-stream-controller.ts":
|
|
22
22
|
/*!***************************************************!*\
|
|
23
23
|
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
24
24
|
\***************************************************/
|
|
25
|
-
/*! 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"),v=r(/*! ../errors */"./src/errors.ts");function m(){return(m=Object.assign?Object.assign.bind():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 y(t,e){return(y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var E=function(t){var e,r;function E(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.bufferFlushed=!1,i.cachedTrackLoadedData=null,i._registerListeners(),i}r=t,(e=E).prototype=Object.create(r.prototype),e.prototype.constructor=e,y(e,r);var T=E.prototype;return T.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},T._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)},T._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)},T.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()}},T.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)),t=e,this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},T.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.resetStartWhenNotLoaded(this.trackId),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.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var v={frag:c,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&t.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),y=a.BufferHelper.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},T.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},T.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},T.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}},T.doTickIdle=function(){var t,e,r=this.hls,i=this.levels,a=this.media,o=this.trackId,l=r.config;if(i&&i[o]&&(a||!this.startFragRequested&&l.startFragPrefetch)){var c=i[o].details;if(!c||c.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(c))this.state=n.State.WAITING_TRACK;else{var h=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&h&&(this.bufferFlushed=!1,this.afterBufferFlushed(h,d.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(h,u.PlaylistLevelType.AUDIO);if(null!==f){var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN),g=f.len,v=this.getMaxBufferLength(null==p?void 0:p.len),m=this.audioSwitch;if(!(g>=v)||m){if(!m&&this._streamEnded(f,c))return r.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var y=c.fragments[0].start,E=f.end;if(m&&a){var T=this.getLoadPosition();E=T,c.PTSKnown&&T<y&&(f.end>y||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=y+.05)}if(!(p&&E>p.end+c.targetduration)&&(p&&p.len||!f.len)){var b=this.getNextFragment(E,c);b?"identity"!==(null===(t=b.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=b.decryptdata)&&void 0!==e&&e.key?this.loadFragment(b,c,E):this.loadKey(b,c):this.bufferFlushed=!0}}}}}},T.getMaxBufferLength=function(e){var r=t.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},T.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},T.onAudioTracksUpdated=function(t,e){var r=e.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(t){return new l.Level(t)}))},T.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()},T.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},T.onLevelLoaded=function(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},T.onAudioTrackLoaded=function(t,e){var r;if(null!=this.mainDetails){var 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=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?(Object(g.alignMediaPlaylistByPDT)(s,u),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)}else this.cachedTrackLoadedData=e},T._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",v=this.transmuxer;v||(v=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],y=null===(e=r.initSegment)||void 0===e?void 0:e.data;if(void 0!==m){var E=i?i.index:-1,T=-1!==E,b=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,s.byteLength,E,T);v.push(s,y,g,"",r,i,p.totalduration,!1,b,m)}else this.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")},T._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},T.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},T.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)},T.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)))},T.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=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(i=!this.reduceMaxBufferLength(s.len)),i&&(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")),this.resetLoadingState()}}},T.onBufferFlushed=function(t,e){e.type===d.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},T._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.resetStartWhenNotLoaded(o.level);var u=l.frag,c=l.part,h=l.level.details,f=a.audio,p=a.text,g=a.id3,v=a.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=n.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=v&&v.tracks&&(this._bufferInitSegment(v.tracks,u,o),i.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:v.tracks})),f){var y=f.startPTS,E=f.endPTS,T=f.startDTS,b=f.endDTS;c&&(c.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:y,endPTS:E,startDTS:T,endDTS:b}),u.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,y,E,T,b),this.bufferFragmentData(f,u,c,o)}if(null!=g&&null!==(e=g.samples)&&void 0!==e&&e.length){var _=m({id:r,frag:u,details:h},g);i.trigger(s.Events.FRAG_PARSING_METADATA,_)}if(p){var S=m({id:r,frag:u,details:h},p);i.trigger(s.Events.FRAG_PARSING_USERDATA,S)}}},T._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()}}},T.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)))},T.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})},E}(n.default);e.default=E},"./src/controller/audio-track-controller.ts":
|
|
25
|
+
/*! 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"),v=r(/*! ../errors */"./src/errors.ts");function m(){return(m=Object.assign?Object.assign.bind():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 y(t,e){return(y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var E=function(t){var e,r;function E(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.bufferFlushed=!1,i.cachedTrackLoadedData=null,i._registerListeners(),i}r=t,(e=E).prototype=Object.create(r.prototype),e.prototype.constructor=e,y(e,r);var T=E.prototype;return T.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},T._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)},T._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)},T.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()}},T.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)),t=e,this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},T.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.resetStartWhenNotLoaded(this.trackId),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.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var v={frag:c,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&t.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),y=a.BufferHelper.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);Object(p.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},T.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},T.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},T.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}},T.doTickIdle=function(){var t,e,r=this.hls,i=this.levels,a=this.media,o=this.trackId,l=r.config;if(i&&i[o]&&(a||!this.startFragRequested&&l.startFragPrefetch)){var c=i[o].details;if(!c||c.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(c))this.state=n.State.WAITING_TRACK;else{var h=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&h&&(this.bufferFlushed=!1,this.afterBufferFlushed(h,d.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(h,u.PlaylistLevelType.AUDIO);if(null!==f){var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN),g=f.len,v=this.getMaxBufferLength(null==p?void 0:p.len),m=this.audioSwitch;if(!(g>=v)||m){if(!m&&this._streamEnded(f,c))return r.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var y=c.fragments[0].start,E=f.end;if(m&&a){var T=this.getLoadPosition();E=T,c.PTSKnown&&T<y&&(f.end>y||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=y+.05)}if(!(p&&E>p.end+c.targetduration)&&(p&&p.len||!f.len)){var _=this.getNextFragment(E,c);_?"identity"!==(null===(t=_.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=_.decryptdata)&&void 0!==e&&e.key?this.loadFragment(_,c,E):this.loadKey(_,c):this.bufferFlushed=!0}}}}}},T.getMaxBufferLength=function(e){var r=t.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},T.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},T.onAudioTracksUpdated=function(t,e){var r=e.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(t){return new l.Level(t)}))},T.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()},T.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},T.onLevelLoaded=function(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},T.onAudioTrackLoaded=function(t,e){var r;if(null!=this.mainDetails){var 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=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?(Object(g.alignMediaPlaylistByPDT)(s,u),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)}else this.cachedTrackLoadedData=e},T._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",v=this.transmuxer;v||(v=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],y=null===(e=r.initSegment)||void 0===e?void 0:e.data;if(void 0!==m){var E=i?i.index:-1,T=-1!==E,_=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,s.byteLength,E,T);v.push(s,y,g,"",r,i,p.totalduration,!1,_,m)}else this.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")},T._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,e)},T.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},T.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)},T.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)))},T.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=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(i=!this.reduceMaxBufferLength(s.len)),i&&(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")),this.resetLoadingState()}}},T.onBufferFlushed=function(t,e){e.type===d.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},T._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.resetStartWhenNotLoaded(o.level);var u=l.frag,c=l.part,h=l.level.details,f=a.audio,p=a.text,g=a.id3,v=a.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=n.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=v&&v.tracks&&(this._bufferInitSegment(v.tracks,u,o),i.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:v.tracks})),f){var y=f.startPTS,E=f.endPTS,T=f.startDTS,_=f.endDTS;c&&(c.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:y,endPTS:E,startDTS:T,endDTS:_}),u.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,y,E,T,_),this.bufferFragmentData(f,u,c,o)}if(null!=g&&null!==(e=g.samples)&&void 0!==e&&e.length){var b=m({id:r,frag:u,details:h},g);i.trigger(s.Events.FRAG_PARSING_METADATA,b)}if(p){var S=m({id:r,frag:u,details:h},p);i.trigger(s.Events.FRAG_PARSING_USERDATA,S)}}},T._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()}}},T.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)))},T.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})},E}(n.default);e.default=E},"./src/controller/audio-track-controller.ts":
|
|
26
26
|
/*!**************************************************!*\
|
|
27
27
|
!*** ./src/controller/audio-track-controller.ts ***!
|
|
28
28
|
\**************************************************/
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
/*!**************************************************!*\
|
|
35
35
|
!*** ./src/controller/base-stream-controller.ts ***!
|
|
36
36
|
\**************************************************/
|
|
37
|
-
/*! exports provided: State, default */function(t,e,r){r.r(e),r.d(e,"State",(function(){return _})),r.d(e,"default",(function(){return S}));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(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ./level-helper */"./src/controller/level-helper.ts"),g=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=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(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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function b(t,e){return(b=Object.setPrototypeOf?Object.setPrototypeOf.bind():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",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},S=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=null,n.mediaBuffer=null,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 v.default(e,e.config),e.on(l.Events.KEY_LOADED,n.onKeyLoaded,T(n)),e.on(l.Events.LEVEL_SWITCHING,n.onLevelSwitching,T(n)),n}r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,b(e,r);var S,A,L,w=n.prototype;return w.doTick=function(){this.onTickEnd()},w.onTickEnd=function(){},w.startLoad=function(t){},w.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},w._streamEnded=function(t,e){var r=this.fragCurrent,i=this.fragmentTracker;if(!e.live&&r&&this.media&&r.sn>=e.endSN&&!t.nextStart){var n=e.partList;if(null!=n&&n.length){var o=n[n.length-1];return a.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var l=i.getState(r);return l===s.FragmentState.PARTIAL||l===s.FragmentState.OK}return!1},w.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)},w.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&&this.onvseeking&&this.onvended&&(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()},w.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=o>e.start+e.duration+u;(o<d||c)&&(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.tickImmediate()},w.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},w.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)}},w.onLevelSwitching=function(t,e){this.fragLoadError=0},w.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},w.onHandlerDestroyed=function(){this.state=_.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,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)},w.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})},w.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},w._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;i.fragContextChanged(t)?(r===_.FRAG_LOADING||!i.fragCurrent&&r===_.PARSING)&&(i.fragmentTracker.removeFragment(t),i.state=_.IDLE):("payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(l.Events.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(e){i.state!==_.STOPPED&&i.state!==_.ERROR&&(i.warn(e),i.resetFragmentLoading(t))}))},w.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},w._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=t.stats;e.state=_.IDLE,e.fragLoadError=0,t.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:t.type}),e.tick()})).catch((function(r){e.state!==_.STOPPED&&e.state!==_.ERROR&&(e.warn(r),e.resetFragmentLoading(t))}))},w.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},w.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+" "+(r?m.default.toString(a.BufferHelper.getBuffered(r)):"(detached)")),this.state=_.IDLE,r&&(!this.loadedmetadata&&r.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},w.seekToStartPos=function(){},w._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 d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);e.flush(a)}},w._handleFragmentLoadProgress=function(t){},w._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)}))},w.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)}))},w.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},w._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)},w.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?Object(p.getPartWith)(s,i,n):null,o=a?a.fragment:Object(p.getFragmentWithSN)(s,i,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},w.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(c.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)}}},w.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)},w.getFwdBufferInfo=function(t,e){var r=this.config,n=this.getLoadPosition();if(!Object(i.isFiniteNumber)(n))return null;var s=a.BufferHelper.bufferInfo(t,n,r.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,e);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,n,Math.max(s.nextStart,r.maxBufferHole))}return s},w.getMaxBufferLength=function(t){var e,r=this.config;return e=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(e,r.maxMaxBufferLength)},w.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)},w.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.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]);if(!n){var l=s.lowLatencyMode?e.partEnd:e.fragmentEnd;n=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(n)},w.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},w.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},w.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},w.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(f.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(f.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},w.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(f.findFragmentByPTS)(a,o,t,h)}else i=o[o.length-1];if(i){var p=i.sn-r.startSN;if(a&&i.sn===a.sn&&!c&&a&&i.level===a.level){var g=o[p+1];i.sn<l&&this.fragmentTracker.getState(g)!==s.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+g.sn),i=g):i=null}}return i},w.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))}}},w.alignPlaylists=function(t,e){var r=this.levels,n=this.levelLastLoaded,s=this.fragPrevious,a=null!==n?r[n]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!e,d=t.alignedSliding&&Object(i.isFiniteNumber)(l);if(u||!d&&!l){Object(h.alignStream)(s,a,t);var c=t.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(s?s.sn:"na")+" fragments: "+o),c}return l},w.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},w.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=t.startTimeOffset;Object(i.isFiniteNumber)(n)?(r=e+n,n<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},w.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},w.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},w.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===_.FRAG_LOADING_WAITING_RETRY)||(this.state=_.IDLE)},w.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){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);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)}}},w.afterBufferFlushed=function(t,e,r){if(t){var i=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===_.ENDED&&this.resetLoadingState()}},w.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=_.IDLE},w.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},w.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+")"),e||!1;var d=i?0:Object(p.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:d,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1)||(this.warn("Found no media in fragment "+t.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=_.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})},w.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S=n,(A=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}])&&E(S.prototype,A),L&&E(S,L),Object.defineProperty(S,"prototype",{writable:!1}),n}(n.default)},"./src/controller/buffer-controller.ts":
|
|
37
|
+
/*! exports provided: State, default */function(t,e,r){r.r(e),r.d(e,"State",(function(){return b})),r.d(e,"default",(function(){return S}));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(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ./level-helper */"./src/controller/level-helper.ts"),g=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=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(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){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _(t,e){return(_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var b={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",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},S=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=b.STOPPED,n.media=null,n.mediaBuffer=null,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 v.default(e,e.config),e.on(l.Events.KEY_LOADED,n.onKeyLoaded,T(n)),e.on(l.Events.LEVEL_SWITCHING,n.onLevelSwitching,T(n)),n}r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,_(e,r);var S,A,L,w=n.prototype;return w.doTick=function(){this.onTickEnd()},w.onTickEnd=function(){},w.startLoad=function(t){},w.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=b.STOPPED},w._streamEnded=function(t,e){var r=this.fragCurrent,i=this.fragmentTracker;if(!e.live&&r&&this.media&&r.sn>=e.endSN&&!t.nextStart){var n=e.partList;if(null!=n&&n.length){var o=n[n.length-1];return a.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var l=i.getState(r);return l===s.FragmentState.PARTIAL||l===s.FragmentState.OK}return!1},w.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===b.STOPPED&&this.startLoad(i.startPosition)},w.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&&this.onvseeking&&this.onvended&&(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()},w.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===b.ENDED)this.resetLoadingState();else if(e&&!l.len){var u=t.maxFragLookUpTolerance,d=e.start-u,c=o>e.start+e.duration+u;(o<d||c)&&(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.tickImmediate()},w.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},w.onKeyLoaded=function(t,e){if(this.state===b.KEY_LOADING&&e.frag===this.fragCurrent&&this.levels){this.state=b.IDLE;var r=this.levels[e.frag.level].details;r&&this.loadFragment(e.frag,r,e.frag.start)}},w.onLevelSwitching=function(t,e){this.fragLoadError=0},w.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},w.onHandlerDestroyed=function(){this.state=b.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,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)},w.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=b.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(l.Events.KEY_LOADING,{frag:t})},w.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},w._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;i.fragContextChanged(t)?(r===b.FRAG_LOADING||!i.fragCurrent&&r===b.PARSING)&&(i.fragmentTracker.removeFragment(t),i.state=b.IDLE):("payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(l.Events.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(e){i.state!==b.STOPPED&&i.state!==b.ERROR&&(i.warn(e),i.resetFragmentLoading(t))}))},w.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},w._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=t.stats;e.state=b.IDLE,e.fragLoadError=0,t.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:t.type}),e.tick()})).catch((function(r){e.state!==b.STOPPED&&e.state!==b.ERROR&&(e.warn(r),e.resetFragmentLoading(t))}))},w.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},w.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+" "+(r?m.default.toString(a.BufferHelper.getBuffered(r)):"(detached)")),this.state=b.IDLE,r&&(!this.loadedmetadata&&r.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},w.seekToStartPos=function(){},w._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 d.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);e.flush(a)}},w._handleFragmentLoadProgress=function(t){},w._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=b.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=b.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)}))},w.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)}))},w.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},w._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===b.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=b.IDLE)},w.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?Object(p.getPartWith)(s,i,n):null,o=a?a.fragment:Object(p.getFragmentWithSN)(s,i,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},w.bufferFragmentData=function(t,e,r,i){if(t&&this.state===b.PARSING){var n=t.data1,s=t.data2,a=n;if(n&&s&&(a=Object(c.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)}}},w.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)},w.getFwdBufferInfo=function(t,e){var r=this.config,n=this.getLoadPosition();if(!Object(i.isFiniteNumber)(n))return null;var s=a.BufferHelper.bufferInfo(t,n,r.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,e);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,n,Math.max(s.nextStart,r.maxBufferHole))}return s},w.getMaxBufferLength=function(t){var e,r=this.config;return e=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(e,r.maxMaxBufferLength)},w.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)},w.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.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]);if(!n){var l=s.lowLatencyMode?e.partEnd:e.fragmentEnd;n=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(n)},w.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},w.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},w.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},w.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(f.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(f.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},w.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(f.findFragmentByPTS)(a,o,t,h)}else i=o[o.length-1];if(i){var p=i.sn-r.startSN;if(a&&i.sn===a.sn&&!c&&a&&i.level===a.level){var g=o[p+1];i.sn<l&&this.fragmentTracker.getState(g)!==s.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+g.sn),i=g):i=null}}return i},w.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))}}},w.alignPlaylists=function(t,e){var r=this.levels,n=this.levelLastLoaded,s=this.fragPrevious,a=null!==n?r[n]:null,o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!e,d=t.alignedSliding&&Object(i.isFiniteNumber)(l);if(u||!d&&!l){Object(h.alignStream)(s,a,t);var c=t.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(s?s.sn:"na")+" fragments: "+o),c}return l},w.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},w.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=t.startTimeOffset;Object(i.isFiniteNumber)(n)?(r=e+n,n<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},w.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},w.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},w.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===b.FRAG_LOADING_WAITING_RETRY)||(this.state=b.IDLE)},w.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){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);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=b.FRAG_LOADING_WAITING_RETRY}else e.levelRetry?(t===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=b.IDLE):(o.logger.error(e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.hls.stopLoad(),this.state=b.ERROR)}}},w.afterBufferFlushed=function(t,e,r){if(t){var i=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===b.ENDED&&this.resetLoadingState()}},w.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=b.IDLE},w.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},w.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+")"),e||!1;var d=i?0:Object(p.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:d,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1)||(this.warn("Found no media in fragment "+t.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=b.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:t,part:e})},w.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S=n,(A=[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}])&&E(S.prototype,A),L&&E(S,L),Object.defineProperty(S,"prototype",{writable:!1}),n}(n.default)},"./src/controller/buffer-controller.ts":
|
|
38
38
|
/*!*********************************************!*\
|
|
39
39
|
!*** ./src/controller/buffer-controller.ts ***!
|
|
40
40
|
\*********************************************/
|
|
41
|
-
/*! 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;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a=e[t],o=a.id,l=a.codec,u=a.levelCodec,d=a.container,c=a.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),p=(u||l).replace(h,"$1");if(f!==p){var g=d+";codecs="+(u||l);r.appendChangeType(t,g),s.logger.log("[buffer-controller]: switching codec "+f+" to "+p),r.tracks[t]={buffer:n.buffer,codec:l,container:d,levelCodec:u,metadata:c,id:o}}}}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],v=self.performance.now();g.start=v;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);var E=u.audio,T="audio"===c&&1===p.id&&"audio/mpeg"===(null==E?void 0:E.container),b={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===m.first&&(m.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.stopLoad())),i.trigger(n.Events.ERROR,e)}};l.append(b,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):this.getSourceBufferTypes().forEach((function(t){i.append(a(t),t)}))},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=this.getSourceBufferTypes();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,metadata:l.metadata,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().then(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":
|
|
41
|
+
/*! 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;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a=e[t],o=a.id,l=a.codec,u=a.levelCodec,d=a.container,c=a.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),p=(u||l).replace(h,"$1");if(f!==p){var g=d+";codecs="+(u||l);r.appendChangeType(t,g),s.logger.log("[buffer-controller]: switching codec "+f+" to "+p),r.tracks[t]={buffer:n.buffer,codec:l,container:d,levelCodec:u,metadata:c,id:o}}}}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],v=self.performance.now();g.start=v;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);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===m.first&&(m.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.stopLoad())),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):this.getSourceBufferTypes().forEach((function(t){i.append(a(t),t)}))},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=this.getSourceBufferTypes();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,metadata:l.metadata,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().then(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":
|
|
42
42
|
/*!**************************************************!*\
|
|
43
43
|
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
44
44
|
\**************************************************/
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
/*!******************************************!*\
|
|
71
71
|
!*** ./src/controller/gap-controller.ts ***!
|
|
72
72
|
\******************************************/
|
|
73
|
-
/*! 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=null,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.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,n=this.media,s=this.stalled;if(null!==n){var u=n.currentTime,d=n.seeking,c=this.seeking&&!d,h=!this.seeking&&d;if(this.seeking=d,u===t){if((h||c)&&(this.stalled=null),!(n.paused&&!d||n.ended||0===n.playbackRate)&&i.BufferHelper.getBuffered(n).length){var f=i.BufferHelper.bufferInfo(n,u,0),p=f.len>0,g=f.nextStart||0;if(p||g){if(d){var v=f.len>l,m=!g||e&&e.start<=u||g-u>l&&!this.fragmentTracker.getPartialFragment(u);if(v||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,E=Math.max(g,f.start||0)-u,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,
|
|
73
|
+
/*! 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=null,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.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,n=this.media,s=this.stalled;if(null!==n){var u=n.currentTime,d=n.seeking,c=this.seeking&&!d,h=!this.seeking&&d;if(this.seeking=d,u===t){if((h||c)&&(this.stalled=null),!(n.paused&&!d||n.ended||0===n.playbackRate)&&i.BufferHelper.getBuffered(n).length){var f=i.BufferHelper.bufferInfo(n,u,0),p=f.len>0,g=f.nextStart||0;if(p||g){if(d){var v=f.len>l,m=!g||e&&e.start<=u||g-u>l&&!this.fragmentTracker.getPartialFragment(u);if(v||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,E=Math.max(g,f.start||0)-u,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(null==T||null===(y=T.details)||void 0===y?void 0:y.live)?2*T.details.targetduration:l;if(E>0&&E<=_)return void this._trySkipBufferHole(null)}var b=self.performance.now();if(null!==s){var S=b-s;if(d||!(S>=o)||(this._reportStall(f),this.media)){var A=i.BufferHelper.bufferInfo(n,u,r.maxBufferHole);this._tryFixBufferStall(A,S)}}else this.stalled=b}}}else if(this.moved=!0,null!==s){if(this.stallReported){var L=self.performance.now()-s;a.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(L)+"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;if(null!==n){var s=n.currentTime,o=i.getPartialFragment(s);if(o&&(this._trySkipBufferHole(o)||!this.media))return;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&&r&&(this.stallReported=!0,a.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")"),e.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t.len}))},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,o=this.media;if(null===o)return 0;for(var 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=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){var l=o+(i+1)*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+o+" 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 @"+o+" 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":
|
|
74
74
|
/*!************************************************!*\
|
|
75
75
|
!*** ./src/controller/id3-track-controller.ts ***!
|
|
76
76
|
\************************************************/
|
|
77
|
-
/*! 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(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),l=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function d(t,e){return t.getTime()/1e3-e}var c=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(Object(s.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},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(s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var s=e.frag,o=e.samples,d=e.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=d.edge||s.end,h=u(),f=!1,p={},g=0;g<o.length;g++){var v=o[g].type;if((v!==l.MetadataSchema.emsg||i)&&n){var m=a.getID3Frames(o[g].data);if(m){var y=o[g].pts,E=c;E-y<=0&&(E=y+.25);for(var T=0;T<m.length;T++){var
|
|
77
|
+
/*! 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(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),l=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function d(t,e){return t.getTime()/1e3-e}var c=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function(){var t=this.hls;t.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(Object(s.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},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(s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var s=e.frag,o=e.samples,d=e.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=d.edge||s.end,h=u(),f=!1,p={},g=0;g<o.length;g++){var v=o[g].type;if((v!==l.MetadataSchema.emsg||i)&&n){var m=a.getID3Frames(o[g].data);if(m){var y=o[g].pts,E=c;E-y<=0&&(E=y+.25);for(var T=0;T<m.length;T++){var _=m[T];if(!a.isTimeStampFrame(_)){var b=new h(y,E,"");b.value=_,v&&(b.type=v),this.id3Track.addCue(b),p[_.key]=null,f=!0}}}}}f&&this.updateId3CueEnds(p)}}},e.updateId3CueEnds=function(t){var e,r=null===(e=this.id3Track)||void 0===e?void 0:e.cues;if(r)for(var i=r.length;i--;){var n,s=r[i],a=null===(n=s.value)||void 0===n?void 0:n.key;if(a&&a in t){var o=t[a];o&&s.endTime!==o&&(s.endTime=o),t[a]=s.startTime}}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,n=e.type,a=this.id3Track,o=this.hls;if(o){var u,d=o.config,c=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;a&&(c||h)&&(u="audio"===n?function(t){return t.type===l.MetadataSchema.audioId3&&h}:"video"===n?function(t){return t.type===l.MetadataSchema.emsg&&c}:function(t){return t.type===l.MetadataSchema.audioId3&&h||t.type===l.MetadataSchema.emsg&&c},Object(s.removeCuesInRange)(a,r,i,u))}},e.onLevelUpdated=function(t,e){var r=this,n=e.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var s=this.dateRangeCuesAppended,a=this.id3Track,c=n.dateRanges,h=Object.keys(c);if(a)for(var f=Object.keys(s).filter((function(t){return!h.includes(t)})),p=function(t){var e=f[t];Object.keys(s[e].cues).forEach((function(t){a.removeCue(s[e].cues[t])})),delete s[e]},g=f.length;g--;)p(g);var v=n.fragments[n.fragments.length-1];if(0!==h.length&&Object(i.isFiniteNumber)(null==v?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=v.programDateTime/1e3-v.start,y=n.edge||v.end,E=u(),T=function(t){var e=h[t],i=c[e],n=s[e],a=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,f=d(i.startDate,m),p=y,g=i.endDate;if(g)p=d(g,m),u=!0;else if(i.endOnNext&&!u){var v=h.reduce((function(t,e){var r=c[e];return r.class===i.class&&r.id!==e&&r.startDate>i.startDate&&t.push(r),t}),[]).sort((function(t,e){return t.startDate.getTime()-e.startDate.getTime()}))[0];v&&(p=d(v.startDate,m),u=!0)}for(var T,_=Object.keys(i.attr),b=0;b<_.length;b++){var S=_[b];if(S!==o.DateRangeAttribute.ID&&S!==o.DateRangeAttribute.CLASS&&S!==o.DateRangeAttribute.START_DATE&&S!==o.DateRangeAttribute.DURATION&&S!==o.DateRangeAttribute.END_DATE&&S!==o.DateRangeAttribute.END_ON_NEXT){var A=a[S];if(A)u&&!n.durationKnown&&(A.endTime=p);else{var L=i.attr[S];A=new E(f,p,""),S!==o.DateRangeAttribute.SCTE35_OUT&&S!==o.DateRangeAttribute.SCTE35_IN||(T=L,L=Uint8Array.from(T.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),A.value={key:S,data:L},A.type=l.MetadataSchema.dateRange,r.id3Track.addCue(A),a[S]=A}}}s[e]={cues:a,dateRange:i,durationKnown:u}},_=0;_<h.length;_++)T(_)}}},t}();e.default=c},"./src/controller/latency-controller.ts":
|
|
78
78
|
/*!**********************************************!*\
|
|
79
79
|
!*** ./src/controller/latency-controller.ts ***!
|
|
80
80
|
\**********************************************/
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
/*!****************************************!*\
|
|
87
87
|
!*** ./src/controller/level-helper.ts ***!
|
|
88
88
|
\****************************************/
|
|
89
|
-
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,e,r){r.r(e),r.d(e,"addGroupId",(function(){return o})),r.d(e,"assignTrackIdsByGroup",(function(){return l})),r.d(e,"updatePTS",(function(){return u})),r.d(e,"updateFragPTSDTS",(function(){return c})),r.d(e,"mergeDetails",(function(){return h})),r.d(e,"mapPartIntersection",(function(){return f})),r.d(e,"mapFragmentIntersection",(function(){return p})),r.d(e,"adjustSliding",(function(){return g})),r.d(e,"addSliding",(function(){return v})),r.d(e,"computeReloadInterval",(function(){return m})),r.d(e,"getFragmentWithSN",(function(){return y})),r.d(e,"getPartWith",(function(){return E}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function a(){return(a=Object.assign?Object.assign.bind():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 o(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 l(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}function u(t,e,r){d(t[e],t[r])}function d(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 c(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 l=r,u=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,l=Math.max(r,c),r=Math.min(r,c),a=Math.min(a,e.startDTS),u=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=l,e.startDTS=a,e.endPTS=s,e.minEndPTS=u,e.endDTS=o;var g,v=e.sn;if(!t||v<t.startSN||v>t.endSN)return 0;var m=v-t.startSN,y=t.fragments;for(y[m]=e,g=m;g>0;g--)d(y[g],y[g-1]);for(g=m;g<y.length-1;g++)d(y[g],y[g+1]);return t.fragmentHint&&d(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,p}function h(t,e){for(var r=null,o=t.fragments,l=o.length-1;l>=0;l--){var u=o[l].initSegment;if(u){r=u;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var d,h,v,m,y,E=0;if(p(t,e,(function(t,n){t.relurl&&(E=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&&(d=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,n.urlId=t.urlId,t.initSegment&&(n.initSegment=t.initSegment,r=t.initSegment)})),r&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=r)||void 0===e?void 0:e.relurl)||(t.initSegment=r)})),e.skippedSegments)if(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 T=e.skippedSegments;T--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=(h=t.dateRanges,v=e.dateRanges,m=e.recentlyRemovedDateranges,y=a({},h),m&&m.forEach((function(t){delete y[t]})),Object.keys(v).forEach((function(t){var e=new s.DateRange(v[t].attr,y[t]);e.isValid?y[t]=e:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(v[t].attr)+'"')})),y));var
|
|
89
|
+
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,e,r){r.r(e),r.d(e,"addGroupId",(function(){return o})),r.d(e,"assignTrackIdsByGroup",(function(){return l})),r.d(e,"updatePTS",(function(){return u})),r.d(e,"updateFragPTSDTS",(function(){return c})),r.d(e,"mergeDetails",(function(){return h})),r.d(e,"mapPartIntersection",(function(){return f})),r.d(e,"mapFragmentIntersection",(function(){return p})),r.d(e,"adjustSliding",(function(){return g})),r.d(e,"addSliding",(function(){return v})),r.d(e,"computeReloadInterval",(function(){return m})),r.d(e,"getFragmentWithSN",(function(){return y})),r.d(e,"getPartWith",(function(){return E}));var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function a(){return(a=Object.assign?Object.assign.bind():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 o(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 l(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}function u(t,e,r){d(t[e],t[r])}function d(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 c(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 l=r,u=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,l=Math.max(r,c),r=Math.min(r,c),a=Math.min(a,e.startDTS),u=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=l,e.startDTS=a,e.endPTS=s,e.minEndPTS=u,e.endDTS=o;var g,v=e.sn;if(!t||v<t.startSN||v>t.endSN)return 0;var m=v-t.startSN,y=t.fragments;for(y[m]=e,g=m;g>0;g--)d(y[g],y[g-1]);for(g=m;g<y.length-1;g++)d(y[g],y[g+1]);return t.fragmentHint&&d(y[y.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,p}function h(t,e){for(var r=null,o=t.fragments,l=o.length-1;l>=0;l--){var u=o[l].initSegment;if(u){r=u;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var d,h,v,m,y,E=0;if(p(t,e,(function(t,n){t.relurl&&(E=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&&(d=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,n.urlId=t.urlId,t.initSegment&&(n.initSegment=t.initSegment,r=t.initSegment)})),r&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null===(e=r)||void 0===e?void 0:e.relurl)||(t.initSegment=r)})),e.skippedSegments)if(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 T=e.skippedSegments;T--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=(h=t.dateRanges,v=e.dateRanges,m=e.recentlyRemovedDateranges,y=a({},h),m&&m.forEach((function(t){delete y[t]})),Object.keys(v).forEach((function(t){var e=new s.DateRange(v[t].attr,y[t]);e.isValid?y[t]=e:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(v[t].attr)+'"')})),y));var _=e.fragments;if(E){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<_.length;b++)_[b].cc+=E}e.skippedSegments&&(e.startCC=e.fragments[0].cc),f(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),d?c(e,d,d.startPTS,d.endPTS,d.startDTS,d.endDTS):g(t,e),_.length&&(e.totalduration=e.edge-_[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var S=e.advancedDateTime;if(e.advanced&&S){var A=e.edge;e.driftStart||(e.driftStartTime=S,e.driftStart=A),e.driftEndTime=S,e.driftEnd=A}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function f(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 p(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 g(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;r<0||r>=i.length||v(e,i[r].start)}function v(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i<r.length;i++)r[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function m(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 y(t,e,r){if(!t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||((n=i.fragmentHint)&&n.sn===e?n:e<i.startSN&&r&&r.sn===e?r:null)}function E(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":
|
|
90
90
|
/*!*********************************************!*\
|
|
91
91
|
!*** ./src/controller/stream-controller.ts ***!
|
|
92
92
|
\*********************************************/
|
|
93
|
-
/*! 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(/*! ./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");function g(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?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){var e,r;function m(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.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=t,(e=m).prototype=Object.create(r.prototype),e.prototype.constructor=e,v(e,r);var y,E,T,b=m.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&&this.levels.length>1?(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.resetStartWhenNotLoaded(this.level),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,i=this.levelLastLoaded,s=this.levels,o=this.media,c=r.config,h=r.nextLoadLevel;if(null!==i&&(o||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&s&&s[h]){var f=s[h];this.level=r.nextLoadLevel=h;var p=f.details;if(!p||this.state===n.State.WAITING_LEVEL||p.live&&this.levelLastLoaded!==h)this.state=n.State.WAITING_LEVEL;else{var g=this.getMainFwdBufferInfo();if(null!==g&&!(g.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(g,p)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}this.backtrackFragment&&this.backtrackFragment.start>g.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:g.end,y=this.getNextFragment(m,p);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn&&this.fragmentTracker.getState(y)!==l.FragmentState.OK){var E,T=(null!=(E=this.backtrackFragment)?E:y).sn-p.startSN,b=p.fragments[T-1];b&&y.cc===b.cc&&(y=b,this.fragmentTracker.removeFragment(b))}else this.backtrackFragment&&g.len&&(this.backtrackFragment=null);if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>m){var _=this.audioOnly&&!this.altAudio?d.ElementaryStreamTypes.AUDIO:d.ElementaryStreamTypes.VIDEO;o&&this.afterBufferFlushed(o,_,u.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,p)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(t=y.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=y.decryptdata)&&void 0!==e&&e.key?this.loadFragment(y,p,m):this.loadKey(y,p))}}}},b.loadFragment=function(e,r,i){var n,s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===l.FragmentState.NOT_LOADED?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(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;switch(this.fragCurrent=null,this.backtrackFragment=null,null!=t&&t.loader&&t.loader.abort(),this.state){case n.State.KEY_LOADING:case n.State.FRAG_LOADING:case n.State.FRAG_LOADING_WAITING_RETRY:case n.State.PARSING:case n.State.PARSED: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&&this.onvplaying&&this.onvseeked&&(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.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=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,this.backtrackFragment=null,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=r.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)),v=i?i.index:-1,m=-1!==v,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,v,m),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:if("main"===e.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},b.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(t).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},b.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},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;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void this.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||n<this.config.maxFragLookUpTolerance)&&(this.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;t.bitrateTest=!0,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),t.bitrateTest=!1}}))},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.resetStartWhenNotLoaded(l.level);var c=u.frag,h=u.part,f=u.level,p=o.video,g=o.text,v=o.id3,m=o.initSegment,y=f.details,E=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,c,l),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:m.tracks}));var T=m.initPTS,b=m.timescale;Object(i.isFiniteNumber)(T)&&(this.initPTS[c.cc]=T,s.trigger(a.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:T,timescale:b}))}if(p&&!1!==o.independent){if(y){var _=p.startPTS,S=p.endPTS,A=p.startDTS,L=p.endDTS;if(h)h.elementaryStreams[p.type]={startPTS:_,endPTS:S,startDTS:A,endDTS:L};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){var w=this.getMainFwdBufferInfo();if((w?w.end:this.getLoadPosition())+this.config.maxBufferHole<(p.firstKeyFramePTS?p.firstKeyFramePTS:_)-this.config.maxBufferHole)return void this.backtrack(c);c.setElementaryStreamInfo(p.type,c.start,S,c.start,L,!0)}c.setElementaryStreamInfo(p.type,_,S,A,L),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(p,c,h,l)}}else if(!1===o.independent)return void this.backtrack(c);if(E){var D=E.startPTS,R=E.endPTS,k=E.startDTS,O=E.endDTS;h&&(h.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:D,endPTS:R,startDTS:k,endDTS:O}),c.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,D,R,k,O),this.bufferFragmentData(E,c,h,l)}if(y&&null!=v&&null!==(e=v.samples)&&void 0!==e&&e.length){var I={id:r,frag:c,details:y,samples:v.samples};s.trigger(a.Events.FRAG_PARSING_METADATA,I)}if(y&&g){var C={id:r,frag:c,details:y,samples:g.samples};s.trigger(a.Events.FRAG_PARSING_USERDATA,C)}}},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.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},b.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=n.State.IDLE},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){this.backtrackFragment=null;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)}}},y=m,(E=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&Object(i.isFiniteNumber)(e)&&Object(i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+1e3*(e-r.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&g(y.prototype,E),T&&g(y,T),Object.defineProperty(y,"prototype",{writable:!1}),m}(n.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
93
|
+
/*! 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(/*! ./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");function g(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?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){var e,r;function m(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.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=t,(e=m).prototype=Object.create(r.prototype),e.prototype.constructor=e,v(e,r);var y,E,T,_=m.prototype;return _._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)},_._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)},_.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},_.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&&this.levels.length>1?(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},_.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},_.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.resetStartWhenNotLoaded(this.level),this.state=n.State.IDLE)}this.onTickEnd()},_.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},_.doTickIdle=function(){var t,e,r=this.hls,i=this.levelLastLoaded,s=this.levels,o=this.media,c=r.config,h=r.nextLoadLevel;if(null!==i&&(o||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&s&&s[h]){var f=s[h];this.level=r.nextLoadLevel=h;var p=f.details;if(!p||this.state===n.State.WAITING_LEVEL||p.live&&this.levelLastLoaded!==h)this.state=n.State.WAITING_LEVEL;else{var g=this.getMainFwdBufferInfo();if(null!==g&&!(g.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(g,p)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}this.backtrackFragment&&this.backtrackFragment.start>g.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:g.end,y=this.getNextFragment(m,p);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn&&this.fragmentTracker.getState(y)!==l.FragmentState.OK){var E,T=(null!=(E=this.backtrackFragment)?E:y).sn-p.startSN,_=p.fragments[T-1];_&&y.cc===_.cc&&(y=_,this.fragmentTracker.removeFragment(_))}else this.backtrackFragment&&g.len&&(this.backtrackFragment=null);if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>m){var b=this.audioOnly&&!this.altAudio?d.ElementaryStreamTypes.AUDIO:d.ElementaryStreamTypes.VIDEO;o&&this.afterBufferFlushed(o,b,u.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,p)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(t=y.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(e=y.decryptdata)&&void 0!==e&&e.key?this.loadFragment(y,p,m):this.loadKey(y,p))}}}},_.loadFragment=function(e,r,i){var n,s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===l.FragmentState.NOT_LOADED?"initSegment"===e.sn?this._loadInitSegment(e):this.bitrateTest?(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()},_.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return e&&"fragment"in e?e.fragment:e},_.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},_.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},_.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},_.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)}}}},_.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,null!=t&&t.loader&&t.loader.abort(),this.state){case n.State.KEY_LOADING:case n.State.FRAG_LOADING:case n.State.FRAG_LOADING_WAITING_RETRY:case n.State.PARSING:case n.State.PARSED:this.state=n.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},_.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},_.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)},_.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(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)},_.onMediaPlaying=function(){this.tick()},_.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()},_.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},_.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},_.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)}},_.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,this.backtrackFragment=null,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)},_._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=r.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)),v=i?i.index:-1,m=-1!==v,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,v,m),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")},_.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})}},_.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()},_.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},_.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)}},_.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:if("main"===e.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},_.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(t).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},_.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},_.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)}},_.onLevelsUpdated=function(t,e){this.levels=e.levels},_.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},_.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void this.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||n<this.config.maxFragLookUpTolerance)&&(this.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}}},_._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},_._loadBitrateTestFrag=function(t){var e=this;t.bitrateTest=!0,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),t.bitrateTest=!1}}))},_._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.resetStartWhenNotLoaded(l.level);var c=u.frag,h=u.part,f=u.level,p=o.video,g=o.text,v=o.id3,m=o.initSegment,y=f.details,E=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(c)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,c,l),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:c,id:r,tracks:m.tracks}));var T=m.initPTS,_=m.timescale;Object(i.isFiniteNumber)(T)&&(this.initPTS[c.cc]=T,s.trigger(a.Events.INIT_PTS_FOUND,{frag:c,id:r,initPTS:T,timescale:_}))}if(p&&!1!==o.independent){if(y){var b=p.startPTS,S=p.endPTS,A=p.startDTS,L=p.endDTS;if(h)h.elementaryStreams[p.type]={startPTS:b,endPTS:S,startDTS:A,endDTS:L};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){var w=this.getMainFwdBufferInfo();if((w?w.end:this.getLoadPosition())+this.config.maxBufferHole<(p.firstKeyFramePTS?p.firstKeyFramePTS:b)-this.config.maxBufferHole)return void this.backtrack(c);c.setElementaryStreamInfo(p.type,c.start,S,c.start,L,!0)}c.setElementaryStreamInfo(p.type,b,S,A,L),this.backtrackFragment&&(this.backtrackFragment=c),this.bufferFragmentData(p,c,h,l)}}else if(!1===o.independent)return void this.backtrack(c);if(E){var D=E.startPTS,R=E.endPTS,k=E.startDTS,O=E.endDTS;h&&(h.elementaryStreams[d.ElementaryStreamTypes.AUDIO]={startPTS:D,endPTS:R,startDTS:k,endDTS:O}),c.setElementaryStreamInfo(d.ElementaryStreamTypes.AUDIO,D,R,k,O),this.bufferFragmentData(E,c,h,l)}if(y&&null!=v&&null!==(e=v.samples)&&void 0!==e&&e.length){var I={id:r,frag:c,details:y,samples:v.samples};s.trigger(a.Events.FRAG_PARSING_METADATA,I)}if(y&&g){var C={id:r,frag:c,details:y,samples:g.samples};s.trigger(a.Events.FRAG_PARSING_USERDATA,C)}}},_._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()}},_.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},_.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=n.State.IDLE},_.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){this.backtrackFragment=null;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)}}},y=m,(E=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&Object(i.isFiniteNumber)(e)&&Object(i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+1e3*(e-r.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&g(y.prototype,E),T&&g(y,T),Object.defineProperty(y,"prototype",{writable:!1}),m}(n.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
94
94
|
/*!******************************************************!*\
|
|
95
95
|
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
96
96
|
\******************************************************/
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
/*!************************************!*\
|
|
111
111
|
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
112
112
|
\************************************/
|
|
113
|
-
/*! 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 v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,t[f]=v,e[v]=f;var m=h[f],y=h[m],E=h[y],T=257*h[v]^16843008*v;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*m^16843008*f,l[v]=T<<24|T>>>8,u[v]=T<<16|T>>>16,d[v]=T<<8|T>>>24,c[v]=T,f?(f=m^h[h[h[E^m]]],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],v=p[1],m=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]]^v[h[l>>>16&255]]^m[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,v,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,
|
|
113
|
+
/*! 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 v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,t[f]=v,e[v]=f;var m=h[f],y=h[m],E=h[y],T=257*h[v]^16843008*v;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*m^16843008*f,l[v]=T<<24|T>>>8,u[v]=T<<16|T>>>16,d[v]=T<<8|T>>>24,c[v]=T,f?(f=m^h[h[h[E^m]]],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],v=p[1],m=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]]^v[h[l>>>16&255]]^m[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,v,m=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],D=L[1],R=L[2],k=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,v=1;v<m;v++)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^D),I[e+2]=C(s^R),I[e+3]=C(n^k),w=c,D=h,R=f,k=p,e+=4}return I.buffer},t}()},"./src/crypt/decrypter.ts":
|
|
114
114
|
/*!********************************!*\
|
|
115
115
|
!*** ./src/crypt/decrypter.ts ***!
|
|
116
116
|
\********************************/
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
/*!*********************************!*\
|
|
143
143
|
!*** ./src/demux/exp-golomb.ts ***!
|
|
144
144
|
\*********************************/
|
|
145
|
-
/*! 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 v=u();if(3===v&&c(1),f(),f(),c(1),d())for(e=3!==v?8:12,r=0;r<e;r++)d()&&p(r<6?16:64)}f();var m=u();if(0===m)u();else if(1===m)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
|
|
145
|
+
/*! 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 v=u();if(3===v&&c(1),f(),f(),c(1),d())for(e=3!==v?8:12,r=0;r<e;r++)d()&&p(r<6?16:64)}f();var m=u();if(0===m)u();else if(1===m)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":
|
|
146
146
|
/*!**************************!*\
|
|
147
147
|
!*** ./src/demux/id3.ts ***!
|
|
148
148
|
\**************************/
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
/*!*******************************************!*\
|
|
167
167
|
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
168
168
|
\*******************************************/
|
|
169
|
-
/*! 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 v;a.logger.log("demuxing in webworker");try{v=this.worker=i(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.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+")")})},v.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"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new s.default(this.observer,p,h,g,e),this.worker=null}}else this.transmuxer=new s.default(this.observer,p,h,g,e)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null,this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},e.push=function(t,e,r,i,n,o,l,u,d,c){var h,f,p=this;d.transmuxing.start=self.performance.now();var g=this.transmuxer,v=this.worker,m=o?o.start:n.start,y=n.decryptdata,E=this.frag,T=!(E&&n.cc===E.cc),
|
|
169
|
+
/*! 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 v;a.logger.log("demuxing in webworker");try{v=this.worker=i(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.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+")")})},v.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"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new s.default(this.observer,p,h,g,e),this.worker=null}}else this.transmuxer=new s.default(this.observer,p,h,g,e)}var e=t.prototype;return e.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null,this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},e.push=function(t,e,r,i,n,o,l,u,d,c){var h,f,p=this;d.transmuxing.start=self.performance.now();var g=this.transmuxer,v=this.worker,m=o?o.start:n.start,y=n.decryptdata,E=this.frag,T=!(E&&n.cc===E.cc),_=!(E&&d.level===E.level),b=E?d.sn-E.sn:-1,S=this.part?d.part-this.part.index:-1,A=0===b&&d.id>1&&d.id===(null==E?void 0:E.stats.chunkCount),L=!_&&(1===b||0===b&&(1===S||A&&S<=0)),w=self.performance.now();(_||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=w),!o||!S&&L||(o.stats.parsing.start=w);var D=!(E&&(null===(h=n.initSegment)||void 0===h?void 0:h.url)===(null===(f=E.initSegment)||void 0===f?void 0:f.url)),R=new s.TransmuxState(T,L,u,_,m,D);if(!L||T||D){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: "+T+"\n trackSwitch: "+_+"\n contiguous: "+L+"\n accurateTimeOffset: "+u+"\n timeOffset: "+m+"\n initSegmentChange: "+D);var k=new s.TransmuxConfig(r,i,e,l,c);this.configureTransmuxer(k)}if(this.frag=n,this.part=o,v)v.postMessage({cmd:"demux",data:t,decryptdata:y,chunkMeta:d,state:R},t instanceof ArrayBuffer?[t]:[]);else if(g){var O=g.push(t,y,d,R);Object(s.isPromise)(O)?O.then((function(t){p.handleTransmuxComplete(t)})):this.handleTransmuxComplete(O)}},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;case"workerLog":a.logger[e.data.logType]&&a.logger[e.data.logType](e.data.message);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":
|
|
170
170
|
/*!****************************************!*\
|
|
171
171
|
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
172
172
|
\****************************************/
|
|
@@ -174,11 +174,11 @@
|
|
|
174
174
|
/*!*********************************!*\
|
|
175
175
|
!*** ./src/demux/transmuxer.ts ***!
|
|
176
176
|
\*********************************/
|
|
177
|
-
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,r){r.r(e),r.d(e,"default",(function(){return g})),r.d(e,"isPromise",(function(){return m})),r.d(e,"TransmuxConfig",(function(){return y})),r.d(e,"TransmuxState",(function(){return E}));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(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(t){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var p=[{demux:u.default,remux:c.default},{demux:l.default,remux:h.default},{demux:o.default,remux:c.default},{demux:d.default,remux:c.default}],g=function(){function t(t,e,r,i,n){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=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.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}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.config,u=this.currentTransmuxState,d=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||u,h=c.contiguous,f=c.discontinuity,p=c.trackSwitch,g=c.accurateTimeOffset,m=c.timeOffset,y=c.initSegmentChange,E=d.audioCodec,T=d.videoCodec,
|
|
177
|
+
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,e,r){r.r(e),r.d(e,"default",(function(){return g})),r.d(e,"isPromise",(function(){return m})),r.d(e,"TransmuxConfig",(function(){return y})),r.d(e,"TransmuxState",(function(){return E}));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(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(t){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var p=[{demux:u.default,remux:c.default},{demux:l.default,remux:h.default},{demux:o.default,remux:c.default},{demux:d.default,remux:c.default}],g=function(){function t(t,e,r,i,n){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=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.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}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.config,u=this.currentTransmuxState,d=this.transmuxConfig;n&&(this.currentTransmuxState=n);var c=n||u,h=c.contiguous,f=c.discontinuity,p=c.trackSwitch,g=c.accurateTimeOffset,m=c.timeOffset,y=c.initSegmentChange,E=d.audioCodec,T=d.videoCodec,_=d.defaultInitPts,b=d.duration,S=d.initSegmentData;(f||p||y)&&this.resetInitSegment(S,E,T,b),(f||y)&&this.resetInitialTimestamp(_),h||this.resetContiguity();var A=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(A&&"AES-128"===A.method){var L=this.getDecrypter();if(!l.enableSoftwareAES)return this.decryptionPromise=L.webCryptoDecrypt(o,A.key.buffer,A.iv.buffer).then((function(t){var e=s.push(t,null,r);return s.decryptionPromise=null,e})),this.decryptionPromise;var w=L.softwareDecrypt(o,A.key.buffer,A.iv.buffer);if(!w)return a.executeEnd=i(),v(r);o=new Uint8Array(w)}this.needsProbing(o,f,p)&&this.configureTransmuxer(o,d);var D=this.transmux(o,A,m,g,r),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.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.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then((function(){return e.flush(t)}));var u=[],d=o.timeOffset;if(a){var c=a.flush();c&&u.push(this.push(c,null,t))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return 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(),[v(t)];var p=h.flush(d);return m(p)?p.then((function(r){return e.flushRemux(u,r,t),u})):(this.flushRemux(u,p,t),u)},e.flushRemux=function(t,e,r){var n=e.audioTrack,s=e.videoTrack,a=e.id3Track,o=e.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,d=l.timeOffset;f.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,this.id);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(t,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.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(s,a,o,l,e,r,!1,this.id),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.videoTrack,t.id3Track,t.textTrack,r,i,!1,s.id),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,g=e.videoCodec,v=0,m=p.length;v<m;v++)if(p[v].demux.probe(t)){r=p[v];break}r||(f.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,g,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}(),v=function(t){return{remuxResult:{},chunkMeta:t}};function m(t){return"then"in t&&t.then instanceof Function}var y=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},E=function(t,e,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}},"./src/demux/tsdemuxer.ts":
|
|
178
178
|
/*!********************************!*\
|
|
179
179
|
!*** ./src/demux/tsdemuxer.ts ***!
|
|
180
180
|
\********************************/
|
|
181
|
-
/*! exports provided: discardEPB, default */function(t,e,r){r.r(e),r.d(e,"discardEPB",(function(){return E}));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(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function h(){return(h=Object.assign?Object.assign.bind():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 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._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(t){return 71===t[0]&&71===t[188]},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:l.RemuxerTrackIdConfig[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,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},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},e.demux=function(t,e,r,i){var n;void 0===r&&(r=!1),void 0===i&&(i=!1),r||(this.sampleAes=null);var s=this._avcTrack,a=this._audioTrack,c=this._id3Track,h=this._txtTrack,f=s.pid,p=s.pesData,y=a.pid,E=c.pid,T=a.pesData,b=c.pesData,_=null,S=this.pmtParsed,A=this._pmtId,L=t.length;if(this.remainderData&&(L=(t=Object(l.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),L<188&&!i)return this.remainderData=t,{audioTrack:a,videoTrack:s,id3Track:c,textTrack:h};(L-=L%188)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,L,t.buffer.byteLength-L));for(var w=0,D=0;D<L;D+=188)if(71===t[D]){var R=!!(64&t[D+1]),k=((31&t[D+1])<<8)+t[D+2],O=void 0;if((48&t[D+3])>>4>1){if((O=D+5+t[D+4])===D+188)continue}else O=D+4;switch(k){case f:R&&(p&&(n=m(p))&&this.parseAVCPES(s,h,n,!1),p={data:[],size:0}),p&&(p.data.push(t.subarray(O,D+188)),p.size+=D+188-O);break;case y:if(R){if(T&&(n=m(T)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n)}T={data:[],size:0}}T&&(T.data.push(t.subarray(O,D+188)),T.size+=D+188-O);break;case E:R&&(b&&(n=m(b))&&this.parseID3PES(c,n),b={data:[],size:0}),b&&(b.data.push(t.subarray(O,D+188)),b.size+=D+188-O);break;case 0:R&&(O+=t[O]+1),A=this._pmtId=g(t,O);break;case A:R&&(O+=t[O]+1);var I=v(t,O,this.typeSupported,r);(f=I.avc)>0&&(s.pid=f),(y=I.audio)>0&&(a.pid=y,a.segmentCodec=I.segmentCodec),(E=I.id3)>0&&(c.pid=E),null===_||S||(u.logger.log("unknown PID '"+_+"' in TS found"),_=null),S=this.pmtParsed=!0;break;case 17:case 8191:break;default:_=k}}else w++;w>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+w+" TS packet/s that do not start with 0x47"}),s.pesData=p,a.pesData=T,c.pesData=b;var C={audioTrack:a,videoTrack:s,id3Track:c,textTrack:h};return i&&this.extractRemainingSamples(C),C},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,s=t.textTrack,a=i.pesData,o=r.pesData,l=n.pesData;if(a&&(e=m(a))?(this.parseAVCPES(i,s,e,!0),i.pesData=null):i.pesData=a,o&&(e=m(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=m(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new a.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.videoTrack;i.samples&&"aac"===i.segmentCodec?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._duration=0},e.parseAVCPES=function(t,e,r,i){var n,a=this,o=this.parseAVCNALu(t,r.data),u=this.avcSample,d=!1;r.data=null,u&&o.length&&!t.audFound&&(y(u,t),u=this.avcSample=p(!1,r.pts,r.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,u||(u=a.avcSample=p(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(d&&o.length>4){var c=new s.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(u.key=!0)}break;case 5:n=!0,u||(u=a.avcSample=p(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,Object(l.parseSEIMessageFromNALu)(E(i.data),r.pts,e.samples);break;case 7:if(n=!0,d=!0,!t.sps){var h=new s.default(i.data).readSPS();t.width=h.width,t.height=h.height,t.pixelRatio=h.pixelRatio,t.sps=[i.data],t.duration=a._duration;for(var f=i.data.subarray(1,4),g="avc1.",v=0;v<3;v++){var m=f[v].toString(16);m.length<2&&(m="0"+m),g+=m}t.codec=g}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,u&&y(u,t),u=a.avcSample=p(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&n&&u.units.push(i)})),i&&u&&(y(u,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!==(e=i)&&void 0!==e&&e.units){var n=i.units;r=n[n.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,n=e.byteLength,s=t.naluState||0,a=s,o=[],l=0,u=-1,d=0;for(-1===s&&(u=0,d=31&e[0],s=0,l=1);l<n;)if(r=e[l++],s)if(1!==s)if(r)if(1===r){if(u>=0){var c={data:e.subarray(u,l-s-1),type:d};o.push(c)}else{var h=this.getLastNalUnit(t.samples);if(h&&(a&&l<=4-a&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-a)),(i=l-s-1)>0)){var f=new Uint8Array(h.data.byteLength+i);f.set(h.data,0),f.set(e.subarray(0,i),h.data.byteLength),h.data=f,h.state=0}}l<n?(u=l,d=31&e[l],s=0):s=-1}else s=0;else s=3;else s=r?0:2;else s=r?0:1;if(u>=0&&s>=0){var p={data:e.subarray(u,n),type:d,state:s};o.push(p)}if(0===o.length){var g=this.getLastNalUnit(t.samples);if(g){var v=new Uint8Array(g.data.byteLength+e.byteLength);v.set(g.data,0),v.set(e,g.data.byteLength),g.data=v}}return t.naluState=s,o},e.parseAACPES=function(t,e){var r,n,s,a,l,c=0,h=this.aacOverFlow,f=e.data;if(h){this.aacOverFlow=null;var p=h.missing,g=h.sample.unit.byteLength;if(-1===p){var v=new Uint8Array(g+f.byteLength);v.set(h.sample.unit,0),v.set(f,g),f=v}else{var m=g-p;h.sample.unit.set(f.subarray(0,p),m),t.samples.push(h.sample),c=h.missing}}for(r=c,n=f.length;r<n-1&&!i.isHeader(f,r);r++);if(r===c||(r<n-1?(s="AAC PES did not start with ADTS header,offset:"+r,a=!1):(s="no ADTS header found in AAC PES",a=!0),u.logger.warn("parsing error:"+s),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:s}),!a)){if(i.initTrackConfig(t,this.observer,f,r,this.audioCodec),void 0!==e.pts)l=e.pts;else{if(!h)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var y=i.getFrameDuration(t.samplerate);l=h.sample.pts+y}for(var E,T=0;r<n;){if(r+=(E=i.appendFrame(t,f,r,l,T)).length,E.missing){this.aacOverFlow=E;break}for(T++;r<n-1&&!i.isHeader(f,r);r++);}}},e.parseMPEGPES=function(t,e){var r=e.data,i=r.length,s=0,a=0,o=e.pts;if(void 0!==o)for(;a<i;)if(n.isHeader(r,a)){var l=n.appendFrame(t,r,a,o,s);if(!l)break;a+=l.length,s++}else a++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t,e){if(void 0!==e.pts){var r=h({},e,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3});t.samples.push(r)}else u.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 v(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},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){u.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){u.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:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=a,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return n}function m(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 d=e[7];192&d&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&d?n-(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(u.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&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function E(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}e.default=f},"./src/errors.ts":
|
|
181
|
+
/*! exports provided: discardEPB, default */function(t,e,r){r.r(e),r.d(e,"discardEPB",(function(){return E}));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(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function h(){return(h=Object.assign?Object.assign.bind():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 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._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(t){return 71===t[0]&&71===t[188]},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:l.RemuxerTrackIdConfig[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,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},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},e.demux=function(t,e,r,i){var n;void 0===r&&(r=!1),void 0===i&&(i=!1),r||(this.sampleAes=null);var s=this._avcTrack,a=this._audioTrack,c=this._id3Track,h=this._txtTrack,f=s.pid,p=s.pesData,y=a.pid,E=c.pid,T=a.pesData,_=c.pesData,b=null,S=this.pmtParsed,A=this._pmtId,L=t.length;if(this.remainderData&&(L=(t=Object(l.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),L<188&&!i)return this.remainderData=t,{audioTrack:a,videoTrack:s,id3Track:c,textTrack:h};(L-=L%188)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,L,t.buffer.byteLength-L));for(var w=0,D=0;D<L;D+=188)if(71===t[D]){var R=!!(64&t[D+1]),k=((31&t[D+1])<<8)+t[D+2],O=void 0;if((48&t[D+3])>>4>1){if((O=D+5+t[D+4])===D+188)continue}else O=D+4;switch(k){case f:R&&(p&&(n=m(p))&&this.parseAVCPES(s,h,n,!1),p={data:[],size:0}),p&&(p.data.push(t.subarray(O,D+188)),p.size+=D+188-O);break;case y:if(R){if(T&&(n=m(T)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n)}T={data:[],size:0}}T&&(T.data.push(t.subarray(O,D+188)),T.size+=D+188-O);break;case E:R&&(_&&(n=m(_))&&this.parseID3PES(c,n),_={data:[],size:0}),_&&(_.data.push(t.subarray(O,D+188)),_.size+=D+188-O);break;case 0:R&&(O+=t[O]+1),A=this._pmtId=g(t,O);break;case A:R&&(O+=t[O]+1);var I=v(t,O,this.typeSupported,r);(f=I.avc)>0&&(s.pid=f),(y=I.audio)>0&&(a.pid=y,a.segmentCodec=I.segmentCodec),(E=I.id3)>0&&(c.pid=E),null===b||S||(u.logger.log("unknown PID '"+b+"' in TS found"),b=null),S=this.pmtParsed=!0;break;case 17:case 8191:break;default:b=k}}else w++;w>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+w+" TS packet/s that do not start with 0x47"}),s.pesData=p,a.pesData=T,c.pesData=_;var C={audioTrack:a,videoTrack:s,id3Track:c,textTrack:h};return i&&this.extractRemainingSamples(C),C},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,s=t.textTrack,a=i.pesData,o=r.pesData,l=n.pesData;if(a&&(e=m(a))?(this.parseAVCPES(i,s,e,!0),i.pesData=null):i.pesData=a,o&&(e=m(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=m(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new a.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.videoTrack;i.samples&&"aac"===i.segmentCodec?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._duration=0},e.parseAVCPES=function(t,e,r,i){var n,a=this,o=this.parseAVCNALu(t,r.data),u=this.avcSample,d=!1;r.data=null,u&&o.length&&!t.audFound&&(y(u,t),u=this.avcSample=p(!1,r.pts,r.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,u||(u=a.avcSample=p(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(d&&o.length>4){var c=new s.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(u.key=!0)}break;case 5:n=!0,u||(u=a.avcSample=p(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,Object(l.parseSEIMessageFromNALu)(E(i.data),r.pts,e.samples);break;case 7:if(n=!0,d=!0,!t.sps){var h=new s.default(i.data).readSPS();t.width=h.width,t.height=h.height,t.pixelRatio=h.pixelRatio,t.sps=[i.data],t.duration=a._duration;for(var f=i.data.subarray(1,4),g="avc1.",v=0;v<3;v++){var m=f[v].toString(16);m.length<2&&(m="0"+m),g+=m}t.codec=g}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,u&&y(u,t),u=a.avcSample=p(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&n&&u.units.push(i)})),i&&u&&(y(u,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!==(e=i)&&void 0!==e&&e.units){var n=i.units;r=n[n.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,n=e.byteLength,s=t.naluState||0,a=s,o=[],l=0,u=-1,d=0;for(-1===s&&(u=0,d=31&e[0],s=0,l=1);l<n;)if(r=e[l++],s)if(1!==s)if(r)if(1===r){if(u>=0){var c={data:e.subarray(u,l-s-1),type:d};o.push(c)}else{var h=this.getLastNalUnit(t.samples);if(h&&(a&&l<=4-a&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-a)),(i=l-s-1)>0)){var f=new Uint8Array(h.data.byteLength+i);f.set(h.data,0),f.set(e.subarray(0,i),h.data.byteLength),h.data=f,h.state=0}}l<n?(u=l,d=31&e[l],s=0):s=-1}else s=0;else s=3;else s=r?0:2;else s=r?0:1;if(u>=0&&s>=0){var p={data:e.subarray(u,n),type:d,state:s};o.push(p)}if(0===o.length){var g=this.getLastNalUnit(t.samples);if(g){var v=new Uint8Array(g.data.byteLength+e.byteLength);v.set(g.data,0),v.set(e,g.data.byteLength),g.data=v}}return t.naluState=s,o},e.parseAACPES=function(t,e){var r,n,s,a,l,c=0,h=this.aacOverFlow,f=e.data;if(h){this.aacOverFlow=null;var p=h.missing,g=h.sample.unit.byteLength;if(-1===p){var v=new Uint8Array(g+f.byteLength);v.set(h.sample.unit,0),v.set(f,g),f=v}else{var m=g-p;h.sample.unit.set(f.subarray(0,p),m),t.samples.push(h.sample),c=h.missing}}for(r=c,n=f.length;r<n-1&&!i.isHeader(f,r);r++);if(r===c||(r<n-1?(s="AAC PES did not start with ADTS header,offset:"+r,a=!1):(s="no ADTS header found in AAC PES",a=!0),u.logger.warn("parsing error:"+s),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:s}),!a)){if(i.initTrackConfig(t,this.observer,f,r,this.audioCodec),void 0!==e.pts)l=e.pts;else{if(!h)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var y=i.getFrameDuration(t.samplerate);l=h.sample.pts+y}for(var E,T=0;r<n;){if(r+=(E=i.appendFrame(t,f,r,l,T)).length,E.missing){this.aacOverFlow=E;break}for(T++;r<n-1&&!i.isHeader(f,r);r++);}}},e.parseMPEGPES=function(t,e){var r=e.data,i=r.length,s=0,a=0,o=e.pts;if(void 0!==o)for(;a<i;)if(n.isHeader(r,a)){var l=n.appendFrame(t,r,a,o,s);if(!l)break;a+=l.length,s++}else a++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t,e){if(void 0!==e.pts){var r=h({},e,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3});t.samples.push(r)}else u.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 v(t,e,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},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){u.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){u.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:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=a,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return n}function m(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 d=e[7];192&d&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&d?n-(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(u.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&&u.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function E(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}e.default=f},"./src/errors.ts":
|
|
182
182
|
/*!***********************!*\
|
|
183
183
|
!*** ./src/errors.ts ***!
|
|
184
184
|
\***********************/
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
/*!********************!*\
|
|
191
191
|
!*** ./src/hls.ts ***!
|
|
192
192
|
\********************/
|
|
193
|
-
/*! 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"),v=r(/*! ./errors */"./src/errors.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)}}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.cmcdController=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,v=r.fpsController,m=this.abrController=new i(this),y=this.bufferController=new c(this),E=this.capLevelController=new g(this),T=new v(this),
|
|
193
|
+
/*! 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"),v=r(/*! ./errors */"./src/errors.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)}}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.cmcdController=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,v=r.fpsController,m=this.abrController=new i(this),y=this.bufferController=new c(this),E=this.capLevelController=new g(this),T=new v(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 D=[_,b,A,w];this.networkControllers=D;var R=[m,y,E,T,S,L];this.audioTrackController=this.createController(r.audioTrackController,null,D),this.createController(r.audioStreamController,L,D),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,D),this.createController(r.subtitleStreamController,L,D),this.createController(r.timelineController,null,R),this.emeController=this.createController(r.emeController,null,R),this.cmcdController=this.createController(r.cmcdController,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:v.ErrorTypes.OTHER_ERROR,details:v.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.2.3"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return v.ErrorTypes}},{key:"ErrorDetails",get:function(){return v.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:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{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}}])&&m(e.prototype,r),y&&m(e,y),Object.defineProperty(e,"prototype",{writable:!1}),t}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
194
194
|
/*!*****************************!*\
|
|
195
195
|
!*** ./src/is-supported.ts ***!
|
|
196
196
|
\*****************************/
|
|
@@ -226,11 +226,11 @@
|
|
|
226
226
|
/*!***********************************!*\
|
|
227
227
|
!*** ./src/loader/m3u8-parser.ts ***!
|
|
228
228
|
\***********************************/
|
|
229
|
-
/*! 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(/*! ./date-range */"./src/loader/date-range.ts"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),l=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#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,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),g=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),v=/\.(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)).slice(-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(h.lastIndex=0;null!=(i=h.exec(e));)if(i[1]){var o=new u.AttrList(i[1]),l={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(i[2],r)},d=o.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),y((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),l),l.videoCodec&&-1!==l.videoCodec.indexOf("avc1")&&(l.videoCodec=t.convertAVC1ToAVCOTI(l.videoCodec)),n.push(l)}else if(i[3]){var c=new u.AttrList(i[3]);c["DATA-ID"]&&(a=!0,s[c["DATA-ID"]]=c)}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(f.lastIndex=0;null!==(s=f.exec(e));){var l=new u.AttrList(s[1]);if(l.TYPE===i){var d={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE||"",type:i,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:l.LANGUAGE,url:l.URI?t.resolve(l.URI,r):""};if(n.length){var c=t.findGroup(n,d.groupId)||n[0];E(d,c,"audioCodec"),E(d,c,"textCodec")}a.push(d)}}return a},t.parseLevelPlaylist=function(t,e,r,c,h){var f,m,y,E=new o.LevelDetails(e),
|
|
229
|
+
/*! 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(/*! ./date-range */"./src/loader/date-range.ts"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),l=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#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,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),g=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),v=/\.(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)).slice(-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(h.lastIndex=0;null!=(i=h.exec(e));)if(i[1]){var o=new u.AttrList(i[1]),l={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(i[2],r)},d=o.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),y((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),l),l.videoCodec&&-1!==l.videoCodec.indexOf("avc1")&&(l.videoCodec=t.convertAVC1ToAVCOTI(l.videoCodec)),n.push(l)}else if(i[3]){var c=new u.AttrList(i[3]);c["DATA-ID"]&&(a=!0,s[c["DATA-ID"]]=c)}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(f.lastIndex=0;null!==(s=f.exec(e));){var l=new u.AttrList(s[1]);if(l.TYPE===i){var d={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE||"",type:i,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:l.LANGUAGE,url:l.URI?t.resolve(l.URI,r):""};if(n.length){var c=t.findGroup(n,d.groupId)||n[0];E(d,c,"audioCodec"),E(d,c,"textCodec")}a.push(d)}}return a},t.parseLevelPlaylist=function(t,e,r,c,h){var f,m,y,E=new o.LevelDetails(e),b=E.fragments,S=null,A=0,L=0,w=0,D=0,R=null,k=new a.Fragment(c,e),O=-1,I=!1;for(p.lastIndex=0,E.m3u8=t;null!==(f=p.exec(t));){I&&(I=!1,(k=new a.Fragment(c,e)).start=w,k.sn=A,k.cc=D,k.level=r,S&&(k.initSegment=S,k.rawProgramDateTime=S.rawProgramDateTime,S.rawProgramDateTime=null));var C=f[1];if(C){k.duration=parseFloat(C);var P=(" "+f[2]).slice(1);k.title=P||null,k.tagList.push(P?["INF",C,P]:["INF",C])}else if(f[3])Object(i.isFiniteNumber)(k.duration)&&(k.start=w,y&&(k.levelkey=y),k.sn=A,k.level=r,k.cc=D,k.urlId=h,b.push(k),k.relurl=(" "+f[3]).slice(1),T(k,R),R=k,w+=k.duration,A++,L=0,I=!0);else if(f[4]){var x=(" "+f[4]).slice(1);R?k.setByteRange(x,R):k.setByteRange(x)}else if(f[5])k.rawProgramDateTime=(" "+f[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),-1===O&&(O=b.length);else{if(!(f=f[0].match(g))){d.logger.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m<f.length&&void 0===f[m];m++);var M=(" "+f[m]).slice(1),F=(" "+f[m+1]).slice(1),N=f[m+2]?(" "+f[m+2]).slice(1):"";switch(M){case"PLAYLIST-TYPE":E.type=F.toUpperCase();break;case"MEDIA-SEQUENCE":A=E.startSN=parseInt(F);break;case"SKIP":var U=new u.AttrList(F),B=U.decimalInteger("SKIPPED-SEGMENTS");if(Object(i.isFiniteNumber)(B)){E.skippedSegments=B;for(var j=B;j--;)b.unshift(null);A+=B}var G=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");G&&(E.recentlyRemovedDateranges=G.split("\t"));break;case"TARGETDURATION":E.targetduration=parseFloat(F);break;case"VERSION":E.version=parseInt(F);break;case"EXTM3U":break;case"ENDLIST":E.live=!1;break;case"#":(F||N)&&k.tagList.push(N?[F,N]:[F]);break;case"DISCONTINUITY":D++,k.tagList.push(["DIS"]);break;case"GAP":k.tagList.push([M]);break;case"BITRATE":k.tagList.push([M,F]);break;case"DATERANGE":var H=new u.AttrList(F),V=new s.DateRange(H,E.dateRanges[H.ID]);V.isValid||E.skippedSegments?E.dateRanges[V.id]=V:d.logger.warn('Ignoring invalid DATERANGE tag: "'+F+'"'),k.tagList.push(["EXT-X-DATERANGE",F]);break;case"DISCONTINUITY-SEQUENCE":D=parseInt(F);break;case"KEY":var K,q=new u.AttrList(F),W=q.enumeratedString("METHOD"),z=q.URI,Y=q.hexadecimalInteger("IV"),X=q.enumeratedString("KEYFORMATVERSIONS"),Q=q.enumeratedString("KEYID"),$=null!=(K=q.enumeratedString("KEYFORMAT"))?K:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf($)>-1){d.logger.warn("Keyformat "+$+" is not supported from the manifest");continue}if("identity"!==$)continue;W&&(y=l.LevelKey.fromURL(e,z),z&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(W)>=0&&(y.method=W,y.keyFormat=$,Q&&(y.keyID=Q),X&&(y.keyFormatVersions=X),y.iv=Y));break;case"START":var Z=new u.AttrList(F).decimalFloatingPoint("TIME-OFFSET");Object(i.isFiniteNumber)(Z)&&(E.startTimeOffset=Z);break;case"MAP":var J=new u.AttrList(F);if(k.duration){var tt=new a.Fragment(c,e);_(tt,J,r,y),S=tt,k.initSegment=S,S.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=S.rawProgramDateTime)}else _(k,J,r,y),S=k,I=!0;break;case"SERVER-CONTROL":var et=new u.AttrList(F);E.canBlockReload=et.bool("CAN-BLOCK-RELOAD"),E.canSkipUntil=et.optionalFloat("CAN-SKIP-UNTIL",0),E.canSkipDateRanges=E.canSkipUntil>0&&et.bool("CAN-SKIP-DATERANGES"),E.partHoldBack=et.optionalFloat("PART-HOLD-BACK",0),E.holdBack=et.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var rt=new u.AttrList(F);E.partTarget=rt.decimalFloatingPoint("PART-TARGET");break;case"PART":var it=E.partList;it||(it=E.partList=[]);var nt=L>0?it[it.length-1]:void 0,st=L++,at=new a.Part(new u.AttrList(F),k,e,st,nt);it.push(at),k.duration+=at.duration;break;case"PRELOAD-HINT":var ot=new u.AttrList(F);E.preloadHint=ot;break;case"RENDITION-REPORT":var lt=new u.AttrList(F);E.renditionReports=E.renditionReports||[],E.renditionReports.push(lt);break;default:d.logger.warn("line parsed but not handled: "+f)}}}R&&!R.relurl?(b.pop(),w-=R.duration,E.partList&&(E.fragmentHint=R)):E.partList&&(T(k,R),k.cc=D,E.fragmentHint=k);var ut=b.length,dt=b[0],ct=b[ut-1];if((w+=E.skippedSegments*E.targetduration)>0&&ut&&ct){E.averagetargetduration=w/ut;var ht=ct.sn;E.endSN="initSegment"!==ht?ht:0,dt&&(E.startCC=dt.cc,dt.initSegment||E.fragments.every((function(t){return t.relurl&&function(t){var e,r;return v.test(null!=(e=null===(r=n.parseURL(t))||void 0===r?void 0:r.path)?e:"")}(t.relurl)}))&&(d.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(k=new a.Fragment(c,e)).relurl=ct.relurl,k.level=r,k.sn="initSegment",dt.initSegment=k,E.needSidxRanges=!0))}else E.endSN=0,E.startCC=0;return E.fragmentHint&&(w+=E.fragmentHint.duration),E.totalduration=w,E.endCC=D,O>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}}(b,O),E},t}();function y(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return Object(c.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 E(t,e,r){var i=e[r];i&&(t[r]=i)}function T(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)}function _(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkey=i),t.initSegment=null}},"./src/loader/playlist-loader.ts":
|
|
230
230
|
/*!***************************************!*\
|
|
231
231
|
!*** ./src/loader/playlist-loader.ts ***!
|
|
232
232
|
\***************************************/
|
|
233
|
-
/*! 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.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},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}})),v=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",v),E=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.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"),m.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:m,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),v=Object(i.isFiniteNumber)(h)?h:0,m=Object(i.isFiniteNumber)(f)?f:v,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,m,y,v);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 b
|
|
233
|
+
/*! 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.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},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}})),v=f.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",v),E=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.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"),m.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:m,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),v=Object(i.isFiniteNumber)(h)?h:0,m=Object(i.isFiniteNumber)(f)?f:v,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,m,y,v);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 _,b=null===(_=E.fragments[0].initSegment)||void 0===_?void 0:_.url;this.load({url:b,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=new Uint8Array(t.data),i=Object(o.findBox)(r,["sidx"])[0];if(i){var n=Object(o.parseSegmentIndex)(i);if(n){var s=n.references,a=e.levelDetails;s.forEach((function(t,e){var i=t.info,n=a.fragments[e];if(0===n.byteRange.length&&n.setByteRange(String(1+i.end-i.start)+"@"+String(i.start)),n.initSegment){var s=Object(o.findBox)(r,["moov"])[0],l=s?s.length:null;n.initSegment.setByteRange(String(l)+"@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":
|
|
234
234
|
/*!*********************************!*\
|
|
235
235
|
!*** ./src/polyfills/number.ts ***!
|
|
236
236
|
\*********************************/
|
|
@@ -246,11 +246,11 @@
|
|
|
246
246
|
/*!**********************************!*\
|
|
247
247
|
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
248
248
|
\**********************************/
|
|
249
|
-
/*! exports provided: default, normalizePts, flushTextTrackMetadataCueSamples, flushTextTrackUserdataCueSamples */function(t,e,r){r.r(e),r.d(e,"default",(function(){return p})),r.d(e,"normalizePts",(function(){return g})),r.d(e,"flushTextTrackMetadataCueSamples",(function(){return v})),r.d(e,"flushTextTrackUserdataCueSamples",(function(){return m}));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(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function c(){return(c=Object.assign?Object.assign.bind():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 h=null,f=null,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.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===h){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=n?parseInt(n[1]):0}if(null===f){var s=navigator.userAgent.match(/Safari\/(\d+)/i);f=s?parseInt(s[1]):0}}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,o){var d,c,h,f,p,y,E=n,T=n,b=t.pid>-1,_=e.pid>-1,S=e.samples.length,A=t.samples.length>0,L=a&&S>0||S>1;if((!b||A)&&(!_||L)||this.ISGenerated||a){this.ISGenerated||(h=this.generateIS(t,e,n));var w,D=this.isVideoContiguous,R=-1;if(L&&(R=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,R>0){l.logger.warn("[mp4-remuxer]: Dropped "+R+" out of "+S+" video samples due to a missing keyframe");var k=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(R),e.dropped+=R,w=T+=(e.samples[0].pts-k)/e.inputTimeScale}else-1===R&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),y=!1);if(this.ISGenerated){if(A&&L){var O=this.getVideoStartPts(e.samples),I=(g(t.samples[0].pts,O)-O)/e.inputTimeScale;E+=Math.max(0,I),T+=Math.max(0,-I)}if(A){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,n)),c=this.remuxAudio(t,E,this.isAudioContiguous,s,_||L||o===u.PlaylistLevelType.AUDIO?T:void 0),L){var C=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,n)),d=this.remuxVideo(e,T,D,C)}}else L&&(d=this.remuxVideo(e,T,D,0));d&&(d.firstKeyFrame=R,d.independent=-1!==R,d.firstKeyFramePTS=w)}}return this.ISGenerated&&(r.samples.length&&(p=v(r,n,this._initPTS,this._initDTS)),i.samples.length&&(f=m(i,n,this._initPTS))),{audio:c,video:d,initSegment:h,independent:y,text:f,id3:p}},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){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(f="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3")}c.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&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))}if(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),v=Math.round(o*r);a=Math.min(a,g(u[0].dts,p)-v),n=Math.min(n,p-v)}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,u,p=t.inputTimeScale,v=t.samples,m=[],E=v.length,T=this._initPTS,b=this.nextAvcDts,_=8,S=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,L=Number.NEGATIVE_INFINITY,w=!1;r&&null!==b||(b=e*p-(v[0].pts-g(v[0].dts,v[0].pts)));for(var D=0;D<E;D++){var R=v[D];R.pts=g(R.pts-T,b),R.dts=g(R.dts-T,b),R.dts<v[D>0?D-1:D].dts&&(w=!0)}w&&v.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),n=v[0].dts;var k=(u=v[v.length-1].dts)-n,O=k?Math.round(k/(E-1)):S||t.inputTimeScale/30;if(r){var I=n-b,C=I>O;if(C||I<-1){C?l.logger.warn("AVC: "+Object(d.toMsFromMpegTsClock)(I,!0)+" ms ("+I+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(d.toMsFromMpegTsClock)(-I,!0)+" ms ("+I+"dts) overlapping between fragments detected"),n=b;var P=v[0].pts-I;v[0].dts=n,v[0].pts=P,l.logger.log("Video: First PTS/DTS adjusted: "+Object(d.toMsFromMpegTsClock)(P,!0)+"/"+Object(d.toMsFromMpegTsClock)(n,!0)+", delta: "+Object(d.toMsFromMpegTsClock)(I,!0)+" ms")}}n=Math.max(0,n);for(var x=0,M=0,F=0;F<E;F++){for(var N=v[F],U=N.units,B=U.length,j=0,G=0;G<B;G++)j+=U[G].data.length;M+=j,x+=B,N.length=j,N.dts=Math.max(N.dts,n),A=Math.min(N.pts,A),L=Math.max(N.pts,L)}u=v[E-1].dts;var H,V=M+4*x+8;try{H=new Uint8Array(V)}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:V,reason:"fail allocating video mdat "+V})}var K=new DataView(H.buffer);K.setUint32(0,V),H.set(s.default.types.mdat,4);for(var q=!1,W=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=0;Q<E;Q++){for(var $=v[Q],Z=$.units,J=0,tt=0,et=Z.length;tt<et;tt++){var rt=Z[tt],it=rt.data,nt=rt.data.byteLength;K.setUint32(_,nt),_+=4,H.set(it,_),_+=nt,J+=4+nt}var st=void 0;if(Q<E-1)S=v[Q+1].dts-$.dts,st=v[Q+1].pts-$.pts;else{var at=this.config,ot=Q>0?$.dts-v[Q-1].dts:O;if(st=Q>0?$.pts-v[Q-1].pts:O,at.stretchShortVideoTrack&&null!==this.nextAudioPts){var lt=Math.floor(at.maxBufferHole*p),ut=(i?A+i*p:this.nextAudioPts)-$.pts;ut>lt?((S=ut-ot)<0?S=ot:q=!0,l.logger.log("[mp4-remuxer]: It is approximately "+ut/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=ot}else S=ot}var dt=Math.round($.pts-$.dts);W=Math.min(W,S),Y=Math.max(Y,S),z=Math.min(z,st),X=Math.max(X,st),m.push(new y($.key,S,J,dt))}if(m.length)if(h){if(h<70){var ct=m[0].flags;ct.dependsOn=2,ct.isNonSync=0}}else if(f&&X-z<Y-W&&O/Y<.025&&0===m[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ht=n,ft=0,pt=m.length;ft<pt;ft++){var gt=ht+m[ft].duration,vt=ht+m[ft].cts;if(ft<pt-1){var mt=gt+m[ft+1].cts;m[ft].duration=mt-vt}else m[ft].duration=ft?m[ft-1].duration:O;m[ft].cts=0,ht=gt}}console.assert(null!==S,"mp4SampleDuration must be computed"),S=q||!S?O:S,this.nextAvcDts=b=u+S,this.videoSampleDuration=S,this.isVideoContiguous=!0;var yt={data1:s.default.moof(t.sequenceNumber++,n,c({},t,{samples:m})),data2:H,startPTS:A/p,endPTS:(L+S)/p,startDTS:n/p,endDTS:b/p,type:"video",hasAudio:!1,hasVideo:!0,nb:m.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(H.length,"MDAT length must not be zero"),yt},e.remuxAudio=function(t,e,r,i,u){var d=t.inputTimeScale,h=d/(t.samplerate?t.samplerate:d),f="aac"===t.segmentCodec?1024:1152,p=f*h,v=this._initPTS,m="mp3"===t.segmentCodec&&this.typeSupported.mpeg,E=[],T=void 0!==u,b=t.samples,_=m?0:8,S=this.nextAudioPts||-1,A=e*d;if(this.isAudioContiguous=r=r||b.length&&S>0&&(i&&Math.abs(A-S)<9e3||Math.abs(g(b[0].pts-v,A)-S)<20*p),b.forEach((function(t){t.pts=g(t.pts-v,A)})),!r||S<0){if(!(b=b.filter((function(t){return t.pts>=0}))).length)return;S=0===u?0:i&&!T?Math.max(0,A):b[0].pts}if("aac"===t.segmentCodec)for(var L=this.config.maxAudioFramesDrift,w=0,D=S;w<b.length;w++){var R=b[w],k=R.pts,O=k-D,I=Math.abs(1e3*O/d);if(O<=-L*p&&T)0===w&&(l.logger.warn("Audio frame @ "+(k/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/d)+" ms."),this.nextAudioPts=S=D=k);else if(O>=L*p&&I<1e4&&T){var C=Math.round(O/p);(D=k-C*p)<0&&(C--,D+=p),0===w&&(this.nextAudioPts=S=D),l.logger.warn("[mp4-remuxer]: Injecting "+C+" audio frame @ "+(D/d).toFixed(3)+"s due to "+Math.round(1e3*O/d)+" ms gap.");for(var P=0;P<C;P++){var x=Math.max(D,0),M=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);M||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),M=R.unit.subarray()),b.splice(w,0,{unit:M,pts:x}),D+=p,w++}}R.pts=D,D+=p}for(var F,N=null,U=null,B=0,j=b.length;j--;)B+=b[j].unit.byteLength;for(var G=0,H=b.length;G<H;G++){var V=b[G],K=V.unit,q=V.pts;if(null!==U)E[G-1].duration=Math.round((q-U)/h);else{if(r&&"aac"===t.segmentCodec&&(q=S),N=q,!(B>0))return;B+=_;try{F=new Uint8Array(B)}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:B,reason:"fail allocating audio mdat "+B})}m||(new DataView(F.buffer).setUint32(0,B),F.set(s.default.types.mdat,4))}F.set(K,_);var W=K.byteLength;_+=W,E.push(new y(!0,f,W,0)),U=q}var z=E.length;if(z){var Y=E[E.length-1];this.nextAudioPts=S=U+h*Y.duration;var X=m?new Uint8Array(0):s.default.moof(t.sequenceNumber++,N/h,c({},t,{samples:E}));t.samples=[];var Q=N/d,$=S/d,Z={data1:X,data2:F,startPTS:Q,endPTS:$,startDTS:Q,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,console.assert(F.length,"MDAT length must not be zero"),Z}},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 v=u+g*c;p.push({unit:f,pts:v,dts:v})}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")},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}function v(t,e,r,i){var n=t.samples.length;if(n){for(var s=t.inputTimeScale,a=0;a<n;a++){var o=t.samples[a];o.pts=g(o.pts-r,e*s)/s,o.dts=g(o.dts-i,e*s)/s}var l=t.samples;return t.samples=[],{samples:l}}}function m(t,e,r){var i=t.samples.length;if(i){for(var n=t.inputTimeScale,s=0;s<i;s++){var a=t.samples[s];a.pts=g(a.pts-r,e*n)/n}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}}var y=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 E(t)},E=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":
|
|
249
|
+
/*! exports provided: default, normalizePts, flushTextTrackMetadataCueSamples, flushTextTrackUserdataCueSamples */function(t,e,r){r.r(e),r.d(e,"default",(function(){return p})),r.d(e,"normalizePts",(function(){return g})),r.d(e,"flushTextTrackMetadataCueSamples",(function(){return v})),r.d(e,"flushTextTrackUserdataCueSamples",(function(){return m}));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(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function c(){return(c=Object.assign?Object.assign.bind():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 h=null,f=null,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.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===h){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=n?parseInt(n[1]):0}if(null===f){var s=navigator.userAgent.match(/Safari\/(\d+)/i);f=s?parseInt(s[1]):0}}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,o){var d,c,h,f,p,y,E=n,T=n,_=t.pid>-1,b=e.pid>-1,S=e.samples.length,A=t.samples.length>0,L=a&&S>0||S>1;if((!_||A)&&(!b||L)||this.ISGenerated||a){this.ISGenerated||(h=this.generateIS(t,e,n));var w,D=this.isVideoContiguous,R=-1;if(L&&(R=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,R>0){l.logger.warn("[mp4-remuxer]: Dropped "+R+" out of "+S+" video samples due to a missing keyframe");var k=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(R),e.dropped+=R,w=T+=(e.samples[0].pts-k)/e.inputTimeScale}else-1===R&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+S+" video samples"),y=!1);if(this.ISGenerated){if(A&&L){var O=this.getVideoStartPts(e.samples),I=(g(t.samples[0].pts,O)-O)/e.inputTimeScale;E+=Math.max(0,I),T+=Math.max(0,-I)}if(A){if(t.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,n)),c=this.remuxAudio(t,E,this.isAudioContiguous,s,b||L||o===u.PlaylistLevelType.AUDIO?T:void 0),L){var C=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,n)),d=this.remuxVideo(e,T,D,C)}}else L&&(d=this.remuxVideo(e,T,D,0));d&&(d.firstKeyFrame=R,d.independent=-1!==R,d.firstKeyFramePTS=w)}}return this.ISGenerated&&(r.samples.length&&(p=v(r,n,this._initPTS,this._initDTS)),i.samples.length&&(f=m(i,n,this._initPTS))),{audio:c,video:d,initSegment:h,independent:y,text:f,id3:p}},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){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(f="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3")}c.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&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))}if(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),v=Math.round(o*r);a=Math.min(a,g(u[0].dts,p)-v),n=Math.min(n,p-v)}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,u,p=t.inputTimeScale,v=t.samples,m=[],E=v.length,T=this._initPTS,_=this.nextAvcDts,b=8,S=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,L=Number.NEGATIVE_INFINITY,w=!1;r&&null!==_||(_=e*p-(v[0].pts-g(v[0].dts,v[0].pts)));for(var D=0;D<E;D++){var R=v[D];R.pts=g(R.pts-T,_),R.dts=g(R.dts-T,_),R.dts<v[D>0?D-1:D].dts&&(w=!0)}w&&v.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),n=v[0].dts;var k=(u=v[v.length-1].dts)-n,O=k?Math.round(k/(E-1)):S||t.inputTimeScale/30;if(r){var I=n-_,C=I>O;if(C||I<-1){C?l.logger.warn("AVC: "+Object(d.toMsFromMpegTsClock)(I,!0)+" ms ("+I+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(d.toMsFromMpegTsClock)(-I,!0)+" ms ("+I+"dts) overlapping between fragments detected"),n=_;var P=v[0].pts-I;v[0].dts=n,v[0].pts=P,l.logger.log("Video: First PTS/DTS adjusted: "+Object(d.toMsFromMpegTsClock)(P,!0)+"/"+Object(d.toMsFromMpegTsClock)(n,!0)+", delta: "+Object(d.toMsFromMpegTsClock)(I,!0)+" ms")}}n=Math.max(0,n);for(var x=0,M=0,F=0;F<E;F++){for(var N=v[F],U=N.units,B=U.length,j=0,G=0;G<B;G++)j+=U[G].data.length;M+=j,x+=B,N.length=j,N.dts=Math.max(N.dts,n),A=Math.min(N.pts,A),L=Math.max(N.pts,L)}u=v[E-1].dts;var H,V=M+4*x+8;try{H=new Uint8Array(V)}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:V,reason:"fail allocating video mdat "+V})}var K=new DataView(H.buffer);K.setUint32(0,V),H.set(s.default.types.mdat,4);for(var q=!1,W=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Q=0;Q<E;Q++){for(var $=v[Q],Z=$.units,J=0,tt=0,et=Z.length;tt<et;tt++){var rt=Z[tt],it=rt.data,nt=rt.data.byteLength;K.setUint32(b,nt),b+=4,H.set(it,b),b+=nt,J+=4+nt}var st=void 0;if(Q<E-1)S=v[Q+1].dts-$.dts,st=v[Q+1].pts-$.pts;else{var at=this.config,ot=Q>0?$.dts-v[Q-1].dts:O;if(st=Q>0?$.pts-v[Q-1].pts:O,at.stretchShortVideoTrack&&null!==this.nextAudioPts){var lt=Math.floor(at.maxBufferHole*p),ut=(i?A+i*p:this.nextAudioPts)-$.pts;ut>lt?((S=ut-ot)<0?S=ot:q=!0,l.logger.log("[mp4-remuxer]: It is approximately "+ut/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=ot}else S=ot}var dt=Math.round($.pts-$.dts);W=Math.min(W,S),Y=Math.max(Y,S),z=Math.min(z,st),X=Math.max(X,st),m.push(new y($.key,S,J,dt))}if(m.length)if(h){if(h<70){var ct=m[0].flags;ct.dependsOn=2,ct.isNonSync=0}}else if(f&&X-z<Y-W&&O/Y<.025&&0===m[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ht=n,ft=0,pt=m.length;ft<pt;ft++){var gt=ht+m[ft].duration,vt=ht+m[ft].cts;if(ft<pt-1){var mt=gt+m[ft+1].cts;m[ft].duration=mt-vt}else m[ft].duration=ft?m[ft-1].duration:O;m[ft].cts=0,ht=gt}}console.assert(null!==S,"mp4SampleDuration must be computed"),S=q||!S?O:S,this.nextAvcDts=_=u+S,this.videoSampleDuration=S,this.isVideoContiguous=!0;var yt={data1:s.default.moof(t.sequenceNumber++,n,c({},t,{samples:m})),data2:H,startPTS:A/p,endPTS:(L+S)/p,startDTS:n/p,endDTS:_/p,type:"video",hasAudio:!1,hasVideo:!0,nb:m.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(H.length,"MDAT length must not be zero"),yt},e.remuxAudio=function(t,e,r,i,u){var d=t.inputTimeScale,h=d/(t.samplerate?t.samplerate:d),f="aac"===t.segmentCodec?1024:1152,p=f*h,v=this._initPTS,m="mp3"===t.segmentCodec&&this.typeSupported.mpeg,E=[],T=void 0!==u,_=t.samples,b=m?0:8,S=this.nextAudioPts||-1,A=e*d;if(this.isAudioContiguous=r=r||_.length&&S>0&&(i&&Math.abs(A-S)<9e3||Math.abs(g(_[0].pts-v,A)-S)<20*p),_.forEach((function(t){t.pts=g(t.pts-v,A)})),!r||S<0){if(!(_=_.filter((function(t){return t.pts>=0}))).length)return;S=0===u?0:i&&!T?Math.max(0,A):_[0].pts}if("aac"===t.segmentCodec)for(var L=this.config.maxAudioFramesDrift,w=0,D=S;w<_.length;w++){var R=_[w],k=R.pts,O=k-D,I=Math.abs(1e3*O/d);if(O<=-L*p&&T)0===w&&(l.logger.warn("Audio frame @ "+(k/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*O/d)+" ms."),this.nextAudioPts=S=D=k);else if(O>=L*p&&I<1e4&&T){var C=Math.round(O/p);(D=k-C*p)<0&&(C--,D+=p),0===w&&(this.nextAudioPts=S=D),l.logger.warn("[mp4-remuxer]: Injecting "+C+" audio frame @ "+(D/d).toFixed(3)+"s due to "+Math.round(1e3*O/d)+" ms gap.");for(var P=0;P<C;P++){var x=Math.max(D,0),M=n.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);M||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),M=R.unit.subarray()),_.splice(w,0,{unit:M,pts:x}),D+=p,w++}}R.pts=D,D+=p}for(var F,N=null,U=null,B=0,j=_.length;j--;)B+=_[j].unit.byteLength;for(var G=0,H=_.length;G<H;G++){var V=_[G],K=V.unit,q=V.pts;if(null!==U)E[G-1].duration=Math.round((q-U)/h);else{if(r&&"aac"===t.segmentCodec&&(q=S),N=q,!(B>0))return;B+=b;try{F=new Uint8Array(B)}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:B,reason:"fail allocating audio mdat "+B})}m||(new DataView(F.buffer).setUint32(0,B),F.set(s.default.types.mdat,4))}F.set(K,b);var W=K.byteLength;b+=W,E.push(new y(!0,f,W,0)),U=q}var z=E.length;if(z){var Y=E[E.length-1];this.nextAudioPts=S=U+h*Y.duration;var X=m?new Uint8Array(0):s.default.moof(t.sequenceNumber++,N/h,c({},t,{samples:E}));t.samples=[];var Q=N/d,$=S/d,Z={data1:X,data2:F,startPTS:Q,endPTS:$,startDTS:Q,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:z};return this.isAudioContiguous=!0,console.assert(F.length,"MDAT length must not be zero"),Z}},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 v=u+g*c;p.push({unit:f,pts:v,dts:v})}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")},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}function v(t,e,r,i){var n=t.samples.length;if(n){for(var s=t.inputTimeScale,a=0;a<n;a++){var o=t.samples[a];o.pts=g(o.pts-r,e*s)/s,o.dts=g(o.dts-i,e*s)/s}var l=t.samples;return t.samples=[],{samples:l}}}function m(t,e,r){var i=t.samples.length;if(i){for(var n=t.inputTimeScale,s=0;s<i;s++){var a=t.samples[s];a.pts=g(a.pts-r,e*n)/n}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}}var y=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 E(t)},E=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":
|
|
250
250
|
/*!******************************************!*\
|
|
251
251
|
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
252
252
|
\******************************************/
|
|
253
|
-
/*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=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.lastEndTime=null}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},e.resetNextTimestamp=function(){this.lastEndTime=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(s.parseInitSegment)(t);e||(e=u(i.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=u(i.video,a.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},e.remux=function(t,e,r,a,l){var u,d=this.initPTS,c=this.lastEndTime,h={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};Object(i.isFiniteNumber)(c)||(c=this.lastEndTime=l||0);var f=e.samples;if(!f||!f.length)return h;var p={initPTS:void 0,timescale:1},g=this.initData;if(g&&g.length||(this.generateInitSegment(f),g=this.initData),!g||!g.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var v=Object(s.getStartDTS)(g,f);Object(i.isFiniteNumber)(d)||(this.initPTS=p.initPTS=d=v-l);var m=Object(s.getDuration)(f,g),y=t?v-d:c,E=y+m;Object(s.offsetStartDTS)(g,f,d),m>0?this.lastEndTime=E:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!g.audio,
|
|
253
|
+
/*! exports provided: default */function(t,e,r){r.r(e);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=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.lastEndTime=null}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},e.resetNextTimestamp=function(){this.lastEndTime=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(s.parseInitSegment)(t);e||(e=u(i.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=u(i.video,a.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},e.remux=function(t,e,r,a,l){var u,d=this.initPTS,c=this.lastEndTime,h={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};Object(i.isFiniteNumber)(c)||(c=this.lastEndTime=l||0);var f=e.samples;if(!f||!f.length)return h;var p={initPTS:void 0,timescale:1},g=this.initData;if(g&&g.length||(this.generateInitSegment(f),g=this.initData),!g||!g.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var v=Object(s.getStartDTS)(g,f);Object(i.isFiniteNumber)(d)||(this.initPTS=p.initPTS=d=v-l);var m=Object(s.getDuration)(f,g),y=t?v-d:c,E=y+m;Object(s.offsetStartDTS)(g,f,d),m>0?this.lastEndTime=E:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!g.audio,_=!!g.video,b="";T&&(b+="audio"),_&&(b+="video");var S={data1:f,startPTS:y,startDTS:y,endPTS:E,endDTS:E,type:b,hasAudio:T,hasVideo:_,nb:1,dropped:0};h.audio="audio"===S.type?S:void 0,h.video="audio"!==S.type?S:void 0,h.initSegment=p;var A=null!=(u=this.initPTS)?u:0;return h.id3=Object(n.flushTextTrackMetadataCueSamples)(r,l,A,A),a.samples.length&&(h.text=Object(n.flushTextTrackUserdataCueSamples)(a,l,A)),h},t}();function u(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}e.default=l},"./src/task-loop.ts":
|
|
254
254
|
/*!**************************!*\
|
|
255
255
|
!*** ./src/task-loop.ts ***!
|
|
256
256
|
\**************************/
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
/*!*************************************!*\
|
|
291
291
|
!*** ./src/utils/cea-608-parser.ts ***!
|
|
292
292
|
\*************************************/
|
|
293
|
-
/*! exports provided: Row, CaptionScreen, default */function(t,e,r){r.r(e),r.d(e,"Row",(function(){return v})),r.d(e,"CaptionScreen",(function(){return m}));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}(),v=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}(),m=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 v(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 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 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(b(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(b(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 b(t,e,r){return r.a===t&&r.b===e}e.default=E},"./src/utils/codecs.ts":
|
|
293
|
+
/*! exports provided: Row, CaptionScreen, default */function(t,e,r){r.r(e),r.d(e,"Row",(function(){return v})),r.d(e,"CaptionScreen",(function(){return m}));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}(),v=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}(),m=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 v(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 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 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":
|
|
294
294
|
/*!*****************************!*\
|
|
295
295
|
!*** ./src/utils/codecs.ts ***!
|
|
296
296
|
\*****************************/
|
|
@@ -318,7 +318,7 @@
|
|
|
318
318
|
/*!****************************************!*\
|
|
319
319
|
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
320
320
|
\****************************************/
|
|
321
|
-
/*! 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?Object.assign.bind():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.map((function(t){return Object(a.utf8ArrayToStr)(t)})),p=Object(o.toTimescaleFromScale)(e,1,r);try{h.forEach((function(t){return 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=v(g(r,"styling","style")),d=v(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")],v=o[t.getAttribute("style")];p.position=10,p.size=80;var T=function(t,e,r){var i="http://www.w3.org/ns/ttml#styling",n=null,s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,s){var a=m(e,i,s)||m(t,i,s)||m(n,i,s);return a&&(r[s]=a),r}),{})}(g,v,o),
|
|
321
|
+
/*! 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?Object.assign.bind():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.map((function(t){return Object(a.utf8ArrayToStr)(t)})),p=Object(o.toTimescaleFromScale)(e,1,r);try{h.forEach((function(t){return 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=v(g(r,"styling","style")),d=v(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")],v=o[t.getAttribute("style")];p.position=10,p.size=80;var T=function(t,e,r){var i="http://www.w3.org/ns/ttml#styling",n=null,s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,s){var a=m(e,i,s)||m(t,i,s)||m(n,i,s);return a&&(r[s]=a),r}),{})}(g,v,o),_=T.textAlign;if(_){var b=f[_];b&&(p.lineAlign=b),p.align=_}return u(p,T),p})).filter((function(t){return null!==t}))}(t,p))}))}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 v(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function m(t,e,r){return t&&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":
|
|
322
322
|
/*!*****************************!*\
|
|
323
323
|
!*** ./src/utils/logger.ts ***!
|
|
324
324
|
\*****************************/
|
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
/*!********************************!*\
|
|
335
335
|
!*** ./src/utils/mp4-tools.ts ***!
|
|
336
336
|
\********************************/
|
|
337
|
-
/*! exports provided: RemuxerTrackIdConfig, bin2str, readUint16, readUint32, readSint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array, parseSamples, parseSEIMessageFromNALu, parseEmsg */function(t,e,r){r.r(e),r.d(e,"RemuxerTrackIdConfig",(function(){return l})),r.d(e,"bin2str",(function(){return u})),r.d(e,"readUint16",(function(){return d})),r.d(e,"readUint32",(function(){return c})),r.d(e,"readSint32",(function(){return h})),r.d(e,"writeUint32",(function(){return f})),r.d(e,"findBox",(function(){return p})),r.d(e,"parseSegmentIndex",(function(){return g})),r.d(e,"parseInitSegment",(function(){return v})),r.d(e,"getStartDTS",(function(){return m})),r.d(e,"getDuration",(function(){return y})),r.d(e,"computeRawDurationFromSamples",(function(){return E})),r.d(e,"offsetStartDTS",(function(){return T})),r.d(e,"segmentValidRange",(function(){return
|
|
337
|
+
/*! exports provided: RemuxerTrackIdConfig, bin2str, readUint16, readUint32, readSint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array, parseSamples, parseSEIMessageFromNALu, parseEmsg */function(t,e,r){r.r(e),r.d(e,"RemuxerTrackIdConfig",(function(){return l})),r.d(e,"bin2str",(function(){return u})),r.d(e,"readUint16",(function(){return d})),r.d(e,"readUint32",(function(){return c})),r.d(e,"readSint32",(function(){return h})),r.d(e,"writeUint32",(function(){return f})),r.d(e,"findBox",(function(){return p})),r.d(e,"parseSegmentIndex",(function(){return g})),r.d(e,"parseInitSegment",(function(){return v})),r.d(e,"getStartDTS",(function(){return m})),r.d(e,"getDuration",(function(){return y})),r.d(e,"computeRawDurationFromSamples",(function(){return E})),r.d(e,"offsetStartDTS",(function(){return T})),r.d(e,"segmentValidRange",(function(){return _})),r.d(e,"appendUint8Array",(function(){return b})),r.d(e,"parseSamples",(function(){return S})),r.d(e,"parseSEIMessageFromNALu",(function(){return L})),r.d(e,"parseEmsg",(function(){return w}));var i=r(/*! ./typed-array */"./src/utils/typed-array.ts"),n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=Math.pow(2,32)-1,o=[].push,l={video:1,audio:2,id3:3,text:4};function u(t){return String.fromCharCode.apply(null,t)}function d(t,e){var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function c(t,e){var r=h(t,e);return r<0?4294967296+r:r}function h(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function f(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function p(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,n=0;n<i;){var s=c(t,n),a=s>1?n+s:i;if(u(t.subarray(n+4,n+8))===e[0])if(1===e.length)r.push(t.subarray(n+8,a));else{var l=p(t.subarray(n+8,a),e.slice(1));l.length&&o.apply(r,l)}n=a}return r}function g(t){var e=[],r=t[0],i=8,n=c(t,i);i+=4,i+=0===r?8:16,i+=2;var s=t.length+0,a=d(t,i);i+=2;for(var o=0;o<a;o++){var l=i,u=c(t,l);l+=4;var h=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var f=c(t,l);l+=4,e.push({referenceSize:h,subsegmentDuration:f,info:{duration:f/n,start:s,end:s+h-1}}),s+=h,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:a,references:e}}function v(t){for(var e=[],r=p(t,["moov","trak"]),i=0;i<r.length;i++){var s=r[i],a=p(s,["tkhd"])[0];if(a){var o=a[0],l=0===o?12:20,d=c(a,l),h=p(s,["mdia","mdhd"])[0];if(h){var f=c(h,l=0===(o=h[0])?12:20),g=p(s,["mdia","hdlr"])[0];if(g){var v=u(g.subarray(8,12)),m={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[v];if(m){var y=p(s,["mdia","minf","stbl","stsd"])[0],E=void 0;y&&(E=u(y.subarray(12,16))),e[d]={timescale:f,type:m},e[m]={timescale:f,id:d,codec:E}}}}}}return p(t,["moov","mvex","trex"]).forEach((function(t){var r=c(t,4),i=e[r];i&&(i.default={duration:c(t,12),flags:c(t,20)})})),e}function m(t,e){return p(e,["moof","traf"]).reduce((function(e,r){var i=p(r,["tfdt"])[0],n=i[0],s=p(r,["tfhd"]).reduce((function(e,r){var s=c(r,4),a=t[s];if(a){var o=c(i,4);1===n&&(o*=Math.pow(2,32),o+=c(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 y(t,e){for(var r=0,i=0,s=0,a=p(t,["moof","traf"]),o=0;o<a.length;o++){var l=a[o],u=p(l,["tfhd"])[0],d=e[c(u,4)];if(d){var h=d.default,f=c(u,0)|(null==h?void 0:h.flags),v=null==h?void 0:h.duration;8&f&&(v=c(u,2&f?12:8));for(var m=d.timescale||9e4,y=p(l,["trun"]),T=0;T<y.length;T++)!(r=E(y[T]))&&v&&(r=v*c(y[T],4)),d.type===n.ElementaryStreamTypes.VIDEO?i+=r/m:d.type===n.ElementaryStreamTypes.AUDIO&&(s+=r/m)}}if(0===i&&0===s){for(var _=0,b=p(t,["sidx"]),S=0;S<b.length;S++){var A=g(b[S]);null!=A&&A.references&&(_+=A.references.reduce((function(t,e){return t+e.info.duration||0}),0))}return _}return i||s}function E(t){var e=c(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,n=c(t,4),s=0;s<n;s++)256&e&&(i+=c(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function T(t,e,r){p(e,["moof","traf"]).forEach((function(e){p(e,["tfhd"]).forEach((function(i){var n=c(i,4),s=t[n];if(s){var o=s.timescale||9e4;p(e,["tfdt"]).forEach((function(t){var e=t[0],i=c(t,4);if(0===e)i-=r*o,f(t,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=c(t,8),i-=r*o,i=Math.max(i,0);var n=Math.floor(i/(a+1)),s=Math.floor(i%(a+1));f(t,4,n),f(t,8,s)}}))}}))}))}function _(t){var e={valid:null,remainder:null},r=p(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.byteOffset-8),e.remainder=Object(i.sliceUint8)(t,n.byteOffset-8),e}function b(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function S(t,e){var r=[],i=e.samples,s=e.timescale,a=e.id,o=!1;return p(i,["moof"]).map((function(l){var u=l.byteOffset-8;p(l,["traf"]).map((function(l){var d=p(l,["tfdt"]).map((function(t){var e=t[0],r=c(t,4);return 1===e&&(r*=Math.pow(2,32),r+=c(t,8)),r/s}))[0];return void 0!==d&&(t=d),p(l,["tfhd"]).map((function(d){var f=c(d,4),g=16777215&c(d,0),v=0,m=0!=(16&g),y=0,E=0!=(32&g),T=8;f===a&&(0!=(1&g)&&(T+=8),0!=(2&g)&&(T+=4),0!=(8&g)&&(v=c(d,T),T+=4),m&&(y=c(d,T),T+=4),E&&(T+=4),"video"===e.type&&(o=function(t){if(!t)return!1;var e=t.indexOf("."),r=e<0?t:t.substring(0,e);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(e.codec)),p(l,["trun"]).map((function(a){var l=a[0],d=16777215&c(a,0),f=0!=(1&d),p=0,g=0!=(4&d),m=0!=(256&d),E=0,T=0!=(512&d),_=0,b=0!=(1024&d),S=0!=(2048&d),w=0,D=c(a,4),R=8;f&&(p=c(a,R),R+=4),g&&(R+=4);for(var k=p+u,O=0;O<D;O++){if(m?(E=c(a,R),R+=4):E=v,T?(_=c(a,R),R+=4):_=y,b&&(R+=4),S&&(w=0===l?c(a,R):h(a,R),R+=4),e.type===n.ElementaryStreamTypes.VIDEO)for(var I=0;I<_;){var C=c(i,k),P=31&i[k+=4];A(o,P)&&L(i.subarray(k,k+C),t+w/s,r),k+=C,I+=C+4}t+=E/s}})))}))}))})),r}function A(t,e){return t?39===e||40===e:6===e}function L(t,e,r){var i=function(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}(t),n=0;n++;for(var a=0,o=0,l=!1,u=0;n<i.length;){a=0;do{if(n>=i.length)break;a+=u=i[n++]}while(255===u);o=0;do{if(n>=i.length)break;o+=u=i[n++]}while(255===u);var h=i.length-n;if(!l&&4===a&&n<i.length){if(l=!0,181===i[n++]){var f=d(i,n);if(n+=2,49===f){var p=c(i,n);if(n+=4,1195456820===p){var g=i[n++];if(3===g){var v=i[n++],m=64&v,y=m?2+3*(31&v):0,E=new Uint8Array(y);if(m){E[0]=v;for(var T=1;T<y;T++)E[T]=i[n++]}r.push({type:g,payloadType:a,pts:e,bytes:E})}}}}}else if(5===a&&o<h){if(l=!0,o>16){for(var _=[],b=0;b<16;b++){var S=i[n++].toString(16);_.push(1==S.length?"0"+S:S),3!==b&&5!==b&&7!==b&&9!==b||_.push("-")}for(var A=o-16,L=new Uint8Array(A),w=0;w<A;w++)L[w]=i[n++];r.push({payloadType:a,pts:e,uuid:_.join(""),userData:Object(s.utf8ArrayToStr)(L),userDataBytes:L})}}else if(o<h)n+=o;else if(o>h)break}}function w(t){var e=t[0],r="",i="",n=0,s=0,a=0,o=0,l=0,d=0;if(0===e){for(;"\0"!==u(t.subarray(d,d+1));)r+=u(t.subarray(d,d+1)),d+=1;for(r+=u(t.subarray(d,d+1)),d+=1;"\0"!==u(t.subarray(d,d+1));)i+=u(t.subarray(d,d+1)),d+=1;i+=u(t.subarray(d,d+1)),d+=1,n=c(t,12),s=c(t,16),o=c(t,20),l=c(t,24),d=28}else if(1===e){n=c(t,d+=4);var h=c(t,d+=4),f=c(t,d+=4);for(d+=4,a=Math.pow(2,32)*h+f,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=c(t,d),l=c(t,d+=4),d+=4;"\0"!==u(t.subarray(d,d+1));)r+=u(t.subarray(d,d+1)),d+=1;for(r+=u(t.subarray(d,d+1)),d+=1;"\0"!==u(t.subarray(d,d+1));)i+=u(t.subarray(d,d+1)),d+=1;i+=u(t.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:t.subarray(d,t.byteLength)}}},"./src/utils/output-filter.ts":
|
|
338
338
|
/*!************************************!*\
|
|
339
339
|
!*** ./src/utils/output-filter.ts ***!
|
|
340
340
|
\************************************/
|
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
/*!*****************************!*\
|
|
359
359
|
!*** ./src/utils/vttcue.ts ***!
|
|
360
360
|
\*****************************/
|
|
361
|
-
/*! 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="",v=!0,m="auto",y="start",E=50,T="middle",
|
|
361
|
+
/*! 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="",v=!0,m="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 v},set:function(t){v=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return m},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");m=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":
|
|
362
362
|
/*!********************************!*\
|
|
363
363
|
!*** ./src/utils/vttparser.ts ***!
|
|
364
364
|
\********************************/
|
|
@@ -366,14 +366,14 @@
|
|
|
366
366
|
/*!************************************!*\
|
|
367
367
|
!*** ./src/utils/webvtt-parser.ts ***!
|
|
368
368
|
\************************************/
|
|
369
|
-
/*! 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.slice(r,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 v,m=new n.VTTParser,y=Object(s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(l,"\n").split("\n"),E=[],T=Object(a.toMpegTsClockFromTimescale)(e,r),
|
|
369
|
+
/*! 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.slice(r,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 v,m=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;m.oncue=function(t){var e=d[h],r=d.ccOffset,i=(b-T)/9e4;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);var n=t.endTime-t.startTime,s=Object(o.normalizePts)(9e4*(t.startTime+r-S),9e4*f)/9e4;t.startTime=Math.max(s,0),t.endTime=Math.max(s+n,0);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)},m.onparsingerror=function(t){v=t},m.onflush=function(){v?g(v):p(E)},y.forEach((function(t){if(A){if(u(t,"X-TIMESTAMP-MAP=")){A=!1,t.slice(16).split(",").forEach((function(t){u(t,"LOCAL:")?_=t.slice(6):u(t,"MPEGTS:")&&(b=parseInt(t.slice(7)))}));try{S=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),s=t.length>9?parseInt(t.substring(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){v=t}return}""===t&&(A=!1)}m.parse(t+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts":
|
|
370
370
|
/*!*********************************!*\
|
|
371
371
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
372
372
|
\*********************************/
|
|
373
|
-
/*! 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);var s=this.context.headers;if(s)for(var a in s)r.setRequestHeader(a,s[a])}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 ci=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const hi="com.widevine.alpha";const fi="application/vnd.apple.mpegURL",pi=[fi,"application/x-mpegurl"],gi=document.createElement("video").canPlayType(fi);function vi({src:t="",type:e="",drm:r},i){const n=(null==i?void 0:i.hls)||{},s="native"in n&&n.native;return(!gi||!s)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[hi].filter((function(t){return t===e})).length;var e}))&&(!(!e||!pi.includes(e))||function(t){const{pathname:e}=nr(t);return e.endsWith(".m3u8")}(t)))}var mi="audio:set",yi="audio:update",Ei="audio:tracks";const Ti=[di.Events.SUBTITLE_TRACKS_UPDATED,di.Events.SUBTITLE_TRACK_SWITCH,di.Events.LEVEL_SWITCHED];function bi(t,e){Ti.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 _i,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(t){t[t.FRAGMENT_ERRORS=0]="FRAGMENT_ERRORS",t[t.STALE_MANIFEST=1]="STALE_MANIFEST"}(_i||(_i={}));const Ai=Sr("hls:failover");class FailoverLoaderController{constructor(){this.playlistCounts={},this.fragmentFailures={},this.ttlMilliseconds=3e3}setHls(t){this.hls=t}reset(){return this.playlistCounts={},this.fragmentFailures={},this}failover(t){var e;this.reset();const r=this.hls;if(!r)return;if(r.levels[r.currentLevel].url.length<2)return;const i=r.levels[r.currentLevel].details;r.levelController.redundantFailover(r.currentLevel),null===(e=r.media)||void 0===e||e.dispatchEvent(new CustomEvent("hls/failover",{detail:{reason:t,from:null==i?void 0:i.url}}))}currentLevel(){var t;return null===(t=this.hls)||void 0===t?void 0:t.levels[this.hls.currentLevel]}nextTTL(){var t;const e=Date.now()+this.ttlMilliseconds,r=this.currentLevel();if(!r)return e;const i=null===(t=r.details)||void 0===t?void 0:t.averagetargetduration;return i?Date.now()+500*i:e}ensurePlaylistUpdating(t,e){this.playlistCounts[t]||(this.playlistCounts[t]={checksum:e,count:0,ttl:this.nextTTL()});const r=this.playlistCounts[t];Date.now()<r.ttl||(r.count=r.checksum===e?r.count+1:0,r.ttl=this.nextTTL(),r.checksum=e,r.count<3||(Ai(`${t} / no change in ${r.count} tries`,this.playlistCounts),this.failover(_i.STALE_MANIFEST)))}trackFragmentError(t){const e=this.fragmentFailures[t]||0;this.fragmentFailures[t]=e+1,this.fragmentFailures[t]>2&&this.failover(_i.FRAGMENT_ERRORS)}createPlaylistLoader(){const t=this;return class extends di.DefaultConfig.loader{load(e,r,i){const n=i.onSuccess;i.onSuccess=({data:e,url:r},...i)=>{t.ensurePlaylistUpdating(r,e),n({data:e,url:r},...i)},super.load(e,r,i)}}}createFragmentLoader(){const t=this;return class extends di.DefaultConfig.loader{load(e,r,i){const n=i.onError;i.onError=e=>{t.trackFragmentError(e.url),n(...arguments)},super.load(e,r,i)}}}}const Li=Sr("hls");function wi(t,e,r){if(!t.reaper||!r.src)return;t.hls&&t.hls.destroy();const n="live"in e==0,s={is_audio_only:!1,fragDuration:-1};if(r.drm&&!ir()&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit(i,{message:"Secure page required for DRM"});const a=new FailoverLoaderController,o=function(t){return Object.assign(Object.assign({autoStartLoad:!1,levelLoadingMaxRetry:1},t.hls),{startPosition:t.start_time||-1})}(e);o.pLoader=a.createPlaylistLoader(),o.fLoader=a.createFragmentLoader();const l=t.hls=new di(o);a.setHls(l),l.subtitleDisplay=!1,l.attachMedia(t),l.loadSource(r.src),t.emit("hls:attached",{hls:l}),function(t,e){t.on(di.Events.AUDIO_TRACKS_UPDATED,(function(t,r){e.emit(Ei,r.audioTracks)})),t.on(di.Events.AUDIO_TRACK_SWITCHING,(function(t,r){e.emit(yi,r)})),t.on(di.Events.MANIFEST_PARSED,(function(t,r){r.audioTracks&&e.emit(Ei,r.audioTracks)})),t.on(di.Events.LEVEL_SWITCHED,(function(r,i){const n=t.levels[i.level];n&&e.emit(Ei,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(l,t),bi(l,t);const u=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(l.levels[r]||-1===r?l.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},d=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=l.audioTrack&&setTimeout((function(){l.audioTrack=r}),0)};t.on("quality:set",u),t.on(mi,d),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",u),t.off(mi,d)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on(L,(function(){l&&l.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&Di(t)}),n&&l.on(di.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),l.on(di.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){var i,n;if(!t.hls)return;Li("Initializer::maybe_start_load_with_quality (start_quality, preload): (%d, %s)",e.start_quality,e.preload),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));const s=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,a=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;Li("Setting maxBufferSize to %d",s),t.hls.config.maxBufferSize=s,"metadata"===e.preload&&Li("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:a,t.once(E,()=>{Li("Playback started, set maxBufferLenght to %d",a),t.hls&&(t.hls.config.maxBufferLength=a)}),"none"===e.preload&&!e.autoplay)return;Di(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})})),l.on(di.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),l.on(di.Events.ERROR,(function(e,r){!function(t,e,r,n){if(0==t.reaper)return;if(0==e.fatal)return;switch(e.type){case di.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 di.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 di.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,l.config)})),l.on(di.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)})),l.on(di.Events.LEVEL_SWITCHING,(e,r)=>{const i=l.levels[l.currentLevel],n=l.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const c=t.opt("start_time");c&&t.once(p,(function(){t.currentTime=c})),"none"!==e.preload||e.autoplay||t.once("beforeplay",()=>{t.hasState("is-casting")||Di(t,e.start_time||-1)})}function Di(t,e){var r;!t.hasState(Z)&&t.setState(J,!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){wi(r,t,i)}wants(t,e,r){return di.isSupported()&&vi(e,r)}}HLS.events=ci,HLS.version=di.version,HLS.failover={Reasons:_i},ie(window,HLS);const Ri=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),ki=(...t)=>t.reduce((t,e)=>Ri(e)?(Object.keys(e).forEach(r=>{if(Ri(t[r])&&Ri(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 Oi(t){return fetch(t).then(t=>t.json())}function Ii(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),Ci()+"/web/public/native/config"+t}const Ci=()=>"https://ljsp.lwcdn.com";function Pi(t){return~t.indexOf("/")?t:"/media/"+t}var xi={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function Mi(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 Fi(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 Ni=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function Ui(t){return"object"==typeof t&&"ovp/base64"==t.type}function Bi(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!Ni.test(t))&&(e.type="video/ovp",!0))}(t,e)||Ui(e)}function ji(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 Gi(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 Hi(t){return t.live}var Vi=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 Ki(t,e){const r=null==e?void 0:e.src;if(Ui(e))return function(t,e){const r=ji(e.src||"");if(function(t){return"string"==typeof t.err}(r))return console.error(r.err);qi(t,r)}(t,e);r&&Pipe.of(r).fmap(Pi).fmap(Ii).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,r])=>200==e?qi(t,r):Wi(t,r)))}function qi(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"),Wi(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=>{e.ima&&Object.assign(t,{ima:e.ima});const i=Fi(t,r);return delete i.playlist,i});return delete n.ima,Object.assign(n,{playlist:s})}(t.opts,e))}(t,e):Hi(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(Gi).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(Fi,t.opts).fmap(Mi).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(Fi,t.opts).fmap(Mi).unwrap())}(t,e)}function Wi(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(xi[e.status])):t.emit("ovp:error",e)}const zi={};function Yi(t,e,r){"object"!=typeof zi[e]&&(zi[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 Xi=!1;function Qi(t,e,r){$i()||Pipe.of("recommendation").fmap(Ii,e,r).fmap(Oi).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(Zi))}function $i(){return Xi}function Zi(t){Xi=!0,console.error("Failed to load recommendations: %j",t)}function Ji(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function tn(t,e){let r=0;function i(){const i=Ji(e);if(i<0||isNaN(i)||0===t.reaper)return clearInterval(r),function(t,e){t.emit("ovp:live:countdown:complete");const r=xt(t,Y);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:en(i+1)}),e.hasState(tt)||e.setState(tt,!0)}(0,t,t.root,i)}var n;n=e,Or().then(t=>Object.assign(n,{server_time_offset:t})),i(),r=setInterval(i,250)}function en(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+Ut(e.hours)+":"+Ut(e.minutes)+":"+Ut(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=Ft("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 rn=["*.lwcdn.com","*.flowplayer.com"];class OVP{constructor(t){vt(t,Y,FlowplayerLiveCountdown)}onload(t,e,r,i){if("string"==typeof i.src)return"string"!=typeof t.player_id||0===i.src.indexOf(t.player_id)||Ui(i)||(i.src=[t.player_id,i.src].join("/")),Ki(r,i)}wants(t,e,r){return Bi(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=Gi(n.metadata.live_start_time)),r.setOpts(n);break}}})),r.on("beforeplay",(function(e){const r=t;if(Hi(r)){if(nn(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 e||Ji(e)>0)return;const i=a(e);r.setOpts(i),r.setAttrs(i),i.src&&r.setSrc(i.src)})),r.on(w,(function({data:i}){var n,s;if("string"==typeof t.src&&Bi(t.src,{}))return;if(t.src&&sn(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(rn).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?nr(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}(),i.domains))return he({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 zi[e])return console.debug("using Cache(%s)",e),Yi(t,e,zi[e]);Pipe.of(e).fmap(Ii).fmap(Oi).fmap(r=>r.then(r=>Yi(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(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),Ji(n)<=0)return r.emit("ovp:request:media:complete",n);xt(r,Y)||(e.appendChild(gt(r,Y)),tn(r,t))})),r.on("timeupdate",(function(){var e,i,n;const s=t;Hi(s)?nn(s)||(r.togglePlay(!1),r.emit(_)):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||$i()||(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)&&Qi(r,t.metadata.media_id,t.metadata.player_id))})),r.on(L,(function(){n.disconnect()}))}}function nn(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)||Gi(i)>Date.now()}OVP.events=Vi;const sn=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 an(t){return{width:t.clientWidth,height:t.clientHeight}}function on(t,e,r){return"number"==typeof r&&(r+="px"),t.style.setProperty(e,r),t}ie(window,OVP);const ln="ad-initialized";var un=Object.freeze({__proto__:null,AD_INIT:ln,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-rendering-settings",ADAPTER_INIT_FAILED:"ad-adapter-init-failed",AD_PLAY_REQUESTED:"ad-play-requested",RELOAD_AD_REQUESTED:"reload-ad-requested",AD_ERROR:"ad-error",REQUEST_AD_PAUSE:"request/ad/pause",REQUEST_AD_PLAY:"request/ad/play",REQUEST_AD_MUTE_UNMUTE:"request/ad/muteunmute"});const dn="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;const cn=Sr("ads/lifecycle"),hn=["ad-playback-error","ad-teardown","ad-break-completed"];async function fn({config:t,root:e,content:r,ads:i,ima:n}){var s;cn("LifeCycle::initLifeCycle",t,e,r,i,n),r.autoplay=!1;const a=t.autoplay===yt.AUDIO_REQUIRED,o=function(t,e){return{muted:!(e||!t.muted),volume:t.volume}}(r,a);r.on("volumechange",()=>{o.volume=r.volume,o.muted=r.muted});const l=gt(r,"flowplayer-ad-ui"),u=l.adContainer;l.setUiFlags(null===(s=t.ads)||void 0===s?void 0:s.ui),e.append(l);const d={listening:!1,preload:null==n?void 0:n.preload_ads};if(cn("initial",o),i.setVideoTag(r),t.autoplay){cn("Trying to autoplay"),l.hideFirstFrame(e);await async function t(e,r){const[i,n]=[e.muted,e.volume];cn("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 cn("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),cn("Lifecycle::peek_content::play"),await new Promise(t=>setTimeout(()=>t(e.togglePlay(!0)))),cn("Lifecycle::peek_content::pause"),await new Promise(t=>setTimeout(()=>t(e.togglePlay(!1)))),e.volume=n,cn("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?(cn("Lifecycle::peek_content::false"),await s()):(cn("Lifecycle::peek_content::recover"),e.muted=!0,!!await t(e)||(e.muted=i,cn("Lifecycle::peek_content::false"),await s()))}}(r,a)?(cn("Can autoplay, start ad"),r.opts.autoplay=1,pn({ads:i,content:r,state:d,adContainer:u,ima:n,config:t})):(cn("cannot autoplay(audioRequired: %s), fallback to poster state",a),t.autoplay=0,l.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(ot)||"touchend"!=o.type)&&e.shallPlayAd(0)&&(!dn&&o.preventDefault(),yn({ads:e,content:t,state:i}),cn("user_gesture(:intercept) -> shallPlayAd(0: %s)",e.shallPlayAd(0)),r.muted=n.muted,await pn({ads:e,content:t,state:i,adContainer:s,ima:a,config:r}),En({ads:e,content:t}))}))}({content:r,ads:i,config:t,state:d,initial:o,adContainer:u,ima:n}),!t.autoplay&&i.hasPreroll()&&d.preload&&pn({ads:i,content:r,state:d,adContainer:u,ima:n,config:t}),mn({config:t,root:e,content:r,ads:i,state:d,adContainer:u,ui:l,ima:n,initial:o}),r.on("src",()=>{r.once("beforeplay",()=>i.resetScheduleCounter())}),r.on("beforeplay",t=>{(i.adBreak||i.adPlaying||i.adRequesting)&&(i.adBreak&&!i.adLinear||(cn("prevented content from starting because ad break is active"),t.preventDefault()))})}async function pn(t){t.state.started||(t.content.hasState(ot)?await gn(t):t.content.once("viewenter",async()=>{await gn(t)}))}async function gn({ads:t,content:e,adContainer:r,ima:i,state:n,config:s}){var a;n.started=!0;const o=_t(i,["ads"]),l=an(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:dn,preload_ads:null===(a=null==s?void 0:s.ima)||void 0===a?void 0:a.preload_ads},o),l));cn("start():",d,n),await t.initialize(!1,d,n.preload)}function vn(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 mn({config:t,root:e,content:r,ads:i,initial:n,adContainer:s,state:a,ui:o,ima:l}){cn("addUIListeners()"),r.once(E,async n=>{if(i){if(cn("addUIListeners() -> content started playing"),yn({ads:i,content:r,state:a}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return cn("addUIListeners() -> no more preroll ads -> resume content"),o.showFirstFrame(e),await pn({ads:i,content:r,state:a,adContainer:s,ima:l,config:t});r.togglePlay(!1),await pn({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),En({ads:i,content:r}))}}),r.on([R,D],(function(){if(!i)return;const{content_width:t,content_height:n}=vn(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=>{var e;i&&(cn("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(),Object.assign(t,{prevented_from_ads:!0}),i.finished((function(){r.emit(_,{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(cn(`Ad[linear: ${a}, currentTime: ${r.currentTime}] starting`,l),"preroll"==u&&!a&&r.paused&&r.togglePlay(!0),"preroll"==u&&a&&r.currentTime>0&&!r.opt("start_time")&&!r.opt("live")&&(cn("Preroll[rewind: true]",r.currentTime),r.currentTime=0),a&&(d=vn(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){cn("non-linear ad / restarting content");try{r.togglePlay(!0),r.volume=n.volume,r.muted=n.muted}catch(t){cn(t)}}}),i.on("ad-pause-content",()=>{o.resize({linear:!0,width:0,height:0})}),r.on(hn,t=>async function({root:t,content:e,ads:r,ui:i,eventName:n,err:s={reason:""}}){cn("teardown(event: %s)",n),t.classList.add("is-seamless"),i.classList.remove("is-vpaid"),t.classList.remove(it),s.reason&&cn("teardown(:err, reason: %s) %o",s.reason);i.classList.remove("on");const a=r.getLastAd();if(i.showFirstFrame(t),!r.shouldRestartContent())return cn("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),Tn(t);if(e.currentTime>0&&e.currentTime>=e.duration||"postroll"==r.ad_type||!1===(null==a?void 0:a.restart))return cn("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),Tn(t);""===e.currentSrc&&e.setSrc(e.original_src);e.paused&&r.shouldRestartContent()&&(cn("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await e.togglePlay(!0));if(!e.paused)return cn("Lifecycle.teardown(:ok)","restarted video content"),Tn(t)}({root:e,content:r,ads:i,ui:o,err:t.detail,eventName:t.type}));let u=!!t.autoplay;var d;r.on("viewenter",()=>{u&&i.resume()}),r.on("viewleave",(d=()=>{u=!i.paused,i.pause()},t=>{setTimeout((function(){if(!t.defaultPrevented)return d(t)}),0)}))}function yn({ads:t,content:e,state:r}){r.listening||(e.on(["timeupdate",S,E,A],r=>{t.adPlaying&&t.adapter.isLinearAd()&&!t.adapter.isSharedVideoTag()&&!e.paused&&e.pause(),En({ads:t,content:e,seek:r.type===A})}),r.listening=!0)}function En({ads:t,content:e,seek:r=!1}){t&&t.setCurrentTime(e.currentTime,void 0,r)}function Tn(t){t.classList.remove("is-seamless")}const bn=Sr("ads/timers");class TimerRegistry{constructor(t={},e={}){this.intervals=t,this.timers=e}}let _n=-1;function Sn(t,e,r){const i=setInterval(r,e);if(bn("TimerRegistry.createInterval() -> "+i,t.intervals),"object"==typeof i){const e=++_n;return t.intervals[e]=e,e}return t.intervals[i]=i,i}function An(t){if(t)return bn("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach(e=>function(t,e){return bn("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 bn("TimerRegistry.removeTimeout() -> "+e,t.timers),clearTimeout(t.timers[e]),delete t.timers[e],t}(t,e)),t}function Ln(t){try{return t.getAdPodInfo().getPodIndex()}catch(t){return}}class IMA{constructor(t){this.eventHandler=t,this.log=Sr("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(){An(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),An(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(ln,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"),An(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{An(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,An(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 Sn(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=function(t){try{return t.getAdPodInfo().getAdPosition()}catch(t){return}}(e),i=function(t){try{return t.getAdPodInfo().getTotalAds()}catch(t){return}}(e),n={ad:{duration:e.getDuration(),width:e.getWidth(),height:e.getHeight(),position:r,totals:i},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)`,n,e),this.eventHandler.trigger(t,n)}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:Ln(e),ad:e})}catch(t){}}}var wn=Oe((function(t,e){var r=function(){for(var t=new Array(256),e=0;e<256;++e)t[e]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return t}(),i=Object.prototype.hasOwnProperty;e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(r[i]=t[i]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r){if(Array.isArray(t))t.push(r);else{if("object"!=typeof t)return[t,r];(n.plainObjects||n.allowPrototypes||!i.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=e.arrayToObject(t,n)),Object.keys(r).reduce((function(t,s){var a=r[s];return i.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a,t}),s)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),i="",n=0;n<e.length;++n){var s=e.charCodeAt(n);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=e.charAt(n):s<128?i+=r[s]:s<2048?i+=r[192|s>>6]+r[128|63&s]:s<55296||s>=57344?i+=r[224|s>>12]+r[128|s>>6&63]+r[128|63&s]:(n+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(n)),i+=r[240|s>>18]+r[128|s>>12&63]+r[128|s>>6&63]+r[128|63&s])}return i},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;var i=r||[],n=i.indexOf(t);if(-1!==n)return i[n];if(i.push(t),Array.isArray(t)){for(var s=[],a=0;a<t.length;++a)t[a]&&"object"==typeof t[a]?s.push(e.compact(t[a],i)):void 0!==t[a]&&s.push(t[a]);return s}for(var o=Object.keys(t),l=0;l<o.length;++l){var u=o[l];t[u]=e.compact(t[u],i)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!=t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}})),Dn={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Rn={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:wn.encode},kn=function t(e,r,i,n,s,a,o,l,u){var d=e;if("function"==typeof o)d=o(r,d);else if(d instanceof Date)d=d.toISOString();else if(null===d){if(n)return a?a(r):r;d=""}if("string"==typeof d||"number"==typeof d||"boolean"==typeof d||wn.isBuffer(d))return a?[a(r)+"="+a(d)]:[r+"="+String(d)];var c,h=[];if(void 0===d)return h;if(Array.isArray(o))c=o;else{var f=Object.keys(d);c=l?f.sort(l):f}for(var p=0;p<c.length;++p){var g=c[p];s&&null===d[g]||(h=Array.isArray(d)?h.concat(t(d[g],i(r,g),i,n,s,a,o,l,u)):h.concat(t(d[g],r+(u?"."+g:"["+g+"]"),i,n,s,a,o,l,u)))}return h},On=Object.prototype.hasOwnProperty,In={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:wn.decode},Cn=function(t,e,r){if(t){var i=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,n=/(\[[^[\]]*])/g,s=/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,o=[];if(a){if(!r.plainObjects&&On.call(Object.prototype,a)&&!r.allowPrototypes)return;o.push(a)}for(var l=0;null!==(s=n.exec(i))&&l<r.depth;){if(l+=1,!r.plainObjects&&On.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;o.push(s[1])}return s&&o.push("["+i.slice(s.index)+"]"),function t(e,r,i){if(!e.length)return r;var n,s=e.shift();if("[]"===s)n=(n=[]).concat(t(e,r,i));else{n=i.plainObjects?Object.create(null):{};var a="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,o=parseInt(a,10);!isNaN(o)&&s!==a&&String(o)===a&&o>=0&&i.parseArrays&&o<=i.arrayLimit?(n=[])[o]=t(e,r,i):n[a]=t(e,r,i)}return n}(o,e,r)}},Pn=function(t,e){var r,i,n=t,s=e||{},a=void 0===s.delimiter?Rn.delimiter:s.delimiter,o="boolean"==typeof s.strictNullHandling?s.strictNullHandling:Rn.strictNullHandling,l="boolean"==typeof s.skipNulls?s.skipNulls:Rn.skipNulls,u=("boolean"==typeof s.encode?s.encode:Rn.encode)?"function"==typeof s.encoder?s.encoder:Rn.encoder:null,d="function"==typeof s.sort?s.sort:null,c=void 0!==s.allowDots&&s.allowDots;if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof s.filter?n=(i=s.filter)("",n):Array.isArray(s.filter)&&(r=i=s.filter);var h,f=[];if("object"!=typeof n||null===n)return"";h=s.arrayFormat in Dn?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var p=Dn[h];r||(r=Object.keys(n)),d&&r.sort(d);for(var g=0;g<r.length;++g){var v=r[g];l&&null===n[v]||(f=f.concat(kn(n[v],v,p,o,l,u,i,d,c)))}return f.join(a)},xn=function(t,e){var r=e||{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.delimiter="string"==typeof r.delimiter||wn.isRegExp(r.delimiter)?r.delimiter:In.delimiter,r.depth="number"==typeof r.depth?r.depth:In.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:In.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:In.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:In.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:In.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:In.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:In.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:In.strictNullHandling,""===t||null==t)return r.plainObjects?Object.create(null):{};for(var i="string"==typeof t?function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),n=0;n<i.length;++n){var s,a,o=i[n],l=-1===o.indexOf("]=")?o.indexOf("="):o.indexOf("]=")+1;-1===l?(s=e.decoder(o),a=e.strictNullHandling?null:""):(s=e.decoder(o.slice(0,l)),a=e.decoder(o.slice(l+1))),On.call(r,s)?r[s]=[].concat(r[s]).concat(a):r[s]=a}return r}(t,r):t,n=r.plainObjects?Object.create(null):{},s=Object.keys(i),a=0;a<s.length;++a){var o=s[a],l=Cn(o,i[o],r);n=wn.merge(n,l,r)}return wn.compact(n)};const Mn=Sr("fpads:macros"),Fn=/\[([\s\S]+?)\]/g;class Macros{constructor(t={},e=Fn){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):"number"==typeof t||"boolean"==typeof t?t.toString():""}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 Mn("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=xn(n||"",{strictNullHandling:!0,decoder:t=>t}),a=Pn(Macros.process_obj(s,this,r),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,r,!0)+"?"+a}}function Nn(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)}Macros.patterns={BRACKETS:Fn,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const Un=/^flowplayer:\/\/(.+)/;async function Bn(t){if("string"==typeof t&&Un.test(t)){const e=Un.exec(t),r=e&&window[e[1]];if(r)return Bn(r)}if("function"!=typeof t)return t;try{return await t()}catch(t){return""}}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"}}}const jn=Object.prototype,Gn=Object.getPrototypeOf;const Hn=Sr("fpads:ads:state");var Vn;!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"}(Vn||(Vn={}));class AdsState{constructor(t=0){this._state=t}static of(){return new AdsState}reset(){this._state=0}toggleState(t,e){return void 0===t&&Hn(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 Kn={ok:Sr("fpads:analytics:request-queue"),err:Sr("fpads:analytics:request-queue:err"),warn:Sr("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 Kn.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(RequestQueue.is_high_water(t))return Kn.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){Kn.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(Kn.ok(`Request[${i.event_type}] request`,i,t.stats),Date.now()<t.stats.ttl)return Kn.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),Kn.warn(`Request[${i.event_type}] timed out in ${n.timeout}ms`,t.stats)},n.onerror=function(e){RequestQueue.handle_error(t,n),e&&Kn.err(e),Kn.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--,Kn.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){Kn.err(t)}}static rpush(t,...e){return e.forEach(e=>{if(RequestQueue.is_high_water(t))return Kn.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 qn={"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"},Wn={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"},zn={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},Yn={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"},Xn={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 qn[t]}static getBrowserTypeByAlias(t){return Wn[t]||""}}const Qn=/version\/(\d+(\.?_?\d+)+)/i,$n=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},r=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||Utils.getFirstMatch(Qn,t);return r&&(e.version=r),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},r=Utils.getFirstMatch(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},r=Utils.getFirstMatch(Qn,t);return r&&(e.version=r),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},r=Utils.getFirstMatch(Qn,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 Zn=[{test:[/Roku\/DVP/],describe(t){const e=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:Yn.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:Yn.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:Yn.Windows,version:e,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:Yn.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:Yn.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:Yn.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:Yn.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:Yn.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:Yn.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:Yn.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:Yn.Tizen,version:e}}},{test:[/linux/i],describe:()=>({name:Yn.Linux})},{test:[/CrOS/],describe:()=>({name:Yn.ChromeOS})},{test:[/PlayStation 4/],describe(t){const e=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:Yn.PlayStation4,version:e}}}],Jn=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(t){const e=Utils.getFirstMatch(/(can-l01)/i,t)&&"Nova",r={type:zn.mobile,vendor:"Huawei"};return e&&(r.model=e),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:zn.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:zn.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:zn.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:zn.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:zn.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:zn.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:zn.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:zn.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:zn.mobile})},{test:t=>"blackberry"===t.getBrowserName(!0),describe:()=>({type:zn.mobile,vendor:"BlackBerry"})},{test:t=>"bada"===t.getBrowserName(!0),describe:()=>({type:zn.mobile})},{test:t=>"windows phone"===t.getBrowserName(),describe:()=>({type:zn.mobile,vendor:"Microsoft"})},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:()=>({type:zn.tablet})},{test:t=>"android"===t.getOSName(!0),describe:()=>({type:zn.mobile})},{test:t=>"macos"===t.getOSName(!0),describe:()=>({type:zn.desktop,vendor:"Apple"})},{test:t=>"windows"===t.getOSName(!0),describe:()=>({type:zn.desktop})},{test:t=>"linux"===t.getOSName(!0),describe:()=>({type:zn.desktop})},{test:t=>"playstation 4"===t.getOSName(!0),describe:()=>({type:zn.tv})},{test:t=>"roku"===t.getOSName(!0),describe:()=>({type:zn.tv})}],ts=[{test:t=>"microsoft edge"===t.getBrowserName(!0),describe(t){if(/\sedg\//i.test(t))return{name:Xn.Blink};const e=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:Xn.EdgeHTML,version:e}}},{test:[/trident/i],describe(t){const e={name:Xn.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:Xn.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:Xn.Gecko},r=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:Xn.Blink})},{test:[/(apple)?webkit/i],describe(t){const e={name:Xn.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($n,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(Zn,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(Jn,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(ts,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))}}
|
|
373
|
+
/*! 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);var s=this.context.headers;if(s)for(var a in s)r.setRequestHeader(a,s[a])}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 ci=Object.freeze({__proto__:null,ATTACHED:"hls:attached"});const hi="com.widevine.alpha";const fi="application/vnd.apple.mpegURL",pi=[fi,"application/x-mpegurl"],gi=document.createElement("video").canPlayType(fi);function vi({src:t="",type:e="",drm:r},i){const n=(null==i?void 0:i.hls)||{},s="native"in n&&n.native;return(!gi||!s)&&(!(r&&!Object.keys(r).find(t=>{return e=t,[hi].filter((function(t){return t===e})).length;var e}))&&(!(!e||!pi.includes(e))||function(t){const{pathname:e}=nr(t);return e.endsWith(".m3u8")}(t)))}var mi="audio:set",yi="audio:update",Ei="audio:tracks";const Ti=[di.Events.SUBTITLE_TRACKS_UPDATED,di.Events.SUBTITLE_TRACK_SWITCH,di.Events.LEVEL_SWITCHED];function _i(t,e){Ti.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 bi,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(t){t[t.FRAGMENT_ERRORS=0]="FRAGMENT_ERRORS",t[t.STALE_MANIFEST=1]="STALE_MANIFEST"}(bi||(bi={}));const Ai=Sr("hls:failover");class FailoverLoaderController{constructor(){this.playlistCounts={},this.fragmentFailures={},this.ttlMilliseconds=3e3}setHls(t){this.hls=t}reset(){return this.playlistCounts={},this.fragmentFailures={},this}failover(t){var e;this.reset();const r=this.hls;if(!r)return;if(r.levels[r.currentLevel].url.length<2)return;const i=r.levels[r.currentLevel].details;r.levelController.redundantFailover(r.currentLevel),null===(e=r.media)||void 0===e||e.dispatchEvent(new CustomEvent("hls/failover",{detail:{reason:t,from:null==i?void 0:i.url}}))}currentLevel(){var t;return null===(t=this.hls)||void 0===t?void 0:t.levels[this.hls.currentLevel]}nextTTL(){var t;const e=Date.now()+this.ttlMilliseconds,r=this.currentLevel();if(!r)return e;const i=null===(t=r.details)||void 0===t?void 0:t.averagetargetduration;return i?Date.now()+500*i:e}ensurePlaylistUpdating(t,e){this.playlistCounts[t]||(this.playlistCounts[t]={checksum:e,count:0,ttl:this.nextTTL()});const r=this.playlistCounts[t];Date.now()<r.ttl||(r.count=r.checksum===e?r.count+1:0,r.ttl=this.nextTTL(),r.checksum=e,r.count<3||(Ai(`${t} / no change in ${r.count} tries`,this.playlistCounts),this.failover(bi.STALE_MANIFEST)))}trackFragmentError(t){const e=this.fragmentFailures[t]||0;this.fragmentFailures[t]=e+1,this.fragmentFailures[t]>2&&this.failover(bi.FRAGMENT_ERRORS)}createPlaylistLoader(){const t=this;return class extends di.DefaultConfig.loader{load(e,r,i){const n=i.onSuccess;i.onSuccess=({data:e,url:r},...i)=>{t.ensurePlaylistUpdating(r,e),n({data:e,url:r},...i)},super.load(e,r,i)}}}createFragmentLoader(){const t=this;return class extends di.DefaultConfig.loader{load(e,r,i){const n=i.onError;i.onError=e=>{t.trackFragmentError(e.url),n(...arguments)},super.load(e,r,i)}}}}const Li=Sr("hls");function wi(t,e,r){if(!t.reaper||!r.src)return;t.hls&&t.hls.destroy();const n="live"in e==0,s={is_audio_only:!1,fragDuration:-1};if(r.drm&&!ir()&&"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname)return t.emit(i,{message:"Secure page required for DRM"});const a=new FailoverLoaderController,o=function(t){return Object.assign(Object.assign({autoStartLoad:!1,levelLoadingMaxRetry:1},t.hls),{startPosition:t.start_time||-1})}(e);o.pLoader=a.createPlaylistLoader(),o.fLoader=a.createFragmentLoader();const l=t.hls=new di(o);a.setHls(l),l.subtitleDisplay=!1,l.attachMedia(t),l.loadSource(r.src),t.emit("hls:attached",{hls:l}),function(t,e){t.on(di.Events.AUDIO_TRACKS_UPDATED,(function(t,r){e.emit(Ei,r.audioTracks)})),t.on(di.Events.AUDIO_TRACK_SWITCHING,(function(t,r){e.emit(yi,r)})),t.on(di.Events.MANIFEST_PARSED,(function(t,r){r.audioTracks&&e.emit(Ei,r.audioTracks)})),t.on(di.Events.LEVEL_SWITCHED,(function(r,i){const n=t.levels[i.level];n&&e.emit(Ei,t.audioTracks.filter((function(t){return t.groupId&&~(n.audioGroupIds||[]).indexOf(t.groupId)})))}))}(l,t),_i(l,t);const u=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.level;"number"==typeof r&&(l.levels[r]||-1===r?l.nextLevel=r:console.error(new Error("skipping invalid quality: "+t.data)))},d=function(t){var e;const r=null===(e=t.data)||void 0===e?void 0:e.id;"number"==typeof r&&r!=l.audioTrack&&setTimeout((function(){l.audioTrack=r}),0)};t.on("quality:set",u),t.on(mi,d),t.on("src",(function(){t.hls&&t.hls.destroy(),t.off("quality:set",u),t.off(mi,d)})),t.on("audioonlysource",(function(){s.is_audio_only=!0})),t.on(L,(function(){l&&l.destroy()})),t.on("remotesession:started",()=>{t.hls&&t.hls.stopLoad()}),t.on("remotesession:ended",()=>{t.hls&&Di(t)}),n&&l.on(di.Events.LEVEL_LOADED,(function(e,r){t.setOpts({live:r.details.live})})),l.on(di.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){var i,n;if(!t.hls)return;Li("Initializer::maybe_start_load_with_quality (start_quality, preload): (%d, %s)",e.start_quality,e.preload),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));const s=(null===(i=e.hls)||void 0===i?void 0:i.maxBufferSize)||1024,a=(null===(n=e.hls)||void 0===n?void 0:n.maxBufferLength)||30;Li("Setting maxBufferSize to %d",s),t.hls.config.maxBufferSize=s,"metadata"===e.preload&&Li("preload === metadata, setting maxBufferLength to 1sec");if(t.hls.config.maxBufferLength="metadata"===e.preload?1:a,t.once(E,()=>{Li("Playback started, set maxBufferLenght to %d",a),t.hls&&(t.hls.config.maxBufferLength=a)}),"none"===e.preload&&!e.autoplay)return;Di(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})})),l.on(di.Events.INIT_PTS_FOUND,(function(t,e){s.fragDuration=e.frag.duration})),l.on(di.Events.ERROR,(function(e,r){!function(t,e){var r,n;if(0==t.reaper)return;if(0==e.fatal)return;switch(e.type){case di.ErrorTypes.MEDIA_ERROR:return null===(r=t.hls)||void 0===r?void 0:r.recoverMediaError();case di.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 di.ErrorTypes.KEY_SYSTEM_ERROR:return 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);default:null===(n=t.hls)||void 0===n||n.destroy()}}(t,r)})),l.on(di.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)})),l.on(di.Events.LEVEL_SWITCHING,(e,r)=>{const i=l.levels[l.currentLevel],n=l.levels[r.level];t.emit("qualitychange",{before:i,after:n,kind:"hls"})});const c=t.opt("start_time");c&&t.once(p,(function(){t.currentTime=c})),"none"!==e.preload||e.autoplay||t.once("beforeplay",()=>{t.hasState("is-casting")||Di(t,e.start_time||-1)})}function Di(t,e){var r;!t.hasState(Z)&&t.setState(J,!0),null===(r=t.hls)||void 0===r||r.startLoad(e)}class HLS{init(){}onload(t,e,r,i){wi(r,t,i)}wants(t,e,r){return di.isSupported()&&vi(e,r)}}HLS.events=ci,HLS.version=di.version,HLS.failover={Reasons:bi},ie(window,HLS);const Ri=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),ki=(...t)=>t.reduce((t,e)=>Ri(e)?(Object.keys(e).forEach(r=>{if(Ri(t[r])&&Ri(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 Oi(t){return fetch(t).then(t=>t.json())}function Ii(){let t=[].join.call(arguments,"/");return"/"!==t[0]&&(t="/"+t),Ci()+"/web/public/native/config"+t}const Ci=()=>"https://ljsp.lwcdn.com";function Pi(t){return~t.indexOf("/")?t:"/media/"+t}var xi={404:"media not found",402:"invalid subscription",400:"bad request",415:"unsupported media type"};function Mi(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 Fi(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 Ni=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;function Ui(t){return"object"==typeof t&&"ovp/base64"==t.type}function Bi(t,e){return function(t,e){return!t.startsWith("blob:")&&(!(~t.indexOf(".")||!Ni.test(t))&&(e.type="video/ovp",!0))}(t,e)||Ui(e)}function ji(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 Gi(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 Hi(t){return t.live}var Vi=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 Ki(t,e){const r=null==e?void 0:e.src;if(Ui(e))return function(t,e){const r=ji(e.src||"");if(function(t){return"string"==typeof t.err}(r))return console.error(r.err);qi(t,r)}(t,e);r&&Pipe.of(r).fmap(Pi).fmap(Ii).fmap(t=>fetch(t)).fmap(e=>e.then(t=>Promise.all([t.status,t.json()])).then(([e,r])=>200==e?qi(t,r):Wi(t,r)))}function qi(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"),Wi(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=>{e.ima&&Object.assign(t,{ima:e.ima});const i=Fi(t,r);return delete i.playlist,i});return delete n.ima,Object.assign(n,{playlist:s})}(t.opts,e))}(t,e):Hi(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(Gi).unwrap());t.emit("ovp:live:countdown:start",Pipe.of(e).fmap(Fi,t.opts).fmap(Mi).unwrap())}(t,e):function(t,e){t.emit("ovp:request:media:complete",Pipe.of(e).fmap(Fi,t.opts).fmap(Mi).unwrap())}(t,e)}function Wi(t,e){return e.message?t.emit("ovp:error",e):e.status?t.emit("ovp:error",new Error(xi[e.status])):t.emit("ovp:error",e)}const zi={};function Yi(t,e,r){"object"!=typeof zi[e]&&(zi[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 Xi=!1;function Qi(t,e,r){$i()||Pipe.of("recommendation").fmap(Ii,e,r).fmap(Oi).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(Zi))}function $i(){return Xi}function Zi(t){Xi=!0,console.error("Failed to load recommendations: %j",t)}function Ji(t){const e=Date.now()-(t.server_time_offset||0);return Math.floor(((t.live_start_time||0)-e)/1e3)}function tn(t,e){let r=0;function i(){const i=Ji(e);if(i<0||isNaN(i)||0===t.reaper||void 0===e.live_start_time)return clearInterval(r),function(t,e,r){t.emit("ovp:live:countdown:complete");const i=xt(t,Y);i&&i.remove(),t.root.classList.remove("is-livecountdown"),r||t.emit("ovp:request:media:complete",e)}(t,e,void 0===e.live_start_time);!function(t,e,r,i){r.classList.add("is-livecountdown"),e.emit("ovp:live:countdown:tick",{remaining_time:en(i+1)}),e.hasState(tt)||e.setState(tt,!0)}(0,t,t.root,i)}var n;n=e,Or().then(t=>Object.assign(n,{server_time_offset:t})),i(),r=setInterval(i,250)}function en(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+Ut(e.hours)+":"+Ut(e.minutes)+":"+Ut(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=Ft("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 rn=["*.lwcdn.com","*.flowplayer.com"];class OVP{constructor(t){vt(t,Y,FlowplayerLiveCountdown)}onload(t,e,r,i){if("string"==typeof i.src)return"string"!=typeof t.player_id||0===i.src.indexOf(t.player_id)||Ui(i)||(i.src=[t.player_id,i.src].join("/")),Ki(r,i)}wants(t,e,r){return Bi(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=Gi(n.metadata.live_start_time)),r.setOpts(n);break}}})),r.on("beforeplay",(function(e){const r=t;if(Hi(r)){if(nn(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 e||Ji(e)>0)return;const i=a(e);r.setOpts(i),r.setAttrs(i),i.src&&r.setSrc(i.src)})),r.on(w,(function({data:i}){var n,s;if("string"==typeof t.src&&Bi(t.src,{}))return;if(t.src&&sn(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(rn).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?nr(document.referrer).hostname:document.location.hostname}catch(t){return window.location.hostname}}(),i.domains))return he({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 zi[e])return console.debug("using Cache(%s)",e),Yi(t,e,zi[e]);Pipe.of(e).fmap(Ii).fmap(Oi).fmap(r=>r.then(r=>Yi(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=bt(e,["playlist"]),s=a(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),Ji(n)<=0)return r.emit("ovp:request:media:complete",n);xt(r,Y)||(e.appendChild(gt(r,Y)),tn(r,t))})),r.on("timeupdate",(function(){var e,i,n;const s=t;Hi(s)?nn(s)||(r.togglePlay(!1),r.emit(b)):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||$i()||(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)&&Qi(r,t.metadata.media_id,t.metadata.player_id))})),r.on(L,(function(){n.disconnect()}))}}function nn(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)||Gi(i)>Date.now()}OVP.events=Vi;const sn=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 an(t){return{width:t.clientWidth,height:t.clientHeight}}function on(t,e,r){return"number"==typeof r&&(r+="px"),t.style.setProperty(e,r),t}ie(window,OVP);const ln="ad-initialized";var un=Object.freeze({__proto__:null,AD_INIT:ln,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-rendering-settings",ADAPTER_INIT_FAILED:"ad-adapter-init-failed",AD_PLAY_REQUESTED:"ad-play-requested",RELOAD_AD_REQUESTED:"reload-ad-requested",AD_ERROR:"ad-error",REQUEST_AD_PAUSE:"request/ad/pause",REQUEST_AD_PLAY:"request/ad/play",REQUEST_AD_MUTE_UNMUTE:"request/ad/muteunmute"});const dn="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;const cn=Sr("ads/lifecycle"),hn=["ad-playback-error","ad-teardown","ad-break-completed"];async function fn({config:t,root:e,content:r,ads:i,ima:n}){var s;cn("LifeCycle::initLifeCycle",t,e,r,i,n),r.autoplay=!1;const a=t.autoplay===yt.AUDIO_REQUIRED,o=function(t,e){return{muted:!(e||!t.muted),volume:t.volume}}(r,a);r.on("volumechange",()=>{o.volume=r.volume,o.muted=r.muted});const l=gt(r,"flowplayer-ad-ui"),u=l.adContainer;l.setUiFlags(null===(s=t.ads)||void 0===s?void 0:s.ui),e.append(l);const d={listening:!1,preload:null==n?void 0:n.preload_ads};if(cn("initial",o),i.setVideoTag(r),t.autoplay){cn("Trying to autoplay"),l.hideFirstFrame(e);await async function t(e,r){const[i,n]=[e.muted,e.volume];cn("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 cn("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),cn("Lifecycle::peek_content::play"),await new Promise(t=>setTimeout(()=>t(e.togglePlay(!0)))),cn("Lifecycle::peek_content::pause"),await new Promise(t=>setTimeout(()=>t(e.togglePlay(!1)))),e.volume=n,cn("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?(cn("Lifecycle::peek_content::false"),await s()):(cn("Lifecycle::peek_content::recover"),e.muted=!0,!!await t(e)||(e.muted=i,cn("Lifecycle::peek_content::false"),await s()))}}(r,a)?(cn("Can autoplay, start ad"),r.opts.autoplay=1,pn({ads:i,content:r,state:d,adContainer:u,ima:n,config:t})):(cn("cannot autoplay(audioRequired: %s), fallback to poster state",a),t.autoplay=0,l.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(ot)||"touchend"!=o.type)&&e.shallPlayAd(0)&&(!dn&&o.preventDefault(),yn({ads:e,content:t,state:i}),cn("user_gesture(:intercept) -> shallPlayAd(0: %s)",e.shallPlayAd(0)),r.muted=n.muted,await pn({ads:e,content:t,state:i,adContainer:s,ima:a,config:r}),En({ads:e,content:t}))}))}({content:r,ads:i,config:t,state:d,initial:o,adContainer:u,ima:n}),!t.autoplay&&i.hasPreroll()&&d.preload&&pn({ads:i,content:r,state:d,adContainer:u,ima:n,config:t}),mn({config:t,root:e,content:r,ads:i,state:d,adContainer:u,ui:l,ima:n,initial:o}),r.on("src",()=>{r.once("beforeplay",()=>i.resetScheduleCounter())}),r.on("beforeplay",t=>{(i.adBreak||i.adPlaying||i.adRequesting)&&(i.adBreak&&!i.adLinear||(cn("prevented content from starting because ad break is active"),t.preventDefault()))})}async function pn(t){t.state.started||(t.content.hasState(ot)?await gn(t):t.content.once("viewenter",async()=>{await gn(t)}))}async function gn({ads:t,content:e,adContainer:r,ima:i,state:n,config:s}){var a;n.started=!0;const o=bt(i,["ads"]),l=an(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:dn,preload_ads:null===(a=null==s?void 0:s.ima)||void 0===a?void 0:a.preload_ads},o),l));cn("start():",d,n),await t.initialize(!1,d,n.preload)}function vn(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 mn({config:t,root:e,content:r,ads:i,initial:n,adContainer:s,state:a,ui:o,ima:l}){cn("addUIListeners()"),r.once(E,async n=>{if(i){if(cn("addUIListeners() -> content started playing"),yn({ads:i,content:r,state:a}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return cn("addUIListeners() -> no more preroll ads -> resume content"),o.showFirstFrame(e),await pn({ads:i,content:r,state:a,adContainer:s,ima:l,config:t});r.togglePlay(!1),await pn({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),En({ads:i,content:r}))}}),r.on([R,D],(function(){if(!i)return;const{content_width:t,content_height:n}=vn(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(b,t=>{var e;i&&(cn("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(),Object.assign(t,{prevented_from_ads:!0}),i.finished((function(){r.emit(b,{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(cn(`Ad[linear: ${a}, currentTime: ${r.currentTime}] starting`,l),"preroll"==u&&!a&&r.paused&&r.togglePlay(!0),"preroll"==u&&a&&r.currentTime>0&&!r.opt("start_time")&&!r.opt("live")&&(cn("Preroll[rewind: true]",r.currentTime),r.currentTime=0),a&&(d=vn(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){cn("non-linear ad / restarting content");try{r.togglePlay(!0),r.volume=n.volume,r.muted=n.muted}catch(t){cn(t)}}!r.hasState(ot)&&a&&i.pause()}),i.on("ad-pause-content",()=>{o.resize({linear:!0,width:0,height:0})}),r.on(hn,t=>async function({root:t,content:e,ads:r,ui:i,eventName:n,err:s={reason:""}}){cn("teardown(event: %s)",n),t.classList.add("is-seamless"),i.classList.remove("is-vpaid"),t.classList.remove(it),s.reason&&cn("teardown(:err, reason: %s) %o",s.reason);i.classList.remove("on");const a=r.getLastAd();if(i.showFirstFrame(t),!r.shouldRestartContent())return cn("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),Tn(t);if(e.currentTime>0&&e.currentTime>=e.duration||"postroll"==r.ad_type||!1===(null==a?void 0:a.restart))return cn("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),Tn(t);""===e.currentSrc&&e.setSrc(e.original_src);e.paused&&r.shouldRestartContent()&&(cn("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await e.togglePlay(!0));if(!e.paused)return cn("Lifecycle.teardown(:ok)","restarted video content"),Tn(t)}({root:e,content:r,ads:i,ui:o,err:t.detail,eventName:t.type}));let u=!!t.autoplay;var d;r.on("viewenter",()=>{u&&i.resume()}),r.on("viewleave",(d=()=>{u=!i.paused,i.pause()},t=>{setTimeout((function(){if(!t.defaultPrevented)return d(t)}),0)}))}function yn({ads:t,content:e,state:r}){r.listening||(e.on(["timeupdate",S,E,A],r=>{t.adPlaying&&t.adapter.isLinearAd()&&!t.adapter.isSharedVideoTag()&&!e.paused&&e.pause(),En({ads:t,content:e,seek:r.type===A})}),r.listening=!0)}function En({ads:t,content:e,seek:r=!1}){t&&t.setCurrentTime(e.currentTime,void 0,r)}function Tn(t){t.classList.remove("is-seamless")}const _n=Sr("ads/timers");class TimerRegistry{constructor(t={},e={}){this.intervals=t,this.timers=e}}let bn=-1;function Sn(t,e,r){const i=setInterval(r,e);if(_n("TimerRegistry.createInterval() -> "+i,t.intervals),"object"==typeof i){const e=++bn;return t.intervals[e]=e,e}return t.intervals[i]=i,i}function An(t){if(t)return _n("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach(e=>function(t,e){return _n("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 _n("TimerRegistry.removeTimeout() -> "+e,t.timers),clearTimeout(t.timers[e]),delete t.timers[e],t}(t,e)),t}function Ln(t){try{return t.getAdPodInfo().getPodIndex()}catch(t){return}}class IMA{constructor(t){this.eventHandler=t,this.log=Sr("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(){An(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),An(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(ln,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"),An(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{An(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,An(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)}});const s=this.getVideoTag();if(!s)return;const a=()=>{e&&(this._started=!0),t.start(),this.eventHandler.trigger("ad-play-requested")};if(!e||s.hasState(ot))return a();s.paused||s.pause(),s.once("viewenter",()=>a())})}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 Sn(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=function(t){try{return t.getAdPodInfo().getAdPosition()}catch(t){return}}(e),i=function(t){try{return t.getAdPodInfo().getTotalAds()}catch(t){return}}(e),n={ad:{duration:e.getDuration(),width:e.getWidth(),height:e.getHeight(),position:r,totals:i},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)`,n,e),this.eventHandler.trigger(t,n)}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:Ln(e),ad:e})}catch(t){}}}var wn=Oe((function(t,e){var r=function(){for(var t=new Array(256),e=0;e<256;++e)t[e]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return t}(),i=Object.prototype.hasOwnProperty;e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(r[i]=t[i]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r){if(Array.isArray(t))t.push(r);else{if("object"!=typeof t)return[t,r];(n.plainObjects||n.allowPrototypes||!i.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=e.arrayToObject(t,n)),Object.keys(r).reduce((function(t,s){var a=r[s];return i.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a,t}),s)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),i="",n=0;n<e.length;++n){var s=e.charCodeAt(n);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?i+=e.charAt(n):s<128?i+=r[s]:s<2048?i+=r[192|s>>6]+r[128|63&s]:s<55296||s>=57344?i+=r[224|s>>12]+r[128|s>>6&63]+r[128|63&s]:(n+=1,s=65536+((1023&s)<<10|1023&e.charCodeAt(n)),i+=r[240|s>>18]+r[128|s>>12&63]+r[128|s>>6&63]+r[128|63&s])}return i},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;var i=r||[],n=i.indexOf(t);if(-1!==n)return i[n];if(i.push(t),Array.isArray(t)){for(var s=[],a=0;a<t.length;++a)t[a]&&"object"==typeof t[a]?s.push(e.compact(t[a],i)):void 0!==t[a]&&s.push(t[a]);return s}for(var o=Object.keys(t),l=0;l<o.length;++l){var u=o[l];t[u]=e.compact(t[u],i)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!=t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}})),Dn={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Rn={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:wn.encode},kn=function t(e,r,i,n,s,a,o,l,u){var d=e;if("function"==typeof o)d=o(r,d);else if(d instanceof Date)d=d.toISOString();else if(null===d){if(n)return a?a(r):r;d=""}if("string"==typeof d||"number"==typeof d||"boolean"==typeof d||wn.isBuffer(d))return a?[a(r)+"="+a(d)]:[r+"="+String(d)];var c,h=[];if(void 0===d)return h;if(Array.isArray(o))c=o;else{var f=Object.keys(d);c=l?f.sort(l):f}for(var p=0;p<c.length;++p){var g=c[p];s&&null===d[g]||(h=Array.isArray(d)?h.concat(t(d[g],i(r,g),i,n,s,a,o,l,u)):h.concat(t(d[g],r+(u?"."+g:"["+g+"]"),i,n,s,a,o,l,u)))}return h},On=Object.prototype.hasOwnProperty,In={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:wn.decode},Cn=function(t,e,r){if(t){var i=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,n=/(\[[^[\]]*])/g,s=/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,o=[];if(a){if(!r.plainObjects&&On.call(Object.prototype,a)&&!r.allowPrototypes)return;o.push(a)}for(var l=0;null!==(s=n.exec(i))&&l<r.depth;){if(l+=1,!r.plainObjects&&On.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;o.push(s[1])}return s&&o.push("["+i.slice(s.index)+"]"),function t(e,r,i){if(!e.length)return r;var n,s=e.shift();if("[]"===s)n=(n=[]).concat(t(e,r,i));else{n=i.plainObjects?Object.create(null):{};var a="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,o=parseInt(a,10);!isNaN(o)&&s!==a&&String(o)===a&&o>=0&&i.parseArrays&&o<=i.arrayLimit?(n=[])[o]=t(e,r,i):n[a]=t(e,r,i)}return n}(o,e,r)}},Pn=function(t,e){var r,i,n=t,s=e||{},a=void 0===s.delimiter?Rn.delimiter:s.delimiter,o="boolean"==typeof s.strictNullHandling?s.strictNullHandling:Rn.strictNullHandling,l="boolean"==typeof s.skipNulls?s.skipNulls:Rn.skipNulls,u=("boolean"==typeof s.encode?s.encode:Rn.encode)?"function"==typeof s.encoder?s.encoder:Rn.encoder:null,d="function"==typeof s.sort?s.sort:null,c=void 0!==s.allowDots&&s.allowDots;if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof s.filter?n=(i=s.filter)("",n):Array.isArray(s.filter)&&(r=i=s.filter);var h,f=[];if("object"!=typeof n||null===n)return"";h=s.arrayFormat in Dn?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var p=Dn[h];r||(r=Object.keys(n)),d&&r.sort(d);for(var g=0;g<r.length;++g){var v=r[g];l&&null===n[v]||(f=f.concat(kn(n[v],v,p,o,l,u,i,d,c)))}return f.join(a)},xn=function(t,e){var r=e||{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.delimiter="string"==typeof r.delimiter||wn.isRegExp(r.delimiter)?r.delimiter:In.delimiter,r.depth="number"==typeof r.depth?r.depth:In.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:In.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:In.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:In.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:In.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:In.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:In.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:In.strictNullHandling,""===t||null==t)return r.plainObjects?Object.create(null):{};for(var i="string"==typeof t?function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),n=0;n<i.length;++n){var s,a,o=i[n],l=-1===o.indexOf("]=")?o.indexOf("="):o.indexOf("]=")+1;-1===l?(s=e.decoder(o),a=e.strictNullHandling?null:""):(s=e.decoder(o.slice(0,l)),a=e.decoder(o.slice(l+1))),On.call(r,s)?r[s]=[].concat(r[s]).concat(a):r[s]=a}return r}(t,r):t,n=r.plainObjects?Object.create(null):{},s=Object.keys(i),a=0;a<s.length;++a){var o=s[a],l=Cn(o,i[o],r);n=wn.merge(n,l,r)}return wn.compact(n)};const Mn=Sr("fpads:macros"),Fn=/\[([\s\S]+?)\]/g;class Macros{constructor(t={},e=Fn){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):"number"==typeof t||"boolean"==typeof t?t.toString():""}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 Mn("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=xn(n||"",{strictNullHandling:!0,decoder:t=>t}),a=Pn(Macros.process_obj(s,this,r),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,r,!0)+"?"+a}}function Nn(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)}Macros.patterns={BRACKETS:Fn,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const Un=/^flowplayer:\/\/(.+)/;async function Bn(t){if("string"==typeof t&&Un.test(t)){const e=Un.exec(t),r=e&&window[e[1]];if(r)return Bn(r)}if("function"!=typeof t)return t;try{return await t()}catch(t){return""}}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"}}}const jn=Object.prototype,Gn=Object.getPrototypeOf;const Hn=Sr("fpads:ads:state");var Vn;!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"}(Vn||(Vn={}));class AdsState{constructor(t=0){this._state=t}static of(){return new AdsState}reset(){this._state=0}toggleState(t,e){return void 0===t&&Hn(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 Kn={ok:Sr("fpads:analytics:request-queue"),err:Sr("fpads:analytics:request-queue:err"),warn:Sr("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 Kn.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(RequestQueue.is_high_water(t))return Kn.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){Kn.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(Kn.ok(`Request[${i.event_type}] request`,i,t.stats),Date.now()<t.stats.ttl)return Kn.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),Kn.warn(`Request[${i.event_type}] timed out in ${n.timeout}ms`,t.stats)},n.onerror=function(e){RequestQueue.handle_error(t,n),e&&Kn.err(e),Kn.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--,Kn.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){Kn.err(t)}}static rpush(t,...e){return e.forEach(e=>{if(RequestQueue.is_high_water(t))return Kn.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 qn={"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"},Wn={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"},zn={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},Yn={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"},Xn={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 qn[t]}static getBrowserTypeByAlias(t){return Wn[t]||""}}const Qn=/version\/(\d+(\.?_?\d+)+)/i,$n=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},r=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||Utils.getFirstMatch(Qn,t);return r&&(e.version=r),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},r=Utils.getFirstMatch(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},r=Utils.getFirstMatch(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,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(Qn,t);return r&&(e.version=r),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},r=Utils.getFirstMatch(Qn,t);return r&&(e.version=r),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},r=Utils.getFirstMatch(Qn,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 Zn=[{test:[/Roku\/DVP/],describe(t){const e=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:Yn.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:Yn.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:Yn.Windows,version:e,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:Yn.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:Yn.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:Yn.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:Yn.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:Yn.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:Yn.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:Yn.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:Yn.Tizen,version:e}}},{test:[/linux/i],describe:()=>({name:Yn.Linux})},{test:[/CrOS/],describe:()=>({name:Yn.ChromeOS})},{test:[/PlayStation 4/],describe(t){const e=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:Yn.PlayStation4,version:e}}}],Jn=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(t){const e=Utils.getFirstMatch(/(can-l01)/i,t)&&"Nova",r={type:zn.mobile,vendor:"Huawei"};return e&&(r.model=e),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:zn.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:zn.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:zn.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:zn.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:zn.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:zn.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:zn.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:zn.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:zn.mobile})},{test:t=>"blackberry"===t.getBrowserName(!0),describe:()=>({type:zn.mobile,vendor:"BlackBerry"})},{test:t=>"bada"===t.getBrowserName(!0),describe:()=>({type:zn.mobile})},{test:t=>"windows phone"===t.getBrowserName(),describe:()=>({type:zn.mobile,vendor:"Microsoft"})},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:()=>({type:zn.tablet})},{test:t=>"android"===t.getOSName(!0),describe:()=>({type:zn.mobile})},{test:t=>"macos"===t.getOSName(!0),describe:()=>({type:zn.desktop,vendor:"Apple"})},{test:t=>"windows"===t.getOSName(!0),describe:()=>({type:zn.desktop})},{test:t=>"linux"===t.getOSName(!0),describe:()=>({type:zn.desktop})},{test:t=>"playstation 4"===t.getOSName(!0),describe:()=>({type:zn.tv})},{test:t=>"roku"===t.getOSName(!0),describe:()=>({type:zn.tv})}],ts=[{test:t=>"microsoft edge"===t.getBrowserName(!0),describe(t){if(/\sedg\//i.test(t))return{name:Xn.Blink};const e=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:Xn.EdgeHTML,version:e}}},{test:[/trident/i],describe(t){const e={name:Xn.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:Xn.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:Xn.Gecko},r=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return r&&(e.version=r),e}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:Xn.Blink})},{test:[/(apple)?webkit/i],describe(t){const e={name:Xn.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($n,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(Zn,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(Jn,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(ts,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))}}
|
|
374
374
|
/*!
|
|
375
375
|
* Bowser - a browser detector
|
|
376
376
|
* https://github.com/lancedikson/bowser
|
|
377
377
|
* MIT License | (c) Dustin Diaz 2012-2015
|
|
378
378
|
* MIT License | (c) Denis Demchenko 2015-2019
|
|
379
|
-
*/const es=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 Wn}static get ENGINE_MAP(){return Xn}static get OS_MAP(){return Yn}static get PLATFORMS_MAP(){return zn}}.parse(window.navigator.userAgent),{platform:rs,os:is,browser:ns}=es,ss=t=>t&&t.toLowerCase();var as={rnd:Math.random().toString(36).substr(2,32),os:ss(is.name+(is.versionName?" "+is.versionName:"")),device:ss(rs.type),browser:ss(ns.name),browser_version:(ns&&ns.version?ns.version:"unknown").split(".").shift(),plugin_version:"3.4.1"};const os="https://fp-eu-w1-aai.flowplayer.com/in",ls="POST",us=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],ds=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],cs=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],hs=Sr("ads/analytics"),fs=RequestQueue.of(),ps=(...t)=>Object.assign({},...t);class Analytics{constructor(t,e={}){this.emitter=t,this.metadata=ps(as,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),hs(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,ps(t.metadata,e,{player_version:"3.4.1"})),t}wireup(){this.events.forEach(t=>{this.emitter.on(t,e=>{const r=e.detail,i=ps(this.metadata,{event_type:t},r),n=Analytics.pluck_valid_keys(this,i),s=Analytics.ensure_required_keys(this,n);if(hs(`Event[${t}]`,{payload:n,observation:r}),s.length)return hs(`Analytics.validate_metadata() failed for\n Event[${t}]\n missing keys: ${s}`,n);RequestQueue.rpush(fs,[os,ls,n])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const gs=Sr("ads/controller"),vs={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({},vs),t),this.analytics=(e=this,Analytics.of(e,{required_keys:ds,optional_keys:cs,events:us})),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()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const t=()=>{var t;const e=new CustomEvent("ad/playing");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.PLAYING,!0)};this.on("ad-play-requested",t),this.on("ad-started",t),this.on("ad-resumed",t);const e=()=>{var t;if(!this.adPlaying)return;const e=new CustomEvent("ad/paused");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.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",()=>{requestAnimationFrame(()=>{var t;const e=new CustomEvent("ad/complete");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.BREAK_ACTIVE,!1)})}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),e(),this._state.toggleState(Vn.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async t=>{if(gs("Ads.on(RELOAD_AD_REQUESTED)",t),this._schedule){if(e(),t)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(Vn.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(Vn.AD_AVAILABLE,!1))}})}async initialize(t,e={},r){return gs("Ads.initialize():",t,e,r),this._state.toggleState(Vn.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){gs("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(ln,()=>t(e))})})}async adapterInitialized(t){gs("Ads.adapterInitialized()"),this._state.toggleState(Vn.INITIALIZING,!1),this._state.toggleState(Vn.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(Vn.FATAL_ERROR,!0),this._state.toggleState(Vn.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(Vn.FETCHING_AD,!1);else if(n===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),n){gs("Ads.fetchNextAd",n),this._state.toggleState(Vn.FETCHING_AD,!0);try{return await this.requestAd(n),this._state.toggleState(Vn.AD_AVAILABLE,!0),void this._state.toggleState(Vn.FETCHING_AD,!1)}catch(r){if(gs("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(Vn.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(Vn.FETCHING_AD))return;if(this._state.hasAny(Vn.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(Vn.AD_AVAILABLE)||await this.fetchNextAd(t),!this._state.hasAny(Vn.AD_AVAILABLE)||!this.shallPlayAd(t)||e)return;await this.playAd(),await this.setCurrentTime(t),this.checkIfBreakComplete()}catch(t){gs("setCurrentTime: Error(from: setCurrentTime, message: %s)",t.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var t;if(this._state.hasAny(Vn.AD_AVAILABLE)){this._state.toggleState(Vn.AD_AVAILABLE,!1),this._state.toggleState(Vn.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(Vn.BREAK_ACTIVE))return gs("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());gs("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(Vn.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(Vn.BREAK_ACTIVE)&&!this.adapter.isAdPod())return gs("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=e)||"object"!=typeof i||Gn(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 this.dispatch(t,n)}dispatch(t,e){const r=this.adapter.getVideoTag();if(r){gs(":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(Tr,{detail:i}))}catch(t){gs(":error",t)}zt(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&&(gs("Ads.finished"),!(this.adapter.isSharedVideoTag()&&this._state.hasAny(Vn.PLAYING)&&this.adapter.isLinearAd()))){gs("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return gs("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(Vn.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(t){gs("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(Vn.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;gs("Ads.requestAd(ad: %o)",{ad:t,timeout:r,idx:e});const i=await async function t(e){if("function"==typeof e)return[await Bn(e)];if("string"==typeof e)return[await Bn(e)];if(Array.isArray(e)){const t=e;return await Promise.all(t.map(Bn))}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],Nn(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(n,r)}catch(t){return gs(`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(Vn.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(Vn.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(Vn.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var ms=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"}),ys=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 Es(t){return Object.assign({muted:!1,timeout:250,inline:!1},t)}function Ts(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 bs={audio:function(t){return Ts(t=Es(t),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(ms)}}))},video:function(t){return Ts(t=Es(t),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(ys)}}))}};let _s=void 0;async function Ss(t=!0){return _s||(_s=await bs.video({timeout:500,muted:t}),_s)}const As=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"});var Ls=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const ws=["progress","duration","remaining"],Ds=Sr("ads/ui");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)),t.on("ad-progress",t=>{const{remaining:e}=t.detail;this.setAttribute("remaining",e+"")})}static get observedAttributes(){return ws}updateState(t){["ad/paused","ad/playing"].forEach(e=>{const r=e.replace("/","-"),i=t===e;this.player.setState(r,i),this.classList.toggle(r,i)})}hideFirstFrame(t){Ds("hideFirstFrame"),t.classList.toggle("ad-hide-first-frame",!0)}showFirstFrame(t){Ds("showFirstFrame"),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")}setUiFlags(t){if(t=t||0,this.classList.toggle("is-ad-controls-sticky",(1&t)>0),this.classList.toggle("no-fullscreen",(2&t)>0),this.classList.toggle("no-indicator",(4&t)>0),(8&t)>0){const t=document.createElement("div");t.classList.add("ad-attribution"),t.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.adContainer.append(t)}if(this.classList.toggle("no-volume-bar",0==(64&t)),(32&t)>0&&this.controls&&(this.remaining=document.createElement("div"),this.remaining.classList.add("fp-ad-remaining","fp-color-text"),this.controls.prepend(this.remaining)),(16&t)>0&&this.controls){this.classList.toggle("is-ad-choices",!0);const t=document.createElement("div");t.classList.add("fp-ad-choices"),t.textContent=this.player.i18n("ads.adchoices","AdChoices"),t.addEventListener("click",t=>{t.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),this.controls.append(t)}}attributeChangedCallback(t,e,r){switch(t){case"duration":return this.onDurationChange(parseFloat(r));case"progress":return this.onProgress(parseFloat(e),parseFloat(r));case"remaining":return this.onRemaining(r)}}onDurationChange(t){}onProgress(t,e){}onRemaining(t){this.remaining&&(this.remaining.textContent=parseFloat(t).toFixed())}render(){this.adContainer.classList.add("fp-ad-container"),this.append(this.adContainer),this.controls=gt(this.player,"flowplayer-ad-controls");const t=gt(this.player,"flowplayer-ad-countdown");this.append(this.controls,t)}}const Rs=Sr("fpads:native:outstream"),ks={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Os,Is;!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"}(Os||(Os={})),function(t){t[t.None=0]="None",t[t.Booting=1]="Booting",t[t.Ready=2]="Ready",t[t.Disposed=3]="Disposed"}(Is||(Is={}));class Outstream{constructor({ads:t,root:e,content:r,ima:i}){this.state=Is.None,Rs("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 an(t);const e={height:t.style.height};on(t,"opacity",0),on(t,"display","absolute"),on(t,"display","inline-block"),on(t,"height","auto");const r=an(t);return on(t,"height",e.height),on(t,"opacity",1),r}(this.root),this.adUi=new AdUI(r),this.adContainer=this.adUi.adContainer,this.initialVolumeState={},e.classList.add(ks.OUTSTREAM),e.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",t=>{var e;if(this.state==Is.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==Is.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==Is.Disposed)return;const e=t.detail;if(e)switch(this.state){case Is.Booting:return Rs(":boot skipping intersectionchange");case Is.None:return this.state=Is.Booting,this.begin_life_cycle();case Is.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 Rs(`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=Is.Ready;const{error:t,result:e}=await Ss(!1),{result:r}=await Ss(!0);this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!e&&!r),muted:!e},Rs("Outstream.show() :autoplay >> sound="+e),t&&this.content&&!e&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await pn({ads:this.ads,content:this.content,adContainer:this.adContainer,ima:this.ima,state:{listening:!1},config:this.content.opts}),En({content:this.content,ads:this.ads}),this.state=Is.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=()=>{hn.forEach(t=>this.ads.removeListener(t,e));const t=new CustomEvent(Os.OUTSTREAM_TEARDOWN);Rs("Outstream(:teardown)",t),this.content.dispatchEvent(t)};hn.forEach(t=>this.ads.once(t,e)),this.content.once(Os.OUTSTREAM_TEARDOWN,t=>{setTimeout(()=>{if(t.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),mn({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(As)})}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==Is.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=Is.Disposed,e.destroy(),t.innerHTML=""}}function Cs(t){return t&&"number"==typeof t.time}function Ps(t){return t&&"number"==typeof t.percent&&"number"!=typeof t.time}Outstream.CLASS=ks;const xs=Sr("ads/index");function Ms(t,e,r){if(!("google"in window))return console.warn("google.ima unavailable");let i=t.autoplay;t.autoplay&&(xs("handling initial autoplay, original_autoplay: ",i),r.autoplay=!1,t.autoplay=0);const n=r.ads=new AdsController,s=n.analytics;let a=!1;n.resize(an(e)),dn&&(r.on([h,f,"webkitendfullscreen"],t=>{var e;const i=t.type===h;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(b,()=>{r.togglePlay(!1)}),r.webkitExitFullscreen()})})),r.on(L,(function(){n&&n.destroy()})),r.on("src",()=>{if(n)return r.root.classList.contains("ad-paused")||r.root.classList.contains("ad-playing")?n.stop():void n.onContentNewSrc()}),r.on(w,(function({detail:o}){const l=o.ima;if(void 0===i&&o.autoplay&&(i=o.autoplay),!l)return;if(!Array.isArray(l.ads))return xs("handling non-array ima.ads"),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=>Cs(t)||Ps(t)).reduce((t,r)=>{if(Cs(r))return t.push(r),t;if(r.lazy)return t.push(r),t;if(Ps(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 xs("is outstream, returning"),new Outstream({root:e,content:r,ads:n,ima:l});fn({config:Object.assign(Object.assign({},t),{autoplay:i}),root:e,content:r,ads:n,ima:l})}}))}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=`${this.player.i18n("ads.indicator","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=this.player.i18n("ads.indicator","ADS");const t=document.createElement("div");t.classList.add("ad-playback-controls");const e=gt(this.player,H);e.addEventListener("click",()=>this.player.emit("request/ad/play"));const r=gt(this.player,V);r.addEventListener("click",()=>this.player.emit("request/ad/pause")),t.append(e,r);const i=gt(this.player,z);i.addEventListener("click",()=>this.player.emit("request/ad/muteunmute"));const n=gt(this.player,M),s=gt(this.player,N);this.append(this.indicatorControl,t,i,n,s)}}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:Fs}=r();class Ads{constructor(t){this.umd=t,vt(t,"flowplayer-ad-ui",AdUI),vt(t,"flowplayer-ad-controls",AdControls),vt(t,"flowplayer-ad-countdown",AdCountdown)}init(t,e,r){if(ce.from_token(t.token||"").is_granted(ce.permissions.ADS)&&!Fs)return Ms(t,e,r)}}return Ads.events=un,Ads.ui=Ls,ie(window,Ads),ui.extensions.push(HLS,OVP,Ads),Object.assign(ui,{hls:HLS,ads:Ads,ovp:OVP}),ui}));
|
|
379
|
+
*/const es=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 Wn}static get ENGINE_MAP(){return Xn}static get OS_MAP(){return Yn}static get PLATFORMS_MAP(){return zn}}.parse(window.navigator.userAgent),{platform:rs,os:is,browser:ns}=es,ss=t=>t&&t.toLowerCase();var as={rnd:Math.random().toString(36).substr(2,32),os:ss(is.name+(is.versionName?" "+is.versionName:"")),device:ss(rs.type),browser:ss(ns.name),browser_version:(ns&&ns.version?ns.version:"unknown").split(".").shift(),plugin_version:"3.4.2"};const os="https://fp-eu-w1-aai.flowplayer.com/in",ls="POST",us=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],ds=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],cs=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],hs=Sr("ads/analytics"),fs=RequestQueue.of(),ps=(...t)=>Object.assign({},...t);class Analytics{constructor(t,e={}){this.emitter=t,this.metadata=ps(as,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),hs(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,ps(t.metadata,e,{player_version:"3.4.2"})),t}wireup(){this.events.forEach(t=>{this.emitter.on(t,e=>{const r=e.detail,i=ps(this.metadata,{event_type:t},r),n=Analytics.pluck_valid_keys(this,i),s=Analytics.ensure_required_keys(this,n);if(hs(`Event[${t}]`,{payload:n,observation:r}),s.length)return hs(`Analytics.validate_metadata() failed for\n Event[${t}]\n missing keys: ${s}`,n);RequestQueue.rpush(fs,[os,ls,n])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const gs=Sr("ads/controller"),vs={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({},vs),t),this.analytics=(e=this,Analytics.of(e,{required_keys:ds,optional_keys:cs,events:us})),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()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const t=()=>{var t;const e=new CustomEvent("ad/playing");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.PLAYING,!0)};this.on("ad-play-requested",t),this.on("ad-started",t),this.on("ad-resumed",t);const e=()=>{var t;if(!this.adPlaying)return;const e=new CustomEvent("ad/paused");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.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",()=>{requestAnimationFrame(()=>{var t;const e=new CustomEvent("ad/complete");null===(t=this.videoTag)||void 0===t||t.dispatchEvent(e),this._state.toggleState(Vn.BREAK_ACTIVE,!1)})}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),e(),this._state.toggleState(Vn.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async t=>{if(gs("Ads.on(RELOAD_AD_REQUESTED)",t),this._schedule){if(e(),t)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(Vn.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(Vn.AD_AVAILABLE,!1))}})}async initialize(t,e={},r){return gs("Ads.initialize():",t,e,r),this._state.toggleState(Vn.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){gs("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(ln,()=>t(e))})})}async adapterInitialized(t){gs("Ads.adapterInitialized()"),this._state.toggleState(Vn.INITIALIZING,!1),this._state.toggleState(Vn.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(Vn.FATAL_ERROR,!0),this._state.toggleState(Vn.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(Vn.FETCHING_AD,!1);else if(n===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),n){gs("Ads.fetchNextAd",n),this._state.toggleState(Vn.FETCHING_AD,!0);try{return await this.requestAd(n),this._state.toggleState(Vn.AD_AVAILABLE,!0),void this._state.toggleState(Vn.FETCHING_AD,!1)}catch(r){if(gs("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(Vn.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(Vn.FETCHING_AD))return;if(this._state.hasAny(Vn.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(Vn.AD_AVAILABLE)||await this.fetchNextAd(t),!this._state.hasAny(Vn.AD_AVAILABLE)||!this.shallPlayAd(t)||e)return;await this.playAd(),await this.setCurrentTime(t),this.checkIfBreakComplete()}catch(t){gs("setCurrentTime: Error(from: setCurrentTime, message: %s)",t.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var t;if(this._state.hasAny(Vn.AD_AVAILABLE)){this._state.toggleState(Vn.AD_AVAILABLE,!1),this._state.toggleState(Vn.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(Vn.BREAK_ACTIVE))return gs("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());gs("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(Vn.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(Vn.BREAK_ACTIVE)&&!this.adapter.isAdPod())return gs("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=e)||"object"!=typeof i||Gn(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 this.dispatch(t,n)}dispatch(t,e){const r=this.adapter.getVideoTag();if(r){gs(":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(Tr,{detail:i}))}catch(t){gs(":error",t)}zt(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&&(gs("Ads.finished"),!(this.adapter.isSharedVideoTag()&&this._state.hasAny(Vn.PLAYING)&&this.adapter.isLinearAd()))){gs("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return gs("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(Vn.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(t){gs("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(Vn.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;gs("Ads.requestAd(ad: %o)",{ad:t,timeout:r,idx:e});const i=await async function t(e){if("function"==typeof e)return[await Bn(e)];if("string"==typeof e)return[await Bn(e)];if(Array.isArray(e)){const t=e;return await Promise.all(t.map(Bn))}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],Nn(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(n,r)}catch(t){return gs(`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(Vn.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(Vn.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(Vn.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var ms=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"}),ys=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 Es(t){return Object.assign({muted:!1,timeout:250,inline:!1},t)}function Ts(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 _s={audio:function(t){return Ts(t=Es(t),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(ms)}}))},video:function(t){return Ts(t=Es(t),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(ys)}}))}};let bs=void 0;async function Ss(t=!0){return bs||(bs=await _s.video({timeout:500,muted:t}),bs)}const As=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"});var Ls=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const ws=["progress","duration","remaining"],Ds=Sr("ads/ui");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)),t.on("ad-progress",t=>{const{remaining:e}=t.detail;this.setAttribute("remaining",e+"")})}static get observedAttributes(){return ws}updateState(t){["ad/paused","ad/playing"].forEach(e=>{const r=e.replace("/","-"),i=t===e;this.player.setState(r,i),this.classList.toggle(r,i)})}hideFirstFrame(t){Ds("hideFirstFrame"),t.classList.toggle("ad-hide-first-frame",!0)}showFirstFrame(t){Ds("showFirstFrame"),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")}setUiFlags(t){if(t=t||0,this.classList.toggle("is-ad-controls-sticky",(1&t)>0),this.classList.toggle("no-fullscreen",(2&t)>0),this.classList.toggle("no-indicator",(4&t)>0),(8&t)>0){const t=document.createElement("div");t.classList.add("ad-attribution"),t.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.adContainer.append(t)}if(this.classList.toggle("no-volume-bar",0==(64&t)),(32&t)>0&&this.controls&&(this.remaining=document.createElement("div"),this.remaining.classList.add("fp-ad-remaining","fp-color-text"),this.controls.prepend(this.remaining)),(16&t)>0&&this.controls){this.classList.toggle("is-ad-choices",!0);const t=document.createElement("div");t.classList.add("fp-ad-choices"),t.textContent=this.player.i18n("ads.adchoices","AdChoices"),t.addEventListener("click",t=>{t.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),this.controls.append(t)}}attributeChangedCallback(t,e,r){switch(t){case"duration":return this.onDurationChange(parseFloat(r));case"progress":return this.onProgress(parseFloat(e),parseFloat(r));case"remaining":return this.onRemaining(r)}}onDurationChange(t){}onProgress(t,e){}onRemaining(t){this.remaining&&(this.remaining.textContent=parseFloat(t).toFixed())}render(){this.adContainer.classList.add("fp-ad-container"),this.append(this.adContainer),this.controls=gt(this.player,"flowplayer-ad-controls");const t=gt(this.player,"flowplayer-ad-countdown");this.append(this.controls,t)}}const Rs=Sr("fpads:native:outstream"),ks={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Os,Is;!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"}(Os||(Os={})),function(t){t[t.None=0]="None",t[t.Booting=1]="Booting",t[t.Ready=2]="Ready",t[t.Disposed=3]="Disposed"}(Is||(Is={}));class Outstream{constructor({ads:t,root:e,content:r,ima:i}){this.state=Is.None,Rs("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 an(t);const e={height:t.style.height};on(t,"opacity",0),on(t,"display","absolute"),on(t,"display","inline-block"),on(t,"height","auto");const r=an(t);return on(t,"height",e.height),on(t,"opacity",1),r}(this.root),this.adUi=new AdUI(r),this.adContainer=this.adUi.adContainer,this.initialVolumeState={},e.classList.add(ks.OUTSTREAM),e.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",t=>{var e;if(this.state==Is.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==Is.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==Is.Disposed)return;const e=t.detail;if(e)switch(this.state){case Is.Booting:return Rs(":boot skipping intersectionchange");case Is.None:return this.state=Is.Booting,this.begin_life_cycle();case Is.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 Rs(`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=Is.Ready;const{error:t,result:e}=await Ss(!1),{result:r}=await Ss(!0);this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!e&&!r),muted:!e},Rs("Outstream.show() :autoplay >> sound="+e),t&&this.content&&!e&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await pn({ads:this.ads,content:this.content,adContainer:this.adContainer,ima:this.ima,state:{listening:!1},config:this.content.opts}),En({content:this.content,ads:this.ads}),this.state=Is.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=()=>{hn.forEach(t=>this.ads.removeListener(t,e));const t=new CustomEvent(Os.OUTSTREAM_TEARDOWN);Rs("Outstream(:teardown)",t),this.content.dispatchEvent(t)};hn.forEach(t=>this.ads.once(t,e)),this.content.once(Os.OUTSTREAM_TEARDOWN,t=>{setTimeout(()=>{if(t.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),mn({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(As)})}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==Is.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=Is.Disposed,e.destroy(),t.innerHTML=""}}function Cs(t){return t&&"number"==typeof t.time}function Ps(t){return t&&"number"==typeof t.percent&&"number"!=typeof t.time}Outstream.CLASS=ks;const xs=Sr("ads/index");function Ms(t,e,r){if(!("google"in window))return console.warn("google.ima unavailable");let i=t.autoplay;t.autoplay&&(xs("handling initial autoplay, original_autoplay: ",i),r.autoplay=!1,t.autoplay=0);const n=r.ads=new AdsController,s=n.analytics;let a=!1;n.resize(an(e)),dn&&(r.on([h,f,"webkitendfullscreen"],t=>{var e;const i=t.type===h;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(_,()=>{r.togglePlay(!1)}),r.webkitExitFullscreen()})})),r.on(L,(function(){n&&n.destroy()})),r.on("src",()=>{if(n)return r.root.classList.contains("ad-paused")||r.root.classList.contains("ad-playing")?n.stop():void n.onContentNewSrc()}),r.on(w,(function({detail:o}){const l=o.ima;if(void 0===i&&o.autoplay&&(i=o.autoplay),!l)return;if(!Array.isArray(l.ads))return xs("handling non-array ima.ads"),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=>Cs(t)||Ps(t)).reduce((t,r)=>{if(Cs(r))return t.push(r),t;if(r.lazy)return t.push(r),t;if(Ps(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 xs("is outstream, returning"),new Outstream({root:e,content:r,ads:n,ima:l});fn({config:Object.assign(Object.assign({},t),{autoplay:i}),root:e,content:r,ads:n,ima:l})}}))}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=`${this.player.i18n("ads.indicator","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=this.player.i18n("ads.indicator","ADS");const t=document.createElement("div");t.classList.add("ad-playback-controls");const e=gt(this.player,H);e.addEventListener("click",()=>this.player.emit("request/ad/play"));const r=gt(this.player,V);r.addEventListener("click",()=>this.player.emit("request/ad/pause")),t.append(e,r);const i=gt(this.player,z);i.addEventListener("click",()=>this.player.emit("request/ad/muteunmute"));const n=gt(this.player,M),s=gt(this.player,N);this.append(this.indicatorControl,t,i,n,s)}}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:Fs}=r();class Ads{constructor(t){this.umd=t,vt(t,"flowplayer-ad-ui",AdUI),vt(t,"flowplayer-ad-controls",AdControls),vt(t,"flowplayer-ad-countdown",AdCountdown)}init(t,e,r){if(ce.from_token(t.token||"").is_granted(ce.permissions.ADS)&&!Fs)return Ms(t,e,r)}}return Ads.events=un,Ads.ui=Ls,ie(window,Ads),ui.extensions.push(HLS,OVP,Ads),Object.assign(ui,{hls:HLS,ads:Ads,ovp:OVP}),ui}));
|