!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("Clappr")):"function"==typeof define&&define.amd?define(["Clappr"],e):"object"==typeof exports?exports.DashShakaPlayback=e(require("Clappr")):t.DashShakaPlayback=e(t.Clappr)}(this,function(t){return function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i=720,this.trigger(u.Events.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(u.Events.PLAYBACK_BITRATE,{bandwidth:t.bandwidth,width:t.width,height:t.height,level:t.id})}},{key:"_destroy",value:function(){o(Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this._isShakaReadyState=!1,u.Log.debug("shaka was destroyed")}},{key:"_shakaReady",value:function(){o(Object.getPrototypeOf(e.prototype),"_ready",this).call(this)}},{key:"isReady",get:function(){return this._isShakaReadyState}},{key:"textTracks",get:function(){return this._player&&this._player.getTracks().filter(function(t){return"text"===t.type})}},{key:"audioTracks",get:function(){return this._player&&this._player.getTracks().filter(function(t){return"audio"===t.type})}},{key:"videoTracks",get:function(){return this._player&&this._player.getTracks().filter(function(t){return"video"===t.type})}}]),e}(u.HTML5Video);e["default"]=p,p.canPlay=function(t){var e=arguments.length<=1||void 0===arguments[1]?"":arguments[1];c["default"].polyfill.installAll();var i=c["default"].Player.isBrowserSupported(),n=t.split("?")[0].match(/.*\.(.*)$/)||[];return i&&("mpd"===n[1]||e.indexOf("application/dash+xml")>-1)},t.exports=e["default"]},function(t,e,i){var n;!function(){var r={};(function(t){function e(t,e){var i=t.split("."),n=Yr;i[0]in n||!n.execScript||n.execScript("var "+i[0]);for(var r;i.length&&(r=i.shift());)i.length||void 0===e?n=n[r]?n[r]:n[r]={}:n[r]=e}function i(t){function e(){}var i=je;e.prototype=i.prototype,t.md=i.prototype,t.prototype=new e,t.prototype.constructor=t,t.fd=function(t,e,n){return i.prototype[e].apply(t,Array.prototype.slice.call(arguments,2))}}function n(t){this.c=Math.exp(Math.log(.5)/t),this.b=this.a=0}function r(t,e,i){var n=Math.pow(t.c,e);i=i*(1-n)+n*t.a,isNaN(i)||(t.a=i,t.b+=e)}function s(t){return t.a/(1-Math.pow(t.c,t.b))}function a(){this.c=new n(2),this.f=new n(5),this.a=0,this.b=5e5}function o(){}function u(){}function h(){this.g=null,this.f=!1,this.b=new a,this.h={},this.a={},this.i=!1,this.c=null}function c(t){return(t=t.h.audio)?(t=f(t),t[Math.floor(t.length/2)]):null}function l(t){var e=t.h.video;if(!e)return null;var e=f(e),i=t.a.audio,i=i&&i.bandwidth||0;t=t.b.getBandwidthEstimate();for(var n=e[0],r=0;r=(s.bandwidth+i)/.95&&t<=a&&(n=s)}}return n}function f(t){return t.streams.slice(0).filter(function(t){return t.allowedByApplication&&t.allowedByKeySystem}).sort(function(t,e){return t.bandwidth-e.bandwidth})}function d(t){var e;t instanceof d?(p(this,t.R),this.ka=t.ka,this.T=t.T,m(this,t.wa),this.O=t.O,y(this,E(t.a)),this.ca=t.ca):t&&(e=String(t).match(Wr))?(p(this,e[1]||"",!0),this.ka=b(e[2]||""),this.T=b(e[3]||"",!0),m(this,e[4]),this.O=b(e[5]||"",!0),y(this,e[6]||"",!0),this.ca=b(e[7]||"")):this.a=new w(null)}function p(t,e,i){t.R=i?b(e,!0):e,t.R&&(t.R=t.R.replace(/:$/,""))}function m(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.wa=e}else t.wa=null}function y(t,e,i){e instanceof w?t.a=e:(i||(e=g(e,Qr)),t.a=new w(e))}function b(t,e){return t?e?decodeURI(t):decodeURIComponent(t):""}function g(t,e,i){return"string"==typeof t?(t=encodeURI(t).replace(e,v),i&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function v(t){return t=t.charCodeAt(0),"%"+(t>>4&15).toString(16)+(15&t).toString(16)}function w(t){this.b=t||null}function E(t){var e=new w;if(e.b=t.b,t.a){var i,n={};for(i in t.a)n[i]=t.a[i].concat();e.a=n,e.c=t.c}return e}function S(t,e,i){this.category=t,this.code=e,this.data=Array.prototype.slice.call(arguments,2)}function T(t,e){return t.reduce(function(t,e,i){return e["catch"](t.bind(null,i))}.bind(null,e),Promise.reject())}function k(t,e){return t.concat(e)}function P(){}function A(t){return null!=t}function I(t){return function(e){return e!=t}}function _(){}function R(){var t,e,i=new Promise(function(i,n){t=i,e=n});return i.resolve=t,i.reject=e,i}function N(t){this.f=!1,this.a=[],this.b=[],this.c=[],this.g=t||null}function C(){return{maxAttempts:2,baseDelay:1e3,backoffFactor:2,fuzzFactor:.5,timeout:0}}function M(t,e){return{uris:t,method:"GET",body:null,headers:{},allowCrossSiteCredentials:!1,retryParameters:e}}function x(t,e,i){for(var n=0;n=t[e]}.bind(null,e);if(!e[0]&&!e[2])return H(t,!1);if(!e[1]&&!e[3])return H(t,!0);if(i(0)&&i(1)&&i(2)&&i(3))return q(t);throw new S(2,2003)}function z(t){t=unescape(encodeURIComponent(t));for(var e=new Uint8Array(t.length),i=0;i=e?null:new ss(t,e,i)}function wt(t,e,i,n){var r=t.g;return Promise.resolve().then(function(){if(this.c){var t=this.h(e,r,i,n,this.i);if(null!=i&&null!=n){for(var s=0;s=this.f);++s)this.c.addCue(t[s]);null==this.b&&(this.b=i),this.a=Math.min(n,this.f)}}}.bind(t))}function Et(t,e){return null==t.a||t.at.end(0)-t.start(0)?null:t.length?t.end(t.length-1):null}function kt(t,e){var i=0;if(!t||1==t.length&&1e-6>t.end(0)-t.start(0))return i;var n=!1,r=1e-4;e||(r=.25);for(var s=0;s=t.start(s)&&e=t.start(s)-t.end(s-1))i+=t.end(s)-t.start(s),i+=t.start(s)-t.end(s-1);else if(0=t.end(s-1)){if(!(.04>=t.start(s)-e))break;i+=t.end(s)-e,n=!0}else n=!1;return i}function Pt(t,e,i){this.f=t,this.h=e,this.j=i,this.c={},this.b=null,this.a={},this.g=new O,this.i=!1}function At(){var t={};return'video/mp4; codecs="avc1.42E01E",video/mp4; codecs="avc3.42E01E",video/mp4; codecs="hvc1.1.6.L93.90",audio/mp4; codecs="mp4a.40.2",audio/mp4; codecs="ac-3",audio/mp4; codecs="ec-3",video/webm; codecs="vp8",video/webm; codecs="vp9",video/webm; codecs="av1",audio/webm; codecs="vorbis",audio/webm; codecs="opus",video/mp2t; codecs="avc1.42E01E",video/mp2t; codecs="avc3.42E01E",video/mp2t; codecs="hvc1.1.6.L93.90",video/mp2t; codecs="mp4a.40.2",video/mp2t; codecs="ac-3",video/mp2t; codecs="ec-3",video/mp2t; codecs="mp4a.40.2",text/vtt,application/mp4; codecs="wvtt",application/ttml+xml,application/mp4; codecs="stpp"'.split(",").forEach(function(e){t[e]=!!rs[e]||MediaSource.isTypeSupported(e);var i=e.split(";")[0];t[i]=t[i]||t[e]}),t}function It(t,e){var i;return"text"==e?i=t.b.b:(i=Rt(t,e),i=!i||1==i.length&&1e-6>i.end(0)-i.start(0)?null:1==i.length&&0>i.start(0)?0:i.length?i.start(0):null),i}function _t(t,e,i){return"text"==e?(e=Et(t.b,i),e||(e=Et(t.b,i+.1))&&(e+=.1)):(t=Rt(t,e),e=kt(t,i),e||(e=kt(t,i+.1))&&(e+=.1)),e}function Rt(t,e){try{return t.c[e].buffered}catch(i){return null}}function Nt(t,e,i,n,r){return"text"==e?wt(t.b,i,n,r):Dt(t,e,t.Tc.bind(t,e,i))}function Ct(t,e){return"text"==e?t.b.remove(0,1/0):Dt(t,e,t.Bb.bind(t,e,0,t.h.duration))}function Mt(t,e,i){return"text"==e?(t.b.g=i,Promise.resolve()):Dt(t,e,t.Jc.bind(t,e,i))}function xt(t,e,i){return"text"==e?(t.b.f=i,Promise.resolve()):Promise.all([Dt(t,e,t.Lb.bind(t,e)),Dt(t,e,t.Hc.bind(t,e,i))])}function Dt(t,e,i){if(t.i)return Promise.reject();if(i={start:i,p:new R},t.a[e].push(i),1==t.a[e].length)try{i.start()}catch(n){"QuotaExceededError"==n.name?i.p.reject(new S(3,3017,e)):i.p.reject(new S(3,3015,n)),Lt(t,e)}return i.p}function Ot(t,e){if(t.i)return Promise.reject();var i,n=[];for(i in t.c){var r=new R,s={start:function(t){t.resolve()}.bind(null,r),p:r};t.a[i].push(s),n.push(r),1==t.a[i].length&&s.start()}return Promise.all(n).then(function(){var t,i;try{e()}catch(n){i=Promise.reject(new S(3,3015,n))}for(t in this.c)Lt(this,t);return i}.bind(t),function(){return Promise.reject()}.bind(t))}function Lt(t,e){t.a[e].shift();var i=t.a[e][0];if(i)try{i.start()}catch(n){i.p.reject(new S(3,3015,n)),Lt(t,e)}}function jt(t,e,i){this.a=t,this.L=e,this.D=i}function Ut(t,e,i,n,r,s){this.position=t,this.startTime=e,this.endTime=i,this.a=n,this.L=r,this.D=s}function Bt(t,e){this.j=t,this.i=e,this.c=this.a=1/0,this.b=1,this.g=this.f=0,this.h=!0}function Ft(t,e,i,n,r,s){this.a=t,this.c=e,this.j=i,this.s=n,this.l=r,this.m=s,this.b=new O,this.h=!1,this.g=1,this.i=this.f=null,0t.c.da()?t.c.ra():Math.max(t.c.Ua(),t.c.ra())}function qt(t,e){e!=t.h&&(t.h=e,zt(t,t.g),t.l(e))}function Ht(e){Gt(e),e.i=t.setTimeout(e.pc.bind(e),250)}function Gt(e){e.i&&(t.clearTimeout(e.i),e.i=null)}function zt(e,i){null!=e.f&&(t.clearInterval(e.f),e.f=null),e.g=i,e.a.playbackRate=e.h||0>i?0:i,!e.h&&0>i&&(e.f=t.setInterval(function(){this.a.currentTime+=i/4}.bind(e),250))}function $t(t,e){var i=t.c,n=i.ra(),r=i.ea();return i.U()&&1/0!=i.c?(i=n+1,n=i+t.j,e>=n&&e<=r||kt(t.a.buffered,e)&&e>=i&&e<=r?e:e>r?r:r=i&&e<=r?e:Math.min(n+2,r)):er?r:e}function Yt(t,e,i){t.a.currentTime=i;var n=0,r=function(){!this.a||10<=n++||this.a.currentTime!=e||(this.a.currentTime=i,setTimeout(r,100))}.bind(t);setTimeout(r,100)}function Wt(t,e){var i=t.c.ra();return ei?i:e)}function Xt(t,e,i){return i==e||t>=as&&i==e.split("-")[0]||t>=os&&i.split("-")[0]==e.split("-")[0]}function Jt(t){t=t.toLowerCase().split("-");var e=us[t[0]];return e&&(t[0]=e),t.join("-")}function Zt(t,e,i){var n=!1;return t.streamSets.forEach(function(t){t.streams.forEach(function(r){var s=r.allowedByApplication;r.allowedByApplication=!0,"video"==t.type?(r.widthe.maxWidth||r.width>i.width||r.heighte.maxHeight||r.height>i.height||r.width*r.heighte.maxPixels||r.bandwidthe.maxVideoBandwidth)&&(r.allowedByApplication=!1):"audio"==t.type&&(r.bandwidthe.maxAudioBandwidth)&&(r.allowedByApplication=!1),s!=r.allowedByApplication&&(n=!0)})}),n}function Qt(t,e,i){var n="",r=null;for(t&&t.A&&(n=t.keySystem(),r=t.m),t=0;tr.indexOf(h)?(s.streams.splice(o,1),--o):!a||u.mimeType==a.mimeType&&u.codecs.split(".")[0]==a.codecs.split(".")[0]||(s.streams.splice(o,1),--o):(s.streams.splice(o,1),--o)}s.streams.length||(i.streamSets.splice(t,1),--t)}}}function te(t,e){return t.streamSets.map(function(t){var i=e?e[t.type]:null;return t.streams.filter(function(t){return t.allowedByApplication&&t.allowedByKeySystem}).map(function(e){return{id:e.id,active:i==e,type:t.type,bandwidth:e.bandwidth,language:t.language,kind:e.kind||null,width:e.width||null,height:e.height||null,frameRate:e.frameRate||void 0,codecs:e.codecs||null}})}).reduce(k,[])}function ee(t,e){for(var i=0;ir?(r=e,n.video=t):e==r&&re(t)t.streams.length?e:(t.streams.forEach(function(t){e+=t.bandwidth}),e/t.streams.length)}function se(t){var e=0;return t?(t.streams.forEach(function(t){t.height>e&&(e=t.height)}),e):e}function ae(t,e){var i=t;return e&&(i+='; codecs="'+e+'"'),i}function oe(t,e,i,n,r,s,a,o,u){this.m=t,this.c=e,this.S=i,this.a=n,this.G=r,this.v=s,this.j=a,this.w=o||null,this.A=u||null,this.h=null,this.i=1,this.C=Promise.resolve(),this.g=[],this.l={},this.b={},this.f=this.s=this.J=!1}function ue(t){return t.a.periods[Ie(t,Kt(t.m))]}function he(t){return K(t.b,function(t){return t.stream})}function ce(t,e){var i={};return i.text=e,fe(t,i)}function le(t,e,i,n){var r=t.b[e];!r&&"text"==e&&t.h.ignoreTextStreamFailures?ce(t,i):r&&(e=t.g[_e(t,i)])&&e.xa&&(e=t.l[i.id])&&e.xa&&r.stream!=i&&(r.stream=i,r.La=!0,n&&(r.aa?r.Pa=!0:r.ga?(r.la=!0,r.Pa=!0):(Me(r),Ne(t,r,!0))))}function fe(t,e){var i=Ie(t,Kt(t.m)),n=K(e,function(t){return ae(t.mimeType,t.codecs)});return t.c.init(n,t.h.useRelativeCueTimestamps),me(t),n=F(e),pe(t,n).then(function(){if(!this.f)for(var t in e){var n=e[t];this.b[t]||(this.b[t]={stream:n,type:t,ta:null,V:null,La:!0,Ma:i,endOfStream:!1,ga:!1,$:null,la:!1,Pa:!1,aa:!1,bb:!1},Ce(this,this.b[t],0))}}.bind(t))}function de(t,e){var i=t.g[e];if(i)return i.I;i={I:new R,xa:!1},t.g[e]=i;var n=t.a.periods[e].streamSets.map(function(t){return t.streams}).reduce(k,[]);return t.C=t.C.then(function(){if(!this.f)return pe(this,n)}.bind(t)).then(function(){this.f||(this.g[e].I.resolve(),this.g[e].xa=!0)}.bind(t))["catch"](function(t){this.f||(this.g[e].I.reject(),delete this.g[e],this.j(t))}.bind(t)),i.I}function pe(t,e){for(var i=[],n=0;ne?t.c.za(e):t.c.za(Math.pow(2,32))}function ye(t,e){var i,n,r=Kt(t.m);n=t.c;var s=e.type;n="text"==s?n.b.a:Tt(Rt(n,s));var s=e.ta&&e.V?t.a.periods[_e(t,e.ta)].startTime+e.V.endTime:r,a=_e(t,e.stream),o=Ie(t,s),u=t.a.periods[o];return i=a!=o?null:be(t,e,r,n,o),(i?u.startTime+i.startTime-r:_t(t.c,e.type,r))>=Math.max(t.i*Math.max(t.a.minBufferTime||0,t.h.rebufferingGoal),t.i*t.h.bufferingGoal)?.5:s>=t.a.presentationTimeline.da()?(e.endOfStream=!0,null):(e.endOfStream=!1,o!=a?(e.Ma=o,null):(i=be(t,e,r,n,a))?(ve(t,e,r,a,i),null):1)}function be(t,e,i,n,r){if(e.V&&e.stream==e.ta)return i=e.V.position+1,ge(t,e,r,i);if(i=e.V?e.stream.findSegmentPosition(Math.max(0,t.a.periods[_e(t,e.ta)].startTime+e.V.endTime-t.a.periods[r].startTime)):e.stream.findSegmentPosition(Math.max(0,(n||i)-t.a.periods[r].startTime)),null==i)return null;var s=null;return null==n&&(s=ge(t,e,r,Math.max(0,i-1))),s||ge(t,e,r,i)}function ge(t,e,i,n){return i=t.a.periods[i],(e=e.stream.getSegmentReference(n))?(t=t.a.presentationTimeline,n=t.ea(),i.startTime+e.endTimen?null:e):null}function ve(t,e,i,n,r){var s=t.a.periods[n],a=e.stream,o=t.a.periods[n+1],u=null,u=o?o.startTime:t.a.presentationTimeline.da();n=Ee(t,e,n,u),e.ga=!0,e.La=!1,o=Re(t,r),Promise.all([n,o]).then(function(t){if(!this.f&&!this.s)return Se(this,e,i,s,a,r,t[1])}.bind(t)).then(function(){this.f||this.s||(e.ga=!1,e.bb=!1,Ce(this,e,0),ke(this,a))}.bind(t))["catch"](function(t){this.f||this.s||(e.ga=!1,1001==t.code||1002==t.code||1003==t.code?"text"==e.type&&this.h.ignoreTextStreamFailures&&1001==t.code?delete this.b.text:(this.j(t),Ce(this,e,4)):3017==t.code?we(this,e,t):this.j(t))}.bind(t))}function we(t,e,i){if(!F(t.b).some(function(t){return t!=e&&t.bb})){var n=Math.round(100*t.i);if(20=i?Promise.resolve():t.c.remove(e.type,n,n+i).then(function(){}.bind(t)))}function ke(t,e){if(!t.J&&(t.J=F(t.b).every(function(t){return!t.la&&!t.aa&&t.V}),t.J)){var i=_e(t,e);for(t.g[i]||de(t,i).then(function(){this.v()}.bind(t))["catch"](P),i=0;i=t.a.periods[i].startTime)return i;return 0}function _e(t,e){for(var i=0;ie?"-Infinity":"Infinity":e;return n}})}function Ze(t){return JSON.parse(t,function(t,e){return"NaN"==e?NaN:"-Infinity"==e?-(1/0):"Infinity"==e?1/0:e&&"object"==typeof e&&"TimeRanges"==e.__type__?Qe(e):e})}function Qe(t){return{length:t.length,start:function(e){return t.start[e]},end:function(e){return t.end[e]}}}function ti(t,e,i,n,r){this.C=t,this.l=e,this.w=i,this.A=n,this.s=r,this.f=this.j=this.g=!1,this.v="",this.a=this.i=null,this.b={video:{},player:{}},this.m=0,this.c={},this.h=null}function ei(t){for(var e in t.c){var i=t.c[e];delete t.c[e],i.reject(new S(7,7e3))}}function ii(t,e){var i=Je(e);t.a.sendMessage("urn:x-cast:com.google.shaka.v2",i,function(){},o)}function ni(t,e,i){je.call(this),this.c=t,this.b=e,this.i=this.f=this.g=this.j=this.l=null,this.a=new ti(i,this.Pc.bind(this),this.Qc.bind(this),this.Rc.bind(this),this.mb.bind(this)),ri(this)}function ri(t){t.a.init(),t.i=new O,cs.forEach(function(t){L(this.i,this.c,t,this.cd.bind(this))}.bind(t)),ps.forEach(function(t){L(this.i,this.b,t,this.xc.bind(this))}.bind(t)),t.l={};for(var e in t.c)Object.defineProperty(t.l,e,{configurable:!1,enumerable:!0,get:t.bd.bind(t,e),set:t.dd.bind(t,e)});t.j={};for(e in t.b)Object.defineProperty(t.j,e,{configurable:!1,enumerable:!0,get:t.wc.bind(t,e)});t.g=new je,t.g.S=t.l,t.f=new je,t.f.S=t.j}function si(t,e,i){je.call(this),this.b=t,this.a=e,this.j={video:t,player:e},this.l=i||function(){},this.i=!1,this.c=!0,this.f=this.g=null,ai(this)}function ai(e){var i=cast.receiver.CastReceiverManager.getInstance();i.onSenderConnected=e.vb.bind(e),i.onSenderDisconnected=e.vb.bind(e),i.onSystemVolumeChanged=e.Tb.bind(e),e.g=i.getCastMessageBus("urn:x-cast:com.google.shaka.v2"),e.g.onMessage=e.hc.bind(e),i.start(),cs.forEach(function(t){this.b.addEventListener(t,this.yb.bind(this,"video"))}.bind(e)),ps.forEach(function(t){this.a.addEventListener(t,this.yb.bind(this,"player"))}.bind(e)),e.a.Gb(1920,1080),e.a.addEventListener("loading",function(){this.c=!1,oi(this)}.bind(e)),e.b.addEventListener("playing",function(){this.c=!1,oi(this)}.bind(e)),e.a.addEventListener("unloading",function(){this.c=!0,oi(this)}.bind(e)),e.b.addEventListener("ended",function(){t.setTimeout(function(){this.b&&this.b.ended&&(this.c=!0,oi(this))}.bind(this),5e3)}.bind(e))}function oi(t){Promise.resolve().then(function(){this.dispatchEvent(new Le("caststatuschanged"))}.bind(t))}function ui(t,e,i){for(var n in e.player)t.a[n](e.player[n]);t.l(i),i=Promise.resolve();var r=t.b.autoplay;e.manifest&&(t.b.autoplay=!1,i=t.a.load(e.manifest,e.startTime),i["catch"](function(t){this.a.dispatchEvent(new Le("error",{detail:t}))}.bind(t))),i.then(function(){for(var t in e.video){var i=e.video[t];this.b[t]=i}for(t in e.playerAfterLoad)i=e.playerAfterLoad[t],this.a[t](i);this.b.autoplay=r,e.manifest&&this.b.play()}.bind(t))}function hi(t,e,i){t.i&&(e=Je(e),i?t.g.getCastChannel(i).send(e):t.g.broadcast(e))}function ci(t,e){var i=li(t,e);return 1!=i.length?null:i[0]}function li(t,e){return Array.prototype.filter.call(t.childNodes,function(t){return t.tagName==e})}function fi(t){var e=t.firstChild;return e&&e.nodeType==Node.TEXT_NODE?t.textContent.trim():null}function di(t,e,i,n){var r=null;return t=t.getAttribute(e),null!=t&&(r=i(t)),null==r?void 0!==n?n:null:r}function pi(t){return t?(t=Date.parse(t),isNaN(t)?null:Math.floor(t/1e3)):null}function mi(t){return t&&(t=/^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$/.exec(t))?(t=31536e3*Number(t[1]||null)+2592e3*Number(t[2]||null)+86400*Number(t[3]||null)+3600*Number(t[4]||null)+60*Number(t[5]||null)+Number(t[6]||null),isFinite(t)?t:null):null}function yi(t){var e=/([0-9]+)-([0-9]+)/.exec(t);return e?(t=Number(e[1]),isFinite(t)?(e=Number(e[2]),isFinite(e)?{start:t,end:e}:null):null):null}function bi(t){return t=Number(t),t%1?null:t}function gi(t){return t=Number(t),!(t%1)&&0e||(i[i.length-1]=new Ut(t.position,t.startTime,e,t.a,t.L,t.D)))}}function _i(t,e){if(!e.length)return t;var i=e.map(function(t){return new d(t)});return t.map(function(t){return new d(t)}).map(function(t){return i.map(t.resolve.bind(t))}).reduce(k,[]).map(function(t){return t.toString()})}function Ri(t,e){var i=Ni(t,e,"timescale"),n=1;i&&(n=gi(i)||1),i=Ni(t,e,"duration"),(i=gi(i||""))&&(i/=n);var r=Ni(t,e,"startNumber"),s=Ni(t,e,"presentationTimeOffset"),a=vi(r||"");null!=r&&null!=a||(a=1);var o=Ci(t,e,"SegmentTimeline"),r=null;if(o){for(var r=n,u=Number(s),h=t.H.duration||1/0,o=li(o,"S"),c=[],l=0,f=0;fd)if(f+1=d)break;d=Math.ceil((d-p)/m)-1}else{if(1/0==h)break;if(p/r>=h)break;d=Math.ceil((h*r-p)/m)-1}0t.b.byteLength&&Ki();var i=t.b.buffer.slice(t.a,t.a+e);return t.a+=e,new Uint8Array(i)}function Bi(t,e){t.a+e>t.b.byteLength&&Ki(),t.a+=e}function Fi(t){var e=t.a;try{for(;xi(t)&&t.b.getUint8(t.a);)t.a+=1}catch(i){Ki()}return e=t.b.buffer.slice(e,t.a),t.a+=1,q(e)}function Ki(){throw new S(3,3e3)}function Vi(t,e){for(;xi(e);){var i=e.a,n=Li(e),r=Li(e);if(1==n?n=ji(e):n||(n=e.b.byteLength-i),r==t)return n;Bi(e,n-(e.a-i))}return-1}function qi(t,e){for(var i=new Mi(new DataView(t)),n=[[1836019574,0],[1953653099,0],[1835297121,0],[1835626086,0],[1937007212,0],[1937011556,8],[e,0]],r=-1,s=0;s>>31,u&=2147483647;var c=Li(t);if(Bi(t,4),1==h)throw new S(3,3006);r.push(new Ut(r.length,n/o,(n+c)/o,function(){return i},e,e+u-1)),n+=c,e+=u}return r}function Gi(t){this.a=t}function zi(t){this.b=t,this.a=new Mi(t),Ts||(Ts=[new Uint8Array([255]),new Uint8Array([127,255]),new Uint8Array([63,255,255]),new Uint8Array([31,255,255,255]),new Uint8Array([15,255,255,255,255]),new Uint8Array([7,255,255,255,255,255]),new Uint8Array([3,255,255,255,255,255,255]),new Uint8Array([1,255,255,255,255,255,255,255])])}function $i(t){var e;if(e=Yi(t),7=e&&!(i&1<<8-e);e++);if(8t||i&&t>=i?null:Math.floor(t/n)},getSegmentReference:function(t){var e=t*n;return new Ut(t,e,e+n,function(){var i=Ai(a,u,t+r,o,e*s);return _i(h,[i])},0,null)}}}function ln(t,e){for(var i=[],n=0;ne.s||(e.f=t.setTimeout(e.Sc.bind(e),1e3*Math.max(Math.max(3,e.s)-i,0)))}function gn(t,e,i){e=e||{contentType:"",mimeType:"",codecs:"",frameRate:void 0},i=i||e.M;var n=li(t,"BaseURL").map(fi),r=t.getAttribute("contentType")||e.contentType,s=t.getAttribute("mimeType")||e.mimeType,a=t.getAttribute("codecs")||e.codecs,o=di(t,"frameRate",wi)||e.frameRate;return r||(r=Tn(s,a)),{M:_i(i,n),Ga:ci(t,"SegmentBase")||e.Ga,Y:ci(t,"SegmentList")||e.Y,Ha:ci(t,"SegmentTemplate")||e.Ha,width:di(t,"width",vi)||e.width,height:di(t,"height",vi)||e.height,contentType:r,mimeType:s,codecs:a,frameRate:o,id:t.getAttribute("id")}}function vn(t){var e={};t.forEach(function(t){e[t.id]=[t]}),t.forEach(function(t){var i=e[t.id];t.Yc.forEach(function(t){(t=e[t])&&t!=i&&(i.push.apply(i,t),t.forEach(function(t){e[t.id]=i}))})});var i=[],n=[];return F(e).forEach(function(t){if(!(0<=n.indexOf(t))){n.push(t);var e=new D;t.forEach(function(t){e.push(t.contentType||"",t)}),e.keys().forEach(function(t){var n=new D;e.get(t).forEach(function(t){n.push(t.language,t)}),n.keys().forEach(function(e){var r=n.get(e);e={language:e,type:t,primary:r.some(function(t){return t.cc}),drmInfos:r.map(function(t){return t.drmInfos}).reduce(k,[]),streams:r.map(function(t){return t.streams}).reduce(k,[])},i.push(e)})})}}),i}function wn(t){var e;return e=0+(t.Ga?1:0),e+=t.Y?1:0,(e+=t.Ha?1:0)?(1!=e&&(t.Ga&&(t.Y=null),t.Ha=null),!0):"text"==t.contentType||"application"==t.contentType}function En(t,e,i,n){return e=_i(e,[i]),e=M(e,t.c.retryParameters),e.method=n,t.a.request(0,e).then(function(t){if("HEAD"==n){if(!t.headers||!t.headers.date)return 0;t=t.headers.date}else t=q(t.data);return t=Date.parse(t),isNaN(t)?0:t-Date.now()})}function Sn(t,e,i,n){i=i.map(function(t){return{scheme:t.getAttribute("schemeIdUri"),value:t.getAttribute("value")}});var r=t.c.dash.clockSyncUri;return n&&!i.length&&r&&i.push({scheme:"urn:mpeg:dash:utc:http-head:2014",value:r}),T(i,function(t){var i=t.value;switch(t.scheme){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":return En(this,e,i,"HEAD");case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":return En(this,e,i,"GET");case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":return t=Date.parse(i),isNaN(t)?0:t-Date.now();case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":return Promise.reject();default:return Promise.reject()}}.bind(t))["catch"](function(){return 0})}function Tn(t,e){return rs[ae(t,e)]?"text":t.split("/")[0]}function kn(t,e){var i=q(t),n=[],r=new DOMParser,s=null;try{s=r.parseFromString(i,"text/xml")}catch(a){throw new S(2,2005)}if(s){var o,u;if(!(i=s.getElementsByTagName("tt")[0]))throw new S(2,2006);for(r=i.getAttribute("ttp:frameRate"),s=i.getAttribute("ttp:subFrameRate"),o=i.getAttribute("ttp:frameRateMultiplier"),u=i.getAttribute("ttp:tickRate"),r=new Pn(r,s,o,u),s=kn.b(i.getElementsByTagName("styling")[0]),o=kn.b(i.getElementsByTagName("layout")[0]),i=kn.b(i.getElementsByTagName("body")[0]),u=0;un.length||"data"!=n[0])throw new S(1,1004,e);if(n=n.slice(1).join(":").split(","),2>n.length)throw new S(1,1004,e);var r=n[0],n=t.decodeURIComponent(n.slice(1).join(",")),r=r.split(";"),s=null;if(1=e.status){var r=e.getAllResponseHeaders().split("\r\n").reduce(function(t,e){var i=e.split(": ");return t[i[0].toLowerCase()]=i.slice(1).join(": "),t},{});e.responseURL&&(t=e.responseURL),i({uri:t,data:e.response,headers:r})}else{r=null;try{r=G(e.response)}catch(s){}n(new S(1,1001,t,e.status,r))}},r.onerror=function(){n(new S(1,1002,t))},r.ontimeout=function(){n(new S(1,1003,t))};for(var s in e.headers)r.setRequestHeader(s,e.headers[s]);r.send(e.body)})}function Dn(){this.a=null,this.c=[],this.b={}}function On(t,e,i){return Un(t,e,"readwrite",function(t){return t.put(i)})}function Ln(t,e){var i=[];return Un(t,"segment","readwrite",function(t){return t.openCursor()},function(t){if(t){if(e(t.value)){var n=t["delete"](),r=new R;n.onsuccess=r.resolve,n.onerror=Bn.bind(null,n,r),i.push(r)}t["continue"]()}}).then(function(){return Promise.all(i)}).then(function(){return i.length})}function jn(t,e){var i=0;return Un(t,e,"readonly",function(t){return t.openCursor(null,"prev")},function(t){t&&(i=t.key+1)}).then(function(){return i})}function Un(t,e,i,n,r){i=t.a.transaction([e],i);var s=n(i.objectStore(e)),a=new R;r&&(s.onsuccess=function(t){r(t.target.result)}),s.onerror=Bn.bind(null,s,a);var o={transaction:i,I:a};t.c.push(o);var u=function(){this.c.splice(this.c.indexOf(o),1)}.bind(t);return i.oncomplete=function(){u(),a.resolve(s.result)},i.onerror=function(t){u(),Bn(s,a,t)},a}function Bn(t,e,i){"AbortError"==t.error.name?e.reject(new S(9,9002)):e.reject(new S(9,9001,t.error)),i.preventDefault()}function Fn(t){return{offlineUri:"offline:"+t.key,originalManifestUri:t.originalManifestUri,duration:t.duration,size:t.size,tracks:t.periods[0].streams.map(function(t){return{id:t.id,active:!1,type:t.contentType,bandwidth:0,language:t.language,kind:t.kind||null,width:t.width,height:t.height,frameRate:t.frameRate,codecs:t.codecs}}),appMetadata:t.appMetadata}}function Kn(){}function Vn(t){var e=new Bt(null,0);e.za(t.duration);var i=t.drmInfo?[t.drmInfo]:[];return{presentationTimeline:e,minBufferTime:10,offlineSessionIds:t.sessionIds,periods:t.periods.map(function(t){return{startTime:t.startTime,streamSets:t.streams.map(function(n){var r=n.segments.map(function(t,e){return new Ut(e,t.startTime,t.endTime,function(){ return[t.uri]},0,null)});return e.Fa(t.startTime,r),r=new Gi(r),{language:n.language,type:n.contentType,primary:n.primary,drmInfos:i,streams:[{id:n.id,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:r.find.bind(r),getSegmentReference:r.get.bind(r),initSegmentReference:n.initSegmentUri?new jt(function(){return[n.initSegmentUri]},0,null):null,presentationTimeOffset:n.presentationTimeOffset,mimeType:n.mimeType,codecs:n.codecs,bandwidth:0,width:n.width||void 0,height:n.height||void 0,kind:n.kind,encrypted:n.encrypted,keyId:n.keyId,allowedByApplication:!0,allowedByKeySystem:!0}]}})}})}}function qn(t){if(/^offline:([0-9]+)$/.exec(t)){var e={uri:t,data:new ArrayBuffer(0),headers:{"content-type":"application/x-offline-manifest"}};return Promise.resolve(e)}if(e=/^offline:[0-9]+\/[0-9]+\/([0-9]+)$/.exec(t)){var i=Number(e[1]),n=new Dn;return n.init(ks).then(function(){return n.get("segment",i)}).then(function(e){return n.o().then(function(){if(!e)throw new S(9,9003,i);return{uri:t,data:e.data,headers:{}}})})}return Promise.reject(new S(1,9004,t))}function Hn(t,e,i){this.b={},this.i=i,this.m=t,this.l=e,this.j=this.a=null,this.f=this.h=this.g=this.c=0}function Gn(t,e,i,n,r){t.b[e]=t.b[e]||[],t.b[e].push({uris:i.a(),L:i.L,D:i.D,ib:n,Da:r})}function zn(t,e){t.c=0,t.g=0,t.h=0,t.f=0,F(t.b).forEach(function(t){t.forEach(function(t){null!=t.D?this.c+=t.D-t.L+1:this.h+=t.ib}.bind(this))}.bind(t)),t.a=e,t.a.size=t.c;var i=F(t.b).map(function(t){var e=0,i=function(){if(!this.i)return Promise.reject(new S(9,9002));if(e>=t.length)return Promise.resolve();var n=t[e++];return $n(this,n).then(i)}.bind(this);return i()}.bind(t));return t.b={},t.j=Promise.all(i)}function $n(t,e){var i=M(e.uris,t.l);(e.L||null!=e.D)&&(i.headers.Range="bytes="+e.L+"-"+(null==e.D?"":e.D));var n;return t.m.request(1,i).then(function(t){return this.a?(n=t.data.byteLength,e.Da(t.data)):Promise.reject(new S(9,9002))}.bind(t)).then(function(){if(!this.a)return Promise.reject(new S(9,9002));null==e.D?(this.a.size+=n,this.f+=e.ib):this.g+=n;var t=(this.g+this.f)/(this.c+this.h),i=Fn(this.a);this.i.progressCallback(i,t)}.bind(t))}function Yn(t){this.a=new Dn,this.c=t,this.j=Jn(this),this.h=null,this.v=!1,this.i=null,this.l=[],this.f=-1,this.m=0,this.b=null,this.g=new Hn(t.i,t.getConfiguration().streaming.retryParameters,this.j)}function Wn(){return!!t.indexedDB}function Xn(t,e,i,n){function r(){}var s,a,o,u=t.c.i,h=t.c.getConfiguration();return bt(e,u,h.manifest.retryParameters,n).then(function(t){return ir(this),o=new t,o.configure(h.manifest),o.start(e,u,this.s.bind(this),i)}.bind(t)).then(function(t){return ir(this),s=t,a=new et(u,i,r),a.configure(h.drm),a.init(s,!0)}.bind(t)).then(function(){return ir(this),tr(s)}.bind(t)).then(function(){return ir(this),rt(a)}.bind(t)).then(function(){return ir(this),o.stop()}.bind(t)).then(function(){return ir(this),{manifest:s,Sb:a}}.bind(t))["catch"](function(t){if(o)return o.stop().then(function(){throw t});throw t})}function Jn(t){return{trackSelectionCallback:t.A.bind(t),progressCallback:function(t,e){if(t||e)return null}}}function Zn(t){return t.a.a?Promise.resolve():t.a.init(ks)}function Qn(t){var e=t.h?t.h.o():Promise.resolve();return t.h=null,t.b=null,t.v=!1,t.i=null,t.l=[],t.f=-1,e}function tr(t){return t=t.periods.map(function(t){return t.streamSets}).reduce(k,[]).map(function(t){return t.streams}).reduce(k,[]),Promise.all(t.map(function(t){return t.createSegmentIndex()}))}function er(t,e,i,n){for(var r=[],s=t.b.presentationTimeline.ra(),a=s,o=n.findSegmentPosition(s),u=null!=o?n.getSegmentReference(o):null;u;){var h=t.a.b.segment++;Gn(t.g,i.type,u,(u.endTime-u.startTime)*n.bandwidth/8,function(t,e,i,n){return e={key:t,data:n,manifestKey:this.f,streamNumber:i,segmentNumber:e},this.l.push(t),On(this.a,"segment",e)}.bind(t,h,u.position,n.id)),r.push({startTime:u.startTime,endTime:u.endTime,uri:"offline:"+t.f+"/"+n.id+"/"+h}),a=u.endTime+e.startTime,u=n.getSegmentReference(++o)}return t.m=Math.max(t.m,a-s),e=null,n.initSegmentReference&&(h=t.a.b.segment++,e="offline:"+t.f+"/"+n.id+"/"+h,Gn(t.g,i.type,n.initSegmentReference,0,function(t,e){var i={key:h,data:e,manifestKey:this.f,streamNumber:t,segmentNumber:-1};return this.l.push(h),On(this.a,"segment",i)}.bind(t,n.id))),{id:n.id,primary:i.primary,presentationTimeOffset:n.presentationTimeOffset||0,contentType:i.type,mimeType:n.mimeType,codecs:n.codecs,frameRate:n.frameRate,kind:n.kind,language:i.language,width:n.width||null,height:n.height||null,initSegmentUri:e,encrypted:n.encrypted,keyId:n.keyId,segments:r}}function ir(t){if(!t.c)throw new S(9,9002)}function nr(t){Ps.push(t)}function rr(t){var e=t.type.replace(/^(webkit|moz|MS)/,"").toLowerCase(),e=new Event(e,t);t.target.dispatchEvent(e)}function sr(t){for(this.c=[],this.b=[],this.a=[],t=new Mi(new DataView(t.buffer));xi(t);){var e=Vi(1886614376,t);if(-1==e)break;var i=t.a-8,n=Di(t);if(1=i.a.length)){for(var n=[],r=0;rthis.a?this.b:Math.min(s(this.c),s(this.f))},e("shaka.abr.SimpleAbrManager",h),h.prototype.stop=function(){this.g=null,this.f=!1,this.h={},this.a={},this.c=null},h.prototype.stop=h.prototype.stop,h.prototype.init=function(t){this.g=t},h.prototype.init=h.prototype.init,h.prototype.chooseStreams=function(t){for(var e in t)this.h[e]=t[e];if(e={},"audio"in t){var i=c(this);i?(e.audio=i,this.a.audio=i):delete this.a.audio}return"video"in t&&((i=l(this))?(e.video=i,this.a.video=i):delete this.a.video),"text"in t&&(e.text=t.text.streams[0]),this.c=Date.now(),e},h.prototype.chooseStreams=h.prototype.chooseStreams,h.prototype.enable=function(){this.f=!0},h.prototype.enable=h.prototype.enable,h.prototype.disable=function(){this.f=!1},h.prototype.disable=h.prototype.disable,h.prototype.segmentDownloaded=function(t,e,i){var n=this.b;if(e-=t,16e3>i||(t=8e3*i/e,e/=1e3,n.a+=i,r(n.c,e,t),r(n.f,e,t)),null!=this.c&&this.f)t:{if(this.i){if(8e3>Date.now()-this.c)break t}else{if(!(128e3<=this.b.a))break t;this.i=!0}i={},(n=c(this))&&(i.audio=n,this.a.audio=n),(n=l(this))&&(i.video=n,this.a.video=n),this.c=Date.now(),this.b.getBandwidthEstimate(),this.g(i)}},h.prototype.segmentDownloaded=h.prototype.segmentDownloaded,h.prototype.getBandwidthEstimate=function(){return this.b.getBandwidthEstimate()},h.prototype.getBandwidthEstimate=h.prototype.getBandwidthEstimate,h.prototype.setDefaultEstimate=function(t){this.b.setDefaultEstimate(t)},h.prototype.setDefaultEstimate=h.prototype.setDefaultEstimate;var Wr=/^(?:([^:\/?#.]+):)?(?:\/\/(?:([^\/?#]*)@)?([^\/#?]*?)(?::([0-9]+))?(?=[\/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/;$r=d.prototype,$r.R="",$r.ka="",$r.T="",$r.wa=null,$r.O="",$r.ca="",$r.toString=function(){var t=[],e=this.R;if(e&&t.push(g(e,Xr,!0),":"),e=this.T){t.push("//");var i=this.ka;i&&t.push(g(i,Xr,!0),"@"),t.push(encodeURIComponent(e).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e=this.wa,null!=e&&t.push(":",String(e))}return(e=this.O)&&(this.T&&"/"!=e.charAt(0)&&t.push("/"),t.push(g(e,"/"==e.charAt(0)?Zr:Jr,!0))),(e=this.a.toString())&&t.push("?",e),(e=this.ca)&&t.push("#",g(e,ts)),t.join("")},$r.resolve=function(t){var e=new d(this);"data"===e.R&&(e=new d);var i=!!t.R;i?p(e,t.R):i=!!t.ka,i?e.ka=t.ka:i=!!t.T,i?e.T=t.T:i=null!=t.wa;var n=t.O;if(i)m(e,t.wa);else if(i=!!t.O){if("/"!=n.charAt(0))if(this.T&&!this.O)n="/"+n;else{var r=e.O.lastIndexOf("/");-1!=r&&(n=e.O.substr(0,r+1)+n)}if(".."==n||"."==n)n="";else if(-1!=n.indexOf("./")||-1!=n.indexOf("/.")){for(var r=!n.lastIndexOf("/",0),n=n.split("/"),s=[],a=0;ai||n&&1e3>i)&&(this.a.splice(e,1),t.close()),W(this.v)}},$r.yc=function(){V(this.w,function(t,e){return"expired"==e})&&this.h(new S(6,6014)),this.J(this.w)};var is={},ns={};e("shaka.media.ManifestParser.registerParserByExtension",function(t,e){ns[t]=e}),e("shaka.media.ManifestParser.registerParserByMime",function(t,e){is[t]=e});var rs={};e("shaka.media.TextEngine.registerParser",function(t,e){rs[t]=e}),e("shaka.media.TextEngine.unregisterParser",function(t){delete rs[t]}),e("shaka.media.TextEngine.makeCue",vt);var ss=t.VTTCue||t.TextTrackCue;gt.prototype.o=function(){return this.c&&St(this,function(){return!0}),this.c=this.h=null,Promise.resolve()},gt.prototype.remove=function(t,e){return Promise.resolve().then(function(){this.c&&(St(this,function(i){return!(i.startTime>=e||i.endTime<=t)}),null==this.b||e<=this.b||t>=this.a||(t<=this.b&&e>=this.a?this.b=this.a=null:t<=this.b&&ethis.b&&e>=this.a&&(this.a=t)))}.bind(this))},$r=Pt.prototype,$r.o=function(){this.i=!0;var t,e=[];for(t in this.a){var i=this.a[t],n=i[0];for(this.a[t]=i.slice(0,1),n&&e.push(n.p["catch"](P)),n=1;n=this.a.duration-.05||this.a.ended;this.h?(e||t>=this.j)&&qt(this,!1):!e&&.5>t&&qt(this,!0)},$r.Ta=function(){return this.g},$r.lc=function(){this.a.playbackRate!=(this.h||0>this.g?0:this.g)&&zt(this,this.a.playbackRate)},$r.sb=function(){this.b.ja(this.a,"loadedmetadata");var t=Vt(this);.001>Math.abs(this.a.currentTime-t)?(L(this.b,this.a,"seeking",this.ub.bind(this)),L(this.b,this.a,"playing",this.tb.bind(this))):(L(this.b,this.a,"seeking",this.nc.bind(this)),this.a.currentTime=t)},$r.nc=function(){this.b.ja(this.a,"seeking"),L(this.b,this.a,"seeking",this.ub.bind(this)),L(this.b,this.a,"playing",this.tb.bind(this))},$r.ub=function(){var t=this.a.currentTime,e=$t(this,t);.001this.ma.indexOf(t.id)}.bind(this))},Ue.prototype.getTracks=Ue.prototype.getTracks,Ue.prototype.Gc=function(t,e){if(this.b){var i=ee(ue(this.b),t);if(i){var n=i.stream;n.allowedByApplication&&n.allowedByKeySystem&&(this.C.push({timestamp:Date.now()/1e3,id:n.id,type:t.type,fromAdaptation:!1}),i={},i[t.type]=n,"text"!=t.type&&(n=he(this.b).text,this.configure({abr:{enabled:!1}}),i.text=n),He(this,i,e))}}},Ue.prototype.selectTrack=Ue.prototype.Gc,Ue.prototype.bc=function(){return"showing"==this.s.mode},Ue.prototype.isTextTrackVisible=Ue.prototype.bc,Ue.prototype.Ic=function(t){this.s.mode=t?"showing":"hidden",Xe(this)},Ue.prototype.setTextTrackVisibility=Ue.prototype.Ic,Ue.prototype.getStats=function(){Ge(this);var t={},e={},i=this.f&&this.f.getVideoPlaybackQuality?this.f.getVideoPlaybackQuality():{};return this.b&&(e=he(this.b),t=e.video||{},e=e.audio||{}),{width:t.width||0,height:t.height||0,streamBandwidth:t.bandwidth+e.bandwidth||0,decodedFrames:Number(i.totalVideoFrames),droppedFrames:Number(i.droppedVideoFrames),estimatedBandwidth:this.a.abr.manager.getBandwidthEstimate(),playTime:this.pa,bufferingTime:this.J,switchHistory:this.C.slice(0)}},Ue.prototype.getStats=Ue.prototype.getStats,Ue.prototype.addTextTrack=function(t,e,i,n,r){if(!this.b)return Promise.reject();for(var s,a=ue(this.b),o=0;oe&&(e+=Math.pow(2,32)),e=e.toString(16)),this.Z(new S(3,3016,t,e))}}},$r.Mc=function(t){var e=["output-restricted","internal-error"],i=ue(this.b),n=!1;i.streamSets.forEach(function(i){i.streams.forEach(function(i){var r=i.allowedByKeySystem;i.keyId&&i.keyId in t&&(i.allowedByKeySystem=0>e.indexOf(t[i.keyId])),r!=i.allowedByKeySystem&&(n=!0)})}),$e(this,i),n&&We(this)};var cs="ended play playing pause pausing ratechange seeked seeking timeupdate volumechange".split(" "),ls="buffered currentTime duration ended loop muted paused playbackRate seeking videoHeight videoWidth volume".split(" "),fs=["loop","playbackRate"],ds=["pause","play"],ps=["adaptation","buffering","error","texttrackvisibility","trackschanged"],ms="getConfiguration getManifestUri getPlaybackRate getTracks getStats isBuffering isLive isTextTrackVisible seekRange".split(" "),ys=[["getConfiguration","configure"]],bs=[["isTextTrackVisible","setTextTrackVisibility"]],gs="configure resetConfiguration trickPlay cancelTrickPlay selectTrack setTextTrackVisibility addTextTrack".split(" "),vs=["load","unload"];$r=ti.prototype,$r.o=function(){return ei(this),this.a&&(this.a.stop(function(){},function(){}),this.a=null),this.A=this.w=this.l=null,this.f=this.j=this.g=!1,this.h=this.c=this.b=this.a=this.i=null,Promise.resolve()},$r.N=function(){return this.f},$r.ab=function(){return this.v},$r.init=function(){if(t.chrome&&chrome.cast&&chrome.cast.isAvailable){delete t.__onGCastApiAvailable,this.g=!0,this.l();var e=new chrome.cast.SessionRequest(this.C),e=new chrome.cast.ApiConfig(e,this.fc.bind(this),this.mc.bind(this),"origin_scoped");chrome.cast.initialize(e,function(){},function(){})}else t.__onGCastApiAvailable=function(t){t&&this.init()}.bind(this)},$r.cb=function(t){this.i=t,this.f&&ii(this,{type:"appData",appData:this.i})},$r.cast=function(t){return this.g?this.j?this.f?Promise.reject(new S(8,8002)):(this.h=new R,chrome.cast.requestSession(this.Za.bind(this,t),this.pb.bind(this)),this.h):Promise.reject(new S(8,8001)):Promise.reject(new S(8,8e3))},$r.get=function(t,e){if("video"==t){if(0<=ds.indexOf(e))return this.Ab.bind(this,t,e)}else if("player"==t){if(0<=gs.indexOf(e))return this.Ab.bind(this,t,e);if(0<=vs.indexOf(e))return this.Bc.bind(this,t,e);if(0<=ms.indexOf(e))return this.xb.bind(this,t,e)}return this.xb(t,e)},$r.set=function(t,e,i){this.b[t][e]=i,ii(this,{type:"set",targetName:t,property:e,value:i})},$r.Za=function(t,e){this.a=e,this.a.addUpdateListener(this.qb.bind(this)),this.a.addMessageListener("urn:x-cast:com.google.shaka.v2",this.gc.bind(this)),this.qb(),ii(this,{type:"init",initState:t,appData:this.i}),this.h.resolve()},$r.pb=function(t){var e=8003;switch(t.code){case"cancel":e=8004;break;case"timeout":e=8005;break;case"receiver_unavailable":e=8006}this.h.reject(new S(8,e,t))},$r.xb=function(t,e){return this.b[t][e]},$r.Ab=function(t,e){ii(this,{type:"call",targetName:t,methodName:e,args:Array.prototype.slice.call(arguments,2)})},$r.Bc=function(t,e){var i=Array.prototype.slice.call(arguments,2),n=new R,r=this.m.toString();return this.m++,this.c[r]=n,ii(this,{type:"asyncCall",targetName:t,methodName:e,args:i,id:r}),n},$r.fc=function(t){var e=this.s();this.h=new R,this.Za(e,t)},$r.mc=function(t){this.j="available"==t,this.l()},$r.qb=function(){var t=!!this.a&&"connected"==this.a.status;if(this.f&&!t){this.A();for(var e in this.b)this.b[e]={};ei(this)}this.v=(this.f=t)?this.a.receiver.friendlyName:"",this.l()},$r.gc=function(t,e){var i=Ze(e);switch(i.type){case"event":var n=i.targetName,r=i.event;this.w(n,new Le(r.type,r));break;case"update":r=i.update;for(n in r){var s,i=this.b[n]||{};for(s in r[n])i[s]=r[n][s]}break;case"asyncComplete":if(n=i.id,s=i.error,i=this.c[n],delete this.c[n],i)if(s){n=new S(s.category,s.code);for(r in s)n[r]=s[r];i.reject(n)}else i.resolve()}},i(ni),e("shaka.cast.CastProxy",ni),ni.prototype.o=function(){var t=[this.i?this.i.o():null,this.b?this.b.o():null,this.a?this.a.o():null];return this.a=this.i=this.j=this.l=this.b=this.c=null,Promise.all(t)},ni.prototype.destroy=ni.prototype.o,ni.prototype.Yb=function(){return this.l},ni.prototype.getVideo=ni.prototype.Yb,ni.prototype.Wb=function(){return this.j},ni.prototype.getPlayer=ni.prototype.Wb,ni.prototype.Mb=function(){return!!this.a&&(this.a.g&&this.a.j)},ni.prototype.canCast=ni.prototype.Mb,ni.prototype.N=function(){return!!this.a&&this.a.N()},ni.prototype.isCasting=ni.prototype.N,ni.prototype.ab=function(){return this.a?this.a.ab():""},ni.prototype.receiverName=ni.prototype.ab,ni.prototype.cast=function(){var t=this.mb();return this.a.cast(t).then(function(){return this.b.hb()}.bind(this))},ni.prototype.cast=ni.prototype.cast,ni.prototype.cb=function(t){this.a.cb(t)},ni.prototype.setAppData=ni.prototype.cb,ni.prototype.Xc=function(){var t=this.a;if(t.f){var e=t.s();chrome.cast.requestSession(t.Za.bind(t,e),t.pb.bind(t))}},ni.prototype.suggestDisconnect=ni.prototype.Xc,$r=ni.prototype,$r.mb=function(){var t={video:{},player:{},playerAfterLoad:{},manifest:this.b.na,startTime:null};return this.c.pause(),fs.forEach(function(e){t.video[e]=this.c[e]}.bind(this)),this.c.ended||(t.startTime=this.c.currentTime),ys.forEach(function(e){var i=e[1];e=this.b[e[0]](),t.player[i]=e}.bind(this)),bs.forEach(function(e){var i=e[1];e=this.b[e[0]](),t.playerAfterLoad[i]=e}.bind(this)),t},$r.Pc=function(){this.dispatchEvent(new Le("caststatuschanged"))},$r.Rc=function(){ys.forEach(function(t){var e=t[1];t=this.a.get("player",t[0])(),this.b[e](t)}.bind(this));var t=this.a.get("player","getManifestUri")(),e=this.a.get("video","ended"),i=Promise.resolve(),n=this.c.autoplay,r=null;e||(r=this.a.get("video","currentTime")),t&&(this.c.autoplay=!1,i=this.b.load(t,r),i["catch"](function(t){this.b.dispatchEvent(new Le("error",{detail:t}))}.bind(this)));var s={};fs.forEach(function(t){s[t]=this.a.get("video",t)}.bind(this)),i.then(function(){fs.forEach(function(t){this.c[t]=s[t]}.bind(this)),bs.forEach(function(t){var e=t[1];t=this.a.get("player",t[0])(),this.b[e](t)}.bind(this)),this.c.autoplay=n,t&&this.c.play()}.bind(this))},$r.bd=function(t){if("addEventListener"==t)return this.g.addEventListener.bind(this.g);if("removeEventListener"==t)return this.g.removeEventListener.bind(this.g);if(this.a.N()&&!Object.keys(this.a.b.video).length){var e=this.c[t];if("function"!=typeof e)return e}return this.a.N()?this.a.get("video",t):(e=this.c[t],"function"==typeof e&&(e=e.bind(this.c)),e)},$r.dd=function(t,e){this.a.N()?this.a.set("video",t,e):this.c[t]=e},$r.cd=function(t){this.a.N()||this.g.dispatchEvent(new Le(t.type,t))},$r.wc=function(t){return"addEventListener"==t?this.f.addEventListener.bind(this.f):"removeEventListener"==t?this.f.removeEventListener.bind(this.f):"getNetworkingEngine"==t?this.b.nb.bind(this.b):this.a.N()&&!Object.keys(this.a.b.video).length&&0<=ms.indexOf(t)||!this.a.N()?(t=this.b[t],t.bind(this.b)):this.a.get("player",t)},$r.xc=function(t){this.a.N()||this.f.dispatchEvent(t)},$r.Qc=function(t,e){this.a.N()&&("video"==t?this.g.dispatchEvent(e):"player"==t&&this.f.dispatchEvent(e))},i(si),e("shaka.cast.CastReceiver",si),si.prototype.$b=function(){return this.i},si.prototype.isConnected=si.prototype.$b,si.prototype.ac=function(){return this.c},si.prototype.isIdle=si.prototype.ac,si.prototype.o=function(){var e=this.a?this.a.o():Promise.resolve();return null!=this.f&&t.clearTimeout(this.f),this.l=this.j=this.a=this.b=null,this.i=!1,this.c=!0,this.f=this.g=null,e.then(function(){cast.receiver.CastReceiverManager.getInstance().stop()})},si.prototype.destroy=si.prototype.o,$r=si.prototype,$r.vb=function(){this.i=!!cast.receiver.CastReceiverManager.getInstance().getSenders().length,oi(this)},$r.yb=function(t,e){this.$a(),hi(this,{type:"event",targetName:t,event:e})},$r.$a=function(){null!=this.f&&t.clearTimeout(this.f),this.f=t.setTimeout(this.$a.bind(this),500);var e={video:{},player:{}};ls.forEach(function(t){e.video[t]=this.b[t]}.bind(this)),ms.forEach(function(t){e.player[t]=this.a[t]()}.bind(this));var i=cast.receiver.CastReceiverManager.getInstance().getSystemVolume();i&&(e.video.volume=i.level,e.video.muted=i.muted),hi(this,{type:"update",update:e})},$r.Tb=function(){var t=cast.receiver.CastReceiverManager.getInstance().getSystemVolume();t&&hi(this,{type:"update",update:{video:{volume:t.level,muted:t.muted}}}),hi(this,{type:"event",targetName:"video",event:{type:"volumechange"}})},$r.hc=function(t){var e=Ze(t.data);switch(e.type){case"init":ui(this,e.initState,e.appData),this.$a();break;case"appData":this.l(e.appData);break;case"set":var i=e.targetName,n=e.property,r=e.value;if("video"==i){if(e=cast.receiver.CastReceiverManager.getInstance(),"volume"==n){e.setSystemVolumeLevel(r);break}if("muted"==n){e.setSystemVolumeMuted(r);break}}this.j[i][n]=r;break;case"call":i=e.targetName,n=e.methodName,r=e.args,i=this.j[i],i[n].apply(i,r);break;case"asyncCall":i=e.targetName,n=e.methodName,r=e.args,e=e.id,t=t.senderId,i=this.j[i],i[n].apply(i,r).then(this.Eb.bind(this,t,e,null),this.Eb.bind(this,t,e))}},$r.Eb=function(t,e,i){hi(this,{type:"asyncComplete",id:e,error:i},t)};var ws={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"},Es=1/15,Ss=1;e("shaka.media.SegmentIndex",Gi),Gi.prototype.o=function(){return this.a=null,Promise.resolve()},Gi.prototype.destroy=Gi.prototype.o,Gi.prototype.find=function(t){for(var e=this.a.length-1;0<=e;--e){var i=this.a[e];if(t>=i.startTime&&tt||t>=this.a.length?null:this.a[t]):null},Gi.prototype.get=Gi.prototype.get,Gi.prototype.Xa=function(t){for(var e=[],i=0,n=0;is.startTime||(.1t);++e);this.a.splice(0,e)},Gi.prototype.evict=Gi.prototype.Sa;var Ts;e("shaka.dash.DashParser",dn),$r=dn.prototype,$r.configure=function(t){this.c=t},$r.start=function(t,e,i,n,r){return this.h=[t],this.a=e,this.j=i,this.l=n,this.m=r,pn(this).then(function(){return this.a&&bn(this,0),this.b}.bind(this))},$r.stop=function(){return this.a&&this.a.Kb(this.Ka),this.c=this.m=this.l=this.j=this.a=null,this.h=[],this.b=null,this.g=[],this.i={},null!=this.f&&(t.clearTimeout(this.f),this.f=null),Promise.resolve()},$r.uc=function(t,e){t.P=gn(e,t.K,null);var i=!1,n=li(e,"Role"),r=void 0;"text"==t.P.contentType&&(r="subtitle");for(var s=0;si.length)return null;var n=null;if(t=kn.pa(t,e))for(e=0;et[0].indexOf("-->")&&(r=t[0],t.splice(0,1));var s=new In(t[0]),a=Nn.a(s),o=_n(s,/[ \t]+--\x3e[ \t]+/g),u=Nn.a(s);if(null==a||!o||null==u)throw new S(2,2001);if(a+=e,u+=e,n&&(a+=i,u+=i),t=vt(a,u,t.slice(1).join("\n").trim()),!t)return null;for(_n(s,/[ \t]+/gm),e=Rn(s);e;)Nn.j(t,e),_n(s,/[ \t]+/gm),e=Rn(s);return null!=r&&(t.id=r),t},Nn.j=function(t,e){var i;(i=/^align:(start|middle|center|end|left|right)$/.exec(e))?(t.align=i[1],"center"==i[1]&&"center"!=t.align&&(t.position="auto",t.align="middle")):(i=/^vertical:(lr|rl)$/.exec(e))?t.vertical=i[1]:(i=/^size:(\d{1,2}|100)%$/.exec(e))?t.size=Number(i[1]):(i=/^position:(\d{1,2}|100)%(?:,(line-left|line-right|center|start|end))?$/.exec(e))?(t.position=Number(i[1]),i[2]&&(t.positionAlign=i[2])):(i=/^line:(\d{1,2}|100)%(?:,(start|end|center))?$/.exec(e))?(t.snapToLines=!1,t.line=Number(i[1]),i[2]&&(t.lineAlign=i[2])):(i=/^line:(-?\d+)(?:,(start|end|center))?$/.exec(e))&&(t.snapToLines=!0,t.line=Number(i[1]),i[2]&&(t.lineAlign=i[2]))},Nn.a=function(t){if(t=_n(t,/(?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3})/g),!t)return null;var e=Number(t[2]),i=Number(t[3]);return 59=t.height});i.sort(function(t,e){return e.bandwidth-t.bandwidth}),i.length&&e.push(i[0]);for(var n=Jt(this.c.getConfiguration().preferredAudioLanguage),i=[0,as,os],r=t.filter(function(t){return"audio"==t.type}),i=i.map(function(t){return r.filter(function(e){return e=Jt(e.language),Xt(t,n,e)})}),s=r,a=0;ae.indexOf("Apple")||(0<=i.indexOf("Version/8")?t.MediaSource=null:0<=i.indexOf("Version/9")?Mr():0<=i.indexOf("Version/10")&&(Mr(),xr()))}});var Rs=0;Lr.prototype.then=function(t,e){var i=new Lr;switch(this.ia){case 1:Kr(this,i,t);break;case 2:Kr(this,i,e);break;case Rs:this.c.push({I:i,Da:t}),this.b.push({I:i,Da:e})}return i},Lr.prototype["catch"]=function(t){return this.then(void 0,t)},Lr.prototype.W=function(t){if(this.ia==Rs){for(this.Oa=t,this.ia=1,t=0;t