/*
 @license
 Shaka Player
 Copyright 2016 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
(function(){var innerGlobal=typeof window!="undefined"?window:global;var exportTo={};(function(window,global,module){/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_ES6=!1;$jscomp.ASSUME_ES2020=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.INSTRUMENT_ASYNC_CONTEXT=!0;$jscomp.objectCreate=$jscomp.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(a){var b=function(){};b.prototype=a;return new b};
$jscomp.defineProperty=$jscomp.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};
$jscomp.global=$jscomp.ASSUME_ES2020?globalThis:$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE=typeof Symbol==="function"&&typeof Symbol("x")==="symbol";$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b,c){if(!c||a!=null){c=$jscomp.propertyToPolyfillSymbol[b];if(c==null)return a[b];c=a[c];return c!==void 0?c:a[b]}};
$jscomp.polyfill=function(a,b,c,d){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,d):$jscomp.polyfillUnisolated(a,b,c,d))};$jscomp.polyfillUnisolated=function(a,b,c,d){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))return;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&b!=null&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
$jscomp.polyfillIsolated=function(a,b,c,d){var e=a.split(".");a=e.length===1;d=e[0];d=!a&&d in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<e.length-1;f++){var g=e[f];if(!(g in d))return;d=d[g]}e=e[e.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&c==="es6"?d[e]:null;b=b(c);b!=null&&(a?$jscomp.defineProperty($jscomp.polyfills,e,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[e]===void 0&&(c=Math.random()*1E9>>>0,$jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+c+"$"+e),$jscomp.defineProperty(d,$jscomp.propertyToPolyfillSymbol[e],{configurable:!0,writable:!0,value:b})))};
$jscomp.getConstructImplementation=function(){function a(){function c(){}new c;Reflect.construct(c,[],function(){});return new c instanceof c}if($jscomp.TRUST_ES6_POLYFILLS&&typeof Reflect!="undefined"&&Reflect.construct){if(a())return Reflect.construct;var b=Reflect.construct;return function(c,d,e){c=b(c,d);e&&Reflect.setPrototypeOf(c,e.prototype);return c}}return function(c,d,e){e===void 0&&(e=c);e=$jscomp.objectCreate(e.prototype||Object.prototype);return Function.prototype.apply.call(c,e,d)||
e}};$jscomp.construct={valueOf:$jscomp.getConstructImplementation}.valueOf();$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};$jscomp.setPrototypeOf=$jscomp.ASSUME_ES6||$jscomp.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;
$jscomp.inherits=function(a,b){a.prototype=$jscomp.objectCreate(b.prototype);a.prototype.constructor=a;if($jscomp.ASSUME_ES6||$jscomp.setPrototypeOf){var c=$jscomp.setPrototypeOf;c(a,b)}else for(c in b)if(c!="prototype")if(Object.defineProperties){var d=Object.getOwnPropertyDescriptor(b,c);d&&Object.defineProperty(a,c,d)}else a[c]=b[c];a.superClass_=b.prototype};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};
$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if(typeof a.length=="number")return $jscomp.arrayIterator(a);throw Error(String(a)+" is not an iterable or ArrayLike");};$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};
$jscomp.initSymbol=function(){};$jscomp.polyfill("Symbol",function(a){if(a)return a;var b=function(f,g){this.$jscomp$symbol$id_=f;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.$jscomp$symbol$id_};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new b(c+(f||"")+"_"+d++,f)};return e},"es6","es3");
$jscomp.polyfill("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=$jscomp.global[b[c]];typeof d==="function"&&typeof d.prototype[a]!="function"&&$jscomp.defineProperty(d.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}})}return a},"es6",
"es3");$jscomp.iteratorPrototype=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a};$jscomp.createTemplateTagFirstArg=function(a){return $jscomp.createTemplateTagFirstArgWithRaw(a,a)};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;Object.freeze&&(Object.freeze(a),Object.freeze(b));return a};$jscomp.generator={};
$jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};
$jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a};
$jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};
$jscomp.generator.Context.prototype.yieldAll=function(a,b){a=$jscomp.makeIterator(a);var c=a.next();$jscomp.generator.ensureIteratorResultIsObject_(c);if(c.done)this.yieldResult=c.value,this.nextAddress=b;else return this.yieldAllIterator_=a,this.yield(c.value,b)};$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};
$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;b!=void 0&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,b,c){c?this.finallyContexts_[c]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0};
$jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,b){b=this.finallyContexts_.splice(b||0)[0];if(b=this.abruptCompletion_=this.abruptCompletion_||b){if(b.isException)return this.jumpToErrorHandler_();b.jumpTo!=void 0&&this.finallyAddress_<b.jumpTo?(this.nextAddress=b.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};
$jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a};
$jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(c){return{value:c,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var d=a.call(this.context_.yieldAllIterator_,b);$jscomp.generator.ensureIteratorResultIsObject_(d);if(!d.done)return this.context_.stop_(),d;var e=d.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,e);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}};
$jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){b=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(b,a.prototype);return b};
$jscomp.asyncExecutePromiseGenerator=function(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function f(g){g.done?d(g.value):Promise.resolve(g.value).then(b,c).then(f,e)}f(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))};
$jscomp.getRestArguments=function(){for(var a=Number(this),b=[],c=a;c<arguments.length;c++)b[c-a]=arguments[c];return b};$jscomp.polyfill("Reflect",function(a){return a?a:{}},"es6","es3");$jscomp.polyfill("Reflect.construct",function(a){return $jscomp.construct},"es6","es3");$jscomp.polyfill("Reflect.setPrototypeOf",function(a){if(a)return a;if($jscomp.setPrototypeOf){var b=$jscomp.setPrototypeOf;return function(c,d){try{return b(c,d),!0}catch(e){return!1}}}return null},"es6","es5");
$jscomp.polyfill("Promise",function(a){function b(){this.batch_=null}function c(g){return g instanceof e?g:new e(function(h,k){h(g)})}if(a&&(!($jscomp.FORCE_POLYFILL_PROMISE||$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION&&typeof $jscomp.global.PromiseRejectionEvent==="undefined")||!$jscomp.global.Promise||$jscomp.global.Promise.toString().indexOf("[native code]")===-1))return a;b.prototype.asyncExecute=function(g){if(this.batch_==null){this.batch_=[];var h=this;this.asyncExecuteFunction(function(){h.executeBatch_()})}this.batch_.push(g)};
var d=$jscomp.global.setTimeout;b.prototype.asyncExecuteFunction=function(g){d(g,0)};b.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var g=this.batch_;this.batch_=[];for(var h=0;h<g.length;++h){var k=g[h];g[h]=null;try{k()}catch(l){this.asyncThrow_(l)}}}this.batch_=null};b.prototype.asyncThrow_=function(g){this.asyncExecuteFunction(function(){throw g;})};var e=function(g){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];this.isRejectionHandled_=!1;var h=this.createResolveAndReject_();
try{g(h.resolve,h.reject)}catch(k){h.reject(k)}};e.prototype.createResolveAndReject_=function(){function g(l){return function(m){k||(k=!0,l.call(h,m))}}var h=this,k=!1;return{resolve:g(this.resolveTo_),reject:g(this.reject_)}};e.prototype.resolveTo_=function(g){if(g===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(g instanceof e)this.settleSameAsPromise_(g);else{a:switch(typeof g){case "object":var h=g!=null;break a;case "function":h=!0;break a;default:h=!1}h?this.resolveToNonPromiseObj_(g):
this.fulfill_(g)}};e.prototype.resolveToNonPromiseObj_=function(g){var h=void 0;try{h=g.then}catch(k){this.reject_(k);return}typeof h=="function"?this.settleSameAsThenable_(h,g):this.fulfill_(g)};e.prototype.reject_=function(g){this.settle_(2,g)};e.prototype.fulfill_=function(g){this.settle_(1,g)};e.prototype.settle_=function(g,h){if(this.state_!=0)throw Error("Cannot settle("+g+", "+h+"): Promise already settled in state"+this.state_);this.state_=g;this.result_=h;this.state_===2&&this.scheduleUnhandledRejectionCheck_();
this.executeOnSettledCallbacks_()};e.prototype.scheduleUnhandledRejectionCheck_=function(){var g=this;d(function(){if(g.notifyUnhandledRejection_()){var h=$jscomp.global.console;typeof h!=="undefined"&&h.error(g.result_)}},1)};e.prototype.notifyUnhandledRejection_=function(){if(this.isRejectionHandled_)return!1;var g=$jscomp.global.CustomEvent,h=$jscomp.global.Event,k=$jscomp.global.dispatchEvent;if(typeof k==="undefined")return!0;typeof g==="function"?g=new g("unhandledrejection",{cancelable:!0}):
typeof h==="function"?g=new h("unhandledrejection",{cancelable:!0}):(g=$jscomp.global.document.createEvent("CustomEvent"),g.initCustomEvent("unhandledrejection",!1,!0,g));g.promise=this;g.reason=this.result_;return k(g)};e.prototype.executeOnSettledCallbacks_=function(){if(this.onSettledCallbacks_!=null){for(var g=0;g<this.onSettledCallbacks_.length;++g)f.asyncExecute(this.onSettledCallbacks_[g]);this.onSettledCallbacks_=null}};var f=new b;e.prototype.settleSameAsPromise_=function(g){var h=this.createResolveAndReject_();
g.callWhenSettled_(h.resolve,h.reject)};e.prototype.settleSameAsThenable_=function(g,h){var k=this.createResolveAndReject_();try{g.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};e.prototype.then=function(g,h){function k(p,q){return typeof p=="function"?function(r){try{l(p(r))}catch(t){m(t)}}:q}var l,m,n=new e(function(p,q){l=p;m=q});this.callWhenSettled_(k(g,l),k(h,m));return n};e.prototype.catch=function(g){return this.then(void 0,g)};e.prototype.callWhenSettled_=function(g,h){function k(){switch(l.state_){case 1:g(l.result_);
break;case 2:h(l.result_);break;default:throw Error("Unexpected state: "+l.state_);}}var l=this;this.onSettledCallbacks_==null?f.asyncExecute(k):this.onSettledCallbacks_.push(k);this.isRejectionHandled_=!0};e.resolve=c;e.reject=function(g){return new e(function(h,k){k(g)})};e.race=function(g){return new e(function(h,k){for(var l=$jscomp.makeIterator(g),m=l.next();!m.done;m=l.next())c(m.value).callWhenSettled_(h,k)})};e.all=function(g){var h=$jscomp.makeIterator(g),k=h.next();return k.done?c([]):new e(function(l,
m){function n(r){return function(t){p[r]=t;q--;q==0&&l(p)}}var p=[],q=0;do p.push(void 0),q++,c(k.value).callWhenSettled_(n(p.length-1),m),k=h.next();while(!k.done)})};return e},"es6","es3");$jscomp.checkEs6ConformanceViaProxy=function(){try{var a={},b=Object.create(new $jscomp.global.Proxy(a,{get:function(c,d,e){return c==a&&d=="q"&&e==b}}));return b.q===!0}catch(c){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();
$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};
$jscomp.polyfill("WeakMap",function(a){function b(){if(!a||!Object.seal)return!1;try{var l=Object.seal({}),m=Object.seal({}),n=new a([[l,2],[m,3]]);if(n.get(l)!=2||n.get(m)!=3)return!1;n.delete(l);n.set(m,4);return!n.has(l)&&n.get(m)==4}catch(p){return!1}}function c(){}function d(l){var m=typeof l;return m==="object"&&l!==null||m==="function"}function e(l){if(!$jscomp.owns(l,g)){var m=new c;$jscomp.defineProperty(l,g,{value:m})}}function f(l){if(!$jscomp.ISOLATE_POLYFILLS){var m=Object[l];m&&(Object[l]=
function(n){if(n instanceof c)return n;Object.isExtensible(n)&&e(n);return m(n)})}}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var g="$jscomp_hidden_"+Math.random();f("freeze");f("preventExtensions");f("seal");var h=0,k=function(l){this.id_=(h+=Math.random()+1).toString();if(l){l=$jscomp.makeIterator(l);for(var m;!(m=l.next()).done;)m=m.value,this.set(m[0],m[1])}};k.prototype.set=function(l,m){if(!d(l))throw Error("Invalid WeakMap key");
e(l);if(!$jscomp.owns(l,g))throw Error("WeakMap key fail: "+l);l[g][this.id_]=m;return this};k.prototype.get=function(l){return d(l)&&$jscomp.owns(l,g)?l[g][this.id_]:void 0};k.prototype.has=function(l){return d(l)&&$jscomp.owns(l,g)&&$jscomp.owns(l[g],this.id_)};k.prototype.delete=function(l){return d(l)&&$jscomp.owns(l,g)&&$jscomp.owns(l[g],this.id_)?delete l[g][this.id_]:!1};return k},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_MAP||!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var k=Object.seal({x:4}),l=new a($jscomp.makeIterator([[k,"s"]]));if(l.get(k)!="s"||l.size!=1||l.get({x:4})||l.set({x:4},"t")!=l||l.size!=2)return!1;var m=l.entries(),n=m.next();if(n.done||n.value[0]!=k||n.value[1]!="s")return!1;n=m.next();return n.done||n.value[0].x!=4||n.value[1]!="t"||!m.next().done?!1:!0}catch(p){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=new WeakMap,d=function(k){this[0]={};this[1]=g();this.size=0;if(k){k=$jscomp.makeIterator(k);for(var l;!(l=k.next()).done;)l=l.value,this.set(l[0],l[1])}};d.prototype.set=function(k,l){k=k===0?0:k;var m=e(this,k);m.list||(m.list=this[0][m.id]=[]);m.entry?m.entry.value=l:(m.entry={next:this[1],previous:this[1].previous,head:this[1],key:k,value:l},m.list.push(m.entry),this[1].previous.next=
m.entry,this[1].previous=m.entry,this.size++);return this};d.prototype.delete=function(k){k=e(this,k);return k.entry&&k.list?(k.list.splice(k.index,1),k.list.length||delete this[0][k.id],k.entry.previous.next=k.entry.next,k.entry.next.previous=k.entry.previous,k.entry.head=null,this.size--,!0):!1};d.prototype.clear=function(){this[0]={};this[1]=this[1].previous=g();this.size=0};d.prototype.has=function(k){return!!e(this,k).entry};d.prototype.get=function(k){return(k=e(this,k).entry)&&k.value};d.prototype.entries=
function(){return f(this,function(k){return[k.key,k.value]})};d.prototype.keys=function(){return f(this,function(k){return k.key})};d.prototype.values=function(){return f(this,function(k){return k.value})};d.prototype.forEach=function(k,l){for(var m=this.entries(),n;!(n=m.next()).done;)n=n.value,k.call(l,n[1],n[0],this)};d.prototype[Symbol.iterator]=d.prototype.entries;var e=function(k,l){var m=l&&typeof l;m=="object"||m=="function"?c.has(l)?m=c.get(l):(m=""+ ++h,c.set(l,m)):m="p_"+l;var n=k[0][m];
if(n&&$jscomp.owns(k[0],m))for(k=0;k<n.length;k++){var p=n[k];if(l!==l&&p.key!==p.key||l===p.key)return{id:m,list:n,index:k,entry:p}}return{id:m,list:n,index:-1,entry:void 0}},f=function(k,l){var m=k[1];return $jscomp.iteratorPrototype(function(){if(m){for(;m.head!=k[1];)m=m.previous;for(;m.next!=m.head;)return m=m.next,{done:!1,value:l(m)};m=null}return{done:!0,value:void 0}})},g=function(){var k={};return k.previous=k.next=k.head=k},h=0;return d},"es6","es3");
$jscomp.polyfill("Set",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_SET||!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var d=Object.seal({x:4}),e=new a($jscomp.makeIterator([d]));if(!e.has(d)||e.size!=1||e.add(d)!=e||e.size!=1||e.add({x:4})!=e||e.size!=2)return!1;var f=e.entries(),g=f.next();if(g.done||g.value[0]!=d||g.value[1]!=d)return!1;g=f.next();return g.done||g.value[0]==d||g.value[0].x!=4||g.value[1]!=g.value[0]?!1:f.next().done}catch(h){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=function(d){this.map_=new Map;if(d){d=$jscomp.makeIterator(d);for(var e;!(e=d.next()).done;)this.add(e.value)}this.size=this.map_.size};c.prototype.add=function(d){d=d===0?0:d;this.map_.set(d,d);this.size=this.map_.size;return this};c.prototype.delete=function(d){d=this.map_.delete(d);this.size=this.map_.size;return d};c.prototype.clear=function(){this.map_.clear();this.size=0};c.prototype.has=
function(d){return this.map_.has(d)};c.prototype.entries=function(){return this.map_.entries()};c.prototype.values=function(){return this.map_.values()};c.prototype.keys=c.prototype.values;c.prototype[Symbol.iterator]=c.prototype.values;c.prototype.forEach=function(d,e){var f=this;this.map_.forEach(function(g){return d.call(e,g,g,f)})};return c},"es6","es3");
$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(b.call(c,f,e,a))return{i:e,v:f}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.findIndex",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).i}},"es6","es3");
$jscomp.iteratorFromArray=function(a,b){if($jscomp.ASSUME_ES6)return a[Symbol.iterator]();a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var f=c++;return{value:b(f,a[f]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e};$jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b,c){return c})}},"es8","es3");
$jscomp.polyfill("Array.from",function(a){return a?a:function(b,c,d){c=c!=null?c:function(h){return h};var e=[],f=typeof Symbol!="undefined"&&Symbol.iterator&&b[Symbol.iterator];if(typeof f=="function"){b=f.call(b);for(var g=0;!(f=b.next()).done;)e.push(c.call(d,f.value,g++))}else for(f=b.length,g=0;g<f;g++)e.push(c.call(d,b[g],g));return e}},"es6","es3");
$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b){return b})}},"es6","es3");$jscomp.polyfill("Object.is",function(a){return a?a:function(b,c){return b===c?b!==0||1/b===1/c:b!==b&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(c<0&&(c=Math.max(c+e,0));c<e;c++){var f=d[c];if(f===b||Object.is(f,b))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,c){if(a==null)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(b,c){return $jscomp.checkStringArgs(this,b,"includes").indexOf(b,c||0)!==-1}},"es6","es3");
$jscomp.polyfill("String.fromCodePoint",function(a){return a?a:function(b){for(var c="",d=0;d<arguments.length;d++){var e=Number(arguments[d]);if(e<0||e>1114111||e!==Math.floor(e))throw new RangeError("invalid_code_point "+e);e<=65535?c+=String.fromCharCode(e):(e-=65536,c+=String.fromCharCode(e>>>10&1023|55296),c+=String.fromCharCode(e&1023|56320))}return c}},"es6","es3");
$jscomp.polyfill("WeakSet",function(a){function b(){if(!a||!Object.seal)return!1;try{var d=Object.seal({}),e=Object.seal({}),f=new a([d]);if(!f.has(d)||f.has(e))return!1;f.delete(d);f.add(e);return!f.has(d)&&f.has(e)}catch(g){return!1}}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=function(d){this.map_=new WeakMap;if(d){d=$jscomp.makeIterator(d);for(var e;!(e=d.next()).done;)this.add(e.value)}};c.prototype.add=function(d){this.map_.set(d,
!0);return this};c.prototype.has=function(d){return this.map_.has(d)};c.prototype.delete=function(d){return this.map_.delete(d)};return c},"es6","es3");$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).v}},"es6","es3");
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(b,c){var d=$jscomp.checkStringArgs(this,b,"startsWith");b+="";var e=d.length,f=b.length;c=Math.max(0,Math.min(c|0,d.length));for(var g=0;g<f&&c<e;)if(d[c++]!=b[g++])return!1;return g>=f}},"es6","es3");$jscomp.polyfill("Object.entries",function(a){return a?a:function(b){var c=[],d;for(d in b)$jscomp.owns(b,d)&&c.push([d,b[d]]);return c}},"es8","es3");
$jscomp.assign=$jscomp.TRUST_ES6_POLYFILLS&&typeof Object.assign=="function"?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");$jscomp.polyfill("Array.prototype.entries",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b,c){return[b,c]})}},"es6","es3");
$jscomp.polyfill("Promise.prototype.finally",function(a){return a?a:function(b){return this.then(function(c){return Promise.resolve(b()).then(function(){return c})},function(c){return Promise.resolve(b()).then(function(){throw c;})})}},"es9","es3");$jscomp.polyfill("Number.EPSILON",function(a){return 2.220446049250313E-16},"es6","es3");$jscomp.polyfill("Number.MAX_SAFE_INTEGER",function(){return 9007199254740991},"es6","es3");
$jscomp.polyfill("Math.trunc",function(a){return a?a:function(b){b=Number(b);if(isNaN(b)||b===Infinity||b===-Infinity||b===0)return b;var c=Math.floor(Math.abs(b));return b<0?-c:c}},"es6","es3");$jscomp.polyfill("Number.isNaN",function(a){return a?a:function(b){return typeof b==="number"&&isNaN(b)}},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(a){return a?a:function(b){var c=$jscomp.checkStringArgs(this,null,"repeat");if(b<0||b>1342177279)throw new RangeError("Invalid count value");b|=0;for(var d="";b;)if(b&1&&(d+=c),b>>>=1)c+=c;return d}},"es6","es3");$jscomp.polyfill("Number.isFinite",function(a){return a?a:function(b){return typeof b!=="number"?!1:!isNaN(b)&&b!==Infinity&&b!==-Infinity}},"es6","es3");
$jscomp.polyfill("String.prototype.endsWith",function(a){return a?a:function(b,c){var d=$jscomp.checkStringArgs(this,b,"endsWith");b+="";c===void 0&&(c=d.length);c=Math.max(0,Math.min(c|0,d.length));for(var e=b.length;e>0&&c>0;)if(d[--c]!=b[--e])return!1;return e<=0}},"es6","es3");var COMPILED=!0,goog=goog||{};goog.global=this||self;
goog.exportPath_=function(a,b,c,d){a=a.split(".");d=d||goog.global;a[0]in d||typeof d.execScript=="undefined"||d.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)if(a.length||b===void 0)d=d[e]&&d[e]!==Object.prototype[e]?d[e]:d[e]={};else if(!c&&goog.isObject(b)&&goog.isObject(d[e]))for(var f in b)b.hasOwnProperty(f)&&(d[e][f]=b[f]);else d[e]=b};
goog.define=function(a,b){if(!COMPILED){var c=goog.global.CLOSURE_UNCOMPILED_DEFINES,d=goog.global.CLOSURE_DEFINES;c&&c.nodeType===void 0&&Object.prototype.hasOwnProperty.call(c,a)?b=c[a]:d&&d.nodeType===void 0&&Object.prototype.hasOwnProperty.call(d,a)&&(b=d[a])}return b};goog.FEATURESET_YEAR=2012;goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;
goog.provide=function(a){if(goog.isInModuleLoader_())throw Error("goog.provide cannot be used within a module.");if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b,c){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var d=a;(d=d.substring(0,d.lastIndexOf(".")))&&!goog.getObjectByName(d);)goog.implicitNamespaces_[d]=!0}goog.exportPath_(a,b,c)};goog.NONCE_PATTERN_=/^[\w+/_-]+[=]{0,2}$/;
goog.getScriptNonce_=function(a){a=(a||goog.global).document;return(a=a.querySelector&&a.querySelector("script[nonce]"))&&(a=a.nonce||a.getAttribute("nonce"))&&goog.NONCE_PATTERN_.test(a)?a:""};goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
goog.module=function(a){if(typeof a!=="string"||!a||a.search(goog.VALID_MODULE_RE_)==-1)throw Error("Invalid module identifier");if(!goog.isInGoogModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");
goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};goog.module.get=function(a){return goog.module.getInternal_(a)};goog.module.getInternal_=function(a){if(!COMPILED){if(a in goog.loadedModules_)return goog.loadedModules_[a].exports;if(!goog.implicitNamespaces_[a])return a=goog.getObjectByName(a),a!=null?a:null}return null};goog.ModuleType={ES6:"es6",GOOG:"goog"};goog.moduleLoaderState_=null;
goog.isInModuleLoader_=function(){return goog.isInGoogModuleLoader_()||goog.isInEs6ModuleLoader_()};goog.isInGoogModuleLoader_=function(){return!!goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.GOOG};goog.isInEs6ModuleLoader_=function(){if(goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.ES6)return!0;var a=goog.global.$jscomp;return a?typeof a.getCurrentModulePath!="function"?!1:!!a.getCurrentModulePath():!1};
goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInGoogModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};
goog.declareModuleId=function(a){if(!COMPILED){if(!goog.isInEs6ModuleLoader_())throw Error("goog.declareModuleId may only be called from within an ES6 module");if(goog.moduleLoaderState_&&goog.moduleLoaderState_.moduleName)throw Error("goog.declareModuleId may only be called once per module.");if(a in goog.loadedModules_)throw Error('Module with namespace "'+a+'" already exists.');}if(goog.moduleLoaderState_)goog.moduleLoaderState_.moduleName=a;else{var b=goog.global.$jscomp;if(!b||typeof b.getCurrentModulePath!=
"function")throw Error('Module with namespace "'+a+'" has been loaded incorrectly.');b=b.require(b.getCurrentModulePath());goog.loadedModules_[a]={exports:b,type:goog.ModuleType.ES6,moduleId:a}}};goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};
COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.getObjectByName(a)!=null},goog.implicitNamespaces_={"goog.module":!0});goog.getObjectByName=function(a,b){a=a.split(".");b=b||goog.global;for(var c=0;c<a.length;c++)if(b=b[a[c]],b==null)return null;return b};goog.addDependency=function(a,b,c,d){!COMPILED&&goog.DEPENDENCIES_ENABLED&&goog.debugLoader_.addDependency(a,b,c,d)};goog.ENABLE_DEBUG_LOADER=!1;
goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.debugLoader_.requested(a);if(goog.isProvided_(a)){if(goog.isInModuleLoader_())return goog.module.getInternal_(a)}else if(goog.ENABLE_DEBUG_LOADER){var b=goog.moduleLoaderState_;goog.moduleLoaderState_=null;try{goog.debugLoader_.load_(a)}finally{goog.moduleLoaderState_=b}}return null}};goog.requireType=function(a){return{}};goog.basePath="";
goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.instance_=void 0;a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;goog.TRANSPILE="detect";
goog.ASSUME_ES_MODULES_TRANSPILED=!1;goog.TRUSTED_TYPES_POLICY_NAME="goog";goog.hasBadLetScoping=null;
goog.loadModule=function(a){var b=goog.moduleLoaderState_;try{goog.moduleLoaderState_={moduleName:"",declareLegacyNamespace:!1,type:goog.ModuleType.GOOG};var c={},d=c;if(typeof a==="function")d=a.call(void 0,d);else if(typeof a==="string")d=goog.loadModuleFromSource_.call(void 0,d,a);else throw Error("Invalid module definition");var e=goog.moduleLoaderState_.moduleName;if(typeof e==="string"&&e)goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(e,d,c!==d):goog.SEAL_MODULE_EXPORTS&&
Object.seal&&typeof d=="object"&&d!=null&&Object.seal(d),goog.loadedModules_[e]={exports:d,type:goog.ModuleType.GOOG,moduleId:goog.moduleLoaderState_.moduleName};else throw Error('Invalid module name "'+e+'"');}finally{goog.moduleLoaderState_=b}};goog.loadModuleFromSource_=function(a){eval(goog.CLOSURE_EVAL_PREFILTER_.createScript(arguments[1]));return a};
goog.normalizePath_=function(a){a=a.split("/");for(var b=0;b<a.length;)a[b]=="."?a.splice(b,1):b&&a[b]==".."&&a[b-1]&&a[b-1]!=".."?a.splice(--b,2):b++;return a.join("/")};goog.loadFileSync_=function(a){if(goog.global.CLOSURE_LOAD_FILE_SYNC)return goog.global.CLOSURE_LOAD_FILE_SYNC(a);try{var b=new goog.global.XMLHttpRequest;b.open("get",a,!1);b.send();return b.status==0||b.status==200?b.responseText:null}catch(c){return null}};
goog.typeOf=function(a){var b=typeof a;return b!="object"?b:a?Array.isArray(a)?"array":b:"null"};goog.isArrayLike=function(a){var b=goog.typeOf(a);return b=="array"||b=="object"&&typeof a.length=="number"};goog.isDateLike=function(a){return goog.isObject(a)&&typeof a.getFullYear=="function"};goog.isObject=function(a){var b=typeof a;return b=="object"&&a!=null||b=="function"};
goog.getUid=function(a){return Object.prototype.hasOwnProperty.call(a,goog.UID_PROPERTY_)&&a[goog.UID_PROPERTY_]||(a[goog.UID_PROPERTY_]=++goog.uidCounter_)};goog.hasUid=function(a){return!!a[goog.UID_PROPERTY_]};goog.removeUid=function(a){a!==null&&"removeAttribute"in a&&a.removeAttribute(goog.UID_PROPERTY_);try{delete a[goog.UID_PROPERTY_]}catch(b){}};goog.UID_PROPERTY_="closure_uid_"+(Math.random()*1E9>>>0);goog.uidCounter_=0;
goog.cloneObject=function(a){var b=goog.typeOf(a);if(b=="object"||b=="array"){if(typeof a.clone==="function")return a.clone();if(typeof Map!=="undefined"&&a instanceof Map)return new Map(a);if(typeof Set!=="undefined"&&a instanceof Set)return new Set(a);b=b=="array"?[]:{};for(var c in a)b[c]=goog.cloneObject(a[c]);return b}return a};goog.bindNative_=function(a,b,c){return a.call.apply(a.bind,arguments)};
goog.bindJs_=function(a,b,c){if(!a)throw Error();if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(e,d);return a.apply(b,e)}}return function(){return a.apply(b,arguments)}};goog.bind=function(a,b,c){Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_;return goog.bind.apply(null,arguments)};
goog.partial=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var d=c.slice();d.push.apply(d,arguments);return a.apply(this,d)}};goog.now=function(){return Date.now()};goog.globalEval=function(a){(0,eval)(a)};
goog.getCssName=function(a,b){if(String(a).charAt(0)==".")throw Error('className passed in goog.getCssName must not start with ".". You passed: '+a);var c=function(e){return goog.cssNameMapping_[e]||e},d=function(e){e=e.split("-");for(var f=[],g=0;g<e.length;g++)f.push(c(e[g]));return f.join("-")};d=goog.cssNameMapping_?goog.cssNameMappingStyle_=="BY_WHOLE"?c:d:function(e){return e};a=b?a+"-"+d(b):d(a);return goog.global.CLOSURE_CSS_NAME_MAP_FN?goog.global.CLOSURE_CSS_NAME_MAP_FN(a):a};
goog.setCssNameMapping=function(a,b){goog.cssNameMapping_=a;goog.cssNameMappingStyle_=b};!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.GetMsgOptions=function(){};
goog.getMsg=function(a,b,c){c&&c.html&&(a=a.replace(/</g,"&lt;"));c&&c.unescapeHtmlEntities&&(a=a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&amp;/g,"&"));b&&(a=a.replace(/\{\$([^}]+)}/g,function(d,e){return b!=null&&e in b?b[e]:d}));return a};goog.getMsgWithFallback=function(a,b){return a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,!0,c)};goog.exportProperty=function(a,b,c){a[b]=c};
goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.base=function(d,e,f){for(var g=Array(arguments.length-2),h=2;h<arguments.length;h++)g[h-2]=arguments[h];return b.prototype[e].apply(d,g)}};goog.scope=function(a){if(goog.isInModuleLoader_())throw Error("goog.scope is not supported within a module.");a.call(goog.global)};COMPILED||(goog.global.COMPILED=COMPILED);
goog.defineClass=function(a,b){var c=b.constructor,d=b.statics;c&&c!=Object.prototype.constructor||(c=function(){throw Error("cannot instantiate an interface (no constructor defined).");});c=goog.defineClass.createSealingConstructor_(c,a);a&&goog.inherits(c,a);delete b.constructor;delete b.statics;goog.defineClass.applyProperties_(c.prototype,b);d!=null&&(d instanceof Function?d(c):goog.defineClass.applyProperties_(c,d));return c};goog.defineClass.SEAL_CLASS_INSTANCES=goog.DEBUG;
goog.defineClass.createSealingConstructor_=function(a,b){return goog.defineClass.SEAL_CLASS_INSTANCES?function(){var c=a.apply(this,arguments)||this;c[goog.UID_PROPERTY_]=c[goog.UID_PROPERTY_];return c}:a};goog.defineClass.OBJECT_PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
goog.defineClass.applyProperties_=function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c]);for(var d=0;d<goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length;d++)c=goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[d],Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])};goog.identity_=function(a){return a};
goog.createTrustedTypesPolicy=function(a){var b=null,c=goog.global.trustedTypes;if(!c||!c.createPolicy)return b;try{b=c.createPolicy(a,{createHTML:goog.identity_,createScript:goog.identity_,createScriptURL:goog.identity_})}catch(d){goog.logToConsole_(d.message)}return b};
!COMPILED&&goog.DEPENDENCIES_ENABLED&&(goog.isEdge_=function(){return!!(goog.global.navigator&&goog.global.navigator.userAgent?goog.global.navigator.userAgent:"").match(/Edge\/(\d+)(\.\d)*/i)},goog.inHtmlDocument_=function(){var a=goog.global.document;return a!=null&&"write"in a},goog.isDocumentLoading_=function(){var a=goog.global.document;return a.attachEvent?a.readyState!="complete":a.readyState=="loading"},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH!=void 0&&typeof goog.global.CLOSURE_BASE_PATH===
"string")goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_()){var a=goog.global.document,b=a.currentScript;a=b?[b]:a.getElementsByTagName("SCRIPT");for(b=a.length-1;b>=0;--b){var c=a[b].src,d=c.lastIndexOf("?");d=d==-1?c.length:d;if(c.slice(d-7,d)=="base.js"){goog.basePath=c.slice(0,d-7);break}}}},goog.findBasePath_(),goog.protectScriptTag_=function(a){return a.replace(/<\/(SCRIPT)/ig,"\\x3c/$1")},goog.DebugLoader_=function(){this.dependencies_={};this.idToPath_={};this.written_=
{};this.loadingDeps_=[];this.depsToLoad_=[];this.paused_=!1;this.factory_=new goog.DependencyFactory;this.deferredCallbacks_={};this.deferredQueue_=[]},goog.DebugLoader_.prototype.bootstrap=function(a,b){function c(){d&&(goog.global.setTimeout(d,0),d=null)}var d=b;if(a.length){b=[];for(var e=0;e<a.length;e++){var f=this.getPathFromDeps_(a[e]);if(!f)throw Error("Unregonized namespace: "+a[e]);b.push(this.dependencies_[f])}f=goog.require;var g=0;for(e=0;e<a.length;e++)f(a[e]),b[e].onLoad(function(){++g==
a.length&&c()})}else c()},goog.DebugLoader_.prototype.loadClosureDeps=function(){this.depsToLoad_.push(this.factory_.createDependency(goog.normalizePath_(goog.basePath+"deps.js"),"deps.js",[],[],{}));this.loadDeps_()},goog.DebugLoader_.prototype.requested=function(a,b){(a=this.getPathFromDeps_(a))&&(b||this.areDepsLoaded_(this.dependencies_[a].requires))&&(b=this.deferredCallbacks_[a])&&(delete this.deferredCallbacks_[a],b())},goog.DebugLoader_.prototype.setDependencyFactory=function(a){this.factory_=
a},goog.DebugLoader_.prototype.load_=function(a){if(this.getPathFromDeps_(a)){var b=this,c=[],d=function(e){var f=b.getPathFromDeps_(e);if(!f)throw Error("Bad dependency path or symbol: "+e);if(!b.written_[f]){b.written_[f]=!0;e=b.dependencies_[f];for(f=0;f<e.requires.length;f++)goog.isProvided_(e.requires[f])||d(e.requires[f]);c.push(e)}};d(a);a=!!this.depsToLoad_.length;this.depsToLoad_=this.depsToLoad_.concat(c);this.paused_||a||this.loadDeps_()}else goog.logToConsole_("goog.require could not find: "+
a)},goog.DebugLoader_.prototype.loadDeps_=function(){for(var a=this,b=this.paused_;this.depsToLoad_.length&&!b;)(function(){var c=!1,d=a.depsToLoad_.shift(),e=!1;a.loading_(d);var f={pause:function(){if(c)throw Error("Cannot call pause after the call to load.");b=!0},resume:function(){c?a.resume_():b=!1},loaded:function(){if(e)throw Error("Double call to loaded.");e=!0;a.loaded_(d)},pending:function(){for(var g=[],h=0;h<a.loadingDeps_.length;h++)g.push(a.loadingDeps_[h]);return g},setModuleState:function(g){goog.moduleLoaderState_=
{type:g,moduleName:"",declareLegacyNamespace:!1}},registerEs6ModuleExports:function(g,h,k){k&&(goog.loadedModules_[k]={exports:h,type:goog.ModuleType.ES6,moduleId:k||""})},registerGoogModuleExports:function(g,h){goog.loadedModules_[g]={exports:h,type:goog.ModuleType.GOOG,moduleId:g}},clearModuleState:function(){goog.moduleLoaderState_=null},defer:function(g){if(c)throw Error("Cannot register with defer after the call to load.");a.defer_(d,g)},areDepsLoaded:function(){return a.areDepsLoaded_(d.requires)}};
try{d.load(f)}finally{c=!0}})();b&&this.pause_()},goog.DebugLoader_.prototype.pause_=function(){this.paused_=!0},goog.DebugLoader_.prototype.resume_=function(){this.paused_&&(this.paused_=!1,this.loadDeps_())},goog.DebugLoader_.prototype.loading_=function(a){this.loadingDeps_.push(a)},goog.DebugLoader_.prototype.loaded_=function(a){for(var b=0;b<this.loadingDeps_.length;b++)if(this.loadingDeps_[b]==a){this.loadingDeps_.splice(b,1);break}for(b=0;b<this.deferredQueue_.length;b++)if(this.deferredQueue_[b]==
a.path){this.deferredQueue_.splice(b,1);break}if(this.loadingDeps_.length==this.deferredQueue_.length&&!this.depsToLoad_.length)for(;this.deferredQueue_.length;)this.requested(this.deferredQueue_.shift(),!0);a.loaded()},goog.DebugLoader_.prototype.areDepsLoaded_=function(a){for(var b=0;b<a.length;b++){var c=this.getPathFromDeps_(a[b]);if(!c||!(c in this.deferredCallbacks_||goog.isProvided_(a[b])))return!1}return!0},goog.DebugLoader_.prototype.getPathFromDeps_=function(a){return a in this.idToPath_?
this.idToPath_[a]:a in this.dependencies_?a:null},goog.DebugLoader_.prototype.defer_=function(a,b){this.deferredCallbacks_[a.path]=b;this.deferredQueue_.push(a.path)},goog.LoadController=function(){},goog.LoadController.prototype.pause=function(){},goog.LoadController.prototype.resume=function(){},goog.LoadController.prototype.loaded=function(){},goog.LoadController.prototype.pending=function(){},goog.LoadController.prototype.registerEs6ModuleExports=function(a,b,c){},goog.LoadController.prototype.setModuleState=
function(a){},goog.LoadController.prototype.clearModuleState=function(){},goog.LoadController.prototype.defer=function(a){},goog.LoadController.prototype.areDepsLoaded=function(){},goog.Dependency=function(a,b,c,d,e){this.path=a;this.relativePath=b;this.provides=c;this.requires=d;this.loadFlags=e;this.loaded_=!1;this.loadCallbacks_=[]},goog.Dependency.prototype.getPathName=function(){var a=this.path,b=a.indexOf("://");b>=0&&(a=a.substring(b+3),b=a.indexOf("/"),b>=0&&(a=a.substring(b+1)));return a},
goog.Dependency.prototype.onLoad=function(a){this.loaded_?a():this.loadCallbacks_.push(a)},goog.Dependency.prototype.loaded=function(){this.loaded_=!0;var a=this.loadCallbacks_;this.loadCallbacks_=[];for(var b=0;b<a.length;b++)a[b]()},goog.Dependency.defer_=!1,goog.Dependency.callbackMap_={},goog.Dependency.registerCallback_=function(a){var b=Math.random().toString(32);goog.Dependency.callbackMap_[b]=a;return b},goog.Dependency.unregisterCallback_=function(a){delete goog.Dependency.callbackMap_[a]},
goog.Dependency.callback_=function(a,b){if(a in goog.Dependency.callbackMap_){for(var c=goog.Dependency.callbackMap_[a],d=[],e=1;e<arguments.length;e++)d.push(arguments[e]);c.apply(void 0,d)}else throw Error("Callback key "+a+" does not exist (was base.js loaded more than once?).");},goog.Dependency.prototype.load=function(a){if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?a.loaded():a.pause();else if(goog.inHtmlDocument_()){var b=goog.global.document;if(b.readyState==
"complete"&&!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING){if(/\bdeps.js$/.test(this.path)){a.loaded();return}throw Error('Cannot write "'+this.path+'" after document load');}var c=goog.getScriptNonce_();if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&goog.isDocumentLoading_()){var d=function(h){h.readyState&&h.readyState!="complete"?h.onload=d:(goog.Dependency.unregisterCallback_(e),a.loaded())};var e=goog.Dependency.registerCallback_(d);c=c?' nonce="'+c+'"':"";var f='<script src="'+this.path+'"'+
c+(goog.Dependency.defer_?" defer":"")+' id="script-'+e+'">\x3c/script>';f+="<script"+c+">";f=goog.Dependency.defer_?f+("document.getElementById('script-"+e+"').onload = function() {\n  goog.Dependency.callback_('"+e+"', this);\n};\n"):f+("goog.Dependency.callback_('"+e+"', document.getElementById('script-"+e+"'));");f+="\x3c/script>";b.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(f):f)}else{var g=b.createElement("script");g.defer=goog.Dependency.defer_;g.async=!1;c&&(g.nonce=
c);g.onload=function(){g.onload=null;a.loaded()};g.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path):this.path;b.head.appendChild(g)}}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),this.relativePath=="deps.js"?(goog.logToConsole_("Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true."),a.loaded()):a.pause()},goog.Es6ModuleDependency=function(a,b,c,d,e){goog.Dependency.call(this,a,
b,c,d,e)},goog.inherits(goog.Es6ModuleDependency,goog.Dependency),goog.Es6ModuleDependency.prototype.load=function(a){function b(l,m){var n="",p=goog.getScriptNonce_();p&&(n=' nonce="'+p+'"');l=m?'<script type="module" crossorigin'+n+">"+m+"\x3c/script>":'<script type="module" crossorigin src="'+l+'"'+n+">\x3c/script>";d.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(l):l)}function c(l,m){var n=d.createElement("script");n.defer=!0;n.async=!1;n.type="module";n.setAttribute("crossorigin",
!0);var p=goog.getScriptNonce_();p&&(n.nonce=p);m?n.text=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScript(m):m:n.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(l):l;d.head.appendChild(n)}if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?a.loaded():a.pause();else if(goog.inHtmlDocument_()){var d=goog.global.document,e=this;if(goog.isDocumentLoading_()){var f=b;goog.Dependency.defer_=!0}else f=c;var g=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(g);
a.setModuleState(goog.ModuleType.ES6)});f(void 0,'goog.Dependency.callback_("'+g+'")');f(this.path,void 0);var h=goog.Dependency.registerCallback_(function(l){goog.Dependency.unregisterCallback_(h);a.registerEs6ModuleExports(e.path,l,goog.moduleLoaderState_.moduleName)});f(void 0,'import * as m from "'+this.path+'"; goog.Dependency.callback_("'+h+'", m)');var k=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(k);a.clearModuleState();a.loaded()});f(void 0,'goog.Dependency.callback_("'+
k+'")')}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),a.pause()},goog.TransformedDependency=function(a,b,c,d,e){goog.Dependency.call(this,a,b,c,d,e);this.contents_=null;this.lazyFetch_=!goog.inHtmlDocument_()||!("noModule"in goog.global.document.createElement("script"))},goog.inherits(goog.TransformedDependency,goog.Dependency),goog.TransformedDependency.prototype.load=function(a){function b(){e.contents_=goog.loadFileSync_(e.path);e.contents_&&(e.contents_=
e.transform(e.contents_),e.contents_&&(e.contents_+="\n//# sourceURL="+e.path))}function c(){e.lazyFetch_&&b();if(e.contents_){f&&a.setModuleState(goog.ModuleType.ES6);try{var l=e.contents_;e.contents_=null;goog.globalEval(goog.CLOSURE_EVAL_PREFILTER_.createScript(l));if(f)var m=goog.moduleLoaderState_.moduleName}finally{f&&a.clearModuleState()}f&&goog.global.$jscomp.require.ensure([e.getPathName()],function(){a.registerEs6ModuleExports(e.path,goog.global.$jscomp.require(e.getPathName()),m)});a.loaded()}}
function d(){var l=goog.global.document,m=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(m);c()}),n=goog.getScriptNonce_();n="<script"+(n?' nonce="'+n+'"':"")+">"+goog.protectScriptTag_('goog.Dependency.callback_("'+m+'");')+"\x3c/script>";l.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(n):n)}var e=this;if(goog.global.CLOSURE_IMPORT_SCRIPT)b(),this.contents_&&goog.global.CLOSURE_IMPORT_SCRIPT("",this.contents_)?(this.contents_=null,a.loaded()):
a.pause();else{var f=this.loadFlags.module==goog.ModuleType.ES6;this.lazyFetch_||b();var g=a.pending().length>1;if(goog.Dependency.defer_&&(g||goog.isDocumentLoading_()))a.defer(function(){c()});else{var h=goog.global.document;g=goog.inHtmlDocument_()&&("ActiveXObject"in goog.global||goog.isEdge_());if(f&&goog.inHtmlDocument_()&&goog.isDocumentLoading_()&&!g){goog.Dependency.defer_=!0;a.pause();var k=h.onreadystatechange;h.onreadystatechange=function(){h.readyState=="interactive"&&(h.onreadystatechange=
k,c(),a.resume());typeof k==="function"&&k.apply(void 0,arguments)}}else goog.inHtmlDocument_()&&goog.isDocumentLoading_()?d():c()}}},goog.TransformedDependency.prototype.transform=function(a){},goog.PreTranspiledEs6ModuleDependency=function(a,b,c,d,e){goog.TransformedDependency.call(this,a,b,c,d,e)},goog.inherits(goog.PreTranspiledEs6ModuleDependency,goog.TransformedDependency),goog.PreTranspiledEs6ModuleDependency.prototype.transform=function(a){return a},goog.GoogModuleDependency=function(a,b,
c,d,e){goog.TransformedDependency.call(this,a,b,c,d,e)},goog.inherits(goog.GoogModuleDependency,goog.TransformedDependency),goog.GoogModuleDependency.prototype.transform=function(a){return goog.LOAD_MODULE_USING_EVAL&&goog.global.JSON!==void 0?"goog.loadModule("+goog.global.JSON.stringify(a+"\n//# sourceURL="+this.path+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+a+"\n;return exports});\n//# sourceURL="+this.path+"\n"},goog.DebugLoader_.prototype.addDependency=function(a,b,c,d){b=
b||[];a=a.replace(/\\/g,"/");var e=goog.normalizePath_(goog.basePath+a);d&&typeof d!=="boolean"||(d=d?{module:goog.ModuleType.GOOG}:{});c=this.factory_.createDependency(e,a,b,c,d);this.dependencies_[e]=c;for(c=0;c<b.length;c++)this.idToPath_[b[c]]=e;this.idToPath_[a]=e},goog.DependencyFactory=function(){},goog.DependencyFactory.prototype.createDependency=function(a,b,c,d,e){return e.module==goog.ModuleType.GOOG?new goog.GoogModuleDependency(a,b,c,d,e):e.module==goog.ModuleType.ES6?goog.ASSUME_ES_MODULES_TRANSPILED?
new goog.PreTranspiledEs6ModuleDependency(a,b,c,d,e):new goog.Es6ModuleDependency(a,b,c,d,e):new goog.Dependency(a,b,c,d,e)},goog.debugLoader_=new goog.DebugLoader_,goog.loadClosureDeps=function(){goog.debugLoader_.loadClosureDeps()},goog.setDependencyFactory=function(a){goog.debugLoader_.setDependencyFactory(a)},goog.TRUSTED_TYPES_POLICY_=goog.TRUSTED_TYPES_POLICY_NAME?goog.createTrustedTypesPolicy(goog.TRUSTED_TYPES_POLICY_NAME+"#base"):null,goog.global.CLOSURE_NO_DEPS||goog.debugLoader_.loadClosureDeps(),
goog.bootstrap=function(a,b){goog.debugLoader_.bootstrap(a,b)});if(!COMPILED){var isChrome87=!1;try{isChrome87=eval(goog.global.trustedTypes.emptyScript)!==goog.global.trustedTypes.emptyScript}catch(a){}goog.CLOSURE_EVAL_PREFILTER_=goog.global.trustedTypes&&isChrome87&&goog.createTrustedTypesPolicy("goog#base#devonly#eval")||{createScript:goog.identity_}};/*
 @license
 Shaka Player
 Copyright 2016 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
goog.asserts=function(){};goog.asserts.assert=function(a,b){};goog.asserts.ENABLE_ASSERTS=!0;goog.asserts.ENABLE_ASSERTS&&console.assert&&console.assert.bind&&(goog.asserts.assert=console.assert.bind(console));var shaka={abr:{}};shaka.abr.Ewma=function(a){goog.asserts.assert(a>0,"expected halfLife to be positive");this.alpha_=Math.exp(Math.log(.5)/a);this.totalWeight_=this.estimate_=0};shaka.abr.Ewma.prototype.updateAlpha=function(a){goog.asserts.assert(a>0,"expected halfLife to be positive");this.alpha_=Math.exp(Math.log(.5)/a)};shaka.abr.Ewma.prototype.sample=function(a,b){var c=Math.pow(this.alpha_,a);b=b*(1-c)+c*this.estimate_;isNaN(b)||(this.estimate_=b,this.totalWeight_+=a)};
shaka.abr.Ewma.prototype.getEstimate=function(){return this.estimate_/(1-Math.pow(this.alpha_,this.totalWeight_))};shaka.abr.EwmaBandwidthEstimator=function(){this.fast_=new shaka.abr.Ewma(2);this.slow_=new shaka.abr.Ewma(5);this.bytesSampled_=0;this.minTotalBytes_=128E3;this.minBytes_=16E3};shaka.abr.EwmaBandwidthEstimator.prototype.configure=function(a){this.minTotalBytes_=a.minTotalBytes;this.minBytes_=a.minBytes;this.fast_.updateAlpha(a.fastHalfLife);this.slow_.updateAlpha(a.slowHalfLife)};
shaka.abr.EwmaBandwidthEstimator.prototype.sample=function(a,b){if(!(b<this.minBytes_)){var c=8E3*b/a;a/=1E3;this.bytesSampled_+=b;this.fast_.sample(a,c);this.slow_.sample(a,c)}};shaka.abr.EwmaBandwidthEstimator.prototype.getBandwidthEstimate=function(a){return this.bytesSampled_<this.minTotalBytes_?a:Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())};shaka.abr.EwmaBandwidthEstimator.prototype.hasGoodEstimate=function(){return this.bytesSampled_>=this.minTotalBytes_};shaka.log=function(){};shaka.log.alwaysError=function(){};shaka.log.alwaysWarn=function(){};shaka.log.warnOnce=function(a){var b=$jscomp.getRestArguments.apply(1,arguments);shaka.log.oneTimeWarningIssued_.has(a)||(shaka.log.oneTimeWarningIssued_.add(a),shaka.log.alwaysWarn.apply(shaka.log,(0,$jscomp.arrayFromIterable)(b)))};shaka.log.error=function(){};shaka.log.warning=function(){};shaka.log.info=function(){};shaka.log.debug=function(){};shaka.log.v1=function(){};shaka.log.v2=function(){};
shaka.log.Level={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4,V1:5,V2:6};shaka.log.MAX_LOG_LEVEL=4;shaka.log.oneTimeWarningIssued_=new Set;
window.console&&(shaka.log.logMap_=(new Map).set(shaka.log.Level.ERROR,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.error.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.WARNING,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.warn.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.INFO,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.info.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.DEBUG,
function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.log.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.V1,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.debug.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.V2,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.debug.apply(console,(0,$jscomp.arrayFromIterable)(a))}),shaka.log.alwaysWarn=function(){var a=$jscomp.getRestArguments.apply(0,
arguments);return console.warn.apply(console,(0,$jscomp.arrayFromIterable)(a))},shaka.log.alwaysError=function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.error.apply(console,(0,$jscomp.arrayFromIterable)(a))},goog.DEBUG?(goog.exportSymbol("shaka.log",shaka.log),shaka.log.setLevel=function(a){var b=function(c){return c<=a?(goog.asserts.assert(shaka.log.logMap_.has(c),"Unexpected log level"),shaka.log.logMap_.get(c)):function(){}};shaka.log.currentLevel=a;shaka.log.error=b(shaka.log.Level.ERROR);
shaka.log.warning=b(shaka.log.Level.WARNING);shaka.log.info=b(shaka.log.Level.INFO);shaka.log.debug=b(shaka.log.Level.DEBUG);shaka.log.v1=b(shaka.log.Level.V1);shaka.log.v2=b(shaka.log.Level.V2)},shaka.log.setLevel(shaka.log.MAX_LOG_LEVEL)):(shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.ERROR&&(shaka.log.error=shaka.log.logMap_.get(shaka.log.Level.ERROR)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.WARNING&&(shaka.log.warning=shaka.log.logMap_.get(shaka.log.Level.WARNING)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.INFO&&
(shaka.log.info=shaka.log.logMap_.get(shaka.log.Level.INFO)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.DEBUG&&(shaka.log.debug=shaka.log.logMap_.get(shaka.log.Level.DEBUG)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V1&&(shaka.log.v1=shaka.log.logMap_.get(shaka.log.Level.V1)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V2&&(shaka.log.v2=shaka.log.logMap_.get(shaka.log.Level.V2))));shaka.util={};shaka.util.ArrayUtils=function(){};shaka.util.ArrayUtils.defaultEquals=function(a,b){return typeof a==="number"&&typeof b==="number"&&isNaN(a)&&isNaN(b)?!0:a===b};shaka.util.ArrayUtils.remove=function(a,b){b=a.indexOf(b);b>-1&&a.splice(b,1)};shaka.util.ArrayUtils.count=function(a,b){var c=0;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())c+=b(d.value)?1:0;return c};
shaka.util.ArrayUtils.hasSameElements=function(a,b,c){c||(c=shaka.util.ArrayUtils.defaultEquals);if(a.length!=b.length)return!1;b=b.slice();a=(0,$jscomp.makeIterator)(a);for(var d=a.next(),e={};!d.done;e={item$jscomp$28:void 0},d=a.next()){e.item$jscomp$28=d.value;d=b.findIndex(function(f){return function(g){return c(f.item$jscomp$28,g)}}(e));if(d==-1)return!1;b[d]=b[b.length-1];b.pop()}return b.length==0};
shaka.util.ArrayUtils.equal=function(a,b,c){if(a===b)return!0;if(!a||!b)return a==b;c||(c=shaka.util.ArrayUtils.defaultEquals);if(a.length!=b.length)return!1;for(var d=0;d<a.length;d++)if(!c(a[d],b[d]))return!1;return!0};shaka.util.IReleasable=function(){};shaka.util.IReleasable.prototype.release=function(){};shaka.util.MultiMap=function(){this.map_=new Map};shaka.util.MultiMap.prototype.push=function(a,b){this.map_.has(a)?this.map_.get(a).push(b):this.map_.set(a,[b])};shaka.util.MultiMap.prototype.get=function(a){return this.map_.has(a)?this.map_.get(a).slice():null};shaka.util.MultiMap.prototype.getAll=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.map_.values()),c=b.next();!c.done;c=b.next())a.push.apply(a,(0,$jscomp.arrayFromIterable)(c.value));return a};
shaka.util.MultiMap.prototype.remove=function(a,b){if(this.map_.has(a)){var c=this.map_.get(a).filter(function(d){return d!=b});this.map_.set(a,c);c.length||this.map_.delete(a)}};shaka.util.MultiMap.prototype.clear=function(){this.map_.clear()};shaka.util.MultiMap.prototype.forEach=function(a){this.map_.forEach(function(b,c){a(c,b)})};shaka.util.MultiMap.prototype.size=function(){return this.map_.size};shaka.util.MultiMap.prototype.keys=function(){return Array.from(this.map_.keys())};shaka.util.EventManager=function(){this.bindingMap_=new shaka.util.MultiMap};shaka.util.EventManager.prototype.release=function(){this.removeAll();this.bindingMap_=null};shaka.util.EventManager.prototype.listen=function(a,b,c,d){this.bindingMap_&&(a=new shaka.util.EventManager.Binding_(a,b,c,d),this.bindingMap_.push(b,a))};shaka.util.EventManager.prototype.listenOnce=function(a,b,c,d){var e=this,f=function(g){e.unlisten(a,b,f);c(g)};this.listen(a,b,f,d)};
shaka.util.EventManager.prototype.unlisten=function(a,b,c){if(this.bindingMap_){var d=this.bindingMap_.get(b)||[];d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,e.target!=a||c!=e.listener&&c||(e.unlisten(),this.bindingMap_.remove(b,e))}};shaka.util.EventManager.prototype.removeAll=function(){if(this.bindingMap_){var a=this.bindingMap_.getAll();a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())b.value.unlisten();this.bindingMap_.clear()}};
goog.exportSymbol("shaka.util.EventManager",shaka.util.EventManager);goog.exportProperty(shaka.util.EventManager.prototype,"removeAll",shaka.util.EventManager.prototype.removeAll);goog.exportProperty(shaka.util.EventManager.prototype,"unlisten",shaka.util.EventManager.prototype.unlisten);goog.exportProperty(shaka.util.EventManager.prototype,"listenOnce",shaka.util.EventManager.prototype.listenOnce);goog.exportProperty(shaka.util.EventManager.prototype,"listen",shaka.util.EventManager.prototype.listen);
goog.exportProperty(shaka.util.EventManager.prototype,"release",shaka.util.EventManager.prototype.release);shaka.util.EventManager.Binding_=function(a,b,c,d){this.target=a;this.type=b;this.listener=c;this.options=shaka.util.EventManager.Binding_.convertOptions_(a,d);this.target.addEventListener(b,c,this.options)};
shaka.util.EventManager.Binding_.prototype.unlisten=function(){goog.asserts.assert(this.target,"Missing target");this.target.removeEventListener(this.type,this.listener,this.options);this.listener=this.target=null;this.options=!1};
shaka.util.EventManager.Binding_.convertOptions_=function(a,b){if(b==void 0)return!1;if(typeof b=="boolean")return b;var c=new Set(["passive","capture"]),d=Object.keys(b).filter(function(e){return!c.has(e)});goog.asserts.assert(d.length==0,"Unsupported flag(s) to addEventListener: "+d.join(","));return shaka.util.EventManager.Binding_.doesSupportObject_(a)?b:b.capture||!1};
shaka.util.EventManager.Binding_.doesSupportObject_=function(a){var b=shaka.util.EventManager.Binding_.supportsObject_;if(b==void 0){b=!1;try{var c={},d={get:function(){b=!0;return!1}};Object.defineProperty(c,"passive",d);Object.defineProperty(c,"capture",d);d=function(){};a.addEventListener("test",d,c);a.removeEventListener("test",d,c)}catch(e){b=!1}shaka.util.EventManager.Binding_.supportsObject_=b}return b||!1};shaka.util.EventManager.Binding_.supportsObject_=void 0;shaka.config={};shaka.config.AutoShowText={NEVER:0,ALWAYS:1,IF_PREFERRED_TEXT_LANGUAGE:2,IF_SUBTITLES_MAY_BE_NEEDED:3};goog.exportSymbol("shaka.config.AutoShowText",shaka.config.AutoShowText);shaka.util.Lazy=function(a){this.gen_=a;this.value_=void 0};shaka.util.Lazy.prototype.value=function(){this.value_===void 0&&(this.value_=this.gen_(),goog.asserts.assert(this.value_!==void 0,"Unable to create lazy value"));return this.value_};shaka.util.Lazy.prototype.reset=function(){this.value_=void 0};/*
 @license
 Shaka Player
 Copyright 2025 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
shaka.device={};shaka.device.DeviceFactory=function(){};shaka.device.DeviceFactory.registerDeviceFactory=function(a){goog.asserts.assert(!shaka.device.DeviceFactory.factory_,"Device Factory should NOT be defined");shaka.device.DeviceFactory.factory_=a};shaka.device.DeviceFactory.registerDefaultDeviceFactory=function(a){goog.asserts.assert(!shaka.device.DeviceFactory.defaultFactory_,"Default device Factory should NOT be defined");shaka.device.DeviceFactory.defaultFactory_=a};
shaka.device.DeviceFactory.getDevice=function(){goog.asserts.assert(shaka.device.DeviceFactory.factory_||shaka.device.DeviceFactory.defaultFactory_,"Device Factory should be defined");return shaka.device.DeviceFactory.device_.value()};shaka.device.DeviceFactory.factory_=null;shaka.device.DeviceFactory.defaultFactory_=null;
shaka.device.DeviceFactory.device_=new shaka.util.Lazy(function(){var a=void 0;shaka.device.DeviceFactory.factory_&&(a=shaka.device.DeviceFactory.factory_());!a&&shaka.device.DeviceFactory.defaultFactory_&&(a=shaka.device.DeviceFactory.defaultFactory_());a&&shaka.log.info(a.toString());return a});shaka.device.IDevice=function(){};shaka.device.IDevice.prototype.supportsMediaSource=function(){};shaka.device.IDevice.prototype.supportsMediaType=function(a){};shaka.device.IDevice.prototype.supportsMediaCapabilities=function(){};shaka.device.IDevice.prototype.getVersion=function(){};shaka.device.IDevice.prototype.getDeviceName=function(){};shaka.device.IDevice.prototype.getDeviceType=function(){};shaka.device.IDevice.prototype.getBrowserEngine=function(){};
shaka.device.IDevice.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){};shaka.device.IDevice.prototype.requiresClearAndEncryptedInitSegments=function(){};shaka.device.IDevice.prototype.insertEncryptionDataBeforeClear=function(){};shaka.device.IDevice.prototype.requiresTfhdFix=function(a){};shaka.device.IDevice.prototype.requiresEC3InitSegments=function(){};shaka.device.IDevice.prototype.supportsSequenceMode=function(){};shaka.device.IDevice.prototype.supportsSmoothCodecSwitching=function(){};
shaka.device.IDevice.prototype.seekDelay=function(){};shaka.device.IDevice.prototype.detectMaxHardwareResolution=function(){};shaka.device.IDevice.prototype.supportsServerCertificate=function(){};shaka.device.IDevice.prototype.adjustConfig=function(a){};shaka.device.IDevice.prototype.shouldOverrideDolbyVisionCodecs=function(){};shaka.device.IDevice.prototype.shouldAvoidUseTextDecoderEncoder=function(){};shaka.device.IDevice.prototype.supportsOfflineStorage=function(){};
shaka.device.IDevice.prototype.rejectCodecs=function(){};shaka.device.IDevice.prototype.getHdrLevel=function(a){};shaka.device.IDevice.prototype.supportsAirPlay=function(){};shaka.device.IDevice.prototype.misreportAC3UsingDrm=function(){};shaka.device.IDevice.prototype.returnLittleEndianUsingPlayReady=function(){};shaka.device.IDevice.prototype.supportsEncryptionSchemePolyfill=function(){};shaka.device.IDevice.prototype.misreportsSupportForPersistentLicenses=function(){};
shaka.device.IDevice.prototype.supportStandardVP9Checking=function(){};shaka.device.IDevice.prototype.createMediaKeysWhenCheckingSupport=function(){};shaka.device.IDevice.prototype.disableHEVCSupport=function(){};shaka.device.IDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){};shaka.device.IDevice.prototype.supportsContainerChangeType=function(){};shaka.device.IDevice.prototype.needWaitForEncryptedEvent=function(a){};
shaka.device.IDevice.DeviceType={DESKTOP:"DESKTOP",MOBILE:"MOBILE",TV:"TV",VR:"VR",APPLE_VR:"APPLE_VR",CONSOLE:"CONSOLE",CAST:"CAST"};shaka.device.IDevice.BrowserEngine={CHROMIUM:"CHROMIUM",EDGE:"EDGE",GECKO:"GECKO",WEBKIT:"WEBKIT",UNKNOWN:"UNKNOWN"};shaka.deprecate={};shaka.deprecate.Version=function(a,b){this.major_=a;this.minor_=b};shaka.deprecate.Version.prototype.major=function(){return this.major_};shaka.deprecate.Version.prototype.minor=function(){return this.minor_};shaka.deprecate.Version.prototype.compareTo=function(a){var b=this.minor_-a.minor_;return this.major_-a.major_||b};shaka.deprecate.Version.prototype.toString=function(){return"v"+this.major_+"."+this.minor_};
shaka.deprecate.Version.parse=function(a){a=a.substring(1).split(".",2);return new shaka.deprecate.Version(Number(a[0]),Number(a[1]))};shaka.deprecate.Enforcer=function(a,b,c){this.libraryVersion_=a;this.onPending_=b;this.onExpired_=c};shaka.deprecate.Enforcer.prototype.enforce=function(a,b,c){(a.compareTo(this.libraryVersion_)>0?this.onPending_:this.onExpired_)(this.libraryVersion_,a,b,c)};shaka.Deprecate=function(){};shaka.Deprecate.init=function(a){goog.asserts.assert(shaka.Deprecate.enforcer_==null,"Deprecate.init should only be called once.");shaka.Deprecate.enforcer_=new shaka.deprecate.Enforcer(shaka.deprecate.Version.parse(a),shaka.Deprecate.onPending_,shaka.Deprecate.onExpired_)};
shaka.Deprecate.deprecateFeature=function(a,b,c){var d=shaka.Deprecate.enforcer_;goog.asserts.assert(d,"Missing deprecation enforcer. Was |init| called?");a=new shaka.deprecate.Version(a,0);d.enforce(a,b,c)};shaka.Deprecate.onPending_=function(a,b,c,d){shaka.log.alwaysWarn([c,"has been deprecated and will be removed in",b,". We are currently at version",a,". Additional information:",d].join(" "))};
shaka.Deprecate.onExpired_=function(a,b,c,d){a=[c,"has been deprecated and has been removed in",b,". We are now at version",a,". Additional information:",d].join(" ");shaka.log.alwaysError(a);goog.asserts.assert(!1,a)};shaka.Deprecate.enforcer_=null;/*
 @license
 Copyright 2008 The Closure Library Authors
 SPDX-License-Identifier: Apache-2.0
*/
goog.uri={};goog.uri.utils={};goog.uri.utils.splitRe_=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");goog.uri.utils.ComponentIndex={SCHEME:1,USER_INFO:2,DOMAIN:3,PORT:4,PATH:5,QUERY_DATA:6,FRAGMENT:7};goog.uri.utils.split=function(a){return a.match(goog.uri.utils.splitRe_)};/*
 @license
 Copyright 2006 The Closure Library Authors
 SPDX-License-Identifier: Apache-2.0
*/
goog.Uri=function(a){var b;a instanceof goog.Uri?(this.setScheme(a.getScheme()),this.setUserInfo(a.getUserInfo()),this.setDomain(a.getDomain()),this.setPort(a.getPort()),this.setPath(a.getPath()),this.setQueryData(a.getQueryData().clone()),this.setFragment(a.getFragment())):a&&(b=goog.uri.utils.split(String(a)))?(this.setScheme(b[goog.uri.utils.ComponentIndex.SCHEME]||"",!0),this.setUserInfo(b[goog.uri.utils.ComponentIndex.USER_INFO]||"",!0),this.setDomain(b[goog.uri.utils.ComponentIndex.DOMAIN]||
"",!0),this.setPort(b[goog.uri.utils.ComponentIndex.PORT]),this.setPath(b[goog.uri.utils.ComponentIndex.PATH]||"",!0),this.setQueryData(b[goog.uri.utils.ComponentIndex.QUERY_DATA]||"",!0),this.setFragment(b[goog.uri.utils.ComponentIndex.FRAGMENT]||"",!0)):this.queryData_=new goog.Uri.QueryData(null,null)};goog.Uri.prototype.scheme_="";goog.Uri.prototype.userInfo_="";goog.Uri.prototype.domain_="";goog.Uri.prototype.port_=null;goog.Uri.prototype.path_="";goog.Uri.prototype.fragment_="";
goog.Uri.prototype.toString=function(){var a=[],b=this.getScheme();b&&a.push(goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),":");if(b=this.getDomain()){a.push("//");var c=this.getUserInfo();c&&a.push(goog.Uri.encodeSpecialChars_(c,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),"@");a.push(goog.Uri.removeDoubleEncoding_(encodeURIComponent(b)));b=this.getPort();b!=null&&a.push(":",String(b))}if(b=this.getPath())this.hasDomain()&&b.charAt(0)!="/"&&a.push("/"),a.push(goog.Uri.encodeSpecialChars_(b,
b.charAt(0)=="/"?goog.Uri.reDisallowedInAbsolutePath_:goog.Uri.reDisallowedInRelativePath_,!0));(b=this.getEncodedQuery())&&a.push("?",b);(b=this.getFragment())&&a.push("#",goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInFragment_));return a.join("")};
goog.Uri.prototype.resolve=function(a){var b=this.clone();b.scheme_==="data"&&(b=new goog.Uri);var c=a.hasScheme();c?b.setScheme(a.getScheme()):c=a.hasUserInfo();c?b.setUserInfo(a.getUserInfo()):c=a.hasDomain();c?b.setDomain(a.getDomain()):c=a.hasPort();var d=a.getPath();if(c)b.setPort(a.getPort());else if(c=a.hasPath()){if(d.charAt(0)!="/")if(this.hasDomain()&&!this.hasPath())d="/"+d;else{var e=b.getPath().lastIndexOf("/");e!=-1&&(d=b.getPath().substr(0,e+1)+d)}d=goog.Uri.removeDotSegments(d)}c?
b.setPath(d):c=a.hasQuery();c?b.setQueryData(a.getQueryData().clone()):c=a.hasFragment();c&&b.setFragment(a.getFragment());return b};goog.Uri.prototype.clone=function(){return new goog.Uri(this)};goog.Uri.prototype.getScheme=function(){return this.scheme_};goog.Uri.prototype.setScheme=function(a,b){if(this.scheme_=b?goog.Uri.decodeOrEmpty_(a,!0):a)this.scheme_=this.scheme_.replace(/:$/,"");return this};goog.Uri.prototype.hasScheme=function(){return!!this.scheme_};goog.Uri.prototype.getUserInfo=function(){return this.userInfo_};
goog.Uri.prototype.setUserInfo=function(a,b){this.userInfo_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasUserInfo=function(){return!!this.userInfo_};goog.Uri.prototype.getDomain=function(){return this.domain_};goog.Uri.prototype.setDomain=function(a,b){this.domain_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasDomain=function(){return!!this.domain_};goog.Uri.prototype.getPort=function(){return this.port_};
goog.Uri.prototype.setPort=function(a){if(a){a=Number(a);if(isNaN(a)||a<0)throw Error("Bad port number "+a);this.port_=a}else this.port_=null;return this};goog.Uri.prototype.hasPort=function(){return this.port_!=null};goog.Uri.prototype.getPath=function(){return this.path_};goog.Uri.prototype.setPath=function(a,b){this.path_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasPath=function(){return!!this.path_};
goog.Uri.prototype.hasQuery=function(){return this.queryData_.toString()!==""};goog.Uri.prototype.setQueryData=function(a,b){a instanceof goog.Uri.QueryData?this.queryData_=a:(b||(a=goog.Uri.encodeSpecialChars_(a,goog.Uri.reDisallowedInQuery_)),this.queryData_=new goog.Uri.QueryData(a,null));return this};goog.Uri.prototype.getEncodedQuery=function(){return this.queryData_.toString()};goog.Uri.prototype.getDecodedQuery=function(){return this.queryData_.toDecodedString()};
goog.Uri.prototype.getQueryData=function(){return this.queryData_};goog.Uri.prototype.getFragment=function(){return this.fragment_};goog.Uri.prototype.setFragment=function(a,b){this.fragment_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasFragment=function(){return!!this.fragment_};
goog.Uri.removeDotSegments=function(a){if(a==".."||a==".")return"";if(a.indexOf("./")==-1&&a.indexOf("/.")==-1)return a;var b=a.lastIndexOf("/",0)==0;a=a.split("/");for(var c=[],d=0;d<a.length;){var e=a[d++];e=="."?b&&d==a.length&&c.push(""):e==".."?((c.length>1||c.length==1&&c[0]!="")&&c.pop(),b&&d==a.length&&c.push("")):(c.push(e),b=!0)}return c.join("/")};goog.Uri.decodeOrEmpty_=function(a,b){return a?b?decodeURI(a):decodeURIComponent(a):""};
goog.Uri.encodeSpecialChars_=function(a,b,c){return a!=null?(a=encodeURI(a).replace(b,goog.Uri.encodeChar_),c&&(a=goog.Uri.removeDoubleEncoding_(a)),a):null};goog.Uri.encodeChar_=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)};goog.Uri.removeDoubleEncoding_=function(a){return a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")};goog.Uri.reDisallowedInSchemeOrUserInfo_=/[#\/\?@]/g;goog.Uri.reDisallowedInRelativePath_=/[#\?:]/g;goog.Uri.reDisallowedInAbsolutePath_=/[#\?]/g;
goog.Uri.reDisallowedInQuery_=/[#\?@]/g;goog.Uri.reDisallowedInFragment_=/#/g;goog.Uri.QueryData=function(a,b){this.encodedQuery_=a||null};goog.Uri.QueryData.prototype.ensureKeyMapInitialized_=function(){if(!this.keyMap_&&(this.keyMap_=new Map,this.count_=0,this.encodedQuery_))for(var a=this.encodedQuery_.split("&"),b=0;b<a.length;b++){var c=a[b].indexOf("="),d=null;if(c>=0){var e=a[b].substring(0,c);d=a[b].substring(c+1)}else e=a[b];e=decodeURIComponent(e);d=d||"";this.add(e,decodeURIComponent(d))}};
goog.Uri.QueryData.prototype.keyMap_=null;goog.Uri.QueryData.prototype.count_=null;goog.Uri.QueryData.prototype.getCount=function(){this.ensureKeyMapInitialized_();return this.count_};goog.Uri.QueryData.prototype.add=function(a,b){this.ensureKeyMapInitialized_();this.encodedQuery_=null;var c=this.keyMap_.has(a)?this.keyMap_.get(a):null;c||this.keyMap_.set(a,c=[]);c.push(b);goog.asserts.assert(this.count_!=null,"Should not be null.");this.count_++;return this};
goog.Uri.QueryData.prototype.set=function(a,b){this.ensureKeyMapInitialized_();this.encodedQuery_=null;this.keyMap_.has(a)?this.keyMap_.set(a,[b]):this.add(a,b);return this};goog.Uri.QueryData.prototype.get=function(a){this.ensureKeyMapInitialized_();return this.keyMap_.get(a)||[]};
goog.Uri.QueryData.prototype.toString=function(){if(this.encodedQuery_)return this.encodedQuery_;if(!this.keyMap_||!this.keyMap_.size)return"";for(var a=[],b=(0,$jscomp.makeIterator)(this.keyMap_.keys()),c=b.next();!c.done;c=b.next()){var d=c.value;c=encodeURIComponent(d);d=this.keyMap_.get(d);for(var e=0;e<d.length;e++){var f=c;d[e]!==""&&(f+="="+encodeURIComponent(d[e]));a.push(f)}}return this.encodedQuery_=a.join("&")};goog.Uri.QueryData.prototype.toDecodedString=function(){return goog.Uri.decodeOrEmpty_(this.toString())};
goog.Uri.QueryData.prototype.clone=function(){var a=new goog.Uri.QueryData;a.encodedQuery_=this.encodedQuery_;if(this.keyMap_){for(var b=new Map,c=(0,$jscomp.makeIterator)(this.keyMap_),d=c.next();!d.done;d=c.next()){var e=(0,$jscomp.makeIterator)(d.value);d=e.next().value;e=e.next().value;b.set(d,e.concat())}a.keyMap_=b;a.count_=this.count_}return a};shaka.util.BufferUtils=function(){};shaka.util.BufferUtils.equal=function(a,b){var c=shaka.util.BufferUtils;if(!a&&!b)return!0;if(!a||!b||a.byteLength!=b.byteLength)return!1;if(c.unsafeGetArrayBuffer_(a)==c.unsafeGetArrayBuffer_(b)&&(a.byteOffset||0)==(b.byteOffset||0))return!0;c=shaka.util.BufferUtils.toUint8(a);b=shaka.util.BufferUtils.toUint8(b);for(var d=0;d<a.byteLength;d++)if(c[d]!=b[d])return!1;return!0};
shaka.util.BufferUtils.unsafeGetArrayBuffer_=function(a){return ArrayBuffer.isView(a)?a.buffer:a};shaka.util.BufferUtils.toArrayBuffer=function(a){return ArrayBuffer.isView(a)?a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:(new Uint8Array(a)).buffer:a};shaka.util.BufferUtils.toUint8=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,Uint8Array)};
shaka.util.BufferUtils.toUint16=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,Uint16Array)};shaka.util.BufferUtils.toDataView=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,DataView)};
shaka.util.BufferUtils.view_=function(a,b,c,d){var e=shaka.util.BufferUtils.unsafeGetArrayBuffer_(a),f=1;"BYTES_PER_ELEMENT"in d&&(f=d.BYTES_PER_ELEMENT);var g=((a.byteOffset||0)+a.byteLength)/f;a=Math.floor(Math.max(0,Math.min(((a.byteOffset||0)+b)/f,g)));return new d(e,a,Math.floor(Math.min(a+Math.max(c,0),g))-a)};goog.exportSymbol("shaka.util.BufferUtils",shaka.util.BufferUtils);goog.exportProperty(shaka.util.BufferUtils,"toDataView",shaka.util.BufferUtils.toDataView);
goog.exportProperty(shaka.util.BufferUtils,"toUint16",shaka.util.BufferUtils.toUint16);goog.exportProperty(shaka.util.BufferUtils,"toUint8",shaka.util.BufferUtils.toUint8);goog.exportProperty(shaka.util.BufferUtils,"toArrayBuffer",shaka.util.BufferUtils.toArrayBuffer);goog.exportProperty(shaka.util.BufferUtils,"equal",shaka.util.BufferUtils.equal);shaka.util.Error=function(a,b,c){var d=$jscomp.getRestArguments.apply(3,arguments);this.severity=a;this.category=b;this.code=c;this.data=d;this.handled=!1;d="Shaka Error "+this.code;if(goog.DEBUG){var e=d="UNKNOWN",f;for(f in shaka.util.Error.Category)shaka.util.Error.Category[f]==this.category&&(d=f);for(var g in shaka.util.Error.Code)shaka.util.Error.Code[g]==this.code&&(e=g);d="Shaka Error "+d+"."+e+" ("+this.data.toString()+")"}this.message=d;if(shaka.util.Error.createStack)try{throw Error(this.message||
"Shaka Error");}catch(h){this.stack=h.stack}};shaka.util.Error.prototype.toString=function(){return"shaka.util.Error "+JSON.stringify(this,null,"  ")};goog.exportSymbol("shaka.util.Error",shaka.util.Error);shaka.util.Error.createStack=!0;shaka.util.Error.Severity={RECOVERABLE:1,CRITICAL:2};goog.exportProperty(shaka.util.Error,"Severity",shaka.util.Error.Severity);shaka.util.Error.Category={NETWORK:1,TEXT:2,MEDIA:3,MANIFEST:4,STREAMING:5,DRM:6,PLAYER:7,CAST:8,STORAGE:9,ADS:10};
goog.exportProperty(shaka.util.Error,"Category",shaka.util.Error.Category);
shaka.util.Error.Code={UNSUPPORTED_SCHEME:1E3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,REQUEST_FILTER_ERROR:1006,RESPONSE_FILTER_ERROR:1007,MALFORMED_TEST_URI:1008,UNEXPECTED_TEST_REQUEST:1009,ATTEMPTS_EXHAUSTED:1010,SEGMENT_MISSING:1011,INVALID_TEXT_HEADER:2E3,INVALID_TEXT_CUE:2001,UNABLE_TO_DETECT_ENCODING:2003,BAD_ENCODING:2004,INVALID_XML:2005,INVALID_MP4_TTML:2007,INVALID_MP4_VTT:2008,UNABLE_TO_EXTRACT_CUE_START_TIME:2009,INVALID_MP4_CEA:2010,TEXT_COULD_NOT_GUESS_MIME_TYPE:2011,
CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS:2012,TEXT_ONLY_WEBVTT_SRC_EQUALS:2013,MISSING_TEXT_PLUGIN:2014,UNSUPPORTED_EXTERNAL_THUMBNAILS_URI:2017,BUFFER_READ_OUT_OF_BOUNDS:3E3,JS_INTEGER_OVERFLOW:3001,EBML_OVERFLOW:3002,EBML_BAD_FLOATING_POINT_SIZE:3003,MP4_SIDX_WRONG_BOX_TYPE:3004,MP4_SIDX_INVALID_TIMESCALE:3005,MP4_SIDX_TYPE_NOT_SUPPORTED:3006,WEBM_CUES_ELEMENT_MISSING:3007,WEBM_EBML_HEADER_ELEMENT_MISSING:3008,WEBM_SEGMENT_ELEMENT_MISSING:3009,WEBM_INFO_ELEMENT_MISSING:3010,WEBM_DURATION_ELEMENT_MISSING:3011,
WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING:3012,WEBM_CUE_TIME_ELEMENT_MISSING:3013,MEDIA_SOURCE_OPERATION_FAILED:3014,MEDIA_SOURCE_OPERATION_THREW:3015,VIDEO_ERROR:3016,QUOTA_EXCEEDED_ERROR:3017,TRANSMUXING_FAILED:3018,CONTENT_TRANSFORMATION_FAILED:3019,MSS_MISSING_DATA_FOR_TRANSMUXING:3020,MSS_TRANSMUXING_FAILED:3022,TRANSMUXING_NO_VIDEO_DATA:3023,STREAMING_NOT_ALLOWED:3024,UNABLE_TO_GUESS_MANIFEST_TYPE:4E3,DASH_INVALID_XML:4001,DASH_NO_SEGMENT_INFO:4002,DASH_EMPTY_ADAPTATION_SET:4003,DASH_EMPTY_PERIOD:4004,
DASH_WEBM_MISSING_INIT:4005,DASH_UNSUPPORTED_CONTAINER:4006,DASH_PSSH_BAD_ENCODING:4007,DASH_NO_COMMON_KEY_SYSTEM:4008,DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED:4009,DASH_CONFLICTING_KEY_IDS:4010,RESTRICTIONS_CANNOT_BE_MET:4012,HLS_PLAYLIST_HEADER_MISSING:4015,INVALID_HLS_TAG:4016,HLS_INVALID_PLAYLIST_HIERARCHY:4017,DASH_DUPLICATE_REPRESENTATION_ID:4018,HLS_MULTIPLE_MEDIA_INIT_SECTIONS_FOUND:4020,HLS_REQUIRED_ATTRIBUTE_MISSING:4023,HLS_REQUIRED_TAG_MISSING:4024,HLS_COULD_NOT_GUESS_CODECS:4025,HLS_KEYFORMATS_NOT_SUPPORTED:4026,
DASH_UNSUPPORTED_XLINK_ACTUATE:4027,DASH_XLINK_DEPTH_LIMIT:4028,CONTENT_UNSUPPORTED_BY_BROWSER:4032,CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM:4033,NO_VARIANTS:4036,PERIOD_FLATTENING_FAILED:4037,INCONSISTENT_DRM_ACROSS_PERIODS:4038,HLS_VARIABLE_NOT_FOUND:4039,HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED:4040,HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED:4041,NO_WEB_CRYPTO_API:4042,CANNOT_ADD_EXTERNAL_THUMBNAILS_TO_LIVE_STREAM:4045,MSS_INVALID_XML:4046,MSS_LIVE_CONTENT_NOT_SUPPORTED:4047,AES_128_INVALID_IV_LENGTH:4048,
AES_128_INVALID_KEY_LENGTH:4049,DASH_CONFLICTING_AES_128:4050,DASH_UNSUPPORTED_AES_128:4051,DASH_INVALID_PATCH:4052,HLS_EMPTY_MEDIA_PLAYLIST:4053,DASH_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED:4054,CANNOT_ADD_EXTERNAL_CHAPTERS_TO_LIVE_STREAM:4055,STREAMING_ENGINE_STARTUP_INVALID_STATE:5006,NO_RECOGNIZED_KEY_SYSTEMS:6E3,REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE:6001,FAILED_TO_CREATE_CDM:6002,FAILED_TO_ATTACH_TO_VIDEO:6003,INVALID_SERVER_CERTIFICATE:6004,FAILED_TO_CREATE_SESSION:6005,FAILED_TO_GENERATE_LICENSE_REQUEST:6006,
LICENSE_REQUEST_FAILED:6007,LICENSE_RESPONSE_REJECTED:6008,ENCRYPTED_CONTENT_WITHOUT_DRM_INFO:6010,NO_LICENSE_SERVER_GIVEN:6012,OFFLINE_SESSION_REMOVED:6013,EXPIRED:6014,SERVER_CERTIFICATE_REQUIRED:6015,INIT_DATA_TRANSFORM_ERROR:6016,SERVER_CERTIFICATE_REQUEST_FAILED:6017,MIN_HDCP_VERSION_NOT_MATCH:6018,ERROR_CHECKING_HDCP_VERSION:6019,MISSING_EME_SUPPORT:6020,LOAD_INTERRUPTED:7E3,OPERATION_ABORTED:7001,NO_VIDEO_ELEMENT:7002,OBJECT_DESTROYED:7003,CONTENT_NOT_LOADED:7004,SRC_EQUALS_PRELOAD_NOT_SUPPORTED:7005,
PRELOAD_DESTROYED:7006,QUEUE_INDEX_OUT_OF_BOUNDS:7007,CAST_API_UNAVAILABLE:8E3,NO_CAST_RECEIVERS:8001,ALREADY_CASTING:8002,UNEXPECTED_CAST_ERROR:8003,CAST_CANCELED_BY_USER:8004,CAST_CONNECTION_TIMED_OUT:8005,CAST_RECEIVER_APP_UNAVAILABLE:8006,STORAGE_NOT_SUPPORTED:9E3,INDEXED_DB_ERROR:9001,DEPRECATED_OPERATION_ABORTED:9002,REQUESTED_ITEM_NOT_FOUND:9003,MALFORMED_OFFLINE_URI:9004,CANNOT_STORE_LIVE_OFFLINE:9005,NO_INIT_DATA_FOR_OFFLINE:9007,LOCAL_PLAYER_INSTANCE_REQUIRED:9008,NEW_KEY_OPERATION_NOT_SUPPORTED:9011,
KEY_NOT_FOUND:9012,MISSING_STORAGE_CELL:9013,STORAGE_LIMIT_REACHED:9014,DOWNLOAD_SIZE_CALLBACK_ERROR:9015,MODIFY_OPERATION_NOT_SUPPORTED:9016,INDEXED_DB_INIT_TIMED_OUT:9017,CS_IMA_SDK_MISSING:1E4,CS_AD_MANAGER_NOT_INITIALIZED:10001,SS_IMA_SDK_MISSING:10002,SS_AD_MANAGER_NOT_INITIALIZED:10003,CURRENT_DAI_REQUEST_NOT_FINISHED:10004,MT_AD_MANAGER_NOT_INITIALIZED:10005,INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED:10006,VAST_INVALID_XML:10007};goog.exportProperty(shaka.util.Error,"Code",shaka.util.Error.Code);shaka.util.StringUtils=function(){};
shaka.util.StringUtils.fromUTF8=function(a){if(!a)return"";a=shaka.util.BufferUtils.toUint8(a);a[0]==239&&a[1]==187&&a[2]==191&&(a=a.subarray(3));if(window.TextDecoder&&!shaka.device.DeviceFactory.getDevice().shouldAvoidUseTextDecoderEncoder())return a=(new TextDecoder).decode(a),a.includes("\ufffd")&&shaka.log.alwaysError('Decoded string contains an "unknown character" codepoint.  That probably means the UTF8 encoding was incorrect!'),a;for(var b="",c=0;c<a.length;++c){var d=65533;(a[c]&128)==0?
d=a[c]:a.length>=c+2&&(a[c]&224)==192&&(a[c+1]&192)==128?(d=(a[c]&31)<<6|a[c+1]&63,c+=1):a.length>=c+3&&(a[c]&240)==224&&(a[c+1]&192)==128&&(a[c+2]&192)==128?(d=(a[c]&15)<<12|(a[c+1]&63)<<6|a[c+2]&63,c+=2):a.length>=c+4&&(a[c]&241)==240&&(a[c+1]&192)==128&&(a[c+2]&192)==128&&(a[c+3]&192)==128&&(d=(a[c]&7)<<18|(a[c+1]&63)<<12|(a[c+2]&63)<<6|a[c+3]&63,c+=3);if(d<=65535)b+=String.fromCharCode(d);else{d-=65536;var e=d&1023;b+=String.fromCharCode(55296+(d>>10));b+=String.fromCharCode(56320+e)}}return b};
shaka.util.StringUtils.fromUTF16=function(a,b,c){if(!a)return"";if(!c&&a.byteLength%2!=0)throw shaka.log.error("Data has an incorrect length, must be even."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BAD_ENCODING);c=Math.floor(a.byteLength/2);var d=new Uint16Array(c);a=shaka.util.BufferUtils.toDataView(a);for(var e=0;e<c;e++)d[e]=a.getUint16(e*2,b);return shaka.util.StringUtils.fromCharCode(d)};
shaka.util.StringUtils.fromBytesAutoDetect=function(a){var b=shaka.util.StringUtils;if(!a)return"";var c=shaka.util.BufferUtils.toUint8(a);if(c[0]==239&&c[1]==187&&c[2]==191)return b.fromUTF8(c);if(c[0]==254&&c[1]==255)return b.fromUTF16(c.subarray(2),!1);if(c[0]==255&&c[1]==254)return b.fromUTF16(c.subarray(2),!0);var d=function(e){return c.byteLength<=e||c[e]>=9&&c[e]<=126};shaka.log.debug("Unable to find byte-order-mark, making an educated guess.");if(c[0]==0&&c[2]==0)return b.fromUTF16(a,!1);
if(c[1]==0&&c[3]==0)return b.fromUTF16(a,!0);if(d(0)&&d(1)&&d(2)&&d(3))return b.fromUTF8(a);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.UNABLE_TO_DETECT_ENCODING);};
shaka.util.StringUtils.toUTF8=function(a){if(window.TextEncoder&&!shaka.device.DeviceFactory.getDevice().shouldAvoidUseTextDecoderEncoder()){var b=new TextEncoder;return shaka.util.BufferUtils.toArrayBuffer(b.encode(a))}a=encodeURIComponent(a);a=unescape(a);b=new Uint8Array(a.length);for(var c=0;c<a.length;c++)b[c]=a[c].charCodeAt(0);return shaka.util.BufferUtils.toArrayBuffer(b)};
shaka.util.StringUtils.toUTF16=function(a,b){for(var c=new ArrayBuffer(a.length*2),d=new DataView(c),e=0;e<a.length;++e){var f=a.charCodeAt(e);d.setUint16(e*2,f,b)}return c};shaka.util.StringUtils.fromCharCode=function(a){return shaka.util.StringUtils.fromCharCodeImpl_.value()(a)};shaka.util.StringUtils.resetFromCharCode=function(){shaka.util.StringUtils.fromCharCodeImpl_.reset()};
shaka.util.StringUtils.htmlUnescape=function(a){var b={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&nbsp;":"\u00a0","&lrm;":"\u200e","&rlm;":"\u200f"},c=/&(?:amp|lt|gt|quot|apos|nbsp|lrm|rlm|#[xX]?[0-9a-fA-F]+);/g,d=RegExp(c.source);return a&&d.test(a)?a.replace(c,function(e){return e[1]=="#"?(e=e[2]=="x"||e[2]=="X"?parseInt(e.substring(3),16):parseInt(e.substring(2),10),e>=0&&e<=1114111?String.fromCodePoint(e):""):b[e]||"'"}):a||""};goog.exportSymbol("shaka.util.StringUtils",shaka.util.StringUtils);
goog.exportProperty(shaka.util.StringUtils,"resetFromCharCode",shaka.util.StringUtils.resetFromCharCode);goog.exportProperty(shaka.util.StringUtils,"toUTF16",shaka.util.StringUtils.toUTF16);goog.exportProperty(shaka.util.StringUtils,"toUTF8",shaka.util.StringUtils.toUTF8);goog.exportProperty(shaka.util.StringUtils,"fromBytesAutoDetect",shaka.util.StringUtils.fromBytesAutoDetect);goog.exportProperty(shaka.util.StringUtils,"fromUTF16",shaka.util.StringUtils.fromUTF16);
goog.exportProperty(shaka.util.StringUtils,"fromUTF8",shaka.util.StringUtils.fromUTF8);
shaka.util.StringUtils.fromCharCodeImpl_=new shaka.util.Lazy(function(){for(var a=function(c){try{var d=new Uint8Array(c),e=String.fromCharCode.apply(null,d);goog.asserts.assert(e,"Should get value");return e.length>0}catch(f){return!1}},b={size$jscomp$22:65536};b.size$jscomp$22>0;b={size$jscomp$22:b.size$jscomp$22},b.size$jscomp$22/=2)if(a(b.size$jscomp$22))return function(c){return function(d){for(var e="",f=0;f<d.length;f+=c.size$jscomp$22){var g=d.subarray(f,f+c.size$jscomp$22);e+=String.fromCharCode.apply(null,
g)}return e}}(b);goog.asserts.assert(!1,"Unable to create a fromCharCode method");return null});shaka.util.Uint8ArrayUtils=function(){};shaka.util.Uint8ArrayUtils.toStandardBase64=function(a){a=shaka.util.StringUtils.fromCharCode(shaka.util.BufferUtils.toUint8(a));return btoa(a)};shaka.util.Uint8ArrayUtils.toBase64=function(a,b){b=b==void 0?!0:b;a=shaka.util.Uint8ArrayUtils.toStandardBase64(a).replace(/\+/g,"-").replace(/\//g,"_");return b?a:a.replace(/[=]*$/,"")};
shaka.util.Uint8ArrayUtils.fromBase64=function(a){a=window.atob(a.replace(/-/g,"+").replace(/_/g,"/"));for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b};shaka.util.Uint8ArrayUtils.fromHex=function(a){for(var b=a.length/2,c=new Uint8Array(b),d=0;d<b;d++)c[d]=window.parseInt(a.substr(d*2,2),16);return c};
shaka.util.Uint8ArrayUtils.toHex=function(a){var b=shaka.util.BufferUtils.toUint8(a);a="";b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,c=c.toString(16),c.length==1&&(c="0"+c),a+=c;return a};
shaka.util.Uint8ArrayUtils.concat=function(){for(var a=$jscomp.getRestArguments.apply(0,arguments),b=shaka.util.BufferUtils,c=0,d=0;d<a.length;++d)c+=a[d].byteLength;c=new Uint8Array(c);for(var e=d=0;e<a.length;++e){var f=a[e];ArrayBuffer.isView(f)&&f.BYTES_PER_ELEMENT===1?c.set(f,d):c.set(b.toUint8(f),d);d+=f.byteLength}return c};goog.exportSymbol("shaka.util.Uint8ArrayUtils",shaka.util.Uint8ArrayUtils);goog.exportProperty(shaka.util.Uint8ArrayUtils,"concat",shaka.util.Uint8ArrayUtils.concat);
goog.exportProperty(shaka.util.Uint8ArrayUtils,"toHex",shaka.util.Uint8ArrayUtils.toHex);goog.exportProperty(shaka.util.Uint8ArrayUtils,"fromHex",shaka.util.Uint8ArrayUtils.fromHex);goog.exportProperty(shaka.util.Uint8ArrayUtils,"fromBase64",shaka.util.Uint8ArrayUtils.fromBase64);goog.exportProperty(shaka.util.Uint8ArrayUtils,"toBase64",shaka.util.Uint8ArrayUtils.toBase64);goog.exportProperty(shaka.util.Uint8ArrayUtils,"toStandardBase64",shaka.util.Uint8ArrayUtils.toStandardBase64);shaka.util.ManifestParserUtils=function(){};
shaka.util.ManifestParserUtils.resolveUris=function(a,b,c){c=c===void 0?"":c;if(b.length==0)return a;if(a.length==1&&b.length==1){var d=new goog.Uri(a[0]);b=new goog.Uri(b[0]);b=d.resolve(b);c&&b.setQueryData(c);return[b.toString()]}b=b.map(function(h){return new goog.Uri(h)});d=[];a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){e=new goog.Uri(e.value);for(var f=(0,$jscomp.makeIterator)(b),g=f.next();!g.done;g=f.next())g=e.resolve(g.value),c&&g.setQueryData(c),d.push(g.toString())}return d};
shaka.util.ManifestParserUtils.createDrmInfo=function(a,b,c,d){a={keySystem:a,encryptionScheme:b,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",sessionType:"",initData:c||[],keyIds:new Set};d&&(a.keySystemUris=new Set([d]));return a};
shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys=function(a,b){b=b===void 0?"cenc":b;var c=shaka.util.StringUtils,d=shaka.util.Uint8ArrayUtils,e=[],f=[],g=[];a.forEach(function(k,l){var m=l;m.length!=22&&(m=d.toBase64(d.fromHex(l),!1));var n=k;n.length!=22&&(n=d.toBase64(d.fromHex(k),!1));k={kty:"oct",kid:m,k:n};e.push(k);f.push(k.kid);g.push(l)});a=JSON.stringify({keys:e});var h=JSON.stringify({kids:f});c=[{initData:shaka.util.BufferUtils.toUint8(c.toUTF8(h)),initDataType:"keyids"}];return{keySystem:"org.w3.clearkey",
encryptionScheme:b,licenseServerUri:"data:application/json;base64,"+window.btoa(a),distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",sessionType:"",initData:c,keyIds:new Set(g)}};
shaka.util.ManifestParserUtils.guessCodecs=function(a,b){if(b.length==1)return b[0];a=shaka.util.ManifestParserUtils.guessCodecsSafe(a,b);if(a!=null)return a;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_COULD_NOT_GUESS_CODECS,b);};
shaka.util.ManifestParserUtils.guessCodecsSafe=function(a,b){var c=shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_.get(a);c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())if(f=f.value,d.test(f.trim()))return f.trim()}return a==shaka.util.ManifestParserUtils.ContentType.TEXT?"":null};
shaka.util.ManifestParserUtils.guessAllCodecsSafe=function(a,b){var c=[];a=shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_.get(a);a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())f=f.value,d.test(f.trim())&&c.push(f.trim())}return c};shaka.util.ManifestParserUtils.ContentType={VIDEO:"video",AUDIO:"audio",TEXT:"text",IMAGE:"image",APPLICATION:"application"};
shaka.util.ManifestParserUtils.TextStreamKind={SUBTITLE:"subtitle",CLOSED_CAPTION:"caption"};shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS=1/15;shaka.util.ManifestParserUtils.VIDEO_CODEC_REGEXPS_=[/^avc/,/^hev/,/^hvc/,/^vvc/,/^vvi/,/^vp0?[89]/,/^av01/,/^dvh/,/^dva/,/^dav/];shaka.util.ManifestParserUtils.AUDIO_CODEC_REGEXPS_=[/^vorbis$/,/^Opus$/,/^opus$/,/^fLaC$/,/^flac$/,/^mp4a/,/^[ae]c-3$/,/^ac-4/,/^dts[cex]$/,/^iamf/,/^mhm[12]/,/^ac3$/,/^eac3$/,/^apac$/];
shaka.util.ManifestParserUtils.TEXT_CODEC_REGEXPS_=[/^vtt$/,/^wvtt/,/^stpp/];shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_=(new Map).set("audio",shaka.util.ManifestParserUtils.AUDIO_CODEC_REGEXPS_).set("video",shaka.util.ManifestParserUtils.VIDEO_CODEC_REGEXPS_).set("text",shaka.util.ManifestParserUtils.TEXT_CODEC_REGEXPS_);shaka.lcevc={};shaka.lcevc.Dec=function(a,b,c,d){this.dec_=null;this.media_=a;this.canvas_=b;this.decConfig_=c;this.isDualTrack_=d;this.toBeDeprecated_=!1;this.create_()};shaka.lcevc.Dec.prototype.appendBuffer=function(a,b,c){c.type!==shaka.util.ManifestParserUtils.ContentType.VIDEO||this.isDualTrack_&&!c.baseOriginalId||this.dec_&&this.dec_.appendBuffer(a,"video",c.id,-b,!this.isDualTrack_)};shaka.lcevc.Dec.prototype.hideCanvas=function(){this.dec_&&this.canvas_.classList.add("shaka-hidden")};
shaka.lcevc.Dec.prototype.create_=function(){this.isSupported_()&&!this.dec_&&this.lcevcLib_.SupportObject.webGLSupport(this.canvas_)&&(this.canvas_.classList.remove("shaka-hidden"),this.dec_=this.toBeDeprecated_?new this.lcevcLib_.LcevcDil(this.media_,this.canvas_,this.decConfig_):new this.lcevcLib_.LCEVCdec(this.media_,this.canvas_,this.decConfig_))};shaka.lcevc.Dec.prototype.release=function(){this.dec_&&(this.dec_.close(),this.dec_=null)};
shaka.lcevc.Dec.prototype.isSupported_=function(){typeof libDPIModule==="undefined"&&shaka.log.alwaysWarn("Could not find LCEVC Library dependencies on this page");if(typeof LCEVCdec!=="undefined")this.lcevcLib_=LCEVCdec;else if(typeof LcevcDil!=="undefined")this.lcevcLib_=LcevcDil,this.toBeDeprecated_=!0,shaka.Deprecate.deprecateFeature(5,"LcevcDil","lcevc_dil.js is deprecated, please use lcevc_dec.js instead");else return shaka.log.alwaysWarn("Could not find LCEVC Library on this page"),!1;if(typeof this.lcevcLib_.SupportObject===
"undefined")return shaka.log.alwaysWarn("Could not find LCEVC Library on this page"),!1;this.lcevcLib_.SupportObject.SupportStatus||shaka.log.alwaysWarn(this.lcevcLib_.SupportObject.SupportError);return typeof this.lcevcLib_!=="undefined"&&typeof libDPIModule!=="undefined"&&this.canvas_ instanceof HTMLCanvasElement&&this.lcevcLib_.SupportObject.SupportStatus};
shaka.lcevc.Dec.prototype.updateVariant=function(a,b){if(a=a.video){a.dependencyStream&&(a=a.dependencyStream);var c=shaka.lcevc.Dec.ContainerFormat.MPEG2_TS,d=shaka.lcevc.Dec.StreamingFormat.OTHER;switch(a.mimeType){case "video/webm":c=shaka.lcevc.Dec.ContainerFormat.WEBM;break;case "video/mp4":c=shaka.lcevc.Dec.ContainerFormat.MP4}switch(b){case "DASH":d=shaka.lcevc.Dec.StreamingFormat.DASH;break;case "HLS":d=shaka.lcevc.Dec.StreamingFormat.HLS}this.dec_&&(this.dec_.setLevelSwitching(a.id,!0),this.dec_.setContainerFormat(c),
this.toBeDeprecated_||this.dec_.setStreamingFormat(d))}};shaka.lcevc.Dec.isStreamSupported=function(a){return a&&typeof LCEVCdec!=="undefined"?a.codecs=="lvc1":!1};goog.exportSymbol("shaka.lcevc.Dec",shaka.lcevc.Dec);goog.exportProperty(shaka.lcevc.Dec.prototype,"release",shaka.lcevc.Dec.prototype.release);shaka.lcevc.Dec.ContainerFormat={MPEG2_TS:0,WEBM:1,MP4:2};shaka.lcevc.Dec.StreamingFormat={HLS:0,DASH:1,OTHER:-1};shaka.media={};shaka.media.Capabilities=function(){};shaka.media.Capabilities.isTypeSupported=function(a){var b=shaka.media.Capabilities.MediaSourceTypeSupportMap;if(b.has(a))return b.get(a);var c=window.ManagedMediaSource||window.MediaSource;return c?(c=c.isTypeSupported(a),b.set(a,c),c):!1};shaka.media.Capabilities.isChangeTypeSupported=function(){var a=window.ManagedSourceBuffer||window.SourceBuffer;return!!a&&!!a.prototype&&!!a.prototype.changeType};
shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported=function(){var a=window.ManagedMediaSource||window.MediaSource;return a&&a.prototype?!!a.prototype.setLiveSeekableRange&&!!a.prototype.clearLiveSeekableRange:!1};shaka.media.Capabilities.MediaSourceTypeSupportMap=new Map;shaka.cea={};shaka.cea.DummyCaptionDecoder=function(){};shaka.cea.DummyCaptionDecoder.prototype.extract=function(a,b){};shaka.cea.DummyCaptionDecoder.prototype.decode=function(){return[]};shaka.cea.DummyCaptionDecoder.prototype.clear=function(){};shaka.cea.DummyCaptionDecoder.prototype.getStreams=function(){return[]};shaka.cea.DummyCeaParser=function(){};shaka.cea.DummyCeaParser.prototype.init=function(a){};shaka.cea.DummyCeaParser.prototype.parse=function(a){return[]};shaka.media.IClosedCaptionParser=function(){};shaka.media.IClosedCaptionParser.prototype.init=function(a,b,c){};shaka.media.IClosedCaptionParser.prototype.parseFrom=function(a){};shaka.media.IClosedCaptionParser.prototype.reset=function(){};shaka.media.IClosedCaptionParser.prototype.remove=function(a){};shaka.media.IClosedCaptionParser.prototype.getStreams=function(){};goog.exportSymbol("shaka.media.IClosedCaptionParser",shaka.media.IClosedCaptionParser);
shaka.media.ClosedCaptionParser=function(a){this.decoderCache_=new Map;this.currentContinuityTimeline_=0;this.ceaParser_=new shaka.cea.DummyCeaParser;if(a=shaka.media.ClosedCaptionParser.findParser(a.toLowerCase()))this.ceaParser_=a();this.ceaDecoder_=new shaka.cea.DummyCaptionDecoder;if(a=shaka.media.ClosedCaptionParser.findDecoder())this.ceaDecoder_=a(),this.decoderCache_.set(this.currentContinuityTimeline_,this.ceaDecoder_)};
shaka.media.ClosedCaptionParser.prototype.init=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?-1:c;shaka.log.debug("Passing new init segment to CEA parser");c!=-1&&this.currentContinuityTimeline_!=c?this.updateDecoder_(c):b||this.reset();this.ceaParser_.init(a);c!=-1&&(this.currentContinuityTimeline_=c)};
shaka.media.ClosedCaptionParser.prototype.parseFrom=function(a){a=this.ceaParser_.parse(a);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){b=b.value;var c=shaka.util.BufferUtils.toUint8(b.packet);c.length>0&&this.ceaDecoder_.extract(c,b.pts)}return this.ceaDecoder_.decode()};
shaka.media.ClosedCaptionParser.prototype.updateDecoder_=function(a){var b=this.decoderCache_.get(a);this.decoderCache_.set(this.currentContinuityTimeline_,this.ceaDecoder_);if(b)this.ceaDecoder_=b;else{if(b=shaka.media.ClosedCaptionParser.findDecoder())this.ceaDecoder_=b();this.decoderCache_.set(a,this.ceaDecoder_)}};shaka.media.ClosedCaptionParser.prototype.reset=function(){this.ceaDecoder_.clear()};
shaka.media.ClosedCaptionParser.prototype.remove=function(a){a=a===void 0?[]:a;a=new Set(a);for(var b=(0,$jscomp.makeIterator)(this.decoderCache_.keys()),c=b.next();!c.done;c=b.next())if(c=c.value,!a.has(c)){var d=this.decoderCache_.get(c);d&&d.clear();this.decoderCache_.delete(c)}};shaka.media.ClosedCaptionParser.prototype.getStreams=function(){return this.ceaDecoder_.getStreams()};shaka.media.ClosedCaptionParser.registerParser=function(a,b){shaka.media.ClosedCaptionParser.parserMap_.set(a,b)};
shaka.media.ClosedCaptionParser.unregisterParser=function(a){shaka.media.ClosedCaptionParser.parserMap_.delete(a)};shaka.media.ClosedCaptionParser.findParser=function(a){return shaka.media.ClosedCaptionParser.parserMap_.get(a)};shaka.media.ClosedCaptionParser.registerDecoder=function(a){shaka.media.ClosedCaptionParser.decoderFactory_=a};shaka.media.ClosedCaptionParser.unregisterDecoder=function(){shaka.media.ClosedCaptionParser.decoderFactory_=null};shaka.media.ClosedCaptionParser.findDecoder=function(){return shaka.media.ClosedCaptionParser.decoderFactory_};
goog.exportSymbol("shaka.media.ClosedCaptionParser",shaka.media.ClosedCaptionParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"findDecoder",shaka.media.ClosedCaptionParser.findDecoder);goog.exportProperty(shaka.media.ClosedCaptionParser,"unregisterDecoder",shaka.media.ClosedCaptionParser.unregisterDecoder);goog.exportProperty(shaka.media.ClosedCaptionParser,"registerDecoder",shaka.media.ClosedCaptionParser.registerDecoder);
goog.exportProperty(shaka.media.ClosedCaptionParser,"findParser",shaka.media.ClosedCaptionParser.findParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"unregisterParser",shaka.media.ClosedCaptionParser.unregisterParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"registerParser",shaka.media.ClosedCaptionParser.registerParser);shaka.media.ClosedCaptionParser.parserMap_=new Map;shaka.media.ClosedCaptionParser.decoderFactory_=null;shaka.text={};shaka.text.CueRegion=function(){var a=shaka.text.CueRegion;this.id="";this.regionAnchorY=this.regionAnchorX=this.viewportAnchorY=this.viewportAnchorX=0;this.height=this.width=100;this.viewportAnchorUnits=this.widthUnits=this.heightUnits=a.units.PERCENTAGE;this.scroll=a.scrollMode.NONE};goog.exportSymbol("shaka.text.CueRegion",shaka.text.CueRegion);shaka.text.CueRegion.units={PX:0,PERCENTAGE:1,LINES:2};goog.exportProperty(shaka.text.CueRegion,"units",shaka.text.CueRegion.units);
shaka.text.CueRegion.scrollMode={NONE:"",UP:"up"};goog.exportProperty(shaka.text.CueRegion,"scrollMode",shaka.text.CueRegion.scrollMode);shaka.util.TextParser=function(a){this.data_=a||"";this.position_=0};shaka.util.TextParser.prototype.atEnd=function(){return this.position_==this.data_.length};shaka.util.TextParser.prototype.readLine=function(){return this.readRegexReturnCapture_(/(.*?)(\n|$)/gm,1)};shaka.util.TextParser.prototype.readWord=function(){return this.readRegexReturnCapture_(/[^ \t\n]*/gm,0)};shaka.util.TextParser.prototype.skipWhitespace=function(){this.readRegex(/[ \t]+/gm)};
shaka.util.TextParser.prototype.readRegex=function(a){a=this.indexOf_(a);if(this.atEnd()||a==null||a.position!=this.position_)return null;this.position_+=a.length;return a.results};shaka.util.TextParser.prototype.readRegexReturnCapture_=function(a,b){return this.atEnd()?null:(a=this.readRegex(a))?a[b]:null};
shaka.util.TextParser.prototype.indexOf_=function(a){goog.asserts.assert(a.global,"global flag should be set");a.lastIndex=this.position_;a=a.exec(this.data_);return a==null?null:{position:a.index,length:a[0].length,results:a}};shaka.util.TextParser.prototype.parseTime=function(){var a=this.readRegex(shaka.util.TextParser.timeFormat_);if(a==null)return null;var b=Number(a[2]),c=Number(a[3]);return b>59||c>59?null:(Number(a[6])||0)/1E3+c+b*60+(Number(a[1])||0)*3600};
shaka.util.TextParser.parseTime=function(a){return a?(new shaka.util.TextParser(a)).parseTime():null};shaka.util.TextParser.timeFormat_=/(?:(\d{1,}):)?(\d{2}):(\d{2})((\.(\d{1,3})))?/g;shaka.util.ObjectUtils=function(){};shaka.util.ObjectUtils.cloneObject=function(a){var b=new WeakSet,c=function(d){switch(typeof d){case "undefined":case "boolean":case "number":case "string":case "symbol":case "function":return d;default:if(!d||ArrayBuffer.isView(d))return d;if(b.has(d))return null;var e=Array.isArray(d);if(d.constructor!=Object&&!e)return null;b.add(d);var f=e?[]:{},g;for(g in d)f[g]=c(d[g]);e&&(f.length=d.length);return f}};return c(a)};
shaka.util.ObjectUtils.shallowCloneObject=function(a){var b={},c;for(c in a)b[c]=a[c];return b};shaka.util.ObjectUtils.alphabeticalKeyOrderStringify=function(a){return Array.isArray(a)?shaka.util.ObjectUtils.arrayStringify_(a):typeof a=="function"?"":a instanceof Object?shaka.util.ObjectUtils.objectStringify_(a):JSON.stringify(a)};
shaka.util.ObjectUtils.objectStringify_=function(a){var b=Object.keys(a);b.sort();var c=[];b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next()){var e=d.value;d=JSON.stringify(e);e=a[e];e!==void 0&&(e=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(e))&&c.push(d+":"+e)}return"{"+c.join(",")+"}"};
shaka.util.ObjectUtils.arrayStringify_=function(a){for(var b=[],c=0;c<a.length;c++){var d=c.toString(),e=a[c];e!==void 0&&(e=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(e))&&b.push(d+":"+e)}return"["+b.join(",")+"]"};goog.exportSymbol("shaka.util.ObjectUtils",shaka.util.ObjectUtils);goog.exportProperty(shaka.util.ObjectUtils,"alphabeticalKeyOrderStringify",shaka.util.ObjectUtils.alphabeticalKeyOrderStringify);goog.exportProperty(shaka.util.ObjectUtils,"shallowCloneObject",shaka.util.ObjectUtils.shallowCloneObject);
goog.exportProperty(shaka.util.ObjectUtils,"cloneObject",shaka.util.ObjectUtils.cloneObject);/*
 @license
 tXml
 Copyright 2015 Tobias Nickel
 SPDX-License-Identifier: MIT
*/
shaka.util.TXml=function(){};shaka.util.TXml.parseXml=function(a,b,c){c=c===void 0?!1:c;a=shaka.util.StringUtils.fromBytesAutoDetect(a);return shaka.util.TXml.parseXmlString(a,b,c)};shaka.util.TXml.parseXmlString=function(a,b,c){a=shaka.util.TXml.parse(a,c===void 0?!1:c);if(!b&&a.length)return a[0];if(a=a.find(function(d){return b.split(",").includes(d.tagName)}))return a;shaka.log.error("parseXml root element not found!");return null};
shaka.util.TXml.getKnownNameSpace=function(a){return shaka.util.TXml.uriToNameSpace_.has(a)?shaka.util.TXml.uriToNameSpace_.get(a):""};shaka.util.TXml.getKnownSchema=function(a){return shaka.util.TXml.nameSpaceToUri_.has(a)?shaka.util.TXml.nameSpaceToUri_.get(a):""};shaka.util.TXml.setKnownNameSpace=function(a,b){shaka.util.TXml.uriToNameSpace_.set(a,b);shaka.util.TXml.nameSpaceToUri_.set(b,a)};
shaka.util.TXml.parse=function(a,b){function c(f,g){g=g===void 0?!1:g;for(var h=[];a[e];)if(a.charCodeAt(e)==60){if(a.charCodeAt(e+1)===47){g=e+2;e=a.indexOf(">",e);g=a.substring(g,e);var k=g.indexOf(f);if(k==-1){var l=f.indexOf(".");l>0&&(f=f.substring(0,l),k=g.indexOf(f))}if(k==-1)throw h=a.substring(0,e).split("\n"),Error("Unexpected close tag\nLine: "+(h.length-1)+"\nColumn: "+(h[h.length-1].length+1)+"\nChar: "+a[e]);e+1&&(e+=1);break}else if(a.charCodeAt(e+1)===33){if(a.charCodeAt(e+2)==45){for(;e!==
-1&&(a.charCodeAt(e)!==62||a.charCodeAt(e-1)!=45||a.charCodeAt(e-2)!=45||e==-1);)e=a.indexOf(">",e+1);e===-1&&(e=a.length)}else if(a.charCodeAt(e+2)===91&&a.charCodeAt(e+8)===91&&a.substr(e+3,5).toLowerCase()==="cdata"){k=a.indexOf("]]\x3e",e);k==-1?(h.push(a.substr(e+9)),e=a.length):(h.push(a.substring(e+9,k)),e=k+3);continue}e++;continue}a:{l=g;e++;var m=d(),n={};for(k=[];a.charCodeAt(e)!==62&&a[e];){var p=a.charCodeAt(e);if(p>64&&p<91||p>96&&p<123){p=d();for(var q=a.charCodeAt(e);q&&q!==39&&q!==
34&&!(q>64&&q<91||q>96&&q<123)&&q!==62;)e++,q=a.charCodeAt(e);var r=e+1;e=a.indexOf(a[e],r);r=a.slice(r,e);if(q===39||q===34){if(e===-1){l={tagName:m,attributes:n,children:k,parent:null};if(b)for(m=0;m<k.length;m++)typeof k[m]!=="string"&&(k[m].parent=l);k=l;break a}}else r=null,e--;p.startsWith("xmlns:")&&(q=p.split(":"),shaka.util.TXml.setKnownNameSpace(r,q[1]));m==="tt"&&p==="xml:space"&&r==="preserve"&&(l=!0);n[p]=r}e++}a.charCodeAt(e-1)!==47?(e++,k=c(m,l)):e++;l={tagName:m,attributes:n,children:k,
parent:null};m=k.length;for(n=0;n<m;n++)p=k[n],typeof p!=="string"?b&&(p.parent=l):n==m-1&&p=="\n"&&k.pop();k=l}h.push(k);if(typeof k==="string")break;k.tagName[0]==="?"&&k.children&&(h.push.apply(h,(0,$jscomp.arrayFromIterable)(k.children)),k.children=[])}else k=e,e=a.indexOf("<",e)-1,e===-2&&(e=a.length),k=a.slice(k,e+1),g?k.length>0&&h.push(k):h.length&&k.length==1&&k[0]=="\n"?h.push(k):k.trim().length>0&&h.push(k),e++;return h}function d(){for(var f=e;"\r\n\t>/= ".indexOf(a[e])===-1&&a[e];)e++;
return a.slice(f,e)}var e=0;return c("")};shaka.util.TXml.isNode=function(a){return!!a.tagName};shaka.util.TXml.isText=function(a){return typeof a==="string"};shaka.util.TXml.getChildNodes=function(a){var b=[];if(!a.children)return[];a=(0,$jscomp.makeIterator)(a.children);for(var c=a.next();!c.done;c=a.next())c=c.value,typeof c!=="string"&&b.push(c);return b};
shaka.util.TXml.findChildren=function(a,b){var c=[];if(!a.children)return[];a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())d=d.value,d.tagName===b&&c.push(d);return c};shaka.util.TXml.getTextContents=function(a){var b=shaka.util.StringUtils;if(typeof a==="string")return b.htmlUnescape(a);a=a.children.reduce(function(c,d){return typeof d==="string"?c+d:c},"");return a===""?null:b.htmlUnescape(a)};
shaka.util.TXml.getContents=function(a){if(!Array.from(a.children).every(function(b){return typeof b==="string"}))return null;(a=shaka.util.TXml.getTextContents(a))&&(a=a.trim());return a};shaka.util.TXml.getElementsByTagName=function(a,b,c){c=c===void 0?[]:c;a.tagName===b&&c.push(a);if(a.children){a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())shaka.util.TXml.getElementsByTagName(d.value,b,c)}return c};
shaka.util.TXml.findChild=function(a,b){a=shaka.util.TXml.findChildren(a,b);return a.length!=1?null:a[0]};shaka.util.TXml.findChildNS=function(a,b,c){a=shaka.util.TXml.findChildrenNS(a,b,c);return a.length!=1?null:a[0]};shaka.util.TXml.parseAttr=function(a,b,c,d){d=d===void 0?null:d;var e=null;a=a.attributes[b];a!=null&&(e=c(a));return e==null?d:e};shaka.util.TXml.getAttributeNS=function(a,b,c){b=shaka.util.TXml.getKnownNameSpace(b);return a.attributes[b+":"+c]||null};
shaka.util.TXml.findChildrenNS=function(a,b,c){var d=shaka.util.TXml.getKnownNameSpace(b);b=[];if(a.children)for(c=d?d+":"+c:c,a=(0,$jscomp.makeIterator)(a.children),d=a.next();!d.done;d=a.next())(d=d.value)&&d.tagName===c&&b.push(d);return b};shaka.util.TXml.getAttributeNSList=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())if(d=shaka.util.TXml.getAttributeNS(a,d.value,c))return d;return null};
shaka.util.TXml.parseDate=function(a){if(!a)return null;/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(a)&&(a+="Z");a=Date.parse(a);return isNaN(a)?null:a/1E3};
shaka.util.TXml.parseDuration=function(a){if(!a)return null;var b=RegExp("^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$","i").exec(a);if(!b)return shaka.log.warning("Invalid duration string:",a),null;a=31536E3*Number(b[1]||null)+2592E3*Number(b[2]||null)+86400*Number(b[3]||null)+3600*Number(b[4]||null)+60*Number(b[5]||null)+Number(b[6]||null);return isFinite(a)?a:null};
shaka.util.TXml.parseRange=function(a){var b=/([0-9]+)-([0-9]+)/.exec(a);if(!b)return null;a=Number(b[1]);if(!isFinite(a))return null;b=Number(b[2]);return isFinite(b)?{start:a,end:b}:null};shaka.util.TXml.parseInt=function(a){a=Number(a);return a%1===0?a:null};shaka.util.TXml.parsePositiveInt=function(a){a=Number(a);return a%1===0&&a>0?a:null};shaka.util.TXml.parseNonNegativeInt=function(a){a=Number(a);return a%1===0&&a>=0?a:null};
shaka.util.TXml.parseFloat=function(a){a=Number(a);return isNaN(a)?null:a};shaka.util.TXml.parseBoolean=function(a){return a?a.toLowerCase()==="true":!1};shaka.util.TXml.evalDivision=function(a){var b;var c=(b=a.match(/^(\d+)\/(\d+)$/))?Number(b[1])/Number(b[2]):Number(a);return isNaN(c)?null:c};
shaka.util.TXml.parseXpath=function(a){var b=[];a=shaka.util.StringUtils.htmlUnescape(a).split(/\/+(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/);a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=c.match(/^([\w]+)/);if(d){var e=c.match(/(@id='(.*?)')/),f=c.match(/(@t='(\d+)')/),g=c.match(/(@n='(\d+)')/),h=c.match(/\[(\d+)\]/);b.push({name:d[0],id:e?e[0].match(/'(.*?)'/)[0].replace(/'/gm,""):null,t:f?Number(f[0].match(/'(.*?)'/)[0].replace(/'/gm,"")):null,n:g?Number(g[0].match(/'(.*?)'/)[0].replace(/'/gm,
"")):null,position:h?Number(h[1])-1:null,attribute:c.split("/@")[1]||null})}else c.startsWith("@")&&b.length&&(b[b.length-1].attribute=c.slice(1))}return b};
shaka.util.TXml.modifyNodes=function(a,b){var c=shaka.util.TXml,d=c.parseXpath(b.attributes.sel||"");if(d.length){var e=d[d.length-1],f=b.attributes.pos||null;d=e.position;d==null&&(e.t!==null&&(d=c.nodePositionByAttribute_(a,"t",e.t)),e.n!==null&&(d=c.nodePositionByAttribute_(a,"n",e.n)));d===null?d=f==="prepend"?0:a.length:f==="prepend"?--d:f==="after"&&++d;f=b.tagName;(e=e.attribute)&&a[d]?c.modifyNodeAttribute(a[d],f,e,c.getContents(b)||""):(f!=="remove"&&f!=="replace"||a.splice(d,1),f!=="add"&&
f!=="replace"||a.splice.apply(a,[d,0].concat((0,$jscomp.arrayFromIterable)(b.children))))}};shaka.util.TXml.nodePositionByAttribute_=function(a,b,c){var d=0;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){if(Number(e.value.attributes[b])===c)return d;d++}return null};shaka.util.TXml.modifyNodeAttribute=function(a,b,c,d){if(b==="remove")delete a.attributes[c];else if(b==="add"||b==="replace")a.attributes[c]=d};
shaka.util.TXml.txmlNodeToDomElement=function(a){var b=shaka.util.TXml,c="",d=a.tagName.split(":");d.length>0&&(c=b.getKnownSchema(d[0]));c=document.createElementNS(c,a.tagName);for(var e in a.attributes)c.setAttribute(e,a.attributes[e]);a=(0,$jscomp.makeIterator)(a.children);for(e=a.next();!e.done;e=a.next())e=e.value,e=typeof e=="string"?new Text(e):b.txmlNodeToDomElement(e),c.appendChild(e);return c};
shaka.util.TXml.cloneNode=function(a){if(!a)return null;var b={tagName:a.tagName,attributes:shaka.util.ObjectUtils.shallowCloneObject(a.attributes),children:[],parent:null};a=(0,$jscomp.makeIterator)(a.children);for(var c=a.next();!c.done;c=a.next())c=c.value,typeof c==="string"?b.children.push(c):(c=shaka.util.TXml.cloneNode(c),c.parent=b,b.children.push(c));return b};shaka.util.TXml.uriToNameSpace_=new Map;shaka.util.TXml.nameSpaceToUri_=new Map;shaka.text.Cue=function(a,b,c){var d=shaka.text.Cue;this.startTime=a;this.endTime=b;this.payload=c;this.region=new shaka.text.CueRegion;this.position=null;this.positionAlign=d.positionAlign.AUTO;this.size=0;this.textAlign=d.textAlign.CENTER;this.direction=d.direction.HORIZONTAL_LEFT_TO_RIGHT;this.writingMode=d.writingMode.HORIZONTAL_TOP_TO_BOTTOM;this.lineInterpretation=d.lineInterpretation.LINE_NUMBER;this.line=null;this.lineHeight="";this.lineAlign=d.lineAlign.START;this.displayAlign=d.displayAlign.AFTER;
this.fontSize=this.border=this.backgroundImage=this.backgroundColor=this.color="";this.fontWeight=d.fontWeight.NORMAL;this.fontStyle=d.fontStyle.NORMAL;this.linePadding=this.letterSpacing=this.fontFamily="";this.opacity=1;this.textCombineUpright="";this.textDecoration=[];this.textStrokeWidth=this.textStrokeColor=this.textShadow="";this.wrapLine=!0;this.id="";this.nestedCues=[];this.lineBreak=this.isContainer=!1;this.rubyTag=null;this.cellResolution={columns:32,rows:15}};
shaka.text.Cue.lineBreak=function(a,b){a=new shaka.text.Cue(a,b,"");a.lineBreak=!0;return a};shaka.text.Cue.prototype.clone=function(){var a=new shaka.text.Cue(0,0,""),b;for(b in this)a[b]=this[b],Array.isArray(a[b])&&(a[b]=a[b].slice());return a};
shaka.text.Cue.equal=function(a,b){if(a.payload!=b.payload||!(Math.abs(a.startTime-b.startTime)<.001&&Math.abs(a.endTime-b.endTime)<.001))return!1;for(var c in a)if(c!="startTime"&&c!="endTime"&&c!="payload")if(c=="nestedCues"){if(!shaka.util.ArrayUtils.equal(a.nestedCues,b.nestedCues,shaka.text.Cue.equal))return!1}else if(c=="region"||c=="cellResolution")for(var d in a[c]){if(a[c][d]!=b[c][d])return!1}else if(Array.isArray(a[c])){if(!shaka.util.ArrayUtils.equal(a[c],b[c]))return!1}else if(a[c]!=
b[c])return!1;return!0};
shaka.text.Cue.parseCuePayload=function(a,b){b=b===void 0?new Map:b;var c=shaka.util.StringUtils,d=shaka.util.TXml,e=a.payload;if(e.includes("<")){b.size===0&&shaka.text.Cue.addDefaultTextColor(b);e=shaka.text.Cue.replaceKaraokeStylePayload_(e);e=shaka.text.Cue.replaceVoiceStylePayload_(e);e=shaka.text.Cue.escapeInvalidChevrons_(e);a.payload="";var f="<span>"+e.replace(/\n/g,"<br />")+"</span>";try{var g=d.parseXmlString(f,"span")}catch(h){shaka.log.warning("cue parse fail: ",h)}if(g)if(f=g.children,
f.length!=1||d.isNode(f[0]))for(c=(0,$jscomp.makeIterator)(f),d=c.next();!d.done;d=c.next())shaka.text.Cue.generateCueFromElement_(d.value,a,b);else a.payload=c.htmlUnescape(e);else shaka.log.warning("The cue's markup could not be parsed: ",e),a.payload=c.htmlUnescape(e)}else a.payload=c.htmlUnescape(e)};
shaka.text.Cue.addDefaultTextColor=function(a){for(var b=(0,$jscomp.makeIterator)(Object.entries(shaka.text.Cue.defaultTextColor)),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;var e=new shaka.text.Cue(0,0,"");e.color=d;a.set("."+c,e)}b=(0,$jscomp.makeIterator)(Object.entries(shaka.text.Cue.defaultTextBackgroundColor));for(c=b.next();!c.done;c=b.next())d=(0,$jscomp.makeIterator)(c.value),c=d.next().value,d=d.next().value,e=new shaka.text.Cue(0,
0,""),e.backgroundColor=d,a.set("."+c,e)};shaka.text.Cue.replaceKaraokeStylePayload_=function(a){for(var b=[],c=-1,d=0;d<a.length;d++)a[d]==="<"?c=d+1:a[d]===">"&&c>0&&(c=a.substr(c,d-c),c.match(shaka.text.Cue.timeFormat_)&&b.push(c),c=-1);b=(0,$jscomp.makeIterator)(b);for(d=b.next();!d.done;d=b.next())d=d.value,a=a.replace("<"+d+">",'<div time="'+d+'">'),a+="</div>";return a};
shaka.text.Cue.replaceVoiceStylePayload_=function(a){for(var b=[],c=-1,d="",e=!1,f=0;f<a.length;f++)if(a[f]==="/"){var g=a.indexOf(">",f);if(g===-1)return a;if((g=a.substring(f+1,g))&&g=="v"){e=!0;var h=null;b.length&&(h=b[b.length-1]);if(h){if(h===g)d+="/"+g+">";else{if(!h.startsWith("v")){d+=a[f];continue}d+="/"+h+">"}f+=g.length+1}else d+=a[f]}else d+=a[f]}else a[f]==="<"?(c=f+1,a[c]!="v"&&(c=-1)):a[f]===">"&&c>0&&(b.push(a.substr(c,f-c)),c=-1),d+=a[f];a=(0,$jscomp.makeIterator)(b);for(b=a.next();!b.done;b=
a.next())b=b.value,c=b.replace(" ",".voice-"),d=d.replace("<"+b+">","<"+c+">"),d=d.replace("</"+b+">","</"+c+">"),e||(d+="</"+c+">");return d};shaka.text.Cue.escapeInvalidChevrons_=function(a){var b={"< ":""," >":" &gt;"},c=/(< +>|<\s|\s>)/g,d=RegExp(c.source);return a&&d.test(a)?a.replace(c,function(e){return b[e]||""}):a||""};
shaka.text.Cue.generateCueFromElement_=function(a,b,c){var d=shaka.util.TXml,e=b.clone();e.nestedCues=[];e.payload="";e.rubyTag="";e.line=null;e.region=new shaka.text.CueRegion;e.position=null;e.size=0;e.textAlign=shaka.text.Cue.textAlign.CENTER;if(d.isNode(a)){var f=shaka.text.Cue.fontWeight.BOLD,g=shaka.text.Cue.fontStyle.ITALIC,h=shaka.text.Cue.textDecoration.UNDERLINE,k=a.tagName.split(/(?=[ .])+/g);k=(0,$jscomp.makeIterator)(k);for(var l=k.next();!l.done;l=k.next()){var m=l=l.value;if(m.startsWith(".voice-")){var n=
m.split("-").pop();m='v[voice="'+n+'"]';c.has(m)||(m="v[voice="+n+"]")}c.has(m)&&shaka.text.Cue.mergeStyle_(e,c.get(m));switch(l){case "br":e=shaka.text.Cue.lineBreak(e.startTime,e.endTime);b.nestedCues.push(e);return;case "b":e.fontWeight=f;break;case "i":e.fontStyle=g;break;case "u":e.textDecoration.push(h);break;case "font":if(l=a.attributes.color)e.color=l;break;case "div":l=a.attributes.time;if(!l)break;if(l=shaka.util.TextParser.parseTime(l))e.startTime=l;break;case "ruby":case "rp":case "rt":e.rubyTag=
l}}}f=a.children;if(d.isText(a)||f.length==1&&d.isText(f[0]))for(c=d.getTextContents(a).split("\n"),a=!0,c=(0,$jscomp.makeIterator)(c),d=c.next();!d.done;d=c.next())d=d.value,a||(a=shaka.text.Cue.lineBreak(e.startTime,e.endTime),b.nestedCues.push(a)),d.length>0&&(a=e.clone(),a.payload=shaka.util.StringUtils.htmlUnescape(d),b.nestedCues.push(a)),a=!1;else for(b.nestedCues.push(e),b=(0,$jscomp.makeIterator)(f),a=b.next();!a.done;a=b.next())shaka.text.Cue.generateCueFromElement_(a.value,e,c)};
shaka.text.Cue.mergeStyle_=function(a,b){b&&(a.backgroundColor=shaka.text.Cue.getOrDefault_(b.backgroundColor,a.backgroundColor),a.color=shaka.text.Cue.getOrDefault_(b.color,a.color),a.fontFamily=shaka.text.Cue.getOrDefault_(b.fontFamily,a.fontFamily),a.fontSize=shaka.text.Cue.getOrDefault_(b.fontSize,a.fontSize),a.textShadow=shaka.text.Cue.getOrDefault_(b.textShadow,a.textShadow),a.fontWeight=b.fontWeight,a.fontStyle=b.fontStyle,a.opacity=b.opacity,a.rubyTag=b.rubyTag,a.textCombineUpright=b.textCombineUpright,
a.wrapLine=b.wrapLine)};shaka.text.Cue.getOrDefault_=function(a,b){return a&&a.length>0?a:b};goog.exportSymbol("shaka.text.Cue",shaka.text.Cue);goog.exportProperty(shaka.text.Cue,"parseCuePayload",shaka.text.Cue.parseCuePayload);goog.exportProperty(shaka.text.Cue,"equal",shaka.text.Cue.equal);goog.exportProperty(shaka.text.Cue.prototype,"clone",shaka.text.Cue.prototype.clone);shaka.text.Cue.positionAlign={LEFT:"line-left",RIGHT:"line-right",CENTER:"center",AUTO:"auto"};
goog.exportProperty(shaka.text.Cue,"positionAlign",shaka.text.Cue.positionAlign);shaka.text.Cue.textAlign={LEFT:"left",RIGHT:"right",CENTER:"center",START:"start",END:"end"};goog.exportProperty(shaka.text.Cue,"textAlign",shaka.text.Cue.textAlign);shaka.text.Cue.displayAlign={BEFORE:"before",CENTER:"center",AFTER:"after"};goog.exportProperty(shaka.text.Cue,"displayAlign",shaka.text.Cue.displayAlign);shaka.text.Cue.direction={HORIZONTAL_LEFT_TO_RIGHT:"ltr",HORIZONTAL_RIGHT_TO_LEFT:"rtl"};
goog.exportProperty(shaka.text.Cue,"direction",shaka.text.Cue.direction);shaka.text.Cue.writingMode={HORIZONTAL_TOP_TO_BOTTOM:"horizontal-tb",VERTICAL_LEFT_TO_RIGHT:"vertical-lr",VERTICAL_RIGHT_TO_LEFT:"vertical-rl"};goog.exportProperty(shaka.text.Cue,"writingMode",shaka.text.Cue.writingMode);shaka.text.Cue.lineInterpretation={LINE_NUMBER:0,PERCENTAGE:1};goog.exportProperty(shaka.text.Cue,"lineInterpretation",shaka.text.Cue.lineInterpretation);
shaka.text.Cue.lineAlign={CENTER:"center",START:"start",END:"end"};goog.exportProperty(shaka.text.Cue,"lineAlign",shaka.text.Cue.lineAlign);shaka.text.Cue.defaultTextColor={white:"white",lime:"lime",cyan:"cyan",red:"red",yellow:"yellow",magenta:"magenta",blue:"blue",black:"black"};goog.exportProperty(shaka.text.Cue,"defaultTextColor",shaka.text.Cue.defaultTextColor);
shaka.text.Cue.defaultTextBackgroundColor={bg_white:"white",bg_lime:"lime",bg_cyan:"cyan",bg_red:"red",bg_yellow:"yellow",bg_magenta:"magenta",bg_blue:"blue",bg_black:"black"};goog.exportProperty(shaka.text.Cue,"defaultTextBackgroundColor",shaka.text.Cue.defaultTextBackgroundColor);shaka.text.Cue.fontWeight={NORMAL:400,BOLD:700};goog.exportProperty(shaka.text.Cue,"fontWeight",shaka.text.Cue.fontWeight);shaka.text.Cue.fontStyle={NORMAL:"normal",ITALIC:"italic",OBLIQUE:"oblique"};
goog.exportProperty(shaka.text.Cue,"fontStyle",shaka.text.Cue.fontStyle);shaka.text.Cue.textDecoration={UNDERLINE:"underline",LINE_THROUGH:"lineThrough",OVERLINE:"overline"};goog.exportProperty(shaka.text.Cue,"textDecoration",shaka.text.Cue.textDecoration);shaka.text.Cue.timeFormat_=/(?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{2,3})/g;shaka.util.IDestroyable=function(){};shaka.util.IDestroyable.prototype.destroy=function(){};shaka.transmuxer={};shaka.transmuxer.TransmuxerEngine=function(){};shaka.transmuxer.TransmuxerEngine.prototype.destroy=function(){};shaka.transmuxer.TransmuxerEngine.registerTransmuxer=function(a,b,c){var d=shaka.transmuxer.TransmuxerEngine;a=d.normalizeMimeType_(a);d.transmuxerMap_.set(a+"-"+c,{priority:c,plugin:b})};shaka.transmuxer.TransmuxerEngine.unregisterTransmuxer=function(a,b){var c=shaka.transmuxer.TransmuxerEngine;a=c.normalizeMimeType_(a);c.transmuxerMap_.delete(a+"-"+b)};
shaka.transmuxer.TransmuxerEngine.findTransmuxer=function(a,b){for(var c=shaka.transmuxer.TransmuxerEngine,d=c.normalizeMimeType_(a),e=(0,$jscomp.makeIterator)([c.PluginPriority.APPLICATION,c.PluginPriority.PREFERRED,c.PluginPriority.PREFERRED_SECONDARY,c.PluginPriority.FALLBACK]),f=e.next();!f.done;f=e.next())if(f=c.transmuxerMap_.get(d+"-"+f.value)){var g=f.plugin(),h=g.isSupported(a,b);g.destroy();if(h)return f.plugin}return null};shaka.transmuxer.TransmuxerEngine.normalizeMimeType_=function(a){return a.toLowerCase().split(";")[0]};
shaka.transmuxer.TransmuxerEngine.isSupported=function(a,b){return shaka.transmuxer.TransmuxerEngine.findTransmuxer(a)?!0:!1};shaka.transmuxer.TransmuxerEngine.convertCodecs=function(a,b){var c=shaka.transmuxer.TransmuxerEngine.findTransmuxer(b);if(!c)return b;c=c();a=c.convertCodecs(a,b);c.destroy();return a};goog.exportSymbol("shaka.transmuxer.TransmuxerEngine",shaka.transmuxer.TransmuxerEngine);goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"findTransmuxer",shaka.transmuxer.TransmuxerEngine.findTransmuxer);
goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"unregisterTransmuxer",shaka.transmuxer.TransmuxerEngine.unregisterTransmuxer);goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"registerTransmuxer",shaka.transmuxer.TransmuxerEngine.registerTransmuxer);goog.exportProperty(shaka.transmuxer.TransmuxerEngine.prototype,"destroy",shaka.transmuxer.TransmuxerEngine.prototype.destroy);shaka.transmuxer.TransmuxerEngine.transmuxerMap_=new Map;
shaka.transmuxer.TransmuxerEngine.PluginPriority={FALLBACK:1,PREFERRED_SECONDARY:2,PREFERRED:3,APPLICATION:4};goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"PluginPriority",shaka.transmuxer.TransmuxerEngine.PluginPriority);shaka.util.MimeUtils=function(){};shaka.util.MimeUtils.getFullType=function(a,b){var c=a;b&&!shaka.util.MimeUtils.RAW_FORMATS.includes(a)&&(c+='; codecs="'+b+'"');return c};shaka.util.MimeUtils.getFullTypeWithAllCodecs=function(a,b){b&&(a+='; codecs="'+b+'"');return a};
shaka.util.MimeUtils.getFullOrConvertedType=function(a,b,c){var d=shaka.util.MimeUtils,e=d.getFullType(a,b);b=d.getFullTypeWithAllCodecs(a,b);d=shaka.util.ManifestParserUtils.ContentType;var f=shaka.transmuxer.TransmuxerEngine;return f.isSupported(b,c)?f.convertCodecs(c,b):a!="video/mp2t"&&c==d.AUDIO?e.replace("video","audio"):e};
shaka.util.MimeUtils.getExtendedType=function(a,b,c){var d=[b];shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_.forEach(function(e,f){var g=a[f];f=="codecs"?shaka.util.MimeUtils.RAW_FORMATS.includes(a.mimeType)||d.push('codecs="'+c+'"'):g&&d.push(e+'="'+g+'"')});a.hdr=="PQ"&&d.push('eotf="smpte2084"');return d.join(";")};shaka.util.MimeUtils.getContainerType=function(a){return a.split(";")[0].split("/")[1]};shaka.util.MimeUtils.splitCodecs=function(a){return a.split(",")};
shaka.util.MimeUtils.getNormalizedCodec=function(a){var b=shaka.util.MimeUtils.getCodecParts_(a);a=b[0].toLowerCase();b=b[1].toLowerCase();switch(!0){case a==="mp4a"&&b==="69":case a==="mp4a"&&b==="6b":case a==="mp4a"&&b==="40.34":return"mp3";case a==="mp4a"&&b==="66":case a==="mp4a"&&b==="67":case a==="mp4a"&&b==="68":case a==="mp4a"&&b==="40.2":case a==="mp4a"&&b==="40.02":case a==="mp4a"&&b==="40.5":case a==="mp4a"&&b==="40.05":case a==="mp4a"&&b==="40.29":case a==="mp4a"&&b==="40.42":return"aac";
case a==="mp4a"&&b==="a5":case a==="ac3":case a==="ac-3":return"ac-3";case a==="mp4a"&&b==="a6":case a==="eac3":case a==="ec-3":return"ec-3";case a==="ac-4":return"ac-4";case a==="mp4a"&&b==="b2":return"dtsx";case a==="mp4a"&&b==="a9":return"dtsc";case a==="vp09":case a==="vp9":return"vp9";case a==="avc1":case a==="avc3":return"avc";case a==="hvc1":case a==="hev1":return"hevc";case a==="vvc1":case a==="vvi1":return"vvc";case a==="dvh1":case a==="dvhe":return b&&b.startsWith("05")?"dovi-p5":"dovi-hevc";
case a==="dvav":case a==="dva1":return"dovi-avc";case a==="dav1":return"dovi-av1";case a==="dvc1":case a==="dvi1":return"dovi-vvc"}return a};shaka.util.MimeUtils.getCodecBase=function(a){var b=[];a=(0,$jscomp.makeIterator)(a.split(","));for(var c=a.next();!c.done;c=a.next())c=shaka.util.MimeUtils.getCodecParts_(c.value),b.push(c[0]);return b.sort().join(",")};shaka.util.MimeUtils.getBasicType=function(a){return a.split(";")[0]};
shaka.util.MimeUtils.getCodecs=function(a){a=a.split(/ *; */);a.shift();return(a=a.find(function(b){return b.startsWith("codecs=")}))?a.split("=")[1].replace(/^"|"$/g,""):""};shaka.util.MimeUtils.isHlsType=function(a){return a==="application/x-mpegurl"||a==="application/vnd.apple.mpegurl"};shaka.util.MimeUtils.isDashType=function(a){return a==="application/dash+xml"||a==="video/vnd.mpeg.dash.mpd"};
shaka.util.MimeUtils.getCodecParts_=function(a){var b=a.split(".");a=b[0];b.shift();b=b.join(".");return[a,b]};goog.exportSymbol("shaka.util.MimeUtils",shaka.util.MimeUtils);goog.exportProperty(shaka.util.MimeUtils,"getFullTypeWithAllCodecs",shaka.util.MimeUtils.getFullTypeWithAllCodecs);goog.exportProperty(shaka.util.MimeUtils,"getFullType",shaka.util.MimeUtils.getFullType);
shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_=(new Map).set("codecs","codecs").set("frameRate","framerate").set("bandwidth","bitrate").set("width","width").set("height","height").set("channelsCount","channels");shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE="application/cea-608";shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE="application/cea-708";shaka.util.MimeUtils.RAW_FORMATS=["audio/aac","audio/ac3","audio/ec3","audio/mpeg"];shaka.text.TextEngine=function(a){this.parser_=null;this.displayer_=a;this.segmentRelativeVttTiming_=!1;this.appendWindowStart_=this.timestampOffset_=0;this.appendWindowEnd_=Infinity;this.bufferEnd_=this.bufferStart_=null;this.selectedClosedCaptionId_="";this.modifyCueCallback_=function(b,c){};this.closedCaptionsMap_=new Map};shaka.text.TextEngine.registerParser=function(a,b){shaka.text.TextEngine.parserMap_.set(a,b)};shaka.text.TextEngine.unregisterParser=function(a){shaka.text.TextEngine.parserMap_.delete(a)};
shaka.text.TextEngine.findParser=function(a){return shaka.text.TextEngine.parserMap_.get(a)};shaka.text.TextEngine.isTypeSupported=function(a){return shaka.text.TextEngine.parserMap_.has(a)?!0:a==shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE||a==shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE?!!shaka.media.ClosedCaptionParser.findDecoder():!1};shaka.text.TextEngine.prototype.destroy=function(){this.displayer_=this.parser_=null;this.closedCaptionsMap_.clear();return Promise.resolve()};
shaka.text.TextEngine.prototype.setDisplayer=function(a){this.displayer_=a};
shaka.text.TextEngine.prototype.initParser=function(a,b,c,d){a==shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE||a==shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE?this.parser_=null:(a=shaka.text.TextEngine.parserMap_.get(a),goog.asserts.assert(a,"Text type negotiation should have happened already"),this.parser_=a(),this.parser_.setSequenceMode?this.parser_.setSequenceMode(b):shaka.Deprecate.deprecateFeature(5,"Text parsers w/ setSequenceMode",'Text parsers should have a "setSequenceMode" method!'),
this.parser_.setManifestType?this.parser_.setManifestType(d):shaka.Deprecate.deprecateFeature(5,"Text parsers w/ setManifestType",'Text parsers should have a "setManifestType" method!'),this.segmentRelativeVttTiming_=c)};shaka.text.TextEngine.prototype.setModifyCueCallback=function(a){this.modifyCueCallback_=a};
shaka.text.TextEngine.prototype.appendBuffer=function(a,b,c,d){var e=this,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.nextAddress==1)return goog.asserts.assert(e.parser_,"The parser should already be initialized"),p.yield(Promise.resolve(),2);if(!e.parser_||!e.displayer_)return p.return();if(b==null||c==null)return e.parser_.parseInit(shaka.util.BufferUtils.toUint8(a)),p.return();f=e.segmentRelativeVttTiming_?b:e.timestampOffset_;g={periodStart:e.timestampOffset_,
segmentStart:b,segmentEnd:c,vttOffset:f};h=e.parser_.parseMedia(shaka.util.BufferUtils.toUint8(a),g,d,[]);k=(0,$jscomp.makeIterator)(h);for(l=k.next();!l.done;l=k.next())m=l.value,e.modifyCueCallback_(m,d||null,g);n=h.filter(function(q){return q.startTime>=e.appendWindowStart_&&q.startTime<e.appendWindowEnd_});e.displayer_.append(n);e.bufferStart_==null?e.bufferStart_=Math.max(b,e.appendWindowStart_):(goog.asserts.assert(e.bufferEnd_!=null,"There should already be a buffered range end."),goog.asserts.assert(b-
e.bufferEnd_<=1,"There should not be a gap in text references >1s"));e.bufferEnd_=Math.min(c,e.appendWindowEnd_);p.jumpToEnd()})};
shaka.text.TextEngine.prototype.remove=function(a,b,c){c=c===void 0?!1:c;var d=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1)return e.yield(Promise.resolve(),2);if(a>=b)return e.return();c&&d.removeClosedCaptions_(a,b);d.displayer_&&d.displayer_.remove(a,b)&&(d.bufferStart_==null?goog.asserts.assert(d.bufferEnd_==null,"end must be null if startTime is null"):(goog.asserts.assert(d.bufferEnd_!=null,"end must be non-null if startTime is non-null"),b<=d.bufferStart_||
a>=d.bufferEnd_||(a<=d.bufferStart_&&b>=d.bufferEnd_?d.bufferStart_=d.bufferEnd_=null:a<=d.bufferStart_&&b<d.bufferEnd_?d.bufferStart_=b:a>d.bufferStart_&&b>=d.bufferEnd_?d.bufferEnd_=a:goog.asserts.assert(!1,"removal from the middle is not supported by TextEngine")),d.updateRangesWithClosedCaptions_()));e.jumpToEnd()})};shaka.text.TextEngine.prototype.setTimestampOffset=function(a){this.timestampOffset_=a};
shaka.text.TextEngine.prototype.setAppendWindow=function(a,b){this.appendWindowStart_=a;this.appendWindowEnd_=b};shaka.text.TextEngine.prototype.bufferStart=function(){return this.bufferStart_};shaka.text.TextEngine.prototype.bufferEnd=function(){return this.bufferEnd_};shaka.text.TextEngine.prototype.isBuffered=function(a){return this.bufferStart_==null||this.bufferEnd_==null?!1:a>=this.bufferStart_&&a<this.bufferEnd_};
shaka.text.TextEngine.prototype.bufferedAheadOf=function(a){if(this.bufferEnd_==null||this.bufferEnd_<a)return 0;goog.asserts.assert(this.bufferStart_!=null,"start should not be null if end is not null");return this.bufferEnd_-Math.max(a,this.bufferStart_)};shaka.text.TextEngine.prototype.setSelectedClosedCaptionId=function(a,b){this.selectedClosedCaptionId_=a;if(a=this.closedCaptionsMap_.get(a))a=a.filter(function(c){return c.endTime<=b}),a.length&&this.displayer_.append(a)};
shaka.text.TextEngine.prototype.applyVideoTimestampOffsetRecursive_=function(a,b){a.startTime+=b;a.endTime+=b;a=(0,$jscomp.makeIterator)(a.nestedCues);for(var c=a.next();!c.done;c=a.next())this.applyVideoTimestampOffsetRecursive_(c.value,b)};
shaka.text.TextEngine.prototype.storeAndAppendClosedCaptions=function(a,b){var c=new Map;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){var e=d.value;d=e.stream;e=e.cue;c.has(d)||c.set(d,[]);this.applyVideoTimestampOffsetRecursive_(e,b);e.startTime>=this.appendWindowStart_&&e.startTime<this.appendWindowEnd_&&(c.get(d).push(e),d==this.selectedClosedCaptionId_&&this.displayer_.append([e]))}b=(0,$jscomp.makeIterator)(c.keys());for(a=b.next();!a.done;a=b.next())for(a=a.value,this.closedCaptionsMap_.has(a)||
this.closedCaptionsMap_.set(a,[]),d=(0,$jscomp.makeIterator)(c.get(a)),e=d.next();!e.done;e=d.next())e=e.value,this.closedCaptionsMap_.get(a).push(e);this.updateRangesWithClosedCaptions_()};shaka.text.TextEngine.prototype.removeClosedCaptions_=function(a,b){for(var c=(0,$jscomp.makeIterator)(this.closedCaptionsMap_.keys()),d=c.next();!d.done;d=c.next()){d=d.value;var e=this.closedCaptionsMap_.get(d);e=e.filter(function(f){return f.startTime<a||f.endTime>=b});this.closedCaptionsMap_.set(d,e)}};
shaka.text.TextEngine.prototype.updateRangesWithClosedCaptions_=function(){for(var a=Infinity,b=-Infinity,c=(0,$jscomp.makeIterator)(this.closedCaptionsMap_.values()),d=c.next();!d.done;d=c.next()){d=(0,$jscomp.makeIterator)(d.value);for(var e=d.next();!e.done;e=d.next())e=e.value,a=Math.min(a,e.startTime),b=Math.max(b,e.endTime)}a!==Infinity&&b!==-Infinity&&(this.bufferStart_=this.bufferStart_==null?Math.max(a,this.appendWindowStart_):Math.min(this.bufferStart_,Math.max(a,this.appendWindowStart_)),
this.bufferEnd_=Math.max(this.bufferEnd_,Math.min(b,this.appendWindowEnd_)))};shaka.text.TextEngine.prototype.getNumberOfClosedCaptionChannels=function(){return this.closedCaptionsMap_.size};shaka.text.TextEngine.prototype.getNumberOfClosedCaptionsInChannel=function(a){return(a=this.closedCaptionsMap_.get(a))?a.length:0};goog.exportSymbol("shaka.text.TextEngine",shaka.text.TextEngine);goog.exportProperty(shaka.text.TextEngine.prototype,"destroy",shaka.text.TextEngine.prototype.destroy);
goog.exportProperty(shaka.text.TextEngine,"findParser",shaka.text.TextEngine.findParser);goog.exportProperty(shaka.text.TextEngine,"unregisterParser",shaka.text.TextEngine.unregisterParser);goog.exportProperty(shaka.text.TextEngine,"registerParser",shaka.text.TextEngine.registerParser);shaka.text.TextEngine.parserMap_=new Map;shaka.util.DelayedTick=function(a){this.onTick_=a;this.cancelPending_=null};shaka.util.DelayedTick.prototype.tickAfter=function(a){var b=this;this.stop();var c=!0,d=null;this.cancelPending_=function(){window.clearTimeout(d);c=!1};d=window.setTimeout(function(){if(c)b.onTick_()},a*1E3);return this};shaka.util.DelayedTick.prototype.stop=function(){this.cancelPending_&&(this.cancelPending_(),this.cancelPending_=null)};shaka.util.Timer=function(a){this.onTick_=a;this.ticker_=null};shaka.util.Timer.prototype.tickNow=function(){this.stop();this.onTick_();return this};shaka.util.Timer.prototype.tickAfter=function(a){var b=this;this.stop();this.ticker_=(new shaka.util.DelayedTick(function(){b.onTick_()})).tickAfter(a);return this};
shaka.util.Timer.prototype.tickEvery=function(a){var b=this;this.stop();goog.DEBUG&&shaka.util.Timer.activeTimers.set(this,Error("Timer created").stack);this.ticker_=(new shaka.util.DelayedTick(function(){b.ticker_.tickAfter(a);b.onTick_()})).tickAfter(a);return this};shaka.util.Timer.prototype.stop=function(){this.ticker_&&(this.ticker_.stop(),this.ticker_=null);goog.DEBUG&&shaka.util.Timer.activeTimers.delete(this)};goog.exportSymbol("shaka.util.Timer",shaka.util.Timer);
goog.exportProperty(shaka.util.Timer.prototype,"stop",shaka.util.Timer.prototype.stop);goog.exportProperty(shaka.util.Timer.prototype,"tickEvery",shaka.util.Timer.prototype.tickEvery);goog.exportProperty(shaka.util.Timer.prototype,"tickAfter",shaka.util.Timer.prototype.tickAfter);goog.exportProperty(shaka.util.Timer.prototype,"tickNow",shaka.util.Timer.prototype.tickNow);goog.DEBUG&&(shaka.util.Timer.activeTimers=new Map);shaka.util.Functional=function(){};shaka.util.Functional.createFallbackPromiseChain=function(a,b){return a.reduce(function(c,d){return c.catch(function(){return b(d)})},Promise.reject())};shaka.util.Functional.collapseArrays=function(a,b){return a.concat(b)};shaka.util.Functional.ignored=function(){};shaka.util.Functional.noop=function(){};shaka.util.Functional.isNotNull=function(a){return a!=null};
shaka.util.Functional.promiseWithTimeout=function(a,b){return Promise.race([b,new Promise(function(c,d){(new shaka.util.Timer(d)).tickAfter(a)})])};shaka.util.LanguageUtils=function(){};shaka.util.LanguageUtils.areLocaleCompatible=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);return a==b};shaka.util.LanguageUtils.areLanguageCompatible=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a[0]==b[0]};
shaka.util.LanguageUtils.isParentOf=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a[0]==b[0]&&a.length==1&&b.length==2};shaka.util.LanguageUtils.isSiblingOf=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a.length==2&&b.length==2&&a[0]==b[0]};
shaka.util.LanguageUtils.normalize=function(a){var b=shaka.util.LanguageUtils;a=(0,$jscomp.makeIterator)(a.split("-x-"));var c=a.next().value;c=c===void 0?"":c;a=a.next().value;a=a===void 0?"":a;var d=(0,$jscomp.makeIterator)(c.split("-"));c=d.next().value;c=c===void 0?"":c;d=d.next().value;d=d===void 0?"":d;a=a?"x-"+a:"";c=c.toLowerCase();c=b.isoMap_.get(c)||c;b=d.toUpperCase();return""+(b?c+"-"+b:c)+(a?"-"+a:"")};
shaka.util.LanguageUtils.areSiblings=function(a,b){var c=shaka.util.LanguageUtils,d=c.getBase(a);c=c.getBase(b);return a!=d&&b!=c&&d==c};shaka.util.LanguageUtils.relatedness=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);return b==a?4:c.isParentOf(b,a)?3:c.isSiblingOf(b,a)?2:c.isParentOf(a,b)?1:0};shaka.util.LanguageUtils.getBase=function(a){var b=shaka.util.LanguageUtils,c=a.indexOf("-");a=c>=0?a.substring(0,c):a;a=a.toLowerCase();return a=b.isoMap_.get(a)||a};
shaka.util.LanguageUtils.getLocaleForText=function(a){var b=shaka.util.LanguageUtils;goog.asserts.assert(a.type==shaka.util.ManifestParserUtils.ContentType.TEXT,"Can only get language from text streams");return b.normalize(a.language||"und")};shaka.util.LanguageUtils.getLocaleForVariant=function(a){var b=shaka.util.LanguageUtils;return a.language?b.normalize(a.language):a.audio&&a.audio.language?b.normalize(a.audio.language):a.video&&a.video.language?b.normalize(a.video.language):"und"};
shaka.util.LanguageUtils.findClosestLocale=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);var d=new Set;b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next())d.add(c.normalize(e.value));b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,e==a)return e;b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,c.isParentOf(e,a))return e;b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,c.isSiblingOf(e,
a))return e;d=(0,$jscomp.makeIterator)(d);for(b=d.next();!b.done;b=d.next())if(b=b.value,c.isParentOf(a,b))return b;return null};shaka.util.LanguageUtils.disassembleLocale_=function(a){var b=a.split("-");goog.asserts.assert(b.length<=2,["Locales should not have more than 2 components. ",a," has too many components."].join());return b};goog.exportSymbol("shaka.util.LanguageUtils",shaka.util.LanguageUtils);goog.exportProperty(shaka.util.LanguageUtils,"findClosestLocale",shaka.util.LanguageUtils.findClosestLocale);
goog.exportProperty(shaka.util.LanguageUtils,"getLocaleForVariant",shaka.util.LanguageUtils.getLocaleForVariant);goog.exportProperty(shaka.util.LanguageUtils,"getLocaleForText",shaka.util.LanguageUtils.getLocaleForText);goog.exportProperty(shaka.util.LanguageUtils,"getBase",shaka.util.LanguageUtils.getBase);goog.exportProperty(shaka.util.LanguageUtils,"relatedness",shaka.util.LanguageUtils.relatedness);goog.exportProperty(shaka.util.LanguageUtils,"areSiblings",shaka.util.LanguageUtils.areSiblings);
goog.exportProperty(shaka.util.LanguageUtils,"normalize",shaka.util.LanguageUtils.normalize);goog.exportProperty(shaka.util.LanguageUtils,"isSiblingOf",shaka.util.LanguageUtils.isSiblingOf);goog.exportProperty(shaka.util.LanguageUtils,"isParentOf",shaka.util.LanguageUtils.isParentOf);goog.exportProperty(shaka.util.LanguageUtils,"areLanguageCompatible",shaka.util.LanguageUtils.areLanguageCompatible);goog.exportProperty(shaka.util.LanguageUtils,"areLocaleCompatible",shaka.util.LanguageUtils.areLocaleCompatible);
shaka.util.LanguageUtils.isoMap_=new Map([["aar","aa"],["abk","ab"],["afr","af"],["aka","ak"],["alb","sq"],["amh","am"],["ara","ar"],["arg","an"],["arm","hy"],["asm","as"],["ava","av"],["ave","ae"],["aym","ay"],["aze","az"],["bak","ba"],["bam","bm"],["baq","eu"],["bel","be"],["ben","bn"],["bih","bh"],["bis","bi"],["bod","bo"],["bos","bs"],["bre","br"],["bul","bg"],["bur","my"],["cat","ca"],["ces","cs"],["cha","ch"],["che","ce"],["chi","zh"],["chu","cu"],["chv","cv"],["cor","kw"],["cos","co"],["cre",
"cr"],["cym","cy"],["cze","cs"],["dan","da"],["deu","de"],["div","dv"],["dut","nl"],["dzo","dz"],["ell","el"],["eng","en"],["epo","eo"],["est","et"],["eus","eu"],["ewe","ee"],["fao","fo"],["fas","fa"],["fij","fj"],["fin","fi"],["fra","fr"],["fre","fr"],["fry","fy"],["ful","ff"],["geo","ka"],["ger","de"],["gla","gd"],["gle","ga"],["glg","gl"],["glv","gv"],["gre","el"],["grn","gn"],["guj","gu"],["hat","ht"],["hau","ha"],["heb","he"],["her","hz"],["hin","hi"],["hmo","ho"],["hrv","hr"],["hun","hu"],["hye",
"hy"],["ibo","ig"],["ice","is"],["ido","io"],["iii","ii"],["iku","iu"],["ile","ie"],["ina","ia"],["ind","id"],["ipk","ik"],["isl","is"],["ita","it"],["jav","jv"],["jpn","ja"],["kal","kl"],["kan","kn"],["kas","ks"],["kat","ka"],["kau","kr"],["kaz","kk"],["khm","km"],["kik","ki"],["kin","rw"],["kir","ky"],["kom","kv"],["kon","kg"],["kor","ko"],["kua","kj"],["kur","ku"],["lao","lo"],["lat","la"],["lav","lv"],["lim","li"],["lin","ln"],["lit","lt"],["ltz","lb"],["lub","lu"],["lug","lg"],["mac","mk"],["mah",
"mh"],["mal","ml"],["mao","mi"],["mar","mr"],["may","ms"],["mkd","mk"],["mlg","mg"],["mlt","mt"],["mon","mn"],["mri","mi"],["msa","ms"],["mya","my"],["nau","na"],["nav","nv"],["nbl","nr"],["nde","nd"],["ndo","ng"],["nep","ne"],["nld","nl"],["nno","nn"],["nob","nb"],["nor","no"],["nya","ny"],["oci","oc"],["oji","oj"],["ori","or"],["orm","om"],["oss","os"],["pan","pa"],["per","fa"],["pli","pi"],["pol","pl"],["por","pt"],["pus","ps"],["que","qu"],["roh","rm"],["ron","ro"],["rum","ro"],["run","rn"],["rus",
"ru"],["sag","sg"],["san","sa"],["sin","si"],["slk","sk"],["slo","sk"],["slv","sl"],["sme","se"],["smo","sm"],["sna","sn"],["snd","sd"],["som","so"],["sot","st"],["spa","es"],["sqi","sq"],["srd","sc"],["srp","sr"],["ssw","ss"],["sun","su"],["swa","sw"],["swe","sv"],["tah","ty"],["tam","ta"],["tat","tt"],["tel","te"],["tgk","tg"],["tgl","tl"],["tha","th"],["tib","bo"],["tir","ti"],["ton","to"],["tsn","tn"],["tso","ts"],["tuk","tk"],["tur","tr"],["twi","tw"],["uig","ug"],["ukr","uk"],["urd","ur"],["uzb",
"uz"],["ven","ve"],["vie","vi"],["vol","vo"],["wel","cy"],["wln","wa"],["wol","wo"],["xho","xh"],["yid","yi"],["yor","yo"],["zha","za"],["zho","zh"],["zul","zu"]]);shaka.util.StreamUtils=function(){};
shaka.util.StreamUtils.chooseCodecsAndFilterManifest=function(a,b,c,d,e){var f=shaka.util.StreamUtils,g=shaka.util.MimeUtils;if(e.length){var h=a.textStreams;e=(0,$jscomp.makeIterator)(e);for(var k=e.next(),l={};!k.done;l={textFormat:void 0},k=e.next())if(l.textFormat=k.value,k=h.filter(function(v){return function(u){return u.codecs.startsWith(v.textFormat)||u.mimeType.startsWith(v.textFormat)?!0:!1}}(l)),k.length){h=k;break}a.textStreams=h}h=a.variants;if(b.length||c.length)h=f.choosePreferredCodecs(h,
b,c);if(d.length){b=new shaka.util.MultiMap;c=(0,$jscomp.makeIterator)(h);for(f=c.next();!f.done;f=c.next())f=f.value,b.push(String(f.video.width||0),f);var m=[];b.forEach(function(v,u){v=0;var x=[];u=(0,$jscomp.makeIterator)(u);for(var z=u.next(),B={};!z.done;B={variant$jscomp$4:void 0},z=u.next())B.variant$jscomp$4=z.value,z=d.filter(function(C){return function(y){return C.variant$jscomp$4.decodingInfos[0][y]}}(B)).length,z>v?(v=z,x=[B.variant$jscomp$4]):z==v&&x.push(B.variant$jscomp$4);m.push.apply(m,
(0,$jscomp.arrayFromIterable)(x))});h=m}c=new Set;b=new Set;f=(0,$jscomp.makeIterator)(h);for(h=f.next();!h.done;h=f.next())h=h.value,h.audio&&c.add(h.audio),h.video&&b.add(h.video);h=Array.from(c).sort(function(v,u){return v.bandwidth-u.bandwidth});var n=[];c=new Map;f=function(v){var u=v.language+(v.channelsCount||0)+(v.audioSamplingRate||0)+v.roles.join(",")+v.label+v.groupId+v.fastSwitching;v.dependencyStream&&(u+=v.dependencyStream.baseOriginalId||"");return u};h=(0,$jscomp.makeIterator)(h);
for(e=h.next();!e.done;e=h.next()){e=e.value;k=f(e);l=c.get(k)||[];if(l.length){var p=l[l.length-1],q=g.getNormalizedCodec(p.codecs),r=g.getNormalizedCodec(e.codecs);q!=r||e.bandwidth&&p.bandwidth&&!(e.bandwidth>p.bandwidth)||(l.push(e),n.push(e.id))}else l.push(e),n.push(e.id);c.set(k,l)}var t={vp8:1,avc:1,"dovi-avc":.95,vp9:.9,vp09:.9,hevc:.85,"dovi-hevc":.8,"dovi-p5":.75,av01:.7,"dovi-av1":.65,vvc:.6};h=Array.from(b).sort(function(v,u){if(!v.bandwidth||!u.bandwidth||v.bandwidth==u.bandwidth){if(v.codecs&&
u.codecs&&v.codecs!=u.codecs&&v.width==u.width){var x=g.getNormalizedCodec(v.codecs),z=g.getNormalizedCodec(u.codecs);if(x!=z)return(t[x]||1)-(t[z]||1)}return v.width-u.width}return v.bandwidth-u.bandwidth});b=shaka.media.Capabilities.isChangeTypeSupported();var w=[];c=new Map;f=function(v){var u=String(v.width||"")+String(v.height||"")+String(Math.round(v.frameRate||0))+(v.hdr||"")+v.fastSwitching;v.dependencyStream&&(u+=v.dependencyStream.baseOriginalId||"");v.roles&&(u+=v.roles.sort().join("_"));
return u};h=(0,$jscomp.makeIterator)(h);for(e=h.next();!e.done;e=h.next()){e=e.value;k=f(e);l=c.get(k)||[];if(l.length){p=l[l.length-1];if(!b&&(q=g.getNormalizedCodec(p.codecs),r=g.getNormalizedCodec(e.codecs),q!==r))continue;q=g.getNormalizedCodec(p.codecs);r=g.getNormalizedCodec(e.codecs);q!=r||e.bandwidth&&p.bandwidth&&!(e.bandwidth>p.bandwidth)||(l.push(e),w.push(e.id))}else l.push(e),w.push(e.id);c.set(k,l)}a.variants=a.variants.filter(function(v){var u=v.audio,x=v.video;return u&&!n.includes(u.id)||
x&&!w.includes(x.id)?(shaka.log.debug("Dropping Variant (better codec available)",v),!1):!0})};
shaka.util.StreamUtils.choosePreferredCodecs=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next(),e={};!d.done;e={videoCodec:void 0},d=b.next())if(e.videoCodec=d.value,d=a.filter(function(f){return function(g){return g.video&&g.video.codecs.startsWith(f.videoCodec)}}(e)),d.length){a=d;break}c=(0,$jscomp.makeIterator)(c);b=c.next();for(d={};!b.done;d={audioCodec:void 0},b=c.next())if(d.audioCodec=b.value,b=a.filter(function(f){return function(g){return g.audio&&g.audio.codecs.startsWith(f.audioCodec)}}(d)),
b.length){a=b;break}return a};shaka.util.StreamUtils.filterByRestrictions=function(a,b,c){a.variants=a.variants.filter(function(d){return shaka.util.StreamUtils.meetsRestrictions(d,b,c)})};
shaka.util.StreamUtils.meetsRestrictions=function(a,b,c){var d=function(h,k,l){return h>=k&&h<=l},e=a.video;if(e&&e.width&&e.height){var f=e.width,g=e.height;g>f&&(g=(0,$jscomp.makeIterator)([g,f]),f=g.next().value,g=g.next().value);if(!d(f,b.minWidth,Math.min(b.maxWidth,c.width))||!d(g,b.minHeight,Math.min(b.maxHeight,c.height))||!d(e.width*e.height,b.minPixels,b.maxPixels))return!1}return a&&a.video&&a.video.frameRate&&!d(a.video.frameRate,b.minFrameRate,b.maxFrameRate)||a&&a.audio&&a.audio.channelsCount&&
!d(a.audio.channelsCount,b.minChannelsCount,b.maxChannelsCount)||!d(a.bandwidth,b.minBandwidth,b.maxBandwidth)?!1:!0};shaka.util.StreamUtils.applyRestrictions=function(a,b,c){var d=!1;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){e=e.value;var f=e.allowedByApplication;e.allowedByApplication=shaka.util.StreamUtils.meetsRestrictions(e,b,c);f!=e.allowedByApplication&&(d=!0)}return d};
shaka.util.StreamUtils.filterManifest=function(a,b,c,d){c=c===void 0?[]:c;d=d===void 0?{}:d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1)return e.yield(shaka.util.StreamUtils.filterManifestByMediaCapabilities(a,b,b.offlineSessionIds.length>0,c,d),2);shaka.util.StreamUtils.filterTextStreams_(b);return e.yield(shaka.util.StreamUtils.filterImageStreams_(b),0)})};
shaka.util.StreamUtils.filterManifestByMediaCapabilities=function(a,b,c,d,e){var f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.nextAddress==1)return goog.asserts.assert(navigator.mediaCapabilities,"MediaCapabilities should be valid."),shaka.device.DeviceFactory.getDevice().shouldOverrideDolbyVisionCodecs()&&shaka.util.StreamUtils.overrideDolbyVisionCodecs(b.variants),k.yield(shaka.util.StreamUtils.getDecodingInfosForVariants(b.variants,c,!1,d),2);f=null;a&&(g=a.getDrmInfo())&&
(f=g.keySystem);h=shaka.util.StreamUtils;b.variants=b.variants.filter(function(l){var m=h.checkVariantSupported_(l,f,e);m||shaka.log.debug("Dropping variant - not compatible with platform",h.getVariantSummaryString_(l));return m});k.jumpToEnd()})};
shaka.util.StreamUtils.overrideDolbyVisionCodecs=function(a){var b=(new Map).set("dvav","avc3").set("dva1","avc1").set("dvhe","hev1").set("dvh1","hvc1").set("dvc1","vvc1").set("dvi1","vvi1"),c=new Set;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())d=d.value,d.video&&c.add(d.video);c=(0,$jscomp.makeIterator)(c);for(a=c.next();!a.done;a=c.next()){a=a.value;d=(0,$jscomp.makeIterator)(b);for(var e=d.next();!e.done;e=d.next()){var f=(0,$jscomp.makeIterator)(e.value);e=f.next().value;
f=f.next().value;if(a.codecs.includes(e)){a.codecs=a.codecs.replace(e,f);break}}}};
shaka.util.StreamUtils.checkVariantSupported_=function(a,b,c){if(!a.decodingInfos.some(function(k){return!k.supported||b&&(k=k.keySystemAccess)&&(c[k.keySystem]||k.keySystem)!=b?!1:!0}))return!1;var d=shaka.device.DeviceFactory.getDevice(),e=d.getDeviceName()==="Xbox";d=d.getDeviceType()===shaka.device.IDevice.DeviceType.MOBILE&&d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO;var f=a.video,g=f&&f.width||0,h=f&&f.height||0;if(e&&f&&(g>1920||h>1080)&&(f.codecs.includes("avc1.")||f.codecs.includes("avc3."))||
(e=f&&f.dependencyStream)&&!shaka.lcevc.Dec.isStreamSupported(e))return!1;a=a.audio;return d&&a&&a.encrypted&&a.codecs.toLowerCase().includes("opus")||a&&a.dependencyStream?!1:!0};
shaka.util.StreamUtils.getDecodingInfosForVariant_=function(a,b){var c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1){c=function(n,p){if(n){var q=shaka.util.ObjectUtils.shallowCloneObject(n);q.supported=n.supported&&p.supported;q.powerEfficient=n.powerEfficient&&p.powerEfficient;q.smooth=n.smooth&&p.smooth;p.keySystemAccess&&!q.keySystemAccess&&(q.keySystemAccess=p.keySystemAccess);return q}return p};d=shaka.util.StreamUtils;e=null;f=[];g=(0,$jscomp.makeIterator)(b);
h=g.next();for(k={};!h.done;k={cache:void 0,cacheKey:void 0},h=g.next())l=h.value,k.cacheKey=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(l),k.cache=d.decodingConfigCache_,k.cache.has(k.cacheKey)?(shaka.log.v2("Using cached results of mediaCapabilities.decodingInfo","for key",k.cacheKey),e=c(e,k.cache.get(k.cacheKey))):f.push(d.checkEachDecodingConfigCombination_(l).then(function(n){return function(p){var q=null;p=(0,$jscomp.makeIterator)(p||[]);for(var r=p.next();!r.done;r=p.next())q=c(q,
r.value);q&&(n.cache.set(n.cacheKey,q),e=c(e,q))}}(k)));return m.yield(Promise.all(f),2)}e&&a.decodingInfos.push(e);m.jumpToEnd()})};
shaka.util.StreamUtils.checkEachDecodingConfigCombination_=function(a){var b=[""];a.video&&(b=shaka.util.MimeUtils.getCodecs(a.video.contentType).split(","));var c=[""];a.audio&&(c=shaka.util.MimeUtils.getCodecs(a.audio.contentType).split(","));var d=[];b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next()){e=e.value;for(var f=(0,$jscomp.makeIterator)(c),g=f.next(),h={};!g.done;h={copy$jscomp$1:void 0},g=f.next()){g=g.value;h.copy$jscomp$1=shaka.util.ObjectUtils.cloneObject(a);if(a.video){var k=
shaka.util.MimeUtils.getBasicType(h.copy$jscomp$1.video.contentType);h.copy$jscomp$1.video.contentType=shaka.util.MimeUtils.getFullType(k,e)}a.audio&&(k=shaka.util.MimeUtils.getBasicType(h.copy$jscomp$1.audio.contentType),h.copy$jscomp$1.audio.contentType=shaka.util.MimeUtils.getFullType(k,g));d.push(new Promise(function(l){return function(m,n){(shaka.device.DeviceFactory.getDevice().getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE?shaka.util.Functional.promiseWithTimeout(5,navigator.mediaCapabilities.decodingInfo(l.copy$jscomp$1)):
navigator.mediaCapabilities.decodingInfo(l.copy$jscomp$1)).then(function(p){m(p)}).catch(n)}}(h)))}}return Promise.all(d).catch(function(l){shaka.log.info("MediaCapabilities.decodingInfo() failed.",JSON.stringify(a),l);return null})};
shaka.util.StreamUtils.getDecodingInfosForVariants=function(a,b,c,d){var e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.nextAddress){case 1:if(e=a.some(function(A){return A.decodingInfos.length}))return shaka.log.debug("Already got the variants' decodingInfo."),y.return();f=(0,$jscomp.makeIterator)(d);g=f.next();h={};case 2:if(g.done){y.jumpTo(4);break}h.preferredKeySystem=g.value;k=!1;l=(0,$jscomp.makeIterator)(a);m=l.next();case 5:if(m.done){y.jumpTo(7);
break}n=m.value;p=shaka.util.StreamUtils.getDecodingConfigs_(n,b,c).filter(function(A){return function(D){D=D[0];return(D.keySystemConfiguration&&D.keySystemConfiguration.keySystem)===A.preferredKeySystem}}(h));q=(0,$jscomp.makeIterator)(p);r=q.next();case 8:if(r.done){y.jumpTo(10);break}t=r.value;return y.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(n,t),9);case 9:r=q.next();y.jumpTo(8);break;case 10:n.decodingInfos.some(function(A){return A.supported})&&(k=!0);m=l.next();y.jumpTo(5);
break;case 7:if(k)return y.return();h={preferredKeySystem:void 0};g=f.next();y.jumpTo(2);break;case 4:w=(0,$jscomp.makeIterator)(a),v=w.next();case 12:if(v.done){y.jumpTo(0);break}u=v.value;x=shaka.util.StreamUtils.getDecodingConfigs_(u,b,c).filter(function(A){A=A[0];A=A.keySystemConfiguration&&A.keySystemConfiguration.keySystem;return!A||!d.includes(A)});z=(0,$jscomp.makeIterator)(x);B=z.next();case 15:if(B.done){v=w.next();y.jumpTo(12);break}C=B.value;return y.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(u,
C),16);case 16:B=z.next(),y.jumpTo(15)}})};
shaka.util.StreamUtils.getDecodingConfigs_=function(a,b,c){var d=a.audio,e=a.video,f=shaka.util.ManifestParserUtils.ContentType,g=shaka.util.ManifestParserUtils,h=shaka.util.MimeUtils,k=shaka.util.StreamUtils,l=[],m=[];if(e)for(var n=(0,$jscomp.makeIterator)(e.fullMimeTypes),p=n.next();!p.done;p=n.next()){p=p.value;var q=h.getCodecs(p);if(q.includes(",")&&!d){var r=q.split(","),t=h.getBasicType(p);q=g.guessCodecs(f.VIDEO,r);r=g.guessCodecs(f.AUDIO,r);r=k.getCorrectAudioCodecs(r,t);t=h.getFullOrConvertedType(t,
r,f.AUDIO);m.push({contentType:t,channels:2,bitrate:a.bandwidth||1,samplerate:1,spatialRendering:!1})}q=k.getCorrectVideoCodecs(q);p={contentType:h.getFullOrConvertedType(h.getBasicType(p),q,f.VIDEO),width:e.width||64,height:e.height||64,bitrate:e.bandwidth||a.bandwidth||1,framerate:e.frameRate||30};if(e.hdr)switch(e.hdr){case "PQ":p.transferFunction="pq";break;case "HLG":p.transferFunction="hlg"}e.colorGamut&&(p.colorGamut=e.colorGamut);l.push(p)}if(d)for(g=(0,$jscomp.makeIterator)(d.fullMimeTypes),
n=g.next();!n.done;n=g.next())p=n.value,n=h.getBasicType(p),p=k.getCorrectAudioCodecs(h.getCodecs(p),n),n=h.getFullOrConvertedType(n,p,f.AUDIO),m.push({contentType:n,channels:d.channelsCount||2,bitrate:d.bandwidth||a.bandwidth||1,samplerate:d.audioSamplingRate||1,spatialRendering:d.spatialAudio});f=[];l.length==0&&l.push(null);m.length==0&&m.push(null);l=(0,$jscomp.makeIterator)(l);for(h=l.next();!h.done;h=l.next())for(h=h.value,k=(0,$jscomp.makeIterator)(m),g=k.next();!g.done;g=k.next())g=g.value,
n={type:c?"file":"media-source"},h&&(n.video=h),g&&(n.audio=g),f.push(n);m=(a.video?a.video.drmInfos:[]).concat(a.audio?a.audio.drmInfos:[]);if(!m.length)return[f];a=[];c=new Map;m=(0,$jscomp.makeIterator)(m);for(l=m.next();!l.done;l=m.next())l=l.value,c.get(l.keySystem)||c.set(l.keySystem,[]),c.get(l.keySystem).push(l);m=b?"required":"optional";b=b?["persistent-license"]:["temporary"];l=(0,$jscomp.makeIterator)(c.keys());for(h=l.next();!h.done;h=l.next()){h=h.value;g=c.get(h);k=new Map;g=(0,$jscomp.makeIterator)(g);
for(n=g.next();!n.done;n=g.next())n=n.value,p=n.videoRobustness+","+n.audioRobustness,k.get(p)||k.set(p,[]),k.get(p).push(n);k=(0,$jscomp.makeIterator)(k.values());for(g=k.next();!g.done;g=k.next()){g=g.value;n=[];p=(0,$jscomp.makeIterator)(f);for(q=p.next();!q.done;q=p.next()){q=Object.assign({},q.value);t={keySystem:h,initDataType:"cenc",persistentState:m,distinctiveIdentifier:"optional",sessionTypes:b};r=(0,$jscomp.makeIterator)(g);for(var w=r.next();!w.done;w=r.next()){w=w.value;if(w.initData&&
w.initData.length){for(var v=new Set,u=(0,$jscomp.makeIterator)(w.initData),x=u.next();!x.done;x=u.next())v.add(x.value.initDataType);v.size>1&&shaka.log.v2("DrmInfo contains more than one initDataType,","and we use the initDataType of the first initData.",w);t.initDataType=w.initData[0].initDataType}w.distinctiveIdentifierRequired&&(t.distinctiveIdentifier="required");w.persistentStateRequired&&(t.persistentState="required");w.sessionType&&(t.sessionTypes=[w.sessionType]);d&&(t.audio?(w.encryptionScheme&&
(t.audio.encryptionScheme=t.audio.encryptionScheme||w.encryptionScheme),t.audio.robustness=t.audio.robustness||w.audioRobustness):(t.audio={robustness:w.audioRobustness},w.encryptionScheme&&(t.audio.encryptionScheme=w.encryptionScheme)),t.audio.robustness==""&&delete t.audio.robustness);e&&(t.video?(w.encryptionScheme&&(t.video.encryptionScheme=t.video.encryptionScheme||w.encryptionScheme),t.video.robustness=t.video.robustness||w.videoRobustness):(t.video={robustness:w.videoRobustness},w.encryptionScheme&&
(t.video.encryptionScheme=w.encryptionScheme)),t.video.robustness==""&&delete t.video.robustness)}q.keySystemConfiguration=t;n.push(q)}a.push(n)}}return a};
shaka.util.StreamUtils.getCorrectAudioCodecs=function(a,b){var c=shaka.device.DeviceFactory.getDevice(),d=shaka.device.IDevice.BrowserEngine.WEBKIT;return a.toLowerCase()=="flac"?c.getBrowserEngine()!=d?"flac":"fLaC":a.toLowerCase()==="opus"?c.getBrowserEngine()!=d?"opus":shaka.util.MimeUtils.getContainerType(b)=="mp4"?"Opus":"opus":a.toLowerCase()=="ac-3"&&c.requiresEC3InitSegments()?"ec-3":a};
shaka.util.StreamUtils.getCorrectVideoCodecs=function(a){if(a.includes("avc1")){var b=a.split(".");if(b.length==3)return a=b.shift()+".",a+=parseInt(b.shift(),10).toString(16),a+=("000"+parseInt(b.shift(),10).toString(16)).slice(-4)}else if(a=="vp9")return"vp09.00.41.08";return a};
shaka.util.StreamUtils.filterManifestByCurrentVariant=function(a,b){var c=shaka.util.StreamUtils;b.variants=b.variants.filter(function(d){var e=d.audio;d=d.video;return e&&a&&a.audio&&!c.areStreamsCompatible_(e,a.audio)?(shaka.log.debug("Dropping variant - not compatible with active audio","active audio",c.getStreamSummaryString_(a.audio),"variant.audio",c.getStreamSummaryString_(e)),!1):d&&a&&a.video&&!c.areStreamsCompatible_(d,a.video)?(shaka.log.debug("Dropping variant - not compatible with active video",
"active video",c.getStreamSummaryString_(a.video),"variant.video",c.getStreamSummaryString_(d)),!1):!0})};shaka.util.StreamUtils.filterTextStreams_=function(a){a.textStreams=a.textStreams.filter(function(b){var c=shaka.util.MimeUtils.getFullType(b.mimeType,b.codecs);(c=shaka.text.TextEngine.isTypeSupported(c))||shaka.log.debug("Dropping text stream. Is not supported by the platform.",b);return c})};
shaka.util.StreamUtils.filterImageStreams_=function(a){var b,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.nextAddress){case 1:b=[],c=(0,$jscomp.makeIterator)(a.imageStreams),d=c.next();case 2:if(d.done){l.jumpTo(4);break}e=d.value;f=e.mimeType;f=="application/mp4"&&e.codecs=="mjpg"&&(f="image/jpg");if(shaka.util.StreamUtils.supportedImageMimeTypes_.has(f)){l.jumpTo(5);break}g=shaka.util.StreamUtils.minImage_.get(f);if(!g){shaka.util.StreamUtils.supportedImageMimeTypes_.set(f,
!1);l.jumpTo(5);break}return l.yield(shaka.util.StreamUtils.isImageSupported_(g),7);case 7:h=l.yieldResult,shaka.util.StreamUtils.supportedImageMimeTypes_.set(f,h);case 5:(k=shaka.util.StreamUtils.supportedImageMimeTypes_.get(f))?b.push(e):shaka.log.debug("Dropping image stream. Is not supported by the platform.",e);d=c.next();l.jumpTo(2);break;case 4:a.imageStreams=b,l.jumpToEnd()}})};
shaka.util.StreamUtils.isImageSupported_=function(a){return new Promise(function(b){var c=new Image;c.src=a;"decode"in c?c.decode().then(function(){b(!0)}).catch(function(){b(!1)}):c.onload=c.onerror=function(){b(c.height===2)}})};shaka.util.StreamUtils.areStreamsCompatible_=function(a,b){return a.mimeType!=b.mimeType||a.codecs.split(".")[0]!=b.codecs.split(".")[0]?!1:!0};
shaka.util.StreamUtils.variantToTrack=function(a){var b=shaka.util.ManifestParserUtils,c=shaka.util.ManifestParserUtils.ContentType,d=a.audio,e=a.video,f=d?d.mimeType:null,g=e?e.mimeType:null,h=d?d.codecs:null,k=e?e.codecs:null,l=d?d.groupId:null,m=[];e&&m.push(e.mimeType);d&&m.push(d.mimeType);m=m[0]||null;var n=[];d&&n.push(d.kind);e&&n.push(e.kind);n=n[0]||null;var p=new Set;if(d)for(var q=(0,$jscomp.makeIterator)(d.roles),r=q.next();!r.done;r=q.next())p.add(r.value);if(e)for(q=(0,$jscomp.makeIterator)(e.roles),
r=q.next();!r.done;r=q.next())p.add(r.value);a={id:a.id,active:!1,type:"variant",bandwidth:a.bandwidth,language:a.language,label:null,videoLabel:null,kind:n,width:null,height:null,frameRate:null,pixelAspectRatio:null,hdr:null,colorGamut:null,videoLayout:null,mimeType:m,audioMimeType:f,videoMimeType:g,codecs:"",audioCodec:h,videoCodec:k,primary:a.primary,roles:Array.from(p),audioRoles:null,videoRoles:null,forced:!1,videoId:null,audioId:null,audioGroupId:l,channelsCount:null,audioSamplingRate:null,
spatialAudio:!1,tilesLayout:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:null,originalImageId:null,accessibilityPurpose:null,originalLanguage:null};if(e){a.videoId=e.id;a.originalVideoId=e.originalId;a.width=e.width||null;a.height=e.height||null;a.frameRate=e.frameRate||null;a.pixelAspectRatio=e.pixelAspectRatio||null;a.videoBandwidth=e.bandwidth||null;a.hdr=e.hdr||null;a.colorGamut=e.colorGamut||null;a.videoLayout=e.videoLayout||null;a.videoRoles=
e.roles;a.videoLabel=e.label;if(f=e.dependencyStream)a.width=f.width||a.width,a.height=f.height||a.height,a.videoCodec=f.codecs||a.videoCodec,a.videoBandwidth&&f.bandwidth&&(a.videoBandwidth+=f.bandwidth);if(k.includes(",")){a.channelsCount=e.channelsCount;a.audioSamplingRate=e.audioSamplingRate;a.spatialAudio=e.spatialAudio;a.originalLanguage=e.originalLanguage;a.audioMimeType=g;g=k.split(",");try{a.videoCodec=b.guessCodecs(c.VIDEO,g),a.audioCodec=b.guessCodecs(c.AUDIO,g)}catch(t){}}}d&&(a.audioId=
d.id,a.originalAudioId=d.originalId,a.channelsCount=d.channelsCount,a.audioSamplingRate=d.audioSamplingRate,a.audioBandwidth=d.bandwidth||null,a.spatialAudio=d.spatialAudio,a.label=d.label,a.audioRoles=d.roles,a.accessibilityPurpose=d.accessibilityPurpose,a.originalLanguage=d.originalLanguage,b=d.dependencyStream)&&(a.audioCodec=b.codecs||a.audioCodec,a.audioBandwidth&&b.bandwidth&&(a.audioBandwidth+=b.bandwidth));e&&!a.videoBandwidth&&(d?a.audioBandwidth&&(a.videoBandwidth=a.bandwidth-a.audioBandwidth):
a.videoBandwidth=a.bandwidth);d&&!a.audioBandwidth&&(e?a.videoBandwidth&&(a.audioBandwidth=a.bandwidth-a.videoBandwidth):a.audioBandwidth=a.bandwidth);d=[];a.videoCodec&&d.push(a.videoCodec);a.audioCodec&&d.push(a.audioCodec);a.codecs=d.join(", ");return a};
shaka.util.StreamUtils.textStreamToTrack=function(a){return{id:a.id,active:!1,type:shaka.util.ManifestParserUtils.ContentType.TEXT,bandwidth:a.bandwidth||0,language:a.language,label:a.label,kind:a.kind||null,mimeType:a.mimeType,codecs:a.codecs||null,primary:a.primary,roles:a.roles,accessibilityPurpose:a.accessibilityPurpose,forced:a.forced,originalTextId:a.originalId,originalLanguage:a.originalLanguage}};
shaka.util.StreamUtils.imageStreamToTrack=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c=a.width||null,d=a.height||null,e=null;a.segmentIndex&&(e=a.segmentIndex.earliestReference());var f=a.tilesLayout;e&&(f=e.getTilesLayout()||f);f&&c!=null&&(c/=Number(f.split("x")[0]));f&&d!=null&&(d/=Number(f.split("x")[1]));return{id:a.id,type:b.IMAGE,bandwidth:a.bandwidth||0,width:c,height:d,mimeType:a.mimeType,codecs:a.codecs||null,tilesLayout:f||null,originalImageId:a.originalId}};
shaka.util.StreamUtils.html5TrackId=function(a){a.__shaka_id||(a.__shaka_id=shaka.util.StreamUtils.nextTrackId_++);return a.__shaka_id};
shaka.util.StreamUtils.html5TextTrackToTrack=function(a){var b=shaka.util.ManifestParserUtils.ContentType;b={id:shaka.util.StreamUtils.html5TrackId(a),active:a.mode!="disabled",type:b.TEXT,bandwidth:0,language:shaka.util.LanguageUtils.normalize(a.language||"und"),label:a.label,kind:a.kind,mimeType:null,codecs:null,primary:!1,roles:[],accessibilityPurpose:null,forced:a.kind=="forced",originalTextId:a.id,originalLanguage:a.language};a.kind=="captions"&&(b.mimeType="unknown");a.kind=="subtitles"&&(b.mimeType=
"text/vtt");a.kind&&(b.roles=[a.kind]);return b};
shaka.util.StreamUtils.html5AudioTrackToTrack=function(a){var b=a.language;b={active:a.enabled,language:shaka.util.LanguageUtils.normalize(b||"und"),label:a.label,mimeType:null,codecs:null,primary:a.kind=="main",roles:[],accessibilityPurpose:null,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,originalLanguage:b};a.kind&&b.roles.push(a.kind);a.configuration&&(a.configuration.codec&&(b.codecs=a.configuration.codec),a.configuration.sampleRate&&(b.audioSamplingRate=a.configuration.sampleRate),
a.configuration.numberOfChannels&&(b.channelsCount=a.configuration.numberOfChannels));return b};
shaka.util.StreamUtils.html5TrackToShakaTrack=function(a,b){goog.asserts.assert(a||b,"There must be at least audioTrack or videoTrack.");var c=shaka.util.LanguageUtils,d=a?a.language:null;c={id:shaka.util.StreamUtils.html5TrackId(a||b),active:a?a.enabled:b.selected,type:"variant",bandwidth:0,language:c.normalize(d||"und"),label:a?a.label:null,videoLabel:null,kind:a?a.kind:null,width:null,height:null,frameRate:null,pixelAspectRatio:null,hdr:null,colorGamut:null,videoLayout:null,mimeType:null,audioMimeType:null,
videoMimeType:null,codecs:null,audioCodec:null,videoCodec:null,primary:a?a.kind=="main":!1,roles:[],forced:!1,audioRoles:null,videoRoles:null,videoId:null,audioId:null,audioGroupId:null,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,tilesLayout:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:b?b.id:null,originalAudioId:a?a.id:null,originalTextId:null,originalImageId:null,accessibilityPurpose:null,originalLanguage:d};a&&a.kind&&(c.roles=[a.kind],c.audioRoles=[a.kind]);a&&a.configuration&&
(a.configuration.codec&&(c.audioCodec=a.configuration.codec,c.codecs=c.audioCodec),a.configuration.bitrate&&(c.audioBandwidth=a.configuration.bitrate,c.bandwidth+=c.audioBandwidth),a.configuration.sampleRate&&(c.audioSamplingRate=a.configuration.sampleRate),a.configuration.numberOfChannels&&(c.channelsCount=a.configuration.numberOfChannels));if(b&&b.configuration&&(b.configuration.codec&&(c.videoCodec=b.configuration.codec,c.codecs=c.codecs?c.codecs+(","+c.videoCodec):c.videoCodec),b.configuration.bitrate&&
(c.videoBandwidth=b.configuration.bitrate,c.bandwidth+=c.videoBandwidth),b.configuration.framerate&&(c.frameRate=b.configuration.framerate),b.configuration.width&&(c.width=b.configuration.width),b.configuration.height&&(c.height=b.configuration.height),b.configuration.colorSpace&&b.configuration.colorSpace.transfer))switch(b.configuration.colorSpace.transfer){case "pq":c.hdr="PQ";break;case "hlg":c.hdr="HLG";break;case "bt709":c.hdr="SDR"}return c};
shaka.util.StreamUtils.isPlayable=function(a){return a.allowedByApplication&&a.allowedByKeySystem&&a.disabledUntilTime==0};shaka.util.StreamUtils.getPlayableVariants=function(a){return a.filter(function(b){return shaka.util.StreamUtils.isPlayable(b)})};
shaka.util.StreamUtils.filterStreamsByLanguageAndRole=function(a,b,c,d){var e=shaka.util.LanguageUtils,f=a,g=a.filter(function(l){return l.primary});g.length&&(f=g);var h=f.length?f[0].language:"";f=f.filter(function(l){return l.language==h});if(b){var k=e.findClosestLocale(e.normalize(b),a.map(function(l){return l.language}));k&&(f=a.filter(function(l){return e.normalize(l.language)==k}))}f=f.filter(function(l){return l.forced==d});if(c){a=shaka.util.StreamUtils.filterStreamsByRole_(f,c);if(a.length)return a;
shaka.log.warning("No exact match for the text role could be found.")}else if(a=f.filter(function(l){return l.roles.length==0}),a.length)return a;a=f.map(function(l){return l.roles}).reduce(shaka.util.Functional.collapseArrays,[]);return a.length?shaka.util.StreamUtils.filterStreamsByRole_(f,a[0]):f};shaka.util.StreamUtils.filterStreamsByRole_=function(a,b){return a.filter(function(c){return c.roles.includes(b)})};shaka.util.StreamUtils.isAudio=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO};
shaka.util.StreamUtils.isVideo=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.VIDEO};shaka.util.StreamUtils.getVariantStreams=function(a){var b=[];a.audio&&b.push(a.audio);a.video&&b.push(a.video);return b};shaka.util.StreamUtils.isFastSwitching=function(a){return a.audio&&a.audio.fastSwitching||a.video&&a.video.fastSwitching?!0:!1};
shaka.util.StreamUtils.setBetterIFrameStream=function(a,b){b.length&&(b=b.filter(function(c){return shaka.util.MimeUtils.getNormalizedCodec(a.codecs)==shaka.util.MimeUtils.getNormalizedCodec(c.codecs)}).sort(function(c,d){return c.bandwidth&&d.bandwidth&&c.bandwidth!=d.bandwidth?c.bandwidth-d.bandwidth:(c.width||0)-(d.width||0)}),a.trickModeVideo=b[0],b.length>1&&(b=b.find(function(c){return a.width==c.width&&a.height==c.height})))&&(a.trickModeVideo=b)};
shaka.util.StreamUtils.getVariantSummaryString_=function(a){var b=[];a.audio&&b.push(shaka.util.StreamUtils.getStreamSummaryString_(a.audio));a.video&&b.push(shaka.util.StreamUtils.getStreamSummaryString_(a.video));return b.join(", ")};
shaka.util.StreamUtils.getStreamSummaryString_=function(a){return shaka.util.StreamUtils.isAudio(a)?"type=audio codecs="+a.codecs+" bandwidth="+a.bandwidth+" channelsCount="+a.channelsCount+" audioSamplingRate="+a.audioSamplingRate:shaka.util.StreamUtils.isVideo(a)?"type=video codecs="+a.codecs+" bandwidth="+a.bandwidth+" frameRate="+a.frameRate+" width="+a.width+" height="+a.height:"unexpected stream type"};shaka.util.StreamUtils.clearDecodingConfigCache=function(){shaka.util.StreamUtils.decodingConfigCache_.clear()};
shaka.util.StreamUtils.shouldInitiallyShowText=function(a,b,c){var d=shaka.config.AutoShowText;if(c.autoShowText==d.NEVER)return!1;if(c.autoShowText==d.ALWAYS)return!0;var e=shaka.util.LanguageUtils,f=e.normalize(c.preferredTextLanguage);b=e.normalize(b.language);if(c.autoShowText==d.IF_PREFERRED_TEXT_LANGUAGE)return e.areLanguageCompatible(b,f);if(c.autoShowText==d.IF_SUBTITLES_MAY_BE_NEEDED){if(!a)return!1;a=e.normalize(a.language);return e.areLanguageCompatible(b,f)&&!e.areLanguageCompatible(a,
b)}shaka.log.alwaysWarn("Invalid autoShowText setting!");return!1};
shaka.util.StreamUtils.createEmptyVariant=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c={id:0,language:"und",disabledUntilTime:0,primary:!1,audio:null,video:null,bandwidth:100,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]};a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;var e={id:0,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:null,mimeType:d?shaka.util.MimeUtils.getBasicType(d):"",
codecs:d?shaka.util.MimeUtils.getCodecs(d):"",encrypted:!0,drmInfos:[],keyIds:new Set,language:"und",originalLanguage:null,label:null,type:b.VIDEO,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!1,fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null};e.fullMimeTypes.add(shaka.util.MimeUtils.getFullType(e.mimeType,
e.codecs));d.startsWith("audio/")?(e.type=b.AUDIO,c.audio=e):c.video=e}return c};goog.exportSymbol("shaka.util.StreamUtils",shaka.util.StreamUtils);goog.exportProperty(shaka.util.StreamUtils,"meetsRestrictions",shaka.util.StreamUtils.meetsRestrictions);shaka.util.StreamUtils.decodingConfigCache_=new Map;shaka.util.StreamUtils.nextTrackId_=0;shaka.util.StreamUtils.DecodingAttributes={SMOOTH:"smooth",POWER:"powerEfficient"};
shaka.util.StreamUtils.supportedImageMimeTypes_=(new Map).set("image/svg+xml",!0).set("image/png",!0).set("image/jpeg",!0).set("image/jpg",!0);shaka.util.StreamUtils.minWebPImage_="data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA";shaka.util.StreamUtils.minAvifImage_="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";
shaka.util.StreamUtils.minImage_=(new Map).set("image/webp",shaka.util.StreamUtils.minWebPImage_).set("image/avif",shaka.util.StreamUtils.minAvifImage_);shaka.abr.SimpleAbrManager=function(){var a=this;this.switch_=null;this.enabled_=!1;this.bandwidthEstimator_=new shaka.abr.EwmaBandwidthEstimator;this.eventManager_=new shaka.util.EventManager;navigator.connection&&navigator.connection.addEventListener&&this.eventManager_.listen(navigator.connection,"change",function(){if(a.enabled_&&a.config_.useNetworkInformation){a.bandwidthEstimator_=new shaka.abr.EwmaBandwidthEstimator;a.config_&&a.bandwidthEstimator_.configure(a.config_.advanced);var b=a.chooseVariant();
b&&navigator.onLine&&a.switch_(b,a.config_.clearBufferSwitch,a.config_.safeMarginSwitch)}});this.variants_=[];this.playbackRate_=1;this.startupComplete_=!1;this.resizeObserver_=this.mediaElement_=this.config_=this.lastTimeChosenMs_=null;this.resizeObserverTimer_=new shaka.util.Timer(function(){if(a.enabled_&&(a.config_.restrictToElementSize||a.config_.restrictToScreenSize)){var b=a.chooseVariant();b&&a.switch_(b,a.config_.clearBufferSwitch,a.config_.safeMarginSwitch)}});this.windowToCheck_=window;
"documentPictureInPicture"in window&&this.eventManager_.listen(window.documentPictureInPicture,"enter",function(){a.windowToCheck_=window.documentPictureInPicture.window;a.resizeObserverTimer_&&a.resizeObserverTimer_.tickNow();a.eventManager_.listenOnce(a.windowToCheck_,"pagehide",function(){a.windowToCheck_=window;a.resizeObserverTimer_&&a.resizeObserverTimer_.tickNow()})});this.cmsdManager_=this.pictureInPictureWindow_=null};
shaka.abr.SimpleAbrManager.prototype.stop=function(){this.switch_=null;this.enabled_=!1;this.variants_=[];this.playbackRate_=1;this.mediaElement_=this.lastTimeChosenMs_=null;this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);this.resizeObserverTimer_&&this.resizeObserverTimer_.stop();this.cmsdManager_=this.pictureInPictureWindow_=null};shaka.abr.SimpleAbrManager.prototype.release=function(){this.stop();this.eventManager_.release();this.resizeObserverTimer_=null};
shaka.abr.SimpleAbrManager.prototype.init=function(a){this.switch_=a};
shaka.abr.SimpleAbrManager.prototype.chooseVariant=function(a){a=a===void 0?!1:a;var b=Infinity,c=Infinity;this.config_.restrictToScreenSize&&(c=this.config_.ignoreDevicePixelRatio?1:this.windowToCheck_.devicePixelRatio,b=this.windowToCheck_.screen.height*c,c*=this.windowToCheck_.screen.width);if(this.resizeObserver_&&this.config_.restrictToElementSize){var d=this.config_.ignoreDevicePixelRatio?1:this.windowToCheck_.devicePixelRatio,e=this.mediaElement_.clientHeight,f=this.mediaElement_.clientWidth;
this.pictureInPictureWindow_&&document.pictureInPictureElement&&document.pictureInPictureElement==this.mediaElement_&&(e=this.pictureInPictureWindow_.height,f=this.pictureInPictureWindow_.width);b=Math.min(b,e*d);c=Math.min(c,f*d)}e=this.variants_.filter(function(m){return m&&!shaka.util.StreamUtils.isFastSwitching(m)});e.length||(e=this.variants_);d=e;a&&e.length!=this.variants_.length&&(d=this.variants_.filter(function(m){return m&&shaka.util.StreamUtils.isFastSwitching(m)}));a=this.filterAndSortVariants_(this.config_.restrictions,
d,Infinity,Infinity);if(b!=Infinity||c!=Infinity){a=this.getResolutionList_(a);a=(0,$jscomp.makeIterator)(a);for(e=a.next();!e.done;e=a.next())if(e=e.value,e.height>=b&&e.width>=c){b=e.height;c=e.width;break}a=this.filterAndSortVariants_(this.config_.restrictions,d,b,c)}b=this.getBandwidthEstimate();d.length&&!a.length&&(shaka.log.warning("No variants met the ABR restrictions. Choosing a variant by lowest bandwidth."),a=this.filterAndSortVariants_(null,d,Infinity,Infinity),a=[a[0]]);c=a[0]||null;
for(d=0;d<a.length;d++){e=a[d];var g=isNaN(this.playbackRate_)?1:Math.abs(this.playbackRate_);f=g*e.bandwidth;for(var h=f/this.config_.bandwidthDowngradeTarget,k={bandwidth:Infinity},l=d+1;l<a.length;l++)if(e.bandwidth!=a[l].bandwidth){k=a[l];break}g=g*k.bandwidth/this.config_.bandwidthUpgradeTarget;shaka.log.v2("Bandwidth ranges:",(f/1E6).toFixed(3),(h/1E6).toFixed(3),(g/1E6).toFixed(3));b>=h&&b<=g&&(c.bandwidth!=e.bandwidth||this.isSameBandwidthAndHigherResolution_(c,e))&&(c=e)}this.lastTimeChosenMs_=
Date.now();return c};shaka.abr.SimpleAbrManager.prototype.enable=function(){this.enabled_=!0};shaka.abr.SimpleAbrManager.prototype.disable=function(){this.enabled_=!1};
shaka.abr.SimpleAbrManager.prototype.segmentDownloaded=function(a,b,c,d,e){e=a;this.config_.removeLatencyFromFirstPacketTime&&d&&d.packetNumber===1&&d.timeToFirstByte&&(e=a-d.timeToFirstByte);e>=this.config_.cacheLoadThreshold&&(shaka.log.v2("Segment downloaded:","contentType="+(d&&d.contentType),"deltaTimeMs="+e,"numBytes="+b,"lastTimeChosenMs="+this.lastTimeChosenMs_,"enabled="+this.enabled_),goog.asserts.assert(e>=0,"expected a non-negative duration"),this.bandwidthEstimator_.sample(e,b));c&&this.lastTimeChosenMs_!=
null&&this.enabled_&&this.suggestStreams_()};shaka.abr.SimpleAbrManager.prototype.trySuggestStreams=function(){this.enabled_&&(this.lastTimeChosenMs_=Date.now(),this.suggestStreams_(!0))};
shaka.abr.SimpleAbrManager.prototype.getBandwidthEstimate=function(){var a=this.getDefaultBandwidth_();if(navigator.connection&&navigator.connection.downlink&&this.config_.useNetworkInformation&&this.config_.preferNetworkInformationBandwidth)return a;a=this.bandwidthEstimator_.getBandwidthEstimate(a);return this.cmsdManager_?this.cmsdManager_.getBandwidthEstimate(a):a};
shaka.abr.SimpleAbrManager.prototype.setVariants=function(a){if(shaka.util.ArrayUtils.hasSameElements(a,this.variants_))return!1;this.variants_=a;return!0};shaka.abr.SimpleAbrManager.prototype.playbackRateChanged=function(a){this.playbackRate_=a};
shaka.abr.SimpleAbrManager.prototype.setMediaElement=function(a){var b=this;this.mediaElement_=a;this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);var c=function(){b.resizeObserverTimer_.tickAfter(shaka.abr.SimpleAbrManager.RESIZE_OBSERVER_BATCH_TIME)};this.mediaElement_&&"ResizeObserver"in window&&(this.resizeObserver_=new ResizeObserver(c),this.resizeObserver_.observe(this.mediaElement_));this.eventManager_.listen(a,"enterpictureinpicture",function(d){d.pictureInPictureWindow&&
(b.pictureInPictureWindow_=d.pictureInPictureWindow,b.eventManager_.listen(b.pictureInPictureWindow_,"resize",c))});this.eventManager_.listen(a,"leavepictureinpicture",function(){b.pictureInPictureWindow_&&b.eventManager_.unlisten(b.pictureInPictureWindow_,"resize",c);b.pictureInPictureWindow_=null})};shaka.abr.SimpleAbrManager.prototype.setCmsdManager=function(a){this.cmsdManager_=a};
shaka.abr.SimpleAbrManager.prototype.configure=function(a){this.config_=a;this.bandwidthEstimator_&&this.config_&&this.bandwidthEstimator_.configure(this.config_.advanced)};
shaka.abr.SimpleAbrManager.prototype.suggestStreams_=function(a){a=a===void 0?!1:a;shaka.log.v2("Suggesting Streams...");goog.asserts.assert(this.lastTimeChosenMs_!=null,"lastTimeChosenMs_ should not be null");if(!a){if(!this.startupComplete_){if(!this.bandwidthEstimator_.hasGoodEstimate()){shaka.log.v2("Still waiting for a good estimate...");return}this.startupComplete_=!0;this.lastTimeChosenMs_-=(this.config_.switchInterval-this.config_.minTimeToSwitch)*1E3}if(Date.now()-this.lastTimeChosenMs_<
this.config_.switchInterval*1E3){shaka.log.v2("Still within switch interval...");return}}a=this.chooseVariant();var b=this.getBandwidthEstimate();b=Math.round(b/1E3);a&&(shaka.log.debug("Calling switch_(), bandwidth="+b+" kbps"),this.switch_(a,this.config_.clearBufferSwitch,this.config_.safeMarginSwitch))};
shaka.abr.SimpleAbrManager.prototype.getDefaultBandwidth_=function(){var a=this.config_.defaultBandwidthEstimate;navigator.connection&&navigator.connection.downlink&&this.config_.useNetworkInformation&&(a=navigator.connection.downlink*1E6);return a};
shaka.abr.SimpleAbrManager.prototype.filterAndSortVariants_=function(a,b,c,d){if(this.cmsdManager_){var e=this.cmsdManager_.getMaxBitrate();e&&(b=b.filter(function(f){return f.bandwidth&&e?f.bandwidth<=e:!0}))}a&&(b=b.filter(function(f){goog.asserts.assert(a,"Restrictions should exist!");return shaka.util.StreamUtils.meetsRestrictions(f,a,{width:d,height:c})}));return b.sort(function(f,g){return f.bandwidth-g.bandwidth})};
shaka.abr.SimpleAbrManager.prototype.getResolutionList_=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())(c=c.value.video)&&c.height&&c.width&&b.push({height:c.height,width:c.width});return b.sort(function(d,e){return d.width-e.width})};shaka.abr.SimpleAbrManager.prototype.isSameBandwidthAndHigherResolution_=function(a,b){return a.bandwidth==b.bandwidth&&a.video&&b.video?a.video.width<b.video.width||a.video.height<b.video.height:!1};
goog.exportSymbol("shaka.abr.SimpleAbrManager",shaka.abr.SimpleAbrManager);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"configure",shaka.abr.SimpleAbrManager.prototype.configure);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setCmsdManager",shaka.abr.SimpleAbrManager.prototype.setCmsdManager);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setMediaElement",shaka.abr.SimpleAbrManager.prototype.setMediaElement);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"playbackRateChanged",shaka.abr.SimpleAbrManager.prototype.playbackRateChanged);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setVariants",shaka.abr.SimpleAbrManager.prototype.setVariants);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"getBandwidthEstimate",shaka.abr.SimpleAbrManager.prototype.getBandwidthEstimate);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"trySuggestStreams",shaka.abr.SimpleAbrManager.prototype.trySuggestStreams);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"segmentDownloaded",shaka.abr.SimpleAbrManager.prototype.segmentDownloaded);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"disable",shaka.abr.SimpleAbrManager.prototype.disable);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"enable",shaka.abr.SimpleAbrManager.prototype.enable);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"chooseVariant",shaka.abr.SimpleAbrManager.prototype.chooseVariant);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"init",shaka.abr.SimpleAbrManager.prototype.init);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"release",shaka.abr.SimpleAbrManager.prototype.release);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"stop",shaka.abr.SimpleAbrManager.prototype.stop);shaka.abr.SimpleAbrManager.RESIZE_OBSERVER_BATCH_TIME=1;shaka.cea.CeaUtils=function(){};
shaka.cea.CeaUtils.getParsedCaption=function(a,b,c,d,e){if(d>=e)return null;for(var f=-1,g=-1,h=0;h<c.length;h++)if(c[h].some(function(z){return z!=null&&z.getChar().trim()!=""})){f=h;break}for(h=c.length-1;h>=0;h--)if(c[h].some(function(z){return z!=null&&z.getChar().trim()!=""})){g=h;break}if(f===-1||g===-1)return null;for(var k=h=!1,l=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR,m=shaka.cea.CeaUtils.DEFAULT_BG_COLOR,n=shaka.cea.CeaUtils.createStyledCue(d,e,h,k,l,m);f<=g;f++){for(var p=c[f],q=-1,r=-1,t=
0;t<p.length;t++)if(p[t]!=null&&p[t].getChar().trim()!==""){q=t;break}for(t=p.length-1;t>=0;t--)if(p[t]!=null&&p[t].getChar().trim()!==""){r=t;break}if(q===-1||r===-1)p=shaka.cea.CeaUtils.createLineBreakCue(d,e),a.nestedCues.push(p);else{for(;q<=r;q++)if(t=p[q]){var w=t.isUnderlined(),v=t.isItalicized(),u=t.getTextColor(),x=t.getBackgroundColor();if(w!=h||v!=k||u!=l||x!=m)n.payload&&a.nestedCues.push(n),n=shaka.cea.CeaUtils.createStyledCue(d,e,w,v,u,x),h=w,k=v,l=u,m=x;n.payload+=t.getChar()}else n.payload+=
" ";n.payload&&a.nestedCues.push(n);f!==g&&(n=shaka.cea.CeaUtils.createLineBreakCue(d,e),a.nestedCues.push(n));n=shaka.cea.CeaUtils.createStyledCue(d,e,h,k,l,m)}}return a.nestedCues.length?{cue:a,stream:b}:null};shaka.cea.CeaUtils.createStyledCue=function(a,b,c,d,e,f){a=new shaka.text.Cue(a,b,"");c&&a.textDecoration.push(shaka.text.Cue.textDecoration.UNDERLINE);d&&(a.fontStyle=shaka.text.Cue.fontStyle.ITALIC);a.color=e;a.backgroundColor=f;return a};
shaka.cea.CeaUtils.createLineBreakCue=function(a,b){a=new shaka.text.Cue(a,b,"");a.lineBreak=!0;return a};shaka.cea.CeaUtils.StyledChar=function(a,b,c,d,e){this.character_=a;this.underline_=b;this.italics_=c;this.backgroundColor_=d;this.textColor_=e};shaka.cea.CeaUtils.StyledChar.prototype.getChar=function(){return this.character_};shaka.cea.CeaUtils.StyledChar.prototype.isUnderlined=function(){return this.underline_};shaka.cea.CeaUtils.StyledChar.prototype.isItalicized=function(){return this.italics_};
shaka.cea.CeaUtils.StyledChar.prototype.getBackgroundColor=function(){return this.backgroundColor_};shaka.cea.CeaUtils.StyledChar.prototype.getTextColor=function(){return this.textColor_};shaka.cea.CeaUtils.DEFAULT_BG_COLOR="black";shaka.cea.CeaUtils.DEFAULT_TXT_COLOR="white";shaka.cea.CeaUtils.H264_NALU_TYPE_SEI=6;shaka.cea.CeaUtils.H265_PREFIX_NALU_TYPE_SEI=39;shaka.cea.CeaUtils.H265_SUFFIX_NALU_TYPE_SEI=40;shaka.cea.CeaUtils.H266_PREFIX_NALU_TYPE_SEI=23;
shaka.cea.CeaUtils.H266_SUFFIX_NALU_TYPE_SEI=24;shaka.cea.CeaUtils.DEFAULT_TIMESCALE_VALUE=9E4;shaka.cea.Cea608Memory=function(a,b){this.rows_=[];this.row_=1;this.scrollRows_=0;this.fieldNum_=a;this.channelNum_=b;this.italics_=this.underline_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;this.indent_=this.offset_=null;this.reset()};
shaka.cea.Cea608Memory.prototype.forceEmit=function(a,b){var c=shaka.cea.Cea608Memory,d="CC"+((this.fieldNum_<<1|this.channelNum_)+1),e=new shaka.text.Cue(a,b,"");e.lineInterpretation=shaka.text.Cue.lineInterpretation.PERCENTAGE;var f=c.ROW_TO_LINE_CONVERSION_.get(this.row_);f&&(e.line=f);this.indent_!=null&&this.offset_!=null&&(e.position=10+Math.min(70,this.indent_*10)+this.offset_*2.5);(a=shaka.cea.CeaUtils.getParsedCaption(e,d,this.rows_,a,b))&&this.row_+a.cue.nestedCues.length-3>15&&(f=c.ROW_TO_LINE_CONVERSION_.get(this.row_+
3-a.cue.nestedCues.length))&&(e.line=f);return a};shaka.cea.Cea608Memory.prototype.reset=function(){this.resetAllRows();this.row_=1};shaka.cea.Cea608Memory.prototype.getRow=function(){return this.row_};shaka.cea.Cea608Memory.prototype.setRow=function(a){this.row_=a};shaka.cea.Cea608Memory.prototype.getScrollSize=function(){return this.scrollRows_};shaka.cea.Cea608Memory.prototype.setScrollSize=function(a){this.scrollRows_=a};
shaka.cea.Cea608Memory.prototype.addChar=function(a,b){if(!(b<32||b>127)){var c="";switch(a){case shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN:c=shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars.has(b)?shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars.get(b):String.fromCharCode(b);break;case shaka.cea.Cea608Memory.CharSet.SPECIAL_NORTH_AMERICAN:c=shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars.get(b);break;case shaka.cea.Cea608Memory.CharSet.SPANISH_FRENCH:this.eraseChar();
c=shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench.get(b);break;case shaka.cea.Cea608Memory.CharSet.PORTUGUESE_GERMAN:this.eraseChar(),c=shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman.get(b)}c&&(a=new shaka.cea.CeaUtils.StyledChar(c,this.underline_,this.italics_,this.backgroundColor_,this.textColor_),this.rows_[this.row_].push(a))}};shaka.cea.Cea608Memory.prototype.eraseChar=function(){this.rows_[this.row_].pop()};
shaka.cea.Cea608Memory.prototype.moveRows=function(a,b,c){if(!(b<0||a<0))if(a>=b)for(--c;c>=0;c--)this.rows_[a+c]=this.rows_[b+c].map(function(e){return e});else for(var d=0;d<c;d++)this.rows_[a+d]=this.rows_[b+d].map(function(e){return e})};shaka.cea.Cea608Memory.prototype.resetRows=function(a,b){for(var c=0;c<=b;c++)this.rows_[a+c]=[]};shaka.cea.Cea608Memory.prototype.resetAllRows=function(){this.resetRows(0,shaka.cea.Cea608Memory.CC_ROWS)};
shaka.cea.Cea608Memory.prototype.eraseBuffer=function(){this.row_=this.scrollRows_>0?this.scrollRows_:0;this.resetAllRows()};shaka.cea.Cea608Memory.prototype.setUnderline=function(a){this.underline_=a};shaka.cea.Cea608Memory.prototype.setItalics=function(a){this.italics_=a};shaka.cea.Cea608Memory.prototype.setTextColor=function(a){this.textColor_=a};shaka.cea.Cea608Memory.prototype.setBackgroundColor=function(a){this.backgroundColor_=a};
shaka.cea.Cea608Memory.prototype.setOffset=function(a){this.offset_=a};shaka.cea.Cea608Memory.prototype.setIndent=function(a){this.indent_=a};shaka.cea.Cea608Memory.CC_ROWS=15;shaka.cea.Cea608Memory.CharSet={BASIC_NORTH_AMERICAN:0,SPECIAL_NORTH_AMERICAN:1,SPANISH_FRENCH:2,PORTUGUESE_GERMAN:3};
shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars=new Map([[39,"\u2019"],[42,"\u00e1"],[92,"\u00e9"],[92,"\u00e9"],[94,"\u00ed"],[95,"\u00f3"],[96,"\u00fa"],[123,"\u00e7"],[124,"\u00f7"],[125,"\u00d1"],[126,"\u00f1"],[127,"\u2588"]]);
shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars=new Map([[48,"\u00ae"],[49,"\u00b0"],[50,"\u00bd"],[51,"\u00bf"],[52,"\u2122"],[53,"\u00a2"],[54,"\u00a3"],[55,"\u266a"],[56,"\u00e0"],[57," "],[58,"\u00e8"],[59,"\u00e2"],[60,"\u00ea"],[61,"\u00ee"],[62,"\u00f4"],[63,"\u00fb"]]);
shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench=new Map([[32,"\u00c1"],[33,"\u00c9"],[34,"\u00d3"],[35,"\u00da"],[36,"\u00dc"],[37,"\u00fc"],[38,"\u2018"],[39,"\u00a1"],[40,"*"],[41,"'"],[42,"\u2500"],[43,"\u00a9"],[44,"\u2120"],[45,"\u00b7"],[46,"\u201c"],[47,"\u201d"],[48,"\u00c0"],[49,"\u00c2"],[50,"\u00c7"],[51,"\u00c8"],[52,"\u00ca"],[53,"\u00cb"],[54,"\u00eb"],[55,"\u00ce"],[56,"\u00cf"],[57,"\u00ef"],[58,"\u00d4"],[59,"\u00d9"],[60,"\u00f9"],[61,"\u00db"],[62,"\u00ab"],[63,"\u00bb"]]);
shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman=new Map([[32,"\u00c3"],[33,"\u00e3"],[34,"\u00cd"],[35,"\u00cc"],[36,"\u00ec"],[37,"\u00d2"],[38,"\u00f2"],[39,"\u00d5"],[40,"\u00f5"],[41,"{"],[42,"}"],[43,"\\"],[44,"^"],[45,"_"],[46,"|"],[47,"~"],[48,"\u00c4"],[49,"\u00e4"],[50,"\u00d6"],[51,"\u00f6"],[52,"\u00df"],[53,"\u00a5"],[54,"\u00a4"],[55,"\u2502"],[56,"\u00c5"],[57,"\u00e5"],[58,"\u00d8"],[59,"\u00f8"],[60,"\u250c"],[61,"\u2510"],[62,"\u2514"],[63,"\u2518"]]);
shaka.cea.Cea608Memory.ROW_TO_LINE_CONVERSION_=new Map([[1,10],[2,15.33],[3,20.66],[4,26],[5,31.33],[6,36.66],[7,42],[8,47.33],[9,52.66],[10,58],[11,63.33],[12,68.66],[13,74],[14,79.33],[15,84.66]]);shaka.cea.Cea608DataChannel=function(a,b){this.type_=shaka.cea.Cea608DataChannel.CaptionType.NONE;this.text_=new shaka.cea.Cea608Memory(a,b);this.displayedMemory_=new shaka.cea.Cea608Memory(a,b);this.curBuf_=this.nonDisplayedMemory_=new shaka.cea.Cea608Memory(a,b);this.prevEndTime_=0;this.lastCp_=null};
shaka.cea.Cea608DataChannel.prototype.reset=function(){this.type_=shaka.cea.Cea608DataChannel.CaptionType.NONE;this.curBuf_=this.nonDisplayedMemory_;this.lastCp_=null;this.displayedMemory_.reset();this.nonDisplayedMemory_.reset();this.text_.reset()};shaka.cea.Cea608DataChannel.prototype.firstPts=function(a){this.prevEndTime_=a};shaka.cea.Cea608DataChannel.prototype.pacToRow_=function(a,b){return[11,11,1,2,3,4,12,13,14,15,5,6,7,8,9,10][(a&7)<<1|b>>5&1]};
shaka.cea.Cea608DataChannel.prototype.controlPac_=function(a,b){a=this.pacToRow_(a,b);var c=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR,d=!1,e=null;var f=b>95?b-96:b-64;f<=13?c=shaka.cea.Cea608DataChannel.TEXT_COLORS[Math.floor(f/2)]:f<=15?d=!0:e=Math.floor((f-16)/2);b=(b&1)===1;if(this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT){f=this.curBuf_;if(this.type_===shaka.cea.Cea608DataChannel.CaptionType.ROLLUP&&a!==f.getRow()){var g=1+f.getRow()-f.getScrollSize(),h=1+a-f.getScrollSize();f.moveRows(h,
g,f.getScrollSize());f.resetRows(0,h-1);f.resetRows(a+1,shaka.cea.Cea608Memory.CC_ROWS-a)}f.setRow(a);f.setUnderline(b);f.setItalics(d);f.setTextColor(c);f.setIndent(e);f.setBackgroundColor(shaka.cea.CeaUtils.DEFAULT_BG_COLOR)}};
shaka.cea.Cea608DataChannel.prototype.controlMidrow_=function(a){this.curBuf_.setUnderline(!1);this.curBuf_.setItalics(!1);this.curBuf_.setTextColor(shaka.cea.CeaUtils.DEFAULT_TXT_COLOR);this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,32);var b=!1;var c=shaka.cea.Cea608DataChannel.TEXT_COLORS[(a&14)>>1];c==="white_italics"&&(c="white",b=!0);this.curBuf_.setUnderline((a&1)===1);this.curBuf_.setItalics(b);this.curBuf_.setTextColor(c)};
shaka.cea.Cea608DataChannel.prototype.controlBackgroundAttribute_=function(a,b){var c=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;(a&7)===0&&(c=shaka.cea.Cea608DataChannel.BG_COLORS[(b&14)>>1]);this.curBuf_.setBackgroundColor(c)};
shaka.cea.Cea608DataChannel.prototype.controlMiscellaneous_=function(a){var b=shaka.cea.Cea608DataChannel.MiscCmd_,c=a.pts,d=null;switch(a.ccData2){case b.RCL:this.controlRcl_();break;case b.BS:this.controlBs_();break;case b.AOD:case b.AON:break;case b.DER:break;case b.RU2:d=this.controlRu_(2,c);break;case b.RU3:d=this.controlRu_(3,c);break;case b.RU4:d=this.controlRu_(4,c);break;case b.FON:this.controlFon_();break;case b.RDC:this.controlRdc_(c);break;case b.TR:this.controlTr_();break;case b.RTD:this.controlRtd_();
break;case b.EDM:d=this.controlEdm_(c);break;case b.CR:d=this.controlCr_(c);break;case b.ENM:this.controlEnm_();break;case b.EOC:d=this.controlEoc_(c)}return d};
shaka.cea.Cea608DataChannel.prototype.controlCr_=function(a){var b=this.curBuf_;if(this.type_!==shaka.cea.Cea608DataChannel.CaptionType.ROLLUP)return null;var c=b.forceEmit(this.prevEndTime_,a),d=b.getRow()-b.getScrollSize()+1;b.moveRows(d-1,d,b.getScrollSize());b.resetRows(0,d-1);b.resetRows(b.getRow(),shaka.cea.Cea608Memory.CC_ROWS-b.getRow());this.prevEndTime_=a;return c};
shaka.cea.Cea608DataChannel.prototype.controlRu_=function(a,b){var c=this.curBuf_=this.displayedMemory_,d=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.ROLLUP&&this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(d=c.forceEmit(this.prevEndTime_,b),this.displayedMemory_.eraseBuffer(),this.nonDisplayedMemory_.eraseBuffer(),c.setRow(shaka.cea.Cea608Memory.CC_ROWS));this.type_=shaka.cea.Cea608DataChannel.CaptionType.ROLLUP;c.setScrollSize(a);return d};
shaka.cea.Cea608DataChannel.prototype.controlFon_=function(){this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,32)};shaka.cea.Cea608DataChannel.prototype.controlEdm_=function(a){var b=this.displayedMemory_,c=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(c=b.forceEmit(this.prevEndTime_,a));b.resetAllRows();return c};
shaka.cea.Cea608DataChannel.prototype.controlRdc_=function(a){this.type_=shaka.cea.Cea608DataChannel.CaptionType.PAINTON;this.curBuf_=this.displayedMemory_;this.curBuf_.setScrollSize(0);this.prevEndTime_=a};shaka.cea.Cea608DataChannel.prototype.controlEnm_=function(){this.nonDisplayedMemory_.resetAllRows()};
shaka.cea.Cea608DataChannel.prototype.controlEoc_=function(a){var b=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(b=this.displayedMemory_.forceEmit(this.prevEndTime_,a));var c=this.nonDisplayedMemory_;this.nonDisplayedMemory_=this.displayedMemory_;this.displayedMemory_=c;this.controlRcl_();this.prevEndTime_=a;return b};shaka.cea.Cea608DataChannel.prototype.controlRcl_=function(){this.type_=shaka.cea.Cea608DataChannel.CaptionType.POPON;this.curBuf_=this.nonDisplayedMemory_;this.curBuf_.setScrollSize(0)};
shaka.cea.Cea608DataChannel.prototype.controlBs_=function(){this.curBuf_.eraseChar()};shaka.cea.Cea608DataChannel.prototype.controlTr_=function(){this.text_.reset();this.controlRtd_()};shaka.cea.Cea608DataChannel.prototype.controlRtd_=function(){shaka.log.warnOnce("Cea608DataChannel","CEA-608 text mode entered, but is unsupported");this.curBuf_=this.text_;this.type_=shaka.cea.Cea608DataChannel.CaptionType.TEXT};
shaka.cea.Cea608DataChannel.prototype.handleBasicNorthAmericanChar=function(a,b){this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,a);this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,b)};shaka.cea.Cea608DataChannel.prototype.handleExtendedWesternEuropeanChar_=function(a,b){this.curBuf_.addChar(a&1?shaka.cea.Cea608Memory.CharSet.PORTUGUESE_GERMAN:shaka.cea.Cea608Memory.CharSet.SPANISH_FRENCH,b)};shaka.cea.Cea608DataChannel.prototype.handleOffset_=function(a){this.curBuf_.setOffset(a)};
shaka.cea.Cea608DataChannel.prototype.handleControlCode=function(a){var b=a.ccData1,c=a.ccData2;if(this.lastCp_===(b<<8|c))return this.lastCp_=null;this.lastCp_=b<<8|c;if(this.isPAC_(b,c))this.controlPac_(b,c);else if(this.isMidrowStyleChange_(b,c))this.controlMidrow_(c);else if(this.isBackgroundAttribute_(b,c))this.controlBackgroundAttribute_(b,c);else if(this.isSpecialNorthAmericanChar_(b,c))this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.SPECIAL_NORTH_AMERICAN,c);else if(this.isExtendedWesternEuropeanChar_(b,
c))this.handleExtendedWesternEuropeanChar_(b,c);else{if(this.isMiscellaneous_(b,c))return this.controlMiscellaneous_(a);this.isOffset_(b,c)&&this.handleOffset_(c-32)}return null};shaka.cea.Cea608DataChannel.prototype.isMiscellaneous_=function(a,b){return(a&246)===20&&(b&240)===32};shaka.cea.Cea608DataChannel.prototype.isOffset_=function(a,b){return(a==23||a==31)&&b>=33&&b<=35};shaka.cea.Cea608DataChannel.prototype.isPAC_=function(a,b){return(a&240)===16&&(b&192)===64};
shaka.cea.Cea608DataChannel.prototype.isMidrowStyleChange_=function(a,b){return(a&247)===17&&(b&240)===32};shaka.cea.Cea608DataChannel.prototype.isBackgroundAttribute_=function(a,b){return(a&247)===16&&(b&240)===32||(a&247)===23&&(b&255)===45};shaka.cea.Cea608DataChannel.prototype.isSpecialNorthAmericanChar_=function(a,b){return(a&247)===17&&(b&240)===48};shaka.cea.Cea608DataChannel.prototype.isExtendedWesternEuropeanChar_=function(a,b){return(a&246)===18&&(b&224)===32};
shaka.cea.Cea608DataChannel.isControlCode=function(a){return(a&112)===16};shaka.cea.Cea608DataChannel.isXdsControlCode=function(a){return a>=1&&a<=15};shaka.cea.Cea608DataChannel.MiscCmd_={RCL:32,BS:33,AOD:34,AON:35,DER:36,RU2:37,RU3:38,RU4:39,FON:40,RDC:41,TR:42,RTD:43,EDM:44,CR:45,ENM:46,EOC:47};shaka.cea.Cea608DataChannel.CaptionType={NONE:0,POPON:1,PAINTON:2,ROLLUP:3,TEXT:4};shaka.cea.Cea608DataChannel.BG_COLORS="black green blue cyan red yellow magenta black".split(" ");
shaka.cea.Cea608DataChannel.TEXT_COLORS="white green blue cyan red yellow magenta white_italics".split(" ");shaka.cea.Cea708Window=function(a,b){this.parentService_=b;this.windowNum_=a;this.relativeToggle_=this.visible_=!1;this.colCount_=this.rowCount_=this.anchorId_=this.verticalAnchor_=this.horizontalAnchor_=0;this.justification_=shaka.cea.Cea708Window.TextJustification.CENTER;this.memory_=[];this.col_=this.row_=this.startTime_=0;this.underline_=this.italics_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;this.resetMemory()};
shaka.cea.Cea708Window.prototype.defineWindow=function(a,b,c,d,e,f,g){this.visible_=a;this.verticalAnchor_=b;this.horizontalAnchor_=c;this.anchorId_=d;this.relativeToggle_=e;this.rowCount_=f;this.colCount_=g};shaka.cea.Cea708Window.prototype.resetMemory=function(){this.memory_=[];for(var a=0;a<shaka.cea.Cea708Window.MAX_ROWS;a++)this.memory_.push(this.createNewRow_())};shaka.cea.Cea708Window.prototype.createNewRow_=function(){for(var a=[],b=0;b<shaka.cea.Cea708Window.MAX_COLS;b++)a.push(null);return a};
shaka.cea.Cea708Window.prototype.setCharacter=function(a){this.isPenInBounds_()&&(a=new shaka.cea.CeaUtils.StyledChar(a,this.underline_,this.italics_,this.backgroundColor_,this.textColor_),this.memory_[this.row_][this.col_]=a,this.col_++)};shaka.cea.Cea708Window.prototype.backspace=function(){!this.isPenInBounds_()||this.col_<=0&&this.row_<=0||(this.col_<=0?(this.col_=this.colCount_-1,this.row_--):this.col_--,this.memory_[this.row_][this.col_]=null)};
shaka.cea.Cea708Window.prototype.isPenInBounds_=function(){var a=this.col_<this.colCount_&&this.col_>=0;return this.row_<this.rowCount_&&this.row_>=0&&a};shaka.cea.Cea708Window.prototype.isVisible=function(){return this.visible_};shaka.cea.Cea708Window.prototype.moveUpRows_=function(a){for(var b=0,c=a;c<shaka.cea.Cea708Window.MAX_ROWS;c++,b++)this.memory_[b]=this.memory_[c];for(c=0;c<a;c++,b++)this.memory_[b]=this.createNewRow_()};
shaka.cea.Cea708Window.prototype.carriageReturn=function(){this.row_+1>=this.rowCount_?this.moveUpRows_(1):this.row_++;this.col_=0};shaka.cea.Cea708Window.prototype.horizontalCarriageReturn=function(){this.memory_[this.row_]=this.createNewRow_();this.col_=0};
shaka.cea.Cea708Window.prototype.forceEmit=function(a,b){b="svc"+b;var c=shaka.cea.Cea708Window.TextJustification,d=new shaka.text.Cue(this.startTime_,a,"");d.textAlign=this.justification_===c.LEFT?shaka.text.Cue.textAlign.LEFT:this.justification_===c.RIGHT?shaka.text.Cue.textAlign.RIGHT:shaka.text.Cue.textAlign.CENTER;this.adjustRegion_(d.region);(b=shaka.cea.CeaUtils.getParsedCaption(d,b,this.memory_,this.startTime_,a))&&this.setStartTime(a);return b};
shaka.cea.Cea708Window.prototype.setPenLocation=function(a,b){this.row_=a;this.col_=b};shaka.cea.Cea708Window.prototype.setPenBackgroundColor=function(a){this.backgroundColor_=a};shaka.cea.Cea708Window.prototype.setPenTextColor=function(a){this.textColor_=a};shaka.cea.Cea708Window.prototype.setPenUnderline=function(a){this.underline_=a};shaka.cea.Cea708Window.prototype.setPenItalics=function(a){this.italics_=a};
shaka.cea.Cea708Window.prototype.resetPen=function(){this.col_=this.row_=0;this.italics_=this.underline_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR};shaka.cea.Cea708Window.prototype.setJustification=function(a){this.justification_=a};shaka.cea.Cea708Window.prototype.display=function(){this.visible_=!0};shaka.cea.Cea708Window.prototype.hide=function(){this.visible_=!1};
shaka.cea.Cea708Window.prototype.toggle=function(){this.visible_=!this.visible_};shaka.cea.Cea708Window.prototype.setStartTime=function(a){this.startTime_=a};
shaka.cea.Cea708Window.prototype.adjustRegion_=function(a){this.parentService_&&(a.id+="svc"+this.parentService_);a.id+="win"+this.windowNum_;a.height=this.rowCount_;a.width=this.colCount_;a.heightUnits=shaka.text.CueRegion.units.LINES;a.widthUnits=shaka.text.CueRegion.units.LINES;a.viewportAnchorX=this.horizontalAnchor_;a.viewportAnchorY=this.verticalAnchor_;a.viewportAnchorUnits=this.relativeToggle_?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.LINES;var b=shaka.cea.Cea708Window.AnchorId;
switch(this.anchorId_){case b.UPPER_LEFT:a.regionAnchorX=0;a.regionAnchorY=0;break;case b.UPPER_CENTER:a.regionAnchorX=50;a.regionAnchorY=0;break;case b.UPPER_RIGHT:a.regionAnchorX=100;a.regionAnchorY=0;break;case b.MIDDLE_LEFT:a.regionAnchorX=0;a.regionAnchorY=50;break;case b.MIDDLE_CENTER:a.regionAnchorX=50;a.regionAnchorY=50;break;case b.MIDDLE_RIGHT:a.regionAnchorX=100;a.regionAnchorY=50;break;case b.LOWER_LEFT:a.regionAnchorX=0;a.regionAnchorY=100;break;case b.LOWER_CENTER:a.regionAnchorX=50;
a.regionAnchorY=100;break;case b.LOWER_RIGHT:a.regionAnchorX=100,a.regionAnchorY=100}};shaka.cea.Cea708Window.TextJustification={LEFT:0,RIGHT:1,CENTER:2,FULL:3};shaka.cea.Cea708Window.AnchorId={UPPER_LEFT:0,UPPER_CENTER:1,UPPER_RIGHT:2,MIDDLE_LEFT:3,MIDDLE_CENTER:4,MIDDLE_RIGHT:5,LOWER_LEFT:6,LOWER_CENTER:7,LOWER_RIGHT:8};shaka.cea.Cea708Window.MAX_COLS=42;shaka.cea.Cea708Window.MAX_ROWS=16;shaka.cea.DtvccPacketBuilder=function(){this.builtPackets_=[];this.currentPacketBeingBuilt_=null;this.bytesLeftToAddInCurrentPacket_=0};
shaka.cea.DtvccPacketBuilder.prototype.addByte=function(a){a.type===shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_START?(this.bytesLeftToAddInCurrentPacket_=(a.value&63)*2-1,this.currentPacketBeingBuilt_=[]):this.currentPacketBeingBuilt_&&(this.bytesLeftToAddInCurrentPacket_>0&&(this.currentPacketBeingBuilt_.push(a),this.bytesLeftToAddInCurrentPacket_--),this.bytesLeftToAddInCurrentPacket_===0&&(a=new shaka.cea.DtvccPacket(this.currentPacketBeingBuilt_),this.builtPackets_.push(a),this.currentPacketBeingBuilt_=
null,this.bytesLeftToAddInCurrentPacket_=0))};shaka.cea.DtvccPacketBuilder.prototype.getBuiltPackets=function(){return this.builtPackets_};shaka.cea.DtvccPacketBuilder.prototype.clearBuiltPackets=function(){this.builtPackets_=[]};shaka.cea.DtvccPacketBuilder.prototype.clear=function(){this.builtPackets_=[];this.currentPacketBeingBuilt_=[];this.bytesLeftToAddInCurrentPacket_=0};shaka.cea.DtvccPacket=function(a){this.pos_=0;this.packetData_=a};
shaka.cea.DtvccPacket.prototype.hasMoreData=function(){return this.pos_<this.packetData_.length};shaka.cea.DtvccPacket.prototype.getPosition=function(){return this.pos_};shaka.cea.DtvccPacket.prototype.readByte=function(){if(!this.hasMoreData())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);return this.packetData_[this.pos_++]};
shaka.cea.DtvccPacket.prototype.skip=function(a){if(this.pos_+a>this.packetData_.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);this.pos_+=a};shaka.cea.DtvccPacket.prototype.rewind=function(a){if(this.pos_-a<0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);this.pos_-=a};
shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_DATA=2;shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_START=3;shaka.cea.Cea708Service=function(a){this.serviceNumber_=a;this.windows_=[null,null,null,null,null,null,null,null];this.currentWindow_=null};
shaka.cea.Cea708Service.prototype.handleCea708ControlCode=function(a){var b=a.readByte(),c=b.value;b=b.pts;if(c===shaka.cea.Cea708Service.EXT_CEA708_CTRL_CODE_BYTE1){var d=a.readByte();c=c<<16|d.value}if(c>=0&&c<=31)return this.handleC0_(a,c,b);if(c>=128&&c<=159)return this.handleC1_(a,c,b);c>=4096&&c<=4127?this.handleC2_(a,c&255):c>=4224&&c<=4255?this.handleC3_(a,c&255):c>=32&&c<=127?this.handleG0_(c):c>=160&&c<=255?this.handleG1_(c):c>=4128&&c<=4223?this.handleG2_(c&255):c>=4256&&c<=4351&&this.handleG3_(c&
255);return[]};shaka.cea.Cea708Service.prototype.handleG0_=function(a){this.currentWindow_&&(a===127?this.currentWindow_.setCharacter("\u266a"):this.currentWindow_.setCharacter(String.fromCharCode(a)))};shaka.cea.Cea708Service.prototype.handleG1_=function(a){this.currentWindow_&&this.currentWindow_.setCharacter(String.fromCharCode(a))};
shaka.cea.Cea708Service.prototype.handleG2_=function(a){this.currentWindow_&&(shaka.cea.Cea708Service.G2Charset.has(a)?(a=shaka.cea.Cea708Service.G2Charset.get(a),this.currentWindow_.setCharacter(a)):this.currentWindow_.setCharacter("_"))};shaka.cea.Cea708Service.prototype.handleG3_=function(a){this.currentWindow_&&(a!=160?this.currentWindow_.setCharacter("_"):this.currentWindow_.setCharacter("[CC]"))};
shaka.cea.Cea708Service.prototype.handleC0_=function(a,b,c){if(!this.currentWindow_)return[];if(b==24)return b=a.readByte().value,c=a.readByte().value,b=function(e){return e.map(function(f){return("0"+(f&255).toString(16)).slice(-2)}).join("")}([b,c]),b=String.fromCharCode(parseInt(b,16)),this.currentWindow_.setCharacter(b),[];a=this.currentWindow_;var d=null;switch(b){case shaka.cea.Cea708Service.ASCII_BACKSPACE:a.backspace();break;case shaka.cea.Cea708Service.ASCII_CARRIAGE_RETURN:a.isVisible()&&
(d=a.forceEmit(c,this.serviceNumber_));a.carriageReturn();break;case shaka.cea.Cea708Service.ASCII_HOR_CARRIAGE_RETURN:a.isVisible()&&(d=a.forceEmit(c,this.serviceNumber_));a.horizontalCarriageReturn();break;case shaka.cea.Cea708Service.ASCII_FORM_FEED:a.isVisible()&&(d=a.forceEmit(c,this.serviceNumber_)),a.resetMemory(),a.setPenLocation(0,0)}return d?[d]:[]};
shaka.cea.Cea708Service.prototype.handleC1_=function(a,b,c){if(b>=128&&b<=135)this.setCurrentWindow_(b&7);else{if(b===136)return a=a.readByte().value,this.clearWindows_(a,c);if(b===137)a=a.readByte().value,this.displayWindows_(a,c);else{if(b===138)return a=a.readByte().value,this.hideWindows_(a,c);if(b===139)return a=a.readByte().value,this.toggleWindows_(a,c);if(b===140)return a=a.readByte().value,this.deleteWindows_(a,c);if(b===143)return this.reset_(c);b===144?this.setPenAttributes_(a):b===145?
this.setPenColor_(a):b===146?this.setPenLocation_(a):b===151?this.setWindowAttributes_(a):b>=152&&b<=159&&this.defineWindow_(a,(b&15)-8,c)}}return[]};shaka.cea.Cea708Service.prototype.handleC2_=function(a,b){b>=8&&b<=15?a.skip(1):b>=16&&b<=23?a.skip(2):b>=24&&b<=31&&a.skip(3)};shaka.cea.Cea708Service.prototype.handleC3_=function(a,b){b>=128&&b<=135?a.skip(4):b>=136&&b<=143&&a.skip(5)};shaka.cea.Cea708Service.prototype.setCurrentWindow_=function(a){this.windows_[a]&&(this.currentWindow_=this.windows_[a])};
shaka.cea.Cea708Service.prototype.getSpecifiedWindowIds_=function(a){for(var b=[],c=0;c<8;c++)(a&1)===1&&this.windows_[c]&&b.push(c),a>>=1;return b};shaka.cea.Cea708Service.prototype.clearWindows_=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next()){d=this.windows_[d.value];if(d.isVisible()){var e=d.forceEmit(b,this.serviceNumber_);e&&c.push(e)}d.resetMemory()}return c};
shaka.cea.Cea708Service.prototype.displayWindows_=function(a,b){a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var c=a.next();!c.done;c=a.next())c=this.windows_[c.value],c.isVisible()||c.setStartTime(b),c.display()};
shaka.cea.Cea708Service.prototype.hideWindows_=function(a,b){var c=null;a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next())d=this.windows_[d.value],d.isVisible()&&(c=d.forceEmit(b,this.serviceNumber_)),d.hide();return c?[c]:[]};
shaka.cea.Cea708Service.prototype.toggleWindows_=function(a,b){var c=null;a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next())d=this.windows_[d.value],d.isVisible()?c=d.forceEmit(b,this.serviceNumber_):d.setStartTime(b),d.toggle();return c?[c]:[]};
shaka.cea.Cea708Service.prototype.deleteWindows_=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next()){d=d.value;var e=this.windows_[d];e.isVisible()&&(e=e.forceEmit(b,this.serviceNumber_))&&c.push(e);this.windows_[d]=null}return c};shaka.cea.Cea708Service.prototype.reset_=function(a){a=this.deleteWindows_(255,a);this.clear();return a};
shaka.cea.Cea708Service.prototype.clear=function(){this.currentWindow_=null;this.windows_=[null,null,null,null,null,null,null,null]};shaka.cea.Cea708Service.prototype.setPenAttributes_=function(a){a.skip(1);a=a.readByte().value;if(this.currentWindow_){var b=(a&64)>0;this.currentWindow_.setPenItalics((a&128)>0);this.currentWindow_.setPenUnderline(b)}};
shaka.cea.Cea708Service.prototype.setPenColor_=function(a){var b=a.readByte().value,c=a.readByte().value;a.skip(1);if(this.currentWindow_){a=c&3;var d=(c&12)>>2;c=(c&48)>>4;b=this.rgbColorToHex_((b&48)>>4,(b&12)>>2,b&3);a=this.rgbColorToHex_(c,d,a);this.currentWindow_.setPenTextColor(b);this.currentWindow_.setPenBackgroundColor(a)}};
shaka.cea.Cea708Service.prototype.setPenLocation_=function(a){var b=a.readByte().value;a=a.readByte().value;this.currentWindow_&&this.currentWindow_.setPenLocation(b&15,a&63)};shaka.cea.Cea708Service.prototype.setWindowAttributes_=function(a){a.skip(1);a.skip(1);var b=a.readByte().value;a.skip(1);this.currentWindow_&&this.currentWindow_.setJustification(b&3)};
shaka.cea.Cea708Service.prototype.defineWindow_=function(a,b,c){var d=this.windows_[b]!==null;if(!d){var e=new shaka.cea.Cea708Window(b,this.serviceNumber_);e.setStartTime(c);this.windows_[b]=e}var f=a.readByte().value,g=a.readByte().value;c=a.readByte().value;var h=a.readByte().value;e=a.readByte().value;a=a.readByte().value;f=(f&32)>0;var k=g&127;g=(g&128)>0;var l=(h&15)+1;h=(h&240)>>4;e=(e&63)+1;d&&(a&7)===0||this.windows_[b].resetPen();this.windows_[b].defineWindow(f,k,c,h,g,l,e);this.currentWindow_=
this.windows_[b]};shaka.cea.Cea708Service.prototype.rgbColorToHex_=function(a,b,c){var d={0:0,1:0,2:1,3:1};a=d[a];b=d[b];c=d[c];return shaka.cea.Cea708Service.Colors[a<<2|b<<1|c]};shaka.cea.Cea708Service.ASCII_BACKSPACE=8;shaka.cea.Cea708Service.ASCII_FORM_FEED=12;shaka.cea.Cea708Service.ASCII_CARRIAGE_RETURN=13;shaka.cea.Cea708Service.ASCII_HOR_CARRIAGE_RETURN=14;shaka.cea.Cea708Service.EXT_CEA708_CTRL_CODE_BYTE1=16;
shaka.cea.Cea708Service.G2Charset=new Map([[32," "],[33,"\u00a0"],[37,"\u2026"],[42,"\u0160"],[44,"\u0152"],[48,"\u2588"],[49,"\u2018"],[50,"\u2019"],[51,"\u201c"],[52,"\u201d"],[53,"\u2022"],[57,"\u2122"],[58,"\u0161"],[60,"\u0153"],[61,"\u2120"],[63,"\u0178"],[118,"\u215b"],[119,"\u215c"],[120,"\u215d"],[121,"\u215e"],[122,"\u2502"],[123,"\u2510"],[124,"\u2514"],[125,"\u2500"],[126,"\u2518"],[127,"\u250c"]]);shaka.cea.Cea708Service.Colors="black blue green cyan red magenta yellow white".split(" ");shaka.util.DataViewReader=function(a,b){this.dataView_=shaka.util.BufferUtils.toDataView(a);this.littleEndian_=b==shaka.util.DataViewReader.Endianness.LITTLE_ENDIAN;this.position_=0};shaka.util.DataViewReader.prototype.getDataView=function(){return this.dataView_};shaka.util.DataViewReader.prototype.hasMoreData=function(){return this.position_<this.dataView_.byteLength};shaka.util.DataViewReader.prototype.getPosition=function(){return this.position_};
shaka.util.DataViewReader.prototype.getLength=function(){return this.dataView_.byteLength};shaka.util.DataViewReader.prototype.readUint8=function(){try{var a=this.dataView_.getUint8(this.position_);this.position_+=1;return a}catch(b){throw this.outOfBounds_();}};shaka.util.DataViewReader.prototype.readUint16=function(){try{var a=this.dataView_.getUint16(this.position_,this.littleEndian_);this.position_+=2;return a}catch(b){throw this.outOfBounds_();}};
shaka.util.DataViewReader.prototype.readUint32=function(){try{var a=this.dataView_.getUint32(this.position_,this.littleEndian_);this.position_+=4;return a}catch(b){throw this.outOfBounds_();}};shaka.util.DataViewReader.prototype.readInt32=function(){try{var a=this.dataView_.getInt32(this.position_,this.littleEndian_);this.position_+=4;return a}catch(b){throw this.outOfBounds_();}};
shaka.util.DataViewReader.prototype.readUint64=function(){try{if(this.littleEndian_){var a=this.dataView_.getUint32(this.position_,!0);var b=this.dataView_.getUint32(this.position_+4,!0)}else b=this.dataView_.getUint32(this.position_,!1),a=this.dataView_.getUint32(this.position_+4,!1)}catch(c){throw this.outOfBounds_();}if(b>2097151)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);this.position_+=8;return b*4294967296+
a};shaka.util.DataViewReader.prototype.readBytes=function(a,b){goog.asserts.assert(a>=0,"Bad call to DataViewReader.readBytes");if(this.position_+a>this.dataView_.byteLength)throw this.outOfBounds_();var c=shaka.util.BufferUtils.toUint8(this.dataView_,this.position_,a);this.position_+=a;return b?new Uint8Array(c):c};
shaka.util.DataViewReader.prototype.skip=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.skip");if(this.position_+a>this.dataView_.byteLength)throw this.outOfBounds_();this.position_+=a};shaka.util.DataViewReader.prototype.rewind=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.rewind");if(this.position_<a)throw this.outOfBounds_();this.position_-=a};
shaka.util.DataViewReader.prototype.seek=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.seek");if(a<0||a>this.dataView_.byteLength)throw this.outOfBounds_();this.position_=a};shaka.util.DataViewReader.prototype.readTerminatedString=function(){for(var a=this.position_;this.hasMoreData()&&this.dataView_.getUint8(this.position_)!=0;)this.position_+=1;a=shaka.util.BufferUtils.toUint8(this.dataView_,a,this.position_-a);this.position_+=1;return shaka.util.StringUtils.fromUTF8(a)};
shaka.util.DataViewReader.prototype.outOfBounds_=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS)};goog.exportSymbol("shaka.util.DataViewReader",shaka.util.DataViewReader);goog.exportProperty(shaka.util.DataViewReader.prototype,"readTerminatedString",shaka.util.DataViewReader.prototype.readTerminatedString);goog.exportProperty(shaka.util.DataViewReader.prototype,"seek",shaka.util.DataViewReader.prototype.seek);
goog.exportProperty(shaka.util.DataViewReader.prototype,"rewind",shaka.util.DataViewReader.prototype.rewind);goog.exportProperty(shaka.util.DataViewReader.prototype,"skip",shaka.util.DataViewReader.prototype.skip);goog.exportProperty(shaka.util.DataViewReader.prototype,"readBytes",shaka.util.DataViewReader.prototype.readBytes);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint64",shaka.util.DataViewReader.prototype.readUint64);
goog.exportProperty(shaka.util.DataViewReader.prototype,"readInt32",shaka.util.DataViewReader.prototype.readInt32);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint32",shaka.util.DataViewReader.prototype.readUint32);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint16",shaka.util.DataViewReader.prototype.readUint16);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint8",shaka.util.DataViewReader.prototype.readUint8);
goog.exportProperty(shaka.util.DataViewReader.prototype,"getLength",shaka.util.DataViewReader.prototype.getLength);goog.exportProperty(shaka.util.DataViewReader.prototype,"getPosition",shaka.util.DataViewReader.prototype.getPosition);goog.exportProperty(shaka.util.DataViewReader.prototype,"hasMoreData",shaka.util.DataViewReader.prototype.hasMoreData);shaka.util.DataViewReader.Endianness={BIG_ENDIAN:0,LITTLE_ENDIAN:1};goog.exportProperty(shaka.util.DataViewReader,"Endianness",shaka.util.DataViewReader.Endianness);shaka.cea.CeaDecoder=function(){this.cea608DataArray_=[];this.cea708DataArray_=[];this.dtvccPacketBuilder_=new shaka.cea.DtvccPacketBuilder;this.badFrames_=0;this.cea608ModeToStream_=new Map([["CC1",new shaka.cea.Cea608DataChannel(0,0)],["CC2",new shaka.cea.Cea608DataChannel(0,1)],["CC3",new shaka.cea.Cea608DataChannel(1,0)],["CC4",new shaka.cea.Cea608DataChannel(1,1)]]);this.currentField2Channel_=this.currentField1Channel_=0;this.serviceNumberToService_=new Map;this.waitingForFirstPacket_=!0;this.streams_=
new Set;this.reset()};shaka.cea.CeaDecoder.prototype.clear=function(){shaka.log.debug("Clearing CEA decoder");this.badFrames_=0;this.cea608DataArray_=[];this.cea708DataArray_=[];this.dtvccPacketBuilder_.clear();this.reset();for(var a=(0,$jscomp.makeIterator)(this.serviceNumberToService_.values()),b=a.next();!b.done;b=a.next())b.value.clear()};
shaka.cea.CeaDecoder.prototype.reset=function(){shaka.log.debug("Resetting CEA decoder");this.currentField2Channel_=this.currentField1Channel_=0;for(var a=(0,$jscomp.makeIterator)(this.cea608ModeToStream_.values()),b=a.next();!b.done;b=a.next())b.value.reset();this.waitingForFirstPacket_=!0};
shaka.cea.CeaDecoder.prototype.extract=function(a,b){if(this.waitingForFirstPacket_){shaka.log.debug("Setting first pts value to",b);for(var c=(0,$jscomp.makeIterator)(this.cea608ModeToStream_.values()),d=c.next();!d.done;d=c.next())d.value.firstPts(b);this.waitingForFirstPacket_=!1}a=new shaka.util.DataViewReader(a,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);if(!(a.getLength()<shaka.cea.CeaDecoder.MIN_LENGTH)&&a.readUint8()===shaka.cea.CeaDecoder.USA_COUNTRY_CODE&&a.readUint16()===shaka.cea.CeaDecoder.ATSC_PROVIDER_CODE&&
a.readUint32()===shaka.cea.CeaDecoder.ATSC1_USER_IDENTIFIER&&a.readUint8()===3&&(c=a.readUint8(),(c&64)!==0))for(c&=31,a.skip(1),d=0;d<c;d++){var e=a.readUint8(),f=(e&4)>>2,g=a.readUint8(),h=a.readUint8();f&&(e&=3,e===shaka.cea.CeaDecoder.NTSC_CC_FIELD_1||e===shaka.cea.CeaDecoder.NTSC_CC_FIELD_2?this.cea608DataArray_.push({pts:b,type:e,ccData1:g,ccData2:h,order:this.cea608DataArray_.length}):(this.cea708DataArray_.push({pts:b,type:e,value:g,order:this.cea708DataArray_.length}),this.cea708DataArray_.push({pts:b,
type:shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_DATA,value:h,order:this.cea708DataArray_.length})))}};
shaka.cea.CeaDecoder.prototype.decode=function(){var a=[],b=function(d,e){return d.pts-e.pts||d.order-e.order};this.cea608DataArray_.sort(b);this.cea708DataArray_.sort(b);b=(0,$jscomp.makeIterator)(this.cea608DataArray_);for(var c=b.next();!c.done;c=b.next())(c=this.decodeCea608_(c.value))&&a.push(c);b=(0,$jscomp.makeIterator)(this.cea708DataArray_);for(c=b.next();!c.done;c=b.next())this.dtvccPacketBuilder_.addByte(c.value);b=this.dtvccPacketBuilder_.getBuiltPackets();b=(0,$jscomp.makeIterator)(b);
for(c=b.next();!c.done;c=b.next())c=this.decodeCea708_(c.value),a.push.apply(a,(0,$jscomp.arrayFromIterable)(c));this.dtvccPacketBuilder_.clearBuiltPackets();this.cea608DataArray_=[];this.cea708DataArray_=[];return a};
shaka.cea.CeaDecoder.prototype.decodeCea608_=function(a){var b=a.type;if(shaka.cea.Cea608DataChannel.isControlCode(a.ccData1)){var c=a.ccData1>>3&1;b===0?this.currentField1Channel_=c:this.currentField2Channel_=c}b="CC"+((b<<1|(b?this.currentField2Channel_:this.currentField1Channel_))+1);c=this.cea608ModeToStream_.get(b);if(a.ccData1===255&&a.ccData2===255||!a.ccData1&&!a.ccData2||!this.isOddParity_(a.ccData1)||!this.isOddParity_(a.ccData2))return++this.badFrames_>=45&&this.reset(),null;this.badFrames_=
0;a.ccData1&=127;a.ccData2&=127;if(shaka.cea.Cea608DataChannel.isXdsControlCode(a.ccData1)||!a.ccData1&&!a.ccData2)return null;var d=null;shaka.cea.Cea608DataChannel.isControlCode(a.ccData1)?(this.streams_.add(b),d=c.handleControlCode(a)):c.handleBasicNorthAmericanChar(a.ccData1,a.ccData2);return d};
shaka.cea.CeaDecoder.prototype.decodeCea708_=function(a){var b=[];try{for(;a.hasMoreData();){var c=a.readByte().value,d=(c&224)>>5,e=c&31;d===7&&e!=0&&(d=a.readByte().value&63);if(d!=0){this.streams_.add("svc"+d);if(!this.serviceNumberToService_.has(d)){var f=new shaka.cea.Cea708Service(d);this.serviceNumberToService_.set(d,f)}for(var g=this.serviceNumberToService_.get(d),h=a.getPosition();a.getPosition()-h<e;){var k=g.handleCea708ControlCode(a);b.push.apply(b,(0,$jscomp.arrayFromIterable)(k))}}}}catch(l){if(l instanceof
shaka.util.Error&&l.code===shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS)shaka.log.warnOnce("CEA708_INVALID_DATA","Buffer read out of bounds / invalid CEA-708 Data.");else throw l;}return b};shaka.cea.CeaDecoder.prototype.isOddParity_=function(a){for(var b=0;a;)b^=a&1,a>>=1;return b===1};shaka.cea.CeaDecoder.prototype.getStreams=function(){return Array.from(this.streams_)};goog.exportSymbol("shaka.cea.CeaDecoder",shaka.cea.CeaDecoder);shaka.cea.CeaDecoder.ATSC_PROVIDER_CODE=49;
shaka.cea.CeaDecoder.ATSC1_USER_IDENTIFIER=1195456820;shaka.cea.CeaDecoder.NTSC_CC_FIELD_1=0;shaka.cea.CeaDecoder.NTSC_CC_FIELD_2=1;shaka.cea.CeaDecoder.USA_COUNTRY_CODE=181;shaka.cea.CeaDecoder.MIN_LENGTH=8;shaka.media.ClosedCaptionParser.registerDecoder(function(){return new shaka.cea.CeaDecoder});shaka.cea.SeiProcessor=function(){};shaka.cea.SeiProcessor.prototype.process=function(a){var b=[];a=this.removeEmu(a);for(var c=0;c<a.length;){for(var d=0;a[c]==255;)d+=255,c++;d+=a[c++];for(var e=0;a[c]==255;)e+=255,c++;e+=a[c++];d==4&&b.push(a.subarray(c,c+e));c+=e}return b};shaka.cea.SeiProcessor.prototype.removeEmu=function(a){for(var b=a,c=a=0;c<b.length;)a==2&&b[c]==3?(a=0,b=[].concat((0,$jscomp.arrayFromIterable)(b)),b.splice(c,1),b=new Uint8Array(b)):b[c]==0?a++:a=0,c++;return b};shaka.util.Mp4Parser=function(){this.headers_=new Map;this.boxDefinitions_=new Map;this.done_=!1};shaka.util.Mp4Parser.prototype.box=function(a,b){a=shaka.util.Mp4Parser.typeFromString_(a);this.headers_.set(a,shaka.util.Mp4Parser.BoxType_.BASIC_BOX);this.boxDefinitions_.set(a,b);return this};shaka.util.Mp4Parser.prototype.fullBox=function(a,b){a=shaka.util.Mp4Parser.typeFromString_(a);this.headers_.set(a,shaka.util.Mp4Parser.BoxType_.FULL_BOX);this.boxDefinitions_.set(a,b);return this};
shaka.util.Mp4Parser.prototype.stop=function(){this.done_=!0};shaka.util.Mp4Parser.prototype.parse=function(a,b,c){a=new shaka.util.DataViewReader(a,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);for(this.done_=!1;a.hasMoreData()&&!this.done_;)this.parseNext(0,a,b,c)};
shaka.util.Mp4Parser.prototype.parseNext=function(a,b,c,d){var e=b.getPosition();if(d&&e+8>b.getLength())this.done_=!0;else{var f=b.readUint32(),g=b.readUint32(),h=shaka.util.Mp4Parser.typeToString(g),k=!1;shaka.log.v2("Parsing MP4 box",h);switch(f){case 0:f=b.getLength()-e;break;case 1:if(d&&b.getPosition()+8>b.getLength()){this.done_=!0;return}f=b.readUint64();k=!0}var l=this.boxDefinitions_.get(g);if(l){var m=null,n=null;if(this.headers_.get(g)==shaka.util.Mp4Parser.BoxType_.FULL_BOX){if(d&&b.getPosition()+
4>b.getLength()){this.done_=!0;return}n=b.readUint32();m=n>>>24;n&=16777215}g=e+f;c&&g>b.getLength()&&(g=b.getLength());d&&g>b.getLength()?this.done_=!0:(g-=b.getPosition(),b=g>0?b.readBytes(g,!1):new Uint8Array(0),b=new shaka.util.DataViewReader(b,shaka.util.DataViewReader.Endianness.BIG_ENDIAN),l({name:h,parser:this,partialOkay:c||!1,stopOnPartial:d||!1,version:m,flags:n,reader:b,size:f,start:e+a,has64BitSize:k}))}else a=Math.min(e+f-b.getPosition(),b.getLength()-b.getPosition()),b.skip(a)}};
shaka.util.Mp4Parser.children=function(a){for(var b=shaka.util.Mp4Parser.headerSize(a);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};shaka.util.Mp4Parser.sampleDescription=function(a){for(var b=shaka.util.Mp4Parser.headerSize(a),c=a.reader.readUint32(),d=0;d<c&&(a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial),!a.parser.done_);d++);};
shaka.util.Mp4Parser.visualSampleEntry=function(a){var b=shaka.util.Mp4Parser.headerSize(a);for(a.reader.skip(78);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};
shaka.util.Mp4Parser.audioSampleEntry=function(a){var b=shaka.util.Mp4Parser.headerSize(a);a.reader.skip(8);var c=a.reader.readUint16();a.reader.skip(6);c==2?a.reader.skip(48):a.reader.skip(12);for(c==1&&a.reader.skip(16);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};shaka.util.Mp4Parser.allData=function(a,b){return function(c){var d=c.reader.getLength()-c.reader.getPosition();a(c.reader.readBytes(d,b))}};
shaka.util.Mp4Parser.typeFromString_=function(a){goog.asserts.assert(a.length==4,"Mp4 box names must be 4 characters long");var b=0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())b=b<<8|c.value.charCodeAt(0);return b};shaka.util.Mp4Parser.typeToString=function(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)};shaka.util.Mp4Parser.headerSize=function(a){return 8+(a.has64BitSize?8:0)+(a.flags!=null?4:0)};goog.exportSymbol("shaka.util.Mp4Parser",shaka.util.Mp4Parser);
goog.exportProperty(shaka.util.Mp4Parser,"headerSize",shaka.util.Mp4Parser.headerSize);goog.exportProperty(shaka.util.Mp4Parser,"typeToString",shaka.util.Mp4Parser.typeToString);goog.exportProperty(shaka.util.Mp4Parser,"allData",shaka.util.Mp4Parser.allData);goog.exportProperty(shaka.util.Mp4Parser,"audioSampleEntry",shaka.util.Mp4Parser.audioSampleEntry);goog.exportProperty(shaka.util.Mp4Parser,"visualSampleEntry",shaka.util.Mp4Parser.visualSampleEntry);
goog.exportProperty(shaka.util.Mp4Parser,"sampleDescription",shaka.util.Mp4Parser.sampleDescription);goog.exportProperty(shaka.util.Mp4Parser,"children",shaka.util.Mp4Parser.children);goog.exportProperty(shaka.util.Mp4Parser.prototype,"parseNext",shaka.util.Mp4Parser.prototype.parseNext);goog.exportProperty(shaka.util.Mp4Parser.prototype,"parse",shaka.util.Mp4Parser.prototype.parse);goog.exportProperty(shaka.util.Mp4Parser.prototype,"stop",shaka.util.Mp4Parser.prototype.stop);
goog.exportProperty(shaka.util.Mp4Parser.prototype,"fullBox",shaka.util.Mp4Parser.prototype.fullBox);goog.exportProperty(shaka.util.Mp4Parser.prototype,"box",shaka.util.Mp4Parser.prototype.box);shaka.util.Mp4Parser.BoxType_={BASIC_BOX:0,FULL_BOX:1};shaka.util.Mp4BoxParsers=function(){};shaka.util.Mp4BoxParsers.parseTFHD=function(a,b){var c=null,d=null,e=null,f=null,g=a.readUint32();b&1&&(e=a.readUint64());b&2&&(f=a.readUint32());b&8&&(c=a.readUint32());b&16&&(d=a.readUint32());return{trackId:g,defaultSampleDuration:c,defaultSampleSize:d,baseDataOffset:e,sampleDescriptionIndex:f}};shaka.util.Mp4BoxParsers.parseTFDT=function(a,b){return{baseMediaDecodeTime:b==1?a.readUint64():a.readUint32()}};
shaka.util.Mp4BoxParsers.parseTFDTInaccurate=function(a,b){return b==1?(b=a.readUint32(),a=a.readUint32(),{baseMediaDecodeTime:b*4294967296+a}):{baseMediaDecodeTime:a.readUint32()}};shaka.util.Mp4BoxParsers.parsePRFTInaccurate=function(a,b){a.readUint32();var c=a.readUint32(),d=a.readUint32();c=c*1E3+d/4294967296*1E3;b===0?a=a.readUint32():(b=a.readUint32(),a=a.readUint32(),a=b*4294967296+a);return{mediaTime:a,ntpTimestamp:c}};
shaka.util.Mp4BoxParsers.parseMDHD=function(a,b){b==1?(a.skip(8),a.skip(8)):(a.skip(4),a.skip(4));b=a.readUint32();a.skip(4);a=a.readUint16();a=String.fromCharCode((a>>10)+96)+String.fromCharCode(((a&960)>>5)+96)+String.fromCharCode((a&31)+96);return{timescale:b,language:a}};shaka.util.Mp4BoxParsers.parseTREX=function(a){a.skip(4);a.skip(4);var b=a.readUint32();a=a.readUint32();return{defaultSampleDuration:b,defaultSampleSize:a}};
shaka.util.Mp4BoxParsers.parseTRUN=function(a,b,c){var d=a.readUint32(),e=[],f=null;c&1&&(f=a.readInt32());c&4&&a.skip(4);for(var g=0;g<d;g++){var h={sampleDuration:null,sampleSize:null,sampleCompositionTimeOffset:null};c&256&&(h.sampleDuration=a.readUint32());c&512&&(h.sampleSize=a.readUint32());c&1024&&a.skip(4);c&2048&&(h.sampleCompositionTimeOffset=b==0?a.readUint32():a.readInt32());e.push(h)}return{sampleCount:d,sampleData:e,dataOffset:f}};
shaka.util.Mp4BoxParsers.parseTKHD=function(a,b){b==1?(a.skip(8),a.skip(8)):(a.skip(4),a.skip(4));var c=a.readUint32();b==1?a.skip(8):a.skip(4);a.skip(4);a.skip(8);a.skip(2);a.skip(2);a.skip(2);a.skip(2);a.skip(36);b=a.readUint16()+a.readUint16()/16;a=a.readUint16()+a.readUint16()/16;return{trackId:c,width:b,height:a}};shaka.util.Mp4BoxParsers.visualSampleEntry=function(a){a.skip(24);var b=a.readUint16(),c=a.readUint16();a.skip(50);return{width:b,height:c}};
shaka.util.Mp4BoxParsers.audioSampleEntry=function(a){a.skip(6);a.skip(2);a.skip(8);var b=a.readUint16();a.skip(2);a.skip(2);a.skip(2);a=a.readUint16()+a.readUint16()/65536;return{channelCount:b,sampleRate:a}};
shaka.util.Mp4BoxParsers.parseESDS=function(a){for(var b="mp4a",c,d;a.hasMoreData();){c=a.readUint8();for(var e=a.readUint8();e&128;)e=a.readUint8();if(c==3)a.readUint16(),e=a.readUint8(),e&128&&a.readUint16(),e&64&&a.skip(a.readUint8()),e&32&&a.readUint16();else if(c==4)d=a.readUint8(),a.skip(12);else if(c==5)break}d&&(b+="."+shaka.util.Mp4BoxParsers.toHex_(d),c==5&&a.hasMoreData()&&(c=a.readUint8(),d=(c&248)>>3,d===31&&a.hasMoreData()&&(d=32+((c&7)<<3)+((a.readUint8()&224)>>5)),b+="."+d));return{codec:b}};
shaka.util.Mp4BoxParsers.parseAVCC=function(a,b,c){c=shaka.util.Mp4BoxParsers;b.skip(1);return{codec:a+"."+c.toHex_(b.readUint8())+c.toHex_(b.readUint8())+c.toHex_(b.readUint8())}};
shaka.util.Mp4BoxParsers.parseHVCC=function(a,b,c){var d=shaka.util.Mp4BoxParsers;b.skip(1);c=b.readUint8();var e=["","A","B","C"][c>>6],f=c&31,g=b.readUint32(),h=(c&32)>>5?"H":"L";c=[b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8()];b=b.readUint8();a=a+("."+e+f)+("."+d.toHex_(d.reverseBits_(g),!0));a+="."+h+b;b="";for(d=c.length;d--;)if((e=c[d])||b)b="."+e.toString(16).toUpperCase()+b;a+=b;return{codec:a}};
shaka.util.Mp4BoxParsers.parseDVCC=function(a,b,c){c=shaka.util.Mp4BoxParsers;b.skip(2);var d=b.readUint8();b=b.readUint8();b=d<<5&32|b>>3&31;return{codec:a+"."+c.addLeadingZero_(d>>1&127)+"."+c.addLeadingZero_(b)}};shaka.util.Mp4BoxParsers.parseDVVC=function(a,b,c){c=shaka.util.Mp4BoxParsers;b.skip(2);var d=b.readUint8();b=b.readUint8();b=d<<5&32|b>>3&31;return{codec:a+"."+c.addLeadingZero_(d>>1&127)+"."+c.addLeadingZero_(b)}};
shaka.util.Mp4BoxParsers.parseVPCC=function(a,b,c){c=shaka.util.Mp4BoxParsers;var d=b.readUint8(),e=b.readUint8();b=b.readUint8()>>4&15;return{codec:a+"."+c.addLeadingZero_(d)+"."+c.addLeadingZero_(e)+"."+c.addLeadingZero_(b)}};
shaka.util.Mp4BoxParsers.parseAV1C=function(a,b,c){c=shaka.util.Mp4BoxParsers;b.skip(1);var d=b.readUint8(),e=b.readUint8();b=d>>>5;var f=e>>>7?"H":"M",g=(e&64)>>6;g=b===2&&g?(e&32)>>5?12:10:g?10:8;var h=(e&16)>>4,k=(e&8)>>3,l=(e&4)>>2;e&=3;return{codec:a+"."+b+"."+c.addLeadingZero_(d&31)+f+"."+c.addLeadingZero_(g)+"."+h+"."+k+l+e+"."+c.addLeadingZero_(1)+"."+c.addLeadingZero_(1)+"."+c.addLeadingZero_(1)+".0"}};shaka.util.Mp4BoxParsers.parseFRMA=function(a){a=a.readUint32();return{codec:shaka.util.Mp4Parser.typeToString(a)}};
shaka.util.Mp4BoxParsers.parseTENC=function(a){var b=shaka.util.Uint8ArrayUtils;a.readUint8();a.readUint8();a.readUint8();a.readUint8();a=a.readBytes(16,!1);return{defaultKID:b.toHex(a)}};shaka.util.Mp4BoxParsers.parseHDLR=function(a){a.skip(8);return{handlerType:a.readTerminatedString()}};shaka.util.Mp4BoxParsers.parsePRJI=function(a){return{projection:a.readTerminatedString()}};shaka.util.Mp4BoxParsers.parseHFOV=function(a){return{hfov:a.readUint32()/1E3}};
shaka.util.Mp4BoxParsers.parseCOLR=function(a){var b=null,c=null,d=a.readBytes(4,!1);var e=""+String.fromCharCode(d[0]);e+=String.fromCharCode(d[1]);e+=String.fromCharCode(d[2]);e+=String.fromCharCode(d[3]);if(e==="nclx"){switch(a.readUint16()){case 1:case 5:case 6:case 7:b="srgb";break;case 9:b="rec2020";break;case 11:case 12:b="p3"}d=a.readUint16();a.readUint16();switch(d){case 1:case 6:case 13:case 14:case 15:c="SDR";break;case 16:c="PQ";break;case 18:c="HLG"}}return{colorGamut:b,videoRange:c}};
shaka.util.Mp4BoxParsers.updateAV1CodecWithCOLRBox=function(a,b){var c=shaka.util.Mp4BoxParsers,d=b.getPosition(),e=b.readBytes(4,!1);var f=""+String.fromCharCode(e[0]);f+=String.fromCharCode(e[1]);f+=String.fromCharCode(e[2]);f+=String.fromCharCode(e[3]);if(f==="nclx"){e=b.readUint16();f=b.readUint16();var g=b.readUint16(),h=b.readUint8()>>7,k=a.split(".");k.length==10&&(k[6]=c.addLeadingZero_(e),k[7]=c.addLeadingZero_(f),k[8]=c.addLeadingZero_(g),k[9]=String(h),a=k.join("."))}b.seek(d);return a};
shaka.util.Mp4BoxParsers.toHex_=function(a,b){b=b===void 0?!1:b;a=a.toString(16).toUpperCase();return b?a:("0"+a).slice(-2)};shaka.util.Mp4BoxParsers.reverseBits_=function(a){for(var b=0,c=0;c<32;c++){b|=a&1;if(c==31)break;b<<=1;a>>=1}return b};shaka.util.Mp4BoxParsers.addLeadingZero_=function(a){return(a<10?"0":"")+a};shaka.cea.Mp4CeaParser=function(){this.seiProcessor_=new shaka.cea.SeiProcessor;this.trackIdToTimescale_=new Map;this.defaultSampleSize_=this.defaultSampleDuration_=0;this.bitstreamFormat_=shaka.cea.Mp4CeaParser.BitstreamFormat.UNKNOWN};
shaka.cea.Mp4CeaParser.prototype.init=function(a){var b=this,c=shaka.util.Mp4Parser,d=shaka.cea.Mp4CeaParser.BitstreamFormat,e=[],f=[],g=function(h){return b.setBitstreamFormat_(h.name)};(new c).box("moov",c.children).box("mvex",c.children).fullBox("trex",function(h){h=shaka.util.Mp4BoxParsers.parseTREX(h.reader);b.defaultSampleDuration_=h.defaultSampleDuration;b.defaultSampleSize_=h.defaultSampleSize}).box("trak",c.children).fullBox("tkhd",function(h){goog.asserts.assert(h.version!=null,"TKHD is a full box and should have a valid version.");
h=shaka.util.Mp4BoxParsers.parseTKHD(h.reader,h.version);e.push(h.trackId)}).box("mdia",c.children).fullBox("mdhd",function(h){goog.asserts.assert(h.version!=null,"MDHD is a full box and should have a valid version.");h=shaka.util.Mp4BoxParsers.parseMDHD(h.reader,h.version);f.push(h.timescale)}).box("minf",c.children).box("stbl",c.children).fullBox("stsd",c.sampleDescription).box("avc1",g).box("avc3",g).box("dvav",g).box("dva1",g).box("hev1",g).box("hvc1",g).box("dvh1",g).box("dvhe",g).box("vvc1",
g).box("vvi1",g).box("dvc1",g).box("dvi1",g).box("encv",c.visualSampleEntry).box("sinf",c.children).box("frma",function(h){h=shaka.util.Mp4BoxParsers.parseFRMA(h.reader).codec;b.setBitstreamFormat_(h)}).parse(a,!0,!0);if(!e.length||!f.length||e.length!=f.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_CEA);this.bitstreamFormat_==d.UNKNOWN&&shaka.log.alwaysWarn("Unable to determine bitstream format for CEA parsing!");
e.forEach(function(h,k){b.trackIdToTimescale_.set(h,f[k])})};
shaka.cea.Mp4CeaParser.prototype.parse=function(a){var b=this,c=shaka.util.Mp4Parser;if(this.bitstreamFormat_==shaka.cea.Mp4CeaParser.BitstreamFormat.UNKNOWN)return[];var d=[],e=0,f=[];(new c).box("moof",function(g){e=g.start;f=[];c.children(g)}).box("traf",function(g){f.push({baseMediaDecodeTime:null,defaultSampleDuration:b.defaultSampleDuration_,defaultSampleSize:b.defaultSampleSize_,parsedTRUNs:[],timescale:shaka.cea.CeaUtils.DEFAULT_TIMESCALE_VALUE});c.children(g)}).fullBox("trun",function(g){goog.asserts.assert(g.version!=
null&&g.flags!=null,"TRUN is a full box and should have a valid version & flags.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTRUN(g.reader,g.version,g.flags);h.parsedTRUNs.push(g)}).fullBox("tfhd",function(g){goog.asserts.assert(g.flags!=null,"TFHD is a full box and should have valid flags.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTFHD(g.reader,g.flags);h.defaultSampleDuration=g.defaultSampleDuration||b.defaultSampleDuration_;h.defaultSampleSize=g.defaultSampleSize||b.defaultSampleSize_;
g=g.trackId;b.trackIdToTimescale_.has(g)&&(h.timescale=b.trackIdToTimescale_.get(g))}).fullBox("tfdt",function(g){goog.asserts.assert(g.version!=null,"TFDT is a full box and should have a valid version.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(g.reader,g.version);h.baseMediaDecodeTime=g.baseMediaDecodeTime}).box("mdat",function(g){for(var h=e-g.start-8,k=g.reader.getPosition(),l=(0,$jscomp.makeIterator)(f),m=l.next();!m.done;m=l.next())m=m.value,m.baseMediaDecodeTime===
null?shaka.log.alwaysWarn("Unable to find base media decode time for CEA captions!"):(g.reader.seek(k),b.parseMdat_(g.reader,m.baseMediaDecodeTime,m.timescale,m.defaultSampleDuration,m.defaultSampleSize,h,m.parsedTRUNs,d))}).parse(a,!1,!0);return d};
shaka.cea.Mp4CeaParser.prototype.parseMdat_=function(a,b,c,d,e,f,g,h){var k=shaka.cea.Mp4CeaParser.BitstreamFormat,l=shaka.cea.CeaUtils,m=0,n=e,p=g.map(function(t){return t.sampleData});p=[].concat.apply([],(0,$jscomp.arrayFromIterable)(p));p.length&&(n=p[0].sampleSize||e);for(a.skip(f+g[0].dataOffset);a.hasMoreData();){f=a.readUint32();var q=a.readUint8(),r=null;r=!1;g=1;goog.asserts.assert(this.bitstreamFormat_!=k.UNKNOWN,"Bitstream format should have been checked before now!");switch(this.bitstreamFormat_){case k.H264:r=
q&31;r=r==l.H264_NALU_TYPE_SEI;break;case k.H265:g=2;a.skip(1);r=q>>1&63;r=r==l.H265_PREFIX_NALU_TYPE_SEI||r==l.H265_SUFFIX_NALU_TYPE_SEI;break;case k.H266:g=2;a.skip(1);r=q>>1&63;r=r==l.H266_PREFIX_NALU_TYPE_SEI||r==l.H266_SUFFIX_NALU_TYPE_SEI;break;default:return}if(r)for(q=0,m<p.length&&(q=p[m].sampleCompositionTimeOffset||0),q=(b+q)/c,g=a.readBytes(f-g,!1),g=(0,$jscomp.makeIterator)(this.seiProcessor_.process(g)),r=g.next();!r.done;r=g.next())h.push({packet:r.value,pts:q});else try{a.skip(f-g)}catch(t){break}n-=
f+4;n==0&&(b=m<p.length?b+(p[m].sampleDuration||d):b+d,m++,n=m<p.length?p[m].sampleSize||e:e)}};shaka.cea.Mp4CeaParser.prototype.setBitstreamFormat_=function(a){shaka.cea.Mp4CeaParser.CodecBitstreamMap_.has(a)&&(this.bitstreamFormat_=shaka.cea.Mp4CeaParser.CodecBitstreamMap_.get(a))};goog.exportSymbol("shaka.cea.Mp4CeaParser",shaka.cea.Mp4CeaParser);shaka.cea.Mp4CeaParser.BitstreamFormat={UNKNOWN:0,H264:1,H265:2,H266:3};
shaka.cea.Mp4CeaParser.CodecBitstreamMap_=(new Map).set("avc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("avc3",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("dvav",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("dva1",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("hev1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("hvc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("dvh1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("dvhe",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("vvc1",
shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("vvi1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("dvc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("dvi1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266);shaka.media.ClosedCaptionParser.registerParser("video/mp4",function(){return new shaka.cea.Mp4CeaParser});/*

 Copyright Brightcove, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/
shaka.util.ExpGolomb=function(a,b){this.data_=a;if(b===void 0?0:b)this.data_=this.ebsp2rbsp_(a);this.workingBytesAvailable_=this.data_.byteLength;this.workingBitsAvailable_=this.workingWord_=0};shaka.util.ExpGolomb.prototype.ebsp2rbsp_=function(a){for(var b=new Uint8Array(a.byteLength),c=0,d=0;d<a.byteLength;d++)d>=2&&a[d]==3&&a[d-1]==0&&a[d-2]==0||(b[c]=a[d],c++);return shaka.util.BufferUtils.toUint8(b,0,c)};
shaka.util.ExpGolomb.prototype.loadWord_=function(){var a=this.data_.byteLength-this.workingBytesAvailable_,b=new Uint8Array(4),c=Math.min(4,this.workingBytesAvailable_);c!==0&&(b.set(this.data_.subarray(a,a+c)),this.workingWord_=(new shaka.util.DataViewReader(b,shaka.util.DataViewReader.Endianness.BIG_ENDIAN)).readUint32(),this.workingBitsAvailable_=c*8,this.workingBytesAvailable_-=c)};
shaka.util.ExpGolomb.prototype.skipBits=function(a){if(this.workingBitsAvailable_<=a){a-=this.workingBitsAvailable_;var b=Math.floor(a/8);a-=b*8;this.workingBitsAvailable_-=b;this.loadWord_()}this.workingWord_<<=a;this.workingBitsAvailable_-=a};
shaka.util.ExpGolomb.prototype.readBits=function(a){var b=Math.min(this.workingBitsAvailable_,a),c=this.workingWord_>>>32-b;this.workingBitsAvailable_-=b;this.workingBitsAvailable_>0?this.workingWord_<<=b:this.workingBytesAvailable_>0&&this.loadWord_();b=a-b;return b>0?c<<b|this.readBits(b):c};
shaka.util.ExpGolomb.prototype.skipLeadingZeros_=function(){var a;for(a=0;a<this.workingBitsAvailable_;++a)if((this.workingWord_&2147483648>>>a)!==0)return this.workingWord_<<=a,this.workingBitsAvailable_-=a,a;this.loadWord_();return a+this.skipLeadingZeros_()};shaka.util.ExpGolomb.prototype.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros_())};shaka.util.ExpGolomb.prototype.readUnsignedExpGolomb=function(){var a=this.skipLeadingZeros_();return this.readBits(a+1)-1};
shaka.util.ExpGolomb.prototype.readExpGolomb=function(){var a=this.readUnsignedExpGolomb();return 1&a?1+a>>>1:-1*(a>>>1)};shaka.util.ExpGolomb.prototype.readBoolean=function(){return this.readBits(1)===1};shaka.util.ExpGolomb.prototype.readUnsignedByte=function(){return this.readBits(8)};shaka.util.ExpGolomb.prototype.skipScalingList=function(a){for(var b=8,c=8,d=0;d<a;d++)c!==0&&(c=this.readExpGolomb(),c=(b+c+256)%256),b=c===0?b:c};
shaka.util.ExpGolomb.prototype.readSliceType=function(){this.readUnsignedByte();this.readUnsignedExpGolomb();return this.readUnsignedExpGolomb()};goog.exportSymbol("shaka.util.ExpGolomb",shaka.util.ExpGolomb);/*
 @license
 Shaka Player
 Copyright 2022 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
shaka.util.Id3Utils=function(){};shaka.util.Id3Utils.isHeader_=function(a,b){return b+10<=a.length&&a[b]===73&&a[b+1]===68&&a[b+2]===51&&a[b+3]<255&&a[b+4]<255&&a[b+6]<128&&a[b+7]<128&&a[b+8]<128&&a[b+9]<128?!0:!1};shaka.util.Id3Utils.isFooter_=function(a,b){return b+10<=a.length&&a[b]===51&&a[b+1]===68&&a[b+2]===73&&a[b+3]<255&&a[b+4]<255&&a[b+6]<128&&a[b+7]<128&&a[b+8]<128&&a[b+9]<128?!0:!1};
shaka.util.Id3Utils.readSize_=function(a,b){var c=(a[b]&127)<<21;c|=(a[b+1]&127)<<14;c|=(a[b+2]&127)<<7;return c|=a[b+3]&127};shaka.util.Id3Utils.getFrameData_=function(a){var b=String.fromCharCode(a[0],a[1],a[2],a[3]),c=shaka.util.Id3Utils.readSize_(a,4);return{type:b,size:c,data:a.subarray(10,10+c)}};
shaka.util.Id3Utils.decodeFrame_=function(a){var b=shaka.util.BufferUtils,c=shaka.util.StringUtils,d={key:a.type,description:"",data:"",mimeType:null,pictureType:null};if(a.type==="APIC"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;var e=a.data.subarray(1).indexOf(0);if(e===-1)return null;var f=c.fromUTF8(b.toUint8(a.data,1,e)),g=a.data[2+e],h=a.data.subarray(3+e).indexOf(0);if(h===-1)return null;
var k=c.fromUTF8(b.toUint8(a.data,3+e,h));a=f==="--\x3e"?c.fromUTF8(b.toUint8(a.data,4+e+h)):b.toArrayBuffer(a.data.subarray(4+e+h));d.mimeType=f;d.pictureType=g;d.description=k;d.data=a;return d}if(a.type==="TXXX"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;g=a.data.subarray(1).indexOf(0);if(g===-1)return null;f=c.fromUTF8(b.toUint8(a.data,1,g));a=c.fromUTF8(b.toUint8(a.data,2+g)).replace(/\0*$/,
"");d.description=f;d.data=a;return d}if(a.type==="WXXX"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;g=a.data.subarray(1).indexOf(0);if(g===-1)return null;f=c.fromUTF8(b.toUint8(a.data,1,g));a=c.fromUTF8(b.toUint8(a.data,2+g)).replace(/\0*$/,"");d.description=f;d.data=a;return d}if(a.type==="PRIV"){if(a.size<2)return null;f=a.data.indexOf(0);if(f===-1)return null;c=c.fromUTF8(b.toUint8(a.data,
0,f));d.description=c;c=="com.apple.streaming.transportStreamTimestamp"?(b=a.data.subarray(c.length+1),a=b[3]&1,b=(b[4]<<23)+(b[5]<<15)+(b[6]<<7)+b[7],b/=45,a&&(b+=4.772185884E7),d.data=b):(a=b.toArrayBuffer(a.data.subarray(c.length+1)),d.data=a);return d}if(a.type[0]==="T"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;a=c.fromUTF8(a.data.subarray(1)).replace(/\0*$/,"");d.data=a;return d}return a.type[0]===
"W"?(a=c.fromUTF8(a.data).replace(/\0*$/,""),d.data=a,d):a.data?(shaka.log.warning("Unrecognized ID3 frame type:",a.type),d.data=b.toArrayBuffer(a.data),d):null};shaka.util.Id3Utils.getID3Frames=function(a){for(var b=shaka.util.Id3Utils,c=0,d=[];b.isHeader_(a,c);){var e=b.readSize_(a,c+6);a[c+5]>>6&1&&(c+=10);c+=10;for(e=c+e;c+10<e;){var f=b.getFrameData_(a.subarray(c)),g=b.decodeFrame_(f);g&&d.push(g);c+=f.size+10}b.isFooter_(a,c)&&(c+=10)}return d};
shaka.util.Id3Utils.getID3Data=function(a,b){b=b===void 0?0:b;for(var c=shaka.util.Id3Utils,d=b,e=0;c.isHeader_(a,b);){a[b+5]>>6&1&&(e+=10);e+=10;var f=c.readSize_(a,b+6);e+=f;c.isFooter_(a,b+10)&&(e+=10);b+=e}return e>0?a.subarray(d,d+e):new Uint8Array([])};goog.exportSymbol("shaka.util.Id3Utils",shaka.util.Id3Utils);goog.exportProperty(shaka.util.Id3Utils,"getID3Data",shaka.util.Id3Utils.getID3Data);goog.exportProperty(shaka.util.Id3Utils,"getID3Frames",shaka.util.Id3Utils.getID3Frames);
shaka.util.Id3Utils.UTF8_encoding=3;shaka.util.TsParser=function(){this.pmtId_=null;this.pmtParsed_=!1;this.videoCodec_=this.videoPid_=null;this.videoData_=[];this.videoPes_=[];this.audioCodec_=this.audioPid_=null;this.audioData_=[];this.audioPes_=[];this.id3Pid_=null;this.id3Data_=[];this.discontinuitySequence_=this.opusMetadata_=this.referenceDts_=this.referencePts_=null};shaka.util.TsParser.prototype.clearData=function(){this.videoData_=[];this.videoPes_=[];this.audioData_=[];this.audioPes_=[];this.id3Data_=[]};
shaka.util.TsParser.prototype.setDiscontinuitySequence=function(a){this.discontinuitySequence_!=null&&this.discontinuitySequence_!=a&&(this.referenceDts_=this.referencePts_=null);this.discontinuitySequence_=a};
shaka.util.TsParser.prototype.parse=function(a){var b=shaka.util.TsParser.PacketLength_;if(a.length<3*b)return this;for(var c=Math.max(0,shaka.util.TsParser.syncOffset(a)),d=a.length-(a.length+c)%b,e=!1,f=c;f<d;f+=b)if(a[f]==71){var g=!!(a[f+1]&64),h=((a[f+1]&31)<<8)+a[f+2];if((a[f+3]&48)>>4>1){var k=f+5+a[f+4];if(k==f+b)continue}else k=f+4;switch(h){case 0:g&&(k+=a[k]+1);this.pmtId_=this.getPmtId_(a,k);break;case 17:case 8191:break;case this.pmtId_:g&&(k+=a[k]+1);g=this.parsePMT_(a,k);g.video!=-1&&
(this.videoPid_=g.video,this.videoCodec_=g.videoCodec);g.audio!=-1&&(this.audioPid_=g.audio,this.audioCodec_=g.audioCodec);g.id3!=-1&&(this.id3Pid_=g.id3);e&&!this.pmtParsed_&&(shaka.log.debug("reparse from beginning"),e=!1,f=c-b);this.pmtParsed_=!0;break;case this.videoPid_:h=a.subarray(k,f+b);g?this.videoData_.push([h]):this.videoData_.length&&this.videoData_[this.videoData_.length-1]&&this.videoData_[this.videoData_.length-1].push(h);break;case this.audioPid_:h=a.subarray(k,f+b);g?this.audioData_.push([h]):
this.audioData_.length&&this.audioData_[this.audioData_.length-1]&&this.audioData_[this.audioData_.length-1].push(h);break;case this.id3Pid_:h=a.subarray(k,f+b);g?this.id3Data_.push([h]):this.id3Data_.length&&this.id3Data_[this.id3Data_.length-1]&&this.id3Data_[this.id3Data_.length-1].push(h);break;default:e=!0}}else shaka.log.warning("Found TS packet that do not start with 0x47");return this};shaka.util.TsParser.prototype.getPmtId_=function(a,b){return(a[b+10]&31)<<8|a[b+11]};
shaka.util.TsParser.prototype.parsePMT_=function(a,b){var c=shaka.util.StringUtils,d={audio:-1,video:-1,id3:-1,audioCodec:"",videoCodec:""},e=b+3+((a[b+1]&15)<<8|a[b+2])-4;for(b+=12+((a[b+10]&15)<<8|a[b+11]);b<e;){var f=(a[b+1]&31)<<8|a[b+2],g=(a[b+3]&15)<<8|a[b+4];switch(a[b]){case 6:if(g>0)for(var h=b+5,k=g;k>2;){var l=a[h+1]+2;switch(a[h]){case 5:var m=a.subarray(h+2,h+l);m=c.fromCharCode(m);d.audio==-1&&m==="Opus"?(d.audio=f,d.audioCodec="opus"):d.video==-1&&m==="AV01"&&(d.video=f,d.videoCodec=
"av1");break;case 106:d.audio==-1&&(d.audio=f,d.audioCodec="ac3");break;case 122:d.audio==-1&&(d.audio=f,d.audioCodec="ec3");break;case 124:d.audio==-1&&(d.audio=f,d.audioCodec="aac");break;case 127:d.audioCodec=="opus"&&(m=null,a[h+2]===128&&(m=a[h+3]),m!=null&&(this.opusMetadata_={channelCount:(m&15)===0?2:m&15,channelConfigCode:m,sampleRate:48E3}))}h+=l;k-=l}break;case 15:d.audio==-1&&(d.audio=f,d.audioCodec="aac");break;case 17:d.audio==-1&&(d.audio=f,d.audioCodec="aac-loas");break;case 21:d.id3==
-1&&(d.id3=f);break;case 27:d.video==-1&&(d.video=f,d.videoCodec="avc");break;case 3:case 4:d.audio==-1&&(d.audio=f,d.audioCodec="mp3");break;case 36:d.video==-1&&(d.video=f,d.videoCodec="hvc");break;case 129:d.audio==-1&&(d.audio=f,d.audioCodec="ac3");break;case 132:case 135:d.audio==-1&&(d.audio=f,d.audioCodec="ec3")}b+=g+5}return d};
shaka.util.TsParser.prototype.parsePES_=function(a){if((a[0]<<16|a[1]<<8|a[2])!==1)return null;var b={data:new Uint8Array(0),packetLength:a[4]<<8|a[5],pts:null,dts:null,nalus:[]};if(b.packetLength&&b.packetLength>a.byteLength-6)return null;var c=a[7];if(c&192){var d=(a[9]&14)*536870912+(a[10]&255)*4194304+(a[11]&254)*16384+(a[12]&255)*128+(a[13]&254)/2;this.referencePts_==null&&(this.referencePts_=d);b.pts=this.handleRollover_(d,this.referencePts_);this.referencePts_=b.pts;b.dts=b.pts;c&64&&(c=(a[14]&
14)*536870912+(a[15]&255)*4194304+(a[16]&254)*16384+(a[17]&255)*128+(a[18]&254)/2,this.referenceDts_==null&&(this.referenceDts_=c),b.dts=b.pts!=d?this.handleRollover_(c,this.referenceDts_):c);this.referenceDts_=b.dts}d=a[8]+9;if(a.byteLength<=d)return null;b.data=a.subarray(d);return b};shaka.util.TsParser.prototype.parseAvcNalus=function(a,b){shaka.Deprecate.deprecateFeature(5,"TsParser.parseAvcNalus","Please use parseNalus function instead.");return this.parseNalus(a,{nalu:null,state:null})};
shaka.util.TsParser.prototype.parseNalus=function(a,b){var c=shaka.util.TsParser.Timescale,d=a.pts?a.pts/c:null;a=a.data;var e=a.byteLength,f=1;this.videoCodec_=="hvc"&&(f=2);var g=b.state||0,h=g,k=0;c=[];var l=-1,m=0;g==-1&&(l=0,m=this.videoCodec_=="hvc"?a[0]>>1&63:a[0]&31,g=0,k=1);for(;k<e;){var n=a[k++];if(g)if(g===1)g=n?0:2;else if(n)if(n==1){n=k-g-1;if(l>=0)g={data:a.subarray(l+f,n),fullData:a.subarray(l,n),type:m,time:d,state:null},c.push(g);else if(g=c.length?c[c.length-1]:b.nalu)h&&k<=4-h&&
g.state&&(g.data=g.data.subarray(0,g.data.byteLength-h),g.fullData=g.fullData.subarray(0,g.fullData.byteLength-h)),n>0&&(n=a.subarray(0,n),g.data=shaka.util.Uint8ArrayUtils.concat(g.data,n),g.fullData=shaka.util.Uint8ArrayUtils.concat(g.fullData,n),g.state=0);k<e?(m=this.videoCodec_=="hvc"?a[k]>>1&63:a[k]&31,l=k,g=0):g=-1}else g=0;else g=3;else g=n?0:1}l>=0&&g>=0&&(d={data:a.subarray(l+f,e),fullData:a.subarray(l,e),type:m,time:d,state:g},c.push(d));!c.length&&b.nalu&&(d=c.length?c[c.length-1]:b.nalu)&&
(d.data=shaka.util.Uint8ArrayUtils.concat(d.data,a),d.fullData=shaka.util.Uint8ArrayUtils.concat(d.fullData,a));b.state=g;return c};
shaka.util.TsParser.prototype.getMetadata=function(){for(var a=shaka.util.TsParser.Timescale,b=[],c=(0,$jscomp.makeIterator)(this.id3Data_),d=c.next();!d.done;d=c.next())d=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(d.value)),(d=this.parsePES_(d))&&b.push({cueTime:d.pts?d.pts/a:null,data:d.data,frames:shaka.util.Id3Utils.getID3Frames(d.data),dts:d.dts,pts:d.pts});return b};
shaka.util.TsParser.prototype.getAudioData=function(){if(this.audioData_.length&&!this.audioPes_.length)for(var a=(0,$jscomp.makeIterator)(this.audioData_),b=a.next();!b.done;b=a.next()){var c=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(b.value)),d=this.parsePES_(c);b=this.audioPes_.length?this.audioPes_[this.audioPes_.length-1]:null;d&&d.pts!=null&&d.dts!=null&&(!b||b.pts!=d.pts&&b.dts!=d.dts)?this.audioPes_.push(d):this.audioPes_.length&&(c=d?
d.data:c)&&(b=this.audioPes_.pop(),b.data=shaka.util.Uint8ArrayUtils.concat(b.data,c),this.audioPes_.push(b))}return this.audioPes_};
shaka.util.TsParser.prototype.getVideoData=function(a){a=a===void 0?!0:a;if(this.videoData_.length&&!this.videoPes_.length){for(var b=(0,$jscomp.makeIterator)(this.videoData_),c=b.next();!c.done;c=b.next()){var d=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(c.value)),e=this.parsePES_(d);c=this.videoPes_.length?this.videoPes_[this.videoPes_.length-1]:null;e&&e.pts!=null&&e.dts!=null&&(!c||c.pts!=e.pts&&c.dts!=e.dts)?this.videoPes_.push(e):this.videoPes_.length&&
(d=e?e.data:d)&&(c=this.videoPes_.pop(),c.data=shaka.util.Uint8ArrayUtils.concat(c.data,d),this.videoPes_.push(c))}if(a){b={nalu:null,state:null};c=[];d=(0,$jscomp.makeIterator)(this.videoPes_);for(e=d.next();!e.done;e=d.next())e=e.value,e.nalus=this.parseNalus(e,b),e.nalus.length&&(c.push(e),b.nalu=e.nalus[e.nalus.length-1]);this.videoPes_=c}}return a?this.videoPes_:(a=this.videoPes_,this.videoPes_=[],a)};
shaka.util.TsParser.prototype.getStartTime=function(a){var b=shaka.util.TsParser.Timescale;if(a=="audio"){a=null;var c=this.getAudioData();c.length&&(a=c[0],a=Math.min(a.dts,a.pts)/b);return a}return a=="video"?(a=null,c=this.getVideoData(!1),c.length&&(a=c[0],a=Math.min(a.dts,a.pts)/b),a):null};shaka.util.TsParser.prototype.getCodecs=function(){return{audio:this.audioCodec_,video:this.videoCodec_}};
shaka.util.TsParser.prototype.getVideoNalus=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.getVideoData()),c=b.next();!c.done;c=b.next())a.push.apply(a,(0,$jscomp.arrayFromIterable)(c.value.nalus));return a};shaka.util.TsParser.prototype.getVideoResolution=function(){shaka.Deprecate.deprecateFeature(5,"TsParser.getVideoResolution","Please use getVideoInfo function instead.");var a=this.getVideoInfo();return{height:a.height,width:a.width}};
shaka.util.TsParser.prototype.getVideoInfo=function(){return this.videoCodec_=="hvc"?this.getHvcInfo_():this.getAvcInfo_()};shaka.util.TsParser.prototype.getFrameRate_=function(){var a=shaka.util.TsParser.Timescale,b=this.getVideoData();if(b.length>1){var c=b[0].pts;goog.asserts.assert(typeof c=="number","Should be an number!");b=b[1].pts;goog.asserts.assert(typeof b=="number","Should be an number!");if(!isNaN(b-c))return String(Math.abs(1/(b-c)*a))}return null};
shaka.util.TsParser.prototype.getAvcInfo_=function(){var a=shaka.util.TsParser,b={height:null,width:null,codec:null,frameRate:null},c=this.getVideoNalus();if(!c.length)return b;c=c.find(function(q){return q.type==a.H264_NALU_TYPE_SPS_});if(!c)return b;c=new shaka.util.ExpGolomb(c.data);var d=c.readUnsignedByte(),e=c.readUnsignedByte(),f=c.readUnsignedByte();c.skipExpGolomb();if(a.PROFILES_WITH_OPTIONAL_SPS_DATA_.includes(d)){var g=c.readUnsignedExpGolomb();g===3&&c.skipBits(1);c.skipExpGolomb();c.skipExpGolomb();
c.skipBits(1);if(c.readBoolean()){g=g!==3?8:12;for(var h=0;h<g;h++)c.readBoolean()&&(h<6?c.skipScalingList(16):c.skipScalingList(64))}}c.skipExpGolomb();g=c.readUnsignedExpGolomb();if(g===0)c.readUnsignedExpGolomb();else if(g===1)for(c.skipBits(1),c.skipExpGolomb(),c.skipExpGolomb(),g=c.readUnsignedExpGolomb(),h=0;h<g;h++)c.skipExpGolomb();c.skipExpGolomb();c.skipBits(1);g=c.readUnsignedExpGolomb();h=c.readUnsignedExpGolomb();var k=c.readBits(1);k===0&&c.skipBits(1);c.skipBits(1);var l=0,m=0,n=0,
p=0;c.readBoolean()&&(l=c.readUnsignedExpGolomb(),m=c.readUnsignedExpGolomb(),n=c.readUnsignedExpGolomb(),p=c.readUnsignedExpGolomb());b.height=String((2-k)*(h+1)*16-n*2-p*2);b.width=String((g+1)*16-l*2-m*2);b.codec="avc1."+this.byteToHex_(d)+this.byteToHex_(e)+this.byteToHex_(f);b.frameRate=this.getFrameRate_();return b};
shaka.util.TsParser.prototype.getHvcInfo_=function(){var a=shaka.util.TsParser,b={height:null,width:null,codec:null,frameRate:null},c=this.getVideoNalus();if(!c.length)return b;c=c.find(function(B){return B.type==a.H265_NALU_TYPE_SPS_});if(!c)return b;var d=new shaka.util.ExpGolomb(c.fullData,!0);d.readUnsignedByte();d.readUnsignedByte();d.readBits(4);var e=d.readBits(3);d.readBoolean();var f=d.readBits(2),g=d.readBits(1),h=d.readBits(5),k=d.readBits(32);c=d.readUnsignedByte();for(var l=d.readUnsignedByte(),
m=d.readUnsignedByte(),n=d.readUnsignedByte(),p=d.readUnsignedByte(),q=d.readUnsignedByte(),r=d.readUnsignedByte(),t=[],w=[],v=0;v<e;v++)t.push(d.readBoolean()),w.push(d.readBoolean());if(e>0)for(v=e;v<8;v++)d.readBits(2);for(v=0;v<e;v++)t[v]&&d.readBits(88),w[v]&&d.readUnsignedByte();d.readUnsignedExpGolomb();e=d.readUnsignedExpGolomb();e==3&&d.readBits(1);t=d.readUnsignedExpGolomb();w=d.readUnsignedExpGolomb();var u=v=0,x=0,z=0;d.readBoolean()&&(v+=d.readUnsignedExpGolomb(),u+=d.readUnsignedExpGolomb(),
x+=d.readUnsignedExpGolomb(),z+=d.readUnsignedExpGolomb());b.width=String(t-(v+u)*(e===1||e===2?2:1));b.height=String(w-(x+z)*(e===1?2:1));d=["","A","B","C"][f];k=function(B){for(var C=0,y=0;y<32;y++)C|=(B>>y&1)<<31-y;return C>>>0}(k);g=g==1?"H":"L";h="hvc1"+("."+d+h)+("."+k.toString(16).toUpperCase());h+="."+g+r;q&&(h+="."+q.toString(16).toUpperCase());p&&(h+="."+p.toString(16).toUpperCase());n&&(h+="."+n.toString(16).toUpperCase());m&&(h+="."+m.toString(16).toUpperCase());l&&(h+="."+l.toString(16).toUpperCase());
c&&(h+="."+c.toString(16).toUpperCase());b.codec=h;b.frameRate=this.getFrameRate_();return b};shaka.util.TsParser.prototype.getOpusMetadata=function(){return this.opusMetadata_};shaka.util.TsParser.prototype.byteToHex_=function(a){return("0"+a.toString(16).toUpperCase()).slice(-2)};shaka.util.TsParser.prototype.handleRollover_=function(a,b){var c=1;for(a>b&&(c=-1);Math.abs(b-a)>4294967296;)a+=c*8589934592;return a};
shaka.util.TsParser.probe=function(a){a=shaka.util.TsParser.syncOffset(a);if(a<0)return!1;a>0&&shaka.log.warning("MPEG2-TS detected but first sync word found @ offset "+a+", junk ahead ?");return!0};shaka.util.TsParser.syncOffset=function(a){for(var b=shaka.util.TsParser.PacketLength_,c=Math.min(1E3,a.length-3*b),d=0;d<c;){if(a[d]==71&&a[d+b]==71&&a[d+2*b]==71)return d;d++}return-1};goog.exportSymbol("shaka.util.TsParser",shaka.util.TsParser);goog.exportProperty(shaka.util.TsParser,"syncOffset",shaka.util.TsParser.syncOffset);
goog.exportProperty(shaka.util.TsParser,"probe",shaka.util.TsParser.probe);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoInfo",shaka.util.TsParser.prototype.getVideoInfo);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoResolution",shaka.util.TsParser.prototype.getVideoResolution);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoNalus",shaka.util.TsParser.prototype.getVideoNalus);goog.exportProperty(shaka.util.TsParser.prototype,"getCodecs",shaka.util.TsParser.prototype.getCodecs);
goog.exportProperty(shaka.util.TsParser.prototype,"getStartTime",shaka.util.TsParser.prototype.getStartTime);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoData",shaka.util.TsParser.prototype.getVideoData);goog.exportProperty(shaka.util.TsParser.prototype,"getAudioData",shaka.util.TsParser.prototype.getAudioData);goog.exportProperty(shaka.util.TsParser.prototype,"getMetadata",shaka.util.TsParser.prototype.getMetadata);goog.exportProperty(shaka.util.TsParser.prototype,"parseNalus",shaka.util.TsParser.prototype.parseNalus);
goog.exportProperty(shaka.util.TsParser.prototype,"parseAvcNalus",shaka.util.TsParser.prototype.parseAvcNalus);goog.exportProperty(shaka.util.TsParser.prototype,"parse",shaka.util.TsParser.prototype.parse);goog.exportProperty(shaka.util.TsParser.prototype,"setDiscontinuitySequence",shaka.util.TsParser.prototype.setDiscontinuitySequence);goog.exportProperty(shaka.util.TsParser.prototype,"clearData",shaka.util.TsParser.prototype.clearData);shaka.util.TsParser.Timescale=9E4;
goog.exportProperty(shaka.util.TsParser,"Timescale",shaka.util.TsParser.Timescale);shaka.util.TsParser.PacketLength_=188;shaka.util.TsParser.H264_NALU_TYPE_SPS_=7;shaka.util.TsParser.H265_NALU_TYPE_SPS_=33;shaka.util.TsParser.PROFILES_WITH_OPTIONAL_SPS_DATA_=[100,110,122,244,44,83,86,118,128,138,139,134];shaka.cea.TsCeaParser=function(){this.seiProcessor_=new shaka.cea.SeiProcessor;this.tsParser_=null};shaka.cea.TsCeaParser.prototype.init=function(a){};
shaka.cea.TsCeaParser.prototype.parse=function(a){var b=shaka.cea.CeaUtils;this.tsParser_?this.tsParser_.clearData():this.tsParser_=new shaka.util.TsParser;var c=[];a=shaka.util.BufferUtils.toUint8(a);if(!shaka.util.TsParser.probe(a))return c;a=this.tsParser_.parse(a);var d=a.getCodecs(),e=a.getVideoNalus();a=[];switch(d.video){case "avc":a.push(b.H264_NALU_TYPE_SEI);break;case "hvc":a.push(b.H265_PREFIX_NALU_TYPE_SEI),a.push(b.H265_SUFFIX_NALU_TYPE_SEI)}if(!a.length)return c;b=(0,$jscomp.makeIterator)(e);
for(d=b.next();!d.done;d=b.next())if(d=d.value,a.includes(d.type)&&d.time!=null){e=(0,$jscomp.makeIterator)(this.seiProcessor_.process(d.data));for(var f=e.next();!f.done;f=e.next())c.push({packet:f.value,pts:d.time})}return c};goog.exportSymbol("shaka.cea.TsCeaParser",shaka.cea.TsCeaParser);shaka.media.ClosedCaptionParser.registerParser("video/mp2t",function(){return new shaka.cea.TsCeaParser});shaka.config.CodecSwitchingStrategy={RELOAD:"reload",SMOOTH:"smooth"};goog.exportSymbol("shaka.config.CodecSwitchingStrategy",shaka.config.CodecSwitchingStrategy);shaka.config.CrossBoundaryStrategy={KEEP:"keep",RESET:"reset",RESET_TO_ENCRYPTED:"reset_to_encrypted",RESET_ON_ENCRYPTION_CHANGE:"RESET_ON_ENCRYPTION_CHANGE"};goog.exportSymbol("shaka.config.CrossBoundaryStrategy",shaka.config.CrossBoundaryStrategy);shaka.config.RepeatMode={OFF:0,ALL:1,SINGLE:2};goog.exportSymbol("shaka.config.RepeatMode",shaka.config.RepeatMode);shaka.debug={};shaka.debug.RunningInLab=!1;shaka.dependencies=function(){};shaka.dependencies.add=function(a,b){if(!shaka.dependencies.Allowed[a])throw Error(a+" is not supported");a==shaka.dependencies.Allowed.muxjs?shaka.Deprecate.deprecateFeature(5,"mux.js","mux.js is no longer used in Shaka Player."):shaka.dependencies.dependencies_.set(a,function(){return b})};shaka.dependencies.has=function(a){return shaka.dependencies.dependencies_.has(a)};shaka.dependencies.isoBoxer=function(){return shaka.dependencies.dependencies_.get(shaka.dependencies.Allowed.ISOBoxer)()};
goog.exportSymbol("shaka.dependencies",shaka.dependencies);goog.exportProperty(shaka.dependencies,"has",shaka.dependencies.has);goog.exportProperty(shaka.dependencies,"add",shaka.dependencies.add);shaka.dependencies.Allowed={muxjs:"muxjs",ISOBoxer:"ISOBoxer"};goog.exportProperty(shaka.dependencies,"Allowed",shaka.dependencies.Allowed);shaka.dependencies.dependencies_=new Map([[shaka.dependencies.Allowed.ISOBoxer,function(){return window.ISOBoxer}]]);shaka.util.Dom=function(){};shaka.util.Dom.createHTMLElement=function(a){return document.createElement(a)};shaka.util.Dom.createSVGElement=function(a){return document.createElementNS("http://www.w3.org/2000/svg",a)};shaka.util.Dom.createButton=function(){var a=document.createElement("button");a.setAttribute("type","button");return a};shaka.util.Dom.createSourceElement=function(a,b){b=b===void 0?"":b;var c=document.createElement("source");c.src=a;c.type=b;return c};
shaka.util.Dom.clearSourceFromVideo=function(a){for(var b=!1,c=a.getElementsByTagName("source"),d=c.length-1;d>=0;--d)a.removeChild(c[d]),b=!0;a.src&&(a.removeAttribute("src"),b=!0);return b};shaka.util.Dom.asHTMLElement=function(a){return a};shaka.util.Dom.asHTMLCanvasElement=function(a){return a};shaka.util.Dom.asHTMLMediaElement=function(a){return a};
shaka.util.Dom.getElementByClassName=function(a,b){b=b.getElementsByClassName(a);goog.asserts.assert(b.length==1,"Should only be one element with class name "+a);return shaka.util.Dom.asHTMLElement(b[0])};shaka.util.Dom.getElementByClassNameIfItExists=function(a,b){b=b.getElementsByClassName(a);if(!b.length)return null;goog.asserts.assert(b.length==1,"Should only be one element with class name "+a);return shaka.util.Dom.asHTMLElement(b[0])};shaka.util.Dom.removeAllChildren=function(a){for(;a.firstChild;)a.removeChild(a.firstChild)};
shaka.util.Dom.anyMediaElement=function(){if(shaka.util.Dom.cachedMediaElement_)return shaka.util.Dom.cachedMediaElement_;shaka.util.Dom.cacheExpirationTimer_||(shaka.util.Dom.cacheExpirationTimer_=new shaka.util.Timer(function(){shaka.util.Dom.cachedMediaElement_=null}));shaka.util.Dom.cachedMediaElement_=document.getElementsByTagName("video")[0]||document.getElementsByTagName("audio")[0];shaka.util.Dom.cachedMediaElement_||(shaka.util.Dom.cachedMediaElement_=document.createElement("video"));shaka.util.Dom.cacheExpirationTimer_.tickAfter(1);
return shaka.util.Dom.cachedMediaElement_};
shaka.util.Dom.addFont=function(a,b){var c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return"fonts"in document&&"FontFace"in window?h.yield(document.fonts.ready,2):h.return();if(!("entries"in document.fonts))return h.return();c=function(k){k=k.entries();for(var l=[],m=k.next();m.done===!1;)l.push(m.value),m=k.next();return l};d=(0,$jscomp.makeIterator)(c(document.fonts));for(e=d.next();!e.done;e=d.next())if(f=e.value,f.family===a&&f.display==="swap")return h.return();
g=new FontFace(a,"url("+b+")",{display:"swap"});document.fonts.add(g);h.jumpToEnd()})};goog.exportSymbol("shaka.util.Dom",shaka.util.Dom);goog.exportProperty(shaka.util.Dom,"removeAllChildren",shaka.util.Dom.removeAllChildren);goog.exportProperty(shaka.util.Dom,"clearSourceFromVideo",shaka.util.Dom.clearSourceFromVideo);shaka.util.Dom.cacheExpirationTimer_=null;shaka.util.Dom.cachedMediaElement_=null;shaka.device.AbstractDevice=function(){this.abstractDeviceType_=new shaka.util.Lazy(function(){return["Oculus","Quest"].some(function(a){return navigator.userAgent.includes(a.toLowerCase())})?shaka.device.IDevice.DeviceType.VR:navigator.userAgent.match(/Smart( ?|_)TV/i)||navigator.userAgent.match(/Android ?TV/i)?shaka.device.IDevice.DeviceType.TV:navigator.userAgentData?navigator.userAgentData.mobile?shaka.device.IDevice.DeviceType.MOBILE:shaka.device.IDevice.DeviceType.DESKTOP:/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)?
shaka.device.IDevice.DeviceType.MOBILE:navigator.userAgentData&&navigator.userAgentData.platform?navigator.userAgentData.platform.toLowerCase()=="android"?shaka.device.IDevice.DeviceType.MOBILE:shaka.device.IDevice.DeviceType.DESKTOP:navigator.userAgent.includes("Android")?shaka.device.IDevice.DeviceType.MOBILE:shaka.device.IDevice.DeviceType.DESKTOP});this.browserEngine_=new shaka.util.Lazy(function(){return navigator.vendor.includes("Apple")&&(navigator.userAgent.includes("Version/")||navigator.userAgent.includes("OS/"))?
shaka.device.IDevice.BrowserEngine.WEBKIT:navigator.userAgent.includes("Edge/")?shaka.device.IDevice.BrowserEngine.EDGE:navigator.userAgent.includes("Chrome/")?shaka.device.IDevice.BrowserEngine.CHROMIUM:navigator.userAgent.includes("Firefox/")?shaka.device.IDevice.BrowserEngine.GECKO:shaka.device.IDevice.BrowserEngine.UNKNOWN})};shaka.device.AbstractDevice.prototype.supportsMediaSource=function(){var a=window.ManagedMediaSource||window.MediaSource;return a&&a.isTypeSupported?!0:!1};
shaka.device.AbstractDevice.prototype.supportsMediaType=function(a){return shaka.util.Dom.anyMediaElement().canPlayType(a)!=""};shaka.device.AbstractDevice.prototype.supportsMediaCapabilities=function(){return!!navigator.mediaCapabilities};shaka.device.AbstractDevice.prototype.getDeviceType=function(){return this.abstractDeviceType_.value()};shaka.device.AbstractDevice.prototype.getBrowserEngine=function(){return this.browserEngine_.value()};
shaka.device.AbstractDevice.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){return!1};shaka.device.AbstractDevice.prototype.requiresClearAndEncryptedInitSegments=function(){return!1};shaka.device.AbstractDevice.prototype.insertEncryptionDataBeforeClear=function(){return!1};shaka.device.AbstractDevice.prototype.requiresTfhdFix=function(a){return!1};shaka.device.AbstractDevice.prototype.requiresEC3InitSegments=function(){return!1};
shaka.device.AbstractDevice.prototype.supportsSequenceMode=function(){return!0};shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching=function(){return!0};shaka.device.AbstractDevice.prototype.supportsServerCertificate=function(){return!0};shaka.device.AbstractDevice.prototype.seekDelay=function(){return 0};shaka.device.AbstractDevice.prototype.detectMaxHardwareResolution=function(){return Promise.resolve({width:Infinity,height:Infinity})};
shaka.device.AbstractDevice.prototype.shouldOverrideDolbyVisionCodecs=function(){return!1};shaka.device.AbstractDevice.prototype.shouldAvoidUseTextDecoderEncoder=function(){return!1};shaka.device.AbstractDevice.prototype.adjustConfig=function(a){var b=this.getDeviceType();if(b===shaka.device.IDevice.DeviceType.TV||b===shaka.device.IDevice.DeviceType.CONSOLE||b===shaka.device.IDevice.DeviceType.CAST)a.ads.customPlayheadTracker=!0,a.ads.skipPlayDetection=!0,a.ads.supportsMultipleMediaElements=!1;return a};
shaka.device.AbstractDevice.prototype.supportsOfflineStorage=function(){return!!window.indexedDB};shaka.device.AbstractDevice.prototype.rejectCodecs=function(){return[]};shaka.device.AbstractDevice.prototype.getHdrLevel=function(a){return window.matchMedia!==void 0&&window.matchMedia("(color-gamut: p3)").matches?a?"HLG":"PQ":"SDR"};shaka.device.AbstractDevice.prototype.supportsAirPlay=function(){return!1};shaka.device.AbstractDevice.prototype.misreportAC3UsingDrm=function(){return!1};
shaka.device.AbstractDevice.prototype.returnLittleEndianUsingPlayReady=function(){return!1};shaka.device.AbstractDevice.prototype.supportsEncryptionSchemePolyfill=function(){return!0};shaka.device.AbstractDevice.prototype.misreportsSupportForPersistentLicenses=function(){return!1};shaka.device.AbstractDevice.prototype.supportStandardVP9Checking=function(){return!0};shaka.device.AbstractDevice.prototype.createMediaKeysWhenCheckingSupport=function(){return!0};
shaka.device.AbstractDevice.prototype.disableHEVCSupport=function(){return!1};shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){return!1};shaka.device.AbstractDevice.prototype.needWaitForEncryptedEvent=function(a){return a==="com.apple.fps"};shaka.device.AbstractDevice.prototype.supportsContainerChangeType=function(){return!0};
shaka.device.AbstractDevice.prototype.toString=function(){return"Device: "+this.getDeviceName()+" v"+this.getVersion()+"; Type: "+this.getDeviceType()};shaka.device.AppleBrowser=function(){shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/Version\/(\d+)/);return a?parseInt(a[1],10):(a=navigator.userAgent.match(/OS (\d+)(?:_\d+)?/))?parseInt(a[1],10):null});this.deviceType_=new shaka.util.Lazy(function(){return/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1?"xr"in navigator?shaka.device.IDevice.DeviceType.APPLE_VR:shaka.device.IDevice.DeviceType.MOBILE:
"xr"in navigator?shaka.device.IDevice.DeviceType.APPLE_VR:shaka.device.IDevice.DeviceType.DESKTOP})};$jscomp.inherits(shaka.device.AppleBrowser,shaka.device.AbstractDevice);shaka.device.AppleBrowser.prototype.getVersion=function(){return this.version_.value()};shaka.device.AppleBrowser.prototype.getDeviceName=function(){return"Apple Browser"};shaka.device.AppleBrowser.prototype.getDeviceType=function(){return this.deviceType_.value()};shaka.device.AppleBrowser.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};
shaka.device.AppleBrowser.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.AppleBrowser.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){return b==="audio"};shaka.device.AppleBrowser.prototype.insertEncryptionDataBeforeClear=function(){return!0};shaka.device.AppleBrowser.prototype.requiresTfhdFix=function(a){return a==="audio"};
shaka.device.AppleBrowser.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.abr.minTimeToSwitch=.5;return a};shaka.device.AppleBrowser.prototype.supportsAirPlay=function(){return!0};shaka.device.AppleBrowser.prototype.supportsContainerChangeType=function(){return!1};
shaka.device.AppleBrowser.isAppleBrowser_=function(){return(navigator.vendor||"").includes("Apple")?/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1||navigator.userAgentData&&navigator.userAgentData.platform&&navigator.userAgentData.platform.toLowerCase()=="macos"||navigator.platform&&navigator.platform.toLowerCase().includes("mac")?!0:!1:!1};shaka.device.AppleBrowser.isAppleBrowser_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.AppleBrowser});shaka.device.Chromecast=function(){if(!shaka.device.Chromecast.isChromecast_())throw Error("Not a Chromecast device!");shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/);return a?parseInt(a[1],10):null});this.osType_=new shaka.util.Lazy(function(){var a=navigator.userAgentData&&navigator.userAgentData.platform||navigator.userAgent;a=a.toLowerCase();return a.includes("android")?shaka.device.Chromecast.OsType_.ANDROID:
a.includes("fuchsia")?shaka.device.Chromecast.OsType_.FUCHSIA:shaka.device.Chromecast.OsType_.LINUX})};$jscomp.inherits(shaka.device.Chromecast,shaka.device.AbstractDevice);shaka.device.Chromecast.prototype.getVersion=function(){return this.version_.value()};shaka.device.Chromecast.prototype.getDeviceName=function(){return"Chromecast with "+this.osType_.value()};shaka.device.Chromecast.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CAST};
shaka.device.Chromecast.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};shaka.device.Chromecast.prototype.supportsMediaCapabilities=function(){return shaka.device.AbstractDevice.prototype.supportsMediaCapabilities.call(this)&&this.osType_.value()!==shaka.device.Chromecast.OsType_.LINUX};shaka.device.Chromecast.prototype.supportsSmoothCodecSwitching=function(){return this.osType_.value()!==shaka.device.Chromecast.OsType_.LINUX};
shaka.device.Chromecast.prototype.seekDelay=function(){switch(this.osType_.value()){case shaka.device.Chromecast.OsType_.ANDROID:return 0;case shaka.device.Chromecast.OsType_.FUCHSIA:return 3;default:return 1}};
shaka.device.Chromecast.prototype.detectMaxHardwareResolution=function(){var a,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){switch(f.nextAddress){case 1:a=window.cast&&cast.__platform__&&cast.__platform__.canDisplayType;b={width:1280,height:720};f.setCatchFinallyBlocks(2);if(!(c=a)){f.jumpTo(4);break}return f.yield(cast.__platform__.canDisplayType('video/mp4; codecs="avc1.640028"; width=3840; height=2160'),5);case 5:c=f.yieldResult;case 4:if(c){b.width=3840;b.height=2160;
f.jumpTo(6);break}if(!(d=a)){f.jumpTo(7);break}return f.yield(cast.__platform__.canDisplayType('video/mp4; codecs="avc1.640028"; width=1920; height=1080'),8);case 8:d=f.yieldResult;case 7:d&&(b.width=1920,b.height=1080);case 6:f.leaveTryBlock(3);break;case 2:e=f.enterCatchBlock(),shaka.log.alwaysError("Failed to check canDisplayType:",e);case 3:return f.return(b)}})};
shaka.device.Chromecast.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.streaming.stallSkip=0;return a};shaka.device.Chromecast.prototype.supportsOfflineStorage=function(){return!1};shaka.device.Chromecast.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){return!0};shaka.device.Chromecast.isChromecast_=function(){return navigator.userAgent.includes("CrKey")&&!navigator.userAgent.includes("VIZIO SmartCast")};
shaka.device.Chromecast.OsType_={ANDROID:"Android",FUCHSIA:"Fuchsia",LINUX:"Linux"};shaka.device.Chromecast.isChromecast_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Chromecast});shaka.drm={};shaka.drm.DrmUtils=function(){};shaka.drm.DrmUtils.isBrowserSupported=function(){return!!window.MediaKeys&&!!window.navigator&&!!window.navigator.requestMediaKeySystemAccess&&!!window.MediaKeySystemAccess&&!!window.MediaKeySystemAccess.prototype.getConfiguration};
shaka.drm.DrmUtils.areDrmCompatible=function(a,b){if(a===b||!a.length||!b.length)return!0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;if(shaka.drm.DrmUtils.isClearKeyWihRawKey_(c))return!0;for(var d=(0,$jscomp.makeIterator)(b),e=d.next();!e.done;e=d.next())if(e=e.value,c.keySystem===e.keySystem||shaka.drm.DrmUtils.isClearKeyWihRawKey_(e))return!0}return!1};
shaka.drm.DrmUtils.getCommonDrmInfos=function(a,b){if(!a.length)return b;if(!b.length)return a;var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())if(f=f.value,d.keySystem==f.keySystem){e=new Map;var g=(d.initData||[]).concat(f.initData||[]);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,e.set(h.keyId,h);e=Array.from(e.values());g=d.keyIds&&f.keyIds?new Set([].concat((0,$jscomp.arrayFromIterable)(d.keyIds),
(0,$jscomp.arrayFromIterable)(f.keyIds))):d.keyIds||f.keyIds;c.push({keySystem:d.keySystem,licenseServerUri:d.licenseServerUri||f.licenseServerUri,distinctiveIdentifierRequired:d.distinctiveIdentifierRequired||f.distinctiveIdentifierRequired,persistentStateRequired:d.persistentStateRequired||f.persistentStateRequired,videoRobustness:d.videoRobustness||f.videoRobustness,audioRobustness:d.audioRobustness||f.audioRobustness,serverCertificate:d.serverCertificate||f.serverCertificate,serverCertificateUri:d.serverCertificateUri||
f.serverCertificateUri,initData:e,keyIds:g});break}else shaka.drm.DrmUtils.isClearKeyWihRawKey_(d)?c.push(d):shaka.drm.DrmUtils.isClearKeyWihRawKey_(f)&&c.push(f)}return c};shaka.drm.DrmUtils.keySystem=function(a){return a?a.keySystem:""};shaka.drm.DrmUtils.isClearKeySystem=function(a){return a==="org.w3.clearkey"};shaka.drm.DrmUtils.isWidevineKeySystem=function(a){return a?!!a.match(/^com\.widevine\.alpha/):!1};
shaka.drm.DrmUtils.isPlayReadyKeySystem=function(a){return a?!!a.match(/^com\.(microsoft|chromecast)\.playready/):!1};shaka.drm.DrmUtils.isFairPlayKeySystem=function(a){return a?!!a.match(/^com\.apple\.fps/):!1};shaka.drm.DrmUtils.isWisePlayKeySystem=function(a){return a==="com.huawei.wiseplay"};shaka.drm.DrmUtils.isClearKeyWihRawKey_=function(a){return(a=a.licenseServerUri)?a.startsWith("data:application/json;base64,"):!1};
shaka.drm.DrmUtils.generateKeySystemCacheKey_=function(a,b,c){return a+"#"+b+"#"+c};shaka.drm.DrmUtils.hasMediaKeySystemAccess=function(a,b,c){var d=shaka.drm.DrmUtils;a=d.generateKeySystemCacheKey_(a,b,c);return d.memoizedMediaKeySystemAccessRequests_.has(a)};shaka.drm.DrmUtils.getMediaKeySystemAccess=function(a,b,c){var d=shaka.drm.DrmUtils;a=d.generateKeySystemCacheKey_(a,b,c);return d.memoizedMediaKeySystemAccessRequests_.get(a)||null};
shaka.drm.DrmUtils.setMediaKeySystemAccess=function(a,b,c,d){var e=shaka.drm.DrmUtils;a=e.generateKeySystemCacheKey_(a,b,c);e.memoizedMediaKeySystemAccessRequests_.set(a,d)};shaka.drm.DrmUtils.clearMediaKeySystemAccessMap=function(){shaka.drm.DrmUtils.memoizedMediaKeySystemAccessRequests_.clear()};shaka.drm.DrmUtils.isMediaKeysPolyfilled=function(a){return a===window.shakaMediaKeysPolyfill};shaka.drm.DrmUtils.DUMMY_KEY_ID=new shaka.util.Lazy(function(){return shaka.util.BufferUtils.toArrayBuffer(new Uint8Array([0]))});
shaka.drm.DrmUtils.memoizedMediaKeySystemAccessRequests_=new Map;shaka.device.DefaultBrowser=function(){shaka.device.AbstractDevice.call(this);var a=this;this.version_=new shaka.util.Lazy(function(){var b=navigator.userAgent.match(/(Chrome|Firefox)\/(\d+)/);return b?parseInt(b[2],10):null});this.deviceName_=new shaka.util.Lazy(function(){return navigator.userAgent.match(/Edge?\//)?"Edge":navigator.userAgent.includes("Chrome")?"Chrome":navigator.userAgent.includes("Firefox")?"Firefox":"Unknown"});this.isWindows_=new shaka.util.Lazy(function(){return navigator.userAgentData&&
navigator.userAgentData.platform?navigator.userAgentData.platform.toLowerCase()=="windows":navigator.platform?navigator.platform.toLowerCase().includes("win32"):!1});this.supportsSmoothCodecSwitching_=new shaka.util.Lazy(function(){return navigator.userAgent.match(/Edge?\//)?!a.isWindows_.value():!0});this.isSonyTV_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("sony.hbbtv.tv")});this.isAndroid_=new shaka.util.Lazy(function(){return navigator.userAgentData&&navigator.userAgentData.platform?
navigator.userAgentData.platform.toLowerCase()=="android":navigator.userAgent.includes("Android")?!0:!1})};$jscomp.inherits(shaka.device.DefaultBrowser,shaka.device.AbstractDevice);shaka.device.DefaultBrowser.prototype.getVersion=function(){return this.version_.value()};shaka.device.DefaultBrowser.prototype.getDeviceName=function(){return this.deviceName_.value()};
shaka.device.DefaultBrowser.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return shaka.drm.DrmUtils.isPlayReadyKeySystem(a)?this.deviceName_.value()==="Edge"&&this.isWindows_.value():!1};shaka.device.DefaultBrowser.prototype.requiresClearAndEncryptedInitSegments=function(){return this.deviceName_.value()==="Edge"&&this.isWindows_.value()};shaka.device.DefaultBrowser.prototype.insertEncryptionDataBeforeClear=function(){return this.deviceName_.value()==="Edge"&&this.isWindows_.value()};
shaka.device.DefaultBrowser.prototype.supportsSmoothCodecSwitching=function(){return this.supportsSmoothCodecSwitching_.value()};
shaka.device.DefaultBrowser.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);if(this.isWindows_.value())switch(this.deviceName_.value()){case "Firefox":a.drm.keySystemsMapping={"com.microsoft.playready":"com.microsoft.playready.recommendation"};break;case "Chrome":a.drm.keySystemsMapping={"com.microsoft.playready":"com.microsoft.playready.recommendation.3000","com.microsoft.playready.recommendation":"com.microsoft.playready.recommendation.3000"}}this.isAndroid_.value()&&
(a.drm.defaultAudioRobustnessForWidevine="",a.drm.defaultVideoRobustnessForWidevine="");return a};shaka.device.DefaultBrowser.prototype.returnLittleEndianUsingPlayReady=function(){return this.deviceName_.value()==="Edge"||this.isSonyTV_.value()};shaka.device.DefaultBrowser.prototype.createMediaKeysWhenCheckingSupport=function(){return goog.DEBUG&&shaka.debug.RunningInLab&&this.isWindows_.value()&&this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO?!1:!0};
shaka.device.DefaultBrowser.prototype.disableHEVCSupport=function(){return this.isWindows_.value()&&this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO};shaka.device.DefaultBrowser.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){if(this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO){var a=this.getVersion();return a!==null?a>=100:shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)}return shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)};
shaka.device.DefaultBrowser.prototype.needWaitForEncryptedEvent=function(a){return this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO?a.startsWith("com.microsoft.playready.recommendation"):shaka.device.AbstractDevice.prototype.needWaitForEncryptedEvent.call(this,a)};shaka.device.DeviceFactory.registerDefaultDeviceFactory(function(){return new shaka.device.DefaultBrowser});shaka.device.Hisense=function(){shaka.device.AbstractDevice.apply(this,arguments)};$jscomp.inherits(shaka.device.Hisense,shaka.device.AbstractDevice);shaka.device.Hisense.prototype.getVersion=function(){return null};shaka.device.Hisense.prototype.getDeviceName=function(){return"Hisense"};shaka.device.Hisense.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Hisense.prototype.supportsMediaCapabilities=function(){return!1};
shaka.device.Hisense.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080},b=null;if(window.Hisense_Get4KSupportState)try{b=window.Hisense_Get4KSupportState()}catch(c){shaka.log.debug("Hisense: Failed to get 4K support state",c)}b==null&&(b=navigator.userAgent.includes("UHD"));b&&(a.width=3840,a.height=2160);return Promise.resolve(a)};
shaka.device.Hisense.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.streaming.stallSkip=0;return a};shaka.device.Hisense.isHisense_=function(){return navigator.userAgent.includes("Hisense")||navigator.userAgent.includes("VIDAA")};shaka.device.Hisense.isHisense_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Hisense});shaka.device.PlayStation=function(){shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/PlayStation (\d+)/);return a?parseInt(a[1],10):null})};$jscomp.inherits(shaka.device.PlayStation,shaka.device.AbstractDevice);shaka.device.PlayStation.prototype.getDeviceName=function(){return"PlayStation"};shaka.device.PlayStation.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CONSOLE};
shaka.device.PlayStation.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};shaka.device.PlayStation.prototype.getVersion=function(){return this.version_.value()};shaka.device.PlayStation.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.PlayStation.prototype.supportsSequenceMode=function(){return!1};shaka.device.PlayStation.prototype.supportsSmoothCodecSwitching=function(){return!1};
shaka.device.PlayStation.prototype.shouldAvoidUseTextDecoderEncoder=function(){return this.getVersion()===4};
shaka.device.PlayStation.prototype.detectMaxHardwareResolution=function(){var a,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){switch(f.nextAddress){case 1:return a={width:1920,height:1080},b=!1,f.setCatchFinallyBlocks(2),f.yield(window.msdk.device.getDisplayInfo(),4);case 4:c=f.yieldResult;b=c.resolution==="4K";f.leaveTryBlock(3);break;case 2:return f.enterCatchBlock(),f.setCatchFinallyBlocks(5),f.yield(window.msdk.device.getDisplayInfoImmediate(),7);case 7:d=f.yieldResult;
b=d.resolution==="4K";f.leaveTryBlock(3);break;case 5:e=f.enterCatchBlock(),shaka.log.alwaysWarn("PlayStation: Failed to get the display info:",e);case 3:return b&&(a.width=3840,a.height=2160),f.return(a)}})};shaka.device.PlayStation.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);this.getVersion()===4&&a.drm.preferredKeySystems.push("com.microsoft.playready");a.streaming.clearDecodingCache=!0;return a};
shaka.device.PlayStation.prototype.returnLittleEndianUsingPlayReady=function(){return this.getVersion()===4};shaka.device.PlayStation.prototype.supportsEncryptionSchemePolyfill=function(){return this.getVersion()!==4};shaka.device.PlayStation.isPlayStation_=function(){return navigator.userAgent.includes("PlayStation")};shaka.device.PlayStation.isPlayStation_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.PlayStation});shaka.device.Tizen=function(){shaka.device.AbstractDevice.call(this);var a=navigator.userAgent.match(/Tizen (\d+).(\d+)/);this.osMajorVersion_=a?parseInt(a[1],10):null;this.osMinorVersion_=a?parseInt(a[2],10):null};$jscomp.inherits(shaka.device.Tizen,shaka.device.AbstractDevice);shaka.device.Tizen.prototype.getVersion=function(){return this.osMajorVersion_};shaka.device.Tizen.prototype.getDeviceName=function(){return"Tizen"};shaka.device.Tizen.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};
shaka.device.Tizen.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Tizen.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return!0};shaka.device.Tizen.prototype.requiresEC3InitSegments=function(){return this.getVersion()===3};shaka.device.Tizen.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.Tizen.prototype.supportsSequenceMode=function(){var a=this.getVersion();return a!==null?a>=4:shaka.device.AbstractDevice.prototype.supportsSequenceMode.call(this)};
shaka.device.Tizen.prototype.supportsSmoothCodecSwitching=function(){return!1};shaka.device.Tizen.prototype.supportsServerCertificate=function(){return this.osMajorVersion_&&this.osMinorVersion_?this.osMajorVersion_===5?this.osMinorVersion_>=5:this.osMajorVersion_>5:shaka.device.AbstractDevice.prototype.supportsServerCertificate.call(this)};
shaka.device.Tizen.prototype.detectMaxHardwareResolution=function(){var a=window.devicePixelRatio;a={width:window.screen.width*a>1920?3840:1920,height:window.screen.height*a>1080?2160:1080};try{if(webapis.systeminfo&&webapis.systeminfo.getMaxVideoResolution){var b=webapis.systeminfo.getMaxVideoResolution();a.width=b.width;a.height=b.height}else webapis.productinfo.is8KPanelSupported&&webapis.productinfo.is8KPanelSupported()?(a.width=7680,a.height=4320):webapis.productinfo.isUdPanelSupported&&webapis.productinfo.isUdPanelSupported()&&
(a.width=3840,a.height=2160)}catch(c){shaka.log.alwaysWarn("Tizen: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};
shaka.device.Tizen.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.drm.ignoreDuplicateInitData=this.getVersion()!==2;this.getVersion()===3&&(a.streaming.crossBoundaryStrategy=shaka.config.CrossBoundaryStrategy.RESET_TO_ENCRYPTED);a.streaming.shouldFixTimestampOffset=!0;a.streaming.stallSkip=0;a.streaming.gapPadding=2;return a};
shaka.device.Tizen.prototype.rejectCodecs=function(){var a=[];this.osMajorVersion_!==null&&this.osMajorVersion_<5&&a.push("opus");return a};shaka.device.Tizen.prototype.getHdrLevel=function(a){try{if(webapis.avinfo.isHdrTvSupport())return a?"HLG":"PQ"}catch(b){return shaka.device.AbstractDevice.prototype.getHdrLevel.call(this,a)}return"SDR"};shaka.device.Tizen.prototype.misreportAC3UsingDrm=function(){return!0};
shaka.device.Tizen.prototype.misreportsSupportForPersistentLicenses=function(){return this.getVersion()===3};shaka.device.Tizen.isTizen_=function(){return navigator.userAgent.includes("Tizen")};shaka.device.Tizen.isTizen_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Tizen});shaka.device.Vizio=function(){shaka.device.AbstractDevice.apply(this,arguments)};$jscomp.inherits(shaka.device.Vizio,shaka.device.AbstractDevice);shaka.device.Vizio.prototype.getVersion=function(){return null};shaka.device.Vizio.prototype.getDeviceName=function(){return"Vizio"};shaka.device.Vizio.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Vizio.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.Vizio.isVizio_=function(){return navigator.userAgent.includes("VIZIO SmartCast")};
shaka.device.Vizio.isVizio_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Vizio});shaka.device.WebKitSTB=function(){shaka.device.AbstractDevice.call(this);this.isSkyQ_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("DT_STB_BCM")||navigator.userAgent.includes("Sky_STB")});this.isOrange_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("SOPOpenBrowser")});this.version_=new shaka.util.Lazy(function(){if(navigator.userAgent.includes("DT_STB_BCM"))return 11;var a=navigator.userAgent.match(/Version\/(\d+)/);return a?parseInt(a[1],10):(a=navigator.userAgent.match(/OS (\d+)(?:_\d+)?/))?
parseInt(a[1],10):null})};$jscomp.inherits(shaka.device.WebKitSTB,shaka.device.AbstractDevice);shaka.device.WebKitSTB.prototype.getVersion=function(){return this.version_.value()};shaka.device.WebKitSTB.prototype.getDeviceName=function(){return"WebKit STB"};shaka.device.WebKitSTB.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.WebKitSTB.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};
shaka.device.WebKitSTB.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.WebKitSTB.prototype.supportsSequenceMode=function(){var a=this.version_.value();return a!==null?a>=15:!0};shaka.device.WebKitSTB.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return this.isOrange_.value()};shaka.device.WebKitSTB.prototype.detectMaxHardwareResolution=function(){return Promise.resolve({width:window.screen.width*window.devicePixelRatio,height:window.screen.height*window.devicePixelRatio})};
shaka.device.WebKitSTB.prototype.supportsEncryptionSchemePolyfill=function(){return!this.isSkyQ_.value()};shaka.device.WebKitSTB.prototype.supportsContainerChangeType=function(){return!1};
shaka.device.WebKitSTB.isWebkitSTB_=function(){return navigator.userAgent.includes("SOPOpenBrowser")||navigator.userAgent.includes("DT_STB_BCM")||navigator.userAgent.includes("Sky_STB")?!0:!(navigator.vendor||"").includes("Apple")||/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1||navigator.userAgentData&&navigator.userAgentData.platform&&navigator.userAgentData.platform.toLowerCase()=="macos"||navigator.platform&&navigator.platform.toLowerCase().includes("mac")?!1:!0};
shaka.device.WebKitSTB.isWebkitSTB_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.WebKitSTB});shaka.device.WebOS=function(){shaka.device.AbstractDevice.call(this);var a=this;this.osVersion_=this.guessWebOSVersion_();this.supportHdr_=null;try{var b=new PalmServiceBridge;b.onservicecallback=function(c){shaka.log.info(c);c=JSON.parse(c);a.supportHdr_=c.configs["tv.model.supportHDR"]||c.configs["tv.config.supportDolbyHDRContents"]||!1};b.call("luna://com.webos.service.config/getConfigs",JSON.stringify({configNames:["tv.model.supportHDR","tv.config.supportDolbyHDRContents"]}))}catch(c){shaka.log.alwaysWarn("WebOS: getConfigs call failed",
c)}};$jscomp.inherits(shaka.device.WebOS,shaka.device.AbstractDevice);shaka.device.WebOS.prototype.getVersion=function(){return this.osVersion_};shaka.device.WebOS.prototype.getDeviceName=function(){return"WebOS"};shaka.device.WebOS.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.WebOS.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};shaka.device.WebOS.prototype.supportsMediaCapabilities=function(){return!1};
shaka.device.WebOS.prototype.supportsSequenceMode=function(){var a=this.getVersion();return a!==null?a>3:shaka.device.AbstractDevice.prototype.supportsSequenceMode.call(this)};shaka.device.WebOS.prototype.supportsSmoothCodecSwitching=function(){var a=this.getVersion();return a!==null?a>6:shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching.call(this)};shaka.device.WebOS.prototype.supportsServerCertificate=function(){var a=this.getVersion();return a!==null?a>3:shaka.device.AbstractDevice.prototype.supportsServerCertificate.call(this)};
shaka.device.WebOS.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080};try{var b=JSON.parse(window.PalmSystem.deviceInfo);a.width=Math.max(1920,b.screenWidth);a.height=Math.max(1080,b.screenHeight)}catch(c){shaka.log.alwaysWarn("WebOS: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};
shaka.device.WebOS.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);this.getVersion()===3&&(a.streaming.crossBoundaryStrategy=shaka.config.CrossBoundaryStrategy.RESET);a.streaming.shouldFixTimestampOffset=!0;a.streaming.stallSkip=0;return a};
shaka.device.WebOS.prototype.getHdrLevel=function(a){return this.supportHdr_==null?(shaka.log.alwaysWarn("WebOS: getConfigs call haven't finished"),shaka.device.AbstractDevice.prototype.getHdrLevel.call(this,a)):this.supportHdr_?a?"HLG":"PQ":"SDR"};
shaka.device.WebOS.prototype.guessWebOSVersion_=function(){var a=null,b=navigator.userAgent.match(/Chrome\/(\d+)/);b&&(a=parseInt(b[1],10));switch(a){case 38:return 3;case 53:return 4;case 68:return 5;case 79:return 6;case 87:return 22;case 94:return 23;case 108:return 24;case 120:return 25;default:return null}};shaka.device.WebOS.prototype.supportStandardVP9Checking=function(){return!1};
shaka.device.WebOS.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){var a=this.getVersion();return a!==null?a>=6:shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)};shaka.device.WebOS.isWebOS_=function(){return navigator.userAgent.includes("Web0S")};if(shaka.device.WebOS.isWebOS_()){var webOSDevice=new shaka.device.WebOS;shaka.device.DeviceFactory.registerDeviceFactory(function(){return webOSDevice})};shaka.device.Xbox=function(){shaka.device.AbstractDevice.call(this);this.isLegacyEdge_=navigator.userAgent.includes("Edge/");var a=navigator.userAgent.match(/Edge?\/(\d+)/);this.version_=a?parseInt(a[1],10):null};$jscomp.inherits(shaka.device.Xbox,shaka.device.AbstractDevice);shaka.device.Xbox.prototype.getVersion=function(){return this.version_};shaka.device.Xbox.prototype.getDeviceName=function(){return"Xbox"};shaka.device.Xbox.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CONSOLE};
shaka.device.Xbox.prototype.getBrowserEngine=function(){return this.isLegacyEdge_?shaka.device.IDevice.BrowserEngine.EDGE:shaka.device.IDevice.BrowserEngine.CHROMIUM};shaka.device.Xbox.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return!0};shaka.device.Xbox.prototype.insertEncryptionDataBeforeClear=function(){return!0};shaka.device.Xbox.prototype.shouldOverrideDolbyVisionCodecs=function(){return this.isLegacyEdge_};
shaka.device.Xbox.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080},b=shaka.device.Xbox.getWinRT_();if(b)try{var c=new b.Media.Protection.ProtectionCapabilities,d=b.Media.Protection.ProtectionCapabilityResult;b=null;do b=c.isTypeSupported('video/mp4;codecs="hvc1,mp4a";features="decode-res-x=3840,decode-res-y=2160,decode-bitrate=20000,decode-fps=30,decode-bpc=10,display-res-x=3840,display-res-y=2160,display-bpc=8"',"com.microsoft.playready.recommendation");while(b===d.maybe);
b===d.probably&&(a.width=3840,a.height=2160)}catch(e){shaka.log.alwaysWarn("Xbox: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};shaka.device.Xbox.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.drm.parseInbandPsshEnabled=this.isLegacyEdge_;a.drm.preferredKeySystems.push("com.microsoft.playready");this.isLegacyEdge_&&(a.streaming.gapPadding=.01);return a};
shaka.device.Xbox.prototype.supportsOfflineStorage=function(){return!1};shaka.device.Xbox.getWinRT_=function(){var a=null;try{a=typeof Windows!=="undefined"?Windows:chrome.webview.hostObjects.sync.Windows}catch(b){}return a};shaka.device.Xbox.isXbox_=function(){return navigator.userAgent.includes("Xbox One")||shaka.device.Xbox.getWinRT_()!==null};shaka.device.Xbox.isXbox_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Xbox});shaka.net={};
shaka.net.Backoff=function(a,b){b=b===void 0?!1:b;var c=shaka.net.Backoff.defaultRetryParameters();this.maxAttempts_=a.maxAttempts==null?c.maxAttempts:a.maxAttempts;goog.asserts.assert(this.maxAttempts_>=1,"maxAttempts should be >= 1");this.baseDelay_=a.baseDelay==null?c.baseDelay:a.baseDelay;goog.asserts.assert(this.baseDelay_>=0,"baseDelay should be >= 0");this.fuzzFactor_=a.fuzzFactor==null?c.fuzzFactor:a.fuzzFactor;goog.asserts.assert(this.fuzzFactor_>=0,"fuzzFactor should be >= 0");this.backoffFactor_=
a.backoffFactor==null?c.backoffFactor:a.backoffFactor;goog.asserts.assert(this.backoffFactor_>=0,"backoffFactor should be >= 0");this.numAttempts_=0;this.nextUnfuzzedDelay_=this.baseDelay_;if(this.autoReset_=b)goog.asserts.assert(this.maxAttempts_>=2,"maxAttempts must be >= 2 for autoReset == true"),this.numAttempts_=1};
shaka.net.Backoff.prototype.attempt=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.nextAddress==1){if(a.numAttempts_>=a.maxAttempts_)if(a.autoReset_)a.reset_();else throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.ATTEMPTS_EXHAUSTED);b=a.numAttempts_;a.numAttempts_++;if(b==0)return goog.asserts.assert(!a.autoReset_,"Failed to delay with auto-reset!"),d.return();c=shaka.net.Backoff.fuzz_(a.nextUnfuzzedDelay_,
a.fuzzFactor_);return d.yield(new Promise(function(e){shaka.net.Backoff.defer(c,e)}),2)}a.nextUnfuzzedDelay_*=a.backoffFactor_;d.jumpToEnd()})};shaka.net.Backoff.defaultRetryParameters=function(){return{maxAttempts:2,baseDelay:1E3,backoffFactor:2,fuzzFactor:.5,timeout:3E4,stallTimeout:5E3,connectionTimeout:1E4}};shaka.net.Backoff.fuzz_=function(a,b){return a*(1+(Math.random()*2-1)*b)};
shaka.net.Backoff.prototype.reset_=function(){goog.asserts.assert(this.autoReset_,"Should only be used for auto-reset!");this.numAttempts_=1;this.nextUnfuzzedDelay_=this.baseDelay_};shaka.net.Backoff.defer=function(a,b){(new shaka.util.Timer(b)).tickAfter(a/1E3)};shaka.util.PublicPromise=function(){var a,b,c=new Promise(function(d,e){a=d;b=e});c.resolve=a;c.reject=b;return c};shaka.util.PublicPromise.prototype.resolve=function(a){};shaka.util.PublicPromise.prototype.reject=function(a){};shaka.util.AbortableOperation=function(a,b){this.promise=a;this.onAbort_=b;this.abortPromise_=null};shaka.util.AbortableOperation.failed=function(a){return new shaka.util.AbortableOperation(Promise.reject(a),function(){return Promise.resolve()})};shaka.util.AbortableOperation.aborted=function(){var a=Promise.reject(shaka.util.AbortableOperation.abortError());a.catch(function(){});return new shaka.util.AbortableOperation(a,function(){return Promise.resolve()})};
shaka.util.AbortableOperation.abortError=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED)};shaka.util.AbortableOperation.completed=function(a){return new shaka.util.AbortableOperation(Promise.resolve(a),function(){return Promise.resolve()})};shaka.util.AbortableOperation.notAbortable=function(a){return new shaka.util.AbortableOperation(a,function(){return a.catch(function(){})})};
shaka.util.AbortableOperation.prototype.abort=function(){this.abortPromise_||(this.abortPromise_=this.onAbort_());return this.abortPromise_};shaka.util.AbortableOperation.all=function(a){return new shaka.util.AbortableOperation(Promise.all(a.map(function(b){return b.promise})),function(){return Promise.all(a.map(function(b){return b.abort()}))})};shaka.util.AbortableOperation.prototype.finally=function(a){this.promise.then(function(b){return a(!0)},function(b){return a(!1)});return this};
shaka.util.AbortableOperation.prototype.chain=function(a,b){var c=this,d=new shaka.util.PublicPromise;d.catch(function(){});var e=shaka.util.AbortableOperation.abortError(),f=function(){d.reject(e);return c.abort()},g=function(h){return function(k){if(c.abortPromise_&&h)d.reject(e);else{var l=h?a:b;l?f=shaka.util.AbortableOperation.wrapChainCallback_(l,k,d):(h?d.resolve:d.reject)(k)}}};this.promise.then(g(!0),g(!1));return new shaka.util.AbortableOperation(d,function(){return f()})};
shaka.util.AbortableOperation.wrapChainCallback_=function(a,b,c){try{var d=a(b);if(d&&d.promise&&d.abort)return c.resolve(d.promise),function(){return d.abort()};c.resolve(d);return function(){return Promise.resolve(d).then(function(){},function(){})}}catch(e){return c.reject(e),function(){return Promise.resolve()}}};$jscomp.global.Object.defineProperties(shaka.util.AbortableOperation.prototype,{aborted:{configurable:!0,enumerable:!0,get:function(){return this.abortPromise_!==null}}});
goog.exportSymbol("shaka.util.AbortableOperation",shaka.util.AbortableOperation);goog.exportProperty(shaka.util.AbortableOperation.prototype,"chain",shaka.util.AbortableOperation.prototype.chain);goog.exportProperty(shaka.util.AbortableOperation.prototype,"finally",shaka.util.AbortableOperation.prototype.finally);goog.exportProperty(shaka.util.AbortableOperation,"all",shaka.util.AbortableOperation.all);goog.exportProperty(shaka.util.AbortableOperation.prototype,"abort",shaka.util.AbortableOperation.prototype.abort);
goog.exportProperty(shaka.util.AbortableOperation,"notAbortable",shaka.util.AbortableOperation.notAbortable);goog.exportProperty(shaka.util.AbortableOperation,"completed",shaka.util.AbortableOperation.completed);goog.exportProperty(shaka.util.AbortableOperation,"aborted",shaka.util.AbortableOperation.aborted);goog.exportProperty(shaka.util.AbortableOperation,"failed",shaka.util.AbortableOperation.failed);shaka.util.FakeEvent=function(a,b){if(b)if(b instanceof Map)for(var c=(0,$jscomp.makeIterator)(b.keys()),d=c.next();!d.done;d=c.next())d=d.value,Object.defineProperty(this,d,{value:b.get(d),writable:!0,enumerable:!0});else for(c in b=shaka.util.FakeEvent.recastDictAsObject_(b),b)Object.defineProperty(this,c,{value:b[c],writable:!0,enumerable:!0});this.defaultPrevented=this.cancelable=this.bubbles=!1;this.timeStamp=window.performance&&window.performance.now?window.performance.now():Date.now();this.type=
a;this.isTrusted=!1;this.target=this.currentTarget=null;this.stopped=!1};shaka.util.FakeEvent.fromRealEvent=function(a){var b=new shaka.util.FakeEvent(a.type),c;for(c in a)Object.defineProperty(b,c,{value:a[c],writable:!0,enumerable:!0});return b};shaka.util.FakeEvent.recastDictAsObject_=function(a){goog.asserts.assert(!(a instanceof Map),"dict should not be a map");return a};shaka.util.FakeEvent.prototype.preventDefault=function(){this.cancelable&&(this.defaultPrevented=!0)};
shaka.util.FakeEvent.prototype.stopImmediatePropagation=function(){this.stopped=!0};shaka.util.FakeEvent.prototype.stopPropagation=function(){};goog.exportSymbol("shaka.util.FakeEvent",shaka.util.FakeEvent);
shaka.util.FakeEvent.EventName={AbrStatusChanged:"abrstatuschanged",Adaptation:"adaptation",AudioTrackChanged:"audiotrackchanged",AudioTracksChanged:"audiotrackschanged",BoundaryCrossed:"boundarycrossed",Buffering:"buffering",CanUpdateStartTime:"canupdatestarttime",Complete:"complete",CurrentItemChanged:"currentitemchanged",DownloadCompleted:"downloadcompleted",DownloadFailed:"downloadfailed",DownloadHeadersReceived:"downloadheadersreceived",DrmSessionUpdate:"drmsessionupdate",Emsg:"emsg",ItemsInserted:"itemsinserted",
ItemsRemoved:"itemsremoved",Prft:"prft",Error:"error",ExpirationUpdated:"expirationupdated",FirstQuartile:"firstquartile",GapJumped:"gapjumped",KeyStatusChanged:"keystatuschanged",Loaded:"loaded",Loading:"loading",ManifestParsed:"manifestparsed",ManifestUpdated:"manifestupdated",MediaQualityChanged:"mediaqualitychanged",MediaSourceRecovered:"mediasourcerecovered",MetadataAdded:"metadataadded",Metadata:"metadata",Midpoint:"midpoint",NoSpatialVideoInfoEvent:"nospatialvideoinfo",OnStateChange:"onstatechange",
RateChange:"ratechange",SegmentAppended:"segmentappended",SessionDataEvent:"sessiondata",SpatialVideoInfoEvent:"spatialvideoinfo",StallDetected:"stalldetected",Started:"started",StateChanged:"statechanged",Streaming:"streaming",TextChanged:"textchanged",TextTrackVisibility:"texttrackvisibility",ThirdQuartile:"thirdquartile",TimelineRegionAdded:"timelineregionadded",TimelineRegionEnter:"timelineregionenter",TimelineRegionExit:"timelineregionexit",TracksChanged:"trackschanged",Unloading:"unloading",
VariantChanged:"variantchanged"};shaka.util.FakeEventTarget=function(){this.listeners_=new shaka.util.MultiMap;this.dispatchTarget=this};shaka.util.FakeEventTarget.prototype.addEventListener=function(a,b,c){this.listeners_&&this.listeners_.push(a,b)};shaka.util.FakeEventTarget.prototype.listenToAllEvents=function(a){this.addEventListener(shaka.util.FakeEventTarget.ALL_EVENTS_,a)};shaka.util.FakeEventTarget.prototype.removeEventListener=function(a,b,c){this.listeners_&&this.listeners_.remove(a,b)};
shaka.util.FakeEventTarget.prototype.dispatchEvent=function(a){goog.asserts.assert(a instanceof shaka.util.FakeEvent,"FakeEventTarget can only dispatch FakeEvents!");if(!this.listeners_)return!0;var b=this.listeners_.get(a.type)||[],c=this.listeners_.get(shaka.util.FakeEventTarget.ALL_EVENTS_);c&&(b=b.concat(c));b=(0,$jscomp.makeIterator)(b);for(c=b.next();!c.done;c=b.next()){c=c.value;a.target=this.dispatchTarget;a.currentTarget=this.dispatchTarget;try{c.handleEvent?c.handleEvent(a):c.call(this,
a)}catch(d){shaka.log.error("Uncaught exception in event handler",d,d?d.message:null,d?d.stack:null)}if(a.stopped)break}return a.defaultPrevented};shaka.util.FakeEventTarget.prototype.release=function(){this.listeners_=null};shaka.util.FakeEventTarget.ALL_EVENTS_="All";shaka.util.OperationManager=function(){this.operations_=[]};shaka.util.OperationManager.prototype.manage=function(a){var b=this;this.operations_.push(a.finally(function(){shaka.util.ArrayUtils.remove(b.operations_,a)}))};shaka.util.OperationManager.prototype.destroy=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.operations_),c=b.next();!c.done;c=b.next())c=c.value,c.promise.catch(function(){}),a.push(c.abort());this.operations_=[];return Promise.all(a)};shaka.net.NetworkingEngine=function(a,b,c,d,e,f,g){shaka.util.FakeEventTarget.call(this);this.config_=null;this.destroyed_=!1;this.operationManager_=new shaka.util.OperationManager;this.requestFilters_=new Set;this.responseFilters_=new Set;this.onProgressUpdated_=a||null;this.onHeadersReceived_=b||null;this.onDownloadCompleted_=c||null;this.onDownloadFailed_=d||null;this.onRequest_=e||null;this.onRetry_=f||null;this.onResponse_=g||null;this.hostCommonAccessTokenMap_=new Map};
$jscomp.inherits(shaka.net.NetworkingEngine,shaka.util.FakeEventTarget);shaka.net.NetworkingEngine.prototype.configure=function(a){this.config_=a};shaka.net.NetworkingEngine.registerScheme=function(a,b,c,d){d=d===void 0?!1:d;goog.asserts.assert(c==void 0||c>0,"explicit priority must be > 0");c=c||shaka.net.NetworkingEngine.PluginPriority.APPLICATION;var e=shaka.net.NetworkingEngine.schemes_.get(a);(!e||c>=e.priority)&&shaka.net.NetworkingEngine.schemes_.set(a,{priority:c,plugin:b,progressSupport:d})};
shaka.net.NetworkingEngine.unregisterScheme=function(a){shaka.net.NetworkingEngine.schemes_.delete(a)};shaka.net.NetworkingEngine.prototype.copyFiltersInto=function(a){for(var b=(0,$jscomp.makeIterator)(this.requestFilters_),c=b.next();!c.done;c=b.next())a.requestFilters_.add(c.value);b=(0,$jscomp.makeIterator)(this.responseFilters_);for(c=b.next();!c.done;c=b.next())a.responseFilters_.add(c.value)};shaka.net.NetworkingEngine.prototype.registerRequestFilter=function(a){this.requestFilters_.add(a)};
shaka.net.NetworkingEngine.prototype.unregisterRequestFilter=function(a){this.requestFilters_.delete(a)};shaka.net.NetworkingEngine.prototype.clearAllRequestFilters=function(){this.requestFilters_.clear()};shaka.net.NetworkingEngine.prototype.registerResponseFilter=function(a){this.responseFilters_.add(a)};shaka.net.NetworkingEngine.prototype.unregisterResponseFilter=function(a){this.responseFilters_.delete(a)};shaka.net.NetworkingEngine.prototype.clearAllResponseFilters=function(){this.responseFilters_.clear()};
shaka.net.NetworkingEngine.prototype.clearCommonAccessTokenMap=function(){this.hostCommonAccessTokenMap_.clear()};shaka.net.NetworkingEngine.defaultRetryParameters=function(){return shaka.net.Backoff.defaultRetryParameters()};shaka.net.NetworkingEngine.makeRequest=function(a,b,c){return{uris:a,method:"GET",body:null,headers:{},allowCrossSiteCredentials:!1,retryParameters:b,licenseRequestType:null,sessionId:null,drmInfo:null,initData:null,initDataType:null,streamDataCallback:c===void 0?null:c}};
shaka.net.NetworkingEngine.prototype.destroy=function(){this.destroyed_=!0;this.requestFilters_.clear();this.responseFilters_.clear();this.hostCommonAccessTokenMap_.clear();shaka.util.FakeEventTarget.prototype.release.call(this);return this.operationManager_.destroy()};
shaka.net.NetworkingEngine.prototype.request=function(a,b,c){var d=this,e=shaka.util.ObjectUtils,f=new shaka.net.NetworkingEngine.NumBytesRemainingClass;if(this.destroyed_)return e=Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED)),e.catch(function(){}),new shaka.net.NetworkingEngine.PendingRequest(e,function(){return Promise.resolve()},f);goog.asserts.assert(b.uris&&b.uris.length,"Request without URIs!");
b.method=b.method||"GET";b.headers=b.headers||{};b.retryParameters=b.retryParameters?e.cloneObject(b.retryParameters):shaka.net.NetworkingEngine.defaultRetryParameters();b.uris=e.cloneObject(b.uris);e=this.filterRequest_(a,b,c);var g=e.chain(function(){return d.makeRequestWithRetry_(a,b,c,f)}),h=g.chain(function(p){return d.filterResponse_(a,p,c)}),k=Date.now(),l=0;e.promise.then(function(){l=Date.now()-k},function(){});var m=0;g.promise.then(function(){m=Date.now()},function(){});var n=h.chain(function(p){var q=
Date.now()-m,r=p.response;r.timeMs+=l;r.timeMs+=q;p.gotProgress||!d.onProgressUpdated_||r.fromCache||b.method=="HEAD"||a!=shaka.net.NetworkingEngine.RequestType.SEGMENT||(p=d.allowSwitch_(c),d.onProgressUpdated_(r.timeMs,r.data.byteLength,p,b,c));if(d.onResponse_)d.onResponse_(a,r,c);return r},function(p){p&&(goog.asserts.assert(p instanceof shaka.util.Error,"Wrong error type"),p.severity=shaka.util.Error.Severity.CRITICAL);throw p;});e=new shaka.net.NetworkingEngine.PendingRequest(n.promise,function(){return n.abort()},
f);this.operationManager_.manage(e);return e};
shaka.net.NetworkingEngine.prototype.filterRequest_=function(a,b,c){var d=shaka.util.AbortableOperation.completed(void 0),e=function(h){d=d.chain(function(){b.body&&(b.body=shaka.util.BufferUtils.toArrayBuffer(b.body));return h(a,b,c)})};this.onRequest_&&e(this.onRequest_);for(var f=(0,$jscomp.makeIterator)(this.requestFilters_),g=f.next();!g.done;g=f.next())e(g.value);return d.chain(void 0,function(h){if(h instanceof shaka.util.Error&&h.code==shaka.util.Error.Code.OPERATION_ABORTED)throw h;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.REQUEST_FILTER_ERROR,h);})};shaka.net.NetworkingEngine.prototype.makeRequestWithRetry_=function(a,b,c,d){var e=new shaka.net.Backoff(b.retryParameters,!1);return this.send_(a,b,c,e,0,null,d)};
shaka.net.NetworkingEngine.prototype.send_=function(a,b,c,d,e,f,g){var h=this;goog.asserts.assert(this.config_,"Config must not be null!");this.config_.forceHTTP&&(b.uris[e]=b.uris[e].replace("https://","http://"));this.config_.forceHTTPS&&(b.uris[e]=b.uris[e].replace("http://","https://"));if(e>0&&this.onRetry_)this.onRetry_(a,c,b.uris[e],b.uris[e-1]);var k=new goog.Uri(b.uris[e]),l=k.getScheme(),m=!1;l||(l=shaka.net.NetworkingEngine.getLocationProtocol_(),goog.asserts.assert(l[l.length-1]==":",
"location.protocol expected to end with a colon!"),l=l.slice(0,-1),k.setScheme(l),b.uris[e]=k.toString());l=l.toLowerCase();var n=(l=shaka.net.NetworkingEngine.schemes_.get(l))?l.plugin:null;if(!n)return shaka.util.AbortableOperation.failed(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.UNSUPPORTED_SCHEME,k));var p=l.progressSupport;(k=this.hostCommonAccessTokenMap_.get(k.getDomain()))&&(b.headers[shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_]=
k);var q=null,r=null,t=!1,w=!1,v;return shaka.util.AbortableOperation.notAbortable(d.attempt()).chain(function(){if(h.destroyed_)return shaka.util.AbortableOperation.aborted();v=Date.now();var u=shaka.net.NetworkingEngine.RequestType.SEGMENT,x=0;b.requestStartTime=Date.now();var z=n(b.uris[e],b,a,function(y,A,D){q&&q.stop();r&&r.tickAfter(C/1E3);if(h.onProgressUpdated_&&a==u){x++;b.packetNumber=x;var E=h.allowSwitch_(c);h.onProgressUpdated_(y,A,E,b,c);m=!0;g.setBytes(D)}},function(y){w=!0;b.timeToFirstByte=
Date.now()-b.requestStartTime;if(h.onHeadersReceived_)h.onHeadersReceived_(y,b,a)},{minBytesForProgressEvents:h.config_.minBytesForProgressEvents});if(!p)return z;var B=b.retryParameters.connectionTimeout;B&&(q=new shaka.util.Timer(function(){t=!0;z.abort()}),q.tickAfter(B/1E3));var C=b.retryParameters.stallTimeout;C&&(r=new shaka.util.Timer(function(){t=!0;z.abort()}));return z}).chain(function(u){q&&q.stop();r&&r.stop();u.timeMs==void 0&&(u.timeMs=Date.now()-v);var x=u.headers[shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_];
if(x){var z=new goog.Uri(u.uri);h.hostCommonAccessTokenMap_.set(z.getDomain(),x)}x={response:u,gotProgress:m};if(!w&&h.onHeadersReceived_)h.onHeadersReceived_(u.headers,b,a);if(h.onDownloadCompleted_)h.onDownloadCompleted_(b,u);return x},function(u){q&&q.stop();r&&r.stop();if(h.onDownloadFailed_){var x=null,z=0;u instanceof shaka.util.Error&&(x=u,u.code==shaka.util.Error.Code.BAD_HTTP_STATUS&&(z=u.data[1]));h.onDownloadFailed_(b,x,z,t)}if(h.destroyed_)return shaka.util.AbortableOperation.aborted();
t&&(u=new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,b.uris[e],a));if(u instanceof shaka.util.Error){if(u.code==shaka.util.Error.Code.OPERATION_ABORTED)throw u;if(u.code==shaka.util.Error.Code.ATTEMPTS_EXHAUSTED)throw goog.asserts.assert(f,"Should have last error"),f;if(u.severity==shaka.util.Error.Severity.RECOVERABLE){x=(new Map).set("error",u);x=new shaka.util.FakeEvent("retry",x);x.cancelable=!0;h.dispatchEvent(x);if(x.defaultPrevented)throw u;
e=(e+1)%b.uris.length;return h.send_(a,b,c,d,e,u,g)}}throw u;})};
shaka.net.NetworkingEngine.prototype.filterResponse_=function(a,b,c){for(var d=shaka.util.AbortableOperation.completed(void 0),e=(0,$jscomp.makeIterator)(this.responseFilters_),f=e.next(),g={};!f.done;g={responseFilter:void 0},f=e.next())g.responseFilter=f.value,d=d.chain(function(h){return function(){var k=b.response;k.data&&(k.data=shaka.util.BufferUtils.toArrayBuffer(k.data));return(0,h.responseFilter)(a,k,c)}}(g));return d.chain(function(){return b},function(h){var k=shaka.util.Error.Severity.CRITICAL;
if(h instanceof shaka.util.Error){if(h.code==shaka.util.Error.Code.OPERATION_ABORTED)throw h;k=h.severity}throw new shaka.util.Error(k,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.RESPONSE_FILTER_ERROR,h);})};shaka.net.NetworkingEngine.prototype.allowSwitch_=function(a){if(a){var b=a.segment;a=a.stream;if(b&&a&&a.fastSwitching&&b.isPartial())return!1}return!0};shaka.net.NetworkingEngine.getLocationProtocol_=function(){return location.protocol};
goog.exportSymbol("shaka.net.NetworkingEngine",shaka.net.NetworkingEngine);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"request",shaka.net.NetworkingEngine.prototype.request);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"destroy",shaka.net.NetworkingEngine.prototype.destroy);goog.exportProperty(shaka.net.NetworkingEngine,"makeRequest",shaka.net.NetworkingEngine.makeRequest);goog.exportProperty(shaka.net.NetworkingEngine,"defaultRetryParameters",shaka.net.NetworkingEngine.defaultRetryParameters);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearCommonAccessTokenMap",shaka.net.NetworkingEngine.prototype.clearCommonAccessTokenMap);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllResponseFilters",shaka.net.NetworkingEngine.prototype.clearAllResponseFilters);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterResponseFilter",shaka.net.NetworkingEngine.prototype.unregisterResponseFilter);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerResponseFilter",shaka.net.NetworkingEngine.prototype.registerResponseFilter);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllRequestFilters",shaka.net.NetworkingEngine.prototype.clearAllRequestFilters);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterRequestFilter",shaka.net.NetworkingEngine.prototype.unregisterRequestFilter);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerRequestFilter",shaka.net.NetworkingEngine.prototype.registerRequestFilter);goog.exportProperty(shaka.net.NetworkingEngine,"unregisterScheme",shaka.net.NetworkingEngine.unregisterScheme);goog.exportProperty(shaka.net.NetworkingEngine,"registerScheme",shaka.net.NetworkingEngine.registerScheme);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"configure",shaka.net.NetworkingEngine.prototype.configure);
shaka.net.NetworkingEngine.NumBytesRemainingClass=function(){this.bytesToLoad_=0};shaka.net.NetworkingEngine.NumBytesRemainingClass.prototype.setBytes=function(a){this.bytesToLoad_=a};shaka.net.NetworkingEngine.NumBytesRemainingClass.prototype.getBytes=function(){return this.bytesToLoad_};goog.exportProperty(shaka.net.NetworkingEngine,"NumBytesRemainingClass",shaka.net.NetworkingEngine.NumBytesRemainingClass);
shaka.net.NetworkingEngine.PendingRequest=function(a,b,c){shaka.util.AbortableOperation.call(this,a,b);this.bytesRemaining_=c};$jscomp.inherits(shaka.net.NetworkingEngine.PendingRequest,shaka.util.AbortableOperation);shaka.net.NetworkingEngine.PendingRequest.prototype.getBytesRemaining=function(){return this.bytesRemaining_.getBytes()};goog.exportProperty(shaka.net.NetworkingEngine,"PendingRequest",shaka.net.NetworkingEngine.PendingRequest);
shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_="common-access-token";shaka.net.NetworkingEngine.RequestType={MANIFEST:0,SEGMENT:1,LICENSE:2,APP:3,TIMING:4,SERVER_CERTIFICATE:5,KEY:6,ADS:7,CONTENT_STEERING:8,CMCD:9};goog.exportProperty(shaka.net.NetworkingEngine,"RequestType",shaka.net.NetworkingEngine.RequestType);
shaka.net.NetworkingEngine.AdvancedRequestType={INIT_SEGMENT:0,MEDIA_SEGMENT:1,MEDIA_PLAYLIST:2,MASTER_PLAYLIST:3,MPD:4,MSS:5,MPD_PATCH:6,MEDIATAILOR_SESSION_INFO:7,MEDIATAILOR_TRACKING_INFO:8,MEDIATAILOR_STATIC_RESOURCE:9,MEDIATAILOR_TRACKING_EVENT:10,INTERSTITIAL_ASSET_LIST:11,INTERSTITIAL_AD_URL:12};goog.exportProperty(shaka.net.NetworkingEngine,"AdvancedRequestType",shaka.net.NetworkingEngine.AdvancedRequestType);shaka.net.NetworkingEngine.PluginPriority={FALLBACK:1,PREFERRED:2,APPLICATION:3};
goog.exportProperty(shaka.net.NetworkingEngine,"PluginPriority",shaka.net.NetworkingEngine.PluginPriority);shaka.net.NetworkingEngine.schemes_=new Map;shaka.util.Destroyer=function(a){this.destroyed_=!1;this.waitOnDestroy_=new shaka.util.PublicPromise;this.onDestroy_=a};shaka.util.Destroyer.prototype.destroyed=function(){return this.destroyed_};shaka.util.Destroyer.prototype.destroy=function(){var a=this;if(this.destroyed_)return this.waitOnDestroy_;this.destroyed_=!0;return this.onDestroy_().then(function(){a.waitOnDestroy_.resolve()},function(){a.waitOnDestroy_.resolve()})};
shaka.util.Destroyer.prototype.ensureNotDestroyed=function(a){if(this.destroyed_){if(a instanceof shaka.util.Error&&a.code==shaka.util.Error.Code.OBJECT_DESTROYED)throw a;throw shaka.util.Destroyer.destroyedError(a);}};shaka.util.Destroyer.destroyedError=function(a){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OBJECT_DESTROYED,a)};shaka.util.Iterables=function(){};shaka.util.Iterables.map=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())c.push(b(d.value));return c};shaka.util.Iterables.every=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(!b(c.value))return!1;return!0};shaka.util.Iterables.some=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(b(c.value))return!0;return!1};
shaka.util.Iterables.filter=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())d=d.value,b(d)&&c.push(d);return c};shaka.util.MapUtils=function(){};shaka.util.MapUtils.asMap=function(a){for(var b=new Map,c=(0,$jscomp.makeIterator)(Object.keys(a)),d=c.next();!d.done;d=c.next())d=d.value,b.set(d,a[d]);return b};shaka.util.MapUtils.asObject=function(a){var b={};a.forEach(function(c,d){b[d]=c});return b};
shaka.util.MapUtils.hasSameElements=function(a,b){if(a||b){if(a&&!b||b&&!a)return!1}else return!0;if(a.size!=b.size)return!1;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;if(!b.has(c))return!1;c=b.get(c);if(c!=d||c==void 0)return!1}return!0};shaka.util.Pssh=function(a){var b=this;this.systemIds=[];this.cencKeyIds=[];this.data=[];(new shaka.util.Mp4Parser).box("moov",shaka.util.Mp4Parser.children).box("moof",shaka.util.Mp4Parser.children).fullBox("pssh",function(c){return b.parsePsshBox_(c)}).parse(a);this.data.length==0&&shaka.log.v2("No pssh box found!")};
shaka.util.Pssh.prototype.parsePsshBox_=function(a){goog.asserts.assert(a.version!=null,"PSSH boxes are full boxes and must have a valid version");goog.asserts.assert(a.flags!=null,"PSSH boxes are full boxes and must have a valid flag");if(a.version>1)shaka.log.warning("Unrecognized PSSH version found!");else{var b=a.reader.getDataView();goog.asserts.assert(b.byteOffset>=12,"DataView at incorrect position");b=shaka.util.BufferUtils.toUint8(b,-12,a.size);this.data.push(b);b=a.reader.readBytes(16,!1);
this.systemIds.push(shaka.util.Uint8ArrayUtils.toHex(b));if(a.version>0){b=a.reader.readUint32();for(var c=0;c<b;c++){var d=a.reader.readBytes(16,!1);d=shaka.util.Uint8ArrayUtils.toHex(d);this.cencKeyIds.push(d)}}}};
shaka.util.Pssh.createPssh=function(a,b,c,d){goog.asserts.assert(b.byteLength==16,"Invalid system ID length");var e=a.length,f=12+b.length+4+e;d>0&&(f+=4+16*c.size);var g=new Uint8Array(f),h=shaka.util.BufferUtils.toDataView(g),k=0;h.setUint32(k,f);k+=4;h.setUint32(k,1886614376);k+=4;d<1?h.setUint32(k,0):h.setUint32(k,16777216);k+=4;g.set(b,k);k+=b.length;if(d>0)for(h.setUint32(k,c.size),k+=4,b=shaka.util.Uint8ArrayUtils,c=(0,$jscomp.makeIterator)(c),d=c.next();!d.done;d=c.next())d=b.fromHex(d.value),
g.set(d,k),k+=d.length;h.setUint32(k,e);k+=4;g.set(a,k);goog.asserts.assert(k+e===f,"PSSH invalid length.");return g};shaka.util.Pssh.getPsshData=function(a){var b=8;a=shaka.util.BufferUtils.toDataView(a);var c=a.getUint8(b);b+=20;c>0&&(b+=4+16*a.getUint32(b));return shaka.util.BufferUtils.toUint8(a,b+4)};
shaka.util.Pssh.normaliseInitData=function(a){if(!a)return a;var b=new shaka.util.Pssh(a);if(b.data.length<=1)return a;a=[];b=(0,$jscomp.makeIterator)(b.data);for(var c=b.next(),d={};!c.done;d={initData$jscomp$9:void 0},c=b.next())d.initData$jscomp$9=c.value,a.some(function(e){return function(f){return shaka.util.BufferUtils.equal(f,e.initData$jscomp$9)}}(d))||a.push(d.initData$jscomp$9);return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(a))};shaka.drm.DrmEngine=function(a){var b=this;this.playerInterface_=a;this.video_=this.mediaKeys_=null;this.initializedForStorage_=this.initialized_=!1;this.licenseTimeSeconds_=0;this.currentDrmInfo_=null;this.eventManager_=new shaka.util.EventManager;this.activeSessions_=new Map;this.activeRequests_=[];this.storedPersistentSessions_=new Map;this.hasInitData_=!1;this.allSessionsLoaded_=new shaka.util.PublicPromise;this.config_=null;this.onError_=function(c){c.severity==shaka.util.Error.Severity.CRITICAL&&
b.allSessionsLoaded_.reject(c);a.onError(c)};this.keyStatusByKeyId_=new Map;this.announcedKeyStatusByKeyId_=new Map;this.keyStatusTimer_=new shaka.util.Timer(function(){return b.processKeyStatusChanges_()});this.usePersistentLicenses_=!1;this.mediaKeyMessageEvents_=[];this.initialRequestsSent_=!1;this.expirationTimer_=new shaka.util.Timer(function(){b.pollExpiration_()});this.allSessionsLoaded_.catch(function(){});this.destroyer_=new shaka.util.Destroyer(function(){return b.destroyNow_()});this.srcEquals_=
!1;this.manifestInitData_=this.mediaKeysAttached_=null;this.isPreload_=function(){return!1}};shaka.drm.DrmEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.drm.DrmEngine.prototype.destroyNow_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.nextAddress){case 1:return a.eventManager_.release(),a.eventManager_=null,a.allSessionsLoaded_.reject(),a.expirationTimer_.stop(),a.expirationTimer_=null,a.keyStatusTimer_.stop(),a.keyStatusTimer_=null,c.yield(a.closeOpenSessions_(),2);case 2:if(!a.video_){c.jumpTo(3);break}shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")||goog.asserts.assert(!a.video_.src&&
!a.video_.getElementsByTagName("source").length,"video src must be removed first!");c.setCatchFinallyBlocks(4);return c.yield(a.video_.setMediaKeys(null),6);case 6:c.leaveTryBlock(5);break;case 4:b=c.enterCatchBlock(),shaka.log.debug("DrmEngine.destroyNow_ exception",b);case 5:a.video_=null;case 3:a.currentDrmInfo_=null,a.mediaKeys_=null,a.storedPersistentSessions_=new Map,a.config_=null,a.onError_=function(){},a.playerInterface_=null,a.srcEquals_=!1,a.mediaKeysAttached_=null,c.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.configure=function(a,b){this.config_=a;b&&(this.isPreload_=b);this.expirationTimer_&&this.initialized_&&this.currentDrmInfo_&&this.expirationTimer_.tickEvery(this.config_.updateExpirationTime)};shaka.drm.DrmEngine.prototype.setSrcEquals=function(a){this.srcEquals_=a};shaka.drm.DrmEngine.prototype.initForStorage=function(a,b){this.initializedForStorage_=!0;this.storedPersistentSessions_=new Map;this.usePersistentLicenses_=b;return this.init_(a,!1)};
shaka.drm.DrmEngine.prototype.initForPlayback=function(a,b,c){c=c===void 0?!0:c;this.storedPersistentSessions_=new Map;b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())this.storedPersistentSessions_.set(d.value,{initData:null,initDataType:null});b=(0,$jscomp.makeIterator)(this.config_.persistentSessionsMetadata);for(d=b.next();!d.done;d=b.next())d=d.value,this.storedPersistentSessions_.set(d.sessionId,{initData:d.initData,initDataType:d.initDataType});this.usePersistentLicenses_=
this.storedPersistentSessions_.size>0;return this.init_(a,c)};
shaka.drm.DrmEngine.prototype.initForRemoval=function(a,b,c,d,e){var f=this,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.nextAddress==1)return g=[],e.length&&g.push(e[0].contentType),d.length&&g.push(d[0].contentType),h=function(p){p=shaka.util.ManifestParserUtils.createDrmInfo(a,p,null);p.licenseServerUri=b;p.serverCertificate=c;p.persistentStateRequired=!0;p.sessionType="persistent-license";return p},k=shaka.util.StreamUtils.createEmptyVariant(g),k.video&&(l=
h(e[0].encryptionScheme||""),k.video.drmInfos.push(l)),k.audio&&(m=h(d[0].encryptionScheme||""),k.audio.drmInfos.push(m)),n.yield(shaka.util.StreamUtils.getDecodingInfosForVariants([k],!0,f.srcEquals_,[]),2);f.destroyer_.ensureNotDestroyed();return n.return(f.queryMediaKeys_([k]))})};
shaka.drm.DrmEngine.prototype.init_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){if(B.nextAddress==1){goog.asserts.assert(c.config_,"DrmEngine configure() must be called before init()!");shaka.drm.DrmEngine.configureClearKey(c.config_.clearKeys,a);d=a.some(function(C){return C.video&&C.video.drmInfos.length||C.audio&&C.audio.drmInfos.length?!0:!1});e=shaka.util.MapUtils.asMap(c.config_.servers);f=shaka.util.MapUtils.asMap(c.config_.advanced||
{});!d&&b&&shaka.drm.DrmEngine.replaceDrmInfo_(a,e);g=new WeakSet;h=(0,$jscomp.makeIterator)(a);for(k=h.next();!k.done;k=h.next())for(l=k.value,m=c.getVariantDrmInfos_(l),n=(0,$jscomp.makeIterator)(m),p=n.next();!p.done;p=n.next())q=p.value,g.has(q)||(g.add(q),shaka.drm.DrmEngine.fillInDrmInfoDefaults_(q,e,f,c.config_.keySystemsMapping));r=function(C,y){var A=[];C=(0,$jscomp.makeIterator)(C);for(var D=C.next();!D.done;D=C.next()){D=D.value;var E=D[y]||f.has(D.keySystem)&&f.get(D.keySystem)[y]||"";
E==""&&shaka.drm.DrmUtils.isWidevineKeySystem(D.keySystem)&&(y=="audioRobustness"?E=[c.config_.defaultAudioRobustnessForWidevine]:y=="videoRobustness"&&(E=[c.config_.defaultVideoRobustnessForWidevine]));if(typeof E==="string")A.push(D);else if(Array.isArray(E)){E.length===0&&(E=[""]);E=(0,$jscomp.makeIterator)(E);for(var F=E.next();!F.done;F=E.next()){var L={};A.push(Object.assign({},D,(L[y]=F.value,L)))}}}return A};t=new WeakSet;w=(0,$jscomp.makeIterator)(a);for(v=w.next();!v.done;v=w.next())u=v.value,
u.video&&!t.has(u.video)&&(u.video.drmInfos=r(u.video.drmInfos,"videoRobustness"),u.video.drmInfos=r(u.video.drmInfos,"audioRobustness"),t.add(u.video)),u.audio&&!t.has(u.audio)&&(u.audio.drmInfos=r(u.audio.drmInfos,"videoRobustness"),u.audio.drmInfos=r(u.audio.drmInfos,"audioRobustness"),t.add(u.audio));return B.yield(shaka.util.StreamUtils.getDecodingInfosForVariants(a,c.usePersistentLicenses_,c.srcEquals_,c.config_.preferredKeySystems),2)}c.destroyer_.ensureNotDestroyed();x=d||e.size>0;if(!x)return c.initialized_=
!0,B.return(Promise.resolve());z=c.queryMediaKeys_(a);return B.return(d?z:z.catch(function(){}))})};
shaka.drm.DrmEngine.prototype.attachMediaKeys_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.nextAddress){case 1:if(a.video_.mediaKeys)return c.return();if(!a.mediaKeysAttached_){c.jumpTo(2);break}return c.yield(a.mediaKeysAttached_,3);case 3:return a.destroyer_.ensureNotDestroyed(),c.return();case 2:return c.setCatchFinallyBlocks(4),a.mediaKeysAttached_=a.video_.setMediaKeys(a.mediaKeys_),c.yield(a.mediaKeysAttached_,6);case 6:c.leaveTryBlock(5);
break;case 4:b=c.enterCatchBlock(),goog.asserts.assert(b instanceof Error,"Wrong error type!"),a.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_ATTACH_TO_VIDEO,b.message));case 5:a.destroyer_.ensureNotDestroyed(),c.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.onEncryptedEvent_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1)return c.yield(b.attachMediaKeys_(),2);b.newInitData(a.initDataType,shaka.util.BufferUtils.toUint8(a.initData));c.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.attach=function(a){var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1){if(b.video_===a)return e.return();if(!b.mediaKeys_)return b.eventManager_.listenOnce(a,"encrypted",function(f){b.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.ENCRYPTED_CONTENT_WITHOUT_DRM_INFO))}),e.return();b.video_=a;b.config_.delayLicenseRequestUntilPlayed&&b.eventManager_.listenOnce(b.video_,
"play",function(){return b.onPlay_()});b.video_.remote?(b.eventManager_.listen(b.video_.remote,"connect",function(){return b.closeOpenSessions_()}),b.eventManager_.listen(b.video_.remote,"connecting",function(){return b.closeOpenSessions_()}),b.eventManager_.listen(b.video_.remote,"disconnect",function(){return b.closeOpenSessions_()})):"webkitCurrentPlaybackTargetIsWireless"in b.video_&&b.eventManager_.listen(b.video_,"webkitcurrentplaybacktargetiswirelesschanged",function(){return b.closeOpenSessions_()});
b.manifestInitData_=b.currentDrmInfo_?b.currentDrmInfo_.initData.find(function(f){return f.initData.length>0})||null:null;c=b.currentDrmInfo_.keySystem;return(d=shaka.device.DeviceFactory.getDevice().needWaitForEncryptedEvent(c))||!b.manifestInitData_&&b.currentDrmInfo_.keySystem==="com.apple.fps"&&!b.storedPersistentSessions_.size?e.jumpTo(2):e.yield(b.attachMediaKeys_(),2)}b.createOrLoad().catch(function(){});!d&&(b.manifestInitData_||b.storedPersistentSessions_.size||b.config_.parseInbandPsshEnabled)||
b.eventManager_.listen(b.video_,"encrypted",function(f){return b.onEncryptedEvent_(f)});e.jumpToEnd()})};shaka.drm.DrmEngine.prototype.hasManifestInitData=function(){return!!this.manifestInitData_};
shaka.drm.DrmEngine.prototype.setServerCertificate=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.nextAddress){case 1:goog.asserts.assert(a.initialized_,"Must call init() before setServerCertificate");if(!a.mediaKeys_||!a.currentDrmInfo_)return h.return();if(!a.currentDrmInfo_.serverCertificateUri||a.currentDrmInfo_.serverCertificate&&a.currentDrmInfo_.serverCertificate.length){h.jumpTo(2);break}b=shaka.net.NetworkingEngine.makeRequest([a.currentDrmInfo_.serverCertificateUri],
a.config_.retryParameters);h.setCatchFinallyBlocks(3);c=a.playerInterface_.netEngine.request(shaka.net.NetworkingEngine.RequestType.SERVER_CERTIFICATE,b,{isPreload:a.isPreload_()});return h.yield(c.promise,5);case 5:d=h.yieldResult;a.currentDrmInfo_.serverCertificate=shaka.util.BufferUtils.toUint8(d.data);h.leaveTryBlock(4);break;case 3:throw e=h.enterCatchBlock(),goog.asserts.assert(e instanceof shaka.util.Error,"Wrong NetworkingEngine error type!"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.SERVER_CERTIFICATE_REQUEST_FAILED,e);case 4:if(a.destroyer_.destroyed())return h.return();case 2:if(!a.currentDrmInfo_.serverCertificate||!a.currentDrmInfo_.serverCertificate.length)return h.return();h.setCatchFinallyBlocks(6);return h.yield(a.mediaKeys_.setServerCertificate(a.currentDrmInfo_.serverCertificate),8);case 8:(f=h.yieldResult)||shaka.log.warning("Server certificates are not supported by the key system.  The server certificate has been ignored.");
h.leaveTryBlock(0);break;case 6:throw g=h.enterCatchBlock(),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.INVALID_SERVER_CERTIFICATE,g.message);}})};
shaka.drm.DrmEngine.prototype.removeSession=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return goog.asserts.assert(b.mediaKeys_,"Must call init() before removeSession"),f.yield(b.loadOfflineSession_(a,{initData:null,initDataType:null}),2);if(f.nextAddress!=3){c=f.yieldResult;if(!c)return shaka.log.v2("Ignoring attempt to remove missing session",a),f.return();d=[];if(e=b.activeSessions_.get(c))e.updatePromise=new shaka.util.PublicPromise,
d.push(e.updatePromise);shaka.log.v2("Attempting to remove session",a);d.push(c.remove());return f.yield(Promise.all(d),3)}b.activeSessions_.delete(c);f.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.createOrLoad=function(){var a=this,b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1){if(!a.storedPersistentSessions_.size)return g.jumpTo(2);a.storedPersistentSessions_.forEach(function(h,k){a.loadOfflineSession_(k,h)});return g.yield(a.allSessionsLoaded_,3)}if(g.nextAddress!=2){b=a.currentDrmInfo_&&a.currentDrmInfo_.keyIds||new Set([]);if(b.size>0&&a.areAllKeysUsable_())return g.return(a.allSessionsLoaded_);a.hasInitData_=
!1;a.allSessionsLoaded_=new shaka.util.PublicPromise;a.allSessionsLoaded_.catch(function(){})}c=(a.currentDrmInfo_?a.currentDrmInfo_.initData:[])||[];d=(0,$jscomp.makeIterator)(c);for(e=d.next();!e.done;e=d.next())f=e.value,a.newInitData(f.initDataType,f.initData);a.areAllSessionsLoaded_()&&a.allSessionsLoaded_.resolve();return g.return(a.allSessionsLoaded_)})};
shaka.drm.DrmEngine.prototype.newInitData=function(a,b){if(b.length){if(this.config_.ignoreDuplicateInitData){var c=this.activeSessions_.values();c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next())if(shaka.util.BufferUtils.equal(b,d.value.initData)){shaka.log.debug("Ignoring duplicate init data.");return}var e=!1;this.storedPersistentSessions_.forEach(function(f,g){!e&&shaka.util.BufferUtils.equal(b,f.initData)&&(e=!0)});if(e){shaka.log.debug("Ignoring duplicate init data.");return}}this.hasInitData_=
!0;this.activeSessions_.size>0&&this.areAllSessionsLoaded_()&&(this.allSessionsLoaded_.resolve(),this.hasInitData_=!1,this.allSessionsLoaded_=new shaka.util.PublicPromise,this.allSessionsLoaded_.catch(function(){}));this.createSession(a,b,this.currentDrmInfo_.sessionType)}};shaka.drm.DrmEngine.prototype.initialized=function(){return this.initialized_};
shaka.drm.DrmEngine.prototype.getSessionIds=function(){var a=this.activeSessions_.keys();a=shaka.util.Iterables.map(a,function(b){return b.sessionId});return Array.from(a)};shaka.drm.DrmEngine.prototype.getActiveSessionsMetadata=function(){var a=this,b=this.activeSessions_.keys();b=shaka.util.Iterables.map(b,function(c){var d=a.activeSessions_.get(c);return{sessionId:c.sessionId,sessionType:d.type,initData:d.initData,initDataType:d.initDataType}});return Array.from(b)};
shaka.drm.DrmEngine.prototype.getExpiration=function(){var a=Infinity,b=this.activeSessions_.keys();b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,isNaN(c.expiration)||(a=Math.min(a,c.expiration));return a};shaka.drm.DrmEngine.prototype.getLicenseTime=function(){return this.licenseTimeSeconds_?this.licenseTimeSeconds_:NaN};shaka.drm.DrmEngine.prototype.getDrmInfo=function(){return this.currentDrmInfo_};shaka.drm.DrmEngine.prototype.getMediaKeys=function(){return this.mediaKeys_};
shaka.drm.DrmEngine.prototype.getKeyStatuses=function(){return shaka.util.MapUtils.asObject(this.announcedKeyStatusByKeyId_)};
shaka.drm.DrmEngine.prototype.queryMediaKeys_=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.nextAddress){case 1:c=new Map;d=b.getKeySystemAccessFromVariants_(a,c);if(!d){if(!navigator.requestMediaKeySystemAccess)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.MISSING_EME_SUPPORT);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,
shaka.util.Error.Code.REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE);}b.destroyer_.ensureNotDestroyed();m.setCatchFinallyBlocks(2);e=d.getConfiguration();shaka.log.v2("Got MediaKeySystemAccess with configuration",e);f=b.config_.keySystemsMapping[d.keySystem]||d.keySystem;b.currentDrmInfo_=b.createDrmInfoByInfos_(f,c.get(f));if(!b.currentDrmInfo_.licenseServerUri)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_LICENSE_SERVER_GIVEN,b.currentDrmInfo_.keySystem);
return m.yield(d.createMediaKeys(),4);case 4:g=m.yieldResult;b.destroyer_.ensureNotDestroyed();shaka.log.info("Created MediaKeys object for key system",b.currentDrmInfo_.keySystem);b.mediaKeys_=g;if(!(b.config_.minHdcpVersion!=""&&"getStatusForPolicy"in b.mediaKeys_)){m.jumpTo(5);break}m.setCatchFinallyBlocks(6);return m.yield(b.mediaKeys_.getStatusForPolicy({minHdcpVersion:b.config_.minHdcpVersion}),8);case 8:h=m.yieldResult;if(h!="usable")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.MIN_HDCP_VERSION_NOT_MATCH);b.destroyer_.ensureNotDestroyed();m.leaveTryBlock(5,2);break;case 6:k=m.enterCatchBlock(2);if(k instanceof shaka.util.Error)throw k;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.ERROR_CHECKING_HDCP_VERSION,k.message);case 5:return b.initialized_=!0,b.expirationTimer_.tickEvery(b.config_.updateExpirationTime),m.yield(b.setServerCertificate(),9);case 9:b.destroyer_.ensureNotDestroyed();
m.leaveTryBlock(0);break;case 2:l=m.enterCatchBlock();b.destroyer_.ensureNotDestroyed(l);b.currentDrmInfo_=null;if(l instanceof shaka.util.Error)throw l;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_CDM,l.message);}})};
shaka.drm.DrmEngine.prototype.getKeySystemAccessFromVariants_=function(a,b){for(var c=(0,$jscomp.makeIterator)(a),d=c.next();!d.done;d=c.next()){d=this.getVariantDrmInfos_(d.value);d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,b.has(e.keySystem)||b.set(e.keySystem,[]),b.get(e.keySystem).push(e)}if(b.size==1&&b.has(""))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_RECOGNIZED_KEY_SYSTEMS);c=this.config_.preferredKeySystems;
c.length||(d=shaka.util.MapUtils.asMap(this.config_.servers),d.size==1&&(c=Array.from(d.keys())));d=(0,$jscomp.makeIterator)(c);var f=d.next();for(e={};!f.done;e={preferredKeySystem$jscomp$1:void 0},f=d.next()){e.preferredKeySystem$jscomp$1=f.value;f=(0,$jscomp.makeIterator)(a);for(var g=f.next();!g.done;g=f.next())if(g=g.value.decodingInfos.find(function(m){return function(n){return n.supported&&n.keySystemAccess!=null&&n.keySystemAccess.keySystem==m.preferredKeySystem$jscomp$1}}(e)))return g.keySystemAccess}d=
(0,$jscomp.makeIterator)([!0,!1]);for(e=d.next();!e.done;e=d.next())for(e=e.value,f=(0,$jscomp.makeIterator)(a),g=f.next();!g.done;g=f.next()){g=(0,$jscomp.makeIterator)(g.value.decodingInfos);for(var h=g.next();!h.done;h=g.next())if(h=h.value,h.supported&&h.keySystemAccess){var k=h.keySystemAccess.keySystem;if(!c.includes(k)){var l=b.get(k);!l&&this.config_.keySystemsMapping[k]&&(l=b.get(this.config_.keySystemsMapping[k]));k=(0,$jscomp.makeIterator)(l);for(l=k.next();!l.done;l=k.next())if(!!l.value.licenseServerUri==
e)return h.keySystemAccess}}}return null};shaka.drm.DrmEngine.prototype.checkSessionsLoaded_=function(){this.areAllSessionsLoaded_()&&this.allSessionsLoaded_.resolve()};shaka.drm.DrmEngine.prototype.setLoadSessionTimeoutTimer_=function(a){var b=this;(new shaka.util.Timer(function(){a.loaded=!0;b.checkSessionsLoaded_()})).tickAfter(shaka.drm.DrmEngine.SESSION_LOAD_TIMEOUT_)};
shaka.drm.DrmEngine.prototype.loadOfflineSession_=function(a,b){var c=this,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.nextAddress){case 1:try{shaka.log.v1("Attempting to load an offline session",a),d=c.mediaKeys_.createSession("persistent-license")}catch(n){return e=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,n.message),c.onError_(e),m.return(Promise.reject(e))}c.eventManager_.listen(d,
"message",function(n){return c.onSessionMessage_(n)});c.eventManager_.listen(d,"keystatuseschange",function(n){return c.onKeyStatusesChange_(n)});f={initData:b.initData,initDataType:b.initDataType,loaded:!1,oldExpiration:Infinity,updatePromise:null,type:"persistent-license"};c.activeSessions_.set(d,f);m.setCatchFinallyBlocks(2);return m.yield(d.load(a),4);case 4:return g=m.yieldResult,c.destroyer_.ensureNotDestroyed(),shaka.log.v2("Loaded offline session",a,g),g||(c.activeSessions_.delete(d),h=c.config_.persistentSessionOnlinePlayback?
shaka.util.Error.Severity.RECOVERABLE:shaka.util.Error.Severity.CRITICAL,c.onError_(new shaka.util.Error(h,shaka.util.Error.Category.DRM,shaka.util.Error.Code.OFFLINE_SESSION_REMOVED)),f.loaded=!0),c.setLoadSessionTimeoutTimer_(f),c.checkSessionsLoaded_(),m.return(d);case 2:k=m.enterCatchBlock(),c.destroyer_.ensureNotDestroyed(k),c.activeSessions_.delete(d),l=c.config_.persistentSessionOnlinePlayback?shaka.util.Error.Severity.RECOVERABLE:shaka.util.Error.Severity.CRITICAL,c.onError_(new shaka.util.Error(l,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,k.message)),f.loaded=!0,c.checkSessionsLoaded_();case 3:return m.return(Promise.resolve())}})};
shaka.drm.DrmEngine.prototype.createSession=function(a,b,c){var d=this;goog.asserts.assert(this.mediaKeys_,"mediaKeys_ should be valid when creating temporary session.");try{shaka.log.info("Creating new",c,"session");var e=this.mediaKeys_.createSession(c)}catch(f){this.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,f.message));return}this.eventManager_.listen(e,"message",function(f){return d.onSessionMessage_(f)});
this.eventManager_.listen(e,"keystatuseschange",function(f){return d.onKeyStatusesChange_(f)});this.activeSessions_.set(e,{initData:b,initDataType:a,loaded:!1,oldExpiration:Infinity,updatePromise:null,type:c});try{b=this.config_.initDataTransform(b,a,this.currentDrmInfo_)}catch(f){a=f;f instanceof shaka.util.Error||(a=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.INIT_DATA_TRANSFORM_ERROR,f));this.onError_(a);return}this.config_.logLicenseExchange&&
(c=shaka.util.Uint8ArrayUtils.toBase64(b),shaka.log.info("EME init data: type=",a,"data=",c));e.generateRequest(a,b).catch(function(f){if(!d.destroyer_.destroyed()){goog.asserts.assert(f instanceof Error,"Wrong error type!");d.activeSessions_.delete(e);var g=f.errorCode;if(g&&g.systemCode){var h=g.systemCode;h<0&&(h+=4294967296);h="0x"+h.toString(16)}d.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_GENERATE_LICENSE_REQUEST,
f.message,f,h))}})};shaka.drm.DrmEngine.prototype.onSessionMessage_=function(a){this.delayLicenseRequest_()?this.mediaKeyMessageEvents_.push(a):this.sendLicenseRequest_(a)};shaka.drm.DrmEngine.prototype.delayLicenseRequest_=function(){return this.video_?this.config_.delayLicenseRequestUntilPlayed&&this.video_.paused&&!this.initialRequestsSent_:!1};
shaka.drm.DrmEngine.prototype.waitForActiveRequests=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.nextAddress==1?a.hasInitData_?b.yield(a.allSessionsLoaded_,3):b.jumpTo(0):b.yield(Promise.all(a.activeRequests_.map(function(c){return c.promise})),0)})};
shaka.drm.DrmEngine.prototype.sendLicenseRequest_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){switch(B.nextAddress){case 1:c=a.target;shaka.log.v1("Sending license request for session",c.sessionId,"of type",a.messageType);b.config_.logLicenseExchange&&(d=shaka.util.Uint8ArrayUtils.toBase64(a.message),shaka.log.info("EME license request",d));e=b.activeSessions_.get(c);f=b.currentDrmInfo_.licenseServerUri;g=b.config_.advanced[b.currentDrmInfo_.keySystem];
a.messageType=="individualization-request"&&g&&g.individualizationServer&&(f=g.individualizationServer);h=shaka.net.NetworkingEngine.RequestType.LICENSE;k=shaka.net.NetworkingEngine.makeRequest([f],b.config_.retryParameters);k.body=a.message;k.method="POST";k.licenseRequestType=a.messageType;k.sessionId=c.sessionId;k.drmInfo=b.currentDrmInfo_;e&&(k.initData=e.initData,k.initDataType=e.initDataType);if(g&&g.headers)for(l in g.headers)k.headers[l]=g.headers[l];shaka.drm.DrmUtils.isClearKeySystem(b.currentDrmInfo_.keySystem)&&
b.fixClearKeyRequest_(k,b.currentDrmInfo_);shaka.drm.DrmUtils.isPlayReadyKeySystem(b.currentDrmInfo_.keySystem)&&b.unpackPlayReadyRequest_(k);m=Date.now();B.setCatchFinallyBlocks(2);p=b.playerInterface_.netEngine.request(h,k,{isPreload:b.isPreload_()});b.activeRequests_.push(p);return B.yield(p.promise,4);case 4:n=B.yieldResult;shaka.util.ArrayUtils.remove(b.activeRequests_,p);B.leaveTryBlock(3);break;case 2:q=B.enterCatchBlock();if(b.destroyer_.destroyed())return B.return();goog.asserts.assert(q instanceof
shaka.util.Error,"Wrong NetworkingEngine error type!");r={sessionId:c.sessionId,sessionType:e.type,initData:e.initData,initDataType:e.initDataType};t=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.LICENSE_REQUEST_FAILED,q,r);b.activeSessions_.size==1?(b.onError_(t),e&&e.updatePromise&&e.updatePromise.reject(t)):(e&&e.updatePromise&&e.updatePromise.reject(t),b.activeSessions_.delete(c),b.areAllSessionsLoaded_()&&(b.allSessionsLoaded_.resolve(),
b.keyStatusTimer_.tickAfter(.1)));return B.return();case 3:if(b.destroyer_.destroyed())return B.return();b.licenseTimeSeconds_+=(Date.now()-m)/1E3;b.config_.logLicenseExchange&&(w=shaka.util.Uint8ArrayUtils.toBase64(n.data),shaka.log.info("EME license response",w));B.setCatchFinallyBlocks(5);shaka.log.v1("Updating session",c.sessionId);return B.yield(c.update(n.data),7);case 7:B.leaveTryBlock(6);break;case 5:return u=(v=B.enterCatchBlock())&&v.message||String(v),x=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.LICENSE_RESPONSE_REJECTED,u),b.onError_(x),e&&e.updatePromise&&e.updatePromise.reject(x),B.return();case 6:if(b.destroyer_.destroyed())return B.return();z=new shaka.util.FakeEvent("drmsessionupdate");b.playerInterface_.onEvent(z);e&&(e.updatePromise&&e.updatePromise.resolve(),b.setLoadSessionTimeoutTimer_(e));B.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.unpackPlayReadyRequest_=function(a){var b=shaka.util.TXml,c=shaka.util.StringUtils.fromUTF16(a.body,!0,!0);if(c.includes("PlayReadyKeyMessage")){shaka.log.debug("Unwrapping PlayReady request.");c=b.parseXmlString(c,"PlayReadyKeyMessage");goog.asserts.assert(c,"Failed to parse PlayReady XML!");var d=b.getElementsByTagName(c,"HttpHeader");d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next()){var f=e.value;e=b.getElementsByTagName(f,"name")[0];f=b.getElementsByTagName(f,
"value")[0];goog.asserts.assert(e&&f,"Malformed PlayReady headers!");a.headers[shaka.util.TXml.getTextContents(e)]=shaka.util.TXml.getTextContents(f)}b=b.getElementsByTagName(c,"Challenge")[0];goog.asserts.assert(b,"Malformed PlayReady challenge!");goog.asserts.assert(b.attributes.encoding=="base64encoded","Unexpected PlayReady challenge encoding!");a.body=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(b))}else shaka.log.debug("PlayReady request is already unwrapped."),a.headers["Content-Type"]=
"text/xml; charset=utf-8"};shaka.drm.DrmEngine.prototype.fixClearKeyRequest_=function(a,b){try{var c=shaka.util.StringUtils.fromBytesAutoDetect(a.body);if(c){var d=JSON.parse(c);d.type||(d.type=b.sessionType,a.body=shaka.util.StringUtils.toUTF8(JSON.stringify(d)))}}catch(e){shaka.log.info("Error unpacking ClearKey license",e)}};
shaka.drm.DrmEngine.prototype.onKeyStatusesChange_=function(a){var b=this;a=a.target;shaka.log.v2("Key status changed for session",a.sessionId);var c=this.activeSessions_.get(a),d=!1;a.keyStatuses.forEach(function(f,g){if(typeof g=="string"){var h=g;g=f;f=h}h=shaka.device.DeviceFactory.getDevice();if(shaka.drm.DrmUtils.isPlayReadyKeySystem(b.currentDrmInfo_.keySystem)&&g.byteLength==16&&h.returnLittleEndianUsingPlayReady()){h=shaka.util.BufferUtils.toDataView(g);var k=h.getUint32(0,!0),l=h.getUint16(4,
!0),m=h.getUint16(6,!0);h.setUint32(0,k,!1);h.setUint16(4,l,!1);h.setUint16(6,m,!1)}f!="status-pending"&&(c.loaded=!0);c||goog.asserts.assert(f!="usable","Usable keys found in closed session");f=="expired"&&(d=!0);g=shaka.util.Uint8ArrayUtils.toHex(g).slice(0,32);b.keyStatusByKeyId_.set(g,f)});var e=a.expiration-Date.now();(e<0||d&&e<1E3)&&c&&!c.updatePromise&&(shaka.log.debug("Session has expired",a.sessionId),this.activeSessions_.delete(a),this.closeSession_(a));this.areAllSessionsLoaded_()&&(this.allSessionsLoaded_.resolve(),
this.keyStatusTimer_.tickAfter(shaka.drm.DrmEngine.KEY_STATUS_BATCH_TIME))};shaka.drm.DrmEngine.prototype.processKeyStatusChanges_=function(){var a=this.keyStatusByKeyId_,b=this.announcedKeyStatusByKeyId_;b.clear();a.forEach(function(c,d){return b.set(d,c)});a=Array.from(b.values());if(a.length&&a.every(function(c){return c=="expired"}))this.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.EXPIRED));this.playerInterface_.onKeyStatus(shaka.util.MapUtils.asObject(b))};
shaka.drm.DrmEngine.probeSupport=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){if(G.nextAddress==1){a="org.w3.clearkey com.widevine.alpha com.widevine.alpha.experiment com.microsoft.playready com.microsoft.playready.hardware com.microsoft.playready.recommendation com.microsoft.playready.recommendation.3000 com.microsoft.playready.recommendation.3000.clearlead com.chromecast.playready com.apple.fps.1_0 com.apple.fps com.huawei.wiseplay".split(" ");
if(!shaka.drm.DrmUtils.isBrowserSupported()){b={};c=(0,$jscomp.makeIterator)(a);for(d=c.next();!d.done;d=c.next())e=d.value,b[e]=null;return G.return(b)}f="1.0 1.1 1.2 1.3 1.4 2.0 2.1 2.2 2.3".split(" ");g=["SW_SECURE_CRYPTO","SW_SECURE_DECODE","HW_SECURE_CRYPTO","HW_SECURE_DECODE","HW_SECURE_ALL"];h=["150","2000","3000"];k={"com.widevine.alpha":g,"com.widevine.alpha.experiment":g,"com.microsoft.playready.recommendation":h};l=[{contentType:'video/mp4; codecs="avc1.42E01E"'},{contentType:'video/webm; codecs="vp8"'}];
m=[{contentType:'audio/mp4; codecs="mp4a.40.2"'},{contentType:'audio/webm; codecs="opus"'}];n={videoCapabilities:l,audioCapabilities:m,initDataTypes:["cenc","sinf","skd","keyids"]};p=[null,"cenc","cbcs"];q=new Map;r=shaka.device.DeviceFactory.getDevice();t=function(M,H,P){var Q,O,N,S,aa,R,W,ba,V,X,Y,Z,U;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(T){switch(T.nextAddress){case 1:T.setCatchFinallyBlocks(2);if(!r.createMediaKeysWhenCheckingSupport())throw Error("Suppressing Firefox Windows DRM in testing!");
return T.yield(H.createMediaKeys(),5);case 5:Q=T.yieldResult;case 4:T.leaveTryBlock(3);break;case 2:return T.enterCatchBlock(),T.return();case 3:N=(O=H.getConfiguration().sessionTypes)?O.includes("persistent-license"):!1;r.misreportsSupportForPersistentLicenses()&&(N=!1);S=H.getConfiguration().videoCapabilities;aa=H.getConfiguration().audioCapabilities;R={persistentState:N,encryptionSchemes:[],videoRobustnessLevels:[],audioRobustnessLevels:[],minHdcpVersions:[]};q.get(M)?R=q.get(M):q.set(M,R);(W=
S[0].encryptionScheme)&&!R.encryptionSchemes.includes(W)&&R.encryptionSchemes.push(W);(ba=S[0].robustness)&&!R.videoRobustnessLevels.includes(ba)&&R.videoRobustnessLevels.push(ba);(V=aa[0].robustness)&&!R.audioRobustnessLevels.includes(V)&&R.audioRobustnessLevels.push(V);if(!(P&&"getStatusForPolicy"in Q)){T.jumpTo(0);break}X=(0,$jscomp.makeIterator)(f);Y=X.next();case 7:if(Y.done){T.jumpTo(0);break}Z=Y.value;if(R.minHdcpVersions.includes(Z)){T.jumpTo(8);break}return T.yield(Q.getStatusForPolicy({minHdcpVersion:Z}),
10);case 10:if(U=T.yieldResult,U=="usable")R.minHdcpVersions.includes(Z)||R.minHdcpVersions.push(Z);else{T.jumpTo(0);break}case 8:Y=X.next(),T.jumpTo(7)}})};w=function(M,H,P,Q,O){O=O===void 0?!1:O;var N,S,aa,R,W,ba,V,X,Y,Z,U;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(T){switch(T.nextAddress){case 1:T.setCatchFinallyBlocks(2);N=shaka.util.ObjectUtils.cloneObject(n);S=(0,$jscomp.makeIterator)(N.videoCapabilities);for(aa=S.next();!aa.done;aa=S.next())R=aa.value,R.encryptionScheme=
H,R.robustness=P;W=(0,$jscomp.makeIterator)(N.audioCapabilities);for(ba=W.next();!ba.done;ba=W.next())V=ba.value,V.encryptionScheme=H,V.robustness=Q;X=shaka.util.ObjectUtils.cloneObject(N);X.persistentState="required";X.sessionTypes=["persistent-license"];Y=[X,N];U=shaka.device.DeviceFactory.getDevice();return U.getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE?T.yield(shaka.util.Functional.promiseWithTimeout(5,navigator.requestMediaKeySystemAccess(M,Y)),7):T.yield(navigator.requestMediaKeySystemAccess(M,
Y),6);case 6:Z=T.yieldResult;T.jumpTo(5);break;case 7:Z=T.yieldResult;case 5:return T.yield(t(M,Z,O),8);case 8:T.leaveTryBlock(0);break;case 2:T.enterCatchBlock(),T.jumpToEnd()}})};v=(0,$jscomp.makeIterator)(a);for(u=v.next();!u.done;u=v.next())x=u.value,q.set(x,null);z=function(M){return shaka.device.DeviceFactory.getDevice().getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&shaka.drm.DrmUtils.isClearKeySystem(M)?!1:!0};B=[];C=(0,$jscomp.makeIterator)(a);for(y=C.next();!y.done;y=C.next())if(A=
y.value,z(A)){D=!0;E=(0,$jscomp.makeIterator)(p);for(F=E.next();!F.done;F=E.next())L=F.value,B.push(w(A,L,"","",D)),D=!1;K=(0,$jscomp.makeIterator)(k[A]||[]);for(J=K.next();!J.done;J=K.next())I=J.value,B.push(w(A,null,I,"")),B.push(w(A,null,"",I))}return G.yield(Promise.all(B),2)}return G.return(shaka.util.MapUtils.asObject(q))})};
shaka.drm.DrmEngine.prototype.onPlay_=function(){for(var a=(0,$jscomp.makeIterator)(this.mediaKeyMessageEvents_),b=a.next();!b.done;b=a.next())this.sendLicenseRequest_(b.value);this.initialRequestsSent_=!0;this.mediaKeyMessageEvents_=[]};
shaka.drm.DrmEngine.prototype.closeSession_=function(a){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.nextAddress==1)return b.setCatchFinallyBlocks(2),b.yield(shaka.util.Functional.promiseWithTimeout(shaka.drm.DrmEngine.CLOSE_TIMEOUT_,Promise.all([a.close().catch(function(){}),a.closed])),4);if(b.nextAddress!=2)return b.leaveTryBlock(0);b.enterCatchBlock();shaka.log.warning("Timeout waiting for session close");b.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.closeOpenSessions_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){b=Array.from(a.activeSessions_.entries());a.activeSessions_.clear();return c.yield(Promise.all(b.map(function(d){d=(0,$jscomp.makeIterator)(d);var e=d.next().value;var f=d.next().value;var g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1){h.setCatchFinallyBlocks(2);if(!a.initializedForStorage_&&!a.storedPersistentSessions_.has(e.sessionId)&&
f.type==="persistent-license"&&!a.config_.persistentSessionOnlinePlayback)return shaka.log.v1("Removing session",e.sessionId),h.yield(e.remove(),5);shaka.log.v1("Closing session",e.sessionId,f);return h.yield(a.closeSession_(e),5)}if(h.nextAddress!=2)return h.leaveTryBlock(0);g=h.enterCatchBlock();shaka.log.error("Failed to close or remove the session",g);h.jumpToEnd()})})),0)})};
shaka.drm.DrmEngine.prototype.getVariantDrmInfos_=function(a){return(a.video?a.video.drmInfos:[]).concat(a.audio?a.audio.drmInfos:[])};shaka.drm.DrmEngine.prototype.pollExpiration_=function(){var a=this;this.activeSessions_.forEach(function(b,c){var d=b.oldExpiration,e=c.expiration;isNaN(e)&&(e=Infinity);e!=d&&(a.playerInterface_.onExpirationUpdated(c.sessionId,e),b.oldExpiration=e)})};
shaka.drm.DrmEngine.prototype.areAllSessionsLoaded_=function(){var a=this.activeSessions_.values();return shaka.util.Iterables.every(a,function(b){return b.loaded})};shaka.drm.DrmEngine.prototype.areAllKeysUsable_=function(){var a=this.currentDrmInfo_&&this.currentDrmInfo_.keyIds||new Set([]);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())if(this.keyStatusByKeyId_.get(b.value)!=="usable")return!1;return!0};
shaka.drm.DrmEngine.replaceDrmInfo_=function(a,b){var c=[];b.forEach(function(d,e){c.push({keySystem:e,licenseServerUri:d,distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",initData:[],keyIds:new Set})});a=(0,$jscomp.makeIterator)(a);for(b=a.next();!b.done;b=a.next())b=b.value,b.video&&(b.video.drmInfos=c),b.audio&&(b.audio.drmInfos=c)};
shaka.drm.DrmEngine.prototype.createDrmInfoByInfos_=function(a,b){var c=[],d=[],e=[],f=[],g=[],h=new Set,k=new Set;shaka.drm.DrmEngine.processDrmInfos_(b,c,d,f,e,g,h,k);c.length>1&&shaka.log.warning("Multiple unique encryption schemes found! Only the first will be used.");f.length>1&&shaka.log.warning("Multiple unique server certificates found! Only the first will be used.");d.length>1&&shaka.log.warning("Multiple unique license server URIs found! Only the first will be used.");e.length>1&&shaka.log.warning("Multiple unique server certificate URIs found! Only the first will be used.");
var l=this.usePersistentLicenses_?"persistent-license":"temporary";a={keySystem:a,encryptionScheme:c[0],licenseServerUri:d[0],distinctiveIdentifierRequired:b[0].distinctiveIdentifierRequired,persistentStateRequired:b[0].persistentStateRequired,sessionType:b[0].sessionType||l,audioRobustness:b[0].audioRobustness||"",videoRobustness:b[0].videoRobustness||"",serverCertificate:f[0],serverCertificateUri:e[0],initData:g,keyIds:h};k.size>0&&(a.keySystemUris=k);b=(0,$jscomp.makeIterator)(b);for(k=b.next();!k.done;k=
b.next())k=k.value,k.distinctiveIdentifierRequired&&(a.distinctiveIdentifierRequired=k.distinctiveIdentifierRequired),k.persistentStateRequired&&(a.persistentStateRequired=k.persistentStateRequired);return a};
shaka.drm.DrmEngine.processDrmInfos_=function(a,b,c,d,e,f,g,h){var k=[];a=(0,$jscomp.makeIterator)(a);for(var l=a.next(),m={};!l.done;m={drmInfo$jscomp$9:void 0},l=a.next()){m.drmInfo$jscomp$9=l.value;b.includes(m.drmInfo$jscomp$9.encryptionScheme)||b.push(m.drmInfo$jscomp$9.encryptionScheme);m.drmInfo$jscomp$9.keySystem=="org.w3.clearkey"&&m.drmInfo$jscomp$9.licenseServerUri.startsWith("data:application/json;base64,")?k.includes(m.drmInfo$jscomp$9.licenseServerUri)||k.push(m.drmInfo$jscomp$9.licenseServerUri):
c.includes(m.drmInfo$jscomp$9.licenseServerUri)||c.push(m.drmInfo$jscomp$9.licenseServerUri);e.includes(m.drmInfo$jscomp$9.serverCertificateUri)||e.push(m.drmInfo$jscomp$9.serverCertificateUri);m.drmInfo$jscomp$9.serverCertificate&&(d.some(function(q){return function(r){return shaka.util.BufferUtils.equal(r,q.drmInfo$jscomp$9.serverCertificate)}}(m))||d.push(m.drmInfo$jscomp$9.serverCertificate));if(m.drmInfo$jscomp$9.initData){l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$9.initData);for(var n=l.next(),
p={};!n.done;p={initDataOverride$jscomp$2:void 0},n=l.next())p.initDataOverride$jscomp$2=n.value,f.some(function(q){return function(r){var t=q.initDataOverride$jscomp$2;r=r.keyId&&r.keyId==t.keyId?!0:r.initDataType==t.initDataType&&shaka.util.BufferUtils.equal(r.initData,t.initData);return r}}(p))||f.push(p.initDataOverride$jscomp$2)}if(m.drmInfo$jscomp$9.keyIds)for(l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$9.keyIds),n=l.next();!n.done;n=l.next())g.add(n.value);if(m.drmInfo$jscomp$9.keySystemUris&&
h)for(m=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$9.keySystemUris),l=m.next();!l.done;l=m.next())h.add(l.value)}if(k.length==1)c.push(k[0]);else if(k.length>0){b=[];k=(0,$jscomp.makeIterator)(k);for(d=k.next();!d.done;d=k.next())d=window.atob(d.value.split("data:application/json;base64,").pop()),d=JSON.parse(d),b.push.apply(b,(0,$jscomp.arrayFromIterable)(d.keys));k=JSON.stringify({keys:b});c.push("data:application/json;base64,"+window.btoa(k))}};
shaka.drm.DrmEngine.fillInDrmInfoDefaults_=function(a,b,c,d){var e=a.keySystem;if(e&&(e!="org.w3.clearkey"||!a.licenseServerUri)){b.size&&b.get(e)&&(b=b.get(e),a.licenseServerUri=b);a.keyIds||(a.keyIds=new Set);if(c=c.get(e))a.distinctiveIdentifierRequired||(a.distinctiveIdentifierRequired=c.distinctiveIdentifierRequired),a.persistentStateRequired||(a.persistentStateRequired=c.persistentStateRequired),a.serverCertificate||(a.serverCertificate=c.serverCertificate),c.sessionType&&(a.sessionType=c.sessionType),
a.serverCertificateUri||(a.serverCertificateUri=c.serverCertificateUri);d[e]&&(a.keySystem=d[e]);window.cast&&window.cast.__platform__&&e=="com.microsoft.playready"&&(a.keySystem="com.chromecast.playready")}};
shaka.drm.DrmEngine.prototype.parseInbandPssh=function(a,b){if(!this.config_.parseInbandPsshEnabled||this.manifestInitData_)return Promise.resolve();var c=shaka.util.ManifestParserUtils.ContentType;if(![c.AUDIO,c.VIDEO].includes(a))return Promise.resolve();a=new shaka.util.Pssh(shaka.util.BufferUtils.toUint8(b));b=0;c=(0,$jscomp.makeIterator)(a.data);for(var d=c.next();!d.done;d=c.next())b+=d.value.length;if(b==0)return Promise.resolve();b=new Uint8Array(b);c=0;a=(0,$jscomp.makeIterator)(a.data);
for(d=a.next();!d.done;d=a.next())d=d.value,b.set(d,c),c+=d.length;this.newInitData("cenc",b);return this.allSessionsLoaded_};shaka.drm.DrmEngine.configureClearKey=function(a,b){a=shaka.util.MapUtils.asMap(a);if(a.size!=0){a=shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys(a);b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,c.video&&(c.video.drmInfos=[a]),c.audio&&(c.audio.drmInfos=[a])}};shaka.drm.DrmEngine.CLOSE_TIMEOUT_=1;
shaka.drm.DrmEngine.SESSION_LOAD_TIMEOUT_=5;shaka.drm.DrmEngine.KEY_STATUS_BATCH_TIME=.5;shaka.drm.FairPlay=function(){};shaka.drm.FairPlay.isFairPlaySupported=function(){var a;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.nextAddress==1)return a={initDataTypes:["cenc","sinf","skd"],videoCapabilities:[{contentType:'video/mp4; codecs="avc1.42E01E"'}]},b.setCatchFinallyBlocks(2),b.yield(navigator.requestMediaKeySystemAccess("com.apple.fps",[a]),4);if(b.nextAddress!=2)return b.return(!0);b.enterCatchBlock();return b.return(!1)})};
shaka.drm.FairPlay.defaultGetContentId=function(a){a=shaka.util.StringUtils.fromBytesAutoDetect(a);return(new goog.Uri(a)).getDomain()};shaka.drm.FairPlay.defaultGetKeyId=function(a){a=(new goog.Uri(a)).getDomain().replace(/-/g,"").toLowerCase();return a.length===32&&/^[0-9a-f]+$/.test(a)?a:null};
shaka.drm.FairPlay.initDataTransform=function(a,b,c){if(!c||!c.byteLength)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.SERVER_CERTIFICATE_REQUIRED);b=typeof b=="string"?shaka.util.StringUtils.toUTF16(b,!0):b;a=shaka.util.StringUtils.fromBytesAutoDetect(a);a=shaka.util.StringUtils.toUTF16(a,!0);var d=new Uint8Array(12+a.byteLength+b.byteLength+c.byteLength),e=0,f=function(g){shaka.util.BufferUtils.toDataView(d).setUint32(e,g.byteLength,
!0);e+=4;d.set(shaka.util.BufferUtils.toUint8(g),e);e+=g.byteLength};f(a);f(b);f(c);goog.asserts.assert(e==d.length,"Inconsistent init data length");return d};shaka.drm.FairPlay.basicInitDataTransform_=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split("skd://").pop();return shaka.drm.FairPlay.initDataTransform(a,c,b)};
shaka.drm.FairPlay.verimatrixInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};shaka.drm.FairPlay.ezdrmInitDataTransform=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split(";").pop();return shaka.drm.FairPlay.initDataTransform(a,c,b)};
shaka.drm.FairPlay.conaxInitDataTransform=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split("skd://").pop().split("?").shift();c=window.atob(c);var d=new ArrayBuffer(c.length*2);d=shaka.util.BufferUtils.toUint16(d);for(var e=0,f=c.length;e<f;e++)d[e]=c.charCodeAt(e);return shaka.drm.FairPlay.initDataTransform(a,d,b)};
shaka.drm.FairPlay.expressplayInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};shaka.drm.FairPlay.muxInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};
shaka.drm.FairPlay.verimatrixFairPlayRequest=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)&&(a=shaka.util.BufferUtils.toUint8(b.body),a=shaka.util.Uint8ArrayUtils.toBase64(a),b.headers["Content-Type"]="application/x-www-form-urlencoded",b.body=shaka.util.StringUtils.toUTF8("spc="+a))};
shaka.drm.FairPlay.octetStreamFairPlayRequest_=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)&&(b.headers["Content-Type"]="application/octet-stream")};shaka.drm.FairPlay.ezdrmFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};shaka.drm.FairPlay.conaxFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};
shaka.drm.FairPlay.expressplayFairPlayRequest=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(c=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(c.keySystem)&&shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};shaka.drm.FairPlay.muxFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};
shaka.drm.FairPlay.commonFairPlayResponse=function(a,b,c){if(a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.originalRequest.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)){try{var d=shaka.util.StringUtils.fromUTF8(b.data)}catch(f){return}a=!1;d=d.trim();d.substr(0,5)==="<ckc>"&&d.substr(-6)==="</ckc>"&&(d=d.slice(5,-6),a=!0);if(!a)try{var e=JSON.parse(d);e.ckc&&(d=e.ckc,a=!0);e.CkcMessage&&(d=e.CkcMessage,a=!0);e.License&&(d=e.License,a=!0)}catch(f){}a&&(b.data=shaka.util.BufferUtils.toArrayBuffer(shaka.util.Uint8ArrayUtils.fromBase64(d)))}};
goog.exportSymbol("shaka.drm.FairPlay",shaka.drm.FairPlay);goog.exportProperty(shaka.drm.FairPlay,"commonFairPlayResponse",shaka.drm.FairPlay.commonFairPlayResponse);goog.exportProperty(shaka.drm.FairPlay,"muxFairPlayRequest",shaka.drm.FairPlay.muxFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"expressplayFairPlayRequest",shaka.drm.FairPlay.expressplayFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"conaxFairPlayRequest",shaka.drm.FairPlay.conaxFairPlayRequest);
goog.exportProperty(shaka.drm.FairPlay,"ezdrmFairPlayRequest",shaka.drm.FairPlay.ezdrmFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"verimatrixFairPlayRequest",shaka.drm.FairPlay.verimatrixFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"muxInitDataTransform",shaka.drm.FairPlay.muxInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"expressplayInitDataTransform",shaka.drm.FairPlay.expressplayInitDataTransform);
goog.exportProperty(shaka.drm.FairPlay,"conaxInitDataTransform",shaka.drm.FairPlay.conaxInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"ezdrmInitDataTransform",shaka.drm.FairPlay.ezdrmInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"verimatrixInitDataTransform",shaka.drm.FairPlay.verimatrixInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"initDataTransform",shaka.drm.FairPlay.initDataTransform);goog.exportProperty(shaka.drm.FairPlay,"defaultGetContentId",shaka.drm.FairPlay.defaultGetContentId);
goog.exportProperty(shaka.drm.FairPlay,"isFairPlaySupported",shaka.drm.FairPlay.isFairPlaySupported);shaka.drm.PlayReady=function(){};shaka.drm.PlayReady.parseMsProRecords_=function(a,b){for(var c=[];b<a.byteLength-1;){var d=a.getUint16(b,!0);b+=2;var e=a.getUint16(b,!0);b+=2;if((e&1)!=0||e+b>a.byteLength)return shaka.log.warning("Malformed MS PRO object"),[];var f=shaka.util.BufferUtils.toUint8(a,b,e);c.push({type:d,value:f});b+=e}return c};
shaka.drm.PlayReady.parseMsPro_=function(a){var b=0,c=shaka.util.BufferUtils.toDataView(a),d=c.getUint32(b,!0);b+=4;return d!=a.byteLength?(shaka.log.warning("PlayReady Object with invalid length encountered."),[]):shaka.drm.PlayReady.parseMsProRecords_(c,b+2)};
shaka.drm.PlayReady.getLaurl_=function(a){a=(0,$jscomp.makeIterator)(shaka.util.TXml.getElementsByTagName(a,"DATA"));for(var b=a.next();!b.done;b=a.next())if(b=b.value,b.children){b=(0,$jscomp.makeIterator)(b.children);for(var c=b.next();!c.done;c=b.next())if(c=c.value,c.tagName=="LA_URL")return shaka.util.TXml.getTextContents(c)}return""};
shaka.drm.PlayReady.getPlayReadyHeaderObject_=function(a){var b=shaka.drm.PlayReady.PLAYREADY_RECORD_TYPES;a=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(a));a=shaka.drm.PlayReady.parseMsPro_(a).filter(function(c){return c.type===b.RIGHTS_MANAGEMENT})[0];if(!a)return null;a=shaka.util.StringUtils.fromUTF16(a.value,!0);return(a=shaka.util.TXml.parseXmlString(a,"WRMHEADER"))?a:null};
shaka.drm.PlayReady.getLicenseUrl=function(a){try{var b=shaka.drm.PlayReady.getPlayReadyHeaderObject_(a);return b?shaka.drm.PlayReady.getLaurl_(b):""}catch(c){return""}};
shaka.drm.PlayReady.getPlayReadyKID=function(a){var b=shaka.drm.PlayReady.getPlayReadyHeaderObject_(a);if(!b)return null;a=shaka.util.TXml;b=(0,$jscomp.makeIterator)(a.getElementsByTagName(b,"DATA"));for(var c=b.next();!c.done;c=b.next())if(c=a.findChild(c.value,"KID"))return a=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(c)),a=new Uint8Array([a[3],a[2],a[1],a[0],a[5],a[4],a[7],a[6]].concat((0,$jscomp.arrayFromIterable)(a.slice(8)))),shaka.util.Uint8ArrayUtils.toHex(a);return null};
shaka.drm.PlayReady.PLAYREADY_RECORD_TYPES={RIGHTS_MANAGEMENT:1,RESERVED:2,EMBEDDED_LICENSE:3};shaka.hls={};shaka.hls.Playlist=function(a,b,c){this.type=a;this.tags=b;this.segments=c||null};shaka.hls.PlaylistType={MASTER:0,MEDIA:1};shaka.hls.Tag=function(a,b,c,d){this.id=a;this.name=b;this.attributes=c;this.value=d===void 0?null:d};
shaka.hls.Tag.prototype.toString=function(a){var b=function(d){var e=isNaN(Number(d.value))?'"'+d.value+'"':d.value;return d.name+"="+e},c="#"+this.name;b=this.attributes?this.attributes.filter(function(d){return a?!a.has(d.name):!0}).map(b):[];this.value&&b.unshift(this.value);b.length>0&&(c+=":"+b.join(","));return c};shaka.hls.Tag.prototype.getTagKey=function(a){if(a)return this.toString();a=(new Set).add("AUDIO").add("VIDEO").add("SUBTITLES").add("PATHWAY-ID").add("GROUP-ID").add("URI");return this.toString(a)};
shaka.hls.Tag.prototype.addAttribute=function(a){this.attributes.push(a)};shaka.hls.Tag.prototype.getAttribute=function(a){var b=this.attributes.filter(function(c){return c.name==a});goog.asserts.assert(b.length<2,"A tag should not have multiple attributes with the same name!");return b.length?b[0]:null};shaka.hls.Tag.prototype.getAttributeValue=function(a,b){return(a=this.getAttribute(a))?a.value:b||null};
shaka.hls.Tag.prototype.getRequiredAttrValue=function(a){var b=this.getAttribute(a);if(!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_REQUIRED_ATTRIBUTE_MISSING,a);return b.value};shaka.hls.Tag.prototype.setName=function(a){this.name=a};shaka.hls.Segment=function(a,b,c){c=c===void 0?[]:c;this.tags=b;this.verbatimSegmentUri=a;this.partialSegments=c};shaka.hls.Attribute=function(a,b){this.name=a;this.value=b};shaka.hls.Utils=function(){};shaka.hls.Utils.filterTagsByName=function(a,b){return a.filter(function(c){return c.name==b})};shaka.hls.Utils.filterTagsByType=function(a,b){return a.filter(function(c){return c.getRequiredAttrValue("TYPE")==b})};shaka.hls.Utils.getFirstTagWithName=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(c=c.value,c.name===b)return c;return null};
shaka.hls.Utils.getFirstTagWithNameAsNumber=function(a,b,c){c=c===void 0?0:c;return(a=shaka.hls.Utils.getFirstTagWithName(a,b))?Number(a.value):c};shaka.hls.Utils.constructSegmentUris=function(a,b,c){return b?shaka.hls.Utils.constructUris(a,[b],c):[]};shaka.hls.Utils.constructUris=function(a,b,c){if(!b.length)return[];var d=b;c&&c.size&&(d=b.map(function(e){return shaka.hls.Utils.variableSubstitution(e,c)}));return shaka.util.ManifestParserUtils.resolveUris(a,d)};
shaka.hls.Utils.variableSubstitution=function(a,b){if(!b||!b.size)return a;a=String(a).replace(/%7B/g,"{").replace(/%7D/g,"}");var c=a.match(/{\$\w*}/g);if(c){c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=d.slice(2,d.length-1),f=b.get(e);if(f)a=a.replace(d,f);else throw shaka.log.error("A variable has been found that is not declared",e),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_VARIABLE_NOT_FOUND,
e);}}return a};shaka.hls.Utils.isComment=function(a){return a.startsWith("#")&&!a.startsWith("#EXT")};shaka.hls.ManifestTextParser=function(){this.globalId_=0};
shaka.hls.ManifestTextParser.prototype.parsePlaylist=function(a){a=shaka.util.StringUtils.fromUTF8(a);a=a.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n").trim();var b=a.split(/\n+/m);if(!shaka.hls.ManifestTextParser.STATIC_PATTERNS.header.test(b[0]))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_PLAYLIST_HEADER_MISSING);a=shaka.hls.PlaylistType.MASTER;for(var c=!1,d=[],e=!0,f=0;f<b.length;f++){var g=b[f],h=b[f+1];if(shaka.hls.Utils.isComment(g)||
e)e=!1;else{g=this.parseTag_(g);c||(shaka.hls.ManifestTextParser.MEDIA_PLAYLIST_TAGS.has(g.name)?(a=shaka.hls.PlaylistType.MEDIA,c=!0):g.name=="EXT-X-STREAM-INF"||g.name=="EXT-X-MEDIA"?c=!0:shaka.hls.ManifestTextParser.SEGMENT_TAGS.has(g.name)&&(a=shaka.hls.PlaylistType.MEDIA,c=!0));if(shaka.hls.ManifestTextParser.SEGMENT_TAGS.has(g.name)){if(a!=shaka.hls.PlaylistType.MEDIA)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_INVALID_PLAYLIST_HIERARCHY);
b=this.parseSegments_(b,f,d);return new shaka.hls.Playlist(a,d,b)}d.push(g);g.name=="EXT-X-STREAM-INF"&&(e=new shaka.hls.Attribute("URI",h),g.addAttribute(e),e=!0)}}return new shaka.hls.Playlist(a,d)};
shaka.hls.ManifestTextParser.prototype.parseSegments_=function(a,b,c){for(var d=Array(Math.max(100,Math.floor((a.length-b)/2))),e=0,f=[],g=[],h=null;b<a.length;b++){var k=a[b];k.startsWith("#EXT")?(k=this.parseTag_(k),shaka.hls.ManifestTextParser.MEDIA_PLAYLIST_TAGS.has(k.name)?c.push(k):k.name=="EXT-X-MAP"?h=k:k.name=="EXT-X-PART"?g.push(k):k.name=="EXT-X-PRELOAD-HINT"?k.getAttributeValue("TYPE")=="PART"?g.push(k):k.getAttributeValue("TYPE")=="MAP"&&(k.setName("EXT-X-MAP"),h=k):f.push(k)):shaka.hls.Utils.isComment(k)||
(k=k.trim(),h&&f.push(h),f=new shaka.hls.Segment(k,f,g),e<d.length?d[e++]=f:(d.push(f),e++),f=[],g=[])}g.length&&(h&&f.push(h),a=new shaka.hls.Segment("",f,g),e<d.length?d[e++]=a:(d.push(a),e++));return e<d.length?d.slice(0,e):d};shaka.hls.ManifestTextParser.prototype.parseTag_=function(a){return shaka.hls.ManifestTextParser.parseTag(this.globalId_++,a)};
shaka.hls.ManifestTextParser.parseTag=function(a,b){var c=b.match(shaka.hls.ManifestTextParser.STATIC_PATTERNS.tagBlocks);if(!c)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.INVALID_HLS_TAG,b);b=c[1];var d=c[2];c=[];var e;if(d){d=new shaka.util.TextParser(d);var f;shaka.hls.ManifestTextParser.STATIC_PATTERNS.valueRegex.lastIndex=0;(f=d.readRegex(shaka.hls.ManifestTextParser.STATIC_PATTERNS.valueRegex))&&(e=f[1]);shaka.hls.ManifestTextParser.STATIC_PATTERNS.attributeRegex.lastIndex=
0;for(f=d.readRegex(shaka.hls.ManifestTextParser.STATIC_PATTERNS.attributeRegex);f;)f=new shaka.hls.Attribute(f[1],f[2]||f[3]),c.push(f),d.skipWhitespace(),f=d.readRegex(shaka.hls.ManifestTextParser.STATIC_PATTERNS.attributeRegex)}return new shaka.hls.Tag(a,b,c,e)};shaka.hls.ManifestTextParser.STATIC_PATTERNS={tagBlocks:/^#(EXT[^:]*)(?::(.*))?$/,header:/^#EXTM3U($|[ \t\n])/m,valueRegex:/^([^,=]+)(?:,|$)/g,attributeRegex:/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g};
shaka.hls.ManifestTextParser.MEDIA_PLAYLIST_TAGS=new Set("EXT-X-TARGETDURATION EXT-X-MEDIA-SEQUENCE EXT-X-DISCONTINUITY-SEQUENCE EXT-X-PLAYLIST-TYPE EXT-X-I-FRAMES-ONLY EXT-X-ENDLIST EXT-X-SERVER-CONTROL EXT-X-SKIP EXT-X-PART-INF EXT-X-DATERANGE".split(" "));shaka.hls.ManifestTextParser.SEGMENT_TAGS=new Set("EXTINF EXT-X-BYTERANGE EXT-X-DISCONTINUITY EXT-X-PROGRAM-DATE-TIME EXT-X-KEY EXT-X-DATERANGE EXT-X-MAP EXT-X-GAP EXT-X-TILES".split(" "));shaka.media.InitSegmentReference=function(a,b,c,d,e,f,g,h){this.getUris=a;this.startByte=b;this.endByte=c;this.mediaQuality=d===void 0?null:d;this.timescale=e===void 0?null:e;this.segmentData=f===void 0?null:f;this.aesKey=g===void 0?null:g;this.boundaryEnd=this.mimeType=this.codecs=null;this.encrypted=h===void 0?!1:h};shaka.media.InitSegmentReference.prototype.getStartByte=function(){return this.startByte};shaka.media.InitSegmentReference.prototype.getEndByte=function(){return this.endByte};
shaka.media.InitSegmentReference.prototype.getSize=function(){return this.endByte?this.endByte+1-this.startByte:null};shaka.media.InitSegmentReference.prototype.getMediaQuality=function(){return this.mediaQuality};shaka.media.InitSegmentReference.prototype.setSegmentData=function(a){this.segmentData=a};shaka.media.InitSegmentReference.prototype.getSegmentData=function(){return this.segmentData};
shaka.media.InitSegmentReference.equal=function(a,b){var c=shaka.util.ArrayUtils,d=shaka.util.BufferUtils;return a===b?!0:a&&b?a.getStartByte()==b.getStartByte()&&a.getEndByte()==b.getEndByte()&&c.equal(a.getUris().sort(),b.getUris().sort())&&d.equal(a.getSegmentData(),b.getSegmentData()):a==b};goog.exportSymbol("shaka.media.InitSegmentReference",shaka.media.InitSegmentReference);goog.exportProperty(shaka.media.InitSegmentReference.prototype,"getEndByte",shaka.media.InitSegmentReference.prototype.getEndByte);
goog.exportProperty(shaka.media.InitSegmentReference.prototype,"getStartByte",shaka.media.InitSegmentReference.prototype.getStartByte);
shaka.media.SegmentReference=function(a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t){l=l===void 0?[]:l;m=m===void 0?"":m;n=n===void 0?null:n;p=p===void 0?null:p;q=q===void 0?shaka.media.SegmentReference.Status.AVAILABLE:q;r=r===void 0?null:r;t=t===void 0?!1:t;goog.asserts.assert(a<=b,"startTime must be less than or equal to endTime");goog.asserts.assert(e==null||d<e,"startByte must be < endByte");this.startTime=a;this.trueEndTime=this.endTime=b;this.getUrisInner=c;this.startByte=d;this.endByte=e;this.initSegmentReference=
f;this.timestampOffset=g;this.appendWindowStart=h;this.appendWindowEnd=k;this.partialReferences=l;this.tilesLayout=m;this.tileDuration=n;this.syncTime=p;this.status=q;this.preload=!1;this.independent=!0;this.byterangeOptimization=!1;this.aesKey=r;this.thumbnailSprite=null;this.discontinuitySequence=-1;this.allPartialSegments=t;this.lastPartial=this.partial=!1;a=(0,$jscomp.makeIterator)(this.partialReferences);for(b=a.next();!b.done;b=a.next())b.value.markAsPartial();this.allPartialSegments&&this.partialReferences.length&&
this.partialReferences[this.partialReferences.length-1].markAsLastPartial();this.segmentData=this.bandwidth=this.mimeType=this.codecs=null;this.removeSegmentDataOnGet=!1};shaka.media.SegmentReference.prototype.getUris=function(){return this.getUrisInner()};shaka.media.SegmentReference.prototype.getStartTime=function(){return this.startTime};shaka.media.SegmentReference.prototype.getEndTime=function(){return this.endTime};shaka.media.SegmentReference.prototype.getStartByte=function(){return this.startByte};
shaka.media.SegmentReference.prototype.getEndByte=function(){return this.endByte};shaka.media.SegmentReference.prototype.getSize=function(){if(this.endByte)return this.endByte+1-this.startByte;if(this.bandwidth){var a=this.bandwidth*(this.endTime-this.startTime);if(!isNaN(a)&&a>0)return a}if(this.hasPartialSegments()&&this.hasAllPartialSegments())for(a=(0,$jscomp.makeIterator)(this.partialReferences),a=a.next();!a.done;a=a.next()){a.value.getSize();break}return null};
shaka.media.SegmentReference.prototype.hasPartialSegments=function(){return this.partialReferences.length>0};shaka.media.SegmentReference.prototype.hasAllPartialSegments=function(){return this.allPartialSegments};shaka.media.SegmentReference.prototype.getTilesLayout=function(){return this.tilesLayout};shaka.media.SegmentReference.prototype.getTileDuration=function(){return this.tileDuration};shaka.media.SegmentReference.prototype.getStatus=function(){return this.status};
shaka.media.SegmentReference.prototype.markAsUnavailable=function(){this.status=shaka.media.SegmentReference.Status.UNAVAILABLE};shaka.media.SegmentReference.prototype.markAsPreload=function(){this.preload=!0};shaka.media.SegmentReference.prototype.isPreload=function(){return this.preload};shaka.media.SegmentReference.prototype.markAsNonIndependent=function(){this.independent=!1};shaka.media.SegmentReference.prototype.isIndependent=function(){return this.independent};
shaka.media.SegmentReference.prototype.markAsPartial=function(){this.partial=!0};shaka.media.SegmentReference.prototype.isPartial=function(){return this.partial};shaka.media.SegmentReference.prototype.markAsLastPartial=function(){this.lastPartial=!0};shaka.media.SegmentReference.prototype.isLastPartial=function(){return this.lastPartial};shaka.media.SegmentReference.prototype.markAsByterangeOptimization=function(){this.byterangeOptimization=!0};
shaka.media.SegmentReference.prototype.hasByterangeOptimization=function(){return this.byterangeOptimization};shaka.media.SegmentReference.prototype.setThumbnailSprite=function(a){this.thumbnailSprite=a};shaka.media.SegmentReference.prototype.getThumbnailSprite=function(){return this.thumbnailSprite};
shaka.media.SegmentReference.prototype.offset=function(a){this.startTime+=a;this.endTime+=a;this.trueEndTime+=a;for(var b=(0,$jscomp.makeIterator)(this.partialReferences),c=b.next();!c.done;c=b.next())c=c.value,c.startTime+=a,c.endTime+=a,c.trueEndTime+=a};shaka.media.SegmentReference.prototype.syncAgainst=function(a){this.syncTime==null?shaka.log.alwaysError("Sync attempted without sync time!"):(a=this.syncTime-a-this.startTime,Math.abs(a)>=.001&&this.offset(a))};
shaka.media.SegmentReference.prototype.setSegmentData=function(a,b){this.segmentData=a;this.removeSegmentDataOnGet=b===void 0?!1:b};shaka.media.SegmentReference.prototype.getSegmentData=function(a){var b=this.segmentData;(a===void 0||a)&&this.removeSegmentDataOnGet&&(this.segmentData=null);return b};shaka.media.SegmentReference.prototype.updateInitSegmentReference=function(a){this.initSegmentReference=a;for(var b=(0,$jscomp.makeIterator)(this.partialReferences),c=b.next();!c.done;c=b.next())c.value.updateInitSegmentReference(a)};
goog.exportSymbol("shaka.media.SegmentReference",shaka.media.SegmentReference);goog.exportProperty(shaka.media.SegmentReference.prototype,"getSegmentData",shaka.media.SegmentReference.prototype.getSegmentData);goog.exportProperty(shaka.media.SegmentReference.prototype,"setSegmentData",shaka.media.SegmentReference.prototype.setSegmentData);goog.exportProperty(shaka.media.SegmentReference.prototype,"syncAgainst",shaka.media.SegmentReference.prototype.syncAgainst);
goog.exportProperty(shaka.media.SegmentReference.prototype,"offset",shaka.media.SegmentReference.prototype.offset);goog.exportProperty(shaka.media.SegmentReference.prototype,"getThumbnailSprite",shaka.media.SegmentReference.prototype.getThumbnailSprite);goog.exportProperty(shaka.media.SegmentReference.prototype,"setThumbnailSprite",shaka.media.SegmentReference.prototype.setThumbnailSprite);goog.exportProperty(shaka.media.SegmentReference.prototype,"hasByterangeOptimization",shaka.media.SegmentReference.prototype.hasByterangeOptimization);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsByterangeOptimization",shaka.media.SegmentReference.prototype.markAsByterangeOptimization);goog.exportProperty(shaka.media.SegmentReference.prototype,"isLastPartial",shaka.media.SegmentReference.prototype.isLastPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsLastPartial",shaka.media.SegmentReference.prototype.markAsLastPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"isPartial",shaka.media.SegmentReference.prototype.isPartial);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsPartial",shaka.media.SegmentReference.prototype.markAsPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"isIndependent",shaka.media.SegmentReference.prototype.isIndependent);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsNonIndependent",shaka.media.SegmentReference.prototype.markAsNonIndependent);goog.exportProperty(shaka.media.SegmentReference.prototype,"isPreload",shaka.media.SegmentReference.prototype.isPreload);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsPreload",shaka.media.SegmentReference.prototype.markAsPreload);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsUnavailable",shaka.media.SegmentReference.prototype.markAsUnavailable);goog.exportProperty(shaka.media.SegmentReference.prototype,"getStatus",shaka.media.SegmentReference.prototype.getStatus);goog.exportProperty(shaka.media.SegmentReference.prototype,"getTileDuration",shaka.media.SegmentReference.prototype.getTileDuration);
goog.exportProperty(shaka.media.SegmentReference.prototype,"getTilesLayout",shaka.media.SegmentReference.prototype.getTilesLayout);goog.exportProperty(shaka.media.SegmentReference.prototype,"getEndByte",shaka.media.SegmentReference.prototype.getEndByte);goog.exportProperty(shaka.media.SegmentReference.prototype,"getStartByte",shaka.media.SegmentReference.prototype.getStartByte);goog.exportProperty(shaka.media.SegmentReference.prototype,"getEndTime",shaka.media.SegmentReference.prototype.getEndTime);
goog.exportProperty(shaka.media.SegmentReference.prototype,"getStartTime",shaka.media.SegmentReference.prototype.getStartTime);goog.exportProperty(shaka.media.SegmentReference.prototype,"getUris",shaka.media.SegmentReference.prototype.getUris);shaka.media.SegmentReference.Status={AVAILABLE:0,UNAVAILABLE:1,MISSING:2};goog.exportProperty(shaka.media.SegmentReference,"Status",shaka.media.SegmentReference.Status);shaka.media.ManifestParser=function(){};shaka.media.ManifestParser.registerParserByExtension=function(a,b){shaka.Deprecate.deprecateFeature(5,"ManifestParser.registerParserByExtension","Please use an ManifestParser with registerParserByMime function.")};shaka.media.ManifestParser.registerParserByMime=function(a,b){shaka.media.ManifestParser.parsersByMime.set(a,b)};shaka.media.ManifestParser.unregisterParserByMime=function(a){shaka.media.ManifestParser.parsersByMime.delete(a)};
shaka.media.ManifestParser.probeSupport=function(){var a=shaka.media.ManifestParser,b={},c=shaka.device.DeviceFactory.getDevice();if(c.supportsMediaSource())for(var d=(0,$jscomp.makeIterator)(a.parsersByMime.keys()),e=d.next();!e.done;e=d.next())b[e.value]=!0;d=(0,$jscomp.makeIterator)(["application/dash+xml","application/x-mpegurl","application/vnd.apple.mpegurl","application/vnd.ms-sstr+xml"]);for(e=d.next();!e.done;e=d.next())e=e.value,c.supportsMediaSource()?b[e]=a.parsersByMime.has(e):b[e]=c.supportsMediaType(e);
return b};shaka.media.ManifestParser.getFactory=function(a,b){var c=shaka.media.ManifestParser;if(b){if(c=c.parsersByMime.get(b.toLowerCase()))return c;shaka.log.warning("Could not determine manifest type using MIME type ",b)}throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.UNABLE_TO_GUESS_MANIFEST_TYPE,a,b);};
shaka.media.ManifestParser.isSupported=function(a){return shaka.device.DeviceFactory.getDevice().supportsMediaSource()?shaka.media.ManifestParser.parsersByMime.has(a):!1};goog.exportSymbol("shaka.media.ManifestParser",shaka.media.ManifestParser);goog.exportProperty(shaka.media.ManifestParser,"unregisterParserByMime",shaka.media.ManifestParser.unregisterParserByMime);goog.exportProperty(shaka.media.ManifestParser,"registerParserByMime",shaka.media.ManifestParser.registerParserByMime);
goog.exportProperty(shaka.media.ManifestParser,"registerParserByExtension",shaka.media.ManifestParser.registerParserByExtension);shaka.media.ManifestParser.HLS="HLS";shaka.media.ManifestParser.DASH="DASH";shaka.media.ManifestParser.MSS="MSS";shaka.media.ManifestParser.UNKNOWN="UNKNOWN";shaka.media.ManifestParser.AccessibilityPurpose={VISUALLY_IMPAIRED:"visually impaired",HARD_OF_HEARING:"hard of hearing",SPOKEN_SUBTITLES:"spoken subtitles"};
goog.exportProperty(shaka.media.ManifestParser,"AccessibilityPurpose",shaka.media.ManifestParser.AccessibilityPurpose);shaka.media.ManifestParser.parsersByMime=new Map;shaka.media.PresentationTimeline=function(a,b,c){this.presentationStartTime_=a;this.presentationDelay_=b;this.segmentAvailabilityDuration_=this.duration_=Infinity;this.maxSegmentDuration_=1;this.maxSegmentEndTime_=this.minSegmentStartTime_=null;this.clockOffset_=0;this.static_=!0;this.isLive2VodTransition_=!1;this.userSeekStart_=0;this.autoCorrectDrift_=c===void 0?!0:c;this.availabilityTimeOffset_=0;this.startTimeLocked_=!1;this.initialProgramDateTime_=a};
shaka.media.PresentationTimeline.prototype.getDuration=function(){return this.duration_};shaka.media.PresentationTimeline.prototype.getMaxSegmentDuration=function(){return this.maxSegmentDuration_};shaka.media.PresentationTimeline.prototype.setPresentationStartTime=function(a){goog.asserts.assert(a>=0,"presentationStartTime must be >= 0");this.presentationStartTime_=a};
shaka.media.PresentationTimeline.prototype.setDuration=function(a){goog.asserts.assert(a>0,"duration must be > 0");this.duration_=a};shaka.media.PresentationTimeline.prototype.getPresentationStartTime=function(){return this.presentationStartTime_};shaka.media.PresentationTimeline.prototype.setClockOffset=function(a){this.clockOffset_=a};shaka.media.PresentationTimeline.prototype.setStatic=function(a){a&&!this.static_&&(this.isLive2VodTransition_=!0);this.static_=a};
shaka.media.PresentationTimeline.prototype.setSegmentAvailabilityDuration=function(a){goog.asserts.assert(a>=0,"segmentAvailabilityDuration must be >= 0");this.segmentAvailabilityDuration_=a};shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityDuration=function(){return this.segmentAvailabilityDuration_};shaka.media.PresentationTimeline.prototype.setDelay=function(a){goog.asserts.assert(a>=0,"delay must be >= 0");this.presentationDelay_=a};
shaka.media.PresentationTimeline.prototype.getDelay=function(){return this.presentationDelay_};
shaka.media.PresentationTimeline.prototype.notifyTimeRange=function(a,b){if(a.length!=0){var c=(Date.now()+this.clockOffset_)/1E3;a=a.filter(function(e){return e.start+b<c});if(a.length!=0){var d=a[a.length-1].end+b;this.notifyMinSegmentStartTime(a[0].start+b);this.maxSegmentDuration_=a.reduce(function(e,f){return Math.max(e,f.end-f.start)},this.maxSegmentDuration_);this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,d);this.presentationStartTime_!=null&&this.autoCorrectDrift_&&!this.startTimeLocked_&&
(this.presentationStartTime_=c-this.maxSegmentEndTime_-this.maxSegmentDuration_);shaka.log.v1("notifySegments:","maxSegmentDuration="+this.maxSegmentDuration_)}}};
shaka.media.PresentationTimeline.prototype.notifySegments=function(a){if(a.length!=0){var b=a[0].startTime,c=a[0].endTime,d=(Date.now()+this.clockOffset_)/1E3;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next())e=e.value,d<e.startTime||(b=Math.min(b,e.startTime),c=Math.max(c,e.endTime),this.maxSegmentDuration_=Math.max(this.maxSegmentDuration_,e.endTime-e.startTime));this.notifyMinSegmentStartTime(b);this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,c);this.presentationStartTime_!=
null&&this.autoCorrectDrift_&&!this.startTimeLocked_&&(this.presentationStartTime_=d-this.maxSegmentEndTime_-this.maxSegmentDuration_);shaka.log.v1("notifySegments:","maxSegmentDuration="+this.maxSegmentDuration_)}};shaka.media.PresentationTimeline.prototype.notifyPeriodDuration=function(a,b){this.notifyMinSegmentStartTime(a);b==Infinity||this.isLive()||(this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,b))};shaka.media.PresentationTimeline.prototype.getMaxSegmentEndTime=function(){return this.maxSegmentEndTime_};
shaka.media.PresentationTimeline.prototype.lockStartTime=function(){this.startTimeLocked_=!0};shaka.media.PresentationTimeline.prototype.isStartTimeLocked=function(){return this.startTimeLocked_};shaka.media.PresentationTimeline.prototype.setInitialProgramDateTime=function(a){this.initialProgramDateTime_=a};shaka.media.PresentationTimeline.prototype.getInitialProgramDateTime=function(){return this.initialProgramDateTime_};
shaka.media.PresentationTimeline.prototype.notifyMinSegmentStartTime=function(a){this.minSegmentStartTime_==null?this.minSegmentStartTime_=a:this.isLive2VodTransition_||(this.minSegmentStartTime_=Math.min(this.minSegmentStartTime_,a))};shaka.media.PresentationTimeline.prototype.notifyMaxSegmentDuration=function(a){this.maxSegmentDuration_=Math.max(this.maxSegmentDuration_,a);shaka.log.v1("notifyNewSegmentDuration:","maxSegmentDuration="+this.maxSegmentDuration_)};
shaka.media.PresentationTimeline.prototype.offset=function(a){this.minSegmentStartTime_!=null&&(this.minSegmentStartTime_+=a);this.maxSegmentEndTime_!=null&&(this.maxSegmentEndTime_+=a)};shaka.media.PresentationTimeline.prototype.isLive=function(){return this.duration_==Infinity&&!this.static_};shaka.media.PresentationTimeline.prototype.isInProgress=function(){return this.duration_!=Infinity&&!this.static_};
shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityStart=function(){goog.asserts.assert(this.segmentAvailabilityDuration_>=0,"The availability duration should be positive");var a=this.getSegmentAvailabilityEnd()-this.segmentAvailabilityDuration_;return Math.max(this.userSeekStart_,a)};shaka.media.PresentationTimeline.prototype.setUserSeekStart=function(a){this.userSeekStart_=a};
shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityEnd=function(){return this.isLive()||this.isInProgress()?Math.min(this.getLiveEdge_()+this.availabilityTimeOffset_,this.duration_):this.maxSegmentEndTime_?Math.min(this.maxSegmentEndTime_,this.duration_):this.duration_};
shaka.media.PresentationTimeline.prototype.getSafeSeekRangeStart=function(a){var b=Math.max(this.minSegmentStartTime_,this.userSeekStart_);if(this.segmentAvailabilityDuration_==Infinity)return Math.ceil(b*1E3)/1E3;var c=this.getSegmentAvailabilityEnd()-this.segmentAvailabilityDuration_;a=Math.min(c+a,this.getSeekRangeEnd());return Math.max(b,a)};shaka.media.PresentationTimeline.prototype.getSeekRangeStart=function(){return this.getSafeSeekRangeStart(0)};
shaka.media.PresentationTimeline.prototype.getSeekRangeEnd=function(){var a=this.isLive()||this.isInProgress()?this.presentationDelay_:0;return Math.max(0,this.getSegmentAvailabilityEnd()-a)};shaka.media.PresentationTimeline.prototype.usingPresentationStartTime=function(){return this.presentationStartTime_==null||this.maxSegmentEndTime_!=null&&this.autoCorrectDrift_?!1:!0};
shaka.media.PresentationTimeline.prototype.getLiveEdge_=function(){goog.asserts.assert(this.presentationStartTime_!=null,"Cannot compute timeline live edge without start time");var a=(Date.now()+this.clockOffset_)/1E3;return Math.max(0,a-this.maxSegmentDuration_-this.presentationStartTime_)};shaka.media.PresentationTimeline.prototype.setAvailabilityTimeOffset=function(a){this.availabilityTimeOffset_=a};shaka.media.PresentationTimeline.prototype.getAvailabilityTimeOffset=function(){return this.availabilityTimeOffset_};
shaka.media.PresentationTimeline.prototype.assertIsValid=function(){goog.DEBUG&&(this.isLive()?goog.asserts.assert(this.presentationStartTime_!=null,"Detected as live stream, but does not match our model of live!"):this.isInProgress()?goog.asserts.assert(this.presentationStartTime_!=null&&this.segmentAvailabilityDuration_==Infinity,"Detected as IPR stream, but does not match our model of IPR!"):goog.asserts.assert(this.segmentAvailabilityDuration_==Infinity&&this.duration_!=Infinity&&this.static_,
"Detected as VOD stream, but does not match our model of VOD!"))};goog.exportSymbol("shaka.media.PresentationTimeline",shaka.media.PresentationTimeline);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getAvailabilityTimeOffset",shaka.media.PresentationTimeline.prototype.getAvailabilityTimeOffset);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setAvailabilityTimeOffset",shaka.media.PresentationTimeline.prototype.setAvailabilityTimeOffset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"usingPresentationStartTime",shaka.media.PresentationTimeline.prototype.usingPresentationStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSeekRangeEnd",shaka.media.PresentationTimeline.prototype.getSeekRangeEnd);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSeekRangeStart",shaka.media.PresentationTimeline.prototype.getSeekRangeStart);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSafeSeekRangeStart",shaka.media.PresentationTimeline.prototype.getSafeSeekRangeStart);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityEnd",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityEnd);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setUserSeekStart",shaka.media.PresentationTimeline.prototype.setUserSeekStart);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityStart",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityStart);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isInProgress",shaka.media.PresentationTimeline.prototype.isInProgress);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isLive",shaka.media.PresentationTimeline.prototype.isLive);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"offset",shaka.media.PresentationTimeline.prototype.offset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyMaxSegmentDuration",shaka.media.PresentationTimeline.prototype.notifyMaxSegmentDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyMinSegmentStartTime",shaka.media.PresentationTimeline.prototype.notifyMinSegmentStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getInitialProgramDateTime",shaka.media.PresentationTimeline.prototype.getInitialProgramDateTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setInitialProgramDateTime",shaka.media.PresentationTimeline.prototype.setInitialProgramDateTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isStartTimeLocked",shaka.media.PresentationTimeline.prototype.isStartTimeLocked);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"lockStartTime",shaka.media.PresentationTimeline.prototype.lockStartTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getMaxSegmentEndTime",shaka.media.PresentationTimeline.prototype.getMaxSegmentEndTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyPeriodDuration",shaka.media.PresentationTimeline.prototype.notifyPeriodDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifySegments",shaka.media.PresentationTimeline.prototype.notifySegments);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyTimeRange",shaka.media.PresentationTimeline.prototype.notifyTimeRange);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getDelay",shaka.media.PresentationTimeline.prototype.getDelay);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setDelay",shaka.media.PresentationTimeline.prototype.setDelay);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityDuration",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityDuration);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setSegmentAvailabilityDuration",shaka.media.PresentationTimeline.prototype.setSegmentAvailabilityDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setStatic",shaka.media.PresentationTimeline.prototype.setStatic);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setClockOffset",shaka.media.PresentationTimeline.prototype.setClockOffset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getPresentationStartTime",shaka.media.PresentationTimeline.prototype.getPresentationStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setDuration",shaka.media.PresentationTimeline.prototype.setDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setPresentationStartTime",shaka.media.PresentationTimeline.prototype.setPresentationStartTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getMaxSegmentDuration",shaka.media.PresentationTimeline.prototype.getMaxSegmentDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getDuration",shaka.media.PresentationTimeline.prototype.getDuration);shaka.media.IPlayheadObserver=function(){};shaka.media.IPlayheadObserver.prototype.poll=function(a,b){};
shaka.media.PlayheadObserverManager=function(a){var b=this;this.mediaElement_=a;this.eventManager_=new shaka.util.EventManager;this.observers_=new Set;this.pollingLoop_=(new shaka.util.Timer(function(){b.pollAllObservers_(!1)})).tickNow();a.paused||this.pollingLoop_.tickEvery(.25);this.eventManager_.listen(a,"playing",function(){b.pollingLoop_.tickNow().tickEvery(.25)});this.eventManager_.listen(a,"pause",function(){b.pollingLoop_.stop()})};
shaka.media.PlayheadObserverManager.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.pollingLoop_.stop();for(var a=(0,$jscomp.makeIterator)(this.observers_),b=a.next();!b.done;b=a.next())b.value.release();this.observers_.clear()};shaka.media.PlayheadObserverManager.prototype.manage=function(a){this.observers_.add(a)};shaka.media.PlayheadObserverManager.prototype.notifyOfSeek=function(a){this.pollAllObservers_(a)};
shaka.media.PlayheadObserverManager.prototype.pollAllObservers_=function(a){for(var b=this.mediaElement_.currentTime,c=(0,$jscomp.makeIterator)(this.observers_),d=c.next();!d.done;d=c.next())d.value.poll(b,a)};shaka.media.QualityObserver=function(a){shaka.util.FakeEventTarget.call(this);this.contentTypeStates_=new Map;this.getBufferedInfo_=a};$jscomp.inherits(shaka.media.QualityObserver,shaka.util.FakeEventTarget);shaka.media.QualityObserver.prototype.release=function(){this.contentTypeStates_.clear();shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.QualityObserver.prototype.getContentTypeState_=function(a){var b=this.contentTypeStates_.get(a);b||(b={qualityChangePositions:[],currentQuality:null,contentType:a},this.contentTypeStates_.set(a,b));return b};
shaka.media.QualityObserver.prototype.addMediaQualityChange=function(a,b){var c=this.getContentTypeState_(a.contentType);this.purgeQualityChangePositions_(c);a={mediaQuality:a,position:b};c=c.qualityChangePositions;var d=c.findIndex(function(e){return e.position>=b});d>=0?c.splice(d,c[d].position==b?1:0,a):c.push(a)};shaka.media.QualityObserver.getMediaQualityAtPosition_=function(a,b){b=b.qualityChangePositions;for(var c=b.length-1;c>=0;c--){var d=b[c];if(d.position<=a)return d.mediaQuality}return null};
shaka.media.QualityObserver.mediaQualitiesAreTheSame_=function(a,b){return a===b?!0:a&&b?a.bandwidth==b.bandwidth&&a.audioSamplingRate==b.audioSamplingRate&&a.codecs==b.codecs&&a.contentType==b.contentType&&a.frameRate==b.frameRate&&a.height==b.height&&a.mimeType==b.mimeType&&a.channelsCount==b.channelsCount&&a.pixelAspectRatio==b.pixelAspectRatio&&a.width==b.width:!1};
shaka.media.QualityObserver.prototype.poll=function(a,b){b=(0,$jscomp.makeIterator)(this.contentTypeStates_.values());for(var c=b.next();!c.done;c=b.next()){c=c.value;var d=c.currentQuality,e=shaka.media.QualityObserver.getMediaQualityAtPosition_(a,c),f=e&&!shaka.media.QualityObserver.mediaQualitiesAreTheSame_(d,e),g=e&&d&&e.label&&d.label&&d.label!==e.label,h=e&&d&&e.language&&d.language&&d.language!==e.language;d=e&&d&&e.roles&&d.roles&&!shaka.util.ArrayUtils.equal(d.roles,e.roles);(g||h||d)&&this.positionIsBuffered_(a,
e.contentType)&&(c.currentQuality=e,g=new shaka.util.FakeEvent("audiotrackchange",new Map([["quality",e],["position",a]])),this.dispatchEvent(g));f&&this.positionIsBuffered_(a,e.contentType)&&(c.currentQuality=e,shaka.log.debug("Media quality changed at position "+a+" "+JSON.stringify(e)),c=new shaka.util.FakeEvent("qualitychange",new Map([["quality",e],["position",a]])),this.dispatchEvent(c))}};
shaka.media.QualityObserver.prototype.positionIsBuffered_=function(a,b){if((b=this.getBufferedInfo_()[b])&&b.length>0){var c=b[b.length-1].end;if(a>=b[0].start&&a<c)return!0}return!1};
shaka.media.QualityObserver.prototype.purgeQualityChangePositions_=function(a){var b=this.getBufferedInfo_()[a.contentType];if(b&&b.length>0){var c=b[0].start,d=b[b.length-1].end,e=a.qualityChangePositions;a.qualityChangePositions=e.filter(function(f,g){return f.position<=c&&g+1<e.length&&e[g+1].position<=c||f.position>=d?!1:!0})}else a.qualityChangePositions=[]};
shaka.media.QualityObserver.createQualityInfo=function(a){var b={bandwidth:a.bandwidth||0,audioSamplingRate:null,codecs:a.codecs,contentType:a.type,frameRate:null,height:null,mimeType:a.mimeType,channelsCount:null,pixelAspectRatio:null,width:null,label:null,roles:a.roles,language:null};a.type==shaka.util.ManifestParserUtils.ContentType.VIDEO&&(b.frameRate=a.frameRate||null,b.height=a.height||null,b.pixelAspectRatio=a.pixelAspectRatio||null,b.width=a.width||null);a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO&&
(b.audioSamplingRate=a.audioSamplingRate,b.channelsCount=a.channelsCount,b.label=a.label||null,b.language=a.language);return b};shaka.media.SegmentIndex=function(a){goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(a);this.references=a;this.timer_=null;this.numEvicted_=0;this.immutable_=!1};shaka.media.SegmentIndex.prototype.getIsImmutable=function(){return this.immutable_};shaka.media.SegmentIndex.prototype.getNumReferences=function(){return this.references.length};shaka.media.SegmentIndex.prototype.getNumEvicted=function(){return this.numEvicted_};
shaka.media.SegmentIndex.prototype.release=function(){this.immutable_||(this.references=[],this.timer_&&this.timer_.stop(),this.timer_=null)};shaka.media.SegmentIndex.prototype.markImmutable=function(){this.immutable_=!0};shaka.media.SegmentIndex.prototype.forEachTopLevelReference=function(a){for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())a(c.value)};shaka.media.SegmentIndex.prototype.earliestReference=function(){return this.references[0]||null};
shaka.media.SegmentIndex.prototype.dropFirstReferences=function(a){this.references.splice(0,a)};shaka.media.SegmentIndex.prototype.find=function(a){for(var b=this.references.length-1,c=b;c>=0;--c){var d=this.references[c],e=c<b?this.references[c+1].startTime:d.endTime;if(a>=d.startTime&&a<e)return c+this.numEvicted_}return this.references.length&&a<this.references[0].startTime?this.numEvicted_:null};
shaka.media.SegmentIndex.prototype.get=function(a){if(this.references.length==0)return null;a-=this.numEvicted_;return a<0||a>=this.references.length?null:this.references[a]};shaka.media.SegmentIndex.prototype.offset=function(a){if(!this.immutable_)for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())c.value.offset(a)};
shaka.media.SegmentIndex.prototype.merge=function(a){goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(a);if(!this.immutable_&&a.length){var b=Math.round(a[0].startTime*1E3)/1E3;this.references=this.references.filter(function(c){return Math.round(c.startTime*1E3)/1E3<b});this.references.push.apply(this.references,(0,$jscomp.arrayFromIterable)(a));goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(this.references)}};
shaka.media.SegmentIndex.prototype.mergeAndEvict=function(a,b){var c=this;a=a.filter(function(e){return e.endTime>b&&(c.references.length==0||e.endTime>c.references[0].startTime)});var d=this.references[0];this.merge(a);a=this.references[0];d&&goog.asserts.assert(d.startTime==a.startTime,"SegmentIndex.merge should not change the first reference time!");this.evict(b)};
shaka.media.SegmentIndex.prototype.evict=function(a){if(!this.immutable_){var b=this.references.length;this.references=this.references.filter(function(c){return c.endTime>a});this.numEvicted_+=b-this.references.length}};
shaka.media.SegmentIndex.prototype.fit=function(a,b,c){c=c===void 0?!1:c;goog.asserts.assert(b!=null,"Content duration must be known for static content!");goog.asserts.assert(b!=Infinity,"Content duration must be finite for static content!");if(!this.immutable_){for(;this.references.length;)if(this.references[this.references.length-1].startTime>=b)this.references.pop();else break;for(;this.references.length;)if(this.references[0].endTime<=a)this.references.shift(),c||this.numEvicted_++;else break;
this.references.length!=0&&(a=this.references[this.references.length-1],b=new shaka.media.SegmentReference(a.startTime,b,a.getUrisInner,a.startByte,a.endByte,a.initSegmentReference,a.timestampOffset,a.appendWindowStart,a.appendWindowEnd,a.partialReferences,a.tilesLayout,a.tileDuration,a.syncTime,a.status,a.aesKey),b.mimeType=a.mimeType,b.codecs=a.codecs,b.discontinuitySequence=a.discontinuitySequence,this.references[this.references.length-1]=b)}};
shaka.media.SegmentIndex.prototype.updateEvery=function(a,b){var c=this;goog.asserts.assert(!this.timer_,"SegmentIndex timer already started!");this.immutable_||(this.timer_&&this.timer_.stop(),this.timer_=new shaka.util.Timer(function(){var d=b();d?c.references.push.apply(c.references,(0,$jscomp.arrayFromIterable)(d)):(c.timer_.stop(),c.timer_=null)}),this.timer_.tickEvery(a))};
shaka.media.SegmentIndex.prototype[Symbol.iterator]=function(){var a=this.getIteratorForTime(0);goog.asserts.assert(a!=null,"Iterator for 0 should never be null!");return a};
shaka.media.SegmentIndex.prototype.getIteratorForTime=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?!1:c;var d=this.find(a);if(d==null)return null;var e=this.get(d);c?d++:d--;var f=-1;if(e&&e.hasPartialSegments())for(var g=e.partialReferences.length-1;g>=0;--g){var h=e.partialReferences[g];if(a>=h.startTime&&a<h.endTime){if(!b){for(;g&&!h.isIndependent();)g--,h=e.partialReferences[g];if(!h.isIndependent())return shaka.log.alwaysError("No independent partial segment found!"),null}c?d--:d++;f=g-1;
break}}return new shaka.media.SegmentIterator(this,d,f,c)};shaka.media.SegmentIndex.prototype.isEmpty=function(){return this.getNumReferences()==0};shaka.media.SegmentIndex.prototype.continuityTimeline=function(){return-1};shaka.media.SegmentIndex.forSingleSegment=function(a,b,c){a=new shaka.media.SegmentReference(a,a+b,function(){return c},0,null,null,a,a,a+b);return new shaka.media.SegmentIndex([a])};goog.exportSymbol("shaka.media.SegmentIndex",shaka.media.SegmentIndex);
goog.exportProperty(shaka.media.SegmentIndex,"forSingleSegment",shaka.media.SegmentIndex.forSingleSegment);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getIteratorForTime",shaka.media.SegmentIndex.prototype.getIteratorForTime);goog.exportProperty(shaka.media.SegmentIndex.prototype,"updateEvery",shaka.media.SegmentIndex.prototype.updateEvery);goog.exportProperty(shaka.media.SegmentIndex.prototype,"fit",shaka.media.SegmentIndex.prototype.fit);
goog.exportProperty(shaka.media.SegmentIndex.prototype,"evict",shaka.media.SegmentIndex.prototype.evict);goog.exportProperty(shaka.media.SegmentIndex.prototype,"mergeAndEvict",shaka.media.SegmentIndex.prototype.mergeAndEvict);goog.exportProperty(shaka.media.SegmentIndex.prototype,"offset",shaka.media.SegmentIndex.prototype.offset);goog.exportProperty(shaka.media.SegmentIndex.prototype,"get",shaka.media.SegmentIndex.prototype.get);goog.exportProperty(shaka.media.SegmentIndex.prototype,"find",shaka.media.SegmentIndex.prototype.find);
goog.exportProperty(shaka.media.SegmentIndex.prototype,"markImmutable",shaka.media.SegmentIndex.prototype.markImmutable);goog.exportProperty(shaka.media.SegmentIndex.prototype,"release",shaka.media.SegmentIndex.prototype.release);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getNumEvicted",shaka.media.SegmentIndex.prototype.getNumEvicted);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getNumReferences",shaka.media.SegmentIndex.prototype.getNumReferences);
goog.DEBUG&&(shaka.media.SegmentIndex.assertCorrectReferences_=function(a){goog.asserts.assert(a.every(function(b,c){if(c==0)return!0;c=a[c-1];return c.startTime<b.startTime?!0:c.startTime>b.startTime?!1:c.endTime<=b.endTime?!0:!1}),"SegmentReferences are incorrect")});shaka.media.SegmentIterator=function(a,b,c,d){this.segmentIndex_=a;this.currentPosition_=b;this.currentPartialPosition_=c;this.reverse=d};shaka.media.SegmentIterator.prototype.setReverse=function(a){this.reverse=a};
shaka.media.SegmentIterator.prototype.currentPosition=function(){return this.currentPosition_};
shaka.media.SegmentIterator.prototype.current=function(){var a=this.segmentIndex_.get(this.currentPosition_);a&&a.hasPartialSegments()&&a.hasAllPartialSegments()&&this.currentPartialPosition_>=a.partialReferences.length&&(this.currentPosition_++,this.currentPartialPosition_=0,a=this.segmentIndex_.get(this.currentPosition_));return a&&a.hasPartialSegments()?a.partialReferences[this.currentPartialPosition_]:a};
shaka.media.SegmentIterator.prototype.next=function(){var a=this.segmentIndex_.get(this.currentPosition_);this.reverse?a&&a.hasPartialSegments()?(this.currentPartialPosition_--,this.currentPartialPosition_<0&&(this.currentPosition_--,(a=this.segmentIndex_.get(this.currentPosition_))&&a.hasPartialSegments()?this.currentPartialPosition_=a.partialReferences.length-1:this.currentPartialPosition_=0)):(this.currentPosition_--,this.currentPartialPosition_=0):a&&a.hasPartialSegments()?(this.currentPartialPosition_++,
a.hasAllPartialSegments()&&this.currentPartialPosition_==a.partialReferences.length&&(this.currentPosition_++,this.currentPartialPosition_=0)):(this.currentPosition_++,this.currentPartialPosition_=0);a=this.current();return{value:a,done:!a}};
shaka.media.SegmentIterator.prototype.resetToLastIndependent=function(){var a=this.current();if(a&&a.isPartial()&&!a.isIndependent()&&(a=this.segmentIndex_.get(this.currentPosition_))&&a.hasPartialSegments())for(var b=a.partialReferences[this.currentPartialPosition_];b.isIndependent()&&!(this.currentPartialPosition_<=0);)this.currentPartialPosition_--,b=a.partialReferences[this.currentPartialPosition_]};goog.exportSymbol("shaka.media.SegmentIterator",shaka.media.SegmentIterator);
goog.exportProperty(shaka.media.SegmentIterator.prototype,"resetToLastIndependent",shaka.media.SegmentIterator.prototype.resetToLastIndependent);goog.exportProperty(shaka.media.SegmentIterator.prototype,"next",shaka.media.SegmentIterator.prototype.next);goog.exportProperty(shaka.media.SegmentIterator.prototype,"current",shaka.media.SegmentIterator.prototype.current);goog.exportProperty(shaka.media.SegmentIterator.prototype,"currentPosition",shaka.media.SegmentIterator.prototype.currentPosition);
goog.exportProperty(shaka.media.SegmentIterator.prototype,"setReverse",shaka.media.SegmentIterator.prototype.setReverse);shaka.media.MetaSegmentIndex=function(){shaka.media.SegmentIndex.call(this,[]);this.indexes_=[]};$jscomp.inherits(shaka.media.MetaSegmentIndex,shaka.media.SegmentIndex);shaka.media.MetaSegmentIndex.prototype.appendSegmentIndex=function(a){goog.asserts.assert(this.indexes_.length==0||a.getNumEvicted()==0,"Should not append a new segment index with already-evicted segments");this.indexes_.push(a)};
shaka.media.MetaSegmentIndex.prototype.clone=function(){var a=new shaka.media.MetaSegmentIndex;a.indexes_=this.indexes_.slice();a.numEvicted_=this.numEvicted_;return a};shaka.media.MetaSegmentIndex.prototype.release=function(){this.indexes_=[]};shaka.media.MetaSegmentIndex.prototype.forEachTopLevelReference=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())c.value.forEachTopLevelReference(a)};
shaka.media.MetaSegmentIndex.prototype.forEachIndex=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())a(c.value)};shaka.media.MetaSegmentIndex.prototype.find=function(a){for(var b=this.numEvicted_,c=(0,$jscomp.makeIterator)(this.indexes_),d=c.next();!d.done;d=c.next()){d=d.value;var e=d.find(a);if(e!=null)return e+b;b+=d.getNumEvicted()+d.getNumReferences()}return null};
shaka.media.MetaSegmentIndex.prototype.getTimelineForTime=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())if(c=c.value,c.find(a)!=null)return c.continuityTimeline();return-1};
shaka.media.MetaSegmentIndex.prototype.get=function(a){for(var b=this.numEvicted_,c=!1,d=(0,$jscomp.makeIterator)(this.indexes_),e=d.next();!e.done;e=d.next()){e=e.value;goog.asserts.assert(!c||e.getNumEvicted()==0,"Should not see evicted segments after available segments");var f=e.get(a-b);if(f)return f;f=e.getNumReferences();b+=e.getNumEvicted()+f;c=c||f!=0}return null};shaka.media.MetaSegmentIndex.prototype.offset=function(a){goog.asserts.assert(!1,"offset() should not be used in MetaSegmentIndex!")};
shaka.media.MetaSegmentIndex.prototype.merge=function(a){goog.asserts.assert(!1,"merge() should not be used in MetaSegmentIndex!")};shaka.media.MetaSegmentIndex.prototype.evict=function(a){if(this.indexes_.length){var b=this.indexes_[0];b.evict(a);b.isEmpty()&&(this.indexes_.shift(),this.numEvicted_+=b.getNumEvicted(),b.release(),this.evict(a))}};shaka.media.MetaSegmentIndex.prototype.mergeAndEvict=function(a,b){goog.asserts.assert(!1,"mergeAndEvict() should not be used in MetaSegmentIndex!")};
shaka.media.MetaSegmentIndex.prototype.fit=function(a,b){goog.asserts.assert(!1,"fit() should not be used in MetaSegmentIndex!")};shaka.media.MetaSegmentIndex.prototype.updateEvery=function(a,b){goog.asserts.assert(!1,"updateEvery() should not be used in MetaSegmentIndex!")};goog.exportSymbol("shaka.media.MetaSegmentIndex",shaka.media.MetaSegmentIndex);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"updateEvery",shaka.media.MetaSegmentIndex.prototype.updateEvery);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"fit",shaka.media.MetaSegmentIndex.prototype.fit);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"mergeAndEvict",shaka.media.MetaSegmentIndex.prototype.mergeAndEvict);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"evict",shaka.media.MetaSegmentIndex.prototype.evict);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"merge",shaka.media.MetaSegmentIndex.prototype.merge);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"offset",shaka.media.MetaSegmentIndex.prototype.offset);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"get",shaka.media.MetaSegmentIndex.prototype.get);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"find",shaka.media.MetaSegmentIndex.prototype.find);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"forEachTopLevelReference",shaka.media.MetaSegmentIndex.prototype.forEachTopLevelReference);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"release",shaka.media.MetaSegmentIndex.prototype.release);shaka.media.SegmentUtils=function(){};shaka.media.SegmentUtils.getBasicInfoFromMimeType=function(a){var b=shaka.util.MimeUtils.getBasicType(a),c=b.split("/")[0];a=shaka.util.MimeUtils.getCodecs(a);return{type:c,mimeType:b,codecs:a,language:null,height:null,width:null,channelCount:null,sampleRate:null,closedCaptions:new Map,videoRange:null,colorGamut:null,frameRate:null}};
shaka.media.SegmentUtils.getBasicInfoFromTs=function(a,b,c,d){var e=shaka.util.BufferUtils.toUint8(a),f=(new shaka.util.TsParser).parse(e),g=f.getCodecs();e=f.getVideoInfo();var h=[],k=!1,l=!1;if(!b)switch(g.audio){case "aac":case "aac-loas":f.getAudioData().length&&(h.push("mp4a.40.2"),k=!0);break;case "mp3":f.getAudioData().length&&(h.push("mp4a.40.34"),k=!0);break;case "ac3":f.getAudioData().length&&(h.push("ac-3"),k=!0);break;case "ec3":f.getAudioData().length&&(h.push("ec-3"),k=!0);break;case "opus":f.getAudioData().length&&
(h.push("opus"),k=!0)}if(!c)switch(g.video){case "avc":e.codec?h.push(e.codec):h.push("avc1.42E01E");l=!0;break;case "hvc":e.codec?h.push(e.codec):h.push("hvc1.1.6.L93.90");l=!0;break;case "av1":h.push("av01.0.01M.08"),l=!0}if(!h.length)return null;b=k&&!l;c=new Map;if(l&&!d){d=new shaka.media.ClosedCaptionParser("video/mp2t");d.parseFrom(a);a=(0,$jscomp.makeIterator)(d.getStreams());for(l=a.next();!l.done;l=a.next())l=l.value,c.set(l,l);d.reset()}return{type:b?"audio":"video",mimeType:"video/mp2t",
codecs:h.join(", "),language:null,height:e.height,width:e.width,channelCount:null,sampleRate:null,closedCaptions:c,videoRange:null,colorGamut:null,frameRate:e.frameRate}};
shaka.media.SegmentUtils.getBasicInfoFromMp4=function(a,b,c){var d=shaka.util.Mp4Parser,e=shaka.media.SegmentUtils,f=[],g=[],h=!1,k=!1,l=function(y){y=y.toLowerCase();switch(y){case "avc1":case "avc3":g.push(y+".42E01E");k=!0;break;case "hev1":case "hvc1":g.push(y+".1.6.L93.90");k=!0;break;case "dvh1":case "dvhe":g.push(y+".05.04");k=!0;break;case "vp09":g.push(y+".00.10.08");k=!0;break;case "av01":g.push(y+".0.01M.08");k=!0;break;case "mp4a":f.push("mp4a.40.2");h=!0;break;case "ac-3":case "ec-3":case "ac-4":case "opus":case "flac":f.push(y);
h=!0;break;case "apac":f.push("apac.31.00"),h=!0}},m=null,n=null,p=null,q=null,r=null,t=null,w=null,v,u=function(y){var A=shaka.util.Mp4BoxParsers.audioSampleEntry(y.reader);q=A.channelCount;r=A.sampleRate;l(y.name)},x=function(y){v=y.name;var A=shaka.util.Mp4BoxParsers.visualSampleEntry(y.reader);p=String(A.width);n=String(A.height);y.reader.hasMoreData()&&d.children(y)};(new d).box("moov",d.children).box("trak",d.children).box("mdia",d.children).fullBox("mdhd",function(y){goog.asserts.assert(y.version!=
null,"MDHD is a full box and should have a valid version.");m=shaka.util.Mp4BoxParsers.parseMDHD(y.reader,y.version).language}).box("minf",d.children).box("stbl",d.children).fullBox("stsd",d.sampleDescription).box("mp4a",function(y){var A=shaka.util.Mp4BoxParsers.audioSampleEntry(y.reader);q=A.channelCount;r=A.sampleRate;y.reader.hasMoreData()?d.children(y):l(y.name)}).box("esds",function(y){y=shaka.util.Mp4BoxParsers.parseESDS(y.reader);f.push(y.codec);h=!0}).box("ac-3",u).box("ec-3",u).box("ac-4",
u).box("Opus",u).box("fLaC",u).box("apac",u).box("avc1",x).box("avc3",x).box("hev1",x).box("hvc1",x).box("dva1",x).box("dvav",x).box("dvh1",x).box("dvhe",x).box("vp09",x).box("av01",x).box("avcC",function(y){var A=v||"";switch(v){case "dvav":A="avc3";break;case "dva1":A="avc1"}y=shaka.util.Mp4BoxParsers.parseAVCC(A,y.reader,y.name);g.push(y.codec);k=!0}).box("hvcC",function(y){var A=v||"";switch(v){case "dvh1":A="hvc1";break;case "dvhe":A="hev1"}y=shaka.util.Mp4BoxParsers.parseHVCC(A,y.reader,y.name);
g.push(y.codec);k=!0}).box("dvcC",function(y){var A=v||"";switch(v){case "hvc1":A="dvh1";break;case "hev1":A="dvhe";break;case "avc1":A="dva1";break;case "avc3":A="dvav";break;case "av01":A="dav1"}y=shaka.util.Mp4BoxParsers.parseDVCC(A,y.reader,y.name);g.push(y.codec);k=!0}).box("dvvC",function(y){var A=v||"";switch(v){case "hvc1":A="dvh1";break;case "hev1":A="dvhe";break;case "avc1":A="dva1";break;case "avc3":A="dvav";break;case "av01":A="dav1"}y=shaka.util.Mp4BoxParsers.parseDVVC(A,y.reader,y.name);
g.push(y.codec);k=!0}).fullBox("vpcC",function(y){y=shaka.util.Mp4BoxParsers.parseVPCC(v||"",y.reader,y.name);g.push(y.codec);k=!0}).box("av1C",function(y){var A=v||"";switch(v){case "dav1":A="av01"}y=shaka.util.Mp4BoxParsers.parseAV1C(A,y.reader,y.name);g.push(y.codec);k=!0}).box("enca",d.audioSampleEntry).box("encv",d.visualSampleEntry).box("sinf",d.children).box("frma",function(y){y=shaka.util.Mp4BoxParsers.parseFRMA(y.reader).codec;l(y)}).box("colr",function(y){g=g.map(function(E){return E.startsWith("av01.")?
shaka.util.Mp4BoxParsers.updateAV1CodecWithCOLRBox(E,y.reader):E});var A=shaka.util.Mp4BoxParsers.parseCOLR(y.reader),D=A.colorGamut;t=A.videoRange;w=D}).parse(a||b,!0,!0);if(!f.length&&!g.length)return null;u=h&&!k;x=new Map;if(k&&!c){c=new shaka.media.ClosedCaptionParser("video/mp4");a&&c.init(a);try{c.parseFrom(b);for(var z=(0,$jscomp.makeIterator)(c.getStreams()),B=z.next();!B.done;B=z.next()){var C=B.value;x.set(C,C)}}catch(y){shaka.log.debug("Error detecting CC streams",y)}c.reset()}a=f.concat(g);
return{type:u?"audio":"video",mimeType:u?"audio/mp4":"video/mp4",codecs:e.codecsFiltering(a).join(", "),language:m,height:n,width:p,channelCount:q,sampleRate:r,closedCaptions:x,videoRange:t,colorGamut:w,frameRate:null}};
shaka.media.SegmentUtils.codecsFiltering=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c=shaka.util.ManifestParserUtils,d=shaka.media.SegmentUtils;a=d.filterDuplicateCodecs_(a);var e=c.guessAllCodecsSafe(b.AUDIO,a),f=c.guessAllCodecsSafe(b.VIDEO,a);b=c.guessAllCodecsSafe(b.TEXT,a);d=d.chooseBetterCodecs_(f);d=e.concat(d).concat(b);return a.length&&!d.length?a:d};
shaka.media.SegmentUtils.filterDuplicateCodecs_=function(a){var b=new Set,c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;var e=shaka.util.MimeUtils.getCodecBase(d);b.has(e)?shaka.log.debug("Ignoring duplicate codec"):(c.push(d),b.add(e))}return c};
shaka.media.SegmentUtils.chooseBetterCodecs_=function(a){if(a.length<=1)return a;var b=a.find(function(c){return c.startsWith("dvav.")||c.startsWith("dva1.")||c.startsWith("dvh1.")||c.startsWith("dvhe.")||c.startsWith("dav1.")||c.startsWith("dvc1.")||c.startsWith("dvi1.")});return b?shaka.media.Capabilities.isTypeSupported('video/mp4; codecs="'+b+'"')?[b]:a.filter(function(c){return c!=b}):a};
shaka.media.SegmentUtils.getDefaultKID=function(a){var b=shaka.util.Mp4Parser,c=null;(new b).box("moov",b.children).box("trak",b.children).box("mdia",b.children).box("minf",b.children).box("stbl",b.children).fullBox("stsd",b.sampleDescription).box("encv",b.visualSampleEntry).box("enca",b.audioSampleEntry).box("sinf",b.children).box("schi",b.children).fullBox("tenc",function(d){c=shaka.util.Mp4BoxParsers.parseTENC(d.reader).defaultKID}).parse(a,!0);return c};
shaka.media.SegmentUtils.aesDecrypt=function(a,b,c){var d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.nextAddress==1){d=b;if(d.cryptoKey)return k.jumpTo(2);goog.asserts.assert(d.fetchKey,"If AES cryptoKey was not preloaded, fetchKey function should be provided");return k.yield(d.fetchKey(),3)}k.nextAddress!=2&&goog.asserts.assert(d.cryptoKey,"AES cryptoKey should now be set");e=d.iv;if(!e)for(e=shaka.util.BufferUtils.toUint8(new ArrayBuffer(16)),f=d.firstMediaSequenceNumber+
c,g=e.byteLength-1;g>=0;g--)e[g]=f&255,f>>=8;h=b.blockCipherMode=="CBC"?{name:"AES-CBC",iv:e}:{name:"AES-CTR",counter:e,length:64};return k.return(window.crypto.subtle.decrypt(h,d.cryptoKey,a))})};shaka.net.DataUriPlugin=function(){};shaka.net.DataUriPlugin.parse=function(a,b,c,d){try{var e=shaka.net.DataUriPlugin.parseRaw(a);return shaka.util.AbortableOperation.completed({uri:a,originalUri:a,data:e.data,headers:{"content-type":e.contentType},originalRequest:b})}catch(f){return shaka.util.AbortableOperation.failed(f)}};
shaka.net.DataUriPlugin.parseRaw=function(a){var b=a.split(":");if(b.length<2||b[0]!="data")throw shaka.log.error("Bad data URI, failed to parse scheme"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.MALFORMED_DATA_URI,a);b=b.slice(1).join(":").split(",");if(b.length<2)throw shaka.log.error("Bad data URI, failed to extract encoding and MIME type"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.MALFORMED_DATA_URI,a);var c=b[0];a=window.decodeURIComponent(b.slice(1).join(","));b=c.split(";");c=b[0];var d=!1;b.length>1&&b[b.length-1]=="base64"&&(d=!0,b.pop());return{data:d?shaka.util.Uint8ArrayUtils.fromBase64(a):shaka.util.StringUtils.toUTF8(a),contentType:c}};goog.exportSymbol("shaka.net.DataUriPlugin",shaka.net.DataUriPlugin);goog.exportProperty(shaka.net.DataUriPlugin,"parse",shaka.net.DataUriPlugin.parse);shaka.net.NetworkingEngine.registerScheme("data",shaka.net.DataUriPlugin.parse);shaka.net.NetworkingUtils=function(){};
shaka.net.NetworkingUtils.getMimeType=function(a,b,c){var d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.nextAddress){case 1:d=shaka.net.NetworkingUtils.getExtension(a);if(e=shaka.net.NetworkingUtils.EXTENSIONS_TO_MIME_TYPES_.get(d))return m.return(e);f=shaka.net.NetworkingEngine.RequestType.MANIFEST;g=shaka.net.NetworkingEngine.makeRequest([a],c);m.setCatchFinallyBlocks(2);g.method="HEAD";return m.yield(b.request(f,g).promise,4);case 4:h=m.yieldResult;e=
h.headers["content-type"];m.leaveTryBlock(3);break;case 2:k=m.enterCatchBlock();if(!k||k.code!=shaka.util.Error.Code.HTTP_ERROR&&k.code!=shaka.util.Error.Code.BAD_HTTP_STATUS){m.jumpTo(3);break}g.method="GET";return m.yield(b.request(f,g).promise,6);case 6:l=m.yieldResult,e=l.headers["content-type"];case 3:return m.return(e?e.toLowerCase().split(";").shift():"")}})};shaka.net.NetworkingUtils.getExtension=function(a){a=(new goog.Uri(a)).getPath().split("/").pop().split(".");return a.length==1?"":a.pop().toLowerCase()};
shaka.net.NetworkingUtils.EXTENSIONS_TO_MIME_TYPES_=(new Map).set("mp4","video/mp4").set("m4v","video/mp4").set("m4a","audio/mp4").set("webm","video/webm").set("weba","audio/webm").set("mkv","video/webm").set("ts","video/mp2t").set("ogv","video/ogg").set("ogg","audio/ogg").set("mpg","video/mpeg").set("mpeg","video/mpeg").set("mov","video/quicktime").set("m3u8","application/x-mpegurl").set("mpd","application/dash+xml").set("ism","application/vnd.ms-sstr+xml").set("mp3","audio/mpeg").set("aac","audio/aac").set("flac",
"audio/flac").set("wav","audio/wav").set("sbv","text/x-subviewer").set("srt","text/srt").set("vtt","text/vtt").set("webvtt","text/vtt").set("ttml","application/ttml+xml").set("lrc","application/x-subtitle-lrc").set("ssa","text/x-ssa").set("ass","text/x-ssa").set("jpeg","image/jpeg").set("jpg","image/jpeg").set("png","image/png").set("svg","image/svg+xml").set("webp","image/webp").set("avif","image/avif").set("html","text/html").set("htm","text/html");shaka.util.ContentSteeringManager=function(a){this.config_=null;this.playerInterface_=a;this.operationManager_=new shaka.util.OperationManager;this.baseUris_=[];this.defaultPathwayId_=null;this.pathwayPriority_=[];this.lastPathwayUsed_=null;this.pathwayClones_=[];this.lastTTL_=300;this.locations_=new Map;this.bannedLocations_=new Map;this.updateTimer_=null;this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.util.ContentSteeringManager.prototype.configure=function(a){this.config_=a};
shaka.util.ContentSteeringManager.prototype.destroy=function(){this.playerInterface_=this.config_=null;this.baseUris_=[];this.defaultPathwayId_=null;this.pathwayPriority_=[];this.pathwayClones_=[];this.locations_.clear();this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);return this.operationManager_.destroy()};shaka.util.ContentSteeringManager.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.util.ContentSteeringManager.prototype.setBaseUris=function(a){this.baseUris_=a};shaka.util.ContentSteeringManager.prototype.setDefaultPathwayId=function(a){this.defaultPathwayId_=a};
shaka.util.ContentSteeringManager.prototype.requestInfo=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1)return c=shaka.util.ManifestParserUtils.resolveUris(b.baseUris_,[b.addQueryParams_(a)]),d=shaka.net.NetworkingEngine.RequestType.CONTENT_STEERING,e=shaka.net.NetworkingEngine.makeRequest(c,b.config_.retryParameters),f=b.playerInterface_.networkingEngine.request(d,e),b.operationManager_.manage(f),m.setCatchFinallyBlocks(2),
m.yield(f.promise,4);if(m.nextAddress!=2)return g=m.yieldResult,h=shaka.util.StringUtils.fromUTF8(g.data),k=JSON.parse(h),k.VERSION==1&&b.processManifest_(k,g.uri),m.leaveTryBlock(0);if((l=m.enterCatchBlock())&&l.code==shaka.util.Error.Code.OPERATION_ABORTED)return m.return();b.updateTimer_!=null&&(b.updateTimer_.stop(),b.updateTimer_=null);b.updateTimer_=new shaka.util.Timer(function(){b.requestInfo(a)});b.updateTimer_.tickAfter(b.lastTTL_);m.jumpToEnd()})};
shaka.util.ContentSteeringManager.prototype.addQueryParams_=function(a){if(!this.pathwayPriority_.length)return a;a=new goog.Uri(a);var b=this.lastPathwayUsed_||this.pathwayPriority_[0],c=Math.round(this.playerInterface_.getBandwidthEstimate()),d=a.getQueryData();this.manifestType_==shaka.media.ManifestParser.DASH?(d.add("_DASH_pathway",b),d.add("_DASH_throughput",String(c))):this.manifestType_==shaka.media.ManifestParser.HLS&&(d.add("_HLS_pathway",b),d.add("_HLS_throughput",String(c)));d.getCount()&&
a.setQueryData(d);return a.toString()};shaka.util.ContentSteeringManager.prototype.processManifest_=function(a,b){var c=this;this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);var d=a["RELOAD-URI"]||b;this.updateTimer_=new shaka.util.Timer(function(){c.requestInfo(d)});if(b=a.TTL)this.lastTTL_=b;this.updateTimer_.tickAfter(this.lastTTL_);this.pathwayPriority_=a["PATHWAY-PRIORITY"]||[];this.pathwayClones_=a["PATHWAY-CLONES"]||[]};
shaka.util.ContentSteeringManager.prototype.clearPreviousLocations=function(){this.locations_.clear()};shaka.util.ContentSteeringManager.prototype.addLocation=function(a,b,c){var d=this.locations_.get(a);d||(d=new Map);d.set(b,c);this.locations_.set(a,d)};shaka.util.ContentSteeringManager.prototype.banLocation=function(a){var b=Date.now()+6E4;this.bannedLocations_.set(a,b)};
shaka.util.ContentSteeringManager.prototype.getLocations=function(a,b){var c=this;b=b===void 0?!1:b;a=this.locations_.get(a)||new Map;for(var d=[],e=(0,$jscomp.makeIterator)(this.pathwayPriority_),f=e.next(),g={};!f.done;g={pathwayId$jscomp$1:void 0},f=e.next())if(g.pathwayId$jscomp$1=f.value,f=a.get(g.pathwayId$jscomp$1))d.push({pathwayId:g.pathwayId$jscomp$1,location:f});else if(f=this.pathwayClones_.find(function(k){return function(l){return l.ID==k.pathwayId$jscomp$1}}(g))){var h=a.get(f["BASE-ID"]);
h&&(f["URI-REPLACEMENT"].HOST?(h=new goog.Uri(h),h.setDomain(f["URI-REPLACEMENT"].HOST),d.push({pathwayId:g.pathwayId$jscomp$1,location:h.toString()})):d.push({pathwayId:g.pathwayId$jscomp$1,location:h}))}e=Date.now();g=(0,$jscomp.makeIterator)(this.bannedLocations_.keys());for(f=g.next();!f.done;f=g.next())f=f.value,h=this.bannedLocations_.get(f),e>h&&this.bannedLocations_.delete(f);d=d.filter(function(k){for(var l=(0,$jscomp.makeIterator)(c.bannedLocations_.keys()),m=l.next();!m.done;m=l.next())if(m.value.includes((new goog.Uri(k.location)).getDomain()))return!1;
return!0});d.length&&(this.lastPathwayUsed_=d[0].pathwayId);d=d.map(function(k){return k.location});if(!d.length&&this.defaultPathwayId_)for(e=(0,$jscomp.makeIterator)(this.defaultPathwayId_.split(",")),g=e.next();!g.done;g=e.next())if(g=a.get(g.value))this.lastPathwayUsed_=this.defaultPathwayId_,d.push(g);if(!d.length)for(a=(0,$jscomp.makeIterator)(a.values()),e=a.next();!e.done;e=a.next())d.push(e.value);return b?d:shaka.util.ManifestParserUtils.resolveUris(this.baseUris_,d)};shaka.util.Networking=function(){};shaka.util.Networking.createSegmentRequest=function(a,b,c,d,e){a=shaka.net.NetworkingEngine.makeRequest(a,d,e);if(b!=0||c!=null)a.headers.Range=c?"bytes="+b+"-"+c:"bytes="+b+"-";return a};shaka.hls.HlsParser=function(){var a=this;this.config_=this.playerInterface_=null;this.globalId_=1;this.globalVariables_=new Map;this.groupIdToStreamInfosMap_=new Map;this.mediaSequenceToStartTimeByType_=new Map;var b=shaka.util.ManifestParserUtils.ContentType;this.mediaSequenceToStartTimeByType_.set(b.VIDEO,new Map);this.mediaSequenceToStartTimeByType_.set(b.AUDIO,new Map);this.mediaSequenceToStartTimeByType_.set(b.TEXT,new Map);this.mediaSequenceToStartTimeByType_.set(b.IMAGE,new Map);this.keyFormatsToDrmParsers_=
(new Map).set("com.apple.streamingkeydelivery",function(c,d,e){return a.fairplayDrmParser_(c,d,e)}).set("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",function(c,d,e){return a.widevineDrmParser_(c,d,e)}).set("com.microsoft.playready",function(c,d,e){return a.playreadyDrmParser_(c,d,e)}).set("urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c",function(c,d,e){return a.wiseplayDrmParser_(c,d,e)});this.variantUriSet_=new Set;this.uriToStreamInfosMap_=new Map;this.presentationTimeline_=null;this.masterPlaylistUri_=
"";this.manifestTextParser_=new shaka.hls.ManifestTextParser;this.minSequenceNumber_=-1;this.lowestSyncTime_=Infinity;this.codecInfoInManifest_=this.streamsFinalized_=this.usesProgramDateTime_=!1;this.updatePlaylistTimer_=new shaka.util.Timer(function(){if(a.mediaElement_&&!a.config_.continueLoadingWhenPaused&&(a.eventManager_.unlisten(a.mediaElement_,"timeupdate"),a.mediaElement_.paused)){a.eventManager_.listenOnce(a.mediaElement_,"timeupdate",function(){return a.onUpdate_()});return}a.onUpdate_()});
this.presentationType_=shaka.hls.HlsParser.PresentationType_.VOD;this.manifest_=null;this.maxTargetDuration_=0;this.lastTargetDuration_=Infinity;this.lowLatencyPresentationDelay_=this.presentationDelay_=this.partialTargetDuration_=0;this.operationManager_=new shaka.util.OperationManager;this.groupIdToClosedCaptionsMap_=new Map;this.groupIdToCodecsMap_=new Map;this.mapTagToInitSegmentRefMap_=new Map;this.aesKeyInfoMap_=new Map;this.aesKeyMap_=new Map;this.identityKeyMap_=new Map;this.initSegmentToKidMap_=
new Map;this.lowLatencyByterangeOptimization_=this.lowLatencyMode_=!1;this.averageUpdateDuration_=new shaka.abr.Ewma(5);this.contentSteeringManager_=null;this.needsClosedCaptionsDetection_=!0;this.eventManager_=new shaka.util.EventManager;this.startTime_=this.mediaElement_=null;this.isPreloadFn_=function(){return!1};this.psshToInitData_=new Map};
shaka.hls.HlsParser.prototype.configure=function(a,b){var c=this.playerInterface_&&a.updatePeriod!=this.config_.updatePeriod&&a.updatePeriod>=0;this.config_=a;b&&(this.isPreloadFn_=b);this.contentSteeringManager_&&this.contentSteeringManager_.configure(this.config_);c&&this.manifest_&&this.manifest_.presentationTimeline.isLive()&&this.updatePlaylistTimer_.tickNow()};
shaka.hls.HlsParser.prototype.start=function(a,b){var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1)return goog.asserts.assert(c.config_,"Must call configure() before start()!"),c.playerInterface_=b,c.lowLatencyMode_=b.isLowLatencyMode(),e.yield(c.requestManifest_([a]).promise,2);if(e.nextAddress!=3)return d=e.yieldResult,c.masterPlaylistUri_=d.uri,goog.asserts.assert(d.data,"Response data should be non-null!"),e.yield(c.parseManifest_(d.data),3);goog.asserts.assert(c.manifest_,
"Manifest should be non-null");return e.return(c.manifest_)})};
shaka.hls.HlsParser.prototype.stop=function(){this.updatePlaylistTimer_&&(this.updatePlaylistTimer_.stop(),this.updatePlaylistTimer_=null);var a=[];this.operationManager_&&(a.push(this.operationManager_.destroy()),this.operationManager_=null);this.config_=this.playerInterface_=null;this.variantUriSet_.clear();this.manifest_=null;this.uriToStreamInfosMap_.clear();this.groupIdToStreamInfosMap_.clear();this.groupIdToCodecsMap_.clear();this.globalVariables_.clear();this.mapTagToInitSegmentRefMap_.clear();
this.aesKeyInfoMap_.clear();this.aesKeyMap_.clear();this.identityKeyMap_.clear();this.initSegmentToKidMap_.clear();this.psshToInitData_.clear();this.contentSteeringManager_&&this.contentSteeringManager_.destroy();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);return Promise.all(a)};
shaka.hls.HlsParser.prototype.update=function(){var a=this,b,c,d,e,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.nextAddress==1){if(!a.isLive_())return n.return();b=[];c=Array.from(a.uriToStreamInfosMap_.values());a.lastTargetDuration_=Infinity;a.manifest_.gapCount=0;d=c.filter(function(p){return p.stream.segmentIndex});e=(0,$jscomp.makeIterator)(d);for(f=e.next();!f.done;f=e.next())g=f.value,b.push(a.updateStream_(g));return n.yield(Promise.all(b),2)}a.notifySegmentsForStreams_(d.map(function(p){return p.stream}));
h=d.some(function(p){return p.hasEndList==0});d.length&&!h&&a.setPresentationType_(shaka.hls.HlsParser.PresentationType_.VOD);h&&a.determineDuration_();k=(0,$jscomp.makeIterator)(d);for(l=k.next();!l.done;l=k.next())m=l.value,m.stream.isAudioMuxedInVideo||!m.stream.segmentIndex||m.stream.segmentIndex.earliestReference()||a.playerInterface_.disableStream(m.stream);n.jumpToEnd()})};
shaka.hls.HlsParser.prototype.getMediaSequenceToStartTimeFor_=function(a){return this.isLive_()?this.mediaSequenceToStartTimeByType_.get(a.type):a.mediaSequenceToStartTime};
shaka.hls.HlsParser.prototype.updateStream_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O,N;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(S){switch(S.nextAddress){case 1:if(a.stream.isAudioMuxedInVideo)return S.return();c=[];d=(0,$jscomp.makeIterator)(a.getUris());for(e=d.next();!e.done;e=d.next())f=e.value,g=new goog.Uri(f),h=g.getQueryData(),a.canBlockReload&&(a.nextMediaSequence>=0&&h.add("_HLS_msn",String(a.nextMediaSequence)),
a.nextPart>=0&&h.add("_HLS_part",String(a.nextPart))),a.canSkipSegments&&h.add("_HLS_skip","YES"),h.getCount()&&g.setQueryData(h.toDecodedString()),c.push(g.toString());S.setCatchFinallyBlocks(2);return S.yield(b.requestManifest_(c,!0).promise,4);case 4:k=S.yieldResult;S.leaveTryBlock(3);break;case 2:throw l=S.enterCatchBlock(),b.playerInterface_&&b.playerInterface_.disableStream(a.stream),l;case 3:if(!a.stream.segmentIndex)return S.return();m=b.manifestTextParser_.parsePlaylist(k.data);if(m.type!=
shaka.hls.PlaylistType.MEDIA)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_INVALID_PLAYLIST_HIERARCHY);n=k.uri;n==k.originalUri||a.getUris().includes(n)||a.redirectUris.push(n);p=shaka.hls.Utils.filterTagsByName(m.tags,"EXT-X-DEFINE");q=b.parseMediaVariables_(p,n);r=a.stream;t=b.getMediaSequenceToStartTimeFor_(a);return S.yield(b.parseDrmInfo_(m,r.mimeType,a.getUris,q),5);case 5:w=S.yieldResult;v=w.keyIds;u=w.drmInfos;x=
w.encrypted;z=w.aesEncrypted;r.encrypted||!x||z||(r.encrypted=!0);B=function(aa,R){return aa.size===R.size&&[].concat((0,$jscomp.arrayFromIterable)(aa)).every(function(W){return R.has(W)})};B(r.keyIds,v)||(r.keyIds=v,r.drmInfos=u,b.playerInterface_.newDrmInfo(r));C=b.createSegments_(m,t,q,a.getUris,a.type);y=C.segments;if(A=C.bandwidth)r.bandwidth=A;D=shaka.media.QualityObserver.createQualityInfo(r);E=(0,$jscomp.makeIterator)(y);for(F=E.next();!F.done;F=E.next())L=F.value,L.initSegmentReference&&
(L.initSegmentReference.mediaQuality=D);r.segmentIndex.mergeAndEvict(y,b.presentationTimeline_.getSegmentAvailabilityStart());y.length&&(K=shaka.hls.Utils.getFirstTagWithNameAsNumber(m.tags,"EXT-X-MEDIA-SEQUENCE",0),I=(J=shaka.hls.Utils.getFirstTagWithName(m.tags,"EXT-X-SKIP"))?Number(J.getAttributeValue("SKIPPED-SEGMENTS")):0,G=b.getNextMediaSequenceAndPart_(K,y),M=G.nextMediaSequence,H=G.nextPart,a.nextMediaSequence=M+I,a.nextPart=H,P=t.get(K),r.segmentIndex.evict(P));if(Q=r.segmentIndex.earliestReference())a.minTimestamp=
Q.startTime,O=y[y.length-1],goog.asserts.assert(O,"Should have segments!"),a.maxTimestamp=O.endTime;if(N=shaka.hls.Utils.getFirstTagWithName(m.tags,"EXT-X-ENDLIST"))a.hasEndList=!0;b.determineLastTargetDuration_(m);b.processDateRangeTags_(m.tags,r.type,q,a.getUris);S.jumpToEnd()}})};shaka.hls.HlsParser.prototype.onExpirationUpdated=function(a,b){};shaka.hls.HlsParser.prototype.onInitialVariantChosen=function(a){};
shaka.hls.HlsParser.prototype.banLocation=function(a){this.contentSteeringManager_&&this.contentSteeringManager_.banLocation(a)};shaka.hls.HlsParser.prototype.setMediaElement=function(a){this.mediaElement_=a};
shaka.hls.HlsParser.prototype.syncStreamsWithSequenceNumber_=function(a,b){b=b===void 0?!1:b;for(var c=this.minSequenceNumber_==-1,d=(0,$jscomp.makeIterator)(a),e=d.next();!e.done;e=d.next()){e=e.value;var f=e.stream.segmentIndex;goog.asserts.assert(f,"Only loaded streams should be synced");var g=this.getMediaSequenceToStartTimeFor_(e);if(f=f.earliestReference()){goog.DEBUG&&g.values().next().value!=f.startTime&&shaka.log.warning("Sequence number map is not ordered as expected!");g=(0,$jscomp.makeIterator)(g);
for(var h=g.next();!h.done;h=g.next()){h=(0,$jscomp.makeIterator)(h.value);var k=h.next().value;if(h.next().value==f.startTime){c&&(this.minSequenceNumber_=Math.max(this.minSequenceNumber_,k));e.firstSequenceNumber=k;break}}}}if(!(this.minSequenceNumber_<0))for(shaka.log.debug("Syncing HLS streams against base sequence number:",this.minSequenceNumber_),a=(0,$jscomp.makeIterator)(a),c=a.next();!c.done;c=a.next())if(c=c.value,this.ignoreManifestProgramDateTimeFor_(c.type)||b)if(d=c.stream.segmentIndex)if(e=
this.minSequenceNumber_-c.firstSequenceNumber,e>0&&(d.dropFirstReferences(e),d=d.earliestReference()))d=-d.startTime,c.stream.segmentIndex.offset(d),this.offsetStreamInfo_(c,d)};
shaka.hls.HlsParser.prototype.syncStreamsWithProgramDateTime_=function(a){if(this.lowestSyncTime_==Infinity){a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())b=b.value.stream.segmentIndex,goog.asserts.assert(b,"Only loaded streams should be synced"),b=b.earliestReference(),b!=null&&b.syncTime!=null&&(this.lowestSyncTime_=Math.min(this.lowestSyncTime_,b.syncTime))}a=this.lowestSyncTime_;if(a!=Infinity){shaka.log.debug("Syncing HLS streams against base time:",a);b=(0,$jscomp.makeIterator)(this.uriToStreamInfosMap_.values());
for(var c=b.next();!c.done;c=b.next())if(c=c.value,!this.ignoreManifestProgramDateTimeFor_(c.type)){var d=c.stream.segmentIndex;if(d!=null){var e=d.earliestReference();if(e)if(e.syncTime==null)shaka.log.alwaysError("Missing EXT-X-PROGRAM-DATE-TIME for stream",c.getUris(),"Expect AV sync issues!");else for(this.offsetStreamInfo_(c,e.syncTime-a-e.startTime),c=(0,$jscomp.makeIterator)(d),d=c.next();!d.done;d=c.next())d.value.syncAgainst(a)}}}};
shaka.hls.HlsParser.prototype.offsetStreamInfo_=function(a,b){if(!(Math.abs(b)<.001)){a.minTimestamp+=b;a.maxTimestamp+=b;goog.asserts.assert(a.maxTimestamp>=0,"Negative maxTimestamp after adjustment!");for(var c=this.getMediaSequenceToStartTimeFor_(a),d=(0,$jscomp.makeIterator)(c),e=d.next();!e.done;e=d.next()){var f=(0,$jscomp.makeIterator)(e.value);e=f.next().value;f=f.next().value;c.set(e,f+b)}shaka.log.debug("Offset",b,"applied to",a.getUris())}};
shaka.hls.HlsParser.prototype.parseManifest_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O,N,S,aa,R,W,ba,V,X;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Y){switch(Y.nextAddress){case 1:c=shaka.hls.Utils;d=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(b.masterPlaylistUri_,"Master playlist URI must be set before calling parseManifest_!");e=b.manifestTextParser_.parsePlaylist(a);f=c.filterTagsByName(e.tags,"EXT-X-DEFINE");
g=[];h=[];k=[];goog.asserts.assert(b.presentationTimeline_==null,"Presentation timeline created early!");b.presentationTimeline_=new shaka.media.PresentationTimeline(null,0);b.presentationTimeline_.setStatic(!0);l=function(){return[b.masterPlaylistUri_]};m=null;n=new Map;if(e.type==shaka.hls.PlaylistType.MEDIA)return b.needsClosedCaptionsDetection_=!1,H=shaka.hls.Utils.filterTagsByName(e.tags,"EXT-X-DEFINE"),n=b.parseMediaVariables_(H,b.masterPlaylistUri_),m=d.VIDEO,P="",Q=new Map,Y.yield(b.convertParsedPlaylistIntoStreamInfo_(b.globalId_++,
n,e,l,"",m,P,!0,"Media Playlist",null,Q,null,!1,null,!1),7);b.parseMasterVariables_(f);p=c.filterTagsByName(e.tags,"EXT-X-MEDIA");q=c.filterTagsByName(e.tags,"EXT-X-STREAM-INF");r=c.filterTagsByName(e.tags,"EXT-X-IMAGE-STREAM-INF");t=c.filterTagsByName(e.tags,"EXT-X-I-FRAME-STREAM-INF");w=c.filterTagsByName(e.tags,"EXT-X-SESSION-KEY");v=c.filterTagsByName(e.tags,"EXT-X-SESSION-DATA");u=c.filterTagsByName(e.tags,"EXT-X-CONTENT-STEERING");b.processSessionData_(v);return Y.yield(b.processContentSteering_(u),
4);case 4:if(!b.config_.ignoreSupplementalCodecs){x=[];z=(0,$jscomp.makeIterator)(q);B=z.next();for(C={};!B.done;C={supplementalCodecs:void 0},B=z.next())if(y=B.value,A=y.getAttributeValue("SUPPLEMENTAL-CODECS"))C.supplementalCodecs=A.split(/\s*,\s*/).map(function(Z){return Z.split("/")[0]}),D=y.attributes.map(function(Z){return function(U){var T=U.name,ca=U.value;T=="CODECS"&&(ca=Z.supplementalCodecs.join(","),U=U.value.split(","),U.length>1&&(U=shaka.util.ManifestParserUtils.guessCodecsSafe(shaka.util.ManifestParserUtils.ContentType.AUDIO,
U))&&(ca+=","+U));return new shaka.hls.Attribute(T,ca)}}(C)),x.push(new shaka.hls.Tag(y.id,y.name,D,null));q.push.apply(q,(0,$jscomp.arrayFromIterable)(x));E=[];F=(0,$jscomp.makeIterator)(t);L=F.next();for(K={};!L.done;K={supplementalCodecs$jscomp$1:void 0},L=F.next())if(J=L.value,I=J.getAttributeValue("SUPPLEMENTAL-CODECS"))K.supplementalCodecs$jscomp$1=I.split(/\s*,\s*/).map(function(Z){return Z.split("/")[0]}),G=J.attributes.map(function(Z){return function(U){var T=U.name;U=U.value;T=="CODECS"&&
(U=Z.supplementalCodecs$jscomp$1.join(","));return new shaka.hls.Attribute(T,U)}}(K)),E.push(new shaka.hls.Tag(J.id,J.name,G,null));t.push.apply(t,(0,$jscomp.arrayFromIterable)(E))}b.parseCodecs_(q);b.parseClosedCaptions_(p);M=b.parseIFrames_(t);return Y.yield(b.createVariantsForTags_(q,w,p,l,b.globalVariables_,M),5);case 5:return g=Y.yieldResult,h=b.parseTexts_(p),Y.yield(b.parseImages_(r,t),6);case 6:k=Y.yieldResult;Y.jumpTo(3);break;case 7:O=Y.yieldResult,b.uriToStreamInfosMap_.set(b.masterPlaylistUri_,
O),O.stream&&(N=shaka.media.QualityObserver.createQualityInfo(O.stream),O.stream.segmentIndex.forEachTopLevelReference(function(Z){Z.initSegmentReference&&(Z.initSegmentReference.mediaQuality=N)})),m=O.stream.type,S=!0,b.config_.disableAudio&&O.type=="audio"?S=!1:b.config_.disableVideo&&O.type=="video"&&!O.stream.codecs.includes(",")&&(S=!1),S&&g.push({id:0,language:b.getLanguage_(P),disabledUntilTime:0,primary:!0,audio:O.type=="audio"?O.stream:null,video:O.type=="video"?O.stream:null,bandwidth:O.stream.bandwidth||
0,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]});case 3:if(!b.playerInterface_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED);b.determineStartTime_(e);e.type==shaka.hls.PlaylistType.MEDIA&&(b.isLive_()&&(b.changePresentationTimelineToLive_(e),aa=b.getUpdatePlaylistDelay_(),b.updatePlaylistTimer_.tickAfter(aa)),R=Array.from(b.uriToStreamInfosMap_.values()),b.finalizeStreams_(R),b.determineDuration_(),
goog.asserts.assert(m,"mediaPlaylistType should be non-null"),b.processDateRangeTags_(e.tags,m,n,l));b.manifest_={presentationTimeline:b.presentationTimeline_,variants:g,textStreams:h,imageStreams:k,offlineSessionIds:[],sequenceMode:b.config_.hls.sequenceMode,ignoreManifestTimestampsInSegmentsMode:b.config_.hls.ignoreManifestTimestampsInSegmentsMode,type:shaka.media.ManifestParser.HLS,serviceDescription:null,nextUrl:null,periodCount:1,gapCount:0,isLowLatency:!1,startTime:b.startTime_};if(b.codecInfoInManifest_||
!b.config_.hls.disableCodecGuessing){Y.jumpTo(8);break}W=[];ba=(0,$jscomp.makeIterator)(b.manifest_.variants);for(V=ba.next();!V.done;V=ba.next())X=V.value,X.audio&&X.audio.codecs===""&&W.push(X.audio.createSegmentIndex()),X.video&&X.video.codecs===""&&W.push(X.video.createSegmentIndex());return Y.yield(Promise.all(W),8);case 8:b.playerInterface_.makeTextStreamsForClosedCaptions(b.manifest_),Y.jumpToEnd()}})};
shaka.hls.HlsParser.prototype.getBasicInfoFromSegments_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){if(u.nextAddress==1){c=shaka.media.SegmentUtils.getBasicInfoFromMimeType(b.config_.hls.mediaPlaylistFullMimeType);if(!a.length)return u.return(c);d=b.getAvailableSegment_(a);e=d.segment;f=d.segmentIndex;g=e.getUris();if(h=shaka.net.NetworkingUtils.getExtension(g[0]))if(k=shaka.hls.HlsParser.RAW_FORMATS_TO_MIME_TYPES_.get(h))return u.return(shaka.media.SegmentUtils.getBasicInfoFromMimeType(k));
return u.yield(Promise.all([b.getInfoFromSegment_(e.initSegmentReference,0),b.getInfoFromSegment_(e,f)]),2)}l=u.yieldResult;m=l[1].mimeType;n=l[0].data;p=l[1].data;q="mp4 mp4a m4s m4i m4a m4f cmfa mp4v m4v cmfv fmp4".split(" ");r=["audio/mp4","video/mp4","video/iso.segment"];t=e.initSegmentReference||r.includes(m);if(!t&&shaka.util.TsParser.probe(shaka.util.BufferUtils.toUint8(p))){if(w=shaka.media.SegmentUtils.getBasicInfoFromTs(p,b.config_.disableAudio,b.config_.disableVideo,b.config_.disableText))return u.return(w)}else if(t||
q.includes(h))if(v=shaka.media.SegmentUtils.getBasicInfoFromMp4(n,p,b.config_.disableText))return u.return(v);return m?u.return(shaka.media.SegmentUtils.getBasicInfoFromMimeType(m)):u.return(c)})};
shaka.hls.HlsParser.prototype.getInfoFromSegment_=function(a,b){var c=this,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.nextAddress){case 1:if(!a)return l.return({mimeType:null,data:null});d=shaka.net.NetworkingEngine.RequestType.SEGMENT;e=shaka.util.Networking.createSegmentRequest(a.getUris(),a.getStartByte(),a.getEndByte(),c.config_.retryParameters);f=a instanceof shaka.media.SegmentReference?shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT:
shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT;return l.yield(c.makeNetworkRequest_(e,d,{type:f}).promise,2);case 2:g=l.yieldResult;h=g.data;if(!a.aesKey){l.jumpTo(3);break}return l.yield(shaka.media.SegmentUtils.aesDecrypt(h,a.aesKey,b),4);case 4:h=l.yieldResult;case 3:return a instanceof shaka.media.SegmentReference?a.setSegmentData(h,!0):a.setSegmentData(h),(k=g.headers["content-type"])&&(k=k.split(";")[0].toLowerCase()),l.return({mimeType:k,data:h})}})};
shaka.hls.HlsParser.prototype.determineDuration_=function(){goog.asserts.assert(this.presentationTimeline_,"Presentation timeline not created!");if(this.isLive_()){if(this.presentationType_==shaka.hls.HlsParser.PresentationType_.LIVE){var a=this.getLiveDuration_()||0;isNaN(this.config_.availabilityWindowOverride)||(a=this.config_.availabilityWindowOverride);this.presentationTimeline_.setSegmentAvailabilityDuration(a)}}else this.presentationTimeline_.setDuration(this.getMinDuration_());if(!this.presentationTimeline_.isStartTimeLocked()){a=
(0,$jscomp.makeIterator)(this.uriToStreamInfosMap_.values());for(var b=a.next();!b.done;b=a.next())b=b.value,!b.stream.segmentIndex||b.type!="audio"&&b.type!="video"||(b=b.stream.segmentIndex.earliestReference())&&b.syncTime&&this.presentationTimeline_.setInitialProgramDateTime(b.syncTime)}this.presentationTimeline_.lockStartTime();goog.asserts.assert(!this.presentationTimeline_.usingPresentationStartTime(),"We should not be using the presentation start time in HLS!")};
shaka.hls.HlsParser.prototype.parseMasterVariables_=function(a){var b=(new goog.Uri(this.masterPlaylistUri_)).getQueryData();a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){var d=c.value;c=d.getAttributeValue("NAME");var e=d.getAttributeValue("VALUE");d=d.getAttributeValue("QUERYPARAM");c&&e&&(this.globalVariables_.has(c)||this.globalVariables_.set(c,e));d&&(c=b.get(d)[0])&&!this.globalVariables_.has(c)&&this.globalVariables_.set(d,c)}};
shaka.hls.HlsParser.prototype.parseMediaVariables_=function(a,b){b=(new goog.Uri(b)).getQueryData();var c=new Map;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){var e=d.value,f=e.getAttributeValue("NAME"),g=e.getAttributeValue("VALUE");d=e.getAttributeValue("QUERYPARAM");e=e.getAttributeValue("IMPORT");f&&g&&(c.has(f)||c.set(f,g));d&&(f=b.get(d)[0])&&!c.has(f)&&c.set(d,f);e&&(d=this.globalVariables_.get(e))&&c.set(e,d)}return c};
shaka.hls.HlsParser.prototype.parseCodecs_=function(a){var b=shaka.util.ManifestParserUtils.ContentType;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){var d=c.value,e=d.getAttributeValue("AUDIO");c=d.getAttributeValue("VIDEO");var f=d.getAttributeValue("SUBTITLES");d=this.getCodecsForVariantTag_(d);if(f){var g=shaka.util.ManifestParserUtils.guessCodecsSafe(b.TEXT,d);goog.asserts.assert(g!=null,"Text codecs should be valid.");this.groupIdToCodecsMap_.set(f,g);shaka.util.ArrayUtils.remove(d,
g)}e&&(f=shaka.util.ManifestParserUtils.guessCodecsSafe(b.AUDIO,d),f||(f=this.config_.hls.defaultAudioCodec),this.groupIdToCodecsMap_.set(e,f));c&&(e=shaka.util.ManifestParserUtils.guessCodecsSafe(b.VIDEO,d),e||(e=this.config_.hls.defaultVideoCodec),this.groupIdToCodecsMap_.set(c,e))}};
shaka.hls.HlsParser.prototype.processSessionData_=function(a){a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){var c=b.value,d=c.getAttributeValue("DATA-ID");b=c.getAttributeValue("URI");var e=c.getAttributeValue("LANGUAGE");c=c.getAttributeValue("VALUE");d=(new Map).set("id",d);b&&d.set("uri",shaka.hls.Utils.constructSegmentUris([this.masterPlaylistUri_],b,this.globalVariables_)[0]);e&&d.set("language",e);c&&d.set("value",c);b=new shaka.util.FakeEvent("sessiondata",d);if(this.playerInterface_)this.playerInterface_.onEvent(b)}};
shaka.hls.HlsParser.prototype.processContentSteering_=function(a){var b=this,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(!b.playerInterface_||!b.config_)return k.return();d=(0,$jscomp.makeIterator)(a);for(e=d.next();!e.done;e=d.next())if(f=e.value,g=f.getAttributeValue("PATHWAY-ID"),h=f.getAttributeValue("SERVER-URI"),g&&h){b.contentSteeringManager_=new shaka.util.ContentSteeringManager(b.playerInterface_);b.contentSteeringManager_.configure(b.config_);b.contentSteeringManager_.setBaseUris([b.masterPlaylistUri_]);
b.contentSteeringManager_.setManifestType(shaka.media.ManifestParser.HLS);b.contentSteeringManager_.setDefaultPathwayId(g);c=b.contentSteeringManager_.requestInfo(h);break}return k.yield(c,0)})};
shaka.hls.HlsParser.prototype.parseTexts_=function(a){var b=this,c=shaka.hls.Utils.filterTagsByType(a,"SUBTITLES");a=c.map(function(h){if(b.config_.disableText)return null;try{return b.createStreamInfoFromMediaTags_([h],new Map).stream}catch(k){if(b.config_.hls.ignoreTextStreamFailures)return null;throw k;}});var d=shaka.util.ManifestParserUtils.ContentType.TEXT;c=(0,$jscomp.makeIterator)(c);for(var e=c.next();!e.done;e=c.next()){var f=e.value.getRequiredAttrValue("GROUP-ID");if(e=this.groupIdToCodecsMap_.get(f))if(f=
this.groupIdToStreamInfosMap_.get(f)){f=(0,$jscomp.makeIterator)(f);for(var g=f.next();!g.done;g=f.next())g=g.value,g.stream.codecs=e,g.stream.mimeType=this.guessMimeTypeBeforeLoading_(d,e)||this.guessMimeTypeFallback_(d),this.setFullTypeForStream_(g.stream)}}return a.filter(function(h){return h})};
shaka.hls.HlsParser.prototype.setFullTypeForStream_=function(a){var b=new Set([shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs)]);a.segmentIndex&&a.segmentIndex.forEachTopLevelReference(function(c){c.mimeType&&b.add(shaka.util.MimeUtils.getFullType(c.mimeType,a.codecs))});a.fullMimeTypes=b};
shaka.hls.HlsParser.prototype.parseImages_=function(a,b){var c=this,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return d=a.map(function(g){var h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1){if(h=c.config_.disableThumbnails)return m.return(null);m.setCatchFinallyBlocks(2);return m.yield(c.createStreamInfoFromImageTag_(g),4)}if(m.nextAddress!=2)return k=m.yieldResult,m.return(k.stream);l=m.enterCatchBlock();
if(c.config_.hls.ignoreImageStreamFailures)return m.return(null);throw l;})}).concat(b.map(function(g){if(c.config_.disableThumbnails)return null;try{var h=c.createStreamInfoFromIframeTag_(g);return h.stream.type!==shaka.util.ManifestParserUtils.ContentType.IMAGE?null:h.stream}catch(k){if(c.config_.hls.ignoreImageStreamFailures)return null;throw k;}})),f.yield(Promise.all(d),2);e=f.yieldResult;return f.return(e.filter(function(g){return g}))})};
shaka.hls.HlsParser.prototype.createStreamInfosFromMediaTags_=function(a,b){a=a.filter(function(g){var h=g.getAttributeValue("URI")||"";g=g.getAttributeValue("TYPE");return g!="SUBTITLES"&&(h!=""||g=="AUDIO")});var c={};a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;var e=d.getTagKey(!this.contentSteeringManager_);c[e]?c[e].push(d):c[e]=[d]}for(var f in c)this.createStreamInfoFromMediaTags_(c[f],b,!1)};
shaka.hls.HlsParser.prototype.parseIFrames_=function(a){var b=this;return a.map(function(c){c=b.createStreamInfoFromIframeTag_(c);return c.stream.type!==shaka.util.ManifestParserUtils.ContentType.VIDEO?null:c.stream}).filter(function(c){return c})};
shaka.hls.HlsParser.prototype.createVariantsForTags_=function(a,b,c,d,e,f){var g=this,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O,N,S,aa,R,W,ba;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(V){switch(V.nextAddress){case 1:h=[];k=new Set;if(g.config_.ignoreDrmInfo||!(b.length>0)){V.jumpTo(2);break}l=(0,$jscomp.makeIterator)(b);m=l.next();case 3:if(m.done){V.jumpTo(2);break}n=m.value;p=n.getRequiredAttrValue("METHOD");q=n.getAttributeValue("KEYFORMAT")||"identity";
r=null;if(p=="NONE"){V.jumpTo(4);break}if(g.isAesMethod_(p)){t=shaka.hls.Utils.constructSegmentUris(d(),n.getRequiredAttrValue("URI"),e);w=t.sort().join("");g.aesKeyMap_.has(w)||(v=shaka.net.NetworkingEngine.RequestType.KEY,u=shaka.net.NetworkingEngine.makeRequest(t,g.config_.retryParameters),x=g.makeNetworkRequest_(u,v).promise,g.aesKeyMap_.set(w,x));V.jumpTo(4);break}if(q=="identity")return V.yield(g.identityDrmParser_(n,"",d,null,e),12);z=g.keyFormatsToDrmParsers_.get(q);if(!z){B=null;V.jumpTo(10);
break}return V.yield(z(n,"",null),11);case 11:B=V.yieldResult;case 10:r=B;V.jumpTo(6);break;case 12:r=V.yieldResult;case 6:if(r){if(r.keyIds)for(C=(0,$jscomp.makeIterator)(r.keyIds),y=C.next();!y.done;y=C.next())A=y.value,k.add(A);h.push(r)}else shaka.log.warning("Unsupported HLS KEYFORMAT",q);case 4:m=l.next();V.jumpTo(3);break;case 2:D={};E=(0,$jscomp.makeIterator)(a);for(F=E.next();!F.done;F=E.next())L=F.value,K=L.getTagKey(!g.contentSteeringManager_),D[K]?D[K].push(L):D[K]=[L];J=[];for(I in D)G=
D[I],M=G[0],H=M.getAttributeValue("FRAME-RATE"),P=Number(M.getAttributeValue("AVERAGE-BANDWIDTH"))||Number(M.getRequiredAttrValue("BANDWIDTH")),Q=M.getAttributeValue("RESOLUTION"),O=(0,$jscomp.makeIterator)(Q?Q.split("x"):[null,null]),N=O.next().value,S=O.next().value,aa=M.getAttributeValue("VIDEO-RANGE"),(R=M.getAttributeValue("REQ-VIDEO-LAYOUT"))&&R.includes(",")&&(W=R.split(",").filter(function(X){return X=="CH-STEREO"||X=="CH-MONO"}),R=W[0]),R=R||"CH-MONO",ba=g.createStreamInfosForVariantTags_(G,
c,Q,H),goog.asserts.assert(ba.audio.length||ba.video.length,"We should have created a stream!"),J.push.apply(J,(0,$jscomp.arrayFromIterable)(g.createVariants_(ba.audio,ba.video,P,N,S,H,aa,R,h,k,f)));return V.return(J.filter(function(X){return X!=null}))}})};
shaka.hls.HlsParser.prototype.createStreamInfosForVariantTags_=function(a,b,c,d){d=shaka.util.ManifestParserUtils.ContentType;c={audio:[],video:[]};for(var e=new Map,f=[],g=!1,h=!1,k=(0,$jscomp.makeIterator)(a),l=k.next();!l.done;l=k.next()){l=l.value;var m=l.getAttributeValue("AUDIO"),n=l.getAttributeValue("VIDEO");goog.asserts.assert(m==null||n==null,"Unexpected: both video and audio described by media tags!");var p=m||n;if(p){f.includes(p)||f.push(p);var q=l.getAttributeValue("PATHWAY-ID");q&&
e.set(p,q);m?g=!0:n&&(h=!0);shaka.log.debug("Guessing stream type for",l.toString())}}f.length&&b.length&&(b=b.filter(function(t){return f.includes(t.getRequiredAttrValue("GROUP-ID"))}),this.createStreamInfosFromMediaTags_(b,e));e=(b=f.sort().join(","))&&this.groupIdToStreamInfosMap_.has(b)?this.groupIdToStreamInfosMap_.get(b):[];g?c.audio.push.apply(c.audio,(0,$jscomp.arrayFromIterable)(e)):h&&c.video.push.apply(c.video,(0,$jscomp.arrayFromIterable)(e));h=!1;var r=a.map(function(t){return t.getRequiredAttrValue("URI")});
g=c.audio.find(function(t){return t&&t.getUris().find(function(w){return r.includes(w)})});e=this.getCodecsForVariantTag_(a[0]);k=shaka.util.ManifestParserUtils.guessCodecsSafe(d.VIDEO,e);(l=shaka.util.ManifestParserUtils.guessCodecsSafe(d.AUDIO,e))&&!k?(g=d.AUDIO,shaka.log.debug("Guessing audio-only."),h=c.audio.length>0&&!c.audio.some(function(t){return t.stream.isAudioMuxedInVideo})):!c.audio.length&&!c.video.length&&l&&k?(shaka.log.debug("Guessing multiplexed audio+video."),g=d.VIDEO,e=[[k,l].join()]):
c.audio.length&&g?(shaka.log.debug("Guessing audio-only."),g=d.AUDIO,h=!0):c.video.length&&!c.audio.length?(shaka.log.debug("Guessing audio-only."),g=d.AUDIO):(shaka.log.debug("Guessing video-only."),g=d.VIDEO);h||(a=this.createStreamInfoFromVariantTags_(a,e,g),b&&this.config_.enableAudioGroups&&(a.stream.groupId=b),a.stream.type==d.AUDIO&&g===d.AUDIO&&c.audio.some(function(t){return t.stream.isAudioMuxedInVideo})&&(d=c.audio[0].stream,a.stream.language=d.language,a.stream.channelsCount=d.channelsCount,
a.stream.label=d.label,a.stream.audioSamplingRate=d.audioSamplingRate,a.stream.originalId=d.originalId,a.stream.originalLanguage=d.originalLanguage),c[a.stream.type]=[a]);return c};
shaka.hls.HlsParser.prototype.getCodecsForVariantTag_=function(a){a=a.getAttributeValue("CODECS")||"";this.codecInfoInManifest_=a.length>0;this.codecInfoInManifest_||this.config_.hls.disableCodecGuessing||(a=[],this.config_.disableVideo||a.push(this.config_.hls.defaultVideoCodec),this.config_.disableAudio||a.push(this.config_.hls.defaultAudioCodec),a=a.join(","));a=a.split(/\s*,\s*/);return shaka.media.SegmentUtils.codecsFiltering(a)};
shaka.hls.HlsParser.prototype.getChannelsCount_=function(a){a=a.getAttributeValue("CHANNELS");if(!a)return null;a=a.split("/")[0];return parseInt(a,10)};shaka.hls.HlsParser.prototype.getSampleRate_=function(a){return(a=a.getAttributeValue("SAMPLE-RATE"))?parseInt(a,10):null};shaka.hls.HlsParser.prototype.isSpatialAudio_=function(a){a=a.getAttributeValue("CHANNELS");if(!a)return!1;a=a.split("/");return a.length!=2?!1:a[1]==="JOC"||a[1].includes("ATMOS")};
shaka.hls.HlsParser.prototype.getClosedCaptions_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType;a=a.getAttributeValue("CLOSED-CAPTIONS");if(b==c.VIDEO){if(this.config_.disableText)return this.needsClosedCaptionsDetection_=!1,null;if(a){if(a!="NONE")return this.groupIdToClosedCaptionsMap_.get(a);this.needsClosedCaptionsDetection_=!1}else if(!a&&this.groupIdToClosedCaptionsMap_.size)for(b=(0,$jscomp.makeIterator)(this.groupIdToClosedCaptionsMap_.keys()),b=b.next();!b.done;b=b.next())return this.groupIdToClosedCaptionsMap_.get(b.value)}return null};
shaka.hls.HlsParser.prototype.getLanguage_=function(a){return shaka.util.LanguageUtils.normalize(a||"und")};shaka.hls.HlsParser.prototype.getType_=function(a){a=a.getRequiredAttrValue("TYPE").toLowerCase();a=="subtitles"&&(a=shaka.util.ManifestParserUtils.ContentType.TEXT);return a};
shaka.hls.HlsParser.prototype.createVariants_=function(a,b,c,d,e,f,g,h,k,l,m){for(var n=shaka.util.ManifestParserUtils.ContentType,p=shaka.drm.DrmUtils,q=(0,$jscomp.makeIterator)(b),r=q.next();!r.done;r=q.next())this.addVideoAttributes_(r.value.stream,d,e,f,g,h,null);d=this.config_.disableVideo;if(!b.length||d)b=[null];d&&(a=a.filter(function(u){return!u.stream.isAudioMuxedInVideo}));d=this.config_.disableAudio;if(!a.length||d)a=[null];d=[];a=(0,$jscomp.makeIterator)(a);for(e=a.next();!e.done;e=a.next())for(e=
e.value,f=(0,$jscomp.makeIterator)(b),g=f.next();!g.done;g=f.next()){var t=g.value;if(g=e?e.stream:null)g.drmInfos=k,g.keyIds=l;if(h=t?t.stream:null)h.drmInfos=k,h.keyIds=l,this.config_.disableIFrames||shaka.util.StreamUtils.setBetterIFrameStream(h,m);h&&!g&&(h.bandwidth=c);!h&&g&&(g.bandwidth=c);q=e?e.stream.drmInfos:null;r=t?t.stream.drmInfos:null;t=t?t.getUris().sort().join(","):"";var w=e?e.getUris().sort().join(","):"",v=[];g&&g.codecs&&v.push(g.codecs);h&&h.codecs&&v.push(h.codecs);t=[t,w,v.sort()].join("-");
g&&h&&!p.areDrmCompatible(q,r)?shaka.log.warning("Incompatible DRM info in HLS variant.  Skipping."):this.variantUriSet_.has(t)?shaka.log.debug("Skipping variant which only differs in text streams."):(goog.asserts.assert(!g||g.type==n.AUDIO,"Audio parameter mismatch!"),goog.asserts.assert(!h||h.type==n.VIDEO,"Video parameter mismatch!"),g={id:this.globalId_++,language:g?g.language:"und",disabledUntilTime:0,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:c,allowedByApplication:!0,
allowedByKeySystem:!0,decodingInfos:[]},d.push(g),this.variantUriSet_.add(t))}return d};
shaka.hls.HlsParser.prototype.parseClosedCaptions_=function(a){a=shaka.hls.Utils.filterTagsByType(a,"CLOSED-CAPTIONS");this.needsClosedCaptionsDetection_=a.length==0;a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){var c=b.value;goog.asserts.assert(c.name=="EXT-X-MEDIA","Should only be called on media tags!");var d=c.getAttributeValue("LANGUAGE");b=this.getLanguage_(d);d||(d=c.getAttributeValue("NAME"))&&(b=d);d=c.getRequiredAttrValue("GROUP-ID");c=c.getRequiredAttrValue("INSTREAM-ID").replace("SERVICE",
"svc");this.groupIdToClosedCaptionsMap_.get(d)||this.groupIdToClosedCaptionsMap_.set(d,new Map);this.groupIdToClosedCaptionsMap_.get(d).set(c,b)}};
shaka.hls.HlsParser.prototype.createStreamInfoFromMediaTags_=function(a,b,c){c=c===void 0?!0:c;for(var d=[],e=[],f=new Map,g=(0,$jscomp.makeIterator)(a),h=g.next(),k={};!h.done;k={id$jscomp$19:void 0},h=g.next())h=h.value,goog.asserts.assert(h.name=="EXT-X-MEDIA","Should only be called on media tags!"),k.id$jscomp$19=++this.globalId_,k=function(r){return function(){return shaka.hls.HlsParser.FAKE_MUXED_URL_+r.id$jscomp$19}}(k),k=c?h.getRequiredAttrValue("URI"):h.getAttributeValue("URI")||k(),h=h.getRequiredAttrValue("GROUP-ID"),
d.push(k),e.push(h),f.set(h,k);c=e.sort().join(",");h=a[0];a="";g=this.getType_(h);if(g==shaka.util.ManifestParserUtils.ContentType.TEXT)a=h.getAttributeValue("CODECS")||"";else for(e=(0,$jscomp.makeIterator)(e),k=e.next();!k.done;k=e.next())if(k=k.value,this.groupIdToCodecsMap_.has(k)){a=this.groupIdToCodecsMap_.get(k);break}e=d.sort().join(",");if(this.uriToStreamInfosMap_.has(e))return this.uriToStreamInfosMap_.get(e);k=this.globalId_++;if(this.contentSteeringManager_){f=(0,$jscomp.makeIterator)(f);
for(var l=f.next();!l.done;l=f.next()){var m=(0,$jscomp.makeIterator)(l.value);l=m.next().value;m=m.next().value;(l=b.get(l))&&this.contentSteeringManager_.addLocation(k,l,m)}}b=h.getAttributeValue("LANGUAGE");f=h.getAttributeValue("NAME");l=h.getAttributeValue("DEFAULT")=="YES";m=g=="audio"?this.getChannelsCount_(h):null;var n=g=="audio"?this.isSpatialAudio_(h):!1,p=h.getAttributeValue("CHARACTERISTICS"),q=h.getAttributeValue("FORCED")=="YES";h=g=="audio"?this.getSampleRate_(h):null;d=this.createStreamInfo_(k,
d,a,g,b,l,f,m,null,p,q,h,n);d.stream&&this.config_.enableAudioGroups&&(d.stream.groupId=c);this.groupIdToStreamInfosMap_.has(c)?this.groupIdToStreamInfosMap_.get(c).push(d):this.groupIdToStreamInfosMap_.set(c,[d]);this.uriToStreamInfosMap_.set(e,d);return d};
shaka.hls.HlsParser.prototype.createStreamInfoFromImageTag_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.nextAddress==1){goog.asserts.assert(a.name=="EXT-X-IMAGE-STREAM-INF","Should only be called on image tags!");c=shaka.util.ManifestParserUtils.ContentType.IMAGE;d=a.getRequiredAttrValue("URI");e=a.getAttributeValue("CODECS","jpeg")||"";if(b.uriToStreamInfosMap_.has(d))return q.return(b.uriToStreamInfosMap_.get(d));f=a.getAttributeValue("LANGUAGE");
g=a.getAttributeValue("NAME");h=a.getAttributeValue("CHARACTERISTICS");k=b.createStreamInfo_(b.globalId_++,[d],e,c,f,!1,g,null,null,h,!1,null,!1);return(l=a.getAttributeValue("RESOLUTION"))?q.yield(k.stream.createSegmentIndex(),3):q.jumpTo(2)}if(q.nextAddress!=2){m=k.stream.segmentIndex.earliestReference();if(n=m.getTilesLayout())k.stream.width=Number(l.split("x")[0])*Number(n.split("x")[0]),k.stream.height=Number(l.split("x")[1])*Number(n.split("x")[1]);k.stream.closeSegmentIndex()}if(p=a.getAttributeValue("BANDWIDTH"))k.stream.bandwidth=
Number(p);b.uriToStreamInfosMap_.set(d,k);return q.return(k)})};
shaka.hls.HlsParser.prototype.createStreamInfoFromIframeTag_=function(a){goog.asserts.assert(a.name=="EXT-X-I-FRAME-STREAM-INF","Should only be called on iframe tags!");var b=shaka.util.ManifestParserUtils.ContentType.VIDEO,c=a.getRequiredAttrValue("URI"),d=a.getAttributeValue("CODECS")||"";d=="mjpg"&&(b=shaka.util.ManifestParserUtils.ContentType.IMAGE);if(this.uriToStreamInfosMap_.has(c))return this.uriToStreamInfosMap_.get(c);var e=a.getAttributeValue("LANGUAGE"),f=a.getAttributeValue("NAME"),g=
a.getAttributeValue("CHARACTERISTICS");b=this.createStreamInfo_(this.globalId_++,[c],d,b,e,!1,f,null,null,g,!1,null,!1);d=a.getAttributeValue("RESOLUTION");e=(0,$jscomp.makeIterator)(d?d.split("x"):[null,null]);d=e.next().value;e=e.next().value;b.stream.width=Number(d)||void 0;b.stream.height=Number(e)||void 0;if(a=a.getAttributeValue("BANDWIDTH"))b.stream.bandwidth=Number(a);this.uriToStreamInfosMap_.set(c,b);return b};
shaka.hls.HlsParser.prototype.createStreamInfoFromVariantTags_=function(a,b,c){for(var d=this.globalId_++,e=[],f=(0,$jscomp.makeIterator)(a),g=f.next();!g.done;g=f.next()){var h=g.value;goog.asserts.assert(h.name=="EXT-X-STREAM-INF","Should only be called on variant tags!");g=h.getRequiredAttrValue("URI");h=h.getAttributeValue("PATHWAY-ID");this.contentSteeringManager_&&h&&this.contentSteeringManager_.addLocation(d,h,g);e.push(g)}f=e.sort().join(",")+b.sort().join(",");if(this.uriToStreamInfosMap_.has(f))return this.uriToStreamInfosMap_.get(f);
g=e.join(",");a=this.getClosedCaptions_(a[0],c);b=shaka.util.ManifestParserUtils.guessCodecs(c,b);c=this.createStreamInfo_(d,e,b,c,null,!1,g,null,a,null,!1,null,!1);this.uriToStreamInfosMap_.set(f,c);return c};
shaka.hls.HlsParser.prototype.createStreamInfo_=function(a,b,c,d,e,f,g,h,k,l,m,n,p){var q=this,r=this.makeStreamObject_(a,c,d,e,f,g,h,k,l,m,n,p);b.some(function(z){return z.startsWith(shaka.hls.HlsParser.FAKE_MUXED_URL_)})&&(r.isAudioMuxedInVideo=!0,r.mimeType="video/mp2t",this.setFullTypeForStream_(r));var t={stream:r,type:d,redirectUris:[],getUris:function(){},minTimestamp:0,maxTimestamp:0,mediaSequenceToStartTime:new Map,canSkipSegments:!1,canBlockReload:!1,hasEndList:!1,firstSequenceNumber:-1,
nextMediaSequence:-1,nextPart:-1},w=function(){return q.contentSteeringManager_&&b.length>1?q.contentSteeringManager_.getLocations(a):t.redirectUris.concat(shaka.hls.Utils.constructUris([q.masterPlaylistUri_],b,q.globalVariables_))};t.getUris=w;var v=function(z){var B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O,N,S,aa;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.nextAddress){case 1:return B=shaka.util.ManifestParserUtils.ContentType,R.setCatchFinallyBlocks(2),R.yield(z.promise,4);
case 4:C=R.yieldResult;if(z.aborted)return R.return();y=C.uri;y!=C.originalUri&&(A=t.getUris(),A.includes(y)||t.redirectUris.push(y));D=q.manifestTextParser_.parsePlaylist(C.data);if(D.type!=shaka.hls.PlaylistType.MEDIA)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_INVALID_PLAYLIST_HIERARCHY);E=shaka.hls.Utils.filterTagsByName(D.tags,"EXT-X-DEFINE");F=q.parseMediaVariables_(E,y);L=!1;(!q.codecInfoInManifest_&&q.config_.hls.disableCodecGuessing||
q.needsClosedCaptionsDetection_&&d==B.VIDEO&&!q.config_.hls.disableClosedCaptionsDetection)&&D.segments.length>0&&(q.needsClosedCaptionsDetection_=!1,L=!0);K=!q.codecInfoInManifest_&&q.config_.hls.disableCodecGuessing;J=q.isLive_();return R.yield(q.convertParsedPlaylistIntoStreamInfo_(a,F,D,w,c,d,e,f,g,h,k,l,m,n,p,void 0,L,K),5);case 5:I=R.yieldResult;if(z.aborted)return R.return();G=I.stream;q.determineStartTime_(D);q.isLive_()&&!J&&q.changePresentationTimelineToLive_(D);t.minTimestamp=I.minTimestamp;
t.maxTimestamp=I.maxTimestamp;t.canSkipSegments=I.canSkipSegments;t.canBlockReload=I.canBlockReload;t.hasEndList=I.hasEndList;t.mediaSequenceToStartTime=I.mediaSequenceToStartTime;t.nextMediaSequence=I.nextMediaSequence;t.nextPart=I.nextPart;r.segmentIndex=G.segmentIndex;r.encrypted=G.encrypted;r.drmInfos=G.drmInfos;r.keyIds=G.keyIds;r.mimeType=G.mimeType;r.bandwidth=r.bandwidth||G.bandwidth;r.codecs=r.codecs||G.codecs;r.closedCaptions=r.closedCaptions||G.closedCaptions;r.width=r.width||G.width;r.height=
r.height||G.height;r.hdr=r.hdr||G.hdr;r.colorGamut=r.colorGamut||G.colorGamut;r.frameRate=r.frameRate||G.frameRate;r.language=="und"&&G.language!="und"&&(r.language=G.language);r.language=r.language||G.language;r.channelsCount=r.channelsCount||G.channelsCount;r.audioSamplingRate=r.audioSamplingRate||G.audioSamplingRate;q.setFullTypeForStream_(r);r.drmInfos.length&&q.playerInterface_.newDrmInfo(r);M=!1;if(!k&&r.closedCaptions||k&&r.closedCaptions&&k.size!=r.closedCaptions.size)M=!0;q.manifest_&&M&&
q.playerInterface_.makeTextStreamsForClosedCaptions(q.manifest_);d==B.TEXT&&(H=G.segmentIndex.earliestReference())&&H.initSegmentReference&&(r.mimeType="application/mp4",q.setFullTypeForStream_(r));P=shaka.media.QualityObserver.createQualityInfo(r);r.segmentIndex.forEachTopLevelReference(function(W){W.initSegmentReference&&(W.initSegmentReference.mediaQuality=P)});q.hasEnoughInfoToFinalizeStreams_()&&(q.streamsFinalized_?q.finalizeStreams_([t]):(q.streamsFinalized_=!0,Q=Array.from(q.uriToStreamInfosMap_.values()),
O=Q.filter(function(W){return W.stream.segmentIndex}),q.finalizeStreams_(O),q.determineDuration_(),N=q.getUpdatePlaylistDelay_(),N>0&&q.updatePlaylistTimer_.tickAfter(N)));q.processDateRangeTags_(D.tags,r.type,F,w);q.manifest_&&(q.manifest_.startTime=q.startTime_);R.leaveTryBlock(0);break;case 2:S=R.enterCatchBlock();r.closeSegmentIndex();if(S.code===shaka.util.Error.Code.OPERATION_ABORTED)return R.return();aa=q.playerInterface_.disableStream(r);if(!aa)throw S;R.jumpToEnd()}})},u=null,x;r.createSegmentIndex=
function(){if(u)return u;if(r.isAudioMuxedInVideo){var z=new shaka.media.SegmentIndex([]);r.segmentIndex=z;return Promise.resolve()}x=q.requestManifest_(t.getUris(),!0);return u=new Promise(function(B){B(v(x))})};r.closeSegmentIndex=function(){u&&!r.segmentIndex&&x.abort();r.segmentIndex&&(r.segmentIndex.release(),r.segmentIndex=null);u=null};return t};
shaka.hls.HlsParser.prototype.getMinDuration_=function(){for(var a=Infinity,b=(0,$jscomp.makeIterator)(this.uriToStreamInfosMap_.values()),c=b.next();!c.done;c=b.next())c=c.value,c.stream.segmentIndex&&c.stream.type!="text"&&!c.stream.isAudioMuxedInVideo&&(a=Math.min(a,c.maxTimestamp));return a};
shaka.hls.HlsParser.prototype.getLiveDuration_=function(){for(var a=Infinity,b=Infinity,c=(0,$jscomp.makeIterator)(this.uriToStreamInfosMap_.values()),d=c.next();!d.done;d=c.next())d=d.value,d.stream.segmentIndex&&d.stream.type!="text"&&!d.stream.isAudioMuxedInVideo&&(a=Math.min(a,d.maxTimestamp),b=Math.min(b,d.minTimestamp));return a-b};
shaka.hls.HlsParser.prototype.notifySegmentsForStreams_=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.segmentIndex&&c.segmentIndex.forEachTopLevelReference(function(d){b.push(d)});this.presentationTimeline_.notifySegments(b)};
shaka.hls.HlsParser.prototype.finalizeStreams_=function(a){if(!this.isLive_())for(var b=this.getMinDuration_(),c=(0,$jscomp.makeIterator)(a),d=c.next();!d.done;d=c.next())d.value.stream.segmentIndex.fit(0,b);this.notifySegmentsForStreams_(a.map(function(f){return f.stream}));c=Array.from(this.uriToStreamInfosMap_.values()).filter(function(f){return f.stream.segmentIndex});var e=shaka.util.ManifestParserUtils.ContentType;b=c.some(function(f){return f.stream.type==e.AUDIO});d=c.some(function(f){return f.stream.type==
e.VIDEO});c=this.isLive_()&&!this.usesProgramDateTime_;b=!this.isLive_()&&this.usesProgramDateTime_&&!(b&&d);this.config_.hls.ignoreManifestProgramDateTime||c||b?this.syncStreamsWithSequenceNumber_(a,c):(this.syncStreamsWithProgramDateTime_(a),this.config_.hls.ignoreManifestProgramDateTimeForTypes.length>0&&this.syncStreamsWithSequenceNumber_(a))};shaka.hls.HlsParser.prototype.ignoreManifestProgramDateTimeFor_=function(a){return this.config_.hls.ignoreManifestProgramDateTime?!0:this.config_.hls.ignoreManifestProgramDateTimeForTypes.includes(a)};
shaka.hls.HlsParser.prototype.hasEnoughInfoToFinalizeStreams_=function(){if(!this.manifest_)return!1;for(var a=[],b=[],c=(0,$jscomp.makeIterator)(this.manifest_.variants),d=c.next();!d.done;d=c.next())d=d.value,d.video&&a.push(d.video),d.audio&&b.push(d.audio);return a.length>0&&!a.some(function(e){return e.segmentIndex})||b.length>0&&!b.some(function(e){return e.segmentIndex})?!1:!0};
shaka.hls.HlsParser.prototype.convertParsedPlaylistIntoStreamInfo_=function(a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v){w=w===void 0?!0:w;v=v===void 0?!0:v;var u=this,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O,N,S,aa,R,W,ba,V,X,Y,Z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(U){switch(U.nextAddress){case 1:x=c.segments||[];z=x.every(function(T){return shaka.hls.Utils.getFirstTagWithName(T.tags,"EXT-X-GAP")?!0:!1});if(!x.length||z)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_EMPTY_MEDIA_PLAYLIST);u.determinePresentationType_(c);u.isLive_()&&u.determineLastTargetDuration_(c);B=u.isLive_()?u.mediaSequenceToStartTimeByType_.get(f):new Map;C=u.createSegments_(c,B,b,d,f);y=C.segments;A=C.bandwidth;K=L=F=E=D=null;if(!(y.length>0&&w)){U.jumpTo(2);break}return U.yield(u.getBasicInfoFromSegments_(y),3);case 3:J=U.yieldResult,f!=J.type&&u.isLive_()&&(u.mediaSequenceToStartTimeByType_.set(J.type,u.mediaSequenceToStartTimeByType_.get(f)),
u.mediaSequenceToStartTimeByType_.set(f,new Map)),f=J.type,g=J.language,l=J.channelCount,q=J.sampleRate,u.config_.disableText||(m=J.closedCaptions),E=J.height,D=J.width,F=J.videoRange,L=J.colorGamut,K=J.frameRate,v&&(t=J.mimeType,e=J.codecs);case 2:if(t){U.jumpTo(4);break}return U.yield(u.guessMimeType_(f,e,y),5);case 5:t=U.yieldResult,f!=shaka.util.ManifestParserUtils.ContentType.TEXT||e||t!="application/mp4"||!y[0]||y[0].initSegmentReference||(t="text/vtt");case 4:return U.yield(u.parseDrmInfo_(c,
t,d,b),6);case 6:I=U.yieldResult;G=I.drmInfos;M=I.keyIds;H=I.encrypted;P=I.aesEncrypted;if(H&&!G.length&&!P)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_KEYFORMATS_NOT_SUPPORTED);Q=u.makeStreamObject_(a,e,f,g,h,k,l,m,n,p,q,r);Q.encrypted=H&&!P;Q.drmInfos=G;Q.keyIds=M;Q.mimeType=t;A&&(Q.bandwidth=A);u.setFullTypeForStream_(Q);f==shaka.util.ManifestParserUtils.ContentType.VIDEO&&(D||E||F||L)&&u.addVideoAttributes_(Q,D,E,K,
F,null,L);u.isLive_()&&u.determineLastTargetDuration_(c);O=y[0].startTime;N=y[y.length-1];S=N.endTime;aa=new shaka.media.SegmentIndex(y);Q.segmentIndex=aa;W=(R=shaka.hls.Utils.getFirstTagWithName(c.tags,"EXT-X-SERVER-CONTROL"))?R.getAttribute("CAN-SKIP-UNTIL")!=null:!1;ba=R?R.getAttribute("CAN-BLOCK-RELOAD")!=null:!1;V=shaka.hls.Utils.getFirstTagWithNameAsNumber(c.tags,"EXT-X-MEDIA-SEQUENCE",0);X=u.getNextMediaSequenceAndPart_(V,y);Y=X.nextMediaSequence;Z=X.nextPart;return U.return({stream:Q,type:f,
redirectUris:[],getUris:d,minTimestamp:O,maxTimestamp:S,canSkipSegments:W,canBlockReload:ba,hasEndList:!1,firstSequenceNumber:-1,nextMediaSequence:Y,nextPart:Z,mediaSequenceToStartTime:B})}})};
shaka.hls.HlsParser.prototype.getNextMediaSequenceAndPart_=function(a,b){a=a+b.length-1;var c=-1;if(!b.length)return a++,{nextMediaSequence:a,nextPart:c};b=b[b.length-1];var d=b.partialReferences;if(!b.partialReferences.length)return a++,b.hasByterangeOptimization()&&(c=0),{nextMediaSequence:a,nextPart:c};c=d.length-1;d[d.length-1].isPreload()||(a++,c=0);return{nextMediaSequence:a,nextPart:c}};
shaka.hls.HlsParser.prototype.makeStreamObject_=function(a,b,c,d,e,f,g,h,k,l,m,n){a=this.guessMimeTypeBeforeLoading_(c,b)||this.guessMimeTypeFallback_(c);var p=[];if(k){k=(0,$jscomp.makeIterator)(k.split(","));for(var q=k.next();!q.done;q=k.next())p.push(q.value)}k=void 0;q=null;c==shaka.util.ManifestParserUtils.ContentType.TEXT?k=p.includes("public.accessibility.transcribes-spoken-dialog")&&p.includes("public.accessibility.describes-music-and-sound")?shaka.util.ManifestParserUtils.TextStreamKind.CLOSED_CAPTION:
shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE:p.includes("public.accessibility.describes-video")&&(q=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED);p.length||k!==shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE||p.push(shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE);b={id:this.globalId_++,originalId:f,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:null,mimeType:a,codecs:b,kind:c==shaka.util.ManifestParserUtils.ContentType.TEXT?
shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE:void 0,encrypted:!1,drmInfos:[],keyIds:new Set,language:this.getLanguage_(d),originalLanguage:d,label:f,type:c,primary:e,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,frameRate:void 0,pixelAspectRatio:void 0,width:void 0,height:void 0,bandwidth:void 0,roles:p,forced:l,channelsCount:g,audioSamplingRate:m,spatialAudio:n,closedCaptions:h,hdr:void 0,colorGamut:void 0,videoLayout:void 0,tilesLayout:void 0,accessibilityPurpose:q,external:!1,
fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null};this.setFullTypeForStream_(b);return b};
shaka.hls.HlsParser.prototype.parseDrmInfo_=function(a,b,c,d){var e=this,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.nextAddress){case 1:f=new Map;if(!e.config_.ignoreDrmInfo&&a.segments)for(g=(0,$jscomp.makeIterator)(a.segments),h=g.next();!h.done;h=g.next())if(k=h.value,l=shaka.hls.Utils.filterTagsByName(k.tags,"EXT-X-KEY"),m=null,l.length)for(m=e.getInitSegmentReference_(a,k.tags,c,d),n=(0,$jscomp.makeIterator)(l),
p=n.next();!p.done;p=n.next())q=p.value,f.set(q,m);t=r=!1;w=[];v=new Set;u=(0,$jscomp.makeIterator)(f);x=u.next();case 2:if(x.done){H.jumpTo(4);break}z=x.value;B=(0,$jscomp.makeIterator)(z);C=B.next().value;y=B.next().value;A=C;D=y;E=A.getRequiredAttrValue("METHOD");if(E=="NONE"){H.jumpTo(3);break}r=!0;F=A.getAttributeValue("KEYFORMAT")||"identity";L=null;if(e.isAesMethod_(E)){t=!0;H.jumpTo(3);break}if(F=="identity")return H.yield(e.identityDrmParser_(A,b,c,D,d),11);K=e.keyFormatsToDrmParsers_.get(F);
if(!K){J=null;H.jumpTo(9);break}return H.yield(K(A,b,D),10);case 10:J=H.yieldResult;case 9:L=J;H.jumpTo(6);break;case 11:L=H.yieldResult;case 6:if(L){if(L.keyIds)for(I=(0,$jscomp.makeIterator)(L.keyIds),G=I.next();!G.done;G=I.next())M=G.value,v.add(M);w.push(L)}else shaka.log.warning("Unsupported HLS KEYFORMAT",F);case 3:x=u.next();H.jumpTo(2);break;case 4:return H.return({drmInfos:w,keyIds:v,encrypted:r,aesEncrypted:t})}})};
shaka.hls.HlsParser.prototype.parseAESDrmTag_=function(a,b,c,d){var e=this;if(!window.crypto||!window.crypto.subtle)throw shaka.log.alwaysWarn("Web Crypto API is not available to decrypt AES. (Web Crypto only exists in secure origins like https)"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.NO_WEB_CRYPTO_API);var f=0,g=a.getAttributeValue("IV","");if(g){var h=shaka.util.Uint8ArrayUtils.fromHex(g.substr(2));if(h.byteLength!=16)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.AES_128_INVALID_IV_LENGTH);}else f=shaka.hls.Utils.getFirstTagWithNameAsNumber(b.tags,"EXT-X-MEDIA-SEQUENCE",0);var k=shaka.hls.Utils.constructSegmentUris(c(),a.getRequiredAttrValue("URI"),d),l=k.sort().join("");b=a.toString()+"-"+f+"-"+l;if(!this.aesKeyInfoMap_.has(b)){var m={bitsKey:128,blockCipherMode:"CBC",iv:h,firstMediaSequenceNumber:f};switch(a.getRequiredAttrValue("METHOD")){case "AES-256":m.bitsKey=256;break;case "AES-256-CTR":m.bitsKey=
256,m.blockCipherMode="CTR"}m.fetchKey=function(){var n,p,q,r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(w){if(w.nextAddress==1)return e.aesKeyMap_.has(l)||(n=shaka.net.NetworkingEngine.RequestType.KEY,p=shaka.net.NetworkingEngine.makeRequest(k,e.config_.retryParameters),q=e.makeNetworkRequest_(p,n).promise,e.aesKeyMap_.set(l,q)),w.yield(e.aesKeyMap_.get(l),2);if(w.nextAddress!=3){r=w.yieldResult;if(!r.data||r.data.byteLength!=m.bitsKey/8)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.AES_128_INVALID_KEY_LENGTH);t={name:m.blockCipherMode=="CTR"?"AES-CTR":"AES-CBC",length:m.bitsKey};return w.yield(window.crypto.subtle.importKey("raw",r.data,t,!0,["decrypt"]),3)}m.cryptoKey=w.yieldResult;m.fetchKey=void 0;w.jumpToEnd()})};this.aesKeyInfoMap_.set(b,m)}return this.aesKeyInfoMap_.get(b)};
shaka.hls.HlsParser.prototype.determineStartTime_=function(a){this.startTime_==null&&(a=shaka.hls.Utils.getFirstTagWithName(a.tags,"EXT-X-START"))&&(this.startTime_=Number(a.getRequiredAttrValue("TIME-OFFSET")))};
shaka.hls.HlsParser.prototype.determinePresentationType_=function(a){var b=shaka.hls.HlsParser.PresentationType_,c=shaka.hls.Utils.getFirstTagWithName(a.tags,"EXT-X-PLAYLIST-TYPE");a=shaka.hls.Utils.getFirstTagWithName(a.tags,"EXT-X-ENDLIST");a=c&&c.value=="VOD"||a;c=c&&c.value=="EVENT"&&!a;c=!a&&!c;a?this.setPresentationType_(b.VOD):c?this.setPresentationType_(b.LIVE):this.setPresentationType_(b.EVENT)};
shaka.hls.HlsParser.prototype.determineLastTargetDuration_=function(a){var b=Infinity,c=a.segments;if(c.length)for(var d=c.length-1;d>=0;){var e=shaka.hls.Utils.getFirstTagWithName(c[d].tags,"EXTINF");if(e){b=e.value.split(",");b=Number(b[0]);break}d--}c=this.getRequiredTag_(a.tags,"EXT-X-TARGETDURATION");c=Number(c.value);if(d=shaka.hls.Utils.getFirstTagWithName(a.tags,"EXT-X-PART-INF"))this.partialTargetDuration_=Number(d.getRequiredAttrValue("PART-TARGET"));a=shaka.hls.Utils.getFirstTagWithName(a.tags,
"EXT-X-SERVER-CONTROL");this.lowLatencyMode_&&this.partialTargetDuration_?(this.lastTargetDuration_=this.lowLatencyByterangeOptimization_?this.partialTargetDuration_*5<=b?Math.min(this.partialTargetDuration_,this.lastTargetDuration_):Math.min(b,this.lastTargetDuration_):Math.min(this.partialTargetDuration_,this.lastTargetDuration_),this.lowLatencyPresentationDelay_=a?Number(a.getRequiredAttrValue("PART-HOLD-BACK")):0):(this.lastTargetDuration_=Math.min(b,this.lastTargetDuration_),this.presentationDelay_=
(a=a?a.getAttribute("HOLD-BACK"):null)?Number(a.value):0);this.maxTargetDuration_=Math.max(c,this.maxTargetDuration_)};
shaka.hls.HlsParser.prototype.changePresentationTimelineToLive_=function(a){var b=0;if(this.config_.defaultPresentationDelay)b=this.config_.defaultPresentationDelay;else if(this.lowLatencyPresentationDelay_)b=this.lowLatencyPresentationDelay_;else if(this.presentationDelay_)b=this.presentationDelay_;else for(var c=a.segments.length,d=c-Math.min(c,this.config_.hls.liveSegmentsDelay);d<c;d++){var e=shaka.hls.Utils.getFirstTagWithName(a.segments[d].tags,"EXTINF");e?(e=e.value.split(","),b+=Number(e[0])):
b+=this.maxTargetDuration_}this.startTime_&&this.startTime_<0&&(b=Math.min(-this.startTime_,b),this.startTime_+=b);this.presentationTimeline_.setPresentationStartTime(0);this.presentationTimeline_.setDelay(b);this.presentationTimeline_.setStatic(!1)};
shaka.hls.HlsParser.prototype.getInitSegmentReference_=function(a,b,c,d){var e=shaka.hls.Utils.getFirstTagWithName(b,"EXT-X-MAP");if(!e)return null;var f=e.getRequiredAttrValue("URI"),g=shaka.hls.Utils.constructSegmentUris(c(),f,d);f=[g.toString(),e.getAttributeValue("BYTERANGE","")].join("-");if(!this.mapTagToInitSegmentRefMap_.has(f)){var h=void 0,k=null,l=!1;b=(0,$jscomp.makeIterator)(b);for(var m=b.next();!m.done;m=b.next())m=m.value,m.name=="EXT-X-KEY"?(l=m.getRequiredAttrValue("METHOD"),this.isAesMethod_(l)&&
m.id<e.id?(l=!1,h=this.parseAESDrmTag_(m,a,c,d)):l=l!="NONE"):m.name=="EXT-X-BYTERANGE"&&m.id<e.id&&(k=m);a=this.createInitSegmentReference_(g,e,k,h,l);this.mapTagToInitSegmentRefMap_.set(f,a)}return this.mapTagToInitSegmentRefMap_.get(f)};
shaka.hls.HlsParser.prototype.createInitSegmentReference_=function(a,b,c,d,e){var f=0,g=null;b=b.getAttributeValue("BYTERANGE");!b&&c&&(b=c.value);b&&(f=b.split("@"),g=Number(f[0]),f=Number(f[1]),g=f+g-1,d&&(c=g+1-f,c%16&&(g+=16-c%16)));return new shaka.media.InitSegmentReference(function(){return a},f,g,null,null,null,d,e)};
shaka.hls.HlsParser.prototype.createSegmentReference_=function(a,b,c,d,e,f,g,h,k,l){f=shaka.hls.HlsParser;var m=c.tags,n=shaka.hls.Utils.getFirstTagWithName(m,"EXTINF"),p=0,q=0,r=null;c.partialSegments.length&&(this.manifest_.isLowLatency=!0);var t=null;if(b&&b.syncTime)t=b.syncTime+b.endTime-b.startTime;else if(!this.config_.hls.ignoreManifestProgramDateTime){var w=shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-PROGRAM-DATE-TIME");w&&w.value&&(t=shaka.util.TXml.parseDate(w.value),goog.asserts.assert(t!=
null,"EXT-X-PROGRAM-DATE-TIME format not valid"),this.usesProgramDateTime_=!0)}var v=shaka.media.SegmentReference.Status.AVAILABLE;shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-GAP")&&(this.manifest_.gapCount++,v=shaka.media.SegmentReference.Status.MISSING);if(!n){if(c.partialSegments.length==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_REQUIRED_TAG_MISSING,"EXTINF");if(!this.lowLatencyMode_)return null}var u=[];w=!1;var x=
null,z=!1,B=!1;if(this.lowLatencyMode_&&c.partialSegments.length){p=a&&window.ReadableStream&&this.config_.hls.allowLowLatencyByteRangeOptimization;for(var C=t,y={},A=0;A<c.partialSegments.length;y={uris$jscomp$8:void 0,pUri:void 0},A++){var D=c.partialSegments[A],E=A==0?b:u[u.length-1],F=A==0?d:E.endTime,L=Number(D.getAttributeValue("DURATION"))||this.partialTargetDuration_;if(L){var K=F+L,J=0,I=null;D.name=="EXT-X-PRELOAD-HINT"?(J=(J=D.getAttributeValue("BYTERANGE-START"))?Number(J):0,(E=D.getAttributeValue("BYTERANGE-LENGTH"))?
I=J+Number(E)-1:J&&(I=Number.MAX_SAFE_INTEGER)):(J=D.getAttributeValue("BYTERANGE"),I=(0,$jscomp.makeIterator)(this.parseByteRange_(E,J)),J=I.next().value,I=I.next().value);y.pUri=D.getAttributeValue("URI");if(y.pUri){E=shaka.media.SegmentReference.Status.AVAILABLE;D.getAttributeValue("GAP")=="YES"&&(this.manifest_.gapCount++,E=shaka.media.SegmentReference.Status.MISSING,z=!0);y.uris$jscomp$8=null;var G=function(H){return function(){H.uris$jscomp$8==null&&(goog.asserts.assert(H.pUri,"Partial uri should be defined!"),
H.uris$jscomp$8=shaka.hls.Utils.constructSegmentUris(h(),H.pUri,e));return H.uris$jscomp$8}}(y);p&&J>=0&&I!=null&&(x=G,w=!0);F=new shaka.media.SegmentReference(F,K,G,J,I,a,0,0,Infinity,[],"",null,C,E,l);D.name=="EXT-X-PRELOAD-HINT"&&(F.markAsPreload(),B=!0);D.getAttributeValue("INDEPENDENT")!="YES"&&A>0&&F.markAsNonIndependent();D=k;D||(u.length&&u[0].mimeType?D=u[0].mimeType:y.pUri&&(D=shaka.hls.HlsParser,y=shaka.net.NetworkingUtils.getExtension(y.pUri),D=D.EXTENSION_MAP_BY_CONTENT_TYPE_.get(g).get(y)||
null));D&&(F.mimeType=D,f.MIME_TYPES_WITHOUT_INIT_SEGMENT_.has(D)&&(F.initSegmentReference=null));u.push(F);C&&(C+=L)}}}}if(n){n=n.value.split(",");n=Number(n[0]);if(n==0)return null;p=d+n}else if(u.length)p=u[u.length-1].endTime;else return null;w&&(z||u[0].startByte!=0?(w=!1,x=null):u=[]);(z=shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-BYTERANGE"))?(r=(0,$jscomp.makeIterator)(this.parseByteRange_(b,z.value)),q=r.next().value,r=r.next().value):u.length&&(q=u[0].startByte,r=u[u.length-1].endByte);
b="";z=null;g==shaka.util.ManifestParserUtils.ContentType.IMAGE&&(b="1x1",g=shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-TILES"))&&(b=g.getRequiredAttrValue("LAYOUT"),(g=g.getAttributeValue("DURATION"))&&(z=Number(g)));var M=null;a=new shaka.media.SegmentReference(d,p,function(){if(x)return x();M==null&&(M=shaka.hls.Utils.constructSegmentUris(h(),c.verbatimSegmentUri,e));return M||[]},q,r,a,0,0,Infinity,u,b,z,t,v,l,u.length>0&&!!c.verbatimSegmentUri);k&&(a.mimeType=k,f.MIME_TYPES_WITHOUT_INIT_SEGMENT_.has(k)&&
(a.initSegmentReference=null));w&&(this.lowLatencyByterangeOptimization_=!0,a.markAsByterangeOptimization(),B&&a.markAsPreload());return a};shaka.hls.HlsParser.prototype.parseByteRange_=function(a,b){var c=0,d=null;b&&(c=b.split("@"),b=Number(c[0]),c[1]?c=Number(c[1]):(goog.asserts.assert(a,"Cannot refer back to previous HLS segment!"),c=a.endByte+1),d=c+b-1);return[c,d]};
shaka.hls.HlsParser.prototype.processDateRangeTags_=function(a,b,c,d){var e=shaka.util.ManifestParserUtils.ContentType;if(b==e.VIDEO||b==e.AUDIO){e=shaka.hls.Utils;var f=this.presentationTimeline_.getInitialProgramDateTime();if(f&&!this.ignoreManifestProgramDateTimeFor_(b))for(a=shaka.hls.Utils.filterTagsByName(a,"EXT-X-DATERANGE"),a=a.filter(function(E){return E.getAttribute("START-DATE")!=null}).sort(function(E,F){E=E.getRequiredAttrValue("START-DATE");F=F.getRequiredAttrValue("START-DATE");return E<
F?-1:E>F?1:0}),b=0;b<a.length;b++){var g=a[b];try{var h=g.getRequiredAttrValue("START-DATE"),k=shaka.util.TXml.parseDate(h);if(!isNaN(k)){goog.asserts.assert(k!=null,"Start date should not be null!");var l=Math.max(0,k-f),m=null,n=g.getAttributeValue("END-DATE");if(n){var p=shaka.util.TXml.parseDate(n);if(!isNaN(p)&&(goog.asserts.assert(p!=null,"End date should not be null!"),m=p-f,m<0))continue}if(m==null){var q=g.getAttributeValue("DURATION")||g.getAttributeValue("PLANNED-DURATION");if(q){var r=
parseFloat(q);isNaN(r)||(m=l+r);if(k-f+r<0)continue}}var t=g.getAttributeValue("CLASS")||"com.apple.quicktime.HLS",w=g.getAttributeValue("END-ON-NEXT")=="YES";if(m==null&&w){for(var v=b+1;v<a.length;v++){var u=a[v].getAttributeValue("CLASS")||"com.apple.quicktime.HLS";if(t==u){var x=a[v].getRequiredAttrValue("START-DATE"),z=shaka.util.TXml.parseDate(x);if(!isNaN(z)&&z&&z>k){m=Math.max(0,z-f);break}}}if(m==null)continue}v=["CLASS","START-DATE","END-DATE","DURATION","END-ON-NEXT"];for(var B=[],C=(0,$jscomp.makeIterator)(g.attributes),
y=C.next();!y.done;y=C.next()){var A=y.value;if(!v.includes(A.name)){var D=e.variableSubstitution(A.value,c);if(A.name=="X-ASSET-URI"||A.name=="X-ASSET-LIST")D=e.constructSegmentUris(d(),A.value,c)[0];B.push({key:A.name,description:"",data:D,mimeType:null,pictureType:null})}}if(B.length>1)this.playerInterface_.onMetadata(t,l,m,B)}}catch(E){shaka.log.warning("Ignoring DATERANGE with errors",g.toString())}}}};
shaka.hls.HlsParser.prototype.createSegments_=function(a,b,c,d,e){var f=a.segments;goog.asserts.assert(f.length,"Playlist should have segments!");var g=null,h=null,k=null,l=null,m=void 0,n=shaka.hls.Utils.getFirstTagWithNameAsNumber(a.tags,"EXT-X-DISCONTINUITY-SEQUENCE",-1),p=shaka.hls.Utils.getFirstTagWithNameAsNumber(a.tags,"EXT-X-MEDIA-SEQUENCE",0),q=shaka.hls.Utils.getFirstTagWithName(a.tags,"EXT-X-SKIP"),r=q?Number(q.getAttributeValue("SKIPPED-SEGMENTS")):0,t=p+r,w=0;this.isLive_()&&b.has(t)&&
(w=b.get(t));w===0&&this.presentationType_==shaka.hls.HlsParser.PresentationType_.LIVE&&b.size>0&&!b.has(t)&&this.presentationTimeline_.getPresentationStartTime()!=null&&(w=this.presentationTimeline_.getSegmentAvailabilityStart());var v=[],u=null;q=[];for(var x=function(D){var E=shaka.hls.HlsParser;D=shaka.net.NetworkingUtils.getExtension(D);if(!D)return null;var F=E.EXTENSION_MAP_BY_CONTENT_TYPE_.get(e).get(D);F||(F=E.RAW_FORMATS_TO_MIME_TYPES_.get(D));return F},z=0;z<f.length;z++){var B=f[z];(t=
shaka.hls.Utils.getFirstTagWithName(B.tags,"EXT-X-MAP"))&&t.id!==h&&(g=this.getInitSegmentReference_(a,B.tags,d,c),h=t.id);t=B.verbatimSegmentUri;var C="";t&&(C=shaka.net.NetworkingUtils.getExtension(t));C!==l&&(k=x(t),l=C);C=z==0?w:u.endTime;t=p+r+z;shaka.hls.Utils.getFirstTagWithName(B.tags,"EXT-X-DISCONTINUITY")&&(n++,u&&u.initSegmentReference&&(u.initSegmentReference.boundaryEnd=C));for(var y=(0,$jscomp.makeIterator)(B.tags),A=y.next();!A.done;A=y.next())A=A.value,A.name=="EXT-X-KEY"&&(m=this.isAesMethod_(A.getRequiredAttrValue("METHOD"))?
this.parseAESDrmTag_(A,a,d,c):void 0);b.set(t,C);if(C=this.createSegmentReference_(g,u,B,C,c,a,e,d,k,m)){if(u=shaka.hls.Utils.getFirstTagWithNameAsNumber(B.tags,"EXT-X-BITRATE"))q.push({bitrate:u,duration:C.endTime-C.startTime}),C.bandwidth=u;else if(C.endByte){if(B=C.getSize())u=C.endTime-C.startTime,B=B*8/u/1E3,q.push({bitrate:B,duration:u}),C.bandwidth=B}else q.length&&(u=q.pop(),u.duration+=C.endTime-C.startTime,q.push(u),C.bandwidth=u.bitrate);if(C.bandwidth)for(u=(0,$jscomp.makeIterator)(C.partialReferences),
B=u.next();!B.done;B=u.next())B.value.bandwidth=C.bandwidth;u=C;C.discontinuitySequence=n;this.ignoreManifestProgramDateTimeFor_(e)&&this.minSequenceNumber_!=null&&t<this.minSequenceNumber_||v.push(C)}}a=void 0;q.length&&(a=q.reduce(function(D,E){return D+E.duration},0),a=Math.round(q.reduce(function(D,E){return D+E.bitrate*E.duration},0)/a*1E3));if(q=v.some(function(D){return D.syncTime!=null}))for(b={},c=0;c<v.length;b={forwardI:void 0,forwardAdd:void 0,backwardI:void 0,reference$jscomp$14:void 0,
backwardAdd:void 0},c++)if(b.reference$jscomp$14=v[c],b.reference$jscomp$14.syncTime==null)for(b.forwardAdd=0,b.forwardI=c,d=function(D){return function(){var E=v[D.forwardI];if(E){if(E.syncTime!=null)return E.syncTime+D.forwardAdd;D.forwardAdd-=E.endTime-E.startTime;D.forwardI+=1}return null}}(b),b.backwardAdd=0,b.backwardI=c,f=function(D){return function(){var E=v[D.backwardI];if(E){E!=D.reference$jscomp$14&&(D.backwardAdd+=E.endTime-E.startTime);if(E.syncTime!=null)return E.syncTime+D.backwardAdd;
--D.backwardI}return null}}(b);b.reference$jscomp$14.syncTime==null;)b.reference$jscomp$14.syncTime=f(),b.reference$jscomp$14.syncTime==null&&(b.reference$jscomp$14.syncTime=d());if(q)for(b=(0,$jscomp.makeIterator)(v),c=b.next();!c.done;c=b.next())for(d=c.value,c=d.syncTime,d=(0,$jscomp.makeIterator)(d.partialReferences),f=d.next();!f.done;f=d.next())f=f.value,f.syncTime=c,c+=f.endTime-f.startTime;b=this.lowestSyncTime_;if(q&&b!=Infinity&&!this.ignoreManifestProgramDateTimeFor_(e))for(q=(0,$jscomp.makeIterator)(v),
c=q.next();!c.done;c=q.next())c.value.syncAgainst(b);return{segments:v,bandwidth:a}};shaka.hls.HlsParser.prototype.guessMimeTypeBeforeLoading_=function(a,b){if(a==shaka.util.ManifestParserUtils.ContentType.TEXT){if(b=="vtt"||b=="wvtt")return"text/vtt";if(b&&b!=="")return"application/mp4"}return a!=shaka.util.ManifestParserUtils.ContentType.IMAGE||b&&b!="jpeg"?a==shaka.util.ManifestParserUtils.ContentType.AUDIO&&b=="mp4a.40.34"?"audio/mpeg":b=="mjpg"?"application/mp4":null:"image/jpeg"};
shaka.hls.HlsParser.prototype.guessMimeTypeFallback_=function(a){return a==shaka.util.ManifestParserUtils.ContentType.TEXT?"text/vtt":shaka.hls.HlsParser.EXTENSION_MAP_BY_CONTENT_TYPE_.get(a).get("mp4")};shaka.hls.HlsParser.prototype.getAvailableSegment_=function(a){goog.asserts.assert(a.length,"Should have segments!");for(var b=this.isLive_()?Math.trunc((a.length-1)/2):0,c=a[b];c.getStatus()==shaka.media.SegmentReference.Status.MISSING&&b+1<a.length;)b++,c=a[b];return{segment:c,segmentIndex:b}};
shaka.hls.HlsParser.prototype.guessMimeType_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.nextAddress){case 1:e=shaka.hls.HlsParser;f=shaka.net.NetworkingEngine.RequestType.SEGMENT;g=d.getAvailableSegment_(c);h=g.segment;if(h.status==shaka.media.SegmentReference.Status.MISSING)return u.return(d.guessMimeTypeFallback_(a));l=h.getUris();if(m=shaka.net.NetworkingUtils.getExtension(l[0]))if(n=e.EXTENSION_MAP_BY_CONTENT_TYPE_.get(a),
(p=n.get(m))||(p=e.RAW_FORMATS_TO_MIME_TYPES_.get(m)))return u.return(p);if(k=d.guessMimeTypeBeforeLoading_(a,b))return u.return(k);r=shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT;t=shaka.net.NetworkingEngine.makeRequest(l,d.config_.retryParameters);u.setCatchFinallyBlocks(2);t.method="HEAD";return u.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,4);case 4:w=u.yieldResult;q=w.headers["content-type"];u.leaveTryBlock(3);break;case 2:v=u.enterCatchBlock();if(!v||v.code!=shaka.util.Error.Code.HTTP_ERROR&&
v.code!=shaka.util.Error.Code.BAD_HTTP_STATUS){u.jumpTo(3);break}t.method="GET";d.config_.hls.allowRangeRequestsToGuessMimeType&&(t.headers.Range="bytes=0-0");return u.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,6);case 6:w=u.yieldResult,q=w.headers["content-type"];case 3:if(!q){u.jumpTo(7);break}k=q.toLowerCase().split(";")[0];if(k!="application/octet-stream"){u.jumpTo(8);break}if(w.data.byteLength){u.jumpTo(9);break}t.method="GET";return u.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,
10);case 10:w=u.yieldResult;case 9:shaka.util.TsParser.probe(shaka.util.BufferUtils.toUint8(w.data))&&(k="video/mp2t");case 8:if(k!="application/octet-stream")return u.return(k);case 7:return u.return(d.guessMimeTypeFallback_(a))}})};shaka.hls.HlsParser.prototype.getRequiredTag_=function(a,b){a=shaka.hls.Utils.getFirstTagWithName(a,b);if(!a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_REQUIRED_TAG_MISSING,b);return a};
shaka.hls.HlsParser.prototype.addVideoAttributes_=function(a,b,c,d,e,f,g){a&&(a.width=Number(b)||void 0,a.height=Number(c)||void 0,a.frameRate=Number(d)||void 0,a.hdr=e||void 0,a.videoLayout=f||void 0,a.colorGamut=g||void 0)};
shaka.hls.HlsParser.prototype.requestManifest_=function(a,b){var c=shaka.net.NetworkingEngine.RequestType.MANIFEST;a=shaka.net.NetworkingEngine.makeRequest(a,this.config_.retryParameters);return this.makeNetworkRequest_(a,c,{type:b?shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_PLAYLIST:shaka.net.NetworkingEngine.AdvancedRequestType.MASTER_PLAYLIST})};
shaka.hls.HlsParser.prototype.onUpdate_=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.nextAddress){case 1:shaka.log.info("Updating manifest...");goog.asserts.assert(a.getUpdatePlaylistDelay_()>0,"We should only call |onUpdate_| when we are suppose to be updating.");if(!a.playerInterface_)return h.return();h.setCatchFinallyBlocks(2);b=Date.now();return h.yield(a.update(),4);case 4:c=Date.now();a.isLive_()&&(d=(c-b)/1E3,a.averageUpdateDuration_.sample(1,
d),e=a.config_.updatePeriod>0?a.config_.updatePeriod:a.getUpdatePlaylistDelay_(),f=Math.max(0,e-a.averageUpdateDuration_.getEstimate()),a.updatePlaylistTimer_.tickAfter(f));h.leaveTryBlock(3);break;case 2:g=h.enterCatchBlock();if(!a.playerInterface_)return h.return();goog.asserts.assert(g instanceof shaka.util.Error,"Should only receive a Shaka error");if(a.config_.raiseFatalErrorOnManifestUpdateRequestFailure)return a.playerInterface_.onError(g),h.return();g.severity=shaka.util.Error.Severity.RECOVERABLE;
a.playerInterface_.onError(g);a.updatePlaylistTimer_.tickAfter(.1);case 3:if(!a.playerInterface_)return h.return();a.playerInterface_.onManifestUpdated();h.jumpToEnd()}})};shaka.hls.HlsParser.prototype.isLive_=function(){return this.presentationType_!=shaka.hls.HlsParser.PresentationType_.VOD};shaka.hls.HlsParser.prototype.getUpdatePlaylistDelay_=function(){return this.lastTargetDuration_};
shaka.hls.HlsParser.prototype.setPresentationType_=function(a){this.presentationType_=a;this.presentationTimeline_&&this.presentationTimeline_.setStatic(!this.isLive_());this.isLive_()||this.updatePlaylistTimer_.stop()};
shaka.hls.HlsParser.prototype.makeNetworkRequest_=function(a,b,c){if(!this.operationManager_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED);c||(c={});c.isPreload=this.isPreloadFn_();a=this.playerInterface_.networkingEngine.request(b,a,c);this.operationManager_.manage(a);return a};shaka.hls.HlsParser.prototype.isAesMethod_=function(a){return a=="AES-128"||a=="AES-256"||a=="AES-256-CTR"};
shaka.hls.HlsParser.prototype.fairplayDrmParser_=function(a,b,c){var d=this,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1){if(b=="video/mp2t")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);if(shaka.drm.DrmUtils.isMediaKeysPolyfilled("apple"))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);e=a.getRequiredAttrValue("METHOD");f=["SAMPLE-AES","SAMPLE-AES-CTR"];if(!f.includes(e))return shaka.log.error("FairPlay in HLS is only supported with [",f.join(", "),"], not",e),m.return(null);g="cenc";e=="SAMPLE-AES"&&(g="cbcs");h=a.getRequiredAttrValue("URI");k=shaka.util.ManifestParserUtils.createDrmInfo("com.apple.fps",g,[{initDataType:"sinf",initData:new Uint8Array(0),keyId:null}],h);return(l=shaka.drm.FairPlay.defaultGetKeyId(h))||
!c?m.jumpTo(2):m.yield(d.getKeyIdFromInitSegment_(c),3)}m.nextAddress!=2&&(l=m.yieldResult);l&&k.keyIds.add(l);return m.return(k)})};
shaka.hls.HlsParser.prototype.widevineDrmParser_=function(a,b,c){c=a.getRequiredAttrValue("METHOD");b=["SAMPLE-AES","SAMPLE-AES-CTR"];if(!b.includes(c))return shaka.log.error("Widevine in HLS is only supported with [",b.join(", "),"], not",c),Promise.resolve(null);b="cenc";c=="SAMPLE-AES"&&(b="cbcs");var d=a.getRequiredAttrValue("URI");c=shaka.net.DataUriPlugin.parseRaw(d.split("?")[0]);d=d.split("?")[0];this.psshToInitData_.has(d)||(c=shaka.util.BufferUtils.toUint8(c.data),this.psshToInitData_.set(d,
c));b=shaka.util.ManifestParserUtils.createDrmInfo("com.widevine.alpha",b,[{initDataType:"cenc",initData:this.psshToInitData_.get(d)}]);if(a=a.getAttributeValue("KEYID"))a=a.toLowerCase(),goog.asserts.assert(a.startsWith("0x"),"Incorrect KEYID format!"),b.keyIds.add(a.substr(2));return Promise.resolve(b)};
shaka.hls.HlsParser.prototype.playreadyDrmParser_=function(a,b,c){c=a.getRequiredAttrValue("METHOD");b=["SAMPLE-AES","SAMPLE-AES-CTR"];if(!b.includes(c))return shaka.log.error("PlayReady in HLS is only supported with [",b.join(", "),"], not",c),Promise.resolve(null);b="cenc";c=="SAMPLE-AES"&&(b="cbcs");a=a.getRequiredAttrValue("URI");a=shaka.net.DataUriPlugin.parseRaw(a.split("?")[0]);a=shaka.util.BufferUtils.toUint8(a.data);c=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,
149]);var d=new Set;c=shaka.util.Pssh.createPssh(a,c,d,0);b=shaka.util.ManifestParserUtils.createDrmInfo("com.microsoft.playready",b,[{initDataType:"cenc",initData:c}]);if(a=shaka.util.TXml.parseXmlString(["<PLAYREADY>",shaka.util.Uint8ArrayUtils.toBase64(a),"</PLAYREADY>"].join("\n")))b.licenseServerUri=shaka.drm.PlayReady.getLicenseUrl(a);return Promise.resolve(b)};
shaka.hls.HlsParser.prototype.wiseplayDrmParser_=function(a,b,c){c=a.getRequiredAttrValue("METHOD");b=["SAMPLE-AES","SAMPLE-AES-CTR"];if(!b.includes(c))return shaka.log.error("WisePlay in HLS is only supported with [",b.join(", "),"], not",c),Promise.resolve(null);b="cenc";c=="SAMPLE-AES"&&(b="cbcs");var d=a.getRequiredAttrValue("URI");c=shaka.net.DataUriPlugin.parseRaw(d.split("?")[0]);d=d.split("?")[0];this.psshToInitData_.has(d)||(c=shaka.util.BufferUtils.toUint8(c.data),this.psshToInitData_.set(d,
c));b=shaka.util.ManifestParserUtils.createDrmInfo("com.huawei.wiseplay",b,[{initDataType:"cenc",initData:this.psshToInitData_.get(d)}]);if(a=a.getAttributeValue("KEYID"))a=a.toLowerCase(),goog.asserts.assert(a.startsWith("0x"),"Incorrect KEYID format!"),b.keyIds.add(a.substr(2));return Promise.resolve(b)};
shaka.hls.HlsParser.prototype.identityDrmParser_=function(a,b,c,d,e){var f=this,g,h,k,l,m,n,p,q,r,t,w,v,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.nextAddress){case 1:if(b=="video/mp2t")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED);if(shaka.drm.DrmUtils.isMediaKeysPolyfilled("apple"))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);g=a.getRequiredAttrValue("METHOD");h=["SAMPLE-AES","SAMPLE-AES-CTR"];if(!h.includes(g))return shaka.log.error("Identity (ClearKey) in HLS is only supported with [",h.join(", "),"], not",g),x.return(null);k=shaka.hls.Utils.constructSegmentUris(c(),a.getRequiredAttrValue("URI"),e);if(k[0].startsWith("data:text/plain;base64,")){l=shaka.util.Uint8ArrayUtils.toHex(shaka.util.Uint8ArrayUtils.fromBase64(k[0].split("data:text/plain;base64,").pop()));
x.jumpTo(2);break}m=k.sort().join("");f.identityKeyMap_.has(m)||(n=shaka.net.NetworkingEngine.RequestType.KEY,p=shaka.net.NetworkingEngine.makeRequest(k,f.config_.retryParameters),q=f.makeNetworkRequest_(p,n).promise,f.identityKeyMap_.set(m,q));return x.yield(f.identityKeyMap_.get(m),3);case 3:r=x.yieldResult,l=shaka.util.Uint8ArrayUtils.toHex(r.data);case 2:t="00000000000000000000000000000000";if(!d){x.jumpTo(4);break}return x.yield(f.getKeyIdFromInitSegment_(d),5);case 5:(w=x.yieldResult)&&(t=w);
case 4:return v=new Map,v.set(t,l),u="cenc",g=="SAMPLE-AES"&&(u="cbcs"),x.return(shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys(v,u))}})};
shaka.hls.HlsParser.prototype.getKeyIdFromInitSegment_=function(a){var b=this,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1){c=null;if(b.initSegmentToKidMap_.has(a))return c=b.initSegmentToKidMap_.get(a),h.jumpTo(2);d=shaka.util.Networking.createSegmentRequest(a.getUris(),a.getStartByte(),a.getEndByte(),b.config_.retryParameters);e=shaka.net.NetworkingEngine.RequestType.SEGMENT;f=shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT;return h.yield(b.makeNetworkRequest_(d,
e,{type:f}).promise,3)}h.nextAddress!=2&&(g=h.yieldResult,a.setSegmentData(g.data),c=shaka.media.SegmentUtils.getDefaultKID(g.data),b.initSegmentToKidMap_.set(a,c));return h.return(c)})};goog.exportSymbol("shaka.hls.HlsParser",shaka.hls.HlsParser);shaka.hls.HlsParser.RAW_FORMATS_TO_MIME_TYPES_=(new Map).set("aac","audio/aac").set("ac3","audio/ac3").set("ec3","audio/ec3").set("mp3","audio/mpeg");
shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_=(new Map).set("mp4","audio/mp4").set("mp4a","audio/mp4").set("m4s","audio/mp4").set("m4i","audio/mp4").set("m4a","audio/mp4").set("m4f","audio/mp4").set("cmfa","audio/mp4").set("ts","video/mp2t").set("tsa","video/mp2t");
shaka.hls.HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_=(new Map).set("mp4","video/mp4").set("mp4v","video/mp4").set("m4s","video/mp4").set("m4i","video/mp4").set("m4v","video/mp4").set("m4f","video/mp4").set("cmfv","video/mp4").set("ts","video/mp2t").set("tsv","video/mp2t");
shaka.hls.HlsParser.TEXT_EXTENSIONS_TO_MIME_TYPES_=(new Map).set("mp4","application/mp4").set("m4s","application/mp4").set("m4i","application/mp4").set("m4f","application/mp4").set("cmft","application/mp4").set("vtt","text/vtt").set("webvtt","text/vtt").set("ttml","application/ttml+xml");shaka.hls.HlsParser.IMAGE_EXTENSIONS_TO_MIME_TYPES_=(new Map).set("jpg","image/jpeg").set("png","image/png").set("svg","image/svg+xml").set("webp","image/webp").set("avif","image/avif");
shaka.hls.HlsParser.EXTENSION_MAP_BY_CONTENT_TYPE_=(new Map).set("audio",shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_).set("video",shaka.hls.HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_).set("text",shaka.hls.HlsParser.TEXT_EXTENSIONS_TO_MIME_TYPES_).set("image",shaka.hls.HlsParser.IMAGE_EXTENSIONS_TO_MIME_TYPES_);shaka.hls.HlsParser.MIME_TYPES_WITHOUT_INIT_SEGMENT_=new Set(["video/mp2t"].concat((0,$jscomp.arrayFromIterable)(shaka.util.MimeUtils.RAW_FORMATS)));
shaka.hls.HlsParser.PresentationType_={VOD:"VOD",EVENT:"EVENT",LIVE:"LIVE"};shaka.hls.HlsParser.FAKE_MUXED_URL_="shaka://hls-muxed";shaka.media.ManifestParser.registerParserByMime("application/x-mpegurl",function(){return new shaka.hls.HlsParser});shaka.media.ManifestParser.registerParserByMime("application/vnd.apple.mpegurl",function(){return new shaka.hls.HlsParser});shaka.media.AdaptationSet=function(a,b,c){c=c===void 0?!0:c;this.root_=a;this.variants_=new Set([a]);b=b||[];a=(0,$jscomp.makeIterator)(b);for(b=a.next();!b.done;b=a.next())this.add(b.value,c)};shaka.media.AdaptationSet.prototype.add=function(a,b){if(this.canInclude(a,b))return this.variants_.add(a),!0;shaka.log.warning("Rejecting variant - not compatible with root.");return!1};
shaka.media.AdaptationSet.prototype.canInclude=function(a,b){return shaka.media.AdaptationSet.areAdaptable(this.root_,a,b===void 0?!0:b)};
shaka.media.AdaptationSet.areAdaptable=function(a,b,c){var d=shaka.media.AdaptationSet;if(!!a.audio!=!!b.audio||!!a.video!=!!b.video||a.language!=b.language)return!1;goog.asserts.assert(!!a.audio==!!b.audio,"Both should either have audio or not have audio.");if(a.audio&&b.audio&&!d.areAudiosCompatible_(a.audio,b.audio,c))return!1;goog.asserts.assert(!!a.video==!!b.video,"Both should either have video or not have video.");return a.video&&b.video&&!d.areVideosCompatible_(a.video,b.video,c)?!1:!0};
shaka.media.AdaptationSet.prototype.values=function(){return this.variants_.values()};shaka.media.AdaptationSet.areAudiosCompatible_=function(a,b,c){var d=shaka.media.AdaptationSet;return(!a.channelsCount||!b.channelsCount||a.channelsCount>2||b.channelsCount>2)&&a.channelsCount!=b.channelsCount||a.spatialAudio!==b.spatialAudio||c&&!d.canTransitionBetween_(a,b)||!d.areRolesEqual_(a.roles,b.roles)||a.groupId!==b.groupId?!1:!0};
shaka.media.AdaptationSet.areVideosCompatible_=function(a,b,c){var d=shaka.media.AdaptationSet;return c&&!d.canTransitionBetween_(a,b)||!d.areRolesEqual_(a.roles,b.roles)?!1:!0};
shaka.media.AdaptationSet.canTransitionBetween_=function(a,b){if(a.mimeType!=b.mimeType)return!1;a=shaka.util.MimeUtils.splitCodecs(a.codecs).map(function(d){return shaka.util.MimeUtils.getCodecBase(d)});b=shaka.util.MimeUtils.splitCodecs(b.codecs).map(function(d){return shaka.util.MimeUtils.getCodecBase(d)});if(a.length!=b.length)return!1;a.sort();b.sort();for(var c=0;c<a.length;c++)if(a[c]!=b[c])return!1;return!0};
shaka.media.AdaptationSet.areRolesEqual_=function(a,b){a=new Set(a);b=new Set(b);a.delete("main");b.delete("main");if(a.size!=b.size)return!1;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(!b.has(c.value))return!1;return!0};goog.exportSymbol("shaka.media.AdaptationSet",shaka.media.AdaptationSet);shaka.util.MediaElementEvent={CAN_PLAY:"canplay",CAN_PLAY_THROUGH:"canplaythrough",DURATION_CHANGE:"durationchange",ENCRYPTED:"encrypted",ENDED:"ended",LOADED_DATA:"loadeddata",LOADED_METADATA:"loadedmetadata",PAUSE:"pause",PLAY:"play",PLAYING:"playing",PROGRESS:"progress",RATE_CHANGE:"ratechange",SEEKED:"seeked",SEEKING:"seeking",STALLED:"stalled",TIME_UPDATE:"timeupdate",VOLUME_CHANGE:"volumechange",WAITING:"waiting"};shaka.media.BufferingObserver=function(a,b){var c=shaka.media.BufferingObserver.State;this.previousState_=c.SATISFIED;this.thresholds_=(new Map).set(c.SATISFIED,b).set(c.STARVING,a);this.lastRebufferTime_=0};shaka.media.BufferingObserver.prototype.setThresholds=function(a,b){var c=shaka.media.BufferingObserver.State;this.thresholds_.set(c.SATISFIED,b).set(c.STARVING,a)};
shaka.media.BufferingObserver.prototype.update=function(a,b){var c=shaka.media.BufferingObserver.State,d=this.thresholds_.get(this.previousState_);return this.setState(b||a>=d&&a>0?c.SATISFIED:c.STARVING)};shaka.media.BufferingObserver.prototype.setState=function(a){var b=shaka.media.BufferingObserver.State,c=this.previousState_!==a;this.previousState_=a;c&&a===b.SATISFIED&&(this.lastRebufferTime_=Date.now());return c};shaka.media.BufferingObserver.prototype.getState=function(){return this.previousState_};
shaka.media.BufferingObserver.prototype.getLastRebufferTime=function(){return this.lastRebufferTime_};shaka.media.BufferingObserver.prototype.resetLastRebufferTime=function(){this.lastRebufferTime_=0};
shaka.media.BufferingObserver.prototype.reportEvent=function(a){var b=void 0;switch(a){case shaka.util.MediaElementEvent.SEEKING:case shaka.util.MediaElementEvent.WAITING:b=shaka.media.BufferingObserver.State.STARVING;break;case shaka.util.MediaElementEvent.CAN_PLAY_THROUGH:case shaka.util.MediaElementEvent.PLAYING:case shaka.util.MediaElementEvent.SEEKED:b=shaka.media.BufferingObserver.State.SATISFIED}return b!==void 0?this.setState(b):!1};shaka.media.BufferingObserver.State={STARVING:0,SATISFIED:1};shaka.util.Mp4Generator=function(a){this.streamInfos_=a};shaka.util.Mp4Generator.prototype.initSegment=function(){var a=shaka.util.Mp4Generator,b=this.moov_();a=a.FTYP_.value();var c=new Uint8Array(a.byteLength+b.byteLength);c.set(a);c.set(b,a.byteLength);return c};
shaka.util.Mp4Generator.prototype.moov_=function(){goog.asserts.assert(this.streamInfos_.length>0,"StreamInfos must have elements");for(var a=shaka.util.Mp4Generator,b=[],c=(0,$jscomp.makeIterator)(this.streamInfos_),d=c.next();!d.done;d=c.next())b.push(this.trak_(d.value));b=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(b));c=this.streamInfos_[0];return a.box("moov",this.mvhd_(c),b,this.mvex_(),this.pssh_(c))};
shaka.util.Mp4Generator.prototype.mvhd_=function(a){var b=shaka.util.Mp4Generator,c=a.duration*a.timescale,d=Math.floor(c/(b.UINT32_MAX_+1));c=Math.floor(c%(b.UINT32_MAX_+1));a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.timescale,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4)),[0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return b.box("mvhd",a)};shaka.util.Mp4Generator.prototype.trak_=function(a){return shaka.util.Mp4Generator.box("trak",this.tkhd_(a),this.mdia_(a))};
shaka.util.Mp4Generator.prototype.tkhd_=function(a){var b=shaka.util.Mp4Generator,c=a.id+1,d=a.stream.width||0,e=a.stream.height||0;a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO&&(e=d=0);var f=a.duration*a.timescale;a=Math.floor(f/(b.UINT32_MAX_+1));f=Math.floor(f%(b.UINT32_MAX_+1));c=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4)),[0,0,0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(f,
4)),[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(e,2)),[0,0]));return b.box("tkhd",c)};shaka.util.Mp4Generator.prototype.mdia_=function(a){return shaka.util.Mp4Generator.box("mdia",this.mdhd_(a),this.hdlr_(a),this.minf_(a))};
shaka.util.Mp4Generator.prototype.mdhd_=function(a){var b=shaka.util.Mp4Generator,c=a.duration*a.timescale,d=Math.floor(c/(b.UINT32_MAX_+1));c=Math.floor(c%(b.UINT32_MAX_+1));var e=a.stream.language;e=e.charCodeAt(0)-96<<10|e.charCodeAt(1)-96<<5|e.charCodeAt(2)-96;a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.timescale,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,
4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(e,2)),[0,0]));return b.box("mdhd",a)};shaka.util.Mp4Generator.prototype.hdlr_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType,d=new Uint8Array([]);switch(a.type){case c.VIDEO:d=b.HDLR_TYPES_.video.value();break;case c.AUDIO:d=b.HDLR_TYPES_.audio.value()}return b.box("hdlr",d)};
shaka.util.Mp4Generator.prototype.minf_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType;switch(a.type){case c.VIDEO:return b.box("minf",b.box("vmhd",b.VMHD_.value()),b.DINF_.value(),this.stbl_(a));case c.AUDIO:return b.box("minf",b.box("smhd",b.SMHD_.value()),b.DINF_.value(),this.stbl_(a))}return new Uint8Array([])};
shaka.util.Mp4Generator.prototype.stbl_=function(a){var b=shaka.util.Mp4Generator;return b.box("stbl",this.stsd_(a),b.box("stts",b.STTS_.value()),b.box("stsc",b.STSC_.value()),b.box("stsz",b.STSZ_.value()),b.box("stco",b.STCO_.value()))};
shaka.util.Mp4Generator.prototype.stsd_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType,d="aac";a.codecs.includes("mp3")?d="mp3":a.codecs.includes("ac-3")?d=shaka.device.DeviceFactory.getDevice().requiresEC3InitSegments()?"ec-3":"ac-3":a.codecs.includes("ec-3")?d="ec-3":a.codecs.includes("opus")&&(d="opus");var e=new Uint8Array([]);switch(a.type){case c.VIDEO:a.codecs.includes("avc1")?e=this.avc1_(a):a.codecs.includes("hvc1")&&(e=this.hvc1_(a));break;case c.AUDIO:e=
d=="mp3"?this.mp3_(a):d=="ac-3"?this.ac3_(a):d=="ec-3"?this.ec3_(a):d=="opus"?this.opus_(a):this.mp4a_(a)}return b.box("stsd",b.STSD_.value(),e)};
shaka.util.Mp4Generator.prototype.avc1_=function(a){var b=shaka.util.Mp4Generator,c=a.stream.width||0,d=a.stream.height||0;var e=a.videoConfig.byteLength>0?b.box("avcC",a.videoConfig):b.box("avcC",this.avcC_(a));c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,2)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,
45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]));d="avc1";var f=this.pasp_(a),g=new Uint8Array([]);a.encrypted&&(g=this.sinf(a.stream,a.codecs),d="encv");return b.box(d,c,e,f,g)};
shaka.util.Mp4Generator.prototype.avcC_=function(a){for(var b=7,c=[],d=[],e=0,f=0,g=0,h=0;h<a.videoNalus.length;h++){var k=this.hexStringToBuffer_(a.videoNalus[h]);switch(k[0]&31){case 7:c.push(k);b+=k.length+2;break;case 8:d.push(k),b+=k.length+2}}c.length>0&&(e=c[0][1],g=c[0][2],f=c[0][3]);a=new Uint8Array(b);b=0;a[b++]=1;a[b++]=e;a[b++]=g;a[b++]=f;a[b++]=255;a[b++]=224|c.length;for(e=0;e<c.length;e++)a[b++]=(c[e].length&65280)>>8,a[b++]=c[e].length&255,a.set(c[e],b),b+=c[e].length;a[b++]=d.length;
for(c=0;c<d.length;c++)a[b++]=(d[c].length&65280)>>8,a[b++]=d[c].length&255,a.set(d[c],b),b+=d[c].length;return a};
shaka.util.Mp4Generator.prototype.hvc1_=function(a){var b=shaka.util.Mp4Generator,c=a.stream.width||0,d=a.stream.height||0,e=new Uint8Array([]);a.videoConfig.byteLength>0&&(e=b.box("hvcC",a.videoConfig));c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,2)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,
108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]));d="hvc1";var f=this.pasp_(a),g=new Uint8Array([]);a.encrypted&&(g=this.sinf(a.stream,a.codecs),d="encv");return b.box(d,c,e,f,g)};
shaka.util.Mp4Generator.prototype.pasp_=function(a){if(!a.hSpacing&&!a.vSpacing)return new Uint8Array([]);var b=shaka.util.Mp4Generator,c=a.vSpacing;a=new Uint8Array([].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.hSpacing,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4))));return b.box("pasp",a)};
shaka.util.Mp4Generator.prototype.audioStsd_=function(a){return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,a.stream.channelsCount||2,0,16,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.stream.audioSamplingRate||44100,2)),[0,0]))};shaka.util.Mp4Generator.prototype.mp3_=function(a){return shaka.util.Mp4Generator.box(".mp3",this.audioStsd_(a))};
shaka.util.Mp4Generator.prototype.ac3_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dac3",a.audioConfig),d="ac-3",e=new Uint8Array([]);a.encrypted&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};shaka.util.Mp4Generator.prototype.ec3_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dec3",a.audioConfig),d="ec-3",e=new Uint8Array([]);a.encrypted&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.opus_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dOps",a.audioConfig),d="Opus",e=new Uint8Array([]);a.encrypted&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.mp4a_=function(a){var b=shaka.util.Mp4Generator;var c=a.audioConfig.byteLength>0?b.box("esds",a.audioConfig):b.box("esds",this.esds_(a));var d="mp4a",e=new Uint8Array([]);a.encrypted&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.esds_=function(a){var b=a.id+1,c=a.stream.channelsCount||2,d=a.stream.audioSamplingRate||44100,e=shaka.util.ManifestParserUtils.guessCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a.codecs.split(",")),f={96E3:0,88200:1,64E3:2,48E3:3,44100:4,32E3:5,24E3:6,22050:7,16E3:8,12E3:9,11025:10,8E3:11,7350:12};a=f[d];if(e==="mp4a.40.5"||e==="mp4a.40.29")a=f[d*2];d=parseInt(e.split(".").pop(),10);return new Uint8Array([0,0,0,0,3,25].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,
2)),[0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,d<<3|a>>>1,a<<7|c<<3,6,1,2]))};shaka.util.Mp4Generator.prototype.mvex_=function(){for(var a=shaka.util.Mp4Generator,b=[],c=(0,$jscomp.makeIterator)(this.streamInfos_),d=c.next();!d.done;d=c.next())b.push(this.trex_(d.value));b=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(b));return a.box("mvex",b)};
shaka.util.Mp4Generator.prototype.trex_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.id+1,4)),[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));return b.box("trex",a)};
shaka.util.Mp4Generator.prototype.pssh_=function(a){var b=[];if(!a.encrypted)return new Uint8Array([]);a=(0,$jscomp.makeIterator)(a.stream.drmInfos);for(var c=a.next();!c.done;c=a.next())if(c=c.value,c.initData){c=(0,$jscomp.makeIterator)(c.initData);for(var d=c.next();!d.done;d=c.next())b.push(d.value.initData)}return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(b))};
shaka.util.Mp4Generator.prototype.sinf=function(a,b){return shaka.util.Mp4Generator.box("sinf",this.frma_(b),this.schm_(a),this.schi_(a))};shaka.util.Mp4Generator.prototype.frma_=function(a){var b=a.split(".")[0];a=shaka.util.Mp4Generator;b=this.stringToCharCode_(b);b=new Uint8Array([].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4))));return a.box("frma",b)};
shaka.util.Mp4Generator.prototype.schm_=function(a){var b="cenc";(a=a.drmInfos[0])&&a.encryptionScheme&&(b=a.encryptionScheme);a=shaka.util.Mp4Generator;b=this.stringToCharCode_(b);b=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4)),[0,1,0,0]));return a.box("schm",b)};shaka.util.Mp4Generator.prototype.schi_=function(a){return shaka.util.Mp4Generator.box("schi",this.tenc_(a))};
shaka.util.Mp4Generator.prototype.tenc_=function(a){var b=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);a=(0,$jscomp.makeIterator)(a.drmInfos);for(var c=a.next();!c.done;c=a.next())if((c=c.value)&&c.keyIds&&c.keyIds.size){c=(0,$jscomp.makeIterator)(c.keyIds);for(var d=c.next();!d.done;d=c.next())b=this.hexStringToBuffer_(d.value)}a=shaka.util.Mp4Generator;c=new Uint8Array([0,0,0,0,0,0,1,8]);goog.asserts.assert(b,"Default KID should be non-null");return a.box("tenc",c,b)};
shaka.util.Mp4Generator.prototype.segmentData=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.streamInfos_),c=b.next();!c.done;c=b.next())c=c.value,a.push.apply(a,[this.moof_(c),this.mdat_(c)]);return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(a))};shaka.util.Mp4Generator.prototype.moof_=function(a){return shaka.util.Mp4Generator.box("moof",this.mfhd_(a),this.traf_(a))};
shaka.util.Mp4Generator.prototype.mfhd_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.data?a.data.sequenceNumber:0,4))));return b.box("mfhd",a)};shaka.util.Mp4Generator.prototype.traf_=function(a){var b=shaka.util.Mp4Generator,c=this.sdtp_(a),d=c.length+32+20+8+16+8+8;return b.box("traf",this.tfhd_(a),this.tfdt_(a),this.trun_(a,d),c)};
shaka.util.Mp4Generator.prototype.sdtp_=function(a){var b=shaka.util.Mp4Generator;a=a.data?a.data.samples:[];for(var c=new Uint8Array(4+a.length),d=0;d<a.length;d++){var e=a[d].flags;c[d+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy}return b.box("sdtp",c)};
shaka.util.Mp4Generator.prototype.tfhd_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,58].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.id+1,4)),[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));return b.box("tfhd",a)};
shaka.util.Mp4Generator.prototype.tfdt_=function(a){var b=shaka.util.Mp4Generator;a=a.data?a.data.baseMediaDecodeTime:0;var c=Math.floor(a%(b.UINT32_MAX_+1));a=new Uint8Array([1,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(Math.floor(a/(b.UINT32_MAX_+1)),4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4))));return b.box("tfdt",a)};
shaka.util.Mp4Generator.prototype.trun_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.Mp4Generator,e=a.data?a.data.samples:[],f=e.length,g=12+16*f,h=new Uint8Array(g);b+=8+g;h.set([a.type===c.VIDEO?1:0,0,15,1].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(f,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4))),0);for(a=0;a<f;a++){var k=e[a];b=this.breakNumberIntoBytes_(k.duration,4);c=this.breakNumberIntoBytes_(k.size,4);g=k.flags;k=this.breakNumberIntoBytes_(k.cts,
4);h.set([].concat((0,$jscomp.arrayFromIterable)(b),(0,$jscomp.arrayFromIterable)(c),[g.isLeading<<2|g.dependsOn,g.isDependedOn<<6|g.hasRedundancy<<4|g.isNonSync,g.degradPrio&61440,g.degradPrio&15],(0,$jscomp.arrayFromIterable)(k)),12+16*a)}return d.box("trun",h)};
shaka.util.Mp4Generator.prototype.mdat_=function(a){var b=shaka.util.Mp4Generator;a=(a.data?a.data.samples:[]).map(function(c){return c.data});a=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(a));return b.box("mdat",a)};shaka.util.Mp4Generator.prototype.breakNumberIntoBytes_=function(a,b){var c=[];for(--b;b>=0;b--)c.push(a>>8*b&255);return c};
shaka.util.Mp4Generator.prototype.hexStringToBuffer_=function(a){for(var b=new Uint8Array(a.length/2),c=0;c<a.length/2;c+=1)b[c]=parseInt(String(a[c*2]+a[c*2+1]),16);return b};shaka.util.Mp4Generator.prototype.stringToCharCode_=function(a){for(var b=0,c=0;c<a.length;c+=1)b|=a.charCodeAt(c)<<(a.length-c-1)*8;return b};
shaka.util.Mp4Generator.box=function(a){var b=$jscomp.getRestArguments.apply(1,arguments),c=shaka.util.Mp4Generator.BOX_TYPES_.get(a);c||(c=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)],shaka.util.Mp4Generator.BOX_TYPES_.set(a,c));for(var d=8,e=b.length-1;e>=0;e--)d+=b[e].byteLength;e=new Uint8Array(d);e[0]=d>>24&255;e[1]=d>>16&255;e[2]=d>>8&255;e[3]=d&255;e.set(c,4);c=0;for(d=8;c<b.length;c++)e.set(b[c],d),d+=b[c].byteLength;return e};shaka.util.Mp4Generator.UINT32_MAX_=4294967295;
shaka.util.Mp4Generator.BOX_TYPES_=new Map;shaka.util.Mp4Generator.HDLR_TYPES_={video:new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0])}),audio:new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])})};
shaka.util.Mp4Generator.STTS_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STSC_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STCO_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STSZ_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])});
shaka.util.Mp4Generator.VMHD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.SMHD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STSD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,1])});
shaka.util.Mp4Generator.FTYP_=new shaka.util.Lazy(function(){var a=new Uint8Array([105,115,111,109]),b=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);return shaka.util.Mp4Generator.box("ftyp",a,c,a,b)});shaka.util.Mp4Generator.DINF_=new shaka.util.Lazy(function(){var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);a=shaka.util.Mp4Generator.box("dref",a);return shaka.util.Mp4Generator.box("dinf",a)});shaka.media.ContentWorkarounds=function(){};
shaka.media.ContentWorkarounds.correctEnca=function(a){a=shaka.util.BufferUtils.toUint8(a);var b=null;(new shaka.util.Mp4Parser).box("moov",shaka.util.Mp4Parser.children).box("trak",shaka.util.Mp4Parser.children).box("mdia",shaka.util.Mp4Parser.children).box("minf",shaka.util.Mp4Parser.children).box("stbl",shaka.util.Mp4Parser.children).fullBox("stsd",shaka.util.Mp4Parser.sampleDescription).box("enca",function(c){b=c.reader.getDataView();return shaka.util.Mp4Parser.audioSampleEntry(c)}).box("sinf",shaka.util.Mp4Parser.children).box("frma",
function(c){c.parser.stop();shaka.util.Mp4BoxParsers.parseFRMA(c.reader).codec==="ec-3"&&b&&b.getUint16(16)!==2&&b.setUint16(16,2)}).parse(a);return a};
shaka.media.ContentWorkarounds.fakeEncryption=function(a,b,c){var d=shaka.media.ContentWorkarounds,e=b=shaka.util.BufferUtils.toUint8(b),f=!1,g,h=[],k=function(q){h.push(q);shaka.util.Mp4Parser.children(q)},l=function(q){f=!0;q.parser.stop()},m=[],n=function(q){m.push({box:q,newType:d.BOX_TYPE_ENCV_})},p=function(q){m.push({box:q,newType:d.BOX_TYPE_ENCA_})};(new shaka.util.Mp4Parser).box("moov",k).box("trak",k).box("mdia",k).box("minf",k).box("stbl",k).fullBox("stsd",function(q){g=q;h.push(q);shaka.util.Mp4Parser.sampleDescription(q)}).fullBox("encv",
l).fullBox("enca",l).fullBox("dvav",n).fullBox("dva1",n).fullBox("dvh1",n).fullBox("dvhe",n).fullBox("dvc1",n).fullBox("dvi1",n).fullBox("hev1",n).fullBox("hvc1",n).fullBox("avc1",n).fullBox("avc3",n).fullBox("ac-3",p).fullBox("ec-3",p).fullBox("ac-4",p).fullBox("Opus",p).fullBox("fLaC",p).fullBox("mp4a",p).parse(b);if(f)return shaka.log.debug("Init segment already indicates encryption."),b;if(m.length==0||!g)throw shaka.log.error("Failed to find boxes needed to fake encryption!"),shaka.log.v2("Failed init segment (hex):",
shaka.util.Uint8ArrayUtils.toHex(b)),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.CONTENT_TRANSFORMATION_FAILED,c);m.reverse();c=(0,$jscomp.makeIterator)(m);for(k=c.next();!k.done;k=c.next())k=k.value,l=shaka.util.Mp4Parser.typeToString(k.newType),shaka.log.debug('Inserting "'+l+'" box into init segment.'),e=d.insertEncryptionMetadata_(a,e,g,k.box,h,k.newType);return shaka.device.DeviceFactory.getDevice().requiresClearAndEncryptedInitSegments()?
(a=new Uint8Array(b.byteLength+e.byteLength),a.set(e),a.set(b,e.byteLength),a):e};
shaka.media.ContentWorkarounds.fakeMediaEncryption=function(a){a=shaka.util.BufferUtils.toUint8(a);var b=[];(new shaka.util.Mp4Parser).box("mdat",function(g){b.push(g)}).parse(a);for(var c=[],d=0;d<b.length;d++){var e=b[d-1],f=b[d];e=a.subarray(e?e.start+e.size:0,f.start+f.size);c.push(shaka.media.ContentWorkarounds.fakeMediaEncryptionInChunk_(e))}return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(c))};
shaka.media.ContentWorkarounds.fakeMediaEncryptionInChunk_=function(a){var b,c,d,e,f=[],g=function(m){f.push(m);shaka.util.Mp4Parser.children(m)};(new shaka.util.Mp4Parser).box("moof",g).box("traf",g).fullBox("tfhd",function(m){b=m;d=shaka.util.Mp4BoxParsers.parseTFHD(m.reader,m.flags)}).fullBox("trun",function(m){c=m;e=shaka.util.Mp4BoxParsers.parseTRUN(m.reader,m.version,m.flags)}).parse(a);if(d&&d.sampleDescriptionIndex!==2){g=b.start+shaka.util.Mp4Parser.headerSize(b)+4+(d.baseDataOffset!==null?
8:0);var h=shaka.util.BufferUtils.toDataView(a);if(d.sampleDescriptionIndex!==null)h.setUint32(g,2);else{shaka.media.ContentWorkarounds.updateBoxSize_(a,b.start,b.size+4);var k=h.getUint32(b.start+8);h.setUint32(b.start+8,k|2);if(e&&e.dataOffset!==null){k=e.dataOffset+4;var l=c.start+shaka.util.Mp4Parser.headerSize(c)+4;h.setInt32(l,k)}k=a.subarray(0,g);h=a.subarray(g);a=new Uint8Array(a.byteLength+4);a.set(k);k=[];for(l=3;l>=0;l--)k.push(2>>8*l&255);a.set(new Uint8Array(k),g);a.set(h,g+4);g=(0,$jscomp.makeIterator)(f);
for(h=g.next();!h.done;h=g.next())h=h.value,shaka.media.ContentWorkarounds.updateBoxSize_(a,h.start,h.size+4)}}return a};
shaka.media.ContentWorkarounds.insertEncryptionMetadata_=function(a,b,c,d,e,f){var g=shaka.media.ContentWorkarounds;f=g.createEncryptionMetadata_(a,b,d,f);a=new Uint8Array(b.byteLength+f.byteLength);d=shaka.device.DeviceFactory.getDevice().insertEncryptionDataBeforeClear()?d.start:d.start+d.size;var h=b.subarray(0,d);b=b.subarray(d);a.set(h);a.set(f,d);a.set(b,d+f.byteLength);e=(0,$jscomp.makeIterator)(e);for(b=e.next();!b.done;b=e.next())b=b.value,goog.asserts.assert(b.start<d,"Ancestor MP4 box found in the wrong location!  Modified init segment will not make sense!"),
g.updateBoxSize_(a,b.start,b.size+f.byteLength);g=shaka.util.BufferUtils.toDataView(a,c.start);c=shaka.util.Mp4Parser.headerSize(c);f=g.getUint32(c);g.setUint32(c,f+1);return a};
shaka.media.ContentWorkarounds.createEncryptionMetadata_=function(a,b,c,d){var e=shaka.media.ContentWorkarounds;a=(new shaka.util.Mp4Generator([])).sinf(a,c.name);b=b.subarray(c.start,c.start+c.size);var f=new Uint8Array(c.size+a.byteLength);f.set(b,0);shaka.util.BufferUtils.toDataView(f).setUint32(e.BOX_TYPE_OFFSET_,d);f.set(a,c.size);e.updateBoxSize_(f,0,f.byteLength);return f};
shaka.media.ContentWorkarounds.updateBoxSize_=function(a,b,c){var d=shaka.media.ContentWorkarounds;a=shaka.util.BufferUtils.toDataView(a,b);b=a.getUint32(d.BOX_SIZE_OFFSET_);b!=0&&(b==1?(a.setUint32(d.BOX_SIZE_64_OFFSET_,c>>32),a.setUint32(d.BOX_SIZE_64_OFFSET_+4,c&4294967295)):a.setUint32(d.BOX_SIZE_OFFSET_,c))};
shaka.media.ContentWorkarounds.fakeEC3=function(a){var b=shaka.media.ContentWorkarounds,c=shaka.util.BufferUtils.toUint8(a),d=[];a=function(e){d.push({start:e.start,size:e.size});shaka.util.Mp4Parser.children(e)};(new shaka.util.Mp4Parser).box("moov",a).box("trak",a).box("mdia",a).box("minf",a).box("stbl",a).box("stsd",function(e){d.push({start:e.start,size:e.size});for(var f=shaka.util.BufferUtils.toDataView(c,e.start),g=0;g<e.size-3;g++){var h=f.getUint32(g);h==b.BOX_TYPE_AC_3_?f.setUint32(g,b.BOX_TYPE_EC_3_):
h==b.BOX_TYPE_DAC3_&&f.setUint32(g,b.BOX_TYPE_DEC3_)}}).parse(c);return c};shaka.media.ContentWorkarounds.BOX_SIZE_OFFSET_=0;shaka.media.ContentWorkarounds.BOX_TYPE_OFFSET_=4;shaka.media.ContentWorkarounds.BOX_SIZE_64_OFFSET_=8;shaka.media.ContentWorkarounds.BOX_TYPE_ENCV_=1701733238;shaka.media.ContentWorkarounds.BOX_TYPE_ENCA_=1701733217;shaka.media.ContentWorkarounds.BOX_TYPE_AC_3_=1633889587;shaka.media.ContentWorkarounds.BOX_TYPE_DAC3_=1684103987;
shaka.media.ContentWorkarounds.BOX_TYPE_EC_3_=1700998451;shaka.media.ContentWorkarounds.BOX_TYPE_DEC3_=1684366131;shaka.media.TimeRangesUtils=function(){};shaka.media.TimeRangesUtils.isBufferNegligible_=function(a){return a.length==1&&a.end(0)-a.start(0)<1E-4};shaka.media.TimeRangesUtils.bufferStart=function(a){return!a||shaka.media.TimeRangesUtils.isBufferNegligible_(a)?null:a.length==1&&a.start(0)<0?0:a.length?a.start(0):null};shaka.media.TimeRangesUtils.bufferEnd=function(a){return!a||shaka.media.TimeRangesUtils.isBufferNegligible_(a)?null:a.length?a.end(a.length-1):null};
shaka.media.TimeRangesUtils.isBuffered=function(a,b){return!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a)||b>a.end(a.length-1)?!1:b>=a.start(0)};shaka.media.TimeRangesUtils.bufferedAheadOf=function(a,b){if(!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a))return 0;var c=0;a=(0,$jscomp.makeIterator)(shaka.media.TimeRangesUtils.getBufferedInfo(a));for(var d=a.next();!d.done;d=a.next()){var e=d.value;d=e.start;e=e.end;e>b&&(c+=e-Math.max(d,b))}return c};
shaka.media.TimeRangesUtils.getGapIndex=function(a,b,c){var d=shaka.media.TimeRangesUtils;if(!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a))return null;a=d.getBufferedInfo(a).findIndex(function(e,f,g){return e.start>b&&(f==0||g[f-1].end-b<=c)});return a>=0?a:null};shaka.media.TimeRangesUtils.getBufferedInfo=function(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++)b.push({start:a.start(c),end:a.end(c)});return b};
shaka.media.TimeRangesUtils.computeAddedRange=function(a,b){var c=shaka.media.TimeRangesUtils;if(!a||!a.length)return null;if(!b||!b.length)return c.getBufferedInfo(b).pop();b=c.getBufferedInfo(b).reverse();a=c.getBufferedInfo(a).reverse();c=(0,$jscomp.makeIterator)(b);for(b=c.next();!b.done;b=c.next()){b=b.value;for(var d=!1,e=(0,$jscomp.makeIterator)(a),f=e.next();!f.done;f=e.next())if(f=f.value,f.end>=b.start&&f.end<=b.end&&(d=!0,b.end>f.end))return{start:f.end,end:b.end};if(!d)return b}return null};shaka.media.GapJumpingController=function(a,b,c,d){var e=this;this.onEvent_=d;this.video_=a;this.timeline_=b;this.config_=c;this.eventManager_=new shaka.util.EventManager;this.seekingEventReceived_=this.started_=!1;this.startTime_=0;this.isJumpingGap_=!1;this.stallsDetected_=this.gapsJumped_=0;this.stallDetector_=this.createStallDetector_();this.hadSegmentAppended_=!1;this.eventManager_.listen(a,"waiting",function(){return e.onPollGapJump_()});this.gapJumpTimer_=(new shaka.util.Timer(function(){e.onPollGapJump_()})).tickEvery(this.config_.gapJumpTimerTime)};
shaka.media.GapJumpingController.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.gapJumpTimer_!=null&&(this.gapJumpTimer_.stop(),this.gapJumpTimer_=null);this.stallDetector_&&(this.stallDetector_.release(),this.stallDetector_=null);this.video_=this.timeline_=this.onEvent_=null};
shaka.media.GapJumpingController.prototype.onSegmentAppended=function(){this.hadSegmentAppended_=!0;this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};shaka.media.GapJumpingController.prototype.onStarted=function(a){this.video_.seeking&&!this.seekingEventReceived_&&(this.seekingEventReceived_=!0,this.startTime_=a);this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};
shaka.media.GapJumpingController.prototype.onSeeking=function(){this.seekingEventReceived_=!0;this.hadSegmentAppended_=!1;this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};shaka.media.GapJumpingController.prototype.getGapsJumped=function(){return this.gapsJumped_};shaka.media.GapJumpingController.prototype.getStallsDetected=function(){return this.stallsDetected_};shaka.media.GapJumpingController.prototype.getIsJumpingGap=function(){return this.isJumpingGap_};
shaka.media.GapJumpingController.prototype.onPollGapJump_=function(){if(this.video_.readyState!=0){if(this.video_.seeking){if(!this.seekingEventReceived_)return}else this.seekingEventReceived_=!1;if(!this.video_.paused||this.video_.currentTime==this.startTime_&&(this.video_.autoplay||this.video_.currentTime!=this.startTime_))if(!this.stallDetector_||!this.stallDetector_.poll()){var a=this.video_.currentTime,b=this.video_.buffered,c=shaka.media.TimeRangesUtils.getGapIndex(b,a,this.config_.gapDetectionThreshold);
if(c!=null&&(c!=0||this.hadSegmentAppended_)){var d=b.start(c),e=this.config_.gapPadding;e&&(d=Math.ceil((d+e)*100)/100);e=this.timeline_.getSeekRangeEnd();d>=e||(e=d-a,e<shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE||(c==0?shaka.log.info("Jumping forward",e,"seconds because of gap before start time of",d):shaka.log.info("Jumping forward",e,"seconds because of gap starting at",b.end(c-1),"and ending at",d),this.seek_(d),a==this.startTime_&&(this.startTime_=d),this.gapsJumped_++,this.onEvent_(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.GapJumped))))}}}};
shaka.media.GapJumpingController.prototype.seek_=function(a){var b=this;this.isJumpingGap_=!0;this.eventManager_.listenOnce(this.video_,"seeked",function(){b.isJumpingGap_=!1});this.video_.currentTime=a};
shaka.media.GapJumpingController.prototype.createStallDetector_=function(){var a=this;if(!this.config_.stallEnabled)return null;goog.asserts.assert(this.video_,"Must have video");var b=this.config_.stallThreshold,c=this.config_.stallSkip;return new shaka.media.StallDetector(new shaka.media.StallDetector.MediaElementImplementation(this.video_),b,function(d,e){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1){goog.asserts.assert(a.video_,"Must have video");
f=shaka.media.TimeRangesUtils.getBufferedInfo(a.video_.buffered);if(!f.length)return g.return();shaka.log.debug("Stall detected at "+d+" for "+e+" seconds.");if(c)return shaka.log.debug("Seeking forward "+c+" seconds to break stall."),a.video_.currentTime+=c,g.jumpTo(2);shaka.log.debug("Wait for play to avoid reject a possible other play call.");return g.yield(a.video_.play(),3)}if(g.nextAddress!=2){if(!a.video_)return g.return();shaka.log.debug("Pausing and unpausing to break stall.");a.video_.pause();
a.video_.play()}a.stallsDetected_++;a.onEvent_(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.StallDetected));g.jumpToEnd()})})};shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE=.001;shaka.media.StallDetector=function(a,b,c){this.implementation_=a;this.wasMakingProgress_=a.shouldBeMakingProgress();this.value_=a.getPresentationSeconds();this.lastUpdateSeconds_=a.getWallSeconds();this.didJump_=!1;this.stallThresholdSeconds_=b;this.onStall_=c};
shaka.media.StallDetector.prototype.release=function(){this.implementation_&&this.implementation_.release();this.onStall_=this.implementation_=null};
shaka.media.StallDetector.prototype.poll=function(){var a=this.implementation_,b=a.shouldBeMakingProgress(),c=a.getPresentationSeconds(),d=a.getWallSeconds();if(this.value_!=c||this.wasMakingProgress_!=b)this.lastUpdateSeconds_=d,this.value_=c,this.wasMakingProgress_=b,this.didJump_=!1;c=d-this.lastUpdateSeconds_;if(b=c>=this.stallThresholdSeconds_&&b&&!this.didJump_){if(this.onStall_)this.onStall_(this.value_,c);this.didJump_=!0;this.value_=a.getPresentationSeconds()}return b};
shaka.media.StallDetector.Implementation=function(){};shaka.media.StallDetector.Implementation.prototype.shouldBeMakingProgress=function(){};shaka.media.StallDetector.Implementation.prototype.getPresentationSeconds=function(){};shaka.media.StallDetector.Implementation.prototype.getWallSeconds=function(){};shaka.media.StallDetector.Implementation.prototype.release=function(){};
shaka.media.StallDetector.MediaElementImplementation=function(a){var b=this;this.mediaElement_=a;this.audioEventManager_=new shaka.util.EventManager;this.audioFocusPaused_=!1;this.audioEventManager_.listen(this.mediaElement_,"audiofocuspaused",function(){shaka.log.info("Audio focus paused");b.audioFocusPaused_=!0});this.audioEventManager_.listen(this.mediaElement_,"audiofocusgranted",function(){shaka.log.info("Audio focus granted");b.audioFocusPaused_=!1});this.audioEventManager_.listen(this.mediaElement_,
"audiofocuslost",function(){shaka.log.info("Audio focus lost");b.audioFocusPaused_=!0})};shaka.media.StallDetector.MediaElementImplementation.prototype.shouldBeMakingProgress=function(){return this.mediaElement_.paused||this.mediaElement_.playbackRate==0||this.audioFocusPaused_||this.mediaElement_.buffered.length==0?!1:this.hasContentFor_(this.mediaElement_.buffered,this.mediaElement_.currentTime)};shaka.media.StallDetector.MediaElementImplementation.prototype.getPresentationSeconds=function(){return this.mediaElement_.currentTime};
shaka.media.StallDetector.MediaElementImplementation.prototype.getWallSeconds=function(){return Date.now()/1E3};shaka.media.StallDetector.MediaElementImplementation.prototype.hasContentFor_=function(a,b){a=(0,$jscomp.makeIterator)(shaka.media.TimeRangesUtils.getBufferedInfo(a));for(var c=a.next();!c.done;c=a.next())if(c=c.value,!(b<c.start-.1||b>c.end-.5))return!0;return!1};
shaka.media.StallDetector.MediaElementImplementation.prototype.release=function(){this.audioEventManager_&&this.audioEventManager_.release();this.audioEventManager_=null};/*
 @license
 Shaka Player
 Copyright 2023 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
shaka.media.ManifestFilterer=function(a,b,c){goog.asserts.assert(a,"Must have config");this.config_=a;this.maxHwRes_=b;this.drmEngine_=c};shaka.media.ManifestFilterer.prototype.setDrmEngine=function(a){this.drmEngine_=a};
shaka.media.ManifestFilterer.prototype.filterManifest=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1)return goog.asserts.assert(a,"Manifest should exist!"),c.yield(shaka.util.StreamUtils.filterManifest(b.drmEngine_,a,b.config_.drm.preferredKeySystems,b.config_.drm.keySystemsMapping),2);b.config_.streaming.dontChooseCodecs||shaka.util.StreamUtils.chooseCodecsAndFilterManifest(a,b.config_.preferredVideoCodecs,b.config_.preferredAudioCodecs,
b.config_.preferredDecodingAttributes,b.config_.preferredTextFormats);b.checkPlayableVariants_(a);return c.return(b.filterManifestWithRestrictions(a))})};shaka.media.ManifestFilterer.prototype.applyRestrictions=function(a){return shaka.util.StreamUtils.applyRestrictions(a.variants,this.config_.restrictions,this.maxHwRes_)};
shaka.media.ManifestFilterer.prototype.filterManifestWithRestrictions=function(a){var b=this.applyRestrictions(a);if(a){var c=this.drmEngine_?this.drmEngine_.getDrmInfo():null;if(c&&this.drmEngine_.getMediaKeys()){for(var d=new Set,e=(0,$jscomp.makeIterator)(a.variants),f=e.next();!f.done;f=e.next())f=f.value,f.audio&&d.add(f.audio),f.video&&d.add(f.video);d=(0,$jscomp.makeIterator)(d);for(e=d.next();!e.done;e=d.next())this.processDrmInfos(c.keySystem,e.value)}this.checkRestrictedVariants(a)}return b};
shaka.media.ManifestFilterer.prototype.checkPlayableVariants_=function(a){if(!a.variants.some(shaka.util.StreamUtils.isPlayable))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CONTENT_UNSUPPORTED_BY_BROWSER);};
shaka.media.ManifestFilterer.prototype.processDrmInfos=function(a,b){b=(0,$jscomp.makeIterator)(b.drmInfos);for(var c=b.next();!c.done;c=b.next())if(c=c.value,c.keySystem==a){c=(0,$jscomp.makeIterator)(c.initData||[]);for(var d=c.next();!d.done;d=c.next())d=d.value,this.drmEngine_.newInitData(d.initDataType,d.initData)}};
shaka.media.ManifestFilterer.prototype.checkRestrictedVariants=function(a){var b=shaka.media.ManifestFilterer.restrictedStatuses,c=this.drmEngine_?this.drmEngine_.getKeyStatuses():{},d=Object.keys(c);d=d.length&&d[0]=="00";var e=!1,f=!1,g=new Set,h=new Set,k=new Set;a=(0,$jscomp.makeIterator)(a.variants);for(var l=a.next();!l.done;l=a.next())l=l.value,l.audio&&k.add(l.audio),l.video&&k.add(l.video),l.allowedByApplication?l.allowedByKeySystem&&(e=!0):f=!0;k=(0,$jscomp.makeIterator)(k);for(a=k.next();!a.done;a=
k.next())if(a=a.value,a.keyIds.size)for(a=(0,$jscomp.makeIterator)(a.keyIds),l=a.next();!l.done;l=a.next()){l=l.value;var m=c[d?"00":l];m?b.includes(m)&&h.add(m):g.add(l)}if(!e)throw b={hasAppRestrictions:f,missingKeys:Array.from(g),restrictedKeyStatuses:Array.from(h)},new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.RESTRICTIONS_CANNOT_BE_MET,b);};shaka.media.ManifestFilterer.restrictedStatuses=["output-restricted","internal-error"];shaka.util.TimeUtils=function(){};shaka.util.TimeUtils.convertNtp=function(a){var b=Date.UTC(1900,0,1,0,0,0,0);return(new Date(b+a)).getTime()};shaka.media.MediaSourceEngine=function(a,b,c,d,e){var f=this;this.video_=a;this.playerInterface_=c;this.config_=d;this.textDisplayer_=b;this.sourceBuffers_=new Map;this.sourceBufferTypes_=new Map;this.expectedEncryption_=new Map;this.textEngine_=null;this.segmentRelativeVttTiming_=!1;this.lcevcDec_=e||null;this.queues_=new Map;this.eventManager_=new shaka.util.EventManager;this.transmuxers_=new Map;this.captionParser_=null;this.mediaSourceOpen_=new shaka.util.PublicPromise;this.url_="";this.playbackHasBegun_=
!1;this.streamingAllowed_=!0;this.usingRemotePlayback_=!1;this.secondarySource_=this.source_=null;this.mediaSource_=this.createMediaSource(this.mediaSourceOpen_);this.playAfterReset_=this.reloadingMediaSource_=!1;this.destroyer_=new shaka.util.Destroyer(function(){return f.doDestroy_()});this.sequenceMode_=!1;this.manifestType_=shaka.media.ManifestParser.UNKNOWN;this.attemptTimestampOffsetCalculation_=this.ignoreManifestTimestampsInSegmentsMode_=!1;this.textSequenceModeOffset_=new shaka.util.PublicPromise;
this.needSplitMuxedContent_=!1;this.lastDuration_=null;this.tsParsers_=new Map;this.firstAudioReferenceStartTime_=this.firstAudioTimestamp_=this.firstVideoReferenceStartTime_=this.firstVideoTimestamp_=null;this.audioCompensation_=new shaka.util.PublicPromise;this.video_.remote&&(this.usingRemotePlayback_=this.video_.remote.state!="disconnected",this.eventManager_.listen(this.video_.remote,"connect",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}),this.eventManager_.listen(this.video_.remote,
"connecting",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}),this.eventManager_.listen(this.video_.remote,"disconnect",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}))};
shaka.media.MediaSourceEngine.prototype.createMediaSource=function(a){var b=this;this.streamingAllowed_=!0;if(window.ManagedMediaSource){this.secondarySource_||(this.video_.disableRemotePlayback=!0);var c=new ManagedMediaSource;this.eventManager_.listen(c,"startstreaming",function(){shaka.log.info("MMS startstreaming");b.streamingAllowed_=!0});this.eventManager_.listen(c,"endstreaming",function(){shaka.log.info("MMS endstreaming");b.streamingAllowed_=!1})}else c=new MediaSource;this.eventManager_.listenOnce(c,
"sourceopen",function(){return b.onSourceOpen_(a)});this.eventManager_.listenOnce(this.video_,"playing",function(){b.playbackHasBegun_=!0});this.url_=shaka.media.MediaSourceEngine.createObjectURL(c);this.config_.useSourceElements?(this.video_.removeAttribute("src"),this.source_&&this.video_.removeChild(this.source_),this.secondarySource_&&this.video_.removeChild(this.secondarySource_),this.source_=shaka.util.Dom.createSourceElement(this.url_),this.video_.appendChild(this.source_),this.secondarySource_&&
this.video_.appendChild(this.secondarySource_),this.video_.load()):this.video_.src=this.url_;return c};shaka.media.MediaSourceEngine.prototype.addSecondarySource=function(a,b){this.video_&&window.ManagedMediaSource&&this.mediaSource_?this.config_.useSourceElements&&(this.secondarySource_&&this.video_.removeChild(this.secondarySource_),this.secondarySource_=shaka.util.Dom.createSourceElement(a,b),this.video_.appendChild(this.secondarySource_),this.video_.disableRemotePlayback=!1):shaka.log.warning("Secondary source is used only with ManagedMediaSource")};
shaka.media.MediaSourceEngine.prototype.onSourceOpen_=function(a){goog.asserts.assert(this.url_,"Must have object URL");URL.revokeObjectURL(this.url_);a.resolve()};
shaka.media.MediaSourceEngine.probeSupport=function(){var a=shaka.util.MimeUtils,b='video/mp4; codecs="avc1.42E01E",video/mp4; codecs="avc3.42E01E",video/mp4; codecs="hev1.1.6.L93.90",video/mp4; codecs="hvc1.1.6.L93.90",video/mp4; codecs="hev1.2.4.L153.B0"; eotf="smpte2084",video/mp4; codecs="hvc1.2.4.L153.B0"; eotf="smpte2084",video/mp4; codecs="hvc1.2.20000000.L153.B0",video/mp4; codecs="hvc1.2.4.L120.b0",video/mp4; codecs="hvc1.2.4.L123.b0",video/mp4; codecs="vp9",video/mp4; codecs="vp09.00.10.08",video/mp4; codecs="av01.0.01M.08",video/mp4; codecs="dvh1.05.01",video/mp4; codecs="dvh1.08.01",video/mp4; codecs="dav1.10.01",video/mp4; codecs="dvh1.20.01",audio/mp4; codecs="mp4a.40.2",audio/mp4; codecs="ac-3",audio/mp4; codecs="ec-3",audio/mp4; codecs="ac-4.02.01.01",audio/mp4; codecs="opus",audio/mp4; codecs="flac",audio/mp4; codecs="dtsc",audio/mp4; codecs="dtse",audio/mp4; codecs="dtsx",audio/mp4; codecs="apac.31.00",video/webm; codecs="vp8",video/webm; codecs="vp9",video/webm; codecs="vp09.00.10.08",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",text/vtt,application/mp4; codecs="wvtt",application/ttml+xml,application/mp4; codecs="stpp"'.split(",").concat((0,$jscomp.arrayFromIterable)(a.RAW_FORMATS)),c=
{},d=shaka.device.DeviceFactory.getDevice();b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next()){e=e.value;if(shaka.text.TextEngine.isTypeSupported(e))c[e]=!0;else if(d.supportsMediaSource()){var f=a.getBasicType(e),g=shaka.util.StreamUtils.getCorrectAudioCodecs(a.getCodecs(e),f);f=a.getFullType(f,g);c[e]=shaka.media.Capabilities.isTypeSupported(f)||shaka.transmuxer.TransmuxerEngine.isSupported(f)}else c[e]=d.supportsMediaType(e);f=e.split(";")[0];c[f]=c[f]||c[e]}return c};
shaka.media.MediaSourceEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.media.MediaSourceEngine.prototype.doDestroy_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.nextAddress==1){b=shaka.util.Functional;c=[];d=(0,$jscomp.makeIterator)(a.queues_);for(e=d.next();!e.done;e=d.next())for(f=e.value,g=(0,$jscomp.makeIterator)(f),h=g.next().value,k=g.next().value,l=k[0],m=h,a.queues_.set(m,k.slice(0,1)),l&&c.push(l.p.catch(b.noop)),n=(0,$jscomp.makeIterator)(k.slice(1)),p=n.next();!p.done;p=
n.next())q=p.value,q.p.reject(shaka.util.Destroyer.destroyedError());a.textEngine_&&c.push(a.textEngine_.destroy());return y.yield(Promise.all(c),2)}r=(0,$jscomp.makeIterator)(a.transmuxers_.values());for(t=r.next();!t.done;t=r.next())w=t.value,w.destroy();a.eventManager_&&(a.eventManager_.release(),a.eventManager_=null);a.video_&&a.secondarySource_&&a.video_.removeChild(a.secondarySource_);a.video_&&a.source_&&(a.video_.removeChild(a.source_),a.video_.load(),a.video_.disableRemotePlayback=!1);a.video_=
null;a.source_=null;a.secondarySource_=null;a.config_=null;a.mediaSource_=null;a.textEngine_=null;a.textDisplayer_=null;a.sourceBuffers_.clear();a.expectedEncryption_.clear();a.transmuxers_.clear();a.captionParser_=null;if(goog.DEBUG)for(v=(0,$jscomp.makeIterator)(a.queues_),u=v.next();!u.done;u=v.next())x=u.value,z=(0,$jscomp.makeIterator)(x),B=z.next().value,C=z.next().value,goog.asserts.assert(C.length==0,B+" queue should be empty after destroy!");a.queues_.clear();a.lcevcDec_=null;a.tsParsers_.clear();
a.playerInterface_=null;y.jumpToEnd()})};shaka.media.MediaSourceEngine.prototype.open=function(){return this.mediaSourceOpen_};
shaka.media.MediaSourceEngine.prototype.init=function(a,b,c,d){b=b===void 0?!1:b;c=c===void 0?shaka.media.ManifestParser.UNKNOWN:c;d=d===void 0?!1:d;var e=this,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.nextAddress==1)return f=shaka.util.ManifestParserUtils.ContentType,n.yield(e.mediaSourceOpen_,2);if(n.nextAddress!=3){if(!e.ended()&&!e.closed())return n.jumpTo(3);shaka.log.alwaysError("Expected MediaSource to be open during init(); reopening the media source.");
e.mediaSourceOpen_=new shaka.util.PublicPromise;e.mediaSource_=e.createMediaSource(e.mediaSourceOpen_);return n.yield(e.mediaSourceOpen_,3)}e.sequenceMode_=b;e.manifestType_=c;e.ignoreManifestTimestampsInSegmentsMode_=d;e.attemptTimestampOffsetCalculation_=!e.sequenceMode_&&e.manifestType_==shaka.media.ManifestParser.HLS&&!e.ignoreManifestTimestampsInSegmentsMode_;e.tsParsers_.clear();e.firstVideoTimestamp_=null;e.firstVideoReferenceStartTime_=null;e.firstAudioTimestamp_=null;e.firstAudioReferenceStartTime_=
null;e.audioCompensation_=new shaka.util.PublicPromise;g=(0,$jscomp.makeIterator)(a.keys());for(h=g.next();!h.done;h=g.next())k=h.value,l=a.get(k),e.initSourceBuffer_(k,l,l.codecs),e.needSplitMuxedContent_?(e.queues_.set(f.AUDIO,[]),e.queues_.set(f.VIDEO,[])):e.queues_.set(k,[]);(m=a.get(f.AUDIO))&&m.isAudioMuxedInVideo&&(e.needSplitMuxedContent_=!0);n.jumpToEnd()})};
shaka.media.MediaSourceEngine.prototype.initSourceBuffer_=function(a,b,c){var d=this,e=shaka.util.ManifestParserUtils.ContentType;a==e.AUDIO&&c&&(c=shaka.util.StreamUtils.getCorrectAudioCodecs(c,b.mimeType));var f=shaka.util.MimeUtils.getFullType(b.mimeType,c);if(a==e.TEXT)this.reinitText(f,this.sequenceMode_,b.external);else{var g=this.config_.forceTransmux;if(!shaka.media.Capabilities.isTypeSupported(f)||!this.sequenceMode_&&shaka.util.MimeUtils.RAW_FORMATS.includes(f))g=!0;var h=shaka.util.MimeUtils.getFullTypeWithAllCodecs(b.mimeType,
c);if(g){g=shaka.util.ManifestParserUtils.guessCodecsSafe(e.AUDIO,(c||"").split(","));c=shaka.util.ManifestParserUtils.guessCodecsSafe(e.VIDEO,(c||"").split(","));if(g&&c){this.needSplitMuxedContent_=!0;this.initSourceBuffer_(e.AUDIO,b,g);this.initSourceBuffer_(e.VIDEO,b,c);return}if(e=shaka.transmuxer.TransmuxerEngine.findTransmuxer(h))f=e(),this.transmuxers_.set(a,f),f=f.convertCodecs(a,h)}h=this.addExtraFeaturesToMimeType_(f);this.destroyer_.ensureNotDestroyed();try{var k=this.mediaSource_.addSourceBuffer(h)}catch(l){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,l,"The mediaSource_ status was "+this.mediaSource_.readyState+" expected 'open'",null);}this.sequenceMode_&&(k.mode=shaka.media.MediaSourceEngine.SourceBufferMode_.SEQUENCE);this.eventManager_.listen(k,"error",function(){return d.onError_(a)});this.eventManager_.listen(k,"updateend",function(){return d.onUpdateEnd_(a)});this.sourceBuffers_.set(a,k);this.sourceBufferTypes_.set(a,f);this.expectedEncryption_.set(a,!!b.drmInfos.length)}};
shaka.media.MediaSourceEngine.prototype.configure=function(a){this.config_=a;this.textEngine_&&this.textEngine_.setModifyCueCallback(a.modifyCueCallback)};shaka.media.MediaSourceEngine.prototype.isStreamingAllowed=function(){return this.streamingAllowed_&&!this.usingRemotePlayback_&&!this.reloadingMediaSource_};
shaka.media.MediaSourceEngine.prototype.reinitText=function(a,b,c){this.textEngine_||(this.textEngine_=new shaka.text.TextEngine(this.textDisplayer_),this.textEngine_.setModifyCueCallback(this.config_.modifyCueCallback));this.textEngine_.initParser(a,b,c||this.segmentRelativeVttTiming_,this.manifestType_)};shaka.media.MediaSourceEngine.prototype.ended=function(){return this.reloadingMediaSource_?!1:this.mediaSource_?this.mediaSource_.readyState=="ended":!0};
shaka.media.MediaSourceEngine.prototype.closed=function(){return this.reloadingMediaSource_?!1:this.mediaSource_?this.mediaSource_.readyState=="closed":!0};shaka.media.MediaSourceEngine.prototype.bufferStart=function(a){return this.sourceBuffers_.size?a==shaka.util.ManifestParserUtils.ContentType.TEXT?this.textEngine_.bufferStart():shaka.media.TimeRangesUtils.bufferStart(this.getBuffered_(a)):null};
shaka.media.MediaSourceEngine.prototype.bufferEnd=function(a){return this.sourceBuffers_.size?a==shaka.util.ManifestParserUtils.ContentType.TEXT?this.textEngine_.bufferEnd():shaka.media.TimeRangesUtils.bufferEnd(this.getBuffered_(a)):null};shaka.media.MediaSourceEngine.prototype.isBuffered=function(a,b){if(a==shaka.util.ManifestParserUtils.ContentType.TEXT)return this.textEngine_.isBuffered(b);a=this.getBuffered_(a);return shaka.media.TimeRangesUtils.isBuffered(a,b)};
shaka.media.MediaSourceEngine.prototype.bufferedAheadOf=function(a,b){if(a==shaka.util.ManifestParserUtils.ContentType.TEXT)return this.textEngine_.bufferedAheadOf(b);a=this.getBuffered_(a);return shaka.media.TimeRangesUtils.bufferedAheadOf(a,b)};
shaka.media.MediaSourceEngine.prototype.getBufferedInfo=function(){var a=shaka.util.ManifestParserUtils.ContentType,b=shaka.media.TimeRangesUtils;a={total:this.reloadingMediaSource_?[]:b.getBufferedInfo(this.video_.buffered),audio:b.getBufferedInfo(this.getBuffered_(a.AUDIO)),video:b.getBufferedInfo(this.getBuffered_(a.VIDEO)),text:[]};if(this.textEngine_){b=this.textEngine_.bufferStart();var c=this.textEngine_.bufferEnd();b!=null&&c!=null&&a.text.push({start:b,end:c})}return a};
shaka.media.MediaSourceEngine.prototype.getBuffered_=function(a){if(this.reloadingMediaSource_||this.usingRemotePlayback_)return null;try{return this.sourceBuffers_.get(a).buffered}catch(b){return this.sourceBuffers_.has(a)&&shaka.log.error("failed to get buffered range for "+a,b),null}};shaka.media.MediaSourceEngine.prototype.getCaptionParser=function(a){return new shaka.media.ClosedCaptionParser(a)};
shaka.media.MediaSourceEngine.prototype.getTimestampAndDispatchMetadata=function(a,b,c,d,e,f){var g=this;f=f===void 0?!1:f;var h=null,k=[],l=shaka.util.BufferUtils.toUint8(b);if(shaka.util.MimeUtils.RAW_FORMATS.includes(e))b=shaka.util.Id3Utils.getID3Frames(l),b.length&&c&&((f=b.find(function(r){return r.description==="com.apple.streaming.transportStreamTimestamp"}))&&typeof f.data=="number"&&(h=Math.round(f.data)/1E3),this.playerInterface_.onMetadata([{cueTime:c.startTime,data:l,frames:b,dts:c.startTime,
pts:c.startTime}],0,c.endTime));else if(e.includes("/mp4")&&c&&c.initSegmentReference){l=shaka.util.Mp4Parser;a=new l;var m=d.emsgSchemeIdUris!=null&&d.emsgSchemeIdUris.length>0||this.config_.dispatchAllEmsgBoxes;m&&a.fullBox("emsg",function(r){return g.parseEMSG_(c,d.emsgSchemeIdUris,r)});var n=c.initSegmentReference.timescale;e=n&&!isNaN(n);var p=0,q=!1;e&&a.fullBox("prft",function(r){goog.asserts.assert(typeof n=="number","Timescale should be a number!");g.parsePrft_(n,r)}).box("moof",l.children).box("traf",
l.children).fullBox("tfdt",function(r){q||(goog.asserts.assert(r.version==0||r.version==1,"TFDT version can only be 0 or 1"),goog.asserts.assert(typeof n=="number","Timescale should be a number!"),p=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(r.reader,r.version).baseMediaDecodeTime/n,q=!0,m||r.parser.stop())});(m||e)&&a.parse(b,!1,f);q&&c.timestampOffset==0&&(h=p)}else e.includes("/mp4")||e.includes("/webm")||!shaka.util.TsParser.probe(l)||(this.tsParsers_.has(a)||this.tsParsers_.set(a,new shaka.util.TsParser),
k=this.tsParsers_.get(a),k.clearData(),k.setDiscontinuitySequence(c.discontinuitySequence),k.parse(l),b=k.getStartTime(a),b!=null&&(h=b),k=k.getMetadata());return{timestamp:h,metadata:k}};
shaka.media.MediaSourceEngine.prototype.parseEMSG_=function(a,b,c){if(c.version===0){var d=c.reader.readTerminatedString();var e=c.reader.readTerminatedString();var f=c.reader.readUint32();var g=c.reader.readUint32();var h=c.reader.readUint32();var k=c.reader.readUint32();var l=a.startTime+g/f}else f=c.reader.readUint32(),l=c.reader.readUint64()/f+a.timestampOffset,g=l-a.startTime,h=c.reader.readUint32(),k=c.reader.readUint32(),d=c.reader.readTerminatedString(),e=c.reader.readTerminatedString();a=
c.reader.readBytes(c.reader.getLength()-c.reader.getPosition(),!0);if(b&&b.includes(d)||this.config_.dispatchAllEmsgBoxes)if(d=="urn:mpeg:dash:event:2012")this.playerInterface_.onManifestUpdate();else if(b=l+h/f,this.playerInterface_.onEmsg({startTime:l,endTime:b,schemeIdUri:d,value:e,timescale:f,presentationTimeDelta:g,eventDuration:h,id:k,messageData:a}),d=="https://aomedia.org/emsg/ID3"||d=="https://developer.apple.com/streaming/emsg-id3")if(f=shaka.util.Id3Utils.getID3Frames(a),f.length)this.playerInterface_.onMetadata([{cueTime:l,
data:a,frames:f,dts:l,pts:l}],0,b)};shaka.media.MediaSourceEngine.prototype.parsePrft_=function(a,b){goog.asserts.assert(b.version==0||b.version==1,"PRFT version can only be 0 or 1");b=shaka.util.Mp4BoxParsers.parsePRFTInaccurate(b.reader,b.version);var c=shaka.util.TimeUtils.convertNtp(b.ntpTimestamp);b={wallClockTime:c,programStartDate:new Date(c-b.mediaTime/a*1E3)};a=shaka.util.FakeEvent.EventName.Prft;b=(new Map).set("detail",b);a=new shaka.util.FakeEvent(a,b);this.playerInterface_.onEvent(a)};
shaka.media.MediaSourceEngine.prototype.appendBuffer=function(a,b,c,d,e,f,g,h,k,l){f=f===void 0?!1:f;g=g===void 0?!1:g;h=h===void 0?!1:h;k=k===void 0?!1:k;var m=this,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P,Q,O;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(N){switch(N.nextAddress){case 1:n=shaka.util.ManifestParserUtils.ContentType;if(a!=n.TEXT){N.jumpTo(2);break}if(m.manifestType_!=shaka.media.ManifestParser.HLS){N.jumpTo(3);break}return N.yield(m.textSequenceModeOffset_,
4);case 4:p=N.yieldResult,m.textEngine_.setTimestampOffset(p);case 3:return N.yield(m.textEngine_.appendBuffer(b,c?c.startTime:null,c?c.endTime:null,c?c.getUris()[0]:null),5);case 5:return N.return();case 2:if(k||!m.needSplitMuxedContent_){N.jumpTo(6);break}return N.yield(m.appendBuffer(n.AUDIO,b,c,d,e,f,g,h,!0),7);case 7:return N.yield(m.appendBuffer(n.VIDEO,b,c,d,e,f,g,h,!0),8);case 8:return N.return();case 6:if(!m.sourceBuffers_.has(a))return shaka.log.warning("Attempted to restore a non-existent source buffer"),
N.return();q=m.sourceBuffers_.get(a).timestampOffset;r=m.sourceBufferTypes_.get(a);m.transmuxers_.has(a)&&(r=m.transmuxers_.get(a).getOriginalMimeType());if(c&&(t=m.getTimestampAndDispatchMetadata(a,b,c,d,r,h),w=t.timestamp,v=t.metadata,w!=null&&(m.firstVideoTimestamp_==null&&a==n.VIDEO&&(m.firstVideoTimestamp_=w,m.firstVideoReferenceStartTime_=c.startTime,m.firstAudioTimestamp_!=null&&(u=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(u=m.firstVideoTimestamp_-m.firstAudioTimestamp_),
m.audioCompensation_.resolve(u))),m.firstAudioTimestamp_==null&&a==n.AUDIO&&(m.firstAudioTimestamp_=w,m.firstAudioReferenceStartTime_=c.startTime,m.firstVideoTimestamp_!=null&&(x=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(x=m.firstVideoTimestamp_-m.firstAudioTimestamp_),m.audioCompensation_.resolve(x))),z=w,B=shaka.util.MimeUtils.RAW_FORMATS,!m.sequenceMode_&&B.includes(m.sourceBufferTypes_.get(a))&&(z=0),C=c.startTime-z,y=Math.abs(q-C),(y>=.001||f||g)&&(!h||C>0||!q)&&(q=
C,m.attemptTimestampOffsetCalculation_&&(m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,q)},null))),(A=a==n.VIDEO||!m.sourceBuffers_.has(n.VIDEO))&&m.textSequenceModeOffset_.resolve(q)),v.length))m.playerInterface_.onMetadata(v,q,c?c.endTime:null);e&&a==n.VIDEO&&(m.textEngine_||m.reinitText(shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE,m.sequenceMode_,!1),m.captionParser_||(D=r.split(";",1)[0],m.captionParser_=m.getCaptionParser(D)),
c?(E=m.captionParser_.parseFrom(b),E.length&&m.textEngine_.storeAndAppendClosedCaptions(E,q)):m.captionParser_.init(b,g,l));if(!m.transmuxers_.has(a)){N.jumpTo(9);break}return N.yield(m.transmuxers_.get(a).transmux(b,d,c,m.mediaSource_.duration,a),10);case 10:F=N.yieldResult,ArrayBuffer.isView(F)?b=F:(L=F,L.init!=null&&(K=L.init,m.enqueueOperation_(a,function(){m.append_(a,K,q,d)},c?c.getUris()[0]:null)),b=L.data);case 9:b=m.workAroundBrokenPlatforms_(d,b,c,a);if(!c||!m.sequenceMode_||a==n.TEXT){N.jumpTo(11);
break}if(!f&&!g){N.jumpTo(11);break}J=c.startTime;if(m.manifestType_!=shaka.media.ManifestParser.HLS||m.needSplitMuxedContent_||a!=n.AUDIO||!m.sourceBuffers_.has(n.VIDEO)){N.jumpTo(13);break}return N.yield(m.audioCompensation_,14);case 14:I=N.yieldResult,Math.abs(I)>.15&&(J-=I);case 13:m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,J)},null);case 11:return G=null,N.yield(m.enqueueOperation_(a,function(){goog.DEBUG&&c&&!c.isPreload()&&
!h&&(G=m.getBuffered_(a));m.append_(a,b,q,d)},c?c.getUris()[0]:null),15);case 15:goog.DEBUG&&c&&!c.isPreload()&&!h&&(M=m.getBuffered_(a),H=shaka.media.TimeRangesUtils.computeAddedRange(G,M))&&(P=c.endTime-c.startTime,Q=H.end-H.start,O=Math.abs(H.end-c.endTime),P>.1&&(O>P/2||Math.abs(P-Q)>.03)&&shaka.log.error("Possible encoding problem detected!","Unexpected buffered range for reference",c,"from URIs",c.getUris(),"should be",{start:c.startTime,end:c.endTime},"but got",H)),N.jumpToEnd()}})};
shaka.media.MediaSourceEngine.prototype.setSelectedClosedCaptionId=function(a){var b=this.bufferEnd(shaka.util.ManifestParserUtils.ContentType.VIDEO)||0;this.textEngine_.setSelectedClosedCaptionId(a,b)};shaka.media.MediaSourceEngine.prototype.clearSelectedClosedCaptionId=function(){this.textEngine_&&this.textEngine_.setSelectedClosedCaptionId("",0)};
shaka.media.MediaSourceEngine.prototype.remove=function(a,b,c,d){var e=this,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){return h.nextAddress==1?(f=shaka.util.ManifestParserUtils.ContentType,a==f.VIDEO&&e.captionParser_&&(e.captionParser_.remove(d),g=e.textEngine_.bufferStart()||0,e.textEngine_.remove(g,c,!0)),a==f.TEXT?h.yield(e.textEngine_.remove(b,c),0):c>b?h.yield(e.enqueueOperation_(a,function(){return e.remove_(a,b,c)},null),5):h.jumpTo(0)):e.needSplitMuxedContent_?
h.yield(e.enqueueOperation_(f.AUDIO,function(){return e.remove_(f.AUDIO,b,c)},null),0):h.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.clear=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.nextAddress==1?(c=shaka.util.ManifestParserUtils.ContentType,a==c.TEXT?b.textEngine_?d.yield(b.textEngine_.remove(0,Infinity),0):d.return():a===c.VIDEO&&b.captionParser_&&b.textEngine_?d.yield(b.textEngine_.remove(0,Infinity,!0),4):d.jumpTo(4)):d.nextAddress!=6?d.yield(b.enqueueOperation_(a,function(){return b.remove_(a,0,b.mediaSource_.duration)},null),
6):b.needSplitMuxedContent_?d.yield(b.enqueueOperation_(c.AUDIO,function(){return b.remove_(c.AUDIO,0,b.mediaSource_.duration)},null),0):d.jumpTo(0)})};shaka.media.MediaSourceEngine.prototype.resetCaptionParser=function(){this.captionParser_&&this.captionParser_.reset()};
shaka.media.MediaSourceEngine.prototype.flush=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.nextAddress==1?(c=shaka.util.ManifestParserUtils.ContentType,a==c.TEXT?d.return():d.yield(b.enqueueOperation_(a,function(){return b.flush_(a)},null),2)):b.needSplitMuxedContent_?d.yield(b.enqueueOperation_(c.AUDIO,function(){return b.flush_(c.AUDIO)},null),0):d.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.setStreamProperties=function(a,b,c,d,e,f,g,h){var k=this,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.nextAddress==1){l=shaka.util.ManifestParserUtils.ContentType;if(a==l.TEXT)return e||k.textEngine_.setTimestampOffset(b),k.textEngine_.setAppendWindow(c,d),p.return();m=[];return p.yield(k.codecSwitchIfNecessary_(a,f,g,h),2)}n=p.yieldResult;n||(m.push(k.enqueueOperation_(a,function(){return k.abort_(a)},null)),k.needSplitMuxedContent_&&
m.push(k.enqueueOperation_(l.AUDIO,function(){return k.abort_(l.AUDIO)},null)));e||(m.push(k.enqueueOperation_(a,function(){return k.setTimestampOffset_(a,b)},null)),k.needSplitMuxedContent_&&m.push(k.enqueueOperation_(l.AUDIO,function(){return k.setTimestampOffset_(l.AUDIO,b)},null)));if(c!=0||d!=Infinity)m.push(k.enqueueOperation_(a,function(){return k.setAppendWindow_(a,c,d)},null)),k.needSplitMuxedContent_&&m.push(k.enqueueOperation_(l.AUDIO,function(){return k.setAppendWindow_(l.AUDIO,c,d)},
null));return m.length?p.yield(Promise.all(m),0):p.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.resync=function(a,b){var c=this,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1){d=shaka.util.ManifestParserUtils.ContentType;if(a==d.TEXT)return f.return();a==d.VIDEO&&(c.textSequenceModeOffset_=new shaka.util.PublicPromise);if(!c.sequenceMode_||(e=c.bufferEnd(a))&&Math.abs(e-b)<.15)return f.return();c.enqueueOperation_(a,function(){return c.abort_(a)},null);c.needSplitMuxedContent_&&c.enqueueOperation_(d.AUDIO,function(){return c.abort_(d.AUDIO)},
null);return f.yield(c.enqueueOperation_(a,function(){return c.setTimestampOffset_(a,b)},null),2)}return c.needSplitMuxedContent_?f.yield(c.enqueueOperation_(d.AUDIO,function(){return c.setTimestampOffset_(d.AUDIO,b)},null),0):f.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.endOfStream=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){return c.yield(b.enqueueBlockingOperation_(function(){b.ended()||b.closed()||(a?b.mediaSource_.endOfStream(a):b.mediaSource_.endOfStream())}),0)})};
shaka.media.MediaSourceEngine.prototype.setDuration=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){return c.yield(b.enqueueBlockingOperation_(function(){if(b.config_.durationReductionEmitsUpdateEnd&&a<b.mediaSource_.duration)for(var d=(0,$jscomp.makeIterator)(b.sourceBuffers_.keys()),e=d.next();!e.done;e=d.next()){e=e.value;var f={start:function(){},p:new shaka.util.PublicPromise,uri:null};b.queues_.get(e).unshift(f)}b.mediaSource_.duration=a;b.lastDuration_=
a}),0)})};shaka.media.MediaSourceEngine.prototype.getDuration=function(){return this.mediaSource_.duration};
shaka.media.MediaSourceEngine.prototype.setLiveSeekableRange=function(a,b){var c=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(c.destroyer_.destroyed()||c.video_.error||c.usingRemotePlayback_||c.reloadingMediaSource_)return d.return();goog.asserts.assert("setLiveSeekableRange"in c.mediaSource_,"Using setLiveSeekableRange on not supported platform");return c.ended()||c.closed()?d.return():d.yield(c.enqueueBlockingOperation_(function(){c.ended()||c.closed()||c.mediaSource_.setLiveSeekableRange(a,
b)}),0)})};
shaka.media.MediaSourceEngine.prototype.clearLiveSeekableRange=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(a.destroyer_.destroyed()||a.video_.error||a.usingRemotePlayback_||a.reloadingMediaSource_)return b.return();goog.asserts.assert("clearLiveSeekableRange"in a.mediaSource_,"Using clearLiveSeekableRange on not supported platform");return a.ended()||a.closed()?b.return():b.yield(a.enqueueBlockingOperation_(function(){a.ended()||a.closed()||a.mediaSource_.clearLiveSeekableRange()}),
0)})};shaka.media.MediaSourceEngine.prototype.appendDependency=function(a,b,c){this.lcevcDec_&&this.lcevcDec_.appendBuffer(a,b,c)};shaka.media.MediaSourceEngine.prototype.append_=function(a,b,c,d){this.appendDependency(b,c,d);this.sourceBuffers_.get(a).appendBuffer(b)};shaka.media.MediaSourceEngine.prototype.remove_=function(a,b,c){if(c<=b)this.onUpdateEnd_(a);else this.sourceBuffers_.get(a).remove(b,c)};
shaka.media.MediaSourceEngine.prototype.abort_=function(a){var b=this.sourceBuffers_.get(a),c=b.appendWindowStart,d=b.appendWindowEnd;b.abort();b.appendWindowStart=c;b.appendWindowEnd=d;this.onUpdateEnd_(a)};shaka.media.MediaSourceEngine.prototype.flush_=function(a){goog.asserts.assert(this.video_.buffered.length==0,"MediaSourceEngine.flush_ should only be used after clearing all data!");this.video_.currentTime-=.001;this.onUpdateEnd_(a)};
shaka.media.MediaSourceEngine.prototype.setTimestampOffset_=function(a,b){b<0&&(b+=.001);this.sourceBuffers_.get(a).timestampOffset=b;this.onUpdateEnd_(a)};shaka.media.MediaSourceEngine.prototype.setAppendWindow_=function(a,b,c){var d=this.sourceBuffers_.get(a);if(d.appendWindowEnd!==c||d.appendWindowStart!==b)d.appendWindowStart=0,d.appendWindowEnd=c,d.appendWindowStart=b;this.onUpdateEnd_(a)};
shaka.media.MediaSourceEngine.prototype.onError_=function(a){var b=this.queues_.get(a)[0];goog.asserts.assert(b,"Spurious error event!");goog.asserts.assert(!this.sourceBuffers_.get(a).updating,"SourceBuffer should not be updating on error!");b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_FAILED,this.video_.error?this.video_.error.code:0,b.uri))};
shaka.media.MediaSourceEngine.prototype.onUpdateEnd_=function(a){if(this.reloadingMediaSource_||this.destroyer_.destroyed()){var b=this.queues_.get(a);b&&b.length&&((b=b[0])&&b.p&&b.p.resolve(),this.queues_.set(a,[]))}else b=this.queues_.get(a)[0],goog.asserts.assert(b,"Spurious updateend event!"),b&&(goog.asserts.assert(!this.sourceBuffers_.get(a).updating,"SourceBuffer should not be updating on updateend!"),b.p.resolve(),this.popFromQueue_(a))};
shaka.media.MediaSourceEngine.prototype.enqueueOperation_=function(a,b,c){this.destroyer_.ensureNotDestroyed();b={start:b,p:new shaka.util.PublicPromise,uri:c};this.queues_.get(a).push(b);this.queues_.get(a).length==1&&this.startOperation_(a);return b.p};
shaka.media.MediaSourceEngine.prototype.enqueueBlockingOperation_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){switch(C.nextAddress){case 1:b.destroyer_.ensureNotDestroyed();c=[];d=Array.from(b.sourceBuffers_.keys());e=(0,$jscomp.makeIterator)(d);f=e.next();for(g={};!f.done;g={ready:void 0},f=e.next())h=f.value,g.ready=new shaka.util.PublicPromise,k={start:function(y){return function(){return y.ready.resolve()}}(g),
p:g.ready,uri:null},l=b.queues_.get(h),l.push(k),c.push(g.ready),l.length==1&&k.start();C.setCatchFinallyBlocks(2);return C.yield(Promise.all(c),4);case 4:C.leaveTryBlock(3);break;case 2:m=C.enterCatchBlock();goog.asserts.assert(b.destroyer_.destroyed(),"Should be destroyed by now");if(goog.DEBUG)for(n=(0,$jscomp.makeIterator)(d),p=n.next();!p.done;p=n.next())q=p.value,r=b.queues_.get(q),r.length&&(goog.asserts.assert(r.length==1,"Should be at most one item in queue!"),goog.asserts.assert(c.includes(r[0].p),
"The item in queue should be one of our waiters!"),r.shift());throw m;case 3:if(goog.DEBUG)for(t=(0,$jscomp.makeIterator)(d),w=t.next();!w.done;w=t.next())v=w.value,goog.asserts.assert(b.sourceBuffers_.get(v).updating==0,"SourceBuffers should not be updating after a blocking op!");C.setCatchFinallyBlocks(5,6);return C.yield(a(),6);case 6:C.enterFinallyBlock();u=(0,$jscomp.makeIterator)(d);for(x=u.next();!x.done;x=u.next())z=x.value,b.popFromQueue_(z);C.leaveFinallyBlock(0);break;case 5:throw B=C.enterCatchBlock(),
new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,B,b.video_.error||"No error in the media element",null);}})};shaka.media.MediaSourceEngine.prototype.popFromQueue_=function(a){goog.asserts.assert(this.queues_.has(a),"Queue should exist");this.queues_.get(a).shift();this.startOperation_(a)};
shaka.media.MediaSourceEngine.prototype.startOperation_=function(a){var b=this.queues_.get(a)[0];if(b)try{b.start()}catch(c){c.name=="QuotaExceededError"?b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR,a)):this.isStreamingAllowed()?b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,c,this.video_.error||"No error in the media element",
b.uri)):b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.STREAMING_NOT_ALLOWED,a)),this.popFromQueue_(a)}};shaka.media.MediaSourceEngine.prototype.getTextDisplayer=function(){goog.asserts.assert(this.textDisplayer_,"TextDisplayer should only be null when this is destroyed");return this.textDisplayer_};shaka.media.MediaSourceEngine.prototype.setTextDisplayer=function(a){this.textDisplayer_=a;this.textEngine_&&this.textEngine_.setDisplayer(a)};
shaka.media.MediaSourceEngine.prototype.setSegmentRelativeVttTiming=function(a){this.segmentRelativeVttTiming_=a};
shaka.media.MediaSourceEngine.prototype.workAroundBrokenPlatforms_=function(a,b,c,d){var e=shaka.util.ManifestParserUtils.ContentType;if(shaka.util.MimeUtils.getContainerType(this.sourceBufferTypes_.get(d))!="mp4")return b;var f=c===null,g=this.expectedEncryption_.get(d),h=this.playerInterface_.getKeySystem(),k=!1;c&&c.initSegmentReference&&(k=c.initSegmentReference.encrypted);c=c?c.getUris()[0]:null;var l=shaka.device.DeviceFactory.getDevice();this.config_.correctEc3Enca&&f&&d===e.AUDIO&&(b=shaka.media.ContentWorkarounds.correctEnca(b));
this.config_.insertFakeEncryptionInInit&&g&&l.requiresEncryptionInfoInAllInitSegments(h,d)&&(f?(shaka.log.debug("Forcing fake encryption information in init segment."),b=shaka.media.ContentWorkarounds.fakeEncryption(a,b,c)):!k&&l.requiresTfhdFix(d)&&(shaka.log.debug("Forcing fake encryption information in media segment."),b=shaka.media.ContentWorkarounds.fakeMediaEncryption(b)));f&&l.requiresEC3InitSegments()&&(shaka.log.debug("Forcing fake EC-3 information in init segment."),b=shaka.media.ContentWorkarounds.fakeEC3(b));
return b};
shaka.media.MediaSourceEngine.prototype.change_=function(a,b,c){if(a===shaka.util.ManifestParserUtils.ContentType.TEXT)shaka.log.debug("Change not supported for "+a);else{var d=this.sourceBufferTypes_.get(a);shaka.log.debug("Change Type: "+d+" -> "+b);shaka.media.Capabilities.isChangeTypeSupported()?(this.transmuxers_.has(a)&&(this.transmuxers_.get(a).destroy(),this.transmuxers_.delete(a)),c&&this.transmuxers_.set(a,c),c=this.addExtraFeaturesToMimeType_(b),this.sourceBuffers_.get(a).changeType(c),this.sourceBufferTypes_.set(a,
b)):shaka.log.debug("Change Type not supported");this.onUpdateEnd_(a)}};shaka.media.MediaSourceEngine.prototype.changeType=function(a,b,c){var d=this;return this.enqueueOperation_(a,function(){return d.change_(a,b,c)},null)};
shaka.media.MediaSourceEngine.prototype.reset_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){if(C.nextAddress==1){if(b.reloadingMediaSource_||b.usingRemotePlayback_)return C.return();c=shaka.util.ManifestParserUtils.ContentType;b.reloadingMediaSource_=!0;b.needSplitMuxedContent_=!1;d=b.video_.currentTime;e=b.video_.autoplay;b.video_.paused||(b.playAfterReset_=!0);b.playbackHasBegun_&&(b.video_.autoplay=!1);C.setFinallyBlock(2);
b.eventManager_.removeAll();f=(0,$jscomp.makeIterator)(b.transmuxers_.values());for(g=f.next();!g.done;g=f.next())h=g.value,h.destroy();k=(0,$jscomp.makeIterator)(b.sourceBuffers_.values());for(l=k.next();!l.done;l=k.next()){m=l.value;try{b.mediaSource_.removeSourceBuffer(m)}catch(y){shaka.log.debug("Exception on removeSourceBuffer",y)}}b.transmuxers_.clear();b.sourceBuffers_.clear();n=b.mediaSource_.duration;b.mediaSourceOpen_=new shaka.util.PublicPromise;b.mediaSource_=b.createMediaSource(b.mediaSourceOpen_);
return C.yield(b.mediaSourceOpen_,4)}if(C.nextAddress!=2){!isNaN(n)&&n?b.mediaSource_.duration=n:!isNaN(b.lastDuration_)&&b.lastDuration_&&(b.mediaSource_.duration=b.lastDuration_);p=new shaka.util.PublicPromise;q=b.mediaSource_.sourceBuffers;r=a.size;t=0;w=function(){t++;t===r&&(p.resolve(),b.eventManager_.unlisten(q,"addsourcebuffer",w))};b.eventManager_.listen(q,"addsourcebuffer",w);v=(0,$jscomp.makeIterator)(a.keys());for(u=v.next();!u.done;u=v.next())x=u.value,z=a.get(x),b.initSourceBuffer_(x,
z,z.codecs);(B=a.get(c.AUDIO))&&B.isAudioMuxedInVideo&&(b.needSplitMuxedContent_=!0);b.needSplitMuxedContent_&&!b.queues_.has(c.AUDIO)&&b.queues_.set(c.AUDIO,[]);b.video_.currentTime=d;return C.yield(p,2)}C.enterFinallyBlock();b.reloadingMediaSource_=!1;b.destroyer_.ensureNotDestroyed();b.eventManager_.listenOnce(b.video_,"canplaythrough",function(){b.destroyer_.destroyed()||(b.video_.autoplay=e,b.playAfterReset_&&(b.playAfterReset_=!1,b.video_.play()))});return C.leaveFinallyBlock(0)})};
shaka.media.MediaSourceEngine.prototype.reset=function(a){var b=this;return this.enqueueBlockingOperation_(function(){return b.reset_(a)})};
shaka.media.MediaSourceEngine.prototype.getRealInfo_=function(a,b,c){var d=shaka.util.ManifestParserUtils.ContentType,e=shaka.util.MimeUtils,f=!1,g=shaka.util.ManifestParserUtils.guessCodecsSafe(d.AUDIO,(c||"").split(",")),h=shaka.util.ManifestParserUtils.guessCodecsSafe(d.VIDEO,(c||"").split(",")),k=h;a==d.AUDIO&&(k=g);k||(k=c);c=shaka.util.MimeUtils.getFullType(b,k);var l=e.getBasicType(this.sourceBufferTypes_.get(a));d=this.config_.forceTransmux;!shaka.media.Capabilities.isTypeSupported(c)||!this.sequenceMode_&&
shaka.util.MimeUtils.RAW_FORMATS.includes(c)?d=!0:d||b==l||(d=!shaka.device.DeviceFactory.getDevice().supportsContainerChangeType()&&shaka.util.MimeUtils.RAW_FORMATS.includes(b));l=shaka.transmuxer.TransmuxerEngine;if(d&&(b=shaka.util.MimeUtils.getFullTypeWithAllCodecs(b,k),k=l.findTransmuxer(b))){var m=k();g&&h&&(f=!0);c=m.convertCodecs(a,b)}a=e.getNormalizedCodec(e.getCodecs(c));e=e.getBasicType(c);return{transmuxer:m,transmuxerMuxed:f,basicType:e,codec:a,mimeType:c}};
shaka.media.MediaSourceEngine.prototype.getInfoAboutResetOrChangeType_=function(a,b,c,d){var e=shaka.util.ManifestParserUtils.ContentType;if(a==e.TEXT)return{type:shaka.media.MediaSourceEngine.ResetMode_.NONE,newMimeType:b,transmuxer:null};var f=shaka.util.MimeUtils,g=f.getNormalizedCodec(f.getCodecs(this.sourceBufferTypes_.get(a))),h=f.getBasicType(this.sourceBufferTypes_.get(a)),k=this.getRealInfo_(a,b,c),l=k.transmuxer,m=k.transmuxerMuxed,n=k.basicType,p=k.codec;k=k.mimeType;var q=!0;m&&this.sourceBufferTypes_.has(e.AUDIO)&&
(b=this.getRealInfo_(e.AUDIO,b,c),c=f.getNormalizedCodec(f.getCodecs(this.sourceBufferTypes_.get(e.AUDIO))),f=f.getBasicType(this.sourceBufferTypes_.get(e.AUDIO)),q=c==b.codec&&f==b.basicType,b.transmuxer&&b.transmuxer.destroy());if(g===p&&h===n&&q)return{type:shaka.media.MediaSourceEngine.ResetMode_.NONE,newMimeType:k,transmuxer:l};g=!0;if(this.needSplitMuxedContent_&&!d.has(e.AUDIO)||m&&l&&!this.transmuxers_.has(a))g=!1;if(g&&this.config_.codecSwitchingStrategy===shaka.config.CodecSwitchingStrategy.SMOOTH&&
shaka.media.Capabilities.isChangeTypeSupported())return{type:shaka.media.MediaSourceEngine.ResetMode_.CHANGE_TYPE,newMimeType:k,transmuxer:l};l&&l.destroy();return{type:shaka.media.MediaSourceEngine.ResetMode_.RESET,newMimeType:k,transmuxer:null}};
shaka.media.MediaSourceEngine.prototype.codecSwitchIfNecessary_=function(a,b,c,d){var e=this,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.nextAddress==1){f=shaka.util.ManifestParserUtils.ContentType;g=e.getInfoAboutResetOrChangeType_(a,b,c,d);h=g.type;k=g.transmuxer;l=g.newMimeType;if(m=d.get(f.AUDIO))e.needSplitMuxedContent_=m.isAudioMuxedInVideo;if(h==shaka.media.MediaSourceEngine.ResetMode_.NONE)return e.transmuxers_.has(a)&&!k?(e.transmuxers_.get(a).destroy(),
e.transmuxers_.delete(a)):!e.transmuxers_.has(a)&&k?e.transmuxers_.set(a,k):k&&(e.transmuxers_.has(a)&&e.transmuxers_.get(a).transmux!==k.transmux?(e.transmuxers_.get(a).destroy(),e.transmuxers_.set(a,k)):k.destroy()),n.return(!1);if(h==shaka.media.MediaSourceEngine.ResetMode_.CHANGE_TYPE)return n.yield(e.changeType(a,l,k),3);if(h!=shaka.media.MediaSourceEngine.ResetMode_.RESET)return n.jumpTo(3);k&&k.destroy();return n.yield(e.reset(d),3)}return n.return(!0)})};
shaka.media.MediaSourceEngine.prototype.isResetMediaSourceNecessary=function(a,b,c,d){a=this.getInfoAboutResetOrChangeType_(a,b,c,d);a.transmuxer&&a.transmuxer.destroy();return a.type==shaka.media.MediaSourceEngine.ResetMode_.RESET};shaka.media.MediaSourceEngine.prototype.updateLcevcDec=function(a){this.lcevcDec_=a};shaka.media.MediaSourceEngine.prototype.addExtraFeaturesToMimeType_=function(a){var b=this.config_.addExtraFeaturesToSourceBuffer(a);a+=b;shaka.log.debug("Using full mime type",a);return a};
shaka.media.MediaSourceEngine.createObjectURL=window.URL.createObjectURL;shaka.media.MediaSourceEngine.SourceBufferMode_={SEQUENCE:"sequence",SEGMENTS:"segments"};shaka.media.MediaSourceEngine.ResetMode_={NONE:"none",RESET:"reset",CHANGE_TYPE:"changeType"};shaka.media.PlayRateController=function(a){var b=this;this.harness_=a;this.isBuffering_=!1;this.rate_=this.harness_.getRate();this.pollRate_=.25;this.timer_=new shaka.util.Timer(function(){b.harness_.movePlayhead(b.rate_*b.pollRate_)})};shaka.media.PlayRateController.prototype.release=function(){this.set(this.getDefaultRate());this.timer_&&(this.timer_.stop(),this.timer_=null);this.harness_=null};shaka.media.PlayRateController.prototype.setBuffering=function(a){this.isBuffering_=a;this.apply_()};
shaka.media.PlayRateController.prototype.set=function(a){goog.asserts.assert(a!=0,"Should never set rate of 0 explicitly!");this.rate_=a;this.apply_()};shaka.media.PlayRateController.prototype.getRealRate=function(){return this.rate_};shaka.media.PlayRateController.prototype.getDefaultRate=function(){return this.harness_.getDefaultRate()};
shaka.media.PlayRateController.prototype.apply_=function(){this.timer_.stop();var a=this.calculateCurrentRate_();shaka.log.v1("Changing effective playback rate to",a);if(a>=0)try{this.applyRate_(a);return}catch(b){}this.timer_.tickEvery(this.pollRate_);this.applyRate_(0)};shaka.media.PlayRateController.prototype.calculateCurrentRate_=function(){return this.isBuffering_?0:this.rate_};
shaka.media.PlayRateController.prototype.applyRate_=function(a){var b=this.harness_.getRate();b!=a&&this.harness_.setRate(a);return b!=a};shaka.util.MediaReadyState=function(){};shaka.util.MediaReadyState.waitForReadyState=function(a,b,c,d){b==HTMLMediaElement.HAVE_NOTHING||a.readyState>=b?d():(b=shaka.util.MediaReadyState.READY_STATES_TO_EVENT_NAMES_.value().get(b),c.listenOnce(a,b,d))};
shaka.util.MediaReadyState.READY_STATES_TO_EVENT_NAMES_=new shaka.util.Lazy(function(){return new Map([[HTMLMediaElement.HAVE_METADATA,"loadedmetadata"],[HTMLMediaElement.HAVE_CURRENT_DATA,"loadeddata"],[HTMLMediaElement.HAVE_FUTURE_DATA,"canplay"],[HTMLMediaElement.HAVE_ENOUGH_DATA,"canplaythrough"]])});shaka.media.VideoWrapper=function(a,b,c,d){var e=this;this.video_=a;this.onSeek_=b;this.onStarted_=c;this.startTime_=null;this.getStartTime_=function(){e.startTime_==null&&(e.startTime_=d());return e.startTime_};this.started_=!1;this.eventManager_=new shaka.util.EventManager;this.mover_=new shaka.media.VideoWrapper.PlayheadMover(a,10);shaka.util.MediaReadyState.waitForReadyState(this.video_,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){e.setStartTime_(e.getStartTime_())})};
shaka.media.VideoWrapper.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.mover_!=null&&(this.mover_.release(),this.mover_=null);this.onSeek_=function(){};this.video_=null};shaka.media.VideoWrapper.prototype.getTime=function(){return this.started_?this.video_.currentTime:this.getStartTime_()};
shaka.media.VideoWrapper.prototype.setTime=function(a){var b=this;this.video_.readyState>0?this.mover_.moveTo(a):shaka.util.MediaReadyState.waitForReadyState(this.video_,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){b.setStartTime_(b.getStartTime_())})};
shaka.media.VideoWrapper.prototype.setStartTime_=function(a){var b=this;Math.abs(this.video_.currentTime-a)<.001?this.startListeningToSeeks_():(this.eventManager_.listenOnce(this.video_,"seeking",function(){b.startListeningToSeeks_()}),this.mover_.moveTo(this.video_.currentTime&&this.video_.currentTime!=0?this.video_.currentTime:a))};
shaka.media.VideoWrapper.prototype.startListeningToSeeks_=function(){var a=this;goog.asserts.assert(this.video_.readyState>0,"The media element should be ready before we listen for seeking.");this.started_=!0;this.eventManager_.listen(this.video_,"seeking",function(){return a.onSeek_()});this.onStarted_(this.video_.currentTime)};
shaka.media.VideoWrapper.PlayheadMover=function(a,b){var c=this;this.mediaElement_=a;this.maxAttempts_=b;this.targetTime_=this.originTime_=this.remainingAttempts_=0;this.timer_=new shaka.util.Timer(function(){return c.onTick_()})};shaka.media.VideoWrapper.PlayheadMover.prototype.release=function(){this.timer_&&(this.timer_.stop(),this.timer_=null);this.mediaElement_=null};
shaka.media.VideoWrapper.PlayheadMover.prototype.moveTo=function(a){this.originTime_=this.mediaElement_.currentTime;this.targetTime_=a;this.remainingAttempts_=this.maxAttempts_;this.mediaElement_.currentTime=a;this.timer_.tickEvery(.1)};
shaka.media.VideoWrapper.PlayheadMover.prototype.onTick_=function(){this.remainingAttempts_<=0?(shaka.log.warning(["Failed to move playhead from",this.originTime_,"to",this.targetTime_].join(" ")),this.timer_.stop()):this.mediaElement_.currentTime!=this.originTime_||this.mediaElement_.currentTime===this.targetTime_?this.timer_.stop():(this.mediaElement_.currentTime=this.targetTime_,this.remainingAttempts_--)};shaka.media.Playhead=function(){};shaka.media.Playhead.prototype.ready=function(){};shaka.media.Playhead.prototype.setStartTime=function(a){};shaka.media.Playhead.prototype.getStallsDetected=function(){};shaka.media.Playhead.prototype.getIsJumpingGap=function(){};shaka.media.Playhead.prototype.getGapsJumped=function(){};shaka.media.Playhead.prototype.getTime=function(){};shaka.media.Playhead.prototype.notifyOfBufferingChange=function(){};shaka.media.Playhead.prototype.isBufferedToEnd=function(){};
shaka.media.SrcEqualsPlayhead=function(a){this.mediaElement_=a;this.started_=!1;this.startTime_=null;this.eventManager_=new shaka.util.EventManager};
shaka.media.SrcEqualsPlayhead.prototype.ready=function(){var a=this;goog.asserts.assert(this.mediaElement_!=null,"Playhead should not be released before calling ready()");var b=function(){if(a.startTime_==null||a.startTime_==0&&a.mediaElement_.duration!=Infinity)a.started_=!0;else{var c=a.mediaElement_.currentTime,d=null;if(typeof a.startTime_==="number")d=a.startTime_;else if(a.startTime_ instanceof Date){var e=a.getProgramStartTime_();e!==null&&(d=a.startTime_.getTime()/1E3-e,d=a.clampTime_(d))}d==
null?a.started_=!0:(d<0&&(d=Math.max(0,c+d)),c!=d?(a.eventManager_.listenOnce(a.mediaElement_,"seeking",function(){a.started_=!0}),a.mediaElement_.currentTime=d):a.started_=!0)}};shaka.util.MediaReadyState.waitForReadyState(this.mediaElement_,HTMLMediaElement.HAVE_FUTURE_DATA,this.eventManager_,function(){b()})};shaka.media.SrcEqualsPlayhead.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.mediaElement_=null};
shaka.media.SrcEqualsPlayhead.prototype.setStartTime=function(a){this.startTime_=this.started_?this.startTime_:a};shaka.media.SrcEqualsPlayhead.prototype.getTime=function(){var a=this.started_?this.mediaElement_.currentTime:this.startTime_;a instanceof Date&&(a=a.getTime()/1E3-(this.getProgramStartTime_()||0),a=this.clampTime_(a));return a||0};shaka.media.SrcEqualsPlayhead.prototype.getStallsDetected=function(){return 0};shaka.media.SrcEqualsPlayhead.prototype.getGapsJumped=function(){return 0};
shaka.media.SrcEqualsPlayhead.prototype.getIsJumpingGap=function(){return!1};shaka.media.SrcEqualsPlayhead.prototype.notifyOfBufferingChange=function(){};shaka.media.SrcEqualsPlayhead.prototype.isBufferedToEnd=function(){goog.asserts.assert(this.mediaElement_,"We need a video element to get buffering information");var a=shaka.media.TimeRangesUtils.bufferEnd(this.mediaElement_.buffered);return a!=null&&a>=this.mediaElement_.duration-1};
shaka.media.SrcEqualsPlayhead.prototype.getProgramStartTime_=function(){if(this.mediaElement_.getStartDate){var a=this.mediaElement_.getStartDate().getTime();if(!isNaN(a))return a/1E3}return null};shaka.media.SrcEqualsPlayhead.prototype.clampTime_=function(a){var b=this.mediaElement_.seekable;b.length>0&&(a=Math.max(b.start(0),a),a=Math.min(b.end(b.length-1),a));return a};
shaka.media.MediaSourcePlayhead=function(a,b,c,d,e,f){var g=this;this.minSeekRange_=3;this.mediaElement_=a;this.timeline_=b.presentationTimeline;this.config_=c;this.onSeek_=e;this.lastCorrectiveSeek_=null;this.gapController_=new shaka.media.GapJumpingController(a,b.presentationTimeline,c,f);this.videoWrapper_=new shaka.media.VideoWrapper(a,function(){return g.onSeeking_()},function(h){return g.onStarted_(h)},function(){return g.getStartTime_(d)});this.checkWindowTimer_=new shaka.util.Timer(function(){g.onPollWindow_()})};
shaka.media.MediaSourcePlayhead.prototype.ready=function(){this.checkWindowTimer_.tickEvery(.25)};shaka.media.MediaSourcePlayhead.prototype.release=function(){this.videoWrapper_&&(this.videoWrapper_.release(),this.videoWrapper_=null);this.gapController_&&(this.gapController_.release(),this.gapController_=null);this.checkWindowTimer_&&(this.checkWindowTimer_.stop(),this.checkWindowTimer_=null);this.mediaElement_=this.videoWrapper_=this.timeline_=this.config_=null;this.onSeek_=function(){}};
shaka.media.MediaSourcePlayhead.prototype.setStartTime=function(a){this.videoWrapper_.setTime(this.getStartTime_(a))};shaka.media.MediaSourcePlayhead.prototype.getTime=function(){var a=this.videoWrapper_.getTime();return this.mediaElement_.readyState>0&&!this.mediaElement_.paused?this.clampTime_(a):a};shaka.media.MediaSourcePlayhead.prototype.getStallsDetected=function(){return this.gapController_.getStallsDetected()};shaka.media.MediaSourcePlayhead.prototype.getGapsJumped=function(){return this.gapController_.getGapsJumped()};
shaka.media.MediaSourcePlayhead.prototype.getIsJumpingGap=function(){return this.gapController_.getIsJumpingGap()};
shaka.media.MediaSourcePlayhead.prototype.getStartTime_=function(a){if(a==null)a=this.timeline_.getDuration()<Infinity?this.timeline_.getSeekRangeStart():this.timeline_.getSeekRangeEnd();else if(a instanceof Date){var b=this.timeline_.getInitialProgramDateTime()||this.timeline_.getPresentationStartTime();goog.asserts.assert(b!=null,"Presentation start time should not be null!");a=a.getTime()/1E3-b}else a<0&&(a=this.timeline_.getSeekRangeEnd()+a);return this.clampSeekToDuration_(this.clampTime_(a))};
shaka.media.MediaSourcePlayhead.prototype.notifyOfBufferingChange=function(){this.gapController_.onSegmentAppended()};
shaka.media.MediaSourcePlayhead.prototype.isBufferedToEnd=function(){goog.asserts.assert(this.mediaElement_,"We need a video element to get buffering information");goog.asserts.assert(this.timeline_,"We need a timeline to get buffering information");if(this.timeline_.isLive()){var a=this.timeline_.getSegmentAvailabilityEnd(),b=shaka.media.TimeRangesUtils.bufferEnd(this.mediaElement_.buffered);if(b!=null&&b>=a)return!0}return!1};
shaka.media.MediaSourcePlayhead.prototype.onPollWindow_=function(){if(this.mediaElement_.readyState!=0&&!this.mediaElement_.paused){var a=this.videoWrapper_.getTime(),b=this.timeline_.getSeekRangeStart(),c=this.timeline_.getSeekRangeEnd();c-b<this.minSeekRange_&&(b=c-this.minSeekRange_);a<b&&(b=this.reposition_(a),shaka.log.info("Jumping forward "+(b-a)+" seconds to catch up with the seek range."),this.mediaElement_.currentTime=b)}};shaka.media.MediaSourcePlayhead.prototype.onStarted_=function(a){this.gapController_.onStarted(a)};
shaka.media.MediaSourcePlayhead.prototype.onSeeking_=function(){this.gapController_.onSeeking();var a=this.videoWrapper_.getTime(),b=this.reposition_(a),c=shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE;if(!shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported()&&Math.abs(b-a)>c){c=!1;var d=shaka.device.DeviceFactory.getDevice().seekDelay();if(d){var e=Date.now()/1E3;if(!this.lastCorrectiveSeek_||this.lastCorrectiveSeek_<e-d)this.lastCorrectiveSeek_=e,c=!0}else c=!0;if(c){this.videoWrapper_.setTime(b);
return}}shaka.log.v1("Seek to "+a);this.onSeek_()};shaka.media.MediaSourcePlayhead.prototype.clampSeekToDuration_=function(a){var b=this.timeline_.getDuration();return a>=b?(goog.asserts.assert(this.config_.durationBackoff>=0,"Duration backoff must be non-negative!"),b-this.config_.durationBackoff):a};
shaka.media.MediaSourcePlayhead.prototype.reposition_=function(a){goog.asserts.assert(this.config_,"Cannot reposition playhead when it has been destroyed");var b=this.config_.rebufferingGoal,c=this.config_.safeSeekOffset,d=this.timeline_.getSeekRangeStart(),e=this.timeline_.getSeekRangeEnd(),f=this.timeline_.getDuration();e-d<this.minSeekRange_&&(d=e-this.minSeekRange_);var g=this.timeline_.getSafeSeekRangeStart(b),h=this.timeline_.getSafeSeekRangeStart(c);b=this.timeline_.getSafeSeekRangeStart(b+
c);if(a>=f)return shaka.log.v1("Playhead past duration."),this.clampSeekToDuration_(a);if(a>e)return shaka.log.v1("Playhead past end."),e-this.config_.safeSeekEndOffset;if(a<d){if(this.timeline_.isLive()&&this.config_.returnToEndOfLiveWindowWhenOutside)return e-this.config_.safeSeekEndOffset;if(shaka.media.TimeRangesUtils.isBuffered(this.mediaElement_.buffered,h))return shaka.log.v1("Playhead before start & start is buffered"),h;shaka.log.v1("Playhead before start & start is unbuffered");return b}if(a>=
g||shaka.media.TimeRangesUtils.isBuffered(this.mediaElement_.buffered,a))return shaka.log.v1("Playhead in safe region or in buffered region."),a;shaka.log.v1("Playhead outside safe region & in unbuffered region.");return b};shaka.media.MediaSourcePlayhead.prototype.clampTime_=function(a){var b=this.timeline_.getSeekRangeStart();if(a<b)return b;b=this.timeline_.getSeekRangeEnd();return a>b?b:a};shaka.media.PreferenceBasedCriteria=function(){this.lastAdaptationSet_=this.config_=null};shaka.media.PreferenceBasedCriteria.prototype.configure=function(a){this.config_=a};shaka.media.PreferenceBasedCriteria.prototype.getConfiguration=function(){return this.config_};
shaka.media.PreferenceBasedCriteria.prototype.create=function(a){var b=shaka.media.PreferenceBasedCriteria,c;if(this.config_.language){var d=b.filterByLanguage_(a,this.config_.language);d.length&&(c=d)}c||(c=a.filter(function(g){return g.primary}),c=c.length?c:a);a=b.filterVariantsByAudioRole_(c,this.config_.role);a.length?c=a:shaka.log.warning("No exact match for variant audio role could be found.");a=b.filterVariantsByVideoRole_(c,this.config_.videoRole);a.length?c=a:shaka.log.warning("No exact match for variant video role could be found.");
this.config_.videoLayout&&(a=b.filterVariantsByVideoLayout_(c,this.config_.videoLayout),a.length?c=a:shaka.log.warning("No exact match for the video layout could be found."));this.config_.hdrLevel&&(a=b.filterVariantsByHDRLevel_(c,this.config_.hdrLevel),a.length?c=a:shaka.log.warning("No exact match for the hdr level could be found."));var e=[this.config_.channelCount,this.config_.preferredAudioChannelCount];a=e.filter(function(g,h){return g&&e.indexOf(g)===h});if(a.length)for(a=(0,$jscomp.makeIterator)(a),
d=a.next();!d.done;d=a.next())if(d=b.filterVariantsByAudioChannelCount_(c,d.value),d.length){c=d;break}else shaka.log.warning("No exact match for the channel count could be found.");this.config_.audioLabel&&(a=b.filterVariantsByAudioLabel_(c,this.config_.audioLabel),a.length?c=a:shaka.log.warning("No exact match for audio label could be found."));this.config_.videoLabel&&(a=b.filterVariantsByVideoLabel_(c,this.config_.videoLabel),a.length?c=a:shaka.log.warning("No exact match for video label could be found."));
a=b.filterVariantsBySpatialAudio_(c,this.config_.spatialAudio);a.length?c=a:shaka.log.warning("No exact match for spatial audio could be found.");var f=[this.config_.audioCodec,this.config_.activeAudioCodec].concat((0,$jscomp.arrayFromIterable)(this.config_.preferredAudioCodecs));a=f.filter(function(g,h){return g&&f.indexOf(g)===h});if(a.length)for(a=(0,$jscomp.makeIterator)(a),d=a.next();!d.done;d=a.next())if(d=b.filterVariantsByAudioCodec_(c,d.value),d.length){c=d;break}else shaka.log.warning("No exact match for audio codec could be found.");
b=this.config_.codecSwitchingStrategy==shaka.config.CodecSwitchingStrategy.SMOOTH&&shaka.media.Capabilities.isChangeTypeSupported();return this.lastAdaptationSet_=new shaka.media.AdaptationSet(c[0],c,!b)};shaka.media.PreferenceBasedCriteria.prototype.getLastAdaptationSet=function(){return this.lastAdaptationSet_};
shaka.media.PreferenceBasedCriteria.filterByLanguage_=function(a,b){var c=shaka.util.LanguageUtils;b=c.normalize(b);var d=c.findClosestLocale(b,a.map(function(e){return c.getLocaleForVariant(e)}));return d?a.filter(function(e){return d==c.getLocaleForVariant(e)}):[]};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioRole_=function(a,b){return a.filter(function(c){return c.audio?b?c.audio.roles.includes(b):c.audio.roles.length==0:!1})};
shaka.media.PreferenceBasedCriteria.filterVariantsByVideoRole_=function(a,b){return a.filter(function(c){return c.video?b?c.video.roles.includes(b):c.video.roles.length==0:!1})};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioLabel_=function(a,b){return a.filter(function(c){if(!c.audio||!c.audio.label)return!1;c=c.audio.label.toLowerCase();var d=b.toLowerCase();return c==d})};
shaka.media.PreferenceBasedCriteria.filterVariantsByVideoLabel_=function(a,b){return a.filter(function(c){if(!c.video||!c.video.label)return!1;c=c.video.label.toLowerCase();var d=b.toLowerCase();return c==d})};
shaka.media.PreferenceBasedCriteria.filterVariantsByAudioChannelCount_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.channelsCount&&c.audio.channelsCount>b?!1:!0}).sort(function(c,d){return c.audio||d.audio?c.audio?d.audio?(d.audio.channelsCount||0)-(c.audio.channelsCount||0):1:-1:0})};
shaka.media.PreferenceBasedCriteria.filterVariantsByHDRLevel_=function(a,b){if(b=="AUTO"){var c=a.some(function(d){return d.video&&d.video.hdr&&d.video.hdr=="HLG"?!0:!1});b=shaka.device.DeviceFactory.getDevice().getHdrLevel(c)}return a.filter(function(d){return d.video&&d.video.hdr&&d.video.hdr!=b?!1:!0})};shaka.media.PreferenceBasedCriteria.filterVariantsByVideoLayout_=function(a,b){return a.filter(function(c){return c.video&&c.video.videoLayout&&c.video.videoLayout!=b?!1:!0})};
shaka.media.PreferenceBasedCriteria.filterVariantsBySpatialAudio_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.spatialAudio!=b?!1:!0})};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioCodec_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.codecs!=b?!1:!0})};shaka.media.RegionTimeline=function(a){shaka.util.FakeEventTarget.call(this);this.regions_=new Map;this.getFilterRange_=a;this.filterTimer_=null};$jscomp.inherits(shaka.media.RegionTimeline,shaka.util.FakeEventTarget);shaka.media.RegionTimeline.prototype.release=function(){this.regions_.clear();this.releaseTimer_();shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.RegionTimeline.prototype.addRegion=function(a){var b=this.generateKey_(a);this.regions_.has(b)||(this.regions_.set(b,a),a=new shaka.util.FakeEvent("regionadd",new Map([["region",a]])),this.dispatchEvent(a),this.setupTimer_())};
shaka.media.RegionTimeline.prototype.filterByRange_=function(){for(var a=this.getFilterRange_(),b=(0,$jscomp.makeIterator)(this.regions_),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;d.endTime<a.start&&(this.regions_.delete(c),c=new shaka.util.FakeEvent("regionremove",new Map([["region",d]])),this.dispatchEvent(c))}this.regions_.size||this.releaseTimer_()};
shaka.media.RegionTimeline.prototype.setupTimer_=function(){var a=this;this.filterTimer_||(this.filterTimer_=(new shaka.util.Timer(function(){a.filterByRange_()})).tickEvery(shaka.media.RegionTimeline.REGION_FILTER_INTERVAL))};shaka.media.RegionTimeline.prototype.releaseTimer_=function(){this.filterTimer_&&(this.filterTimer_.stop(),this.filterTimer_=null)};shaka.media.RegionTimeline.prototype.regions=function(){return this.regions_.values()};
shaka.media.RegionTimeline.prototype.generateKey_=function(a){return a.schemeIdUri+"_"+a.id+"_"+(a.startTime.toFixed(1)+"_"+a.endTime.toFixed(1))};shaka.media.RegionTimeline.REGION_FILTER_INTERVAL=2;shaka.media.SegmentPrefetch=function(a,b,c,d,e){this.prefetchLimit_=a;this.stream_=b;this.fetchDispatcher_=c;this.segmentPrefetchMap_=new Map;this.initSegmentPrefetchMap_=new Map;this.iterator_=null;this.reverse_=d;a=function(f,g){return g.fastSwitching&&f.isPartial()&&f.isLastPartial()?!1:!0};this.shouldPrefetchNextSegment_=e||a};
shaka.media.SegmentPrefetch.prototype.replaceFetchDispatcher=function(a){this.fetchDispatcher_=a;for(var b=(0,$jscomp.makeIterator)(this.segmentPrefetchMap_.values()),c=b.next();!c.done;c=b.next())c.value.replaceFetchDispatcher(a)};
shaka.media.SegmentPrefetch.prototype.prefetchSegmentsByTime=function(a,b){b=b===void 0?!1:b;goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var c=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);if(!this.stream_.segmentIndex)return shaka.log.debug(c,"missing segmentIndex"),Promise.resolve();this.iterator_||(this.iterator_=this.stream_.segmentIndex.getIteratorForTime(a,!0,this.reverse_));if(!this.iterator_)return shaka.log.debug(c,"missing iterator"),
Promise.resolve();b&&this.iterator_.next();for(a=[];this.segmentPrefetchMap_.size<this.prefetchLimit_;){b=this.iterator_.next().value;if(!b)break;c=!0;b.isPreload()&&b.endByte!=null&&(c=!1);b.getStatus()==shaka.media.SegmentReference.Status.MISSING&&(c=!1);b.getSegmentData(!1)&&(c=!1);c&&b.initSegmentReference&&a.push(this.prefetchInitSegment(b.initSegmentReference));c&&!this.segmentPrefetchMap_.has(b)&&(c=new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_),a.push(c.dispatchFetch(b,this.stream_)),
this.segmentPrefetchMap_.set(b,c));if(!this.shouldPrefetchNextSegment_(b,this.stream_))break}this.clearInitSegments_();return Promise.all(a)};
shaka.media.SegmentPrefetch.prototype.prefetchInitSegment=function(a){goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);if(!this.stream_.segmentIndex)return shaka.log.debug(b,"missing segmentIndex"),Promise.resolve();if(a.getSegmentData()||Array.from(this.initSegmentPrefetchMap_.keys()).some(function(d){return shaka.media.InitSegmentReference.equal(d,a)}))return Promise.resolve();b=new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_);
var c=b.dispatchFetch(a,this.stream_);this.initSegmentPrefetchMap_.set(a,b);return c};
shaka.media.SegmentPrefetch.prototype.getPrefetchedSegment=function(a,b){goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var c=shaka.media.SegmentPrefetch.logPrefix_(this.stream_),d=this.segmentPrefetchMap_;a instanceof shaka.media.InitSegmentReference&&(d=this.initSegmentPrefetchMap_);if(d.has(a)){var e=d.get(a);b&&e.setStreamDataCallback(b);a instanceof shaka.media.SegmentReference?shaka.log.debug(c,"reused prefetched segment at time:",a.startTime,
"mapSize",d.size):shaka.log.debug(c,"reused prefetched init segment at time, mapSize",d.size);return e.getOperation()}a instanceof shaka.media.SegmentReference?shaka.log.debug(c,"missed segment at time:",a.startTime,"mapSize",d.size):shaka.log.debug(c,"missed init segment at time, mapSize",d.size);return null};shaka.media.SegmentPrefetch.prototype.clearMap_=function(a){a=(0,$jscomp.makeIterator)(a.keys());for(var b=a.next();!b.done;b=a.next())(b=b.value)&&this.abortPrefetchedSegment_(b)};
shaka.media.SegmentPrefetch.prototype.resetPosition=function(){this.iterator_=null};shaka.media.SegmentPrefetch.prototype.clearAll=function(){this.clearMap_(this.segmentPrefetchMap_);this.clearMap_(this.initSegmentPrefetchMap_);this.resetPosition();var a=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);shaka.log.debug(a,"cleared all")};shaka.media.SegmentPrefetch.prototype.removeReference=function(a){this.abortPrefetchedSegment_(a)};
shaka.media.SegmentPrefetch.prototype.evict=function(a,b){b=b===void 0?!1:b;for(var c=(0,$jscomp.makeIterator)(this.segmentPrefetchMap_.keys()),d=c.next();!d.done;d=c.next())d=d.value,a>d.endTime&&this.abortPrefetchedSegment_(d);b&&this.clearInitSegments_()};shaka.media.SegmentPrefetch.prototype.setReverse=function(a){this.reverse_=a;this.iterator_&&this.iterator_.setReverse(a)};
shaka.media.SegmentPrefetch.prototype.clearInitSegments_=function(){if(this.segmentPrefetchMap_.size)for(var a=Array.from(this.segmentPrefetchMap_.keys()),b=(0,$jscomp.makeIterator)(this.initSegmentPrefetchMap_.keys()),c=b.next(),d={};!c.done;d={initSegmentReference$jscomp$4:void 0},c=b.next())d.initSegmentReference$jscomp$4=c.value,a.some(function(e){return function(f){return shaka.media.InitSegmentReference.equal(f.initSegmentReference,e.initSegmentReference$jscomp$4)}}(d))||this.abortPrefetchedSegment_(d.initSegmentReference$jscomp$4)};
shaka.media.SegmentPrefetch.prototype.resetLimit=function(a){goog.asserts.assert(a>=0,"The new prefetch limit must be >= 0.");var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);shaka.log.debug(b,"resetting prefetch limit to",a);this.prefetchLimit_=a;for(b=Array.from(this.segmentPrefetchMap_.keys());b.length>a;){var c=b.pop();c&&this.abortPrefetchedSegment_(c)}this.clearInitSegments_()};
shaka.media.SegmentPrefetch.prototype.switchStream=function(a){a&&a!==this.stream_&&(this.clearAll(),this.stream_=a)};shaka.media.SegmentPrefetch.prototype.getStream=function(){return this.stream_};
shaka.media.SegmentPrefetch.prototype.abortPrefetchedSegment_=function(a){var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_),c=this.segmentPrefetchMap_;a instanceof shaka.media.InitSegmentReference&&(c=this.initSegmentPrefetchMap_);var d=c.get(a);c.delete(a);d&&(d.abort(),a instanceof shaka.media.SegmentReference?shaka.log.debug(b,"pop and abort prefetched segment at time:",a.startTime):shaka.log.debug(b,"pop and abort prefetched init segment"))};
shaka.media.SegmentPrefetch.logPrefix_=function(a){return"SegmentPrefetch("+a.type+":"+a.id+")"};shaka.media.SegmentPrefetchOperation=function(a){this.fetchDispatcher_=a;this.operation_=this.streamDataCallback_=null};shaka.media.SegmentPrefetchOperation.prototype.replaceFetchDispatcher=function(a){this.fetchDispatcher_=a};
shaka.media.SegmentPrefetchOperation.prototype.dispatchFetch=function(a,b){var c=this,d=new Uint8Array(0);this.operation_=this.fetchDispatcher_(a,b,function(e){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return d=d.byteLength>0?shaka.util.Uint8ArrayUtils.concat(d,e):e,c.streamDataCallback_?f.yield(c.streamDataCallback_(d),3):f.jumpTo(0);d=new Uint8Array(0);f.jumpToEnd()})});return this.operation_.promise.catch(function(e){return e instanceof shaka.util.Error&&
e.code==shaka.util.Error.Code.OPERATION_ABORTED?Promise.resolve():Promise.reject(e)})};shaka.media.SegmentPrefetchOperation.prototype.getOperation=function(){return this.operation_};shaka.media.SegmentPrefetchOperation.prototype.setStreamDataCallback=function(a){this.streamDataCallback_=a};shaka.media.SegmentPrefetchOperation.prototype.abort=function(){this.operation_&&this.operation_.abort()};shaka.media.StreamingEngine=function(a,b){var c=this;this.playerInterface_=b;this.manifest_=a;this.config_=null;this.deferredCloseSegmentIndex_=new Map;this.bufferingScale_=1;this.currentTextStream_=this.currentVariant_=null;this.textStreamSequenceId_=0;this.mediaStates_=new Map;this.startupComplete_=!1;this.failureCallbackBackoff_=null;this.fatalError_=!1;this.destroyer_=new shaka.util.Destroyer(function(){return c.doDestroy_()});this.lastMediaSourceReset_=Date.now()/1E3;this.audioPrefetchMap_=new Map;
this.spatialVideoInfo_={projection:null,hfov:null};this.playRangeStart_=0;this.playRangeEnd_=Infinity;this.lastTextMediaStateBeforeUnload_=null;this.requestedDependencySegments_=[];this.updateLiveSeekableRangeTimer_=new shaka.util.Timer(function(){if(c.manifest_&&c.playerInterface_)if(c.manifest_.presentationTimeline.isLive()){var d=c.manifest_.presentationTimeline.getSeekRangeStart(),e=c.manifest_.presentationTimeline.getSeekRangeEnd();e-d>1?c.playerInterface_.mediaSourceEngine.setLiveSeekableRange(d,
e):c.playerInterface_.mediaSourceEngine.clearLiveSeekableRange()}else c.playerInterface_.mediaSourceEngine.clearLiveSeekableRange(),c.updateLiveSeekableRangeTimer_&&c.updateLiveSeekableRangeTimer_.stop();else c.updateLiveSeekableRangeTimer_&&c.updateLiveSeekableRangeTimer_.stop()});this.boundaryTime_=null;this.crossBoundarySeek_=!1;this.crossBoundaryTimer_=new shaka.util.Timer(function(){var d=c.playerInterface_.video;!d.ended&&c.boundaryTime_&&(shaka.log.info("Crossing boundary at",c.boundaryTime_),
c.crossBoundarySeek_=!0,d.currentTime=c.boundaryTime_,c.boundaryTime_=null)});this.crossBoundaryEventManager_=new shaka.util.EventManager};shaka.media.StreamingEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.media.StreamingEngine.prototype.doDestroy_=function(){var a=this,b,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.nextAddress==1){a.updateLiveSeekableRangeTimer_&&a.updateLiveSeekableRangeTimer_.stop();a.updateLiveSeekableRangeTimer_=null;a.crossBoundaryTimer_&&a.crossBoundaryTimer_.stop();a.crossBoundaryTimer_=null;a.crossBoundaryEventManager_&&(a.crossBoundaryEventManager_.release(),a.crossBoundaryEventManager_=null);b=[];c=(0,$jscomp.makeIterator)(a.mediaStates_.values());
for(d=c.next();!d.done;d=c.next())e=d.value,a.cancelUpdate_(e),b.push(a.abortOperations_(e)),e.segmentPrefetch&&(e.segmentPrefetch.clearAll(),e.segmentPrefetch=null);f=(0,$jscomp.makeIterator)(a.audioPrefetchMap_.values());for(g=f.next();!g.done;g=f.next())h=g.value,h.clearAll();return k.yield(Promise.all(b),2)}a.mediaStates_.clear();a.audioPrefetchMap_.clear();a.playerInterface_=null;a.manifest_=null;a.config_=null;a.boundaryTime_=null;k.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.configure=function(a){this.config_=a;this.failureCallbackBackoff_=new shaka.net.Backoff({maxAttempts:Math.max(a.retryParameters.maxAttempts,2),baseDelay:a.retryParameters.baseDelay,backoffFactor:a.retryParameters.backoffFactor,fuzzFactor:a.retryParameters.fuzzFactor,timeout:0,stallTimeout:0,connectionTimeout:0},!0);var b=shaka.util.ManifestParserUtils.ContentType;if(a.disableAudioPrefetch){var c=this.mediaStates_.get(b.AUDIO);c&&c.segmentPrefetch&&(c.segmentPrefetch.clearAll(),
c.segmentPrefetch=null);c=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.keys());for(var d=c.next();!d.done;d=c.next())d=d.value,this.audioPrefetchMap_.get(d).clearAll(),this.audioPrefetchMap_.delete(d)}a.disableTextPrefetch&&(c=this.mediaStates_.get(b.TEXT))&&c.segmentPrefetch&&(c.segmentPrefetch.clearAll(),c.segmentPrefetch=null);a.disableVideoPrefetch&&(b=this.mediaStates_.get(b.VIDEO))&&b.segmentPrefetch&&(b.segmentPrefetch.clearAll(),b.segmentPrefetch=null);b=(0,$jscomp.makeIterator)(this.mediaStates_.keys());
for(c=b.next();!c.done;c=b.next())c=this.mediaStates_.get(c.value),c.segmentPrefetch?(c.segmentPrefetch.resetLimit(a.segmentPrefetchLimit),a.segmentPrefetchLimit>0||(c.segmentPrefetch.clearAll(),c.segmentPrefetch=null)):a.segmentPrefetchLimit>0&&(c.segmentPrefetch=this.createSegmentPrefetch_(c.stream));a.disableAudioPrefetch||this.updatePrefetchMapForAudio_()};
shaka.media.StreamingEngine.prototype.applyPlayRange=function(a,b){this.manifest_.presentationTimeline.isLive()||(this.playRangeStart_=a,this.playRangeEnd_=b)};
shaka.media.StreamingEngine.prototype.start=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1)return goog.asserts.assert(b.config_,"StreamingEngine configure() must be called before init()!"),c.yield(b.initStreams_(a||new Map),2);b.destroyer_.ensureNotDestroyed();shaka.log.debug("init: completed initial Stream setup");b.startupComplete_=!0;c.jumpToEnd()})};shaka.media.StreamingEngine.prototype.getCurrentVariant=function(){return this.currentVariant_};
shaka.media.StreamingEngine.prototype.getCurrentTextStream=function(){return this.currentTextStream_};
shaka.media.StreamingEngine.prototype.loadNewTextStream_=function(a){var b=this,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.nextAddress){case 1:return c=shaka.util.ManifestParserUtils.ContentType,goog.asserts.assert(!b.mediaStates_.has(c.TEXT),"Should not call loadNewTextStream_ while streaming text!"),b.textStreamSequenceId_++,d=b.textStreamSequenceId_,l.setCatchFinallyBlocks(2),l.yield(b.playerInterface_.mediaSourceEngine.clear(c.TEXT),4);case 4:l.leaveTryBlock(3);
break;case 2:if(e=l.enterCatchBlock(),b.playerInterface_)b.playerInterface_.onError(e);case 3:f=shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs),b.playerInterface_.mediaSourceEngine.reinitText(f,b.manifest_.sequenceMode,a.external),g=b.playerInterface_.mediaSourceEngine.getTextDisplayer(),(h=g.isTextVisible()||b.config_.alwaysStreamText)&&b.textStreamSequenceId_==d&&(k=b.createMediaState_(a),b.mediaStates_.set(c.TEXT,k),b.scheduleUpdate_(k,0)),l.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.unloadTextStream=function(){var a=shaka.util.ManifestParserUtils.ContentType,b=this.mediaStates_.get(a.TEXT);b&&(this.cancelUpdate_(b),this.abortOperations_(b).catch(function(){}),this.lastTextMediaStateBeforeUnload_=this.mediaStates_.get(a.TEXT),this.mediaStates_.delete(a.TEXT),b.stream&&b.stream.closeSegmentIndex&&b.stream.closeSegmentIndex());this.currentTextStream_=null};
shaka.media.StreamingEngine.prototype.setTrickPlay=function(a){var b=shaka.util.ManifestParserUtils.ContentType;this.updateSegmentIteratorReverse_();if(b=this.mediaStates_.get(b.VIDEO)){var c=b.stream;if(c)if(shaka.log.debug("setTrickPlay",a),a)(a=c.trickModeVideo)&&!b.restoreStreamAfterTrickPlay&&(shaka.log.debug("Engaging trick mode stream",a),this.switchInternal_(a,!1,0,!1),b.restoreStreamAfterTrickPlay=c);else if(a=b.restoreStreamAfterTrickPlay)shaka.log.debug("Restoring non-trick-mode stream",
a),b.restoreStreamAfterTrickPlay=null,this.switchInternal_(a,!0,0,!1)}};shaka.media.StreamingEngine.prototype.switchVariant=function(a,b,c,d,e){b=b===void 0?!1:b;c=c===void 0?0:c;d=d===void 0?!1:d;e=e===void 0?!1:e;this.currentVariant_=a;this.startupComplete_&&(a.video&&this.switchInternal_(a.video,b,c,d,e),a.audio&&this.switchInternal_(a.audio,b,c,d,e))};
shaka.media.StreamingEngine.prototype.switchTextStream=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.nextAddress==1){b.lastTextMediaStateBeforeUnload_=null;b.currentTextStream_=a;if(!b.startupComplete_)return d.return();c=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(a&&a.type==c.TEXT,"Wrong stream type passed to switchTextStream!");return a.segmentIndex?d.jumpTo(2):d.yield(a.createSegmentIndex(),2)}b.switchInternal_(a,!0,0,!1);d.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.reloadTextStream=function(){var a=this.mediaStates_.get(shaka.util.ManifestParserUtils.ContentType.TEXT);a&&this.switchInternal_(a.stream,!0,0,!0)};shaka.media.StreamingEngine.prototype.handleDeferredCloseSegmentIndexes_=function(a){for(var b=(0,$jscomp.makeIterator)(this.deferredCloseSegmentIndex_.entries()),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;c.includes(a.type)&&(d(),this.deferredCloseSegmentIndex_.delete(c))}};
shaka.media.StreamingEngine.prototype.switchInternal_=function(a,b,c,d,e){var f=this,g=shaka.util.ManifestParserUtils.ContentType,h=this.mediaStates_.get(a.type);h||a.type!=g.TEXT?(goog.asserts.assert(h,"switch: expected mediaState to exist"),h&&(h.restoreStreamAfterTrickPlay&&(shaka.log.debug("switch during trick play mode",a),a.trickModeVideo?(h.restoreStreamAfterTrickPlay=a,a=a.trickModeVideo,shaka.log.debug("switch found trick play stream",a)):(h.restoreStreamAfterTrickPlay=null,shaka.log.debug("switch found no special trick play stream"))),
h.stream!=a||d?(this.audioPrefetchMap_.has(a)?h.segmentPrefetch=this.audioPrefetchMap_.get(a):h.segmentPrefetch&&h.segmentPrefetch.switchStream(a),a.type==g.TEXT&&h.stream!=a&&(d=shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs),this.playerInterface_.mediaSourceEngine.reinitText(d,this.manifest_.sequenceMode,a.external)),!this.audioPrefetchMap_.has(h.stream)&&h.stream.closeSegmentIndex&&(h.performingUpdate?(d=shaka.media.StreamingEngine.logPrefix_(h),this.deferredCloseSegmentIndex_.has(d)||this.deferredCloseSegmentIndex_.set(d,
h.stream.closeSegmentIndex)):h.stream.closeSegmentIndex()),d=h.stream.isAudioMuxedInVideo!=a.isAudioMuxedInVideo,h.stream=a,h.segmentIterator=null,h.adaptation=!!e,h.dependencyMediaState=a.dependencyStream?this.createMediaState_(a.dependencyStream):null,this.setupCrossBoundaryListeners_(),e=shaka.media.StreamingEngine.logPrefix_(h),shaka.log.debug("switch: switching to Stream "+e),d&&(h.lastInitSegmentReference=null,h.lastAppendWindowStart=null,h.lastAppendWindowEnd=null,a.isAudioMuxedInVideo&&(a=
null,h.type===g.VIDEO?a=this.mediaStates_.get(g.AUDIO):h.type===g.AUDIO&&(a=this.mediaStates_.get(g.VIDEO)),a&&(this.abortOperations_(a).catch(function(){}),a.lastInitSegmentReference=null,a.lastAppendWindowStart=null,a.lastAppendWindowEnd=null,this.forceClearBuffer_(a),this.makeAbortDecision_(a).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})))),b?h.clearingBuffer?h.waitingToFlushBuffer=!0:h.performingUpdate?
(h.waitingToClearBuffer=!0,h.clearBufferSafeMargin=c,h.waitingToFlushBuffer=!0):(this.cancelUpdate_(h),this.clearBuffer_(h,!0,c).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})):h.performingUpdate||h.updateTimer||this.scheduleUpdate_(h,0),this.makeAbortDecision_(h).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})):
(b=shaka.media.StreamingEngine.logPrefix_(h),shaka.log.debug("switch: Stream "+b+" already active")))):this.loadNewTextStream_(a)};
shaka.media.StreamingEngine.prototype.makeAbortDecision_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1){if(!a.operation)return f.return();c=a.stream;d=a.operation;return c.segmentIndex?f.jumpTo(2):f.yield(c.createSegmentIndex(),2)}if(f.nextAddress!=4)return e=c.dependencyStream,!e||e.segmentIndex?f.jumpTo(4):f.yield(e.createSegmentIndex(),4);if(a.operation!=d||a.stream!=c)return f.return();goog.asserts.assert(a.stream.segmentIndex,
"Segment index should exist by now!");b.shouldAbortCurrentRequest_(a)&&(shaka.log.info("Aborting current segment request."),a.operation.abort());f.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.shouldAbortCurrentRequest_=function(a){goog.asserts.assert(a.operation,"Abort logic requires an ongoing operation!");goog.asserts.assert(a.stream&&a.stream.segmentIndex,"Abort logic requires a segment index");var b=this.playerInterface_.getPresentationTime(),c=this.playerInterface_.mediaSourceEngine.bufferEnd(a.type),d=this.getTimeNeeded_(a,b);d=a.stream.segmentIndex.find(d);var e=d==null?null:a.stream.segmentIndex.get(d);d=e?e.getSize():null;e&&!d&&(d=(e.getEndTime()-
e.getStartTime())*(a.stream.bandwidth||this.currentVariant_.bandwidth)/8);if(!d)return!0;(e=e.initSegmentReference)&&(d+=e.getSize()||0);e=this.playerInterface_.getBandwidthEstimate();return d*8/e<(c||0)-b-this.config_.rebufferingGoal||a.operation.getBytesRemaining()>d?!0:!1};
shaka.media.StreamingEngine.prototype.seeked=function(){if(this.playerInterface_){for(var a=this.playerInterface_.getPresentationTime(),b=shaka.util.ManifestParserUtils.ContentType,c=!1,d=(0,$jscomp.makeIterator)(this.mediaStates_.keys()),e=d.next();!e.done;e=d.next()){e=e.value;var f=this.mediaStates_.get(e),g=shaka.media.StreamingEngine.logPrefix_(f);if(!this.crossBoundarySeek_&&!this.playerInterface_.mediaSourceEngine.isBuffered(e,a)){this.lastMediaSourceReset_=0;f.segmentPrefetch&&f.segmentPrefetch.resetPosition();
if(f.type===b.AUDIO)for(var h=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.values()),k=h.next();!k.done;k=h.next())k.value.resetPosition();f.segmentIterator=null;if(this.playerInterface_.mediaSourceEngine.bufferEnd(e)!=null||f.performingUpdate)this.forceClearBuffer_(f),c=!0;f.operation&&(f.operation.abort(),shaka.log.debug(g,"Aborting operation due to seek"),f.operation=null);e===b.TEXT&&this.playerInterface_.mediaSourceEngine.resetCaptionParser();f.seeked=!0}!this.crossBoundarySeek_||f.clearingBuffer||
f.performingUpdate||f.updateTimer||this.scheduleUpdate_(f,0)}this.shouldUseCrossBoundaryLogic_()&&this.forwardTimeForCrossBoundary_();c||shaka.log.debug("(all): seeked: buffered seek: presentationTime="+a)}};
shaka.media.StreamingEngine.prototype.forceClearBuffer_=function(a){var b=this,c=shaka.media.StreamingEngine.logPrefix_(a);a.clearingBuffer?shaka.log.debug(c,"clear: already clearing the buffer"):a.waitingToClearBuffer?shaka.log.debug(c,"clear: already waiting"):a.performingUpdate?(shaka.log.debug(c,"clear: currently updating"),a.waitingToClearBuffer=!0,a.clearBufferSafeMargin=0):this.playerInterface_.mediaSourceEngine.bufferStart(a.type)==null?(shaka.log.debug(c,"clear: nothing buffered"),a.updateTimer==
null&&this.scheduleUpdate_(a,0)):(shaka.log.debug(c,"clear: handling right now"),this.cancelUpdate_(a),this.clearBuffer_(a,!1,0).catch(function(d){b.playerInterface_&&(goog.asserts.assert(d instanceof shaka.util.Error,"Wrong error type!"),b.playerInterface_.onError(d))}))};
shaka.media.StreamingEngine.prototype.initStreams_=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1){goog.asserts.assert(b.config_,"StreamingEngine configure() must be called before init()!");if(!b.currentVariant_)throw shaka.log.error("init: no Streams chosen"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STREAMING,shaka.util.Error.Code.STREAMING_ENGINE_STARTUP_INVALID_STATE);c=b.getStreamsByType_(!0);
d=b.playerInterface_.mediaSourceEngine;return m.yield(d.init(c,b.manifest_.sequenceMode,b.manifest_.type,b.manifest_.ignoreManifestTimestampsInSegmentsMode),2)}b.destroyer_.ensureNotDestroyed();b.updateDuration();e=(0,$jscomp.makeIterator)(c.keys());for(f=e.next();!f.done;f=e.next())g=f.value,h=c.get(g),b.mediaStates_.has(g)||(k=b.createMediaState_(h),a.has(h.id)&&(l=a.get(h.id),l.replaceFetchDispatcher(function(n,p,q){return b.dispatchFetch_(n,p,q)}),k.segmentPrefetch=l),b.mediaStates_.set(g,k),
b.scheduleUpdate_(k,0));b.setupCrossBoundaryListeners_();m.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.createMediaState_=function(a){var b={stream:a,type:a.type,segmentIterator:null,segmentPrefetch:this.createSegmentPrefetch_(a),lastSegmentReference:null,lastInitSegmentReference:null,lastTimestampOffset:null,lastAppendWindowStart:null,lastAppendWindowEnd:null,lastCodecs:null,lastMimeType:null,restoreStreamAfterTrickPlay:null,endOfStream:!1,performingUpdate:!1,updateTimer:null,waitingToClearBuffer:!1,clearBufferSafeMargin:0,waitingToFlushBuffer:!1,clearingBuffer:!1,
seeked:!0,adaptation:!1,recovering:!1,hasError:!1,operation:null,dependencyMediaState:null};a.dependencyStream&&(b.dependencyMediaState=this.createMediaState_(a.dependencyStream));return b};
shaka.media.StreamingEngine.prototype.createSegmentPrefetch_=function(a){var b=this,c=shaka.util.ManifestParserUtils.ContentType;if(a.type===c.VIDEO&&this.config_.disableVideoPrefetch||a.type===c.AUDIO&&this.config_.disableAudioPrefetch)return null;var d=shaka.util.MimeUtils,e=d.CEA608_CLOSED_CAPTION_MIMETYPE;d=d.CEA708_CLOSED_CAPTION_MIMETYPE;return a.type===c.TEXT&&(a.mimeType==e||a.mimeType==d)||a.type===c.TEXT&&this.config_.disableTextPrefetch?null:this.audioPrefetchMap_.has(a)?this.audioPrefetchMap_.get(a):
(c=(c=this.mediaStates_.get(a.type))&&c.segmentPrefetch)&&a===c.getStream()?c:this.config_.segmentPrefetchLimit>0?(c=this.playerInterface_.getPlaybackRate()<0,new shaka.media.SegmentPrefetch(this.config_.segmentPrefetchLimit,a,function(f,g,h){return b.dispatchFetch_(f,g,h)},c,this.playerInterface_.shouldPrefetchNextSegment)):null};
shaka.media.StreamingEngine.prototype.updatePrefetchMapForAudio_=function(){for(var a=this.config_.segmentPrefetchLimit,b=this.config_.prefetchAudioLanguages,c=shaka.util.LanguageUtils,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next(),f={};!e.done;f={variant$jscomp$66:void 0},e=d.next())if(f.variant$jscomp$66=e.value,f.variant$jscomp$66.audio)if(this.audioPrefetchMap_.has(f.variant$jscomp$66.audio)){if(e=this.audioPrefetchMap_.get(f.variant$jscomp$66.audio),e.resetLimit(a),!(a>0&&b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$66.audio.language,
k)}}(f)))){var g=this.mediaStates_.get(f.variant$jscomp$66.audio.type);e!==(g&&g.segmentPrefetch)&&e.clearAll();this.audioPrefetchMap_.delete(f.variant$jscomp$66.audio)}}else a<=0||!b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$66.audio.language,k)}}(f))||!(e=this.createSegmentPrefetch_(f.variant$jscomp$66.audio))||(f.variant$jscomp$66.audio.segmentIndex||f.variant$jscomp$66.audio.createSegmentIndex(),this.audioPrefetchMap_.set(f.variant$jscomp$66.audio,e))};
shaka.media.StreamingEngine.prototype.updateDuration=function(){var a=shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported(),b=this.manifest_.presentationTimeline.getDuration();b<Infinity?(a&&(this.updateLiveSeekableRangeTimer_&&this.updateLiveSeekableRangeTimer_.stop(),this.playerInterface_.mediaSourceEngine.clearLiveSeekableRange()),this.playerInterface_.mediaSourceEngine.setDuration(b)):a?(this.updateLiveSeekableRangeTimer_&&this.updateLiveSeekableRangeTimer_.tickEvery(.5),this.playerInterface_.mediaSourceEngine.setDuration(Infinity)):
this.playerInterface_.mediaSourceEngine.setDuration(4294967296)};
shaka.media.StreamingEngine.prototype.onUpdate_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.nextAddress){case 1:b.destroyer_.ensureNotDestroyed();c=shaka.util.ManifestParserUtils.ContentType;d=shaka.media.StreamingEngine.logPrefix_(a);goog.asserts.assert(!a.performingUpdate&&a.updateTimer!=null,d+" unexpected call to onUpdate_()");if(a.performingUpdate||a.updateTimer==null)return q.return();goog.asserts.assert(!a.clearingBuffer,
d+" onUpdate_() should not be called when clearing the buffer");if(a.clearingBuffer)return q.return();a.updateTimer=null;if(!a.waitingToClearBuffer){q.jumpTo(2);break}shaka.log.debug(d,"skipping update and clearing the buffer");return q.yield(b.clearBuffer_(a,a.waitingToFlushBuffer,a.clearBufferSafeMargin),3);case 3:return q.return();case 2:b.handleDeferredCloseSegmentIndexes_(a);if(a.stream.segmentIndex){q.jumpTo(4);break}e=a.stream;q.setCatchFinallyBlocks(5);return q.yield(a.stream.createSegmentIndex(),
7);case 7:q.leaveTryBlock(6);break;case 5:return f=q.enterCatchBlock(),q.yield(b.handleStreamingError_(a,f),8);case 8:return q.return();case 6:if(e!=a.stream)return e.closeSegmentIndex&&(goog.asserts.assert(!a.stream.segmentIndex,"mediaState.stream should not have segmentIndex yet."),e.closeSegmentIndex()),a.performingUpdate||a.updateTimer||b.scheduleUpdate_(a,0),q.return();case 4:if(!a.dependencyMediaState){q.jumpTo(9);break}if(a.dependencyMediaState.stream.segmentIndex){q.jumpTo(9);break}q.setCatchFinallyBlocks(11);
return q.yield(a.dependencyMediaState.stream.createSegmentIndex(),13);case 13:q.leaveTryBlock(9);break;case 11:g=q.enterCatchBlock(),shaka.log.warning("Could not create segment index for dependency",g);case 9:q.setCatchFinallyBlocks(14);h=b.update_(a);h!=null&&(b.scheduleUpdate_(a,h),a.hasError=!1);q.leaveTryBlock(15);break;case 14:return k=q.enterCatchBlock(),q.yield(b.handleStreamingError_(a,k),16);case 16:return q.return();case 15:if(a.type===c.TEXT)return q.return();l=[a];m=a.type===c.AUDIO?c.VIDEO:
c.AUDIO;(n=b.mediaStates_.get(m))&&l.push(n);if(!b.startupComplete_||!l.every(function(r){return r.endOfStream})){q.jumpTo(0);break}shaka.log.v1(d,"calling endOfStream()...");return q.yield(b.playerInterface_.mediaSourceEngine.endOfStream(),18);case 18:b.destroyer_.ensureNotDestroyed(),p=b.playerInterface_.mediaSourceEngine.getDuration(),p!=0&&p<b.manifest_.presentationTimeline.getDuration()&&b.manifest_.presentationTimeline.setDuration(p),q.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.update_=function(a){goog.asserts.assert(this.manifest_,"manifest_ should not be null");goog.asserts.assert(this.config_,"config_ should not be null");var b=shaka.util.ManifestParserUtils.ContentType;if(shaka.media.StreamingEngine.isEmbeddedText_(a))return this.playerInterface_.mediaSourceEngine.setSelectedClosedCaptionId(a.stream.originalId||""),null;a.type==b.TEXT&&this.playerInterface_.mediaSourceEngine.clearSelectedClosedCaptionId();if(a.stream.isAudioMuxedInVideo&&
a.type==b.AUDIO)return null;if(a.type!=b.TEXT&&this.playerInterface_.mediaSourceEngine.closed())return this.resetMediaSource(!0),null;var c=this.config_.updateIntervalSeconds/Math.max(1,Math.abs(this.playerInterface_.getPlaybackRate()));if(!this.playerInterface_.mediaSourceEngine.isStreamingAllowed()&&a.type!=b.TEXT)return c/2;var d=shaka.media.StreamingEngine.logPrefix_(a),e=this.playerInterface_.getPresentationTime();if(a.type===b.AUDIO)for(var f=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.keys()),
g=f.next();!g.done;g=f.next())g=this.audioPrefetchMap_.get(g.value),g.evict(e,!0),g.prefetchSegmentsByTime(e);f=this.getTimeNeeded_(a,e);shaka.log.v2(d,"timeNeeded="+f);var h=this.playerInterface_.mediaSourceEngine.bufferedAheadOf(a.type,e);shaka.log.v2(d,"update_:","presentationTime="+e,"bufferedAhead="+h);g=Math.max(1,Math.max(this.config_.rebufferingGoal,this.config_.bufferingGoal)*this.bufferingScale_);var k=this.manifest_.presentationTimeline.getDuration()-f,l=this.playerInterface_.mediaSourceEngine.bufferEnd(a.type);
if(k<1E-6&&l)return shaka.log.debug(d,"buffered to end of presentation"),a.endOfStream=!0,a.type==b.VIDEO&&(a=this.mediaStates_.get(b.TEXT))&&shaka.media.StreamingEngine.isEmbeddedText_(a)&&(a.endOfStream=!0),null;a.endOfStream=!1;if(h>=g)return shaka.log.v2(d,"buffering goal met"),c/2;h=!a.segmentIterator;b=this.getSegmentReferenceNeeded_(a,e,l);if(!b)return c;l=a.lastInitSegmentReference;k=b.initSegmentReference;l&&k&&shaka.media.InitSegmentReference.equal(k,l)&&(l.boundaryEnd=k.boundaryEnd);l=
!1;h&&a.adaptation&&(l=!0,a.adaptation=!1);h=Infinity;k=Array.from(this.mediaStates_.values());k=(0,$jscomp.makeIterator)(k);for(var m=k.next();!m.done;m=k.next())m=m.value,shaka.media.StreamingEngine.isEmbeddedText_(m)||m.segmentIterator&&!m.segmentIterator.current()||(m=this.getTimeNeeded_(m,e),h=Math.min(h,m));k=this.manifest_.presentationTimeline.getMaxSegmentDuration()*shaka.media.StreamingEngine.MAX_RUN_AHEAD_SEGMENTS_;if(f>=h+k)return shaka.log.v2(d,"waiting for other streams to buffer"),c;
a.segmentPrefetch&&a.segmentIterator&&!this.audioPrefetchMap_.has(a.stream)&&(a.segmentPrefetch.evict(b.startTime+.001),a.segmentPrefetch.prefetchSegmentsByTime(b.startTime).catch(function(){}));if(this.shouldUseCrossBoundaryLogic_()&&this.discardReferenceByBoundary_(a,b))return null;this.fetchAndAppend_(a,e,b,l).catch(function(){});a.dependencyMediaState&&this.fetchAndAppendDependency_(a.dependencyMediaState,e,g);return null};
shaka.media.StreamingEngine.prototype.getTimeNeeded_=function(a,b){return a.lastSegmentReference?a.lastSegmentReference.endTime:b};
shaka.media.StreamingEngine.prototype.getSegmentReferenceNeeded_=function(a,b,c){var d=shaka.media.StreamingEngine.logPrefix_(a);goog.asserts.assert(a.stream.segmentIndex,"segment index should have been generated already");if(a.segmentIterator)return(d=a.segmentIterator.current())&&a.lastSegmentReference&&Math.abs(a.lastSegmentReference.startTime-d.startTime)<.001&&(d=a.segmentIterator.next().value),d;if(a.lastSegmentReference||c)return b=a.lastSegmentReference?a.lastSegmentReference.endTime:c,goog.asserts.assert(b!=
null,"Should have a time to search"),shaka.log.v1(d,"looking up segment from new stream endTime:",b),c=this.playerInterface_.getPlaybackRate()<0,a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,c)),a=a.segmentIterator&&a.segmentIterator.next().value,a==null&&shaka.log.warning(d,"cannot find segment","endTime:",b),a;c=this.manifest_.sequenceMode||this.shouldUseCrossBoundaryLogic_()?0:this.config_.inaccurateManifestTolerance;var e=Math.max(b-c,0);shaka.log.v1(d,
"looking up segment","lookupTime:",e,"presentationTime:",b);var f=this.playerInterface_.getPlaybackRate()<0,g=null;c&&(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(e,!1,f)),g=a.segmentIterator&&a.segmentIterator.next().value);g||(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,f)),g=a.segmentIterator&&a.segmentIterator.next().value);g==null&&shaka.log.warning(d,"cannot find segment","lookupTime:",e,"presentationTime:",b);
return g};
shaka.media.StreamingEngine.prototype.fetchAndAppend_=function(a,b,c,d){var e=this,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){switch(E.nextAddress){case 1:f=shaka.util.ManifestParserUtils.ContentType;g=shaka.media.StreamingEngine;h=g.logPrefix_(a);shaka.log.v1(h,"fetchAndAppend_:","presentationTime="+b,"reference.startTime="+c.startTime,"reference.endTime="+c.endTime);k=a.stream;l=a.segmentIterator;a.performingUpdate=!0;E.setCatchFinallyBlocks(2);if(c.getStatus()==
shaka.media.SegmentReference.Status.MISSING)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.SEGMENT_MISSING);return E.yield(e.initSourceBuffer_(a,c,d),4);case 4:e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return E.return();shaka.log.v2(h,"fetching segment");m=k.mimeType=="video/mp4"||k.mimeType=="audio/mp4";n=window.ReadableStream;if((p=e.config_.lowLatencyMode&&e.manifest_.isLowLatency)&&n&&m&&(e.manifest_.type!=shaka.media.ManifestParser.HLS||
c.hasByterangeOptimization()))return t=new Uint8Array(0),v=w=!1,x=function(F){var L,K,J,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.nextAddress){case 1:if(w)return G.return();v=!0;e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return G.return();G.setCatchFinallyBlocks(2);t=shaka.util.Uint8ArrayUtils.concat(t,F);L=!1;K=0;(new shaka.util.Mp4Parser).box("mdat",function(M){K=M.size+M.start;L=!0}).parse(t,!1,!0);if(!L){G.jumpTo(4);break}J=t.subarray(0,K);t=t.subarray(K);
return G.yield(e.append_(a,b,k,c,J,!0,d),5);case 5:a.segmentPrefetch&&a.segmentIterator&&a.segmentPrefetch.prefetchSegmentsByTime(c.startTime,!0);case 4:G.leaveTryBlock(0);break;case 2:u=I=G.enterCatchBlock(),G.jumpToEnd()}})},E.yield(e.fetch_(a,c,x),9);p&&!n&&shaka.log.warning("Low latency streaming mode is enabled, but ReadableStream is not supported by the browser.");q=e.fetch_(a,c);return E.yield(q,7);case 7:r=E.yieldResult;e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return E.return();
e.destroyer_.ensureNotDestroyed();return a.waitingToClearBuffer?(shaka.log.info(h,"waitingToClearBuffer, skip append"),a.performingUpdate=!1,e.scheduleUpdate_(a,0),E.return()):E.yield(e.append_(a,b,k,c,r,!1,d),6);case 9:z=E.yieldResult;if(u)throw u;if(v){E.jumpTo(10);break}w=!0;e.destroyer_.ensureNotDestroyed();return e.fatalError_?E.return():a.waitingToClearBuffer?(shaka.log.info(h,"waitingToClearBuffer, skip append"),a.performingUpdate=!1,e.scheduleUpdate_(a,0),E.return()):E.yield(e.append_(a,b,
k,c,z,!1,d),10);case 10:a.segmentPrefetch&&a.segmentIterator&&a.segmentPrefetch.prefetchSegmentsByTime(c.startTime,!0);case 6:e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return E.return();a.lastSegmentReference=c;B=l.next().value;shaka.log.v2(h,"advancing to next segment",B);a.performingUpdate=!1;a.recovering=!1;C=e.playerInterface_.mediaSourceEngine.getBufferedInfo();y=C[a.type];shaka.log.v1(h,"finished fetch and append",JSON.stringify(y));if(!a.waitingToClearBuffer)if(A=null,a.type===f.VIDEO?
A=e.mediaStates_.get(f.AUDIO):a.type===f.AUDIO&&(A=e.mediaStates_.get(f.VIDEO)),A&&A.type==f.AUDIO)e.playerInterface_.onSegmentAppended(c,a.stream,A.stream.isAudioMuxedInVideo);else e.playerInterface_.onSegmentAppended(c,a.stream,a.stream.codecs.includes(","));e.cancelUpdate_(a);e.scheduleUpdate_(a,0);E.leaveTryBlock(0);break;case 2:D=E.enterCatchBlock();e.destroyer_.ensureNotDestroyed(D);if(e.fatalError_)return E.return();goog.asserts.assert(D instanceof shaka.util.Error,"Should only receive a Shaka error");
a.performingUpdate=!1;if(D.code==shaka.util.Error.Code.OPERATION_ABORTED)a.performingUpdate=!1,e.cancelUpdate_(a),e.scheduleUpdate_(a,0),E.jumpTo(0);else if(a.type==f.TEXT&&e.config_.ignoreTextStreamFailures)D.code==shaka.util.Error.Code.BAD_HTTP_STATUS?shaka.log.warning(h,"Text stream failed to download. Proceeding without it."):shaka.log.warning(h,"Text stream failed to parse. Proceeding without it."),e.mediaStates_.delete(f.TEXT),E.jumpTo(0);else{if(D.code==shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR)return E.yield(e.handleQuotaExceeded_(a,
D),0);shaka.log.error(h,"failed fetch and append: code="+D.code);a.hasError=!0;D.category==shaka.util.Error.Category.NETWORK&&a.segmentPrefetch&&a.segmentPrefetch.removeReference(c);D.severity=shaka.util.Error.Severity.CRITICAL;return E.yield(e.handleStreamingError_(a,D),0)}}})};
shaka.media.StreamingEngine.prototype.fetchAndAppendDependency_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.nextAddress){case 1:e=a.stream;for(h=(g=(f=e.segmentIndex)&&f.getIteratorForTime(b))&&g.next().value;h&&d.requestedDependencySegments_.includes(h.startTime);)h=g&&g.next().value;if(!h){t.jumpTo(0);break}k=h.initSegmentReference;if(!k||shaka.media.InitSegmentReference.equal(k,a.lastInitSegmentReference)){t.jumpTo(3);
break}a.lastInitSegmentReference=k;t.setCatchFinallyBlocks(4);return t.yield(d.fetch_(a,k),6);case 6:l=t.yieldResult;d.playerInterface_.mediaSourceEngine.appendDependency(l,0,e);d.requestedDependencySegments_=[];t.leaveTryBlock(3);break;case 4:throw m=t.enterCatchBlock(),a.lastInitSegmentReference=null,m;case 3:if(a.lastSegmentReference&&a.lastSegmentReference==h){t.jumpTo(0);break}a.lastSegmentReference=h;t.setCatchFinallyBlocks(8);return t.yield(d.fetch_(a,h),10);case 10:n=t.yieldResult;d.playerInterface_.mediaSourceEngine.appendDependency(n,
0,e);d.requestedDependencySegments_.push(h.startTime);t.leaveTryBlock(9);break;case 8:throw p=t.enterCatchBlock(),a.lastSegmentReference=null,p;case 9:q=Math.max.apply(Math,[0].concat((0,$jscomp.arrayFromIterable)(d.requestedDependencySegments_)));r=d.playerInterface_.getPresentationTime();if(r+c>q)return t.yield(d.fetchAndAppendDependency_(a,h.startTime,c),0);t.jumpTo(0)}})};
shaka.media.StreamingEngine.prototype.retry=function(a){if(this.destroyer_.destroyed())return shaka.log.error("Unable to retry after StreamingEngine is destroyed!"),!1;if(this.fatalError_)return shaka.log.error("Unable to retry after StreamingEngine encountered a fatal error!"),!1;for(var b=(0,$jscomp.makeIterator)(this.mediaStates_.values()),c=b.next();!c.done;c=b.next()){c=c.value;var d=shaka.media.StreamingEngine.logPrefix_(c);!c.hasError||c.performingUpdate||c.updateTimer||(shaka.log.info(d,"Retrying after failure..."),
c.hasError=!1,this.scheduleUpdate_(c,a))}return!0};
shaka.media.StreamingEngine.prototype.handleQuotaExceeded_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(r){switch(r.nextAddress){case 1:d=shaka.media.StreamingEngine.logPrefix_(a);e=Array.from(c.mediaStates_.values());if(f=e.some(function(t){return t!=a&&t.recovering})){shaka.log.debug(d,"MediaSource threw QuotaExceededError:","waiting for another stream to recover...");r.jumpTo(2);break}if(c.config_.avoidEvictionOnQuotaExceededError){(g=
c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);if(h=c.playerInterface_.disableStream(a.stream,g))return r.return();c.scheduleUpdate_(a,4);return r.return()}k=Math.round(100*c.bufferingScale_);if(k>20){c.bufferingScale_-=.2;r.jumpTo(3);break}if(k>4){c.bufferingScale_-=.04;r.jumpTo(3);break}(l=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);m=c.playerInterface_.disableStream(a.stream,l);if(!m){shaka.log.error(d,"MediaSource threw QuotaExceededError too many times");
a.hasError=!0;c.fatalError_=!0;c.playerInterface_.onError(b);r.jumpTo(5);break}c.bufferingScale_=1;n=c.playerInterface_.getPresentationTime();return r.yield(c.evict_(a,n),5);case 5:return r.return();case 3:return p=Math.round(100*c.bufferingScale_),shaka.log.warning(d,"MediaSource threw QuotaExceededError:","reducing buffering goals by "+(100-p)+"%"),a.recovering=!0,q=c.playerInterface_.getPresentationTime(),r.yield(c.evict_(a,q),2);case 2:c.scheduleUpdate_(a,4),r.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.initSourceBuffer_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.nextAddress){case 1:e=shaka.util.ManifestParserUtils.ContentType;f=shaka.util.MimeUtils;g=shaka.media.StreamingEngine;h=g.logPrefix_(a);k=a.lastSegmentReference==null;l=[];m=Math.max(0,Math.max(b.appendWindowStart,d.playRangeStart_)-g.APPEND_WINDOW_START_FUDGE_);n=Math.min(b.appendWindowEnd,d.playRangeEnd_)+
g.APPEND_WINDOW_END_FUDGE_;goog.asserts.assert(b.startTime<=n,h+" segment should start before append window end");p=b.codecs||a.stream.codecs;q=f.getCodecBase(p);r=f.getBasicType(b.mimeType||a.stream.mimeType);t=b.timestampOffset;if(t==a.lastTimestampOffset&&m==a.lastAppendWindowStart&&n==a.lastAppendWindowEnd&&q==a.lastCodecs&&r==a.lastMimeType){y.jumpTo(2);break}shaka.log.v1(h,"setting timestamp offset to "+t);shaka.log.v1(h,"setting append window start to "+m);shaka.log.v1(h,"setting append window end to "+
n);w=a.lastCodecs&&a.lastMimeType&&d.playerInterface_.mediaSourceEngine.isResetMediaSourceNecessary(a.type,r,p,d.getStreamsByType_());if(!w){y.jumpTo(3);break}v=null;a.type===e.VIDEO?v=d.mediaStates_.get(e.AUDIO):a.type===e.AUDIO&&(v=d.mediaStates_.get(e.VIDEO));if(!v){y.jumpTo(3);break}return y.yield(d.abortOperations_(v).catch(function(){}),5);case 5:v.lastInitSegmentReference=null,v.lastAppendWindowStart=null,v.lastAppendWindowEnd=null,d.forceClearBuffer_(v);case 3:return y.yield(d.setProperties_(a,
t,m,n,b,q,r),2);case 2:return shaka.media.InitSegmentReference.equal(b.initSegmentReference,a.lastInitSegmentReference)||(a.lastInitSegmentReference=b.initSegmentReference,b.isIndependent()&&b.initSegmentReference&&(shaka.log.v1(h,"fetching init segment"),u=d.fetch_(a,b.initSegmentReference),x=function(){var A,D,E,F,L,K,J,I,G,M,H,P,Q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(O){switch(O.nextAddress){case 1:return O.setCatchFinallyBlocks(2),O.yield(u,4);case 4:return A=O.yieldResult,
d.destroyer_.ensureNotDestroyed(),D=null,E=new Map,F={projection:null,hfov:null},a.stream&&(L=a.stream.videoLayout)&&(K=L.split("/"),K.includes("PROJ-RECT")?F.projection="rect":K.includes("PROJ-EQUI")?F.projection="equi":K.includes("PROJ-HEQU")?F.projection="hequ":K.includes("PROJ-PRIM")?F.projection="prim":K.includes("PROJ-AIV")&&(F.projection="hequ")),J=new shaka.util.Mp4Parser,I=shaka.util.Mp4Parser,G=shaka.util.Mp4BoxParsers,J.box("moov",I.children).box("trak",I.children).box("mdia",I.children).fullBox("mdhd",
function(N){goog.asserts.assert(N.version!=null,"MDHD is a full box and should have a valid version.");D=G.parseMDHD(N.reader,N.version).timescale}).box("hdlr",function(N){switch(G.parseHDLR(N.reader).handlerType){case "soun":E.set(e.AUDIO,D);break;case "vide":E.set(e.VIDEO,D)}D=null}),a.type!==e.VIDEO||F.projection||J.box("minf",I.children).box("stbl",I.children).fullBox("stsd",I.sampleDescription).box("encv",I.visualSampleEntry).box("avc1",I.visualSampleEntry).box("avc3",I.visualSampleEntry).box("hev1",
I.visualSampleEntry).box("hvc1",I.visualSampleEntry).box("dvav",I.visualSampleEntry).box("dva1",I.visualSampleEntry).box("dvh1",I.visualSampleEntry).box("dvhe",I.visualSampleEntry).box("dvc1",I.visualSampleEntry).box("dvi1",I.visualSampleEntry).box("vexu",I.children).box("proj",I.children).fullBox("prji",function(N){N=G.parsePRJI(N.reader);F.projection=N.projection}).box("hfov",function(N){N=G.parseHFOV(N.reader);F.hfov=N.hfov}),J.parse(A,!0,!0),a.type===e.VIDEO&&d.updateSpatialVideoInfo_(F),E.has(a.type)?
b.initSegmentReference.timescale=E.get(a.type):D!=null&&(b.initSegmentReference.timescale=D),M=a.stream.segmentIndex,M instanceof shaka.media.MetaSegmentIndex&&(H=M.getTimelineForTime(b.startTime)),shaka.log.v1(h,"appending init segment"),P=a.stream.closedCaptions&&a.stream.closedCaptions.size>0,O.yield(d.playerInterface_.beforeAppendSegment(a.type,A),5);case 5:return O.yield(d.playerInterface_.mediaSourceEngine.appendBuffer(a.type,A,null,a.stream,P,a.seeked,c,!1,!1,H),6);case 6:O.leaveTryBlock(0);
break;case 2:throw Q=O.enterCatchBlock(),a.lastInitSegmentReference=null,Q;}})},z=b.startTime,k&&(B=d.playerInterface_.mediaSourceEngine.bufferEnd(a.type),B!=null&&(z=B)),d.playerInterface_.onInitSegmentAppended(z,b.initSegmentReference),l.push(x()))),C=a.lastSegmentReference?a.lastSegmentReference.discontinuitySequence:-1,b.discontinuitySequence!=C&&l.push(d.playerInterface_.mediaSourceEngine.resync(a.type,b.startTime)),y.yield(Promise.all(l),0)}})};
shaka.media.StreamingEngine.prototype.setProperties_=function(a,b,c,d,e,f,g){var h=this,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.nextAddress){case 1:k=shaka.util.ManifestParserUtils.ContentType;l=h.getStreamsByType_();q.setCatchFinallyBlocks(2);a.lastAppendWindowStart=c;a.lastAppendWindowEnd=d;f&&(a.lastCodecs=f);g&&(a.lastMimeType=g);a.lastTimestampOffset=b;m=h.manifest_.sequenceMode||h.manifest_.type==shaka.media.ManifestParser.HLS;n=null;a.type===k.VIDEO?
n=h.mediaStates_.get(k.AUDIO):a.type===k.AUDIO&&(n=h.mediaStates_.get(k.VIDEO));if(!(n&&n.stream&&n.stream.isAudioMuxedInVideo)){q.jumpTo(4);break}return q.yield(h.playerInterface_.mediaSourceEngine.setStreamProperties(n.type,b,c,d,m,n.stream.mimeType,n.stream.codecs,l),4);case 4:return q.yield(h.playerInterface_.mediaSourceEngine.setStreamProperties(a.type,b,c,d,m,e.mimeType||a.stream.mimeType,e.codecs||a.stream.codecs,l),6);case 6:q.leaveTryBlock(0);break;case 2:throw p=q.enterCatchBlock(),a.lastAppendWindowStart=
null,a.lastAppendWindowEnd=null,a.lastCodecs=null,a.lastMimeType=null,a.lastTimestampOffset=null,p;}})};
shaka.media.StreamingEngine.prototype.append_=function(a,b,c,d,e,f,g){f=f===void 0?!1:f;g=g===void 0?!1:g;var h=this,k,l,m,n,p,q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(r){switch(r.nextAddress){case 1:return k=shaka.media.StreamingEngine.logPrefix_(a),l=c.closedCaptions&&c.closedCaptions.size>0,h.config_.shouldFixTimestampOffset&&(m=c.mimeType=="video/mp4"||c.mimeType=="audio/mp4",n=null,d.initSegmentReference&&(n=d.initSegmentReference.timescale),(p=m&&n&&c.type===shaka.util.ManifestParserUtils.ContentType.VIDEO&&
h.manifest_.type==shaka.media.ManifestParser.DASH)&&(new shaka.util.Mp4Parser).box("moof",shaka.util.Mp4Parser.children).box("traf",shaka.util.Mp4Parser.children).fullBox("tfdt",function(t){var w,v,u,x,z,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){goog.asserts.assert(t.version!=null,"TFDT is a full box and should have a valid version.");w=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(t.reader,t.version);v=w.baseMediaDecodeTime;if(!v)return C.return();goog.asserts.assert(typeof n==
"number","Should be an number!");u=-v/n;x=Number(a.lastTimestampOffset)||0;if(!(x<u))return C.jumpTo(0);z=a.lastAppendWindowStart;B=a.lastAppendWindowEnd;goog.asserts.assert(typeof z=="number","Should be an number!");goog.asserts.assert(typeof B=="number","Should be an number!");return C.yield(h.setProperties_(a,u,z,B,d),0)})}).parse(e,!1,f)),r.yield(h.evict_(a,b),2);case 2:return h.destroyer_.ensureNotDestroyed(),q=a.seeked,a.seeked=!1,r.yield(h.playerInterface_.beforeAppendSegment(a.type,e),3);
case 3:return r.yield(h.playerInterface_.mediaSourceEngine.appendBuffer(a.type,e,d,c,l,q,g,f),4);case 4:h.destroyer_.ensureNotDestroyed(),shaka.log.v2(k,"appended media segment"),r.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.evict_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.nextAddress==1){d=a.stream.segmentIndex;d instanceof shaka.media.MetaSegmentIndex&&(d.evict(c.manifest_.presentationTimeline.getSegmentAvailabilityStart()),e=[],d.forEachIndex(function(r){e.push(r.continuityTimeline())}));f=shaka.media.StreamingEngine.logPrefix_(a);shaka.log.v2(f,"checking buffer length");g=Math.max(c.config_.bufferBehind*
c.bufferingScale_,c.manifest_.presentationTimeline.getMaxSegmentDuration());h=c.playerInterface_.mediaSourceEngine.bufferStart(a.type);if(h==null)return c.lastTextMediaStateBeforeUnload_==a&&(c.lastTextMediaStateBeforeUnload_=null),shaka.log.v2(f,"buffer behind okay because nothing buffered:","presentationTime="+b,"bufferBehind="+g),q.return();k=b-h;l=c.config_.evictionGoal;m=c.manifest_.presentationTimeline.getSeekRangeStart();n=c.manifest_.presentationTimeline.getSeekRangeEnd();p=k-g;n-m>l&&(p=
Math.max(k-g,m-l-h));if(p<=l)return shaka.log.v2(f,"buffer behind okay:","presentationTime="+b,"bufferedBehind="+k,"bufferBehind="+g,"evictionGoal="+l,"underflow="+Math.abs(p)),q.return();shaka.log.v1(f,"buffer behind too large:","presentationTime="+b,"bufferedBehind="+k,"bufferBehind="+g,"evictionGoal="+l,"overflow="+p);return q.yield(c.playerInterface_.mediaSourceEngine.remove(a.type,h,h+p,e),2)}if(q.nextAddress!=4)return c.destroyer_.ensureNotDestroyed(),shaka.log.v1(f,"evicted "+p+" seconds"),
c.lastTextMediaStateBeforeUnload_?q.yield(c.evict_(c.lastTextMediaStateBeforeUnload_,b),4):q.jumpTo(0);c.destroyer_.ensureNotDestroyed();q.jumpToEnd()})};shaka.media.StreamingEngine.isEmbeddedText_=function(a){var b=shaka.util.MimeUtils,c=b.CEA608_CLOSED_CAPTION_MIMETYPE;b=b.CEA708_CLOSED_CAPTION_MIMETYPE;return a&&a.type==shaka.util.ManifestParserUtils.ContentType.TEXT&&(a.stream.mimeType==c||a.stream.mimeType==b)};
shaka.media.StreamingEngine.prototype.fetch_=function(a,b,c){var d=this,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.nextAddress){case 1:if(e=b.getSegmentData())return l.return(e);f=null;a.segmentPrefetch&&(f=a.segmentPrefetch.getPrefetchedSegment(b,c));f||(f=d.dispatchFetch_(b,a.stream,c));g=0;a.segmentIterator&&(g=a.segmentIterator.currentPosition());a.operation=f;return l.yield(f.promise,2);case 2:h=l.yieldResult;a.operation=null;k=h.data;if(!b.aesKey){l.jumpTo(3);
break}return l.yield(shaka.media.SegmentUtils.aesDecrypt(k,b.aesKey,g),4);case 4:k=l.yieldResult;case 3:return l.return(k)}})};shaka.media.StreamingEngine.prototype.dispatchFetch_=function(a,b,c,d){goog.asserts.assert(this.playerInterface_.netEngine,"Must have net engine");return shaka.media.StreamingEngine.dispatchFetch(a,b,c||null,this.config_.retryParameters,this.playerInterface_.netEngine)};
shaka.media.StreamingEngine.dispatchFetch=function(a,b,c,d,e,f){f=f===void 0?!1:f;var g=shaka.net.NetworkingEngine.RequestType.SEGMENT,h=a instanceof shaka.media.SegmentReference?a:void 0,k=h?shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT:shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT;c=shaka.util.Networking.createSegmentRequest(a.getUris(),a.startByte,a.endByte,d,c);c.contentType=b.type;shaka.log.v2("fetching: reference=",a);return e.request(g,c,{type:k,stream:b,segment:h,
isPreload:f})};
shaka.media.StreamingEngine.prototype.clearBuffer_=function(a,b,c){var d=this,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return e=shaka.media.StreamingEngine.logPrefix_(a),goog.asserts.assert(!a.performingUpdate&&a.updateTimer==null,e+" unexpected call to clearBuffer_()"),a.waitingToClearBuffer=!1,a.waitingToFlushBuffer=!1,a.clearBufferSafeMargin=0,a.clearingBuffer=!0,a.lastSegmentReference=null,a.segmentIterator=null,shaka.log.debug(e,"clearing buffer"),
a.segmentPrefetch&&!d.audioPrefetchMap_.has(a.stream)&&a.segmentPrefetch.clearAll(),c?(f=d.playerInterface_.getPresentationTime(),g=d.playerInterface_.mediaSourceEngine.getDuration(),h.yield(d.playerInterface_.mediaSourceEngine.remove(a.type,f+c,g),3)):h.yield(d.playerInterface_.mediaSourceEngine.clear(a.type),4);if(h.nextAddress!=3)return d.destroyer_.ensureNotDestroyed(),b?h.yield(d.playerInterface_.mediaSourceEngine.flush(a.type),3):h.jumpTo(3);d.destroyer_.ensureNotDestroyed();shaka.log.debug(e,
"cleared buffer");a.clearingBuffer=!1;a.endOfStream=!1;a.performingUpdate||a.updateTimer||d.scheduleUpdate_(a,0);h.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.scheduleUpdate_=function(a,b){var c=this,d=shaka.media.StreamingEngine.logPrefix_(a),e=a.type;e!=shaka.util.ManifestParserUtils.ContentType.TEXT||this.mediaStates_.has(e)?(shaka.log.v2(d,"updating in "+b+" seconds"),goog.asserts.assert(a.updateTimer==null,d+" did not expect update to be scheduled"),a.updateTimer=(new shaka.util.DelayedTick(function(){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1)return g.setCatchFinallyBlocks(2),
g.yield(c.onUpdate_(a),4);if(g.nextAddress!=2)return g.leaveTryBlock(0);f=g.enterCatchBlock();if(c.playerInterface_)c.playerInterface_.onError(f);g.jumpToEnd()})})).tickAfter(b)):shaka.log.v1(d,"Text stream is unloaded. No update is needed.")};shaka.media.StreamingEngine.prototype.cancelUpdate_=function(a){a.updateTimer!=null&&(a.updateTimer.stop(),a.updateTimer=null)};
shaka.media.StreamingEngine.prototype.abortOperations_=function(a){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return a.operation?b.yield(a.operation.abort(),0):b.jumpTo(0)})};
shaka.media.StreamingEngine.prototype.handleStreamingError_=function(a,b){var c=this,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return d=shaka.media.StreamingEngine.logPrefix_(a),b.code==shaka.util.Error.Code.STREAMING_NOT_ALLOWED?(a.performingUpdate=!1,c.cancelUpdate_(a),c.scheduleUpdate_(a,0),f.return()):f.yield(c.failureCallbackBackoff_.attempt(),2);c.destroyer_.ensureNotDestroyed();if(b.category===shaka.util.Error.Category.NETWORK&&b.code!=shaka.util.Error.Code.TIMEOUT){if(a.restoreStreamAfterTrickPlay)return c.setTrickPlay(!1),
f.return();(e=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to error",b);b.handled=c.playerInterface_.disableStream(a.stream,e);b.handled&&(b.severity=shaka.util.Error.Severity.RECOVERABLE)}if(!b.handled||b.code!=shaka.util.Error.Code.SEGMENT_MISSING)c.playerInterface_.onError(b);b.handled||c.config_.failureCallback(b);f.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.getDisabledTime_=function(a){return this.config_.maxDisabledTime===0&&a.code==shaka.util.Error.Code.SEGMENT_MISSING?1:this.config_.maxDisabledTime};
shaka.media.StreamingEngine.prototype.resetMediaSource=function(a,b){a=a===void 0?!1:a;var c=this,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.nextAddress==1){d=Date.now()/1E3;e=c.config_.minTimeBetweenRecoveries;if(!a){if(!c.config_.allowMediaSourceRecoveries||d-c.lastMediaSourceReset_<e)return l.return(!1);c.lastMediaSourceReset_=d}f=shaka.util.ManifestParserUtils.ContentType;if(g=c.mediaStates_.get(f.AUDIO))c.cancelUpdate_(g),g.operation&&(g.operation.abort(),
g.operation=null),g.lastInitSegmentReference=null,g.lastAppendWindowStart=null,g.lastAppendWindowEnd=null,g.performingUpdate=!1,g.waitingToClearBuffer=!1,g.clearBufferSafeMargin=0,g.waitingToFlushBuffer=!1,g.clearingBuffer=!1,g.segmentIterator&&g.segmentIterator.resetToLastIndependent();if(h=c.mediaStates_.get(f.VIDEO))c.cancelUpdate_(h),h.operation&&(h.operation.abort(),h.operation=null),h.lastInitSegmentReference=null,h.lastAppendWindowStart=null,h.lastAppendWindowEnd=null,h.performingUpdate=!1,
h.waitingToClearBuffer=!1,h.clearBufferSafeMargin=0,h.waitingToFlushBuffer=!1,h.clearingBuffer=!1,h.segmentIterator&&h.segmentIterator.resetToLastIndependent();k=c.playerInterface_.video.paused;return l.yield(c.playerInterface_.mediaSourceEngine.reset(c.getStreamsByType_()),2)}!h||h.clearingBuffer||h.performingUpdate||h.updateTimer||c.scheduleUpdate_(h,0);!g||g.clearingBuffer||g.performingUpdate||g.updateTimer||c.scheduleUpdate_(g,0);k||c.playerInterface_.video.play();return l.return(!0)})};
shaka.media.StreamingEngine.prototype.updateSpatialVideoInfo_=function(a){if(this.spatialVideoInfo_.projection!=a.projection||this.spatialVideoInfo_.hfov!=a.hfov){var b=shaka.util.FakeEvent.EventName;if(a.projection!=null||a.hfov!=null){b=b.SpatialVideoInfoEvent;var c=(new Map).set("detail",a);b=new shaka.util.FakeEvent(b,c)}else b=new shaka.util.FakeEvent(b.NoSpatialVideoInfoEvent);b.cancelable=!0;this.playerInterface_.onEvent(b);this.spatialVideoInfo_=a}};
shaka.media.StreamingEngine.prototype.updateSegmentIteratorReverse_=function(){for(var a=this.playerInterface_.getPlaybackRate()<0,b=(0,$jscomp.makeIterator)(this.mediaStates_.values()),c=b.next();!c.done;c=b.next())c=c.value,c.segmentIterator&&c.segmentIterator.setReverse(a),c.segmentPrefetch&&c.segmentPrefetch.setReverse(a);b=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.values());for(c=b.next();!c.done;c=b.next())c.value.setReverse(a)};
shaka.media.StreamingEngine.prototype.shouldUseCrossBoundaryLogic_=function(){if(this.config_.crossBoundaryStrategy!==shaka.config.CrossBoundaryStrategy.KEEP)return!0;var a=shaka.device.DeviceFactory.getDevice();if(!shaka.media.Capabilities.isChangeTypeSupported()||!a.supportsSmoothCodecSwitching()){a=(0,$jscomp.makeIterator)(this.mediaStates_.keys());for(var b=a.next();!b.done;b=a.next())if(b=this.mediaStates_.get(b.value),b.type!==shaka.util.ManifestParserUtils.ContentType.TEXT&&(b=b.stream)&&b.fullMimeTypes&&
b.fullMimeTypes.size>1)return!0}else if(!a.supportsContainerChangeType())for(a=(0,$jscomp.makeIterator)(this.mediaStates_.keys()),b=a.next();!b.done;b=a.next())if(b=this.mediaStates_.get(b.value),b.type!==shaka.util.ManifestParserUtils.ContentType.TEXT&&(b=b.stream)&&b.fullMimeTypes&&b.fullMimeTypes.size>1){a=new Set;b=(0,$jscomp.makeIterator)(b.fullMimeTypes);for(var c=b.next();!c.done;c=b.next())a.add(shaka.util.MimeUtils.getContainerType(c.value));return a.size>1}return!1};
shaka.media.StreamingEngine.prototype.setupCrossBoundaryListeners_=function(){var a=this;this.crossBoundaryEventManager_.removeAll();this.shouldUseCrossBoundaryLogic_()&&(this.crossBoundaryEventManager_.listen(this.playerInterface_.video,"waiting",function(){return a.forwardTimeForCrossBoundary_()}),this.crossBoundaryEventManager_.listen(this.playerInterface_.video,"timeupdate",function(){return a.forwardTimeForCrossBoundary_()}))};
shaka.media.StreamingEngine.prototype.forwardTimeForCrossBoundary_=function(){if(this.shouldUseCrossBoundaryLogic_()){this.crossBoundaryTimer_.stop();var a=this.playerInterface_.getPresentationTime(),b=shaka.util.ManifestParserUtils.ContentType;if((b=this.mediaStates_.get(b.VIDEO)||this.mediaStates_.get(b.AUDIO))&&(b=b.lastInitSegmentReference)&&b.boundaryEnd!==null){var c=shaka.media.StreamingEngine.CROSS_BOUNDARY_END_THRESHOLD_;a=b.boundaryEnd-a;a<0||a>c||(this.boundaryTime_=b.boundaryEnd+shaka.media.StreamingEngine.APPEND_WINDOW_END_FUDGE_,
this.crossBoundaryTimer_.tickAfter(a))}}};
shaka.media.StreamingEngine.prototype.discardReferenceByBoundary_=function(a,b){var c=this;if(a.type===shaka.util.ManifestParserUtils.ContentType.TEXT)return!1;var d=a.lastInitSegmentReference;if(!d)return!1;var e=shaka.config.CrossBoundaryStrategy,f=shaka.media.StreamingEngine.logPrefix_(a),g=b.initSegmentReference,h=d.boundaryEnd!==g.boundaryEnd;this.config_.crossBoundaryStrategy===e.RESET_TO_ENCRYPTED&&(d.encrypted||g.encrypted||(h=!1),d.encrypted&&(shaka.log.debug(f,"stream is encrypted, discard crossBoundaryStrategy"),
this.config_.crossBoundaryStrategy=e.KEEP));this.config_.crossBoundaryStrategy===e.RESET_ON_ENCRYPTION_CHANGE&&d.encrypted==g.encrypted&&(h=!1);if(this.config_.crossBoundaryStrategy===e.KEEP&&d.mimeType&&g.mimeType){var k=shaka.util.MimeUtils;e=k.getNormalizedCodec(k.getCodecs(d.mimeType));k=k.getNormalizedCodec(k.getCodecs(d.mimeType));d.mimeType==g.mimeType&&e==k&&(h=!1)}h&&(this.crossBoundarySeek_||a.seeked)&&(shaka.log.debug(f,"reset mediaSource","from=",a.lastInitSegmentReference,"to=",b.initSegmentReference),
this.crossBoundarySeek_=!1,this.resetMediaSource(!0).then(function(){var l=shaka.util.FakeEvent.EventName.BoundaryCrossed,m=(new Map).set("oldEncrypted",d.encrypted).set("newEncrypted",g.encrypted);c.playerInterface_.onEvent(new shaka.util.FakeEvent(l,m))}));return h};
shaka.media.StreamingEngine.prototype.getStreamsByType_=function(a){var b=this;a=a===void 0?!1:a;var c=shaka.util.ManifestParserUtils.ContentType,d=function(g){if(g.fullMimeTypes&&g.fullMimeTypes.size>1&&b.mediaStates_.has(g.type)){var h=b.mediaStates_.get(g.type),k=b.playerInterface_.mediaSourceEngine.bufferEnd(h.type),l=b.playerInterface_.getPresentationTime();(h=b.getSegmentReferenceNeeded_(h,l,k))&&h.codecs&&h.mimeType&&(g.codecs=h.codecs,g.mimeType=h.mimeType)}},e=new Map,f=this.currentVariant_.audio;
f&&(d(f),e.set(c.AUDIO,f));if(f=this.currentVariant_.video)d(f),e.set(c.VIDEO,f);a&&this.currentTextStream_&&e.set(c.TEXT,this.currentTextStream_);return e};shaka.media.StreamingEngine.logPrefix_=function(a){return"("+a.type+":"+a.stream.id+")"};shaka.media.StreamingEngine.APPEND_WINDOW_START_FUDGE_=.1;shaka.media.StreamingEngine.APPEND_WINDOW_END_FUDGE_=.1;shaka.media.StreamingEngine.MAX_RUN_AHEAD_SEGMENTS_=1;shaka.media.StreamingEngine.CROSS_BOUNDARY_END_THRESHOLD_=1;shaka.util.ConfigUtils=function(){};
shaka.util.ConfigUtils.mergeConfigObjects=function(a,b,c,d,e){goog.asserts.assert(a,"Destination config must not be null!");var f=e in d;var g=f?c.constructor==Object&&Object.keys(d).length==0:c.constructor==Object&&Object.keys(c).length==0;var h=f||g,k=!0,l;for(l in b){var m=e+"."+l,n=f?d[e]:c[l];h||l in c?b[l]===void 0?n===void 0||h?delete a[l]:a[l]=shaka.util.ObjectUtils.cloneObject(n):g?a[l]=b[l]:n.constructor==Object&&b[l]&&b[l].constructor==Object?(a[l]||(a[l]=shaka.util.ObjectUtils.cloneObject(n)),
m=shaka.util.ConfigUtils.mergeConfigObjects(a[l],b[l],n,d,m),k=k&&m):typeof b[l]!=typeof n||b[l]==null||typeof b[l]!="function"&&b[l].constructor!=n.constructor?(shaka.log.alwaysError("Invalid config, wrong type for "+m),k=!1):typeof c[l]=="function"&&c[l].length!=b[l].length?(shaka.log.alwaysWarn("Unexpected number of arguments for "+m),a[l]=b[l]):Array.isArray(a[l])?a[l]=b[l].slice():a[l]=b[l]:(shaka.log.alwaysError("Invalid config, unrecognized key "+m),k=!1)}return k};
shaka.util.ConfigUtils.convertToConfigObject=function(a,b){for(var c={},d=c,e=0,f=0;;){e=a.indexOf(".",e);if(e<0)break;if(e==0||a[e-1]!="\\")f=a.substring(f,e).replace(/\\\./g,"."),d[f]={},d=d[f],f=e+1;e+=1}d[a.substring(f).replace(/\\\./g,".")]=b;return c};shaka.util.ConfigUtils.referenceParametersAndReturn=function(a,b){return a&&b};
shaka.util.ConfigUtils.getDifferenceFromConfigObjects=function(a,b){var c=function(f){return f&&typeof f==="object"&&!Array.isArray(f)},d=function(f,g){return Object.keys(f).reduce(function(h,k){var l=f[k];if(g.hasOwnProperty(k))if(l instanceof HTMLElement&&g[k]instanceof HTMLElement)l.isEqualNode(g[k])||(h[k]=l);else if(c(l)&&c(g[k])){if(l=d(l,g[k]),Object.keys(l).length>0||!c(l))h[k]=l}else Array.isArray(l)&&Array.isArray(g[k])?shaka.util.ArrayUtils.hasSameElements(l,g[k])||(h[k]=l):Number.isNaN(l)&&
Number.isNaN(g[k])||l!==g[k]&&(h[k]=l);else h[k]=l;return h},{})};a=d(a,b);var e=function(f){for(var g=(0,$jscomp.makeIterator)(Object.keys(f)),h=g.next();!h.done;h=g.next())if(h=h.value,!(f[h]instanceof HTMLElement))if(c(f[h])&&Object.keys(f[h]).length===0)delete f[h];else{var k=f[h];Array.isArray(k)&&k.length===0?delete f[h]:typeof f[h]=="function"?delete f[h]:c(f[h])&&(e(f[h]),Object.keys(f[h]).length===0&&delete f[h])}};e(a);return a};goog.exportSymbol("shaka.util.ConfigUtils",shaka.util.ConfigUtils);
goog.exportProperty(shaka.util.ConfigUtils,"getDifferenceFromConfigObjects",shaka.util.ConfigUtils.getDifferenceFromConfigObjects);goog.exportProperty(shaka.util.ConfigUtils,"convertToConfigObject",shaka.util.ConfigUtils.convertToConfigObject);goog.exportProperty(shaka.util.ConfigUtils,"mergeConfigObjects",shaka.util.ConfigUtils.mergeConfigObjects);shaka.util.PlayerConfiguration=function(){};
shaka.util.PlayerConfiguration.createDefault=function(){var a=Infinity,b=shaka.device.DeviceFactory.getDevice();navigator.connection&&navigator.connection.saveData&&(a=360);var c={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),servers:{},clearKeys:{},advanced:{},delayLicenseRequestUntilPlayed:!1,persistentSessionOnlinePlayback:!1,persistentSessionsMetadata:[],initDataTransform:function(k,l,m){shaka.drm.DrmUtils.isMediaKeysPolyfilled("apple")&&l=="skd"&&(l=m.serverCertificate,
m=shaka.drm.FairPlay.defaultGetContentId(k),k=shaka.drm.FairPlay.initDataTransform(k,m,l));return k},logLicenseExchange:!1,updateExpirationTime:1,preferredKeySystems:[],keySystemsMapping:{},parseInbandPsshEnabled:!1,minHdcpVersion:"",ignoreDuplicateInitData:!0,defaultAudioRobustnessForWidevine:"SW_SECURE_CRYPTO",defaultVideoRobustnessForWidevine:"SW_SECURE_DECODE"},d=shaka.config.CodecSwitchingStrategy.RELOAD;shaka.media.Capabilities.isChangeTypeSupported()&&b.supportsSmoothCodecSwitching()&&(d=shaka.config.CodecSwitchingStrategy.SMOOTH);
var e={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),availabilityWindowOverride:NaN,disableAudio:!1,disableVideo:!1,disableText:!1,disableThumbnails:!1,disableIFrames:!1,defaultPresentationDelay:0,segmentRelativeVttTiming:!1,raiseFatalErrorOnManifestUpdateRequestFailure:!1,continueLoadingWhenPaused:!0,ignoreSupplementalCodecs:!1,updatePeriod:-1,ignoreDrmInfo:!1,enableAudioGroups:!0,dash:{clockSyncUri:"",disableXlinkProcessing:!0,xlinkFailGracefully:!1,ignoreMinBufferTime:!1,
autoCorrectDrift:!0,initialSegmentLimit:1E3,ignoreSuggestedPresentationDelay:!1,ignoreEmptyAdaptationSet:!1,ignoreMaxSegmentDuration:!1,keySystemsByURI:{"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e":"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:79f0049a-4098-8642-ab92-e65be0885f95":"com.microsoft.playready",
"urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2":"com.apple.fps","urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c":"com.huawei.wiseplay"},manifestPreprocessor:shaka.util.PlayerConfiguration.defaultManifestPreprocessor,manifestPreprocessorTXml:shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml,sequenceMode:!1,useStreamOnceInPeriodFlattening:!1,enableFastSwitching:!0},hls:{ignoreTextStreamFailures:!1,ignoreImageStreamFailures:!1,defaultAudioCodec:"mp4a.40.2",defaultVideoCodec:"avc1.42E01E",
ignoreManifestProgramDateTime:!1,ignoreManifestProgramDateTimeForTypes:[],mediaPlaylistFullMimeType:'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"',liveSegmentsDelay:3,sequenceMode:b.supportsSequenceMode(),ignoreManifestTimestampsInSegmentsMode:!1,disableCodecGuessing:!1,disableClosedCaptionsDetection:!1,allowLowLatencyByteRangeOptimization:!0,allowRangeRequestsToGuessMimeType:!1},mss:{manifestPreprocessor:shaka.util.PlayerConfiguration.defaultManifestPreprocessor,manifestPreprocessorTXml:shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml,
sequenceMode:!1,keySystemsBySystemId:{"9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","79f0049a-4098-8642-ab92-e65be0885f95":"com.microsoft.playready"}}},f={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),failureCallback:function(k){shaka.log.error("Unhandled streaming error",k);return shaka.util.ConfigUtils.referenceParametersAndReturn([k],void 0)},rebufferingGoal:0,bufferingGoal:10,bufferBehind:30,evictionGoal:1,ignoreTextStreamFailures:!1,alwaysStreamText:!1,
startAtSegmentBoundary:!1,gapDetectionThreshold:.5,gapPadding:0,gapJumpTimerTime:.25,durationBackoff:1,safeSeekOffset:5,safeSeekEndOffset:0,stallEnabled:!0,stallThreshold:1,stallSkip:.1,useNativeHlsForFairPlay:!0,inaccurateManifestTolerance:2,lowLatencyMode:!0,preferNativeDash:!1,preferNativeHls:!1,updateIntervalSeconds:1,observeQualityChanges:!1,maxDisabledTime:30,segmentPrefetchLimit:1,prefetchAudioLanguages:[],disableAudioPrefetch:!1,disableTextPrefetch:!1,disableVideoPrefetch:!1,liveSync:{enabled:!1,
targetLatency:.5,targetLatencyTolerance:.5,maxPlaybackRate:1.1,minPlaybackRate:.95,panicMode:!1,panicThreshold:60,dynamicTargetLatency:{enabled:!1,stabilityThreshold:60,rebufferIncrement:.5,maxAttempts:10,maxLatency:4,minLatency:1}},allowMediaSourceRecoveries:!0,minTimeBetweenRecoveries:5,vodDynamicPlaybackRate:!1,vodDynamicPlaybackRateLowBufferRate:.95,vodDynamicPlaybackRateBufferRatio:.5,preloadNextUrlWindow:30,loadTimeout:30,clearDecodingCache:!1,dontChooseCodecs:!1,shouldFixTimestampOffset:!1,
avoidEvictionOnQuotaExceededError:!1,crossBoundaryStrategy:shaka.config.CrossBoundaryStrategy.KEEP,returnToEndOfLiveWindowWhenOutside:!1},g={trackSelectionCallback:function(k){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){return l.return(k)})},downloadSizeCallback:function(k){var l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1)return navigator.storage&&navigator.storage.estimate?m.yield(navigator.storage.estimate(),3):m.return(!0);l=m.yieldResult;
return m.return(l.usage+k<l.quota*.95)})},progressCallback:function(k,l){return shaka.util.ConfigUtils.referenceParametersAndReturn([k,l],void 0)},usePersistentLicense:!0,numberOfParallelDownloads:5},h={drm:c,manifest:e,streaming:f,networking:{forceHTTP:!1,forceHTTPS:!1,minBytesForProgressEvents:16E3},mediaSource:{codecSwitchingStrategy:d,addExtraFeaturesToSourceBuffer:function(k){return shaka.util.ConfigUtils.referenceParametersAndReturn([k],"")},forceTransmux:!1,insertFakeEncryptionInInit:!0,correctEc3Enca:!1,
modifyCueCallback:function(k,l){return shaka.util.ConfigUtils.referenceParametersAndReturn([k,l],void 0)},dispatchAllEmsgBoxes:!1,useSourceElements:!0,durationReductionEmitsUpdateEnd:!0},offline:g,abrFactory:function(){return new shaka.abr.SimpleAbrManager},adaptationSetCriteriaFactory:function(){var k=$jscomp.getRestArguments.apply(0,arguments);return new (Function.prototype.bind.apply(shaka.media.PreferenceBasedCriteria,[null].concat((0,$jscomp.arrayFromIterable)(k))))},abr:{enabled:!0,useNetworkInformation:!0,
defaultBandwidthEstimate:1E6,switchInterval:8,bandwidthUpgradeTarget:.85,bandwidthDowngradeTarget:.95,restrictions:{minWidth:0,maxWidth:Infinity,minHeight:0,maxHeight:a,minPixels:0,maxPixels:Infinity,minFrameRate:0,maxFrameRate:Infinity,minBandwidth:0,maxBandwidth:Infinity,minChannelsCount:0,maxChannelsCount:Infinity},advanced:{minTotalBytes:128E3,minBytes:16E3,fastHalfLife:2,slowHalfLife:5},restrictToElementSize:!1,restrictToScreenSize:!1,ignoreDevicePixelRatio:!1,clearBufferSwitch:!1,safeMarginSwitch:0,
cacheLoadThreshold:5,minTimeToSwitch:0,preferNetworkInformationBandwidth:!1,removeLatencyFromFirstPacketTime:!0},autoShowText:shaka.config.AutoShowText.IF_SUBTITLES_MAY_BE_NEEDED,preferredAudioLanguage:"",preferredAudioLabel:"",preferredTextLanguage:"",preferredAudioRole:"",preferredVideoRole:"",preferredTextRole:"",preferredAudioChannelCount:2,preferredVideoHdrLevel:"AUTO",preferredVideoLayout:"",preferredVideoLabel:"",preferredVideoCodecs:[],preferredAudioCodecs:[],preferredTextFormats:[],preferForcedSubs:!1,
preferSpatialAudio:!1,preferredDecodingAttributes:[],restrictions:{minWidth:0,maxWidth:Infinity,minHeight:0,maxHeight:Infinity,minPixels:0,maxPixels:Infinity,minFrameRate:0,maxFrameRate:Infinity,minBandwidth:0,maxBandwidth:Infinity,minChannelsCount:0,maxChannelsCount:Infinity},playRangeStart:0,playRangeEnd:Infinity,textDisplayer:{captionsUpdatePeriod:.25,fontScaleFactor:1},textDisplayFactory:function(){return null},cmcd:{enabled:!1,sessionId:"",contentId:"",rtpSafetyFactor:5,useHeaders:!1,includeKeys:[],
version:1,targets:[]},cmsd:{enabled:!0,applyMaximumSuggestedBitrate:!0,estimatedThroughputWeightRatio:.5},lcevc:{enabled:!1,dynamicPerformanceScaling:!0,logLevel:0,drawLogo:!1,poster:!0},ads:{customPlayheadTracker:!1,skipPlayDetection:!1,supportsMultipleMediaElements:!0,disableHLSInterstitial:!1,disableDASHInterstitial:!1,allowPreloadOnDomElements:!0,allowStartInMiddleOfInterstitial:!0},ignoreHardwareResolution:!1,queue:{preloadNextUrlWindow:Infinity,preloadPrevItem:!0,repeatMode:shaka.config.RepeatMode.OFF}};
g.trackSelectionCallback=function(k){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){return l.return(shaka.util.PlayerConfiguration.defaultTrackSelect(k,h.preferredAudioLanguage,h.preferredVideoHdrLevel))})};return b.adjustConfig(h)};
shaka.util.PlayerConfiguration.createDefaultForLL=function(){return{streaming:{inaccurateManifestTolerance:0,segmentPrefetchLimit:2,updateIntervalSeconds:.1,maxDisabledTime:1,retryParameters:{baseDelay:100}},manifest:{dash:{autoCorrectDrift:!1},retryParameters:{baseDelay:100}},drm:{retryParameters:{baseDelay:100}}}};
shaka.util.PlayerConfiguration.mergeConfigObjects=function(a,b,c){var d={".drm.keySystemsMapping":"",".drm.servers":"",".drm.clearKeys":"",".drm.advanced":{distinctiveIdentifierRequired:!1,persistentStateRequired:!1,videoRobustness:[],audioRobustness:[],sessionType:"",serverCertificate:new Uint8Array(0),serverCertificateUri:"",individualizationServer:"",headers:{}}};return shaka.util.ConfigUtils.mergeConfigObjects(a,b,c||shaka.util.PlayerConfiguration.createDefault(),d,"")};
shaka.util.PlayerConfiguration.defaultTrackSelect=function(a,b,c){var d=shaka.util.ManifestParserUtils.ContentType,e=shaka.util.LanguageUtils,f=c;f=="AUTO"&&(c=a.some(function(l){return l.hdr&&l.hdr=="HLG"?!0:!1}),f=shaka.device.DeviceFactory.getDevice().getHdrLevel(c));var g=a.filter(function(l){return l.type!="variant"||l.hdr&&l.hdr!=f?!1:!0});c=[];var h=e.findClosestLocale(b,g.map(function(l){return l.language}));h&&(c=g.filter(function(l){return e.normalize(l.language)==h}));c.length==0&&(c=g.filter(function(l){return l.primary}));
c.length==0&&((new Set(g.map(function(l){return l.language}))).size>1&&shaka.log.warning("Could not choose a good audio track based on language preferences or primary tracks.  An arbitrary language will be stored!"),c=g);var k=c.filter(function(l){return l.height&&l.height<=480});k.length&&(k.sort(function(l,m){goog.asserts.assert(l.height!=null,"Null height");goog.asserts.assert(m.height!=null,"Null height");return m.height-l.height}),c=k.filter(function(l){return l.height==k[0].height}));b=[];c.length&&
(g=Math.floor(c.length/2),c.sort(function(l,m){return l.bandwidth-m.bandwidth}),b.push(c[g]));a=(0,$jscomp.makeIterator)(a);for(c=a.next();!c.done;c=a.next())c=c.value,c.type!=d.TEXT&&c.type!=d.IMAGE||b.push(c);return b};shaka.util.PlayerConfiguration.defaultManifestPreprocessor=function(a){return shaka.util.ConfigUtils.referenceParametersAndReturn([a],a)};shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml=function(a){return shaka.util.ConfigUtils.referenceParametersAndReturn([a],a)};
goog.exportSymbol("shaka.util.PlayerConfiguration",shaka.util.PlayerConfiguration);goog.exportProperty(shaka.util.PlayerConfiguration,"mergeConfigObjects",shaka.util.PlayerConfiguration.mergeConfigObjects);goog.exportProperty(shaka.util.PlayerConfiguration,"createDefaultForLL",shaka.util.PlayerConfiguration.createDefaultForLL);goog.exportProperty(shaka.util.PlayerConfiguration,"createDefault",shaka.util.PlayerConfiguration.createDefault);shaka.util.StateHistory=function(){this.open_=null;this.closed_=[]};shaka.util.StateHistory.prototype.update=function(a){return this.open_==null?(this.start_(a),!0):this.update_(a)};shaka.util.StateHistory.prototype.getTimeSpentIn=function(a){var b=0;this.open_&&this.open_.state==a&&(b+=this.open_.duration);for(var c=(0,$jscomp.makeIterator)(this.closed_),d=c.next();!d.done;d=c.next())d=d.value,b+=d.state==a?d.duration:0;return b};
shaka.util.StateHistory.prototype.getCopy=function(){for(var a=function(e){return{timestamp:e.timestamp,state:e.state,duration:e.duration}},b=[],c=(0,$jscomp.makeIterator)(this.closed_),d=c.next();!d.done;d=c.next())b.push(a(d.value));this.open_&&b.push(a(this.open_));return b};
shaka.util.StateHistory.prototype.start_=function(a){goog.asserts.assert(this.open_==null,"There must be no open entry in order when we start");shaka.log.v1("Changing Player state to",a);this.open_={timestamp:this.getNowInSeconds_(),state:a,duration:0}};
shaka.util.StateHistory.prototype.update_=function(a){goog.asserts.assert(this.open_,"There must be an open entry in order to update it");var b=this.getNowInSeconds_();this.open_.duration=b-this.open_.timestamp;if(this.open_.state==a)return!1;shaka.log.v1("Changing Player state to",a);this.closed_.push(this.open_);this.open_={timestamp:b,state:a,duration:0};return!0};shaka.util.StateHistory.prototype.getNowInSeconds_=function(){return Date.now()/1E3};shaka.util.SwitchHistory=function(){this.currentText_=this.currentVariant_=null;this.history_=[]};shaka.util.SwitchHistory.prototype.updateCurrentVariant=function(a,b){this.currentVariant_!=a&&(this.currentVariant_=a,this.history_.push({timestamp:this.getNowInSeconds_(),id:a.id,type:"variant",fromAdaptation:b,bandwidth:a.bandwidth}))};
shaka.util.SwitchHistory.prototype.updateCurrentText=function(a,b){this.currentText_!=a&&(this.currentText_=a,this.history_.push({timestamp:this.getNowInSeconds_(),id:a.id,type:"text",fromAdaptation:b,bandwidth:null}))};shaka.util.SwitchHistory.prototype.getCopy=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.history_),c=b.next();!c.done;c=b.next())a.push(this.clone_(c.value));return a};shaka.util.SwitchHistory.prototype.getNowInSeconds_=function(){return Date.now()/1E3};
shaka.util.SwitchHistory.prototype.clone_=function(a){return{timestamp:a.timestamp,id:a.id,type:a.type,fromAdaptation:a.fromAdaptation,bandwidth:a.bandwidth}};shaka.util.Stats=function(){this.height_=this.width_=NaN;this.currentCodecs_="";this.bytesDownloaded_=this.manifestSizeBytes_=this.bandwidthEstimate_=this.currentStreamBandwidth_=this.maxSegmentDurationSeconds_=this.liveLatencySeconds_=this.licenseTimeSeconds_=this.drmTimeSeconds_=this.manifestTimeSeconds_=this.loadLatencySeconds_=this.completionPercent_=this.totalGapsJumped_=this.totalStallsDetected_=this.totalCorruptedFrames_=this.totalDecodedFrames_=this.totalDroppedFrames_=NaN;this.nonFatalErrorCount_=
0;this.manifestGapCount_=this.manifestPeriodCount_=NaN;this.stateHistory_=new shaka.util.StateHistory;this.switchHistory_=new shaka.util.SwitchHistory};shaka.util.Stats.prototype.setDroppedFrames=function(a,b){this.totalDroppedFrames_=a;this.totalDecodedFrames_=b};shaka.util.Stats.prototype.setCorruptedFrames=function(a){this.totalCorruptedFrames_=a};shaka.util.Stats.prototype.setStallsDetected=function(a){this.totalStallsDetected_=a};
shaka.util.Stats.prototype.setGapsJumped=function(a){this.totalGapsJumped_=a};shaka.util.Stats.prototype.setResolution=function(a,b){this.width_=a;this.height_=b};shaka.util.Stats.prototype.setCodecs=function(a){this.currentCodecs_=a};shaka.util.Stats.prototype.setLoadLatency=function(a){this.loadLatencySeconds_=a};shaka.util.Stats.prototype.setManifestTime=function(a){this.manifestTimeSeconds_=a};
shaka.util.Stats.prototype.setCompletionPercent=function(a){isNaN(this.completionPercent_)?this.completionPercent_=a:this.completionPercent_=Math.max(this.completionPercent_,a)};shaka.util.Stats.prototype.setDrmTime=function(a){this.drmTimeSeconds_=a};shaka.util.Stats.prototype.setLicenseTime=function(a){this.licenseTimeSeconds_=a};shaka.util.Stats.prototype.setLiveLatency=function(a){this.liveLatencySeconds_=a};
shaka.util.Stats.prototype.setMaxSegmentDuration=function(a){this.maxSegmentDurationSeconds_=a};shaka.util.Stats.prototype.setCurrentStreamBandwidth=function(a){this.currentStreamBandwidth_=a};shaka.util.Stats.prototype.setBandwidthEstimate=function(a){this.bandwidthEstimate_=a};shaka.util.Stats.prototype.setManifestSize=function(a){this.manifestSizeBytes_=a};shaka.util.Stats.prototype.addBytesDownloaded=function(a){isNaN(this.bytesDownloaded_)?this.bytesDownloaded_=a:this.bytesDownloaded_+=a};
shaka.util.Stats.prototype.addNonFatalError=function(){this.nonFatalErrorCount_++};shaka.util.Stats.prototype.setManifestPeriodCount=function(a){this.manifestPeriodCount_=a};shaka.util.Stats.prototype.setManifestGapCount=function(a){this.manifestGapCount_=a};shaka.util.Stats.prototype.getStateHistory=function(){return this.stateHistory_};shaka.util.Stats.prototype.getSwitchHistory=function(){return this.switchHistory_};
shaka.util.Stats.prototype.getBlob=function(){return{width:this.width_,height:this.height_,currentCodecs:this.currentCodecs_,streamBandwidth:this.currentStreamBandwidth_,decodedFrames:this.totalDecodedFrames_,droppedFrames:this.totalDroppedFrames_,corruptedFrames:this.totalCorruptedFrames_,stallsDetected:this.totalStallsDetected_,gapsJumped:this.totalGapsJumped_,estimatedBandwidth:this.bandwidthEstimate_,completionPercent:this.completionPercent_,loadLatency:this.loadLatencySeconds_,manifestTimeSeconds:this.manifestTimeSeconds_,
drmTimeSeconds:this.drmTimeSeconds_,playTime:this.stateHistory_.getTimeSpentIn("playing"),pauseTime:this.stateHistory_.getTimeSpentIn("paused"),bufferingTime:this.stateHistory_.getTimeSpentIn("buffering"),licenseTime:this.licenseTimeSeconds_,liveLatency:this.liveLatencySeconds_,maxSegmentDuration:this.maxSegmentDurationSeconds_,manifestSizeBytes:this.manifestSizeBytes_,bytesDownloaded:this.bytesDownloaded_,nonFatalErrorCount:this.nonFatalErrorCount_,manifestPeriodCount:this.manifestPeriodCount_,manifestGapCount:this.manifestGapCount_,
stateHistory:this.stateHistory_.getCopy(),switchHistory:this.switchHistory_.getCopy()}};
shaka.util.Stats.getEmptyBlob=function(){return{width:NaN,height:NaN,currentCodecs:"",streamBandwidth:NaN,decodedFrames:NaN,droppedFrames:NaN,corruptedFrames:NaN,stallsDetected:NaN,gapsJumped:NaN,estimatedBandwidth:NaN,completionPercent:NaN,loadLatency:NaN,manifestTimeSeconds:NaN,drmTimeSeconds:NaN,playTime:NaN,pauseTime:NaN,bufferingTime:NaN,licenseTime:NaN,liveLatency:NaN,maxSegmentDuration:NaN,manifestSizeBytes:NaN,bytesDownloaded:NaN,nonFatalErrorCount:NaN,manifestPeriodCount:NaN,manifestGapCount:NaN,
switchHistory:[],stateHistory:[]}};shaka.media.PreloadManager=function(a,b,c,d){shaka.util.FakeEventTarget.call(this);this.assetUri_=a;this.mimeType_=b;this.networkingEngine_=d.networkingEngine;this.startTime_=c;this.currentAdaptationSetCriteria_=null;this.startTimeOfDrm_=0;this.createDrmEngine_=d.createDrmEngine;this.manifestFilterer_=d.manifestFilterer;this.manifestPlayerInterface_=d.manifestPlayerInterface;this.config_=d.config;this.parser_=this.parserFactory_=this.manifest_=null;this.parserEntrusted_=!1;this.regionTimeline_=d.regionTimeline;
this.regionTimelineEntrusted_=!1;this.drmEngine_=null;this.drmEngineEntrusted_=!1;this.abrManager_=null;this.segmentPrefetchById_=new Map;this.segmentPrefetchEntrusted_=!1;this.qualityObserver_=d.qualityObserver;this.stats_=new shaka.util.Stats;this.manifestPromise_=new shaka.util.PublicPromise;this.successPromise_=new shaka.util.PublicPromise;this.eventHandoffTarget_=null;this.destroyed_=!1;this.allowPrefetch_=d.allowPrefetch;this.prefetchedTextStream_=this.prefetchedVariant_=null;this.hasBeenAttached_=
!1;this.queuedOperations_=[];this.latePhaseQueuedOperations_=[];this.isPreload_=!0};$jscomp.inherits(shaka.media.PreloadManager,shaka.util.FakeEventTarget);shaka.media.PreloadManager.prototype.markIsLoad=function(){this.isPreload_=!1};shaka.media.PreloadManager.prototype.addQueuedOperation=function(a,b){(a=a?this.latePhaseQueuedOperations_:this.queuedOperations_)?a.push(b):b()};
shaka.media.PreloadManager.prototype.stopQueuingLatePhaseQueuedOperations=function(){if(this.latePhaseQueuedOperations_)for(var a=(0,$jscomp.makeIterator)(this.latePhaseQueuedOperations_),b=a.next();!b.done;b=a.next())b=b.value,b();this.latePhaseQueuedOperations_=null};
shaka.media.PreloadManager.prototype.setEventHandoffTarget=function(a){this.eventHandoffTarget_=a;this.hasBeenAttached_=!0;if(this.queuedOperations_){a=(0,$jscomp.makeIterator)(this.queuedOperations_);for(var b=a.next();!b.done;b=a.next())b=b.value,b()}this.queuedOperations_=null};shaka.media.PreloadManager.prototype.setOffsetToStartTime=function(a){this.startTime_&&a&&(typeof this.startTime_==="number"?this.startTime_+=a:this.startTime_.setTime(this.startTime_.getTime()+a*1E3))};
shaka.media.PreloadManager.prototype.getStartTime=function(){return this.startTime_};shaka.media.PreloadManager.prototype.getStartTimeOfDRM=function(){return this.startTimeOfDrm_};shaka.media.PreloadManager.prototype.getMimeType=function(){return this.mimeType_};shaka.media.PreloadManager.prototype.getAssetUri=function(){return this.assetUri_};shaka.media.PreloadManager.prototype.getManifest=function(){return this.manifest_};shaka.media.PreloadManager.prototype.getParserFactory=function(){return this.parserFactory_};
shaka.media.PreloadManager.prototype.getCurrentAdaptationSetCriteria=function(){return this.currentAdaptationSetCriteria_};shaka.media.PreloadManager.prototype.receiveParser=function(){this.parserEntrusted_=!0;return this.parser_};shaka.media.PreloadManager.prototype.getParser=function(){return this.parser_};shaka.media.PreloadManager.prototype.receiveRegionTimeline=function(){this.regionTimelineEntrusted_=!0;return this.regionTimeline_};shaka.media.PreloadManager.prototype.getRegionTimeline=function(){return this.regionTimeline_};
shaka.media.PreloadManager.prototype.getQualityObserver=function(){return this.qualityObserver_};shaka.media.PreloadManager.prototype.getStats=function(){return this.stats_};shaka.media.PreloadManager.prototype.getManifestFilterer=function(){return this.manifestFilterer_};shaka.media.PreloadManager.prototype.receiveDrmEngine=function(){this.drmEngineEntrusted_=!0;return this.drmEngine_};shaka.media.PreloadManager.prototype.getDrmEngine=function(){return this.drmEngine_};
shaka.media.PreloadManager.prototype.setPrefetchVariant=function(a){this.prefetchedVariant_=a};shaka.media.PreloadManager.prototype.getPrefetchedVariant=function(){return this.prefetchedVariant_};shaka.media.PreloadManager.prototype.getPrefetchedVariantTrack=function(){return this.prefetchedVariant_?shaka.util.StreamUtils.variantToTrack(this.prefetchedVariant_):null};
shaka.media.PreloadManager.prototype.getPrefetchedTextTrack=function(){return this.prefetchedTextStream_?shaka.util.StreamUtils.textStreamToTrack(this.prefetchedTextStream_):null};shaka.media.PreloadManager.prototype.receiveSegmentPrefetchesById=function(){this.segmentPrefetchEntrusted_=!0;return this.segmentPrefetchById_};shaka.media.PreloadManager.prototype.attachAdaptationSetCriteria=function(a){this.currentAdaptationSetCriteria_=a};
shaka.media.PreloadManager.prototype.attachManifest=function(a,b,c){this.manifest_=a;this.parser_=b;this.parserFactory_=c};
shaka.media.PreloadManager.prototype.start=function(){var a=this;(function(){var b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.nextAddress){case 1:return c.yield(Promise.resolve(),2);case 2:return c.setCatchFinallyBlocks(3),c.yield(a.parseManifestInner_(),5);case 5:a.throwIfDestroyed_();if(shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")){c.jumpTo(6);break}return c.yield(a.initializeDrm(),7);case 7:a.throwIfDestroyed_();case 6:if(!a.allowPrefetch_){c.jumpTo(8);break}return c.yield(a.prefetchInner_(),
9);case 9:a.throwIfDestroyed_();case 8:if(!a.allowPrefetch_||!a.drmEngine_){c.jumpTo(10);break}return c.yield(a.drmEngine_.waitForActiveRequests(),11);case 11:a.throwIfDestroyed_();case 10:a.successPromise_.resolve();c.leaveTryBlock(0);break;case 3:b=c.enterCatchBlock(),b instanceof shaka.util.Error&&(b.code==shaka.util.Error.Code.OPERATION_ABORTED||b.code==shaka.util.Error.Code.OBJECT_DESTROYED)||a.successPromise_.reject(b),c.jumpToEnd()}})})()};
shaka.media.PreloadManager.prototype.dispatchEvent=function(a){return this.eventHandoffTarget_?this.eventHandoffTarget_.dispatchEvent(a):shaka.util.FakeEventTarget.prototype.dispatchEvent.call(this,a)};shaka.media.PreloadManager.prototype.onError=function(a){a.severity===shaka.util.Error.Severity.CRITICAL&&(this.successPromise_.reject(a),this.destroy());var b=this.makeEvent_(shaka.util.FakeEvent.EventName.Error,(new Map).set("detail",a));this.dispatchEvent(b);b.defaultPrevented&&(a.handled=!0)};
shaka.media.PreloadManager.prototype.throwIfDestroyed_=function(){if(this.isDestroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OBJECT_DESTROYED);};shaka.media.PreloadManager.prototype.makeStateChangeEvent_=function(a){this.dispatchEvent(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.OnStateChange,(new Map).set("state",a)))};
shaka.media.PreloadManager.prototype.makeEvent_=function(a,b){return new shaka.util.FakeEvent(a,b)};
shaka.media.PreloadManager.prototype.parseManifestInner_=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.nextAddress){case 1:a.makeStateChangeEvent_("manifest-parser");a.parser_||(a.parserFactory_=shaka.media.ManifestParser.getFactory(a.assetUri_,a.mimeType_),goog.asserts.assert(a.parserFactory_,"Must have manifest parser"),a.parser_=a.parserFactory_(),a.parser_.configure(a.config_.manifest,function(){return a.isPreload_}));b=Date.now()/
1E3;a.makeStateChangeEvent_("manifest");if(a.manifest_){h.jumpTo(2);break}return h.yield(a.parser_.start(a.assetUri_,a.manifestPlayerInterface_),3);case 3:return a.manifest_=h.yieldResult,shaka.media.PreloadManager.filterForAVVariants_(a.manifest_),h.yield(a.chooseInitialVariant_(),2);case 2:return a.manifestPromise_.resolve(),c=a.makeEvent_(shaka.util.FakeEvent.EventName.ManifestParsed),h.yield(Promise.resolve(),5);case 5:a.dispatchEvent(c);if(a.manifest_.variants.length==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.NO_VARIANTS);shaka.media.PreloadManager.filterForAVVariants_(a.manifest_);d=a.manifestFilterer_.applyRestrictions(a.manifest_);if(!d){h.jumpTo(6);break}e=a.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return h.yield(Promise.resolve(),7);case 7:a.throwIfDestroyed_(),a.dispatchEvent(e);case 6:f=Date.now()/1E3,g=f-b,a.stats_.setManifestTime(g),h.jumpToEnd()}})};
shaka.media.PreloadManager.prototype.initializeDrm=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.nextAddress){case 1:if(!b.manifest_||b.drmEngine_)return g.return();b.makeStateChangeEvent_("drm-engine");b.startTimeOfDrm_=Date.now()/1E3;b.drmEngine_=b.createDrmEngine_();b.manifestFilterer_.setDrmEngine(b.drmEngine_);b.drmEngine_.configure(b.config_.drm,function(){return b.isPreload_});c=shaka.util.StreamUtils.getPlayableVariants(b.manifest_.variants);
d=!0;b.manifest_&&b.manifest_.presentationTimeline&&(d=b.manifest_.presentationTimeline.isLive());return g.yield(b.drmEngine_.initForPlayback(c,b.manifest_.offlineSessionIds,d),2);case 2:b.throwIfDestroyed_();if(!a){g.jumpTo(3);break}return g.yield(b.drmEngine_.attach(a),4);case 4:b.throwIfDestroyed_();case 3:return g.yield(b.manifestFilterer_.filterManifest(b.manifest_),5);case 5:e=g.yieldResult;if(!e){g.jumpTo(0);break}f=b.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return g.yield(Promise.resolve(),
7);case 7:b.dispatchEvent(f),g.jumpToEnd()}})};shaka.media.PreloadManager.prototype.reconfigure=function(a){this.config_=a};shaka.media.PreloadManager.prototype.configure=function(a,b){a=shaka.util.ConfigUtils.convertToConfigObject(a,b);shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,a)};shaka.media.PreloadManager.prototype.getConfiguration=function(){return shaka.util.ObjectUtils.cloneObject(this.config_)};
shaka.media.PreloadManager.prototype.chooseInitialVariant_=function(){var a=this,b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){a.currentAdaptationSetCriteria_||(a.currentAdaptationSetCriteria_=a.config_.adaptationSetCriteriaFactory(),a.currentAdaptationSetCriteria_.configure({language:a.config_.preferredAudioLanguage,role:a.config_.preferredAudioRole,videoRole:a.config_.preferredVideoRole,channelCount:a.config_.preferredAudioChannelCount,hdrLevel:a.config_.preferredVideoHdrLevel,
spatialAudio:a.config_.preferSpatialAudio,videoLayout:a.config_.preferredVideoLayout,audioLabel:a.config_.preferredAudioLabel,videoLabel:a.config_.preferredVideoLabel,codecSwitchingStrategy:a.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:a.config_.preferredAudioCodecs,preferredAudioChannelCount:a.config_.preferredAudioChannelCount}));if(!a.shouldCreateSegmentIndexBeforeDrmEngineInitialization_())return g.jumpTo(0);b=a.configureAbrManagerAndChooseVariant_();
if(!b)return g.jumpTo(0);c=[];d=(0,$jscomp.makeIterator)([b.video,b.audio]);for(e=d.next();!e.done;e=d.next())(f=e.value)&&!f.segmentIndex&&c.push(f.createSegmentIndex());return c.length>0?g.yield(Promise.all(c),0):g.jumpTo(0)})};
shaka.media.PreloadManager.prototype.shouldCreateSegmentIndexBeforeDrmEngineInitialization_=function(){goog.asserts.assert(this.manifest_,"The manifest should already be parsed.");return this.manifest_.variants.length==1||this.manifest_.type==shaka.media.ManifestParser.HLS?!0:!1};
shaka.media.PreloadManager.prototype.prefetchInner_=function(){var a=this,b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){!a.prefetchedVariant_&&(b=a.configureAbrManagerAndChooseVariant_())&&(a.prefetchedVariant_=b);if(!a.prefetchedVariant_)return g.jumpTo(0);c=a.manifest_.presentationTimeline.isLive();d=[];e=a.prefetchedVariant_;e.video&&d.push(a.prefetchStream_(e.video,c));e.audio&&d.push(a.prefetchStream_(e.audio,c));(f=a.chooseTextStream_())&&shaka.util.StreamUtils.shouldInitiallyShowText(e.audio,
f,a.config_)&&(d.push(a.prefetchStream_(f,c)),a.prefetchedTextStream_=f);return g.yield(Promise.all(d),0)})};
shaka.media.PreloadManager.prototype.configureAbrManagerAndChooseVariant_=function(){goog.asserts.assert(this.currentAdaptationSetCriteria_,"Must have an AdaptationSetCriteria");if(!this.abrManager_){var a=this.config_.abrFactory;this.abrManager_=a();this.abrManager_.configure(this.config_.abr)}a=shaka.util.StreamUtils.getPlayableVariants(this.manifest_.variants);a=this.currentAdaptationSetCriteria_.create(a);this.abrManager_.setVariants(Array.from(a.values()));return this.abrManager_.chooseVariant(!0)};
shaka.media.PreloadManager.prototype.chooseTextStream_=function(){return shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.config_.preferredTextLanguage,this.config_.preferredTextRole,this.config_.preferForcedSubs)[0]||null};
shaka.media.PreloadManager.prototype.prefetchStream_=function(a,b){var c=this,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.nextAddress==1)return d=c.config_.streaming.segmentPrefetchLimit||2,e=new shaka.media.SegmentPrefetch(d,a,function(l,m,n){return shaka.media.StreamingEngine.dispatchFetch(l,m,n||null,c.config_.streaming.retryParameters,c.networkingEngine_,c.isPreload_)},!1),c.segmentPrefetchById_.set(a.id,e),a.segmentIndex?k.jumpTo(2):k.yield(a.createSegmentIndex(),
2);f=typeof c.startTime_==="number"?c.startTime_:0;g=a.segmentIndex.getIteratorForTime(f);h=null;g&&(h=g.current(),h||(h=g.next().value));h||(h=a.segmentIndex.earliestReference());return h?b?h.initSegmentReference?k.yield(e.prefetchInitSegment(h.initSegmentReference),0):k.jumpTo(0):k.yield(e.prefetchSegmentsByTime(h.startTime),0):k.jumpTo(0)})};shaka.media.PreloadManager.prototype.waitForFinish=function(){return this.successPromise_};
shaka.media.PreloadManager.prototype.waitForManifest=function(){return Promise.race([this.manifestPromise_,this.successPromise_])};
shaka.media.PreloadManager.prototype.destroy=function(){var a=this,b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1)return a.destroyed_=!0,!a.parser_||a.parserEntrusted_?e.jumpTo(2):e.yield(a.parser_.stop(),2);if(e.nextAddress!=4)return a.abrManager_&&a.abrManager_.release(),a.regionTimeline_&&!a.regionTimelineEntrusted_&&a.regionTimeline_.release(),!a.drmEngine_||a.drmEngineEntrusted_?e.jumpTo(4):e.yield(a.drmEngine_.destroy(),4);if(a.segmentPrefetchById_.size>
0&&!a.segmentPrefetchEntrusted_)for(b=(0,$jscomp.makeIterator)(a.segmentPrefetchById_.values()),c=b.next();!c.done;c=b.next())d=c.value,d.clearAll();e.jumpToEnd()})};shaka.media.PreloadManager.prototype.isDestroyed=function(){return this.destroyed_};shaka.media.PreloadManager.prototype.hasBeenAttached=function(){return this.hasBeenAttached_};
shaka.media.PreloadManager.filterForAVVariants_=function(a){var b=function(c){return c.video&&c.audio||c.video&&c.video.codecs.includes(",")};a.variants.some(b)&&(shaka.log.debug("Found variant with audio and video content, so filtering out audio-only content."),a.variants=a.variants.filter(b))};goog.exportSymbol("shaka.media.PreloadManager",shaka.media.PreloadManager);goog.exportProperty(shaka.media.PreloadManager.prototype,"destroy",shaka.media.PreloadManager.prototype.destroy);
goog.exportProperty(shaka.media.PreloadManager.prototype,"waitForFinish",shaka.media.PreloadManager.prototype.waitForFinish);goog.exportProperty(shaka.media.PreloadManager.prototype,"getPrefetchedTextTrack",shaka.media.PreloadManager.prototype.getPrefetchedTextTrack);goog.exportProperty(shaka.media.PreloadManager.prototype,"getPrefetchedVariantTrack",shaka.media.PreloadManager.prototype.getPrefetchedVariantTrack);shaka.media.RegionObserver=function(a,b){shaka.util.FakeEventTarget.call(this);var c=this;this.timeline_=a;this.startsPastZero_=b;this.oldPosition_=new Map;var d=shaka.media.RegionObserver.RelativePosition_;a=d.BEFORE_THE_REGION;b=d.IN_THE_REGION;d=d.AFTER_THE_REGION;this.rules_=[{weWere:null,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:a,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:d,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:b,
weAre:a,invoke:function(e,f){return c.onEvent_("exit",e,f)}},{weWere:b,weAre:d,invoke:function(e,f){return c.onEvent_("exit",e,f)}},{weWere:a,weAre:d,invoke:function(e,f){if(f)c.onEvent_("skip",e,f);else c.onEvent_("enter",e,f),c.onEvent_("exit",e,f)}},{weWere:d,weAre:a,invoke:function(e,f){return c.onEvent_("skip",e,f)}}];this.eventManager_=new shaka.util.EventManager;this.eventManager_.listen(this.timeline_,"regionremove",function(e){c.oldPosition_.delete(e.region)})};
$jscomp.inherits(shaka.media.RegionObserver,shaka.util.FakeEventTarget);shaka.media.RegionObserver.prototype.release=function(){this.timeline_=null;this.oldPosition_.clear();this.eventManager_.release();this.eventManager_=null;shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.RegionObserver.prototype.poll=function(a,b){var c=shaka.media.RegionObserver;if(!this.startsPastZero_||a!=0){this.startsPastZero_=!1;for(var d=(0,$jscomp.makeIterator)(this.timeline_.regions()),e=d.next();!e.done;e=d.next()){e=e.value;var f=this.oldPosition_.get(e),g=c.determinePositionRelativeTo_(e,a);this.oldPosition_.set(e,g);for(var h=(0,$jscomp.makeIterator)(this.rules_),k=h.next();!k.done;k=h.next())k=k.value,k.weWere==f&&k.weAre==g&&k.invoke(e,b)}}};
shaka.media.RegionObserver.prototype.onEvent_=function(a,b,c){a=new shaka.util.FakeEvent(a,new Map([["region",b],["seeking",c]]));this.dispatchEvent(a)};shaka.media.RegionObserver.determinePositionRelativeTo_=function(a,b){var c=shaka.media.RegionObserver.RelativePosition_;return b<a.startTime?c.BEFORE_THE_REGION:b>a.endTime?c.AFTER_THE_REGION:c.IN_THE_REGION};shaka.media.RegionObserver.RelativePosition_={BEFORE_THE_REGION:1,IN_THE_REGION:2,AFTER_THE_REGION:3};shaka.net.HttpPluginUtils=function(){};
shaka.net.HttpPluginUtils.makeResponse=function(a,b,c,d,e,f,g){goog.asserts.assert(b,"Data should be non-null!");if(c>=200&&c<=299&&c!=202||c==304)return{uri:e||d,originalUri:d,data:b,status:c,headers:a,fromCache:!!a["x-shaka-from-cache"],originalRequest:f};f=null;try{f=shaka.util.StringUtils.fromBytesAutoDetect(b)}catch(h){}shaka.log.debug("HTTP error text:",f);throw new shaka.util.Error(c==401||c==403?shaka.util.Error.Severity.CRITICAL:shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.BAD_HTTP_STATUS,d,c,f,a,g,e||d);};shaka.net.HttpFetchPlugin=function(){};
shaka.net.HttpFetchPlugin.parse=function(a,b,c,d,e,f){var g=new shaka.net.HttpFetchPlugin.Headers_;try{shaka.util.MapUtils.asMap(b.headers).forEach(function(m,n){g.append(n,m)})}catch(m){return shaka.log.debug("Failed to create headers:",m),shaka.util.AbortableOperation.failed(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,m,c))}var h=new shaka.net.HttpFetchPlugin.AbortController_,k={canceled:!1,timedOut:!1};a=shaka.net.HttpFetchPlugin.request_(a,
b,c,{body:b.body||void 0,headers:g,method:b.method,signal:h.signal,credentials:b.allowCrossSiteCredentials?"include":void 0},k,d,e,b.streamDataCallback,f.minBytesForProgressEvents||0);a=new shaka.util.AbortableOperation(a,function(){k.canceled=!0;h.abort();return Promise.resolve()});if(b=b.retryParameters.timeout){var l=new shaka.util.Timer(function(){k.timedOut=!0;h.abort()});l.tickAfter(b/1E3);a.finally(function(){l.stop()})}return a};
shaka.net.HttpFetchPlugin.request_=function(a,b,c,d,e,f,g,h,k){var l,m,n,p,q,r,t,w,v,u,x,z,B,C,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.nextAddress){case 1:return l=shaka.net.HttpFetchPlugin.fetch_,m=shaka.net.HttpFetchPlugin.ReadableStream_,p=new ArrayBuffer(0),r=q=0,t={},w=Date.now(),A.setCatchFinallyBlocks(2),A.yield(l(a,d),4);case 4:n=A.yieldResult;t=shaka.net.HttpFetchPlugin.headersToGenericObject_(n.headers);g(t);if(d.method=="HEAD"){A.jumpTo(5);break}goog.asserts.assert(n.body,
"non-HEAD responses should have a body");u=(v=n.headers.get("Content-Length"))?parseInt(v,10):0;if(!n.body)return A.yield(n.arrayBuffer(),9);x=n.clone().body.getReader();z=function(D){var E=function(){var F,L,K,J,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.nextAddress){case 1:return G.setCatchFinallyBlocks(2),G.yield(x.read(),4);case 4:F=G.yieldResult;G.leaveTryBlock(3);break;case 2:return L=G.enterCatchBlock(),shaka.log.v1("error reading from stream",L.message),G.return();
case 3:if(F.done){G.jumpTo(5);break}q+=F.value.byteLength;if(!h){G.jumpTo(5);break}return G.yield(h(F.value),5);case 5:K=Date.now();J=q-r;if(K-w>100&&J>=k||F.done)I=F.done?0:u-q,f(K-w,J,I),r=q,w=K;F.done?(goog.asserts.assert(!F.value,'readObj should be unset when "done" is true.'),D.close()):(D.enqueue(F.value),E());G.jumpToEnd()}})};E()};new m({start:z});return A.yield(n.arrayBuffer(),8);case 8:p=A.yieldResult;A.jumpTo(5);break;case 9:p=A.yieldResult,B=Date.now(),f(B-w,p.byteLength,0);case 5:b.headers.Range&&
(C=b.headers.Range.replace("bytes=","").split("-").filter(function(D){return D}).map(function(D){return parseInt(D,10)}),C.length==2&&p.byteLength!=C[1]-C[0]+1&&shaka.log.alwaysWarn("Payload length does not match range requested bytes",b,n));A.leaveTryBlock(3);break;case 2:y=A.enterCatchBlock();if(e.canceled)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED,a,c);if(e.timedOut)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,a,c);throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,y,c);case 3:return A.return(shaka.net.HttpPluginUtils.makeResponse(t,p,n.status,a,n.url,b,c))}})};shaka.net.HttpFetchPlugin.headersToGenericObject_=function(a){var b={};a.forEach(function(c,d){b[d.trim()]=c});return b};
shaka.net.HttpFetchPlugin.isSupported=function(){if(window.ReadableStream)try{new ReadableStream({})}catch(a){return!1}else return!1;if(window.Response){if(!(new Response("")).body)return!1}else return!1;return!(!window.fetch||"polyfill"in window.fetch||!window.AbortController)};goog.exportSymbol("shaka.net.HttpFetchPlugin",shaka.net.HttpFetchPlugin);goog.exportProperty(shaka.net.HttpFetchPlugin,"isSupported",shaka.net.HttpFetchPlugin.isSupported);
goog.exportProperty(shaka.net.HttpFetchPlugin,"parse",shaka.net.HttpFetchPlugin.parse);shaka.net.HttpFetchPlugin.fetch_=window.fetch;shaka.net.HttpFetchPlugin.AbortController_=window.AbortController;shaka.net.HttpFetchPlugin.ReadableStream_=window.ReadableStream;shaka.net.HttpFetchPlugin.Headers_=window.Headers;
shaka.net.HttpFetchPlugin.isSupported()&&(shaka.net.NetworkingEngine.registerScheme("http",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0),shaka.net.NetworkingEngine.registerScheme("https",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0),shaka.net.NetworkingEngine.registerScheme("blob",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0));shaka.net.HttpXHRPlugin=function(){};
shaka.net.HttpXHRPlugin.parse=function(a,b,c,d,e,f){var g=new shaka.net.HttpXHRPlugin.Xhr_,h=Date.now(),k=0,l=new Promise(function(m,n){g.open(b.method,a,!0);g.responseType="arraybuffer";g.timeout=b.retryParameters.timeout;g.withCredentials=b.allowCrossSiteCredentials;var p={};g.onabort=function(){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED,a,c))};g.onreadystatechange=function(t){g.readyState===XMLHttpRequest.HEADERS_RECEIVED&&
(p=shaka.net.HttpXHRPlugin.headersToGenericObject_(g),e(p))};g.onload=function(t){goog.asserts.assert(g.response instanceof ArrayBuffer,"XHR should have a response by now!");var w=g.response;try{var v=Date.now();d(v-h,t.loaded-k,0);var u=shaka.net.HttpPluginUtils.makeResponse(p,w,g.status,a,g.responseURL,b,c);m(u)}catch(x){goog.asserts.assert(x instanceof shaka.util.Error,"Wrong error type!"),n(x)}};g.onerror=function(t){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.HTTP_ERROR,a,t,c))};g.ontimeout=function(t){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,a,c))};g.onprogress=function(t){var w=Date.now(),v=f.minBytesForProgressEvents||0,u=t.loaded-k;if(w-h>100&&u>=v||t.lengthComputable&&t.loaded==t.total)d(w-h,u,g.readyState==4?0:t.total-t.loaded),k=t.loaded,h=w};for(var q in b.headers)try{var r=q.toLowerCase();g.setRequestHeader(r,b.headers[q])}catch(t){throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,t,c);}g.send(b.body)});return new shaka.util.AbortableOperation(l,function(){g.abort();return Promise.resolve()})};shaka.net.HttpXHRPlugin.headersToGenericObject_=function(a){var b=a.getAllResponseHeaders().trim().split("\r\n");a={};b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value.split(": "),a[c[0].toLowerCase()]=c.slice(1).join(": ");return a};goog.exportSymbol("shaka.net.HttpXHRPlugin",shaka.net.HttpXHRPlugin);
goog.exportProperty(shaka.net.HttpXHRPlugin,"parse",shaka.net.HttpXHRPlugin.parse);shaka.net.HttpXHRPlugin.Xhr_=window.XMLHttpRequest;shaka.net.NetworkingEngine.registerScheme("http",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);shaka.net.NetworkingEngine.registerScheme("https",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);
shaka.net.NetworkingEngine.registerScheme("blob",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);/*
 @license
 Copyright 2013 Ali Al Dallal

 Licensed under the MIT license.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
*/
for(var mozilla={LanguageMapping:{ach:"Lwo",ady:"\u0410\u0434\u044b\u0433\u044d\u0431\u0437\u044d",af:"Afrikaans","af-NA":"Afrikaans (Namibia)","af-ZA":"Afrikaans (South Africa)",ak:"T\u0255\u0265i",ar:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-AR":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-MA":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-SA":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629)","ay-BO":"Aymar aru",az:"Az\u0259rbaycan dili",
"az-AZ":"Az\u0259rbaycan dili","be-BY":"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f",bg:"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438","bg-BG":"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438",bn:"\u09ac\u09be\u0982\u09b2\u09be","bn-IN":"\u09ac\u09be\u0982\u09b2\u09be (\u09ad\u09be\u09b0\u09a4)","bn-BD":"\u09ac\u09be\u0982\u09b2\u09be(\u09ac\u09be\u0982\u09b2\u09be\u09a6\u09c7\u09b6)","bs-BA":"Bosanski",ca:"Catal\u00e0","ca-ES":"Catal\u00e0",cak:"Maya Kaqchikel",
"ck-US":"\u13e3\u13b3\u13a9 (tsalagi)",cs:"\u010ce\u0161tina","cs-CZ":"\u010ce\u0161tina",cy:"Cymraeg","cy-GB":"Cymraeg",da:"Dansk","da-DK":"Dansk",de:"Deutsch","de-AT":"Deutsch (\u00d6sterreich)","de-DE":"Deutsch (Deutschland)","de-CH":"Deutsch (Schweiz)",dsb:"Dolnoserb\u0161\u0107ina",el:"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac","el-GR":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac",en:"English","en-GB":"English (UK)","en-AU":"English (Australia)","en-CA":"English (Canada)","en-IE":"English (Ireland)",
"en-IN":"English (India)","en-PI":"English (Pirate)","en-UD":"English (Upside Down)","en-US":"English (US)","en-ZA":"English (South Africa)","en@pirate":"English (Pirate)",eo:"Esperanto","eo-EO":"Esperanto",es:"Espa\u00f1ol","es-AR":"Espa\u00f1ol (Argentine)","es-419":"Espa\u00f1ol (Latinoam\u00e9rica)","es-CL":"Espa\u00f1ol (Chile)","es-CO":"Espa\u00f1ol (Colombia)","es-EC":"Espa\u00f1ol (Ecuador)","es-ES":"Espa\u00f1ol (Espa\u00f1a)","es-LA":"Espa\u00f1ol (Latinoam\u00e9rica)","es-NI":"Espa\u00f1ol (Nicaragua)",
"es-MX":"Espa\u00f1ol (M\u00e9xico)","es-US":"Espa\u00f1ol (Estados Unidos)","es-VE":"Espa\u00f1ol (Venezuela)",et:"eesti keel","et-EE":"Eesti (Estonia)",eu:"Euskara","eu-ES":"Euskara",fa:"\u0641\u0627\u0631\u0633\u06cc","fa-IR":"\u0641\u0627\u0631\u0633\u06cc","fb-LT":"Leet Speak",ff:"Fulah",fi:"Suomi","fi-FI":"Suomi","fo-FO":"F\u00f8royskt",fr:"Fran\u00e7ais","fr-CA":"Fran\u00e7ais (Canada)","fr-FR":"Fran\u00e7ais (France)","fr-BE":"Fran\u00e7ais (Belgique)","fr-CH":"Fran\u00e7ais (Suisse)","fy-NL":"Frysk",
ga:"Gaeilge","ga-IE":"Gaeilge (Gaelic)",gl:"Galego","gl-ES":"Galego","gn-PY":"Ava\u00f1e'\u1ebd","gu-IN":"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0","gx-GR":"\u1f19\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ae \u1f00\u03c1\u03c7\u03b1\u03af\u03b1",he:"\u05e2\u05d1\u05e8\u05d9\u05ea\u200f","he-IL":"\u05e2\u05d1\u05e8\u05d9\u05ea\u200f",hi:"\u0939\u093f\u0928\u094d\u0926\u0940","hi-IN":"\u0939\u093f\u0928\u094d\u0926\u0940",hr:"Hrvatski","hr-HR":"Hrvatski",hsb:"Hornjoserb\u0161\u0107ina",ht:"Krey\u00f2l",
hu:"Magyar","hu-HU":"Magyar","hy-AM":"\u0540\u0561\u0575\u0565\u0580\u0565\u0576",id:"Bahasa Indonesia","id-ID":"Bahasa Indonesia",is:"\u00cdslenska","is-IS":"\u00cdslenska (Iceland)",it:"Italiano","it-IT":"Italiano",ja:"\u65e5\u672c\u8a9e","ja-JP":"\u65e5\u672c\u8a9e","jv-ID":"Basa Jawa","ka-GE":"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8","kk-KZ":"\u049a\u0430\u0437\u0430\u049b\u0448\u0430",km:"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a","km-KH":"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a",
kab:"Taqbaylit",kn:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1","kn-IN":"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1 (India)",ko:"\ud55c\uad6d\uc5b4","ko-KR":"\ud55c\uad6d\uc5b4 (\u97e9\u56fd)",ku:"Kurd\u00ee","ku-TR":"Kurd\u00ee",la:"Latin","la-VA":"Latin",lb:"L\u00ebtzebuergesch","li-NL":"L\u00e8mb\u00f6rgs",lt:"Lietuvi\u0173","lt-LT":"Lietuvi\u0173",lv:"Latvie\u0161u","lv-LV":"Latvie\u0161u",mai:"\u092e\u0948\u0925\u093f\u0932\u0940, \u09ae\u09c8\u09a5\u09bf\u09b2\u09c0","mg-MG":"Malagasy",mk:"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438",
"mk-MK":"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 (\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438)",ml:"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02","ml-IN":"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02","mn-MN":"\u041c\u043e\u043d\u0433\u043e\u043b",mr:"\u092e\u0930\u093e\u0920\u0940","mr-IN":"\u092e\u0930\u093e\u0920\u0940",ms:"Bahasa Melayu","ms-MY":"Bahasa Melayu",mt:"Malti","mt-MT":"Malti",my:"\u1017\u1019\u102c\u1005\u1000\u102c",nb:"Norsk (bokm\u00e5l)","nb-NO":"Norsk (bokm\u00e5l)",
ne:"\u0928\u0947\u092a\u093e\u0932\u0940","ne-NP":"\u0928\u0947\u092a\u093e\u0932\u0940",nl:"Nederlands","nl-BE":"Nederlands (Belgi\u00eb)","nl-NL":"Nederlands (Nederland)","nn-NO":"Norsk (nynorsk)",no:"Norsk",oc:"Occitan","or-IN":"\u0b13\u0b21\u0b3c\u0b3f\u0b06",pa:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40","pa-IN":"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40 (\u0a2d\u0a3e\u0a30\u0a24 \u0a28\u0a42\u0a70)",pl:"Polski","pl-PL":"Polski","ps-AF":"\u067e\u069a\u062a\u0648",pt:"Portugu\u00eas","pt-BR":"Portugu\u00eas (Brasil)",
"pt-PT":"Portugu\u00eas (Portugal)","qu-PE":"Qhichwa","rm-CH":"Rumantsch",ro:"Rom\u00e2n\u0103","ro-RO":"Rom\u00e2n\u0103",ru:"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","ru-RU":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","sa-IN":"\u0938\u0902\u0938\u094d\u0915\u0943\u0924\u092e\u094d","se-NO":"Davvis\u00e1megiella","si-LK":"\u0db4\u0dc5\u0dcf\u0dad",sk:"Sloven\u010dina","sk-SK":"Sloven\u010dina (Slovakia)",sl:"Sloven\u0161\u010dina","sl-SI":"Sloven\u0161\u010dina","so-SO":"Soomaaliga",sq:"Shqip",
"sq-AL":"Shqip",sr:"\u0421\u0440\u043f\u0441\u043a\u0438","sr-RS":"\u0421\u0440\u043f\u0441\u043a\u0438 (Serbia)",su:"Basa Sunda",sv:"Svenska","sv-SE":"Svenska",sw:"Kiswahili","sw-KE":"Kiswahili",ta:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd","ta-IN":"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd",te:"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41","te-IN":"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41",tg:"\u0437\u0430\u0431\u043e\u0301\u043d\u0438 \u0442\u043e\u04b7\u0438\u043a\u04e3\u0301","tg-TJ":"\u0442\u043e\u04b7\u0438\u043a\u04e3",th:"\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22",
"th-TH":"\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22 (\u0e1b\u0e23\u0e30\u0e40\u0e17\u0e28\u0e44\u0e17\u0e22)",tl:"Filipino","tl-PH":"Filipino",tlh:"tlhIngan-Hol",tr:"T\u00fcrk\u00e7e","tr-TR":"T\u00fcrk\u00e7e","tt-RU":"\u0442\u0430\u0442\u0430\u0440\u0447\u0430",uk:"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430","uk-UA":"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430",ur:"\u0627\u0631\u062f\u0648","ur-PK":"\u0627\u0631\u062f\u0648",uz:"O'zbek","uz-UZ":"O'zbek",vi:"Ti\u1ebfng Vi\u1ec7t",
"vi-VN":"Ti\u1ebfng Vi\u1ec7t","xh-ZA":"isiXhosa",yi:"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9","yi-DE":"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9 (German)",zh:"\u4e2d\u6587","zh-HANS":"\u4e2d\u6587\u7b80\u4f53","zh-HANT":"\u4e2d\u6587\u7e41\u9ad4","zh-CN":"\u4e2d\u6587\uff08\u4e2d\u56fd\uff09","zh-HK":"\u4e2d\u6587\uff08\u9999\u6e2f\uff09","zh-SG":"\u4e2d\u6587\uff08\u65b0\u52a0\u5761\uff09","zh-TW":"\u4e2d\u6587\uff08\u53f0\u7063\uff09","zu-ZA":"isiZulu"}},$jscomp$iter$325=(0,$jscomp.makeIterator)(Object.keys(mozilla.LanguageMapping)),
$jscomp$key$2089745539$0$key$jscomp$115=$jscomp$iter$325.next();!$jscomp$key$2089745539$0$key$jscomp$115.done;$jscomp$key$2089745539$0$key$jscomp$115=$jscomp$iter$325.next()){var key$jscomp$115=$jscomp$key$2089745539$0$key$jscomp$115.value;mozilla.LanguageMapping[key$jscomp$115.toLowerCase()]=mozilla.LanguageMapping[key$jscomp$115]};shaka.text.Utils=function(){};
shaka.text.Utils.flattenPayload_=function(a,b){if(a.lineBreak)return"\n";if(a.nestedCues.length)return a.nestedCues.map(function(g){return shaka.text.Utils.flattenPayload_(g,a)}).join("");if(!a.payload)return a.payload;var c=[],d=a.fontWeight>=shaka.text.Cue.fontWeight.BOLD,e=a.fontStyle==shaka.text.Cue.fontStyle.ITALIC,f=a.textDecoration.includes(shaka.text.Cue.textDecoration.UNDERLINE);d&&c.push(["b"]);e&&c.push(["i"]);f&&c.push(["u"]);e=a.color;e==""&&b&&(e=b.color);d="";(e=shaka.text.Utils.getColorName_(e))&&
(d+="."+e);e=a.backgroundColor;e==""&&b&&(e=b.backgroundColor);(b=shaka.text.Utils.getColorName_(e))&&(d+=".bg_"+b);d&&c.push(["c",d]);return c.reduceRight(function(g,h){var k=(0,$jscomp.makeIterator)(h);h=k.next().value;k=k.next().value;return"<"+h+(k===void 0?"":k)+">"+g+"</"+h+">"},a.payload)};
shaka.text.Utils.getColorName_=function(a){a=a.toLowerCase();var b=a.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);b?a="#"+(parseInt(b[1],10)|256).toString(16).slice(1)+(parseInt(b[2],10)|256).toString(16).slice(1)+(parseInt(b[3],10)|256).toString(16).slice(1):a.startsWith("#")&&a.length>7&&(a=a.slice(0,7));switch(a){case "white":case "#fff":case "#ffffff":return"white";case "lime":case "#0f0":case "#00ff00":return"lime";case "cyan":case "#0ff":case "#00ffff":return"cyan";case "red":case "#f00":case "#ff0000":return"red";
case "yellow":case "#ff0":case "#ffff00":return"yellow";case "magenta":case "#f0f":case "#ff00ff":return"magenta";case "blue":case "#00f":case "#0000ff":return"blue";case "black":case "#000":case "#000000":return"black"}return null};
shaka.text.Utils.getCuesToFlatten=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(shaka.text.Utils.removeDuplicates(a));for(var d=a.next();!d.done;d=a.next())if(d=d.value,d.isContainer)c.push.apply(c,(0,$jscomp.arrayFromIterable)(shaka.text.Utils.getCuesToFlatten(d.nestedCues,d)));else{var e=d.clone();e.nestedCues=[];e.payload=shaka.text.Utils.flattenPayload_(d,b);c.push(e)}return c};
shaka.text.Utils.removeDuplicates=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next(),d={};!c.done;d={cue$jscomp$19:void 0},c=a.next())d.cue$jscomp$19=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(e.cue$jscomp$19,f)}}(d))||b.push(d.cue$jscomp$19);return b};
shaka.text.Utils.mapShakaCueToNativeCue=function(a){if(a.startTime>=a.endTime)return shaka.log.warning("Invalid cue times: "+a.startTime+" - "+a.endTime),null;var b=shaka.text.Cue,c=new VTTCue(a.startTime,a.endTime,a.payload),d=function(e){for(var f=5381,g=e.length;g;)f=f*33^e.charCodeAt(--g);return(f>>>0).toString()};c.id=d(a.startTime.toString())+d(a.endTime.toString())+d(a.payload);c.lineAlign=a.lineAlign;c.positionAlign=a.positionAlign;a.size&&(c.size=a.size);try{c.align=a.textAlign}catch(e){}a.textAlign==
"center"&&c.align!="center"&&(c.align="middle");a.writingMode==b.writingMode.VERTICAL_LEFT_TO_RIGHT?c.vertical="lr":a.writingMode==b.writingMode.VERTICAL_RIGHT_TO_LEFT&&(c.vertical="rl");a.lineInterpretation==b.lineInterpretation.PERCENTAGE&&(c.snapToLines=!1);a.line!=null&&(c.line=a.line);a.position!=null&&(c.position=a.position);return c};
shaka.text.Utils.mapNativeCueToShakaCue=function(a){if(a.endTime===Infinity||a.endTime<a.startTime)return null;var b=new shaka.text.Cue(a.startTime,a.endTime,a.text);b.line=typeof a.line==="number"?a.line:null;a.lineAlign&&(b.lineAlign=a.lineAlign);b.lineInterpretation=a.snapToLines?shaka.text.Cue.lineInterpretation.LINE_NUMBER:shaka.text.Cue.lineInterpretation.PERCENTAGE;b.position=typeof a.position==="number"?a.position:null;a.positionAlign&&(b.positionAlign=a.positionAlign);b.size=a.size;b.textAlign=
a.align;a.vertical==="lr"?b.writingMode=shaka.text.Cue.writingMode.VERTICAL_LEFT_TO_RIGHT:a.vertical==="rl"&&(b.writingMode=shaka.text.Cue.writingMode.VERTICAL_RIGHT_TO_LEFT);a.region&&(b.region.id=a.region.id,b.region.height=a.region.lines,b.region.heightUnits=shaka.text.CueRegion.units.LINES,b.region.regionAnchorX=a.region.regionAnchorX,b.region.regionAnchorY=a.region.regionAnchorY,b.region.scroll=a.region.scroll,b.region.viewportAnchorX=a.region.viewportAnchorX,b.region.viewportAnchorY=a.region.viewportAnchorY,
b.region.viewportAnchorUnits=shaka.text.CueRegion.units.PERCENTAGE,b.region.width=a.region.width,b.region.widthUnits=shaka.text.CueRegion.units.PERCENTAGE);shaka.text.Cue.parseCuePayload(b);return b};
shaka.text.Utils.appendCuesToTextTrack=function(a,b){var c=shaka.text.Utils.getCuesToFlatten(b),d=[];b=a.cues?Array.from(a.cues):[];c=(0,$jscomp.makeIterator)(c);for(var e=c.next(),f={};!e.done;f={inCue:void 0},e=c.next())f.inCue=e.value,!b.some(function(g){return function(h){return h.startTime==g.inCue.startTime&&h.endTime==g.inCue.endTime&&h.text==g.inCue.payload?!0:!1}}(f))&&f.inCue.payload&&(e=shaka.text.Utils.mapShakaCueToNativeCue(f.inCue))&&d.push(e);b=d.slice().sort(function(g,h){return g.startTime!=
h.startTime?g.startTime-h.startTime:g.endTime!=h.endTime?g.endTime-h.startTime:"line"in VTTCue.prototype?d.indexOf(h)-d.indexOf(g):d.indexOf(g)-d.indexOf(h)});b=(0,$jscomp.makeIterator)(b);for(c=b.next();!c.done;c=b.next())a.addCue(c.value)};
shaka.text.Utils.removeCuesFromTextTrack=function(a,b){var c=!1;a.mode==="disabled"&&(c=!0,a.mode="hidden",goog.asserts.assert(a.cues,'Cues should be accessible when mode is set to "hidden".'));for(var d=0;d<a.cues.length;){var e=a.cues[d];b(e)?a.removeCue(e):d++}c&&(a.mode="disabled")};shaka.text.NativeTextDisplayer=function(a){var b=this;this.player_=a;this.eventManager_=new shaka.util.EventManager;this.video_=null;this.trackNodes_=new Map;this.trackId_=-1;this.visible_=!1;this.timer_=null;this.onUnloading_=function(){b.eventManager_.unlisten(b.player_,shaka.util.FakeEvent.EventName.TextChanged,b.onTextChanged_);b.eventManager_.unlisten(b.video_.textTracks,"change",b.onChange_);for(var c=(0,$jscomp.makeIterator)(b.trackNodes_.values()),d=c.next();!d.done;d=c.next())d.value.remove();
b.trackNodes_.clear();b.trackId_=-1;b.video_=null};this.onTextChanged_=function(){var c=new Map,d=b.player_.getTextTracks();d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next()){e=e.value;if(b.trackNodes_.has(e.id)){var f=b.trackNodes_.get(e.id);e.active||f.track.mode==="disabled"||(f.track.mode="disabled");b.trackNodes_.delete(e.id)}else f=b.video_.ownerDocument.createElement("track"),f.kind=shaka.text.NativeTextDisplayer.getTrackKind_(e),f.label=shaka.text.NativeTextDisplayer.getTrackLabel_(e),
e.language in mozilla.LanguageMapping&&(f.srclang=e.language),f.src="data:,WEBVTT",f.track.mode="disabled",b.video_.appendChild(f);c.set(e.id,f);e.active&&(b.trackId_=e.id)}d=(0,$jscomp.makeIterator)(b.trackNodes_.values());for(e=d.next();!e.done;e=d.next())e.value.remove();b.trackId_>-1&&(c.has(b.trackId_)?(d=c.get(b.trackId_).track,d.mode==="disabled"&&(d.mode=b.visible_?"showing":"hidden")):b.trackId_=-1);b.trackNodes_=c};this.onChange_=function(){if(!b.timer_){var c=b.video_;b.timer_=(new shaka.util.Timer(function(){b.timer_=
null;if(b.video_===c){var d=-1,e=!1;if(b.trackNodes_.has(b.trackId_)){var f=b.trackNodes_.get(b.trackId_);f.track.mode==="showing"?(d=b.trackId_,e=!0):f.track.mode==="hidden"&&(d=b.trackId_)}if(!e)for(e=(0,$jscomp.makeIterator)(b.trackNodes_),f=e.next();!f.done;f=e.next()){var g=(0,$jscomp.makeIterator)(f.value);f=g.next().value;g=g.next().value;if(g.track.mode==="showing"){d=f;break}else d<0&&g.track.mode==="hidden"&&(d=f)}e=(0,$jscomp.makeIterator)(b.trackNodes_);for(f=e.next();!f.done;f=e.next())g=
(0,$jscomp.makeIterator)(f.value),f=g.next().value,g=g.next().value,f!==d&&g.track.mode!=="disabled"&&(g.track.mode="disabled");b.trackId_!==d&&(b.trackId_=d,d>-1&&b.player_.selectTextTrack({id:d}));b.player_.setTextTrackVisibility(d>-1&&b.trackNodes_.get(d).track.mode==="showing")}})).tickAfter(0)}};this.eventManager_.listen(a,shaka.util.FakeEvent.EventName.Loaded,function(){return b.enableTextDisplayer()});this.enableTextDisplayer()};shaka.text.NativeTextDisplayer.prototype.configure=function(a){};
shaka.text.NativeTextDisplayer.prototype.remove=function(a,b){if(this.player_)this.trackNodes_.has(this.trackId_)&&shaka.text.Utils.removeCuesFromTextTrack(this.trackNodes_.get(this.trackId_).track,function(c){return c.startTime<b&&c.endTime>a});else return!1;return!0};shaka.text.NativeTextDisplayer.prototype.append=function(a){this.trackNodes_.has(this.trackId_)&&shaka.text.Utils.appendCuesToTextTrack(this.trackNodes_.get(this.trackId_).track,a)};
shaka.text.NativeTextDisplayer.prototype.destroy=function(){if(this.player_){if(this.video_)this.onUnloading_();this.player_=null}this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);return Promise.resolve()};shaka.text.NativeTextDisplayer.prototype.isTextVisible=function(){return this.visible_};
shaka.text.NativeTextDisplayer.prototype.setTextVisibility=function(a){this.visible_=a;if(this.trackNodes_.has(this.trackId_)){var b=this.trackNodes_.get(this.trackId_).track;b.mode!=="disabled"&&(a=a?"showing":"hidden",b.mode!==a&&(b.mode=a))}else if(this.player_&&this.player_.getLoadMode()===3)if(b=Array.from(this.player_.getMediaElement().textTracks).filter(function(d){return["captions","subtitles","forced"].includes(d.kind)}),a){a=null;b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=
b.next())if(c=c.value,c.mode==="showing"){a=null;break}else a||c.mode!=="hidden"||(a=c);a&&(a.mode="showing")}else for(a=(0,$jscomp.makeIterator)(b),b=a.next();!b.done;b=a.next())b=b.value,b.mode==="showing"&&(b.mode="hidden")};shaka.text.NativeTextDisplayer.prototype.setTextLanguage=function(a){};
shaka.text.NativeTextDisplayer.prototype.enableTextDisplayer=function(){!this.video_&&this.player_&&this.player_.getLoadMode()===2&&(this.video_=this.player_.getMediaElement(),this.eventManager_.listenOnce(this.player_,shaka.util.FakeEvent.EventName.Unloading,this.onUnloading_),this.eventManager_.listen(this.player_,shaka.util.FakeEvent.EventName.TextChanged,this.onTextChanged_),this.eventManager_.listen(this.video_.textTracks,"change",this.onChange_),this.onTextChanged_())};
shaka.text.NativeTextDisplayer.getTrackKind_=function(a){var b=shaka.device.DeviceFactory.getDevice();return a.forced&&b.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT?"forced":a.kind==="caption"||a.roles&&a.roles.some(function(c){return c.includes("transcribes-spoken-dialog")})&&a.roles.some(function(c){return c.includes("describes-music-and-sound")})?"captions":"subtitles"};
shaka.text.NativeTextDisplayer.getTrackLabel_=function(a){if(a.label)var b=a.label;else if(a.language)if(a.language in mozilla.LanguageMapping)b=mozilla.LanguageMapping[a.language];else{var c=shaka.util.LanguageUtils.getBase(a.language);c in mozilla.LanguageMapping&&(b=mozilla.LanguageMapping[c]+" ("+a.language+")")}b||(b=a.originalTextId,a.language&&a.language!==a.originalTextId&&(b+=" ("+a.language+")"));return b};goog.exportSymbol("shaka.text.NativeTextDisplayer",shaka.text.NativeTextDisplayer);
goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"enableTextDisplayer",shaka.text.NativeTextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"setTextLanguage",shaka.text.NativeTextDisplayer.prototype.setTextLanguage);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"setTextVisibility",shaka.text.NativeTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"isTextVisible",shaka.text.NativeTextDisplayer.prototype.isTextVisible);
goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"destroy",shaka.text.NativeTextDisplayer.prototype.destroy);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"append",shaka.text.NativeTextDisplayer.prototype.append);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"remove",shaka.text.NativeTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"configure",shaka.text.NativeTextDisplayer.prototype.configure);shaka.text.SimpleTextDisplayer=function(a,b){shaka.Deprecate.deprecateFeature(5,"SimpleTextDisplayer","Please migrate to NativeTextDisplayer");this.video_=a;this.textTrackLabel_=b;this.textTrack_=null;a=(0,$jscomp.makeIterator)(Array.from(this.video_.textTracks));for(b=a.next();!b.done;b=a.next())b=b.value,b.kind!=="metadata"&&b.kind!=="chapters"&&(b.mode="disabled",b.label==this.textTrackLabel_&&(this.textTrack_=b));this.textTrack_&&(this.textTrack_.mode="hidden")};
shaka.text.SimpleTextDisplayer.prototype.configure=function(a){};shaka.text.SimpleTextDisplayer.prototype.remove=function(a,b){if(!this.textTrack_)return!1;shaka.text.Utils.removeCuesFromTextTrack(this.textTrack_,function(c){return c.startTime<b&&c.endTime>a});return!0};shaka.text.SimpleTextDisplayer.prototype.append=function(a){this.textTrack_&&shaka.text.Utils.appendCuesToTextTrack(this.textTrack_,a)};
shaka.text.SimpleTextDisplayer.prototype.destroy=function(){this.textTrack_&&(shaka.text.Utils.removeCuesFromTextTrack(this.textTrack_,function(a){return!0}),this.textTrack_.mode="disabled");this.textTrack_=this.video_=null;return Promise.resolve()};shaka.text.SimpleTextDisplayer.prototype.isTextVisible=function(){return this.textTrack_?this.textTrack_.mode=="showing":!1};
shaka.text.SimpleTextDisplayer.prototype.setTextVisibility=function(a){a&&!this.textTrack_&&this.createTextTrack_();this.textTrack_&&(this.textTrack_.mode=a?"showing":"hidden")};shaka.text.SimpleTextDisplayer.prototype.setTextLanguage=function(a){};shaka.text.SimpleTextDisplayer.prototype.enableTextDisplayer=function(){this.createTextTrack_()};
shaka.text.SimpleTextDisplayer.prototype.createTextTrack_=function(){this.video_&&!this.textTrack_&&(this.textTrack_=this.video_.addTextTrack("subtitles",this.textTrackLabel_),this.textTrack_.mode="hidden")};goog.exportSymbol("shaka.text.SimpleTextDisplayer",shaka.text.SimpleTextDisplayer);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"enableTextDisplayer",shaka.text.SimpleTextDisplayer.prototype.enableTextDisplayer);
goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"setTextLanguage",shaka.text.SimpleTextDisplayer.prototype.setTextLanguage);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"setTextVisibility",shaka.text.SimpleTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"isTextVisible",shaka.text.SimpleTextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"destroy",shaka.text.SimpleTextDisplayer.prototype.destroy);
goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"append",shaka.text.SimpleTextDisplayer.prototype.append);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"remove",shaka.text.SimpleTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"configure",shaka.text.SimpleTextDisplayer.prototype.configure);shaka.text.StubTextDisplayer=function(){};shaka.text.StubTextDisplayer.prototype.configure=function(a){};shaka.text.StubTextDisplayer.prototype.remove=function(a,b){};shaka.text.StubTextDisplayer.prototype.append=function(a){};shaka.text.StubTextDisplayer.prototype.destroy=function(){};shaka.text.StubTextDisplayer.prototype.isTextVisible=function(){return!1};shaka.text.StubTextDisplayer.prototype.setTextVisibility=function(a){};shaka.text.StubTextDisplayer.prototype.setTextLanguage=function(a){};
shaka.text.StubTextDisplayer.prototype.enableTextDisplayer=function(){};goog.exportSymbol("shaka.text.StubTextDisplayer",shaka.text.StubTextDisplayer);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"enableTextDisplayer",shaka.text.StubTextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"setTextLanguage",shaka.text.StubTextDisplayer.prototype.setTextLanguage);
goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"setTextVisibility",shaka.text.StubTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"isTextVisible",shaka.text.StubTextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"destroy",shaka.text.StubTextDisplayer.prototype.destroy);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"append",shaka.text.StubTextDisplayer.prototype.append);
goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"remove",shaka.text.StubTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"configure",shaka.text.StubTextDisplayer.prototype.configure);shaka.text.UITextDisplayer=function(a,b){var c=this;goog.asserts.assert(b,"videoContainer should be valid.");this.isTextVisible_=!1;this.cues_=[];this.video_=a;this.videoContainer_=b;this.config_=this.aspectRatio_=null;this.textContainer_=shaka.util.Dom.createHTMLElement("div");this.textContainer_.classList.add("shaka-text-container");this.textContainer_.style.textAlign="center";this.textContainer_.style.display="flex";this.textContainer_.style.flexDirection="column";this.textContainer_.style.alignItems=
"center";this.textContainer_.style.justifyContent="flex-end";this.captionsTimer_=new shaka.util.Timer(function(){c.video_.paused||c.updateCaptions_()});this.configureCaptionsTimer_();this.currentCuesMap_=new Map;this.eventManager_=new shaka.util.EventManager;this.eventManager_.listen(document,"fullscreenchange",function(){c.updateCaptions_(!0)});this.eventManager_.listen(this.video_,"seeking",function(){c.updateCaptions_(!0)});this.eventManager_.listen(this.video_,"ratechange",function(){c.configureCaptionsTimer_()});
this.eventManager_.listen(this.video_,"resize",function(){var d=c.video_,e=d.videoWidth;d=d.videoHeight;c.aspectRatio_=e&&d?e/d:null});this.resizeObserver_=null;"ResizeObserver"in window&&(this.resizeObserver_=new ResizeObserver(function(){c.updateCaptions_(!0)}),this.resizeObserver_.observe(this.textContainer_));this.regionElements_=new Map};shaka.text.UITextDisplayer.prototype.configure=function(a){this.config_=a;this.configureCaptionsTimer_();this.updateCaptions_(!0)};
shaka.text.UITextDisplayer.prototype.append=function(a){var b=[].concat((0,$jscomp.arrayFromIterable)(this.cues_));a=(0,$jscomp.makeIterator)(shaka.text.Utils.removeDuplicates(a));for(var c=a.next(),d={};!c.done;d={cue$jscomp$27:void 0},c=a.next())d.cue$jscomp$27=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(f,e.cue$jscomp$27)}}(d))||this.cues_.push(d.cue$jscomp$27);this.cues_.length&&this.configureCaptionsTimer_();this.updateCaptions_()};
shaka.text.UITextDisplayer.prototype.destroy=function(){if(!this.textContainer_)return Promise.resolve();this.textContainer_.parentElement&&this.videoContainer_.removeChild(this.textContainer_);this.textContainer_=null;this.isTextVisible_=!1;this.cues_=[];this.captionsTimer_&&(this.captionsTimer_.stop(),this.captionsTimer_=null);this.currentCuesMap_.clear();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=
null);return Promise.resolve()};shaka.text.UITextDisplayer.prototype.remove=function(a,b){if(!this.textContainer_)return!1;var c=this.cues_.length;this.cues_=this.cues_.filter(function(d){return d.startTime<a||d.endTime>=b});this.updateCaptions_(c>this.cues_.length);this.cues_.length||this.configureCaptionsTimer_();return!0};shaka.text.UITextDisplayer.prototype.isTextVisible=function(){return this.isTextVisible_};
shaka.text.UITextDisplayer.prototype.setTextVisibility=function(a){(this.isTextVisible_=a)?(this.textContainer_.parentElement||this.videoContainer_.appendChild(this.textContainer_),this.updateCaptions_(!0)):this.textContainer_.parentElement&&this.videoContainer_.removeChild(this.textContainer_)};shaka.text.UITextDisplayer.prototype.setTextLanguage=function(a){a&&a!="und"?this.textContainer_.setAttribute("lang",a):this.textContainer_.setAttribute("lang","")};
shaka.text.UITextDisplayer.prototype.enableTextDisplayer=function(){};shaka.text.UITextDisplayer.prototype.configureCaptionsTimer_=function(){this.captionsTimer_&&(this.cues_.length?this.captionsTimer_.tickEvery((this.config_?this.config_.captionsUpdatePeriod:.25)/Math.max(1,Math.abs(this.video_.playbackRate))):this.captionsTimer_.stop())};shaka.text.UITextDisplayer.prototype.isElementUnderTextContainer_=function(a){for(;a!=null;){if(a==this.textContainer_)return!0;a=a.parentElement}return!1};
shaka.text.UITextDisplayer.prototype.updateCuesRecursive_=function(a,b,c,d){var e=!1,f=[],g=[];a=(0,$jscomp.makeIterator)(a);for(var h=a.next();!h.done;h=a.next()){h=h.value;d.push(h);var k=this.currentCuesMap_.get(h),l=h.startTime<=c&&h.endTime>c,m=k?k.wrapper:null;k&&(f.push(k.cueElement),k.regionElement&&f.push(k.regionElement),l||(e=!0,this.currentCuesMap_.delete(h),k=null));l&&(g.push(h),k?this.isElementUnderTextContainer_(m)||(e=!0):(this.createCue_(h,d),k=this.currentCuesMap_.get(h),m=k.wrapper,
e=!0));h.nestedCues.length>0&&m&&this.updateCuesRecursive_(h.nestedCues,m,c,d);k=d.pop();goog.asserts.assert(k==h,"Parent cues should be kept in order")}if(e){c=(0,$jscomp.makeIterator)(f);for(d=c.next();!d.done;d=c.next())d=d.value,d.parentElement&&d.parentElement.removeChild(d);g.sort(function(n,p){return n.startTime!=p.startTime?n.startTime-p.startTime:n.endTime-p.endTime});g=(0,$jscomp.makeIterator)(g);for(c=g.next();!c.done;c=g.next())c=this.currentCuesMap_.get(c.value),goog.asserts.assert(c,
"cueRegistry should exist."),c.regionElement?(c.regionElement.contains(b)&&c.regionElement.removeChild(b),b.appendChild(c.regionElement),c.regionElement.appendChild(c.cueElement)):b.appendChild(c.cueElement)}};
shaka.text.UITextDisplayer.prototype.updateCaptions_=function(a){if(this.textContainer_){var b=this.video_.currentTime;if(!this.isTextVisible_||(a===void 0?0:a)){a=(0,$jscomp.makeIterator)(this.regionElements_.values());for(var c=a.next();!c.done;c=a.next())shaka.util.Dom.removeAllChildren(c.value);shaka.util.Dom.removeAllChildren(this.textContainer_);this.currentCuesMap_.clear();this.regionElements_.clear()}if(this.isTextVisible_){a=new Map;if(goog.DEBUG){c=(0,$jscomp.makeIterator)(this.currentCuesMap_.keys());
for(var d=c.next();!d.done;d=c.next())d=d.value,a.set(d,this.currentCuesMap_.get(d))}this.updateCuesRecursive_(this.cues_,this.textContainer_,b,[]);if(goog.DEBUG)for(b=(0,$jscomp.makeIterator)(a.keys()),c=b.next();!c.done;c=b.next())c=c.value,this.currentCuesMap_.has(c)||(c=a.get(c).cueElement,goog.asserts.assert(!c.parentNode,"Cue was not properly removed!"))}}};
shaka.text.UITextDisplayer.prototype.generateRegionId_=function(a){var b=shaka.text.CueRegion.units.PERCENTAGE;return a.id+"_"+a.width+"x"+a.height+(a.heightUnits==b?"%":"px")+"-"+a.viewportAnchorX+"x"+a.viewportAnchorY+(a.viewportAnchorUnits==b?"%":"px")};
shaka.text.UITextDisplayer.prototype.getRegionElement_=function(a){var b=a.region,c=this.aspectRatio_===4/3?2.5:1.9,d=this.generateRegionId_(b);if(this.regionElements_.has(d))return this.regionElements_.get(d);var e=shaka.util.Dom.createHTMLElement("span"),f=shaka.text.CueRegion.units.LINES,g=shaka.text.CueRegion.units.PERCENTAGE,h=shaka.text.CueRegion.units.PX,k=b.heightUnits==g?"%":"px",l=b.widthUnits==g?"%":"px",m=b.viewportAnchorUnits==g?"%":"px";e.id="shaka-text-region---"+d;e.classList.add("shaka-text-region");
e.style.position="absolute";g=b.height;var n=b.width;b.heightUnits===f&&(g=b.height*5.33,k="%");b.widthUnits===f&&(n=b.width*c,l="%");e.style.height=g+k;e.style.width=n+l;b.viewportAnchorUnits===f?(c=b.viewportAnchorY/75*100,f=b.viewportAnchorX/(this.aspectRatio_===4/3?160:210)*100,c-=b.regionAnchorY*g/100,f-=b.regionAnchorX*n/100,e.style.top=c+"%",e.style.left=f+"%"):(e.style.top=b.viewportAnchorY-b.regionAnchorY*g/100+m,e.style.left=b.viewportAnchorX-b.regionAnchorX*n/100+m);b.heightUnits!==h&&
b.widthUnits!==h&&b.viewportAnchorUnits!==h&&(b=parseInt(e.style.top.slice(0,-1),10)||0,g=parseInt(e.style.left.slice(0,-1),10)||0,h=parseInt(e.style.height.slice(0,-1),10)||0,n=parseInt(e.style.width.slice(0,-1),10)||0,g=Math.max(0,Math.min(100-n,g)),e.style.top=Math.max(0,Math.min(100-h,b))+"%",e.style.left=g+"%");e.style.display="flex";e.style.flexDirection="column";e.style.alignItems="center";e.style.justifyContent=a.displayAlign==shaka.text.Cue.displayAlign.BEFORE?"flex-start":a.displayAlign==
shaka.text.Cue.displayAlign.CENTER?"center":"flex-end";this.regionElements_.set(d,e);return e};
shaka.text.UITextDisplayer.prototype.createCue_=function(a,b){var c=b.length>1,d=c?"span":"div";a.lineBreak&&(d="br");a.rubyTag&&(d=a.rubyTag);c=!c&&a.nestedCues.length>0;var e=shaka.util.Dom.createHTMLElement(d);d!="br"&&this.setCaptionStyles_(e,a,b,c);b=null;a.region&&a.region.id&&(b=this.getRegionElement_(a));d=e;c&&(d=shaka.util.Dom.createHTMLElement("span"),d.classList.add("shaka-text-wrapper"),d.style.backgroundColor=a.backgroundColor,d.style.lineHeight="normal",e.appendChild(d));this.currentCuesMap_.set(a,
{cueElement:e,wrapper:d,regionElement:b})};
shaka.text.UITextDisplayer.prototype.computeCuePositionAlignment_=function(a){var b=shaka.text.Cue,c=a.direction,d=a.positionAlign;a=a.textAlign;return d!==b.positionAlign.AUTO?d:a===b.textAlign.LEFT||a===b.textAlign.START&&c===b.direction.HORIZONTAL_LEFT_TO_RIGHT||a===b.textAlign.END&&c===b.direction.HORIZONTAL_RIGHT_TO_LEFT?b.positionAlign.LEFT:a===b.textAlign.RIGHT||a===b.textAlign.START&&c===b.direction.HORIZONTAL_RIGHT_TO_LEFT||a===b.textAlign.END&&c===b.direction.HORIZONTAL_LEFT_TO_RIGHT?b.positionAlign.RIGHT:
b.positionAlign.CENTER};
shaka.text.UITextDisplayer.prototype.setCaptionStyles_=function(a,b,c,d){var e=shaka.text.Cue,f=a.style,g=b.nestedCues.length==0,h=c.length>1;f.whiteSpace="pre-wrap";var k=b.payload.replace(/\s+$/g,function(m){return"\u00a0".repeat(m.length)});f.webkitTextStrokeColor=b.textStrokeColor;f.webkitTextStrokeWidth=b.textStrokeWidth;f.color=b.color;f.direction=b.direction;f.opacity=b.opacity;f.paddingLeft=shaka.text.UITextDisplayer.convertLengthValue_(b.linePadding,b,this.videoContainer_);f.paddingRight=
shaka.text.UITextDisplayer.convertLengthValue_(b.linePadding,b,this.videoContainer_);f.textCombineUpright=b.textCombineUpright;f.textShadow=b.textShadow;if(b.backgroundImage)f.backgroundImage="url('"+b.backgroundImage+"')",f.backgroundRepeat="no-repeat",f.backgroundSize="contain",f.backgroundPosition="center",b.backgroundColor&&(f.backgroundColor=b.backgroundColor),f.width="100%",f.height="100%";else{if(b.nestedCues.length)var l=a;else l=shaka.util.Dom.createHTMLElement("span"),a.appendChild(l);b.border&&
(l.style.border=b.border);d||((a=shaka.text.UITextDisplayer.inheritProperty_(c,function(m){return m.backgroundColor}))?l.style.backgroundColor=a:k&&(l.style.backgroundColor="rgba(0, 0, 0, 0.8)"));k&&(l.setAttribute("translate","no"),l.textContent=k)}if(h&&!c[c.length-1].isContainer)f.display="inline";else{f.display="flex";f.flexDirection="column";f.alignItems="center";if(b.textAlign==e.textAlign.LEFT||b.textAlign==e.textAlign.START)f.width="100%",f.alignItems="start";else if(b.textAlign==e.textAlign.RIGHT||
b.textAlign==e.textAlign.END)f.width="100%",f.alignItems="end";f.justifyContent=b.displayAlign==e.displayAlign.BEFORE?"flex-start":b.displayAlign==e.displayAlign.CENTER?"center":"flex-end"}g||(f.margin="0");f.fontFamily=b.fontFamily;f.fontWeight=b.fontWeight.toString();f.fontStyle=b.fontStyle;f.letterSpacing=b.letterSpacing;c=this.config_?this.config_.fontScaleFactor:1;if(c!==1||b.fontSize)f.fontSize=shaka.text.UITextDisplayer.convertLengthValue_(b.fontSize||"1em",b,this.videoContainer_,c);c=b.line;
c!=null&&(g=b.lineInterpretation,g==e.lineInterpretation.LINE_NUMBER&&(g=e.lineInterpretation.PERCENTAGE,h=16,this.aspectRatio_&&this.aspectRatio_<1&&(h=32),c=c<0?100+c/h*100:c/h*100),g==e.lineInterpretation.PERCENTAGE&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.width="100%",b.lineAlign==e.lineAlign.START?f.top=c+"%":b.lineAlign==e.lineAlign.END&&(f.bottom=100-c+"%")):b.writingMode==e.writingMode.VERTICAL_LEFT_TO_RIGHT?(f.height="100%",b.lineAlign==e.lineAlign.START?
f.left=c+"%":b.lineAlign==e.lineAlign.END&&(f.right=100-c+"%")):(f.height="100%",b.lineAlign==e.lineAlign.START?f.right=c+"%":b.lineAlign==e.lineAlign.END&&(f.left=100-c+"%"))));f.lineHeight=b.lineHeight;c=this.computeCuePositionAlignment_(b);c==e.positionAlign.LEFT?(f.cssFloat="left",b.position!==null&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.left=b.position+"%",f.width="auto"):f.top=b.position+"%")):c==e.positionAlign.RIGHT?(f.cssFloat="right",b.position!==
null&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.right=100-b.position+"%",f.width="auto"):f.bottom=b.position+"%")):b.position!==null&&b.position!=50&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.left=b.position+"%",f.width="auto"):f.top=b.position+"%",b.size&&(f.transform="translateX(-50%)"));f.textAlign=b.textAlign;f.textDecoration=b.textDecoration.join(" ");f.writingMode=b.writingMode;"writingMode"in document.documentElement.style&&
f.writingMode==b.writingMode||(f.webkitWritingMode=b.writingMode);b.size&&(b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?f.width=b.size+"%":f.height=b.size+"%")};shaka.text.UITextDisplayer.getLengthValueInfo_=function(a){return(a=(new RegExp(/(\d*\.?\d+)([a-z]+|%+)/)).exec(a))?{value:Number(a[1]),unit:a[2]}:null};
shaka.text.UITextDisplayer.convertLengthValue_=function(a,b,c,d){d=d===void 0?1:d;var e=shaka.text.UITextDisplayer.getLengthValueInfo_(a);if(!e)return a;a=e.unit;d*=e.value;switch(a){case "%":return shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_(d/100,b,c);case "c":return shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_(d,b,c);default:return d+a}};shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_=function(a,b,c){return c.clientHeight*a/b.cellResolution.rows+"px"};
shaka.text.UITextDisplayer.inheritProperty_=function(a,b){for(var c=a.length-1;c>=0;c--){var d=b(a[c]);if(d||d===0)return d}return null};goog.exportSymbol("shaka.text.UITextDisplayer",shaka.text.UITextDisplayer);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"enableTextDisplayer",shaka.text.UITextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"setTextLanguage",shaka.text.UITextDisplayer.prototype.setTextLanguage);
goog.exportProperty(shaka.text.UITextDisplayer.prototype,"setTextVisibility",shaka.text.UITextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"isTextVisible",shaka.text.UITextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"remove",shaka.text.UITextDisplayer.prototype.remove);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"destroy",shaka.text.UITextDisplayer.prototype.destroy);
goog.exportProperty(shaka.text.UITextDisplayer.prototype,"append",shaka.text.UITextDisplayer.prototype.append);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"configure",shaka.text.UITextDisplayer.prototype.configure);shaka.text.WebVttGenerator=function(){};
shaka.text.WebVttGenerator.convert=function(a,b){var c=function(f){for(var g=f,h=(0,$jscomp.makeIterator)(b),k=h.next();!k.done;k=h.next())k=k.value,k.end&&k.start<f&&(g+=k.end-k.start);f=Math.floor(g/3600);h=Math.floor(g/60%60);k=Math.floor(g%60);g=Math.floor(g*1E3%1E3);return(f<10?"0":"")+f+":"+(h<10?"0":"")+h+":"+(k<10?"0":"")+k+"."+(g<100?g<10?"00":"0":"")+g},d=shaka.text.Utils.getCuesToFlatten(a);a="WEBVTT\n\n";d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,a+=
c(e.startTime)+" --\x3e "+c(e.endTime)+function(f){var g=[],h=shaka.text.Cue;switch(f.textAlign){case h.textAlign.LEFT:g.push("align:left");break;case h.textAlign.RIGHT:g.push("align:right");break;case h.textAlign.CENTER:g.push("align:middle");break;case h.textAlign.START:g.push("align:start");break;case h.textAlign.END:g.push("align:end")}switch(f.writingMode){case h.writingMode.VERTICAL_LEFT_TO_RIGHT:g.push("vertical:lr");break;case h.writingMode.VERTICAL_RIGHT_TO_LEFT:g.push("vertical:rl")}return g.length?
" "+g.join(" "):""}(e)+"\n",a+=e.payload+"\n\n";return a};goog.exportSymbol("shaka.text.WebVttGenerator",shaka.text.WebVttGenerator);shaka.util.CmcdManager=function(a,b){this.config_=b;this.player_=a;this.requestTimestampMap_=new Map;this.sf_=void 0;this.playbackStarted_=!1;this.buffering_=!0;this.lowLatency_=this.starved_=!1;this.playbackPlayingTime_=this.playbackPlayTime_=void 0;this.startTimeOfLoad_=0;this.msdSent_={request:!1,response:!1,event:!1};this.cmcdSequenceNumbers_={};this.eventManager_=new shaka.util.EventManager;this.eventTimers_=[];this.video_=null};
shaka.util.CmcdManager.prototype.setMediaElement=function(a){this.video_=a;this.setupEventListeners_()};shaka.util.CmcdManager.prototype.configure=function(a){this.config_=a;this.setupEventModeTimeInterval_()};
shaka.util.CmcdManager.prototype.reset=function(){this.requestTimestampMap_.clear();this.playbackStarted_=!1;this.buffering_=!0;this.lowLatency_=this.starved_=!1;this.startTimeOfLoad_=this.playbackPlayingTime_=this.playbackPlayTime_=0;this.msdSent_={request:!1,response:!1,event:!1};this.stopAndClearEventTimers_();this.cmcdSequenceNumbers_={};this.video_=null;this.eventManager_.removeAll()};
shaka.util.CmcdManager.prototype.setBuffering=function(a){a||this.playbackStarted_||(this.playbackStarted_=!0);this.playbackStarted_&&a&&(this.starved_=!0,this.reportEvent_("ps",{sta:"r"}));this.buffering_=a};
shaka.util.CmcdManager.prototype.setLowLatency=function(a){this.lowLatency_=a;a=shaka.util.CmcdManager.StreamingFormat;this.lowLatency_?this.sf_==a.DASH?this.sf_=a.LOW_LATENCY_DASH:this.sf_==a.HLS&&(this.sf_=a.LOW_LATENCY_HLS):this.sf_==a.LOW_LATENCY_DASH?this.sf_=a.DASH:this.sf_==a.LOW_LATENCY_HLS&&(this.sf_=a.HLS)};
shaka.util.CmcdManager.prototype.setStartTimeOfLoad=function(a){var b=this;if(this.config_&&this.config_.enabled&&(this.reportEvent_("ps",{sta:"d"}),this.video_&&this.video_.autoplay)){var c=this.video_.play();c&&c.then(function(){b.startTimeOfLoad_=a}).catch(function(d){b.startTimeOfLoad_=0})}};
shaka.util.CmcdManager.prototype.applyRequestData=function(a,b,c){c=c===void 0?{}:c;if(this.config_.enabled)if(b.method==="HEAD")this.applyRequest_(b,{});else{var d=shaka.net.NetworkingEngine.RequestType,e=shaka.util.CmcdManager.ObjectType;switch(a){case d.MANIFEST:this.applyManifestData(b,c);break;case d.SEGMENT:this.applyRequestSegmentData(b,c);break;case d.LICENSE:case d.SERVER_CERTIFICATE:case d.KEY:this.applyRequest_(b,{ot:e.KEY});break;case d.TIMING:this.applyRequest_(b,{ot:e.OTHER})}}};
shaka.util.CmcdManager.prototype.applyResponseData=function(a,b,c){c=c===void 0?{}:c;if(this.getResponseModeEnabledTargets().length!==0){var d=shaka.net.NetworkingEngine.RequestType;switch(a){case d.SEGMENT:this.applyResponseSegmentData(b,c)}}};
shaka.util.CmcdManager.prototype.applyManifestData=function(a,b){try{this.config_.enabled&&(b.type&&(this.sf_=this.getStreamFormat_(b.type)),this.applyRequest_(a,{ot:shaka.util.CmcdManager.ObjectType.MANIFEST,su:!this.playbackStarted_}))}catch(c){shaka.log.warnOnce("CMCD_MANIFEST_ERROR","Could not generate manifest CMCD data.",c)}};
shaka.util.CmcdManager.prototype.applyResponseSegmentData=function(a,b){try{var c=this.getDataForSegment_(b,a.uri);a.originalRequest&&a.originalRequest.timeToFirstByte!=null&&(c.ttfb=a.originalRequest.timeToFirstByte);a.timeMs!=null&&(c.ttlb=a.timeMs);c.url=this.removeCmcdQueryFromUri_(a.originalUri||a.uri);this.requestTimestampMap_.has(a.originalRequest)?(c.ts=this.requestTimestampMap_.get(a.originalRequest),this.requestTimestampMap_.delete(a.originalRequest)):c.ts||(c.ts=Date.now());this.applyResponse_(a,
c)}catch(d){shaka.log.warnOnce("CMCD_SEGMENT_ERROR","Could not generate response segment CMCD data.",d)}};shaka.util.CmcdManager.prototype.applyRequestSegmentData=function(a,b){try{if(this.config_.enabled){var c=this.getDataForSegment_(b,a.uris[0]);c.ts=Date.now();this.requestTimestampMap_.set(a,c.ts);this.applyRequest_(a,c)}}catch(d){shaka.log.warnOnce("CMCD_SEGMENT_ERROR","Could not generate segment CMCD data.",d)}};
shaka.util.CmcdManager.prototype.applyTextData=function(a){try{this.config_.enabled&&this.applyRequest_(a,{ot:shaka.util.CmcdManager.ObjectType.CAPTION,su:!0})}catch(b){shaka.log.warnOnce("CMCD_TEXT_ERROR","Could not generate text CMCD data.",b)}};shaka.util.CmcdManager.prototype.removeCmcdQueryFromUri_=function(a){if(!a.includes("CMCD="))return a;try{var b=new URL(a);b.searchParams.delete("CMCD");return b.toString()}catch(c){return shaka.log.error("Failed to parse URI for CMCD removal:",a,c),a}};
shaka.util.CmcdManager.prototype.appendSrcData=function(a,b){try{if(!this.config_.enabled)return a;var c=this.createData_();c.ot=this.getObjectTypeFromMimeType_(b);c.su=!0;var d=shaka.util.CmcdManager.toQuery(c);return shaka.util.CmcdManager.appendQueryToUri(a,d)}catch(e){return shaka.log.warnOnce("CMCD_SRC_ERROR","Could not generate src CMCD data.",e),a}};
shaka.util.CmcdManager.prototype.appendTextTrackData=function(a){try{if(!this.config_.enabled)return a;var b=this.createData_();b.ot=shaka.util.CmcdManager.ObjectType.CAPTION;b.su=!0;var c=shaka.util.CmcdManager.toQuery(b);return shaka.util.CmcdManager.appendQueryToUri(a,c)}catch(d){return shaka.log.warnOnce("CMCD_TEXT_TRACK_ERROR","Could not generate text track CMCD data.",d),a}};
shaka.util.CmcdManager.prototype.onPlaybackPlay_=function(){this.playbackPlayTime_||(this.playbackPlayTime_=Date.now(),this.reportEvent_("ps",{sta:"s"}))};shaka.util.CmcdManager.prototype.onPlaybackPlaying_=function(){this.playbackPlayingTime_||(this.playbackPlayingTime_=Date.now())};
shaka.util.CmcdManager.prototype.setupEventListeners_=function(){var a=this;this.eventManager_.listen(this.video_,"playing",function(){a.onPlaybackPlaying_();a.reportEvent_("ps",{sta:"p"})});this.eventManager_.listen(this.video_,"volumechange",function(){a.reportEvent_(a.video_.muted?"m":"um")});this.eventManager_.listen(this.video_,"play",function(){a.onPlaybackPlay_()});this.eventManager_.listen(this.video_,"pause",function(){a.reportEvent_("ps",{sta:"a"})});this.eventManager_.listen(this.player_,
"buffering",function(){a.reportEvent_("ps",{sta:"w"})});this.eventManager_.listen(this.video_,"seeking",function(){return a.reportEvent_("ps",{sta:"k"})});this.eventManager_.listen(document,"fullscreenchange",function(){a.reportEvent_(document.fullscreenElement?"pe":"pc")});var b=this.video_;(b.webkitPresentationMode||b.webkitSupportsFullscreen)&&this.eventManager_.listen(b,"webkitpresentationmodechanged",function(){b.webkitPresentationMode?a.reportEvent_(b.webkitPresentationMode!=="inline"?"pe":
"pc"):b.webkitSupportsFullscreen&&a.reportEvent_(b.webkitDisplayingFullscreen?"pe":"pc")});this.eventManager_.listen(this.video_,"enterpictureinpicture",function(){a.reportEvent_("pe")});this.eventManager_.listen(this.video_,"leavepictureinpicture",function(){a.reportEvent_("pc")});"documentPictureInPicture"in window&&this.eventManager_.listen(window.documentPictureInPicture,"enter",function(c){a.reportEvent_("pe");a.eventManager_.listenOnce(c.window,"pagehide",function(){a.reportEvent_("pc")})});
this.eventManager_.listen(document,"visibilitychange",function(){document.hidden?a.reportEvent_("b",{bg:!0}):a.reportEvent_("b")});this.eventManager_.listen(this.player_,"complete",function(){a.reportEvent_("ps",{sta:"e"})})};
shaka.util.CmcdManager.prototype.setupEventModeTimeInterval_=function(){var a=this;this.stopAndClearEventTimers_();var b=this.getEventModeEnabledTargets_();b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value.timeInterval,c===void 0&&(c=shaka.util.CmcdManager.CmcdV2Constants.TIME_INTERVAL_DEFAULT_VALUE),c>=1){var d=new shaka.util.Timer(function(){return a.reportEvent_(shaka.util.CmcdManager.CmcdV2Keys.TIME_INTERVAL_EVENT)});d.tickEvery(c);this.eventTimers_.push(d)}};
shaka.util.CmcdManager.prototype.stopAndClearEventTimers_=function(){if(this.eventTimers_)for(var a=(0,$jscomp.makeIterator)(this.eventTimers_),b=a.next();!b.done;b=a.next())b.value.stop();this.eventTimers_=[]};shaka.util.CmcdManager.prototype.getEventModeEnabledTargets_=function(){var a=this.config_.targets;return a?a.filter(function(b){return b.mode===shaka.util.CmcdManager.CmcdMode.EVENT&&b.enabled}):[]};
shaka.util.CmcdManager.prototype.getResponseModeEnabledTargets=function(){var a=this.config_.targets;return a?a.filter(function(b){return b.mode===shaka.util.CmcdManager.CmcdMode.RESPONSE&&b.enabled===!0}):[]};shaka.util.CmcdManager.prototype.createData_=function(){this.config_.sessionId||(this.config_.sessionId=window.crypto.randomUUID());return{v:this.config_.version,sf:this.sf_,sid:this.config_.sessionId,cid:this.config_.contentId,mtp:this.player_.getBandwidthEstimate()/1E3}};
shaka.util.CmcdManager.prototype.reportEvent_=function(a,b){b=b===void 0?{}:b;a={e:a,ts:Date.now()};b=Object.assign(a,b);b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.EVENT);a=this.config_.targets;if(!(this.config_.version<shaka.util.CmcdManager.Version.VERSION_2)&&a){var c=this.getEventModeEnabledTargets_();a=Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2EventKeys))));
c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=this.checkValidKeys_(d.includeKeys||[],a,shaka.util.CmcdManager.CmcdMode.EVENT);e.includes(shaka.util.CmcdManager.CmcdV2Keys.TIMESTAMP)||e.push(shaka.util.CmcdManager.CmcdV2Keys.TIMESTAMP);e=this.filterKeys_(b,e);this.isValidEvent_(d.events||[],e)&&this.sendCmcdRequest_(e,d)}}};
shaka.util.CmcdManager.prototype.applyRequest_=function(a,b){if(this.config_.enabled){b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.REQUEST);var c=this.getCmcdTargetHash_({mode:shaka.util.CmcdManager.CmcdMode.REQUEST,useHeaders:this.config_.useHeaders,includeKeys:this.config_.includeKeys||[]});this.cmcdSequenceNumbers_[c]||(this.cmcdSequenceNumbers_[c]={request:1,response:1});b.sn=this.cmcdSequenceNumbers_[c].request++;c=this.config_.includeKeys||[];var d=this.config_.version==shaka.util.CmcdManager.Version.VERSION_2?
Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2RequestModeKeys)))):shaka.util.CmcdManager.CmcdKeys.V1Keys;c=this.checkValidKeys_(c,d,shaka.util.CmcdManager.CmcdMode.REQUEST);b=this.filterKeys_(b,c);this.applyCmcdDataToRequest_(b,a,this.config_.useHeaders)}};
shaka.util.CmcdManager.prototype.applyResponse_=function(a,b){var c=this.getResponseModeEnabledTargets();if(c.length!==0){var d=this.config_.version==shaka.util.CmcdManager.Version.VERSION_2?Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2ResponseModeKeys)))):shaka.util.CmcdManager.CmcdKeys.V1Keys;b.rc=a.status||0;b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.RESPONSE);
a.headers&&a.headers["CMSD-Static"]&&(b.cmsds=btoa(a.headers["CMSD-Static"]));a.headers&&a.headers["CMSD-Dynamic"]&&(b.cmsdd=btoa(a.headers["CMSD-Dynamic"]));c=(0,$jscomp.makeIterator)(c);for(var e=c.next();!e.done;e=c.next()){e=e.value;var f=this.checkValidKeys_(e.includeKeys||[],d,shaka.util.CmcdManager.CmcdMode.RESPONSE),g=this.getCmcdTargetHash_(e);this.cmcdSequenceNumbers_[g]||(this.cmcdSequenceNumbers_[g]={request:1,response:1});b.sn=this.cmcdSequenceNumbers_[g].response++;f=this.filterKeys_(b,
f);this.sendCmcdRequest_(f,e,a)}}};
shaka.util.CmcdManager.prototype.sendCmcdRequest_=function(a,b,c){var d=shaka.net.NetworkingEngine.defaultRetryParameters(),e=b.url;if(b.useHeaders){a=shaka.util.CmcdManager.toHeaders(a);if(!Object.keys(a).length)return;c&&Object.assign(c.headers,a);c=shaka.net.NetworkingEngine.makeRequest([e],d);Object.assign(c.headers,a)}else{a=shaka.util.CmcdManager.toQuery(a);if(!a)return;e=shaka.util.CmcdManager.appendQueryToUri(e,a);c&&(c.uri=e);c=shaka.net.NetworkingEngine.makeRequest([e],d)}d=shaka.net.NetworkingEngine.RequestType.CMCD;
this.player_.getNetworkingEngine().request(d,c)};shaka.util.CmcdManager.prototype.applyCmcdDataToRequest_=function(a,b,c){if(c)a=shaka.util.CmcdManager.toHeaders(a),Object.keys(a).length&&Object.assign(b.headers,a);else{var d=shaka.util.CmcdManager.toQuery(a);d&&(b.uris=b.uris.map(function(e){return shaka.util.CmcdManager.appendQueryToUri(e,d)}))}};
shaka.util.CmcdManager.prototype.checkValidKeys_=function(a,b,c){if(!a||a.length===0)return b;for(var d=(0,$jscomp.makeIterator)(a),e=d.next();!e.done;e=d.next())e=e.value,b.includes(e)||shaka.log.error('CMCD Key "'+e+'" is not allowed for '+c+" mode");return a=a.filter(function(f){return b.includes(f)})};shaka.util.CmcdManager.prototype.filterKeys_=function(a,b){return Object.keys(a).reduce(function(c,d){b.includes(d)&&(c[d]=a[d]);return c},{})};
shaka.util.CmcdManager.prototype.isValidEvent_=function(a,b){var c=shaka.util.CmcdManager.CmcdKeys.CmcdV2Events,d=shaka.util.CmcdManager.CmcdKeys.CmcdV2PlayStates,e=b.e;b=b.sta;return e&&(!c.includes(e)||!(e!=="ps"||b&&d.includes(b))||a&&a.length>0&&!a.includes(e))?!1:!0};
shaka.util.CmcdManager.prototype.getObjectType_=function(a){if(a.type===shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT)return shaka.util.CmcdManager.ObjectType.INIT;if(a=a.stream){var b=a.type;if(b=="video")return a.codecs&&a.codecs.includes(",")?shaka.util.CmcdManager.ObjectType.MUXED:shaka.util.CmcdManager.ObjectType.VIDEO;if(b=="audio")return shaka.util.CmcdManager.ObjectType.AUDIO;if(b=="text")return a.mimeType==="application/mp4"?shaka.util.CmcdManager.ObjectType.TIMED_TEXT:shaka.util.CmcdManager.ObjectType.CAPTION}};
shaka.util.CmcdManager.prototype.getObjectTypeFromMimeType_=function(a){switch(a.toLowerCase()){case "audio/mp4":case "audio/webm":case "audio/ogg":case "audio/mpeg":case "audio/aac":case "audio/flac":case "audio/wav":return shaka.util.CmcdManager.ObjectType.AUDIO;case "video/webm":case "video/mp4":case "video/mpeg":case "video/mp2t":return shaka.util.CmcdManager.ObjectType.MUXED;case "application/x-mpegurl":case "application/vnd.apple.mpegurl":case "application/dash+xml":case "video/vnd.mpeg.dash.mpd":case "application/vnd.ms-sstr+xml":return shaka.util.CmcdManager.ObjectType.MANIFEST}};
shaka.util.CmcdManager.prototype.getCmcdTargetHash_=function(a){var b=Object.keys(a).sort().reduce(function(c,d){d!=="enabled"&&(c[d]=a[d]);return c},{});return JSON.stringify(b)};shaka.util.CmcdManager.prototype.getBufferLength_=function(a){a=this.player_.getBufferedInfo()[a];if(!a.length)return NaN;var b=this.getCurrentTime_();return(a=a.find(function(c){return c.start<=b&&c.end>=b}))?(a.end-b)*1E3:NaN};
shaka.util.CmcdManager.prototype.getRemainingBufferLength_=function(a){a=this.player_.getBufferedInfo()[a];if(!a.length)return 0;var b=this.getCurrentTime_();return(a=a.find(function(c){return c.start<=b&&c.end>=b}))?(a.end-b)*1E3:0};shaka.util.CmcdManager.prototype.calculateMSD_=function(){if(this.playbackPlayingTime_&&this.playbackPlayTime_)return this.playbackPlayingTime_-(this.startTimeOfLoad_||this.playbackPlayTime_)};
shaka.util.CmcdManager.prototype.calculateRtp_=function(a,b){var c=this.player_.getPlaybackRate()||1,d=this.getRemainingBufferLength_(a.type)||500;return(a=a.bandwidth)?a*(b.endTime-b.startTime)/1E3/(d/c/1E3)*this.config_.rtpSafetyFactor:NaN};
shaka.util.CmcdManager.prototype.getStreamFormat_=function(a){var b=shaka.net.NetworkingEngine.AdvancedRequestType;switch(a){case b.MPD:return this.lowLatency_?shaka.util.CmcdManager.StreamingFormat.LOW_LATENCY_DASH:shaka.util.CmcdManager.StreamingFormat.DASH;case b.MASTER_PLAYLIST:case b.MEDIA_PLAYLIST:return this.lowLatency_?shaka.util.CmcdManager.StreamingFormat.LOW_LATENCY_HLS:shaka.util.CmcdManager.StreamingFormat.HLS;case b.MSS:return shaka.util.CmcdManager.StreamingFormat.SMOOTH}};
shaka.util.CmcdManager.prototype.getStreamType_=function(){return this.player_.isLive()?shaka.util.CmcdManager.StreamType.LIVE:shaka.util.CmcdManager.StreamType.VOD};
shaka.util.CmcdManager.prototype.getTopBandwidth_=function(a){var b=this.player_.getVariantTracks();if(!b.length)return NaN;var c=b[0];b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())d=d.value,d.type==="variant"&&d.bandwidth>c.bandwidth&&(c=d);b=shaka.util.CmcdManager.ObjectType;switch(a){case b.VIDEO:return c.videoBandwidth||NaN;case b.AUDIO:return c.audioBandwidth||NaN;default:return c.bandwidth}};
shaka.util.CmcdManager.prototype.getDataForSegment_=function(a,b){var c=a.segment,d=0;c&&(d=c.endTime-c.startTime);d={d:d*1E3,st:this.getStreamType_()};d.ot=this.getObjectType_(a);var e=shaka.util.CmcdManager.ObjectType,f=d.ot===e.VIDEO||d.ot===e.AUDIO||d.ot===e.MUXED||d.ot===e.TIMED_TEXT;if(a=a.stream){var g=this.player_.getPlaybackRate();if(f&&(d.bl=this.getBufferLength_(a.type),d.ot!==e.TIMED_TEXT)){var h=this.getRemainingBufferLength_(a.type);d.dl=g?h/Math.abs(g):h}a.bandwidth&&(d.br=a.bandwidth/
1E3);a.segmentIndex&&c&&((g=a.segmentIndex.getIteratorForTime(c.endTime,!0,g<0))&&(g=g.next().value)&&g!=c&&(b&&!shaka.util.ArrayUtils.equal(c.getUris(),g.getUris())&&(d.nor=shaka.util.CmcdManager.urlToRelativePath(g.getUris()[0],b)),!g.startByte&&!g.endByte||c.startByte==g.startByte&&c.endByte==g.endByte||(b=g.startByte+"-",g.endByte&&(b+=g.endByte),d.nrr=b)),c=this.calculateRtp_(a,c),isNaN(c)||(d.rtp=c))}f&&d.ot!==e.TIMED_TEXT&&(d.tb=this.getTopBandwidth_(d.ot)/1E3);return d};
shaka.util.CmcdManager.prototype.getCurrentTime_=function(){return this.video_?this.video_.currentTime:0};
shaka.util.CmcdManager.prototype.getGenericData_=function(a,b){Object.assign(a,this.createData_());a.pr=this.player_.getPlaybackRate();var c=a.ot===shaka.util.CmcdManager.ObjectType.VIDEO||a.ot===shaka.util.CmcdManager.ObjectType.MUXED;this.starved_&&c&&(a.bs=!0,a.su=!0,this.starved_=!1);a.su==null&&(a.su=this.buffering_);this.player_.isLive()&&(c=this.player_.getLiveLatency(),a.ltc=c||void 0);document.hidden&&(a.bg=!0);c=this.calculateMSD_();c==void 0||this.msdSent_[b]||(a.msd=c,this.msdSent_[b]=
!0);return a};
shaka.util.CmcdManager.serialize=function(a){var b=[],c=function(m){return!Number.isNaN(m)&&m!=null&&m!==""&&m!==!1},d=function(m){return Math.round(m)},e=function(m){return d(m/100)*100};e={br:d,d:d,bl:e,dl:e,mtp:e,nor:function(m){return encodeURIComponent(m)},rtp:e,tb:d,ttfb:d,ttlb:d};var f=Object.keys(a||{}).sort();f=(0,$jscomp.makeIterator)(f);for(var g=f.next();!g.done;g=f.next()){g=g.value;var h=a[g];if(c(h)&&(g!=="v"||h!==1)&&(g!="pr"||h!==1)){var k=e[g];k&&(h=k(h));k=typeof h;var l=void 0;
l=k==="string"&&g!=="ot"&&g!=="sf"&&g!=="st"?g+"="+JSON.stringify(h):k==="boolean"?g:k==="symbol"?g+"="+h.description:g+"="+h;b.push(l)}}return b.join(",")};
shaka.util.CmcdManager.toHeaders=function(a){var b=Object.keys(a),c={},d=["Object","Request","Session","Status"],e=[{},{},{},{}],f={br:0,d:0,ot:0,tb:0,url:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,ltc:1,ttfb:1,ttlb:1,ts:1,rc:1,cmsdd:1,cmsds:1,sn:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,msd:2,bs:3,rtp:3,bg:3};b=(0,$jscomp.makeIterator)(b);for(var g=b.next();!g.done;g=b.next())g=g.value,e[f[g]!=null?f[g]:1][g]=a[g];for(a=0;a<e.length;a++)(f=shaka.util.CmcdManager.serialize(e[a]))&&(c["CMCD-"+d[a]]=f);return c};
shaka.util.CmcdManager.toQuery=function(a){return shaka.util.CmcdManager.serialize(a)};shaka.util.CmcdManager.appendQueryToUri=function(a,b){if(!b||a.includes("offline:"))return a;a=new goog.Uri(a);a.getQueryData().set("CMCD",b);return a.toString()};
shaka.util.CmcdManager.urlToRelativePath=function(a,b){var c=new URL(a);b=new URL(b);if(c.origin!==b.origin)return a;a=c.pathname.split("/").slice(1);b=b.pathname.split("/").slice(1,-1);for(var d=Math.min(a.length,b.length),e=0;e<d&&a[e]===b[e];e++)a.shift(),b.shift();for(;b.length;)b.shift(),a.unshift("..");return a.join("/")+c.search+c.hash};shaka.util.CmcdManager.ObjectType={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};
shaka.util.CmcdManager.Version={VERSION_1:1,VERSION_2:2};shaka.util.CmcdManager.StreamType={VOD:"v",LIVE:"l"};shaka.util.CmcdManager.StreamingFormat={DASH:"d",LOW_LATENCY_DASH:"ld",HLS:"h",LOW_LATENCY_HLS:"lh",SMOOTH:"s",OTHER:"o"};goog.exportSymbol("shaka.util.CmcdManager.StreamingFormat",shaka.util.CmcdManager.StreamingFormat);
shaka.util.CmcdManager.CmcdKeys={V1Keys:"br bl bs cid d dl mtp nor nrr ot pr rtp sf sid st su tb v".split(" "),V2CommonKeys:"br ab bl tbl bs cdn cid ltc mtp pr sf sid bg sta st ts tpb tb lb tab lab pt ec msd v sn".split(" "),V2RequestModeKeys:"ab bl tbl bs cdn cid d dl ltc mtp nor ot pr rtp sf sid bg sta st su ts tpb tb lb tab lab pt ec msd v".split(" "),V2ResponseModeKeys:"d dl nor ot rtp rc su ttfb ttfbb ttlb url cmsdd cmsds".split(" "),V2EventKeys:["e","sta"],CmcdV2Events:"ps e t c b m um pe pc".split(" "),
CmcdV2PlayStates:"spawkrfeqd".split("")};shaka.util.CmcdManager.CmcdV2Constants={TIME_INTERVAL_DEFAULT_VALUE:10};shaka.util.CmcdManager.CmcdV2Keys={TIMESTAMP:"ts",TIME_INTERVAL_EVENT:"t"};shaka.util.CmcdManager.CmcdMode={REQUEST:"request",RESPONSE:"response",EVENT:"event"};shaka.util.CmsdManager=function(a){this.config_=a;this.dynamicParams_=this.staticParams_=null};shaka.util.CmsdManager.prototype.configure=function(a){this.config_=a};shaka.util.CmsdManager.prototype.reset=function(){this.dynamicParams_=this.staticParams_=null};
shaka.util.CmsdManager.prototype.processHeaders=function(a){if(this.config_.enabled){var b=shaka.util.CmsdManager,c=a[b.CMSD_STATIC_HEADER_NAME_];c&&(c=this.parseCMSDStatic_(c))&&(this.staticParams_=c);if(a=a[b.CMSD_DYNAMIC_HEADER_NAME_])if(a=this.parseCMSDDynamic_(a))this.dynamicParams_=a}};
shaka.util.CmsdManager.prototype.getMaxBitrate=function(){var a=shaka.util.CmsdManager.KEYS_.MAX_SUGGESTED_BITRATE;return this.config_.enabled&&this.config_.applyMaximumSuggestedBitrate&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a)*1E3:null};
shaka.util.CmsdManager.prototype.getEstimatedThroughput=function(){var a=shaka.util.CmsdManager.KEYS_.ESTIMATED_THROUGHPUT;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a)*1E3:null};shaka.util.CmsdManager.prototype.getResponseDelay=function(){var a=shaka.util.CmsdManager.KEYS_.RESPONSE_DELAY;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a):null};
shaka.util.CmsdManager.prototype.getRoundTripTime=function(){var a=shaka.util.CmsdManager.KEYS_.ROUND_TRIP_TIME;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a):null};shaka.util.CmsdManager.prototype.getBandwidthEstimate=function(a){var b=this.getEstimatedThroughput();if(!b)return a;var c=this.config_.estimatedThroughputWeightRatio;return c>0&&c<=1?a*(1-c)+b*c:a};
shaka.util.CmsdManager.prototype.parseCMSDStatic_=function(a){try{var b=new Map,c=a.split(",");for(a=0;a<c.length;a++){var d=c[a].split("="),e=d[0],f=this.parseParameterValue_(d[1]);b.set(e,f)}return b}catch(g){return shaka.log.warning("Failed to parse CMSD-Static response header value:",g),null}};
shaka.util.CmsdManager.prototype.parseCMSDDynamic_=function(a){try{var b=new Map,c=a.split(";");for(a=1;a<c.length;a++){var d=c[a].split("="),e=d[0],f=this.parseParameterValue_(d[1]);b.set(e,f)}return b}catch(g){return shaka.log.warning("Failed to parse CMSD-Dynamic response header value:",g),null}};shaka.util.CmsdManager.prototype.parseParameterValue_=function(a){return a?a.toLowerCase()==="false"?!1:/^[-0-9]/.test(a)?parseInt(a,10):a.replace(/["]+/g,""):!0};
goog.exportSymbol("shaka.util.CmsdManager",shaka.util.CmsdManager);goog.exportProperty(shaka.util.CmsdManager.prototype,"getBandwidthEstimate",shaka.util.CmsdManager.prototype.getBandwidthEstimate);goog.exportProperty(shaka.util.CmsdManager.prototype,"getRoundTripTime",shaka.util.CmsdManager.prototype.getRoundTripTime);goog.exportProperty(shaka.util.CmsdManager.prototype,"getResponseDelay",shaka.util.CmsdManager.prototype.getResponseDelay);
goog.exportProperty(shaka.util.CmsdManager.prototype,"getEstimatedThroughput",shaka.util.CmsdManager.prototype.getEstimatedThroughput);goog.exportProperty(shaka.util.CmsdManager.prototype,"getMaxBitrate",shaka.util.CmsdManager.prototype.getMaxBitrate);shaka.util.CmsdManager.CMSD_STATIC_HEADER_NAME_="cmsd-static";shaka.util.CmsdManager.CMSD_DYNAMIC_HEADER_NAME_="cmsd-dynamic";
shaka.util.CmsdManager.KEYS_={AVAILABILITY_TIME:"at",DURESS:"du",ENCODED_BITRATE:"br",ESTIMATED_THROUGHPUT:"etp",HELD_TIME:"ht",INTERMEDIARY_IDENTIFIER:"n",MAX_SUGGESTED_BITRATE:"mb",NEXT_OBJECT_RESPONSE:"nor",NEXT_RANGE_RESPONSE:"nrr",OBJECT_DURATION:"d",OBJECT_TYPE:"ot",RESPONSE_DELAY:"rd",ROUND_TRIP_TIME:"rtt",STARTUP:"su",STREAM_TYPE:"st",STREAMING_FORMAT:"sf",VERSION:"v"};shaka.util.Mutex=function(){this.acquiredIdentifier=null;this.unlockQueue=[]};shaka.util.Mutex.prototype.acquire=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1)return shaka.log.v2(a+" has requested mutex"),b.acquiredIdentifier?c.yield(new Promise(function(d){return b.unlockQueue.push(d)}),2):c.jumpTo(2);b.acquiredIdentifier=a;shaka.log.v2(a+" has acquired mutex");c.jumpToEnd()})};
shaka.util.Mutex.prototype.release=function(){shaka.log.v2(this.acquiredIdentifier+" has released mutex");this.unlockQueue.length>0?this.unlockQueue.shift()():this.acquiredIdentifier=null};shaka.util.Mutex.prototype.releaseAll=function(){for(;this.acquiredIdentifier;)this.release()};shaka.util.NumberUtils=function(){};shaka.util.NumberUtils.isFloatEqual=function(a,b,c){c=c===void 0?Number.EPSILON:c;if(a===b)return!0;a=Math.abs(a-b);return a<=c?!0:c!==Number.EPSILON?Math.abs(a-c)<=Number.EPSILON:!1};shaka.Player=function(a,b,c){b=b===void 0?null:b;shaka.util.FakeEventTarget.call(this);var d=this;this.loadMode_=shaka.Player.LoadMode.NOT_LOADED;this.video_=null;this.videoContainer_=b;this.isTextVisible_=!1;this.globalEventManager_=new shaka.util.EventManager;this.attachEventManager_=new shaka.util.EventManager;this.loadEventManager_=new shaka.util.EventManager;this.trickPlayEventManager_=new shaka.util.EventManager;this.adManagerEventManager_=new shaka.util.EventManager;this.playhead_=this.mediaSourceEngine_=
this.drmEngine_=this.networkingEngine_=null;this.operationId_=0;this.mutex_=new shaka.util.Mutex;this.startTime_=this.mimeType_=this.assetUri_=this.manifest_=this.parserFactory_=this.parser_=this.streamingEngine_=this.qualityObserver_=this.lcevcDec_=this.lcevcCanvas_=this.cmsdManager_=this.cmcdManager_=this.emsgRegionTimeline_=this.metadataRegionTimeline_=this.regionTimeline_=this.bufferObserver_=this.bufferPoller_=this.playRateController_=this.playheadObservers_=null;this.fullyLoaded_=!1;this.abrManagerFactory_=
this.abrManager_=null;this.nextExternalStreamId_=1E9;this.externalSrcEqualsThumbnailsStreams_=[];this.deferredCloseSegmentIndex_=new Map;this.externalChaptersStreams_=[];this.completionPercent_=-1;this.config_=this.defaultConfig_();this.lowLatencyConfig_=shaka.util.PlayerConfiguration.createDefaultForLL();this.currentTargetLatency_=null;this.rebufferingCount_=-1;this.targetLatencyReached_=null;this.maxHwRes_={width:Infinity,height:Infinity};this.manifestFilterer_=new shaka.media.ManifestFilterer(this.config_,
this.maxHwRes_,null);this.createdPreloadManagers_=[];this.stats_=null;this.currentAdaptationSetCriteria_=this.config_.adaptationSetCriteriaFactory();this.currentAdaptationSetCriteria_.configure({language:this.config_.preferredAudioLanguage,role:this.config_.preferredAudioRole,videoRole:this.config_.preferredVideoRole,channelCount:0,hdrLevel:this.config_.preferredVideoHdrLevel,spatialAudio:this.config_.preferSpatialAudio,videoLayout:this.config_.preferredVideoLayout,audioLabel:this.config_.preferredAudioLabel,
videoLabel:this.config_.preferredVideoLabel,codecSwitchingStrategy:this.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:this.config_.preferredAudioCodecs,preferredAudioChannelCount:this.config_.preferredAudioChannelCount});this.currentTextLanguage_=this.config_.preferredTextLanguage;this.currentTextRole_=this.config_.preferredTextRole;this.currentTextForced_=this.config_.preferForcedSubs;this.cleanupOnUnload_=[];c&&c(this);
this.cmcdManager_=this.createCmcd_();this.cmsdManager_=this.createCmsd_();this.networkingEngine_=this.createNetworkingEngine();this.preloadDueAdManagerVideo_=this.preloadDueAdManager_=this.queueManager_=this.adManager_=null;this.preloadDueAdManagerVideoEnded_=!1;this.externalSrcEqualsTextTracks_=[];this.preloadDueAdManagerTimer_=new shaka.util.Timer(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1){if(!d.preloadDueAdManager_)return e.jumpTo(0);goog.asserts.assert(d.preloadDueAdManagerVideo_,
"Must have video");return e.yield(d.attach(d.preloadDueAdManagerVideo_,!0),3)}if(e.nextAddress!=4)return e.yield(d.load(d.preloadDueAdManager_),4);d.preloadDueAdManagerVideoEnded_?d.preloadDueAdManagerVideo_.pause():d.preloadDueAdManagerVideo_.play();d.preloadDueAdManager_=null;d.preloadDueAdManagerVideoEnded_=!1;e.jumpToEnd()})});shaka.Player.adManagerFactory_&&(this.adManager_=shaka.Player.adManagerFactory_(),this.adManager_.configure(this.config_.ads),this.adManagerEventManager_.listen(this.adManager_,
"ad-content-pause-requested",function(e){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1){d.preloadDueAdManagerTimer_.stop();if(d.preloadDueAdManager_)return g.jumpTo(0);d.preloadDueAdManagerVideo_=d.video_;d.preloadDueAdManagerVideoEnded_=d.isEnded();f=e.saveLivePosition||!1;return g.yield(d.detachAndSavePreload(!0,f),3)}d.preloadDueAdManager_=g.yieldResult;g.jumpToEnd()})}),this.adManagerEventManager_.listen(this.adManager_,"ad-content-resume-requested",
function(e){e=e.offset||0;d.preloadDueAdManager_&&d.preloadDueAdManager_.setOffsetToStartTime(e);d.preloadDueAdManagerTimer_.tickAfter(.1)}),this.adManagerEventManager_.listen(this.adManager_,"ad-content-attach-requested",function(e){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(d.video_||!d.preloadDueAdManagerVideo_)return f.jumpTo(0);goog.asserts.assert(d.preloadDueAdManagerVideo_,"Must have video");return f.yield(d.attach(d.preloadDueAdManagerVideo_,!0),0)})}));shaka.Player.queueManagerFactory_&&
(this.queueManager_=shaka.Player.queueManagerFactory_(this),this.queueManager_.configure(this.config_.queue));this.globalEventManager_.listen(window,"online",function(){d.restoreDisabledVariants_();d.retryStreaming()});this.checkVariantsTimer_=new shaka.util.Timer(function(){return d.checkVariants_()});this.preloadNextUrl_=null;a&&(shaka.Deprecate.deprecateFeature(5,"Player w/ mediaElement","Please migrate from initializing Player with a mediaElement; use the attach method instead."),this.attach(a,
!0));this.textDisplayer_=null};$jscomp.inherits(shaka.Player,shaka.util.FakeEventTarget);shaka.Player.prototype.createLcevcDec_=function(a,b){this.lcevcDec_==null&&(this.lcevcDec_=new shaka.lcevc.Dec(this.video_,this.lcevcCanvas_,a,b),this.mediaSourceEngine_&&this.mediaSourceEngine_.updateLcevcDec(this.lcevcDec_))};shaka.Player.prototype.closeLcevcDec_=function(){this.lcevcDec_!=null&&(this.lcevcDec_.hideCanvas(),this.lcevcDec_.release(),this.lcevcDec_=null)};
shaka.Player.prototype.setupLcevc_=function(a,b){b||a.lcevc.enabled?(this.closeLcevcDec_(),this.createLcevcDec_(a.lcevc,b)):this.closeLcevcDec_()};shaka.Player.makeEvent_=function(a,b){return new shaka.util.FakeEvent(a,b)};
shaka.Player.prototype.destroy=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.nextAddress){case 1:if(a.loadMode_==shaka.Player.LoadMode.DESTROYED)return c.return();a.closeLcevcDec_();b=a.detach();a.loadMode_=shaka.Player.LoadMode.DESTROYED;return c.yield(b,2);case 2:return c.yield(a.destroyAllPreloads(),3);case 3:a.globalEventManager_&&(a.globalEventManager_.release(),a.globalEventManager_=null);a.attachEventManager_&&(a.attachEventManager_.release(),
a.attachEventManager_=null);a.loadEventManager_&&(a.loadEventManager_.release(),a.loadEventManager_=null);a.trickPlayEventManager_&&(a.trickPlayEventManager_.release(),a.trickPlayEventManager_=null);a.adManagerEventManager_&&(a.adManagerEventManager_.release(),a.adManagerEventManager_=null);a.abrManagerFactory_=null;a.config_=null;a.stats_=null;a.videoContainer_=null;a.cmcdManager_=null;a.cmsdManager_=null;if(!a.networkingEngine_){c.jumpTo(4);break}return c.yield(a.networkingEngine_.destroy(),5);
case 5:a.networkingEngine_=null;case 4:a.abrManager_&&(a.abrManager_.release(),a.abrManager_=null),a.queueManager_&&(a.queueManager_.destroy(),a.queueManager_=null),shaka.util.FakeEventTarget.prototype.release.call(a),c.jumpToEnd()}})};shaka.Player.registerSupportPlugin=function(a,b){shaka.Player.supportPlugins_.set(a,b)};shaka.Player.setAdManagerFactory=function(a){shaka.Player.adManagerFactory_=a};shaka.Player.setQueueManagerFactory=function(a){shaka.Player.queueManagerFactory_=a};
shaka.Player.isBrowserSupported=function(){window.Promise||shaka.log.alwaysWarn("A Promise implementation or polyfill is required");if(!(window.Promise&&window.Uint8Array&&Array.prototype.forEach)||(navigator.userAgent||"").includes("Trident/"))return!1;var a=shaka.device.DeviceFactory.getDevice();return a.supportsMediaSource()?!0:a.supportsMediaType("application/x-mpegurl")};
shaka.Player.probeSupport=function(a){a=a===void 0?!0:a;var b,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.nextAddress){case 1:goog.asserts.assert(shaka.Player.isBrowserSupported(),"Must have basic support");b={};if(!a){k.jumpTo(2);break}return k.yield(shaka.drm.DrmEngine.probeSupport(),3);case 3:b=k.yieldResult;case 2:return c=shaka.media.ManifestParser.probeSupport(),d=shaka.media.MediaSourceEngine.probeSupport(),e=shaka.device.DeviceFactory.getDevice(),
goog.asserts.assert(e,"device must be non-null"),k.yield(e.detectMaxHardwareResolution(),4);case 4:return f=k.yieldResult,g={manifest:c,media:d,drm:b,hardwareResolution:f},h=shaka.Player.supportPlugins_,h.forEach(function(l,m){g[m]=l()}),k.return(g)}})};shaka.Player.prototype.makeStateChangeEvent_=function(a){this.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.OnStateChange,(new Map).set("state",a)))};
shaka.Player.prototype.attach=function(a,b){b=b===void 0?!0:b;var c=this,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.nextAddress){case 1:if(c.loadMode_==shaka.Player.LoadMode.DESTROYED)throw c.createAbortLoadError_();d=c.video_&&c.video_==a;if(!c.video_||c.video_==a){h.jumpTo(2);break}return h.yield(c.detach(),2);case 2:return h.yield(c.atomicOperationAcquireMutex_("attach"),4);case 4:if(h.yieldResult)return h.return();h.setCatchFinallyBlocks(5,6);d||(c.makeStateChangeEvent_("attach"),
e=function(k){return c.onVideoError_(k)},c.attachEventManager_.listen(a,"error",e),c.video_=a,c.cmcdManager_&&c.cmcdManager_.setMediaElement(a));f=shaka.device.DeviceFactory.getDevice();if(!b||!f.supportsMediaSource()||c.mediaSourceEngine_){h.jumpTo(6);break}return h.yield(c.initializeMediaSourceEngineInner_(),6);case 6:h.enterFinallyBlock();c.mutex_.release();h.leaveFinallyBlock(0);break;case 5:return g=h.enterCatchBlock(),h.yield(c.detach(),10);case 10:throw g;}})};
shaka.Player.prototype.attachCanvas=function(a){this.lcevcCanvas_=a};
shaka.Player.prototype.detach=function(a){a=a===void 0?!1:a;var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1){if(b.loadMode_==shaka.Player.LoadMode.DESTROYED)throw b.createAbortLoadError_();return c.yield(b.unload(!1,a),2)}if(c.nextAddress!=3)return c.yield(b.atomicOperationAcquireMutex_("detach"),3);if(c.yieldResult)return c.return();try{b.video_&&(b.attachEventManager_.removeAll(),b.video_=null),b.makeStateChangeEvent_("detach"),b.adManager_&&!a&&
b.adManager_.release()}finally{b.mutex_.release()}c.jumpToEnd()})};shaka.Player.prototype.atomicOperationAcquireMutex_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.nextAddress==1?(c=++b.operationId_,d.yield(b.mutex_.acquire(a),2)):c!=b.operationId_?(b.mutex_.release(),d.return(!0)):d.return(!1)})};
shaka.Player.prototype.unload=function(a,b){a=a===void 0?!0:a;b=b===void 0?!1:b;var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.nextAddress){case 1:return c.loadMode_!=shaka.Player.LoadMode.DESTROYED&&(c.loadMode_=shaka.Player.LoadMode.NOT_LOADED),z.yield(c.atomicOperationAcquireMutex_("unload"),2);case 2:if(z.yieldResult)return z.return();z.setFinallyBlock(3);c.fullyLoaded_=!1;c.makeStateChangeEvent_("unload");c.closeLcevcDec_();
d=c.cleanupOnUnload_.map(function(B){return B()});c.cleanupOnUnload_=[];return z.yield(Promise.all(d),5);case 5:c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Unloading));c.regionTimeline_&&(c.regionTimeline_.release(),c.regionTimeline_=null);c.metadataRegionTimeline_&&(c.metadataRegionTimeline_.release(),c.metadataRegionTimeline_=null);c.emsgRegionTimeline_&&(c.emsgRegionTimeline_.release(),c.emsgRegionTimeline_=null);c.video_&&(c.loadEventManager_.removeAll(),c.trickPlayEventManager_.removeAll());
c.checkVariantsTimer_.stop();c.playheadObservers_&&(c.playheadObservers_.release(),c.playheadObservers_=null);c.bufferPoller_&&(c.bufferPoller_.stop(),c.bufferPoller_=null);if(!c.parser_){z.jumpTo(6);break}return z.yield(c.parser_.stop(),7);case 7:c.parser_=null,c.parserFactory_=null;case 6:c.abrManager_&&c.abrManager_.stop();if(!c.streamingEngine_){z.jumpTo(8);break}return z.yield(c.streamingEngine_.destroy(),9);case 9:c.streamingEngine_=null;case 8:c.playRateController_&&(c.playRateController_.release(),
c.playRateController_=null);c.playhead_&&(c.playhead_.release(),c.playhead_=null);if(!shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")||!c.drmEngine_){z.jumpTo(10);break}return z.yield(c.drmEngine_.destroy(),11);case 11:c.drmEngine_=null;case 10:if(!c.mediaSourceEngine_){z.jumpTo(12);break}return z.yield(c.mediaSourceEngine_.destroy(),13);case 13:c.mediaSourceEngine_=null;case 12:if(c.adManager_&&!b)c.adManager_.onAssetUnload();c.preloadDueAdManager_&&!b&&(c.preloadDueAdManager_.destroy(),c.preloadDueAdManager_=
null);b||c.preloadDueAdManagerTimer_.stop();c.cmcdManager_&&c.cmcdManager_.reset();c.cmsdManager_&&c.cmsdManager_.reset();if(!c.textDisplayer_){z.jumpTo(14);break}return z.yield(c.textDisplayer_.destroy(),15);case 15:c.textDisplayer_=null;case 14:c.isTextVisible_=!1;if(c.video_){e=(0,$jscomp.makeIterator)(c.externalSrcEqualsTextTracks_);for(f=e.next();!f.done;f=e.next())g=f.value,g.src.startsWith("blob:")&&URL.revokeObjectURL(g.src),g.remove();c.externalSrcEqualsTextTracks_=[];shaka.util.Dom.clearSourceFromVideo(c.video_)&&
c.video_.load()}if(!c.drmEngine_){z.jumpTo(16);break}return z.yield(c.drmEngine_.destroy(),17);case 17:c.drmEngine_=null;case 16:c.preloadNextUrl_&&c.assetUri_!=c.preloadNextUrl_.getAssetUri()&&(c.preloadNextUrl_.isDestroyed()||c.preloadNextUrl_.destroy(),c.preloadNextUrl_=null);c.assetUri_=null;c.mimeType_=null;c.bufferObserver_=null;if(c.manifest_){h=(0,$jscomp.makeIterator)(c.manifest_.variants);for(k=h.next();!k.done;k=h.next())for(l=k.value,m=(0,$jscomp.makeIterator)([l.audio,l.video]),n=m.next();!n.done;n=
m.next())(p=n.value)&&p.segmentIndex&&p.segmentIndex.release();q=(0,$jscomp.makeIterator)(c.manifest_.textStreams);for(r=q.next();!r.done;r=q.next())t=r.value,t.segmentIndex&&t.segmentIndex.release()}c.config_&&c.config_.streaming.clearDecodingCache&&(shaka.util.StreamUtils.clearDecodingConfigCache(),shaka.drm.DrmUtils.clearMediaKeySystemAccessMap());c.manifest_=null;c.stats_=new shaka.util.Stats;c.lastTextFactory_=null;c.targetLatencyReached_=null;c.currentTargetLatency_=null;c.rebufferingCount_=
-1;c.externalSrcEqualsThumbnailsStreams_=[];w=(0,$jscomp.makeIterator)(c.deferredCloseSegmentIndex_.values());for(v=w.next();!v.done;v=w.next())u=v.value,u.stop();c.deferredCloseSegmentIndex_.clear();c.externalChaptersStreams_=[];c.completionPercent_=-1;c.networkingEngine_&&c.networkingEngine_.clearCommonAccessTokenMap();c.updateBufferState_();case 3:z.enterFinallyBlock();c.mutex_.release();z.leaveFinallyBlock(4);break;case 4:x=shaka.device.DeviceFactory.getDevice();if(a&&x.supportsMediaSource()&&
!c.mediaSourceEngine_&&c.video_)return z.yield(c.initializeMediaSourceEngineInner_(),0);z.jumpTo(0)}})};shaka.Player.prototype.updateStartTime=function(a){this.startTime_=a};
shaka.Player.prototype.load=function(a,b,c){b=b===void 0?null:b;var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.nextAddress){case 1:if(d.loadMode_==shaka.Player.LoadMode.DESTROYED)throw d.createAbortLoadError_();e=null;f="";if(a instanceof shaka.media.PreloadManager){if(a.isDestroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.PRELOAD_DESTROYED);e=a;f=e.getAssetUri()||
""}else f=a||"";return u.yield(d.mutex_.acquire("load"),2);case 2:d.mutex_.release();if(!d.video_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.NO_VIDEO_ELEMENT);if(!d.assetUri_){u.jumpTo(3);break}d.assetUri_=f;return u.yield(d.unload(!1),3);case 3:g=++d.operationId_;h=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){if(x.nextAddress==1)return d.operationId_==g?x.jumpTo(0):e?x.yield(e.destroy(),3):x.jumpTo(3);
throw d.createAbortLoadError_();})};k=function(x,z){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){switch(B.nextAddress){case 1:return B.setFinallyBlock(2),B.yield(d.mutex_.acquire(z),4);case 4:return B.yield(h(),5);case 5:return B.yield(x(),6);case 6:return B.yield(h(),7);case 7:e&&d.config_&&e.reconfigure(d.config_);case 2:B.enterFinallyBlock(),d.mutex_.release(),B.leaveFinallyBlock(0)}})};u.setCatchFinallyBlocks(5,6);b==null&&e&&(b=e.getStartTime());d.startTime_=b;d.fullyLoaded_=
!1;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Loading));if(e){c=e.getMimeType();u.jumpTo(8);break}if(c){u.jumpTo(8);break}return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){if(x.nextAddress==1)return x.yield(d.guessMimeType_(f),2);c=x.yieldResult;x.jumpToEnd()})},"guessMimeType_"),8);case 8:l=!!e;if(e){e.setEventHandoffTarget(d);d.stats_=e.getStats();u.jumpTo(11);break}return u.yield(d.preloadInner_(f,b,c,!0,d.config_),12);case 12:(e=
u.yieldResult)?(e.markIsLoad(),e.setEventHandoffTarget(d),d.stats_=e.getStats(),e.start(),e.waitForFinish().catch(function(){})):d.stats_=new shaka.util.Stats;case 11:m=!e;n=Date.now()/1E3;d.stats_=e?e.getStats():new shaka.util.Stats;d.assetUri_=f;d.mimeType_=c||null;d.updateBufferState_();p=function(){var x=d.video_?d.video_.buffered:null;return{start:shaka.media.TimeRangesUtils.bufferStart(x)||0,end:shaka.media.TimeRangesUtils.bufferEnd(x)||0}};d.metadataRegionTimeline_=new shaka.media.RegionTimeline(p);
d.metadataRegionTimeline_.addEventListener("regionadd",function(x){d.dispatchMetadataEvent_(x.region,shaka.util.FakeEvent.EventName.MetadataAdded)});if(m)return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){goog.asserts.assert(c,"We should know the mimeType by now!");return x.yield(d.initializeSrcEqualsDrmInner_(c),0)})},"initializeSrcEqualsDrmInner_"),23);d.emsgRegionTimeline_=new shaka.media.RegionTimeline(p);return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){if(x.nextAddress==
1)return x.yield(e.waitForManifest(),2);d.parserFactory_=e.getParserFactory();d.parser_=e.receiveParser();d.manifest_=e.getManifest();x.jumpToEnd()})},"waitForFinish"),15);case 15:if(d.mediaSourceEngine_){u.jumpTo(16);break}return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){return x.yield(d.initializeMediaSourceEngineInner_(),0)})},"initializeMediaSourceEngineInner_"),16);case 16:return d.manifest_&&d.manifest_.textStreams.length&&(d.textDisplayer_.enableTextDisplayer?
d.textDisplayer_.enableTextDisplayer():shaka.Deprecate.deprecateFeature(5,"Text displayer w/ enableTextDisplayer",'Text displayer should have a "enableTextDisplayer" method!')),u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){return x.yield(e.waitForFinish(),0)})},"waitForFinish"),18);case 18:d.config_=e.getConfiguration();d.manifestFilterer_=e.getManifestFilterer();d.parser_&&d.parser_.setMediaElement&&d.video_&&d.parser_.setMediaElement(d.video_);d.regionTimeline_=
e.receiveRegionTimeline();d.qualityObserver_=e.getQualityObserver();if(q=e.getCurrentAdaptationSetCriteria())d.currentAdaptationSetCriteria_=q;l&&d.video_&&d.video_.nodeName==="AUDIO"&&(d.makeManifestAudioOnly_(),d.configure("manifest.disableVideo",!0));if(e.getDrmEngine()){u.jumpTo(19);break}return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){return x.yield(e.initializeDrm(d.video_),0)})},"drmEngine_.init"),19);case 19:return d.drmEngine_=e.receiveDrmEngine(),
u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){return x.yield(d.drmEngine_.attach(d.video_),0)})},"drmEngine_.attach"),21);case 21:return r=d.config_.abrFactory,d.abrManager_&&d.abrManagerFactory_==r||(d.abrManagerFactory_=r,d.abrManager_&&d.abrManager_.release(),d.abrManager_=r(),typeof d.abrManager_.setMediaElement!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o setMediaElement","Please use an AbrManager with setMediaElement function."),d.abrManager_.setMediaElement=
function(){}),typeof d.abrManager_.setCmsdManager!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o setCmsdManager","Please use an AbrManager with setCmsdManager function."),d.abrManager_.setCmsdManager=function(){}),typeof d.abrManager_.trySuggestStreams!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o trySuggestStreams","Please use an AbrManager with trySuggestStreams function."),d.abrManager_.trySuggestStreams=function(){}),d.abrManager_.configure(d.config_.abr)),
t=e.receiveSegmentPrefetchesById(),w=e.getPrefetchedVariant(),u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){return x.yield(d.loadInner_(n,w,t),0)})},"loadInner_"),22);case 22:e.stopQueuingLatePhaseQueuedOperations();d.mimeType_&&shaka.device.DeviceFactory.getDevice().supportsAirPlay()&&shaka.util.MimeUtils.isHlsType(d.mimeType_)&&d.mediaSourceEngine_.addSecondarySource(d.assetUri_,d.mimeType_);u.jumpTo(14);break;case 23:return u.yield(k(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){goog.asserts.assert(c,
"We should know the mimeType by now!");return x.yield(d.srcEqualsInner_(n,c),0)})},"srcEqualsInner_"),14);case 14:d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Loaded));case 6:u.enterFinallyBlock();if(!e){u.jumpTo(25);break}return u.yield(e.destroy(),25);case 25:d.preloadNextUrl_=null;u.leaveFinallyBlock(0);break;case 5:v=u.enterCatchBlock();if(!v||v.code==shaka.util.Error.Code.LOAD_INTERRUPTED){u.jumpTo(27);break}return u.yield(d.unload(!1),27);case 27:throw v;}})};
shaka.Player.prototype.makeManifestAudioOnly_=function(){for(var a=(0,$jscomp.makeIterator)(this.manifest_.variants),b=a.next();!b.done;b=a.next())b=b.value,b.video&&(b.video.closeSegmentIndex(),b.video=null),b.bandwidth=b.audio&&b.audio.bandwidth?b.audio.bandwidth:0;this.manifest_.variants=this.manifest_.variants.filter(function(c){return c.audio})};
shaka.Player.prototype.unloadAndSavePreload=function(a,b){a=a===void 0?!0:a;b=b===void 0?!1:b;var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.nextAddress==1?e.yield(c.savePreload_(),2):e.nextAddress!=3?(d=e.yieldResult,e.yield(c.unload(a,b),3)):e.return(d)})};
shaka.Player.prototype.detachAndSavePreload=function(a,b){a=a===void 0?!1:a;b=b===void 0?!1:b;var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.nextAddress==1?e.yield(c.savePreload_(b),2):e.nextAddress!=3?(d=e.yieldResult,e.yield(c.detach(a),3)):e.return(d)})};
shaka.Player.prototype.savePreload_=function(a){a=a===void 0?!1:a;var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1){c=null;if(!(b.manifest_&&b.parser_&&b.parserFactory_&&b.assetUri_&&b.config_))return f.jumpTo(2);d=b.video_.currentTime;b.isLive()&&!a&&(d=null);return f.yield(b.makePreloadManager_(b.assetUri_,d,b.mimeType_,b.config_,!0,!1),3)}f.nextAddress!=2&&(c=f.yieldResult,b.createdPreloadManagers_.push(c),b.parser_&&b.parser_.setMediaElement&&
b.parser_.setMediaElement(null),(e=b.streamingEngine_?b.streamingEngine_.getCurrentVariant():null)&&c.setPrefetchVariant(e),c.attachManifest(b.manifest_,b.parser_,b.parserFactory_),c.attachAdaptationSetCriteria(b.currentAdaptationSetCriteria_),c.start(),b.manifest_=null,b.parser_=null,b.parserFactory_=null,b.abrManager_=null,b.abrManagerFactory_=null);return f.return(c)})};
shaka.Player.prototype.preload=function(a,b,c,d){b=b===void 0?null:b;var e=this,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return goog.asserts.assert(e.config_,"Config must not be null!"),f=e.defaultConfig_(),shaka.util.PlayerConfiguration.mergeConfigObjects(f,d||e.config_,e.defaultConfig_()),h.yield(e.preloadInner_(a,b,c,!1,f),2);if(g=h.yieldResult)g.start();else e.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,
shaka.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED));return h.return(g)})};shaka.Player.prototype.destroyAllPreloads=function(){var a=this,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)(a.createdPreloadManagers_);for(d=c.next();!d.done;d=c.next())e=d.value,e.isDestroyed()||b.push(e.destroy());a.createdPreloadManagers_=[];return f.yield(Promise.all(b),0)})};
shaka.Player.prototype.preloadInner_=function(a,b,c,d,e){d=d===void 0?!1:d;var f=this,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.nextAddress==1)return goog.asserts.assert(f.networkingEngine_,"Should have a net engine!"),goog.asserts.assert(f.config_,"Config must not be null!"),c?m.jumpTo(2):m.yield(f.guessMimeType_(a),3);m.nextAddress!=2&&(c=m.yieldResult);if(g=f.shouldUseSrcEquals_(a,c))return m.return(null);h=e||f.config_;k=!1;d&&f.video_&&f.video_.nodeName===
"AUDIO"&&(k=!0);l=f.makePreloadManager_(a,b,c||null,h,!d,k);l=d?l.then(function(n){n.markIsLoad();return n}):l.then(function(n){f.createdPreloadManagers_.push(n);return n});return m.return(l)})};
shaka.Player.prototype.makePreloadManager_=function(a,b,c,d,e,f){e=e===void 0?!0:e;f=f===void 0?!1:f;var g=this,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){if(C.nextAddress==1){goog.asserts.assert(g.networkingEngine_,"Must have net engine");h=null;k=shaka.util.ObjectUtils.cloneObject(d);f&&(k.manifest.disableVideo=!0);l=function(){goog.asserts.assert(h,"Must have preload manager");return h.hasBeenAttached()&&h.isDestroyed()?null:h};m=function(){return l()?
l().getConfiguration():g.config_};if(g.maxHwRes_.width!=Infinity||g.maxHwRes_.height!=Infinity||g.config_.ignoreHardwareResolution)return C.jumpTo(2);n=shaka.device.DeviceFactory.getDevice();goog.asserts.assert(n,"device must be non-null");return C.yield(n.detectMaxHardwareResolution(),3)}C.nextAddress!=2&&(p=C.yieldResult,g.maxHwRes_.width=p.width,g.maxHwRes_.height=p.height);q=new shaka.media.ManifestFilterer(k,g.maxHwRes_,null);r={networkingEngine:g.networkingEngine_,filter:function(y){var A,D;
return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){if(E.nextAddress==1)return E.yield(q.filterManifest(y),2);if(E.nextAddress!=4){A=E.yieldResult;if(!A)return E.jumpTo(0);D=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return E.yield(Promise.resolve(),4)}h.dispatchEvent(D);E.jumpToEnd()})},makeTextStreamsForClosedCaptions:function(y){return g.makeTextStreamsForClosedCaptions_(y)},onTimelineRegionAdded:function(y){h.getRegionTimeline().addRegion(y)},onEvent:function(y){return h.dispatchEvent(y)},
onError:function(y){return h.onError(y)},isLowLatencyMode:function(){return m().streaming.lowLatencyMode},updateDuration:function(){g.streamingEngine_&&h.hasBeenAttached()&&g.streamingEngine_.updateDuration()},newDrmInfo:function(y){var A=h.getDrmEngine(),D=A?A.getDrmInfo():null;D&&A.getMediaKeys()&&q.processDrmInfos(D.keySystem,y)},onManifestUpdated:function(){var y=shaka.util.FakeEvent.EventName.ManifestUpdated,A=(new Map).set("isLive",g.isLive());h.dispatchEvent(shaka.Player.makeEvent_(y,A));h.addQueuedOperation(!1,
function(){if(g.adManager_)g.adManager_.onManifestUpdated(g.isLive())})},getBandwidthEstimate:function(){return g.abrManager_.getBandwidthEstimate()},onMetadata:function(y,A,D,E){var F=y;if(y=="com.apple.hls.interstitial"||y=="com.apple.hls.overlay")F="com.apple.quicktime.HLS",y={startTime:A,endTime:D,values:E},g.adManager_&&(goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onHLSInterstitialMetadata(g,g.video_,y));E=(0,$jscomp.makeIterator)(E);y=E.next();for(var L={};!y.done;L={payload$jscomp$7:void 0},
y=E.next())L.payload$jscomp$7=y.value,L.payload$jscomp$7.name!="ID"&&h.addQueuedOperation(!1,function(K){return function(){g.addMetadataToRegionTimeline_(A,D,F,K.payload$jscomp$7)}}(L))},disableStream:function(y){return g.disableStream(y,g.config_.streaming.maxDisabledTime)},addFont:function(y,A){return g.addFont(y,A)}};t=new shaka.media.RegionTimeline(function(){return g.seekRange()});t.addEventListener("regionadd",function(y){var A=y.region;g.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionAdded,
A,h);h.addQueuedOperation(!1,function(){g.adManager_&&(g.adManager_.onDashTimedMetadata(A),goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onDASHInterstitialMetadata(g,g.video_,A))})});w=null;k.streaming.observeQualityChanges&&(w=new shaka.media.QualityObserver(function(){return g.getBufferedInfo()}),w.addEventListener("qualitychange",function(y){g.onMediaQualityChange_(y.quality,y.position)}),w.addEventListener("audiotrackchange",function(y){g.onMediaQualityChange_(y.quality,y.position,
!0)}));v=!0;u={netEngine:g.networkingEngine_,onError:function(y){return h.onError(y)},onKeyStatus:function(y){h.addQueuedOperation(!0,function(){if(g.drmEngine_)g.onKeyStatus_(y)})},onExpirationUpdated:function(y,A){var D=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ExpirationUpdated);h.dispatchEvent(D);if((D=h.getParser())&&D.onExpirationUpdated)D.onExpirationUpdated(y,A)},onEvent:function(y){h.dispatchEvent(y);y.type==shaka.util.FakeEvent.EventName.DrmSessionUpdate&&v&&(v=!1,y=Date.now()/
1E3-h.getStartTimeOfDRM(),(g.stats_||h.getStats()).setDrmTime(y),g.lcevcDec_&&g.lcevcDec_.hideCanvas())}};x=g.createNetworkingEngine(l);g.networkingEngine_.copyFiltersInto(x);z=function(){return g.createDrmEngine(u)};B={config:k,manifestPlayerInterface:r,regionTimeline:t,qualityObserver:w,createDrmEngine:z,manifestFilterer:q,networkingEngine:x,allowPrefetch:e};h=new shaka.media.PreloadManager(a,c,b,B);return C.return(h)})};
shaka.Player.prototype.guessMimeType_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1)return goog.asserts.assert(b.networkingEngine_,"Should have a net engine!"),c=b.config_.manifest.retryParameters,g.yield(shaka.net.NetworkingUtils.getMimeType(a,b.networkingEngine_,c),2);d=g.yieldResult;d=="application/x-mpegurl"&&(e=shaka.device.DeviceFactory.getDevice(),e.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&(d="application/vnd.apple.mpegurl"));
d=="video/quicktime"&&(f=shaka.device.DeviceFactory.getDevice(),f.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.CHROMIUM&&(d="video/mp4"));return g.return(d)})};
shaka.Player.prototype.shouldUseSrcEquals_=function(a,b){a=shaka.util.MimeUtils;if(!shaka.device.DeviceFactory.getDevice().supportsMediaSource())return!0;if(b){var c=(this.video_||shaka.util.Dom.anyMediaElement()).canPlayType(b)!="";if(!c)return!1;var d=shaka.media.ManifestParser.isSupported(b);if(!d)return!0;goog.asserts.assert(c&&d,"Both native and MSE playback should be possible!");if(a.isHlsType(b))return shaka.device.DeviceFactory.getDevice().getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&
(this.config_.drm.servers["com.apple.fps"]||this.config_.drm.servers["com.apple.fps.1_0"])?this.config_.streaming.useNativeHlsForFairPlay:this.config_.streaming.preferNativeHls;if(a.isDashType(b))return this.config_.streaming.preferNativeDash}return!1};
shaka.Player.prototype.createAndConfigureTextDisplayer_=function(a){var b=this.config_.textDisplayFactory;this.lastTextFactory_!==b||(a===void 0?0:a)?(a=this.textDisplayer_,this.textDisplayer_=b(),this.textDisplayer_.configure?this.textDisplayer_.configure(this.config_.textDisplayer):shaka.Deprecate.deprecateFeature(5,"Text displayer w/ configure",'Text displayer should have a "configure" method!'),this.textDisplayer_.setTextLanguage||shaka.Deprecate.deprecateFeature(5,"Text displayer w/ setTextLanguage",
'Text displayer should have a "setTextLanguage" method!'),a?(this.textDisplayer_.setTextVisibility(a.isTextVisible()),a.destroy().catch(function(){})):this.textDisplayer_.setTextVisibility(this.isTextVisible_),this.mediaSourceEngine_&&this.mediaSourceEngine_.setTextDisplayer(this.textDisplayer_),this.lastTextFactory_=b,this.streamingEngine_&&this.streamingEngine_.reloadTextStream()):this.textDisplayer_&&this.textDisplayer_.configure&&this.textDisplayer_.configure(this.config_.textDisplayer)};
shaka.Player.prototype.initializeMediaSourceEngineInner_=function(){var a=this,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return b=shaka.device.DeviceFactory.getDevice(),goog.asserts.assert(b.supportsMediaSource(),"We should not be initializing media source on a platform that does not support media source."),goog.asserts.assert(a.video_,"We should have a media element when initializing media source."),goog.asserts.assert(a.mediaSourceEngine_==null,
"We should not have a media source engine yet."),a.makeStateChangeEvent_("media-source"),a.config_.mediaSource.useSourceElements&&shaka.util.Dom.clearSourceFromVideo(a.video_),a.createAndConfigureTextDisplayer_(),goog.asserts.assert(a.textDisplayer_,"Text displayer should be created already"),c=a.createMediaSourceEngine(a.video_,a.textDisplayer_,{getKeySystem:function(){return a.keySystem()},onMetadata:function(g,h,k){a.processTimedMetadataMediaSrc_(g,h,k)},onEmsg:function(g){a.addEmsgToRegionTimeline_(g)},
onEvent:function(g){return a.dispatchEvent(g)},onManifestUpdate:function(){return a.onManifestUpdate_()}},a.lcevcDec_,a.config_.mediaSource),d=a.config_.manifest,e=d.segmentRelativeVttTiming,c.setSegmentRelativeVttTiming(e),f.yield(c.open(),2);a.mediaSourceEngine_=c;f.jumpToEnd()})};
shaka.Player.prototype.addBasicMediaListeners_=function(a,b){var c=this,d=function(){return c.updateStateHistory_()};this.loadEventManager_.listen(a,"playing",d);this.loadEventManager_.listen(a,"pause",d);this.loadEventManager_.listen(a,"ended",d);this.loadEventManager_.listen(a,"ratechange",function(){return c.onRateChange_()});a.remote&&(this.loadEventManager_.listen(a.remote,"connect",function(){if(c.streamingEngine_&&a.remote.state=="connected")c.onTextChanged_();c.onTracksChanged_()}),this.loadEventManager_.listen(a.remote,
"connecting",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.remote,"disconnect",function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.nextAddress==1)return c.streamingEngine_&&a.remote.state=="disconnected"?f.yield(c.streamingEngine_.resetMediaSource(),3):f.jumpTo(2);if(f.nextAddress!=2)c.onTextChanged_();c.onTracksChanged_();f.jumpToEnd()})}));a.audioTracks&&(this.loadEventManager_.listen(a.audioTracks,"addtrack",function(){return c.onTracksChanged_()}),
this.loadEventManager_.listen(a.audioTracks,"removetrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.audioTracks,"change",function(){return c.onTracksChanged_()}));a.videoTracks&&(this.loadEventManager_.listen(a.videoTracks,"addtrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.videoTracks,"removetrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.videoTracks,"change",function(){return c.onTracksChanged_()}));(a.webkitPresentationMode||
a.webkitSupportsFullscreen)&&this.loadEventManager_.listen(a,"webkitpresentationmodechanged",function(){c.videoContainer_&&c.createAndConfigureTextDisplayer_(!0)});if(a.textTracks){var e=function(){if(c.loadMode_===shaka.Player.LoadMode.SRC_EQUALS&&c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer)c.onTextChanged_();c.onTracksChanged_()};this.loadEventManager_.listen(a.textTracks,"addtrack",function(f){if(f.track)switch(f=f.track,goog.asserts.assert(f instanceof TextTrack,"Wrong track type!"),
f.kind){case "metadata":c.processTimedMetadataSrcEquals_(f);break;case "chapters":c.activateChaptersTrack_(f);break;default:e()}});this.loadEventManager_.listen(a.textTracks,"removetrack",e);this.loadEventManager_.listen(a.textTracks,"change",e)}a.preload!="none"&&this.loadEventManager_.listenOnce(a,"loadedmetadata",function(){var f=Date.now()/1E3-b;c.stats_.setLoadLatency(f)})};
shaka.Player.prototype.loadInner_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(M){switch(M.nextAddress){case 1:goog.asserts.assert(d.video_,"We should have a media element by now.");goog.asserts.assert(d.manifest_,"The manifest should already be parsed.");goog.asserts.assert(d.assetUri_,"We should have an asset uri by now.");goog.asserts.assert(d.abrManager_,"We should have an abr manager by now.");
d.makeStateChangeEvent_("load");e=d.video_;d.playRateController_=new shaka.media.PlayRateController({getRate:function(){return e.playbackRate},getDefaultRate:function(){return e.defaultPlaybackRate},setRate:function(H){e.playbackRate=H},movePlayhead:function(H){e.currentTime+=H}});d.addBasicMediaListeners_(e,a);"onchange"in window.screen&&d.loadEventManager_.listen(window.screen,"change",function(){if(d.currentAdaptationSetCriteria_.getConfiguration){var H=d.currentAdaptationSetCriteria_.getConfiguration();
H.hdrLevel=="AUTO"?d.updateAbrManagerVariants_():d.config_.preferredVideoHdrLevel=="AUTO"&&d.config_.abr.enabled&&(H.hdrLevel="AUTO",d.currentAdaptationSetCriteria_.configure(H),d.updateAbrManagerVariants_())}});f=!1;g=(0,$jscomp.makeIterator)(d.manifest_.variants);for(h=g.next();!h.done;h=g.next())k=h.value,(l=k.video&&k.video.dependencyStream)&&(f=shaka.lcevc.Dec.isStreamSupported(l));d.setupLcevc_(d.config_,f);d.currentTextLanguage_=d.config_.preferredTextLanguage;d.currentTextRole_=d.config_.preferredTextRole;
d.currentTextForced_=d.config_.preferForcedSubs;shaka.Player.applyPlayRange_(d.manifest_.presentationTimeline,d.config_.playRangeStart,d.config_.playRangeEnd);d.abrManager_.init(function(H,P,Q){return d.switch_(H,P,Q)});d.abrManager_.setMediaElement(e);d.abrManager_.setCmsdManager(d.cmsdManager_);d.streamingEngine_=d.createStreamingEngine();d.streamingEngine_.configure(d.config_.streaming);d.loadMode_=shaka.Player.LoadMode.MEDIA_SOURCE;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Streaming));
m=b;case 2:p=d.streamingEngine_.getCurrentVariant();p||m||(m=d.chooseVariant_(!0),goog.asserts.assert(m,"Must choose an initial variant!"));q=[];n=p||m;r=(0,$jscomp.makeIterator)([n.video,n.audio]);for(t=r.next();!t.done;t=r.next())(w=t.value)&&!w.segmentIndex&&(q.push(w.createSegmentIndex()),w.dependencyStream&&q.push(w.dependencyStream.createSegmentIndex()));if(!(q.length>0)){M.jumpTo(4);break}return M.yield(Promise.all(q),4);case 4:if(!n||n.disabledUntilTime!=0){M.jumpTo(2);break}if(d.parser_&&
d.parser_.onInitialVariantChosen)d.parser_.onInitialVariantChosen(n);d.manifest_.isLowLatency&&(d.config_.streaming.lowLatencyMode?d.configure(d.lowLatencyConfig_):shaka.log.alwaysWarn("Low-latency live stream detected, but low-latency streaming mode is not enabled in Shaka Player. Set streaming.lowLatencyMode configuration to true, and see https://bit.ly/3clctcj for details."));d.cmcdManager_&&(d.cmcdManager_.setLowLatency(d.manifest_.isLowLatency&&d.config_.streaming.lowLatencyMode),d.cmcdManager_.setStartTimeOfLoad(a*
1E3));shaka.Player.applyPlayRange_(d.manifest_.presentationTimeline,d.config_.playRangeStart,d.config_.playRangeEnd);d.streamingEngine_.applyPlayRange(d.config_.playRangeStart,d.config_.playRangeEnd);d.fullyLoaded_=!0;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.CanUpdateStartTime));v=function(H){d.playhead_=d.createPlayhead(H);d.playheadObservers_=d.createPlayheadObserversForMSE_(H);d.startBufferManagement_(e,!1)};d.config_.streaming.startAtSegmentBoundary||(u=d.startTime_,
u==null&&d.manifest_.startTime&&(u=d.manifest_.startTime),v(u));if(p){M.jumpTo(7);break}goog.asserts.assert(m,"Must have chosen an initial variant!");if(!d.config_.streaming.startAtSegmentBoundary){M.jumpTo(8);break}x=d.manifest_.presentationTimeline;d.startTime_ instanceof Date&&(B=x.getInitialProgramDateTime()||x.getPresentationStartTime(),goog.asserts.assert(B!=null,"Presentation start time should not be null!"),C=d.startTime_.getTime()/1E3-B,C!=null&&(z=C));z==null&&(z=typeof d.startTime_==="number"?
d.startTime_:d.video_.currentTime);d.startTime_==null&&d.manifest_.startTime&&(z=d.manifest_.startTime);y=x.getSeekRangeStart();A=x.getSeekRangeEnd();z<y?z=y:z>A&&(z=A);return M.yield(d.adjustStartTime_(m,z),9);case 9:D=M.yieldResult,v(D);case 8:d.switchVariant_(m,!0,!1,0);case 7:return d.playhead_.ready(),E=d.getTextTracks().find(function(H){return H.active}),E||((F=d.chooseTextStream_())&&d.addTextStreamToSwitchHistory_(F,!0),m&&d.setInitialTextState_(m,F),F&&d.shouldStreamText_()&&(d.streamingEngine_.switchTextStream(F),
d.setTextDisplayerLanguage_())),M.yield(d.streamingEngine_.start(c),10);case 10:d.config_.abr.enabled&&(d.abrManager_.enable(),d.onAbrStatusChanged_());d.onTracksChanged_();L=d.manifest_.variants.some(function(H){return H.primary});d.config_.preferredAudioLanguage||L||shaka.log.warning("No preferred audio language set.  We have chosen an arbitrary language initially");if((K=d.isLive())&&(d.config_.streaming.liveSync&&d.config_.streaming.liveSync.enabled||d.manifest_.serviceDescription||d.config_.streaming.liveSync.panicMode)||
d.config_.streaming.vodDynamicPlaybackRate)J=function(){return d.onTimeUpdate_()},d.loadEventManager_.listen(e,"timeupdate",J);K||(I=function(){return d.onVideoProgress_()},d.loadEventManager_.listen(e,"timeupdate",I),d.onVideoProgress_(),d.manifest_.nextUrl&&(d.config_.streaming.preloadNextUrlWindow>0&&(G=function(){var H;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.nextAddress==1){H=d.seekRange().end-d.video_.currentTime;if(isNaN(H)||!(H<=d.config_.streaming.preloadNextUrlWindow))return P.jumpTo(0);
d.loadEventManager_.unlisten(e,"timeupdate",G);goog.asserts.assert(d.manifest_.nextUrl,"this.manifest_.nextUrl should be valid.");return P.yield(d.preload(d.manifest_.nextUrl),4)}d.preloadNextUrl_=P.yieldResult;P.jumpToEnd()})},d.loadEventManager_.listen(e,"timeupdate",G)),d.loadEventManager_.listen(e,"ended",function(){d.load(d.preloadNextUrl_||d.manifest_.nextUrl)})));if(d.adManager_)d.adManager_.onManifestUpdated(K);M.jumpToEnd()}})};
shaka.Player.prototype.initializeSrcEqualsDrmInner_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){return f.nextAddress==1?(goog.asserts.assert(b.networkingEngine_,"|onInitializeSrcEqualsDrm_| should never be called after |destroy|"),goog.asserts.assert(b.config_,"|onInitializeSrcEqualsDrm_| should never be called after |destroy|"),c=Date.now()/1E3,d=!0,b.drmEngine_=b.createDrmEngine({netEngine:b.networkingEngine_,onError:function(g){b.onError_(g)},
onKeyStatus:function(g){},onExpirationUpdated:function(g,h){g=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ExpirationUpdated);b.dispatchEvent(g)},onEvent:function(g){b.dispatchEvent(g);g.type==shaka.util.FakeEvent.EventName.DrmSessionUpdate&&d&&(d=!1,g=Date.now()/1E3-c,b.stats_.setDrmTime(g))}}),b.drmEngine_.configure(b.config_.drm),e=shaka.util.StreamUtils.createEmptyVariant([a]),b.drmEngine_.setSrcEquals(!0),f.yield(b.drmEngine_.initForPlayback([e],[]),2)):f.yield(b.drmEngine_.attach(b.video_),
0)})};
shaka.Player.prototype.srcEqualsInner_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.nextAddress){case 1:c.makeStateChangeEvent_("src-equals");goog.asserts.assert(c.video_,"We should have a media element when loading.");goog.asserts.assert(c.assetUri_,"We should have a valid uri when loading.");d=c.video_;c.playhead_=new shaka.media.SrcEqualsPlayhead(d);e=!1;c.cleanupOnUnload_.push(function(){e=!0});c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.CanUpdateStartTime));c.startTime_!=
null&&c.playhead_.setStartTime(c.startTime_);c.playheadObservers_=c.createPlayheadObserversForSrcEquals_(c.startTime_||0);c.playRateController_=new shaka.media.PlayRateController({getRate:function(){return d.playbackRate},getDefaultRate:function(){return d.defaultPlaybackRate},setRate:function(w){d.playbackRate=w},movePlayhead:function(w){d.currentTime+=w}});c.startBufferManagement_(d,!0);d.textTracks&&(c.createAndConfigureTextDisplayer_(),f=function(w){if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer)){var v=
c.getFilteredTextTracks_().find(function(u){return u.mode!=="disabled"});v&&(v.mode=w?"showing":"hidden");c.textDisplayer_ instanceof shaka.text.SimpleTextDisplayer&&(v=c.getGeneratedTextTrack_())&&(v.mode=!w&&c.textDisplayer_.isTextVisible()?"showing":"hidden")}},c.loadEventManager_.listen(d,"enterpictureinpicture",function(){return f(!0)}),c.loadEventManager_.listen(d,"leavepictureinpicture",function(){return f(!1)}),d.remote?(c.loadEventManager_.listen(d.remote,"connect",function(){return f(!1)}),
c.loadEventManager_.listen(d.remote,"connecting",function(){return f(!1)}),c.loadEventManager_.listen(d.remote,"disconnect",function(){return f(!1)})):"webkitCurrentPlaybackTargetIsWireless"in d&&c.loadEventManager_.listen(d,"webkitcurrentplaybacktargetiswirelesschanged",function(){return f(!1)}),g=d,(g.webkitPresentationMode||g.webkitSupportsFullscreen)&&c.loadEventManager_.listen(g,"webkitpresentationmodechanged",function(){g.webkitPresentationMode?f(g.webkitPresentationMode!=="inline"):g.webkitSupportsFullscreen&&
f(g.webkitDisplayingFullscreen)}));c.addBasicMediaListeners_(d,a);h=c.cmcdManager_.appendSrcData(c.assetUri_,b);!h.includes("#t=")&&(c.config_.playRangeStart>0||isFinite(c.config_.playRangeEnd))&&(h+="#t=",c.config_.playRangeStart>0&&(h+=c.config_.playRangeStart),isFinite(c.config_.playRangeEnd)&&(h+=","+c.config_.playRangeEnd));if(!c.mediaSourceEngine_){t.jumpTo(2);break}return t.yield(c.mediaSourceEngine_.destroy(),3);case 3:c.mediaSourceEngine_=null;case 2:return shaka.util.Dom.clearSourceFromVideo(d),
d.src=h,k=shaka.device.DeviceFactory.getDevice(),k.getDeviceType()==shaka.device.IDevice.DeviceType.TV&&d.load(),d.preload!="none"&&!d.autoplay&&shaka.util.MimeUtils.isHlsType(b)&&k.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&d.load(),c.loadMode_=shaka.Player.LoadMode.SRC_EQUALS,c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Streaming)),l=new shaka.util.PublicPromise,shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_METADATA,c.loadEventManager_,
function(){c.playhead_.ready();c.mimeType_&&shaka.util.MimeUtils.isHlsType(c.mimeType_)||l.resolve()}),m=function(){return new Promise(function(w){var v=new shaka.util.Timer(w);c.loadEventManager_.listen(d.textTracks,"change",function(){return v.tickAfter(.5)});v.tickAfter(.5)})},shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_CURRENT_DATA,c.loadEventManager_,function(){var w,v,u,x,z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){if(B.nextAddress==1)return B.yield(m(),
2);if(e)return B.return();c.setupPreferredAudioOnSrc_();w=c.getFilteredTextTracks_();w.some(function(C){return C.mode==="showing"})&&(c.isTextVisible_=!0,c.textDisplayer_.setTextVisibility(!0));if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer))for(w.length&&(c.textDisplayer_.enableTextDisplayer?c.textDisplayer_.enableTextDisplayer():shaka.Deprecate.deprecateFeature(5,"Text displayer w/ enableTextDisplayer",'Text displayer should have a "enableTextDisplayer" method')),v=!1,u=(0,$jscomp.makeIterator)(w),
x=u.next();!x.done;x=u.next())z=x.value,z.mode!=="disabled"&&(v?(z.mode="disabled",shaka.log.alwaysWarn("Found more than one enabled text track, disabling it",z)):(c.enableNativeTrack_(z),v=!0));c.setupPreferredTextOnSrc_();c.mimeType_&&shaka.util.MimeUtils.isHlsType(c.mimeType_)&&l.resolve();B.jumpToEnd()})}),d.error?l.reject(c.videoErrorToShakaError_()):d.preload=="none"&&(shaka.log.alwaysWarn('With <video preload="none">, the browser will not load anything until play() is called. We are unable to measure load latency in a meaningful way, and we cannot provide track info yet. Please do not use preload="none" with Shaka Player.'),
l.resolve()),c.loadEventManager_.listenOnce(d,"error",function(){l.reject(c.videoErrorToShakaError_())}),t.yield(shaka.util.Functional.promiseWithTimeout(c.config_.streaming.loadTimeout,l),4);case 4:if((n=c.isLive())&&(c.config_.streaming.liveSync&&c.config_.streaming.liveSync.enabled||c.config_.streaming.liveSync.panicMode)||c.config_.streaming.vodDynamicPlaybackRate)p=function(){return c.onTimeUpdate_()},c.loadEventManager_.listen(d,"timeupdate",p);n||(q=function(){return c.onVideoProgress_()},
c.loadEventManager_.listen(d,"timeupdate",q),c.onVideoProgress_());c.adManager_&&(c.adManager_.onManifestUpdated(n),n&&(r=c.seekRange().end,c.loadEventManager_.listen(d,"progress",function(){var w=c.seekRange().end;r!=w&&(c.adManager_.onManifestUpdated(c.isLive()),r=w)})));c.fullyLoaded_=!0;t.jumpToEnd()}})};shaka.Player.prototype.setupPreferredAudioOnSrc_=function(){var a=this.config_.preferredAudioLanguage;a!=""&&this.selectAudioLanguage(a,this.config_.preferredAudioRole)};
shaka.Player.prototype.setupPreferredTextOnSrc_=function(){var a=this.config_.preferredTextLanguage;a!=""&&this.selectTextLanguage(a,this.config_.preferredTextRole,this.config_.preferForcedSubs)};
shaka.Player.prototype.processTimedMetadataSrcEquals_=function(a){var b=this;if(a.kind=="metadata"){a.mode="hidden";this.loadEventManager_.listen(a,"cuechange",function(){if(a.activeCues)for(var d=(0,$jscomp.makeIterator)(a.activeCues),e=d.next();!e.done;e=d.next())if(e=e.value,b.addMetadataToRegionTimeline_(e.startTime,e.endTime,e.type,e.value),b.adManager_)b.adManager_.onCueMetadataChange(e.value);if(a.cues){d=[];e=(0,$jscomp.makeIterator)(a.cues);for(var f=e.next(),g={};!f.done;g={cue$jscomp$42:void 0},
f=e.next())g.cue$jscomp$42=f.value,g.cue$jscomp$42.type=="com.apple.quicktime.HLS"&&g.cue$jscomp$42.startTime!=null&&(f=d.find(function(h){return function(k){return k.startTime==h.cue$jscomp$42.startTime&&k.endTime==h.cue$jscomp$42.endTime}}(g)),f||(f={startTime:g.cue$jscomp$42.startTime,endTime:g.cue$jscomp$42.endTime,values:[]},d.push(f)),f.values.push(g.cue$jscomp$42.value));d=(0,$jscomp.makeIterator)(d);for(e=d.next();!e.done;e=d.next())e=e.value,e.values.some(function(h){return h.key=="X-ASSET-URI"||
h.key=="X-ASSET-LIST"})&&b.adManager_&&(g=e.startTime==0&&!b.isLive(),e.values.push({key:"CUE",description:"",data:g?"ONCE,PRE":"ONCE",mimeType:null,pictureType:null}),goog.asserts.assert(b.video_,"Must have video"),b.adManager_.onHLSInterstitialMetadata(b,b.video_,e))}});var c=(new shaka.util.Timer(function(){var d=b.getMetadataTracks_();d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e.value.mode="hidden"})).tickNow().tickAfter(.5);this.cleanupOnUnload_.push(function(){c.stop()})}};
shaka.Player.prototype.processTimedMetadataMediaSrc_=function(a,b,c){a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())if(d=d.value,d.data&&typeof d.cueTime=="number"&&d.frames){var e=d.cueTime+b,f=c;f&&e>f&&(f=e);for(var g=(0,$jscomp.makeIterator)(d.frames),h=g.next();!h.done;h=g.next())this.addMetadataToRegionTimeline_(e,f,"org.id3",h.value);if(this.adManager_)this.adManager_.onHlsTimedMetadata(d,e)}};
shaka.Player.prototype.dispatchMetadataEvent_=function(a,b){a=(new Map).set("startTime",a.startTime).set("endTime",a.endTime).set("metadataType",a.schemeIdUri).set("payload",a.payload);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};
shaka.Player.prototype.addMetadataToRegionTimeline_=function(a,b,c,d){this.metadataRegionTimeline_&&(goog.asserts.assert(!b||a<=b,"Metadata start time should be less or equal to the end time!"),a={schemeIdUri:c,startTime:a,endTime:b||Infinity,id:"",payload:d},a.id=JSON.stringify(a),this.metadataRegionTimeline_.addRegion(a))};
shaka.Player.prototype.dispatchEmsgEvent_=function(a){var b=shaka.util.FakeEvent.EventName.Emsg;a=a.emsg;a=(new Map).set("detail",a);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};shaka.Player.prototype.addEmsgToRegionTimeline_=function(a){this.emsgRegionTimeline_&&this.emsgRegionTimeline_.addRegion({schemeIdUri:a.schemeIdUri,startTime:a.startTime,endTime:a.endTime,id:String(a.id),emsg:a})};
shaka.Player.prototype.activateChaptersTrack_=function(a){if(a&&a.kind=="chapters"){a.mode="hidden";var b=(new shaka.util.Timer(function(){a.mode="hidden"})).tickNow().tickAfter(.5);this.cleanupOnUnload_.push(function(){b.stop()})}};shaka.Player.prototype.releaseAllMutexes=function(){this.mutex_.releaseAll()};shaka.Player.prototype.createDrmEngine=function(a){return new shaka.drm.DrmEngine(a)};
shaka.Player.prototype.createNetworkingEngine=function(a){var b=this;a||(a=function(){return null});var c=function(f){a()?a().addQueuedOperation(!0,f):f()},d=function(f){a()?a().dispatchEvent(f):b.dispatchEvent(f)},e=new shaka.net.NetworkingEngine(function(f,g,h,k,l){c(function(){b.abrManager_&&b.abrManager_.segmentDownloaded(f,g,h,k,l)})},function(f,g,h){var k=shaka.util.FakeEvent.EventName.DownloadHeadersReceived;g=(new Map).set("headers",f).set("request",g).set("requestType",h);d(shaka.Player.makeEvent_(k,
g));c(function(){b.cmsdManager_&&b.cmsdManager_.processHeaders(f)})},function(f,g){var h=shaka.util.FakeEvent.EventName.DownloadCompleted;f=(new Map).set("request",f).set("response",g);d(shaka.Player.makeEvent_(h,f))},function(f,g,h,k){var l=shaka.util.FakeEvent.EventName.DownloadFailed;f=(new Map).set("request",f).set("error",g).set("httpResponseCode",h).set("aborted",k);d(shaka.Player.makeEvent_(l,f))},function(f,g,h){c(function(){b.cmcdManager_&&b.cmcdManager_.applyRequestData(f,g,h)})},function(f,
g,h,k){f=a()?a().getParser():b.parser_;f&&f.banLocation&&f.banLocation(k)},function(f,g,h){if(g.data){var k=g.data.byteLength;var l=a()?a().getStats():b.stats_;l&&(l.addBytesDownloaded(k),f===shaka.net.NetworkingEngine.RequestType.MANIFEST&&l.setManifestSize(k));b.cmcdManager_.applyResponseData(f,g,h)}});e.configure(this.config_.networking);return e};
shaka.Player.prototype.createPlayhead=function(a){var b=this;goog.asserts.assert(this.manifest_,"Must have manifest");goog.asserts.assert(this.video_,"Must have video");return new shaka.media.MediaSourcePlayhead(this.video_,this.manifest_,this.config_.streaming,a,function(){return b.onSeek_()},function(c){return b.dispatchEvent(c)})};
shaka.Player.prototype.createPlayheadObserversForMSE_=function(a){var b=this;goog.asserts.assert(this.manifest_,"Must have manifest");goog.asserts.assert(this.regionTimeline_,"Must have region timeline");goog.asserts.assert(this.metadataRegionTimeline_,"Must have metadata region timeline");goog.asserts.assert(this.emsgRegionTimeline_,"Must have emsg region timeline");goog.asserts.assert(this.video_,"Must have video element");var c=this.isLive()||typeof a==="number"&&a>0;a=new shaka.media.RegionObserver(this.regionTimeline_,
c);a.addEventListener("enter",function(f){b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionEnter,f.region)});a.addEventListener("exit",function(f){b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionExit,f.region)});a.addEventListener("skip",function(f){var g=f.region;f.seeking||(b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionEnter,g),b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionExit,g))});var d=new shaka.media.RegionObserver(this.metadataRegionTimeline_,
c);d.addEventListener("enter",function(f){b.dispatchMetadataEvent_(f.region,shaka.util.FakeEvent.EventName.Metadata)});c=new shaka.media.RegionObserver(this.emsgRegionTimeline_,c);c.addEventListener("enter",function(f){b.dispatchEmsgEvent_(f.region)});var e=new shaka.media.PlayheadObserverManager(this.video_);e.manage(a);e.manage(d);e.manage(c);this.qualityObserver_&&e.manage(this.qualityObserver_);return e};
shaka.Player.prototype.createPlayheadObserversForSrcEquals_=function(a){var b=this;goog.asserts.assert(this.metadataRegionTimeline_,"Must have metadata region timeline");goog.asserts.assert(this.video_,"Must have video element");a=new shaka.media.RegionObserver(this.metadataRegionTimeline_,a instanceof Date||a>0);a.addEventListener("enter",function(d){b.dispatchMetadataEvent_(d.region,shaka.util.FakeEvent.EventName.Metadata)});var c=new shaka.media.PlayheadObserverManager(this.video_);c.manage(a);
return c};
shaka.Player.prototype.startBufferManagement_=function(a,b){var c=this,d=shaka.util.MediaElementEvent;goog.asserts.assert(!this.bufferObserver_,"No buffering observer should exist before initialization.");goog.asserts.assert(!this.bufferPoller_,"No buffer timer should exist before initialization.");this.bufferObserver_=new shaka.media.BufferingObserver(1,2);this.bufferObserver_.setState(shaka.media.BufferingObserver.State.STARVING);this.updateBufferingSettings_();this.updateBufferState_();this.bufferPoller_=
new shaka.util.Timer(function(){c.pollBufferState_()});this.config_.streaming.rebufferingGoal&&this.bufferPoller_.tickEvery(.25);this.loadEventManager_.listen(a,d.WAITING,function(e){return c.pollBufferState_(d.WAITING)});this.loadEventManager_.listen(a,d.CAN_PLAY_THROUGH,function(e){return c.pollBufferState_(d.CAN_PLAY_THROUGH)});this.loadEventManager_.listen(a,d.PLAYING,function(e){return c.pollBufferState_(d.PLAYING)});this.loadEventManager_.listen(a,d.SEEKED,function(e){return c.pollBufferState_(d.SEEKED)});
b&&(this.loadEventManager_.listen(a,d.STALLED,function(e){return c.pollBufferState_(d.STALLED)}),this.loadEventManager_.listen(a,d.PROGRESS,function(e){return c.pollBufferState_(d.PROGRESS)}),this.loadEventManager_.listen(a,d.TIME_UPDATE,function(e){return c.pollBufferState_(d.TIME_UPDATE)}))};shaka.Player.prototype.updateBufferingSettings_=function(){var a=this.config_.streaming.rebufferingGoal;this.bufferObserver_.setThresholds(a,Math.min(shaka.Player.TYPICAL_BUFFERING_THRESHOLD_,a/2))};
shaka.Player.prototype.pollBufferState_=function(a){goog.asserts.assert(this.video_,"Need a media element to update the buffering observer");goog.asserts.assert(this.bufferObserver_,"Need a buffering observer to update");if(this.config_.streaming.rebufferingGoal){a=this.mediaSourceEngine_?this.mediaSourceEngine_.ended():!1;a=this.isEnded()||a||this.playhead_.isBufferedToEnd();var b=shaka.media.TimeRangesUtils.bufferedAheadOf(this.video_.buffered,this.video_.currentTime);this.bufferObserver_.update(b,
a)&&this.updateBufferState_()}else a&&this.bufferObserver_.reportEvent(a)&&this.updateBufferState_()};shaka.Player.prototype.createMediaSourceEngine=function(a,b,c,d,e){return new shaka.media.MediaSourceEngine(a,b,c,e,d)};shaka.Player.prototype.createCmcd_=function(){return new shaka.util.CmcdManager(this,this.config_.cmcd)};shaka.Player.prototype.createCmsd_=function(){return new shaka.util.CmsdManager(this.config_.cmsd)};
shaka.Player.prototype.createStreamingEngine=function(){var a=this;goog.asserts.assert(this.abrManager_&&this.mediaSourceEngine_&&this.manifest_&&this.video_,"Must not be destroyed");return new shaka.media.StreamingEngine(this.manifest_,{getPresentationTime:function(){return a.playhead_?a.playhead_.getTime():0},getBandwidthEstimate:function(){return a.abrManager_.getBandwidthEstimate()},getPlaybackRate:function(){return a.getPlaybackRate()},video:this.video_,mediaSourceEngine:this.mediaSourceEngine_,
netEngine:this.networkingEngine_,onError:function(b){return a.onError_(b)},onEvent:function(b){return a.dispatchEvent(b)},onSegmentAppended:function(b,c,d){a.onSegmentAppended_(b.startTime,b.endTime,c.type,d);a.abrManager_&&c.fastSwitching&&b.isPartial()&&b.isLastPartial()&&a.abrManager_.trySuggestStreams()},onInitSegmentAppended:function(b,c){(c=c.getMediaQuality())&&a.qualityObserver_&&a.qualityObserver_.addMediaQualityChange(c,b)},beforeAppendSegment:function(b,c){return a.drmEngine_.parseInbandPssh(b,
c)},disableStream:function(b,c){return a.disableStream(b,c)},shouldPrefetchNextSegment:function(b,c){return a.config_.abr.enabled&&c.fastSwitching&&b.isPartial()&&b.isLastPartial()?!1:!0}})};
shaka.Player.prototype.configure=function(a,b){goog.asserts.assert(this.config_,"Config must not be null!");goog.asserts.assert(typeof a=="object"||arguments.length==2,"String configs should have values!");var c=this.getConfiguration();arguments.length==2&&typeof a=="string"&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));goog.asserts.assert(typeof a=="object","Should be an object!");"preferredVariantRole"in a&&(shaka.Deprecate.deprecateFeature(5,"preferredVariantRole configuration","Please Use preferredAudioRole instead."),
a.preferredAudioRole=a.preferredVariantRole,delete a.preferredVariantRole);a.streaming&&"forceTransmuxTS"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceTransmuxTS configuration","Please Use mediaSource.forceTransmux instead."),a.mediaSource=a.mediaSource||{},a.mediaSource.mediaSource=a.streaming.forceTransmuxTS,delete a.streaming.forceTransmuxTS);a.streaming&&"forceTransmux"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceTransmux configuration","Please Use mediaSource.forceTransmux instead."),
a.mediaSource=a.mediaSource||{},a.mediaSource.mediaSource=a.streaming.forceTransmux,delete a.streaming.forceTransmux);if(a.streaming&&"useNativeHlsOnSafari"in a.streaming){shaka.Deprecate.deprecateFeature(5,"streaming.useNativeHlsOnSafari configuration","Please Use streaming.useNativeHlsForFairPlay or streaming.preferNativeHls instead.");var d=shaka.device.DeviceFactory.getDevice();a.streaming.preferNativeHls=a.streaming.useNativeHlsOnSafari&&d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT;
delete a.streaming.useNativeHlsOnSafari}a.streaming&&typeof a.streaming.liveSync=="boolean"&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSync","Please Use streaming.liveSync.enabled instead."),d=a.streaming.liveSync,a.streaming.liveSync={},a.streaming.liveSync.enabled=d);if(a.streaming&&!(a.streaming.liveSync&&"targetLatency"in a.streaming.liveSync)&&("liveSyncMinLatency"in a.streaming||"liveSyncMaxLatency"in a.streaming)){d=a.streaming.liveSyncMinLatency||0;var e=Math.abs((a.streaming.liveSyncMaxLatency||
1)-d)/2;a.streaming.liveSync=a.streaming.liveSync||{};a.streaming.liveSync.targetLatency=d+e;a.streaming.liveSync.targetLatencyTolerance=e}a.streaming&&"liveSyncMaxLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncMaxLatency","Please Use streaming.liveSync.targetLatency and streaming.liveSync.targetLatencyTolerance instead. Or, set the values in your DASH manifest"),delete a.streaming.liveSyncMaxLatency);a.streaming&&"liveSyncMinLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,
"streaming.liveSyncMinLatency","Please Use streaming.liveSync.targetLatency and streaming.liveSync.targetLatencyTolerance instead. Or, set the values in your DASH manifest"),delete a.streaming.liveSyncMinLatency);a.streaming&&"liveSyncTargetLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncTargetLatency","Please Use streaming.liveSync.targetLatency instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.targetLatency=a.streaming.liveSyncTargetLatency,
delete a.streaming.liveSyncTargetLatency);a.streaming&&"liveSyncTargetLatencyTolerance"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncTargetLatencyTolerance","Please Use streaming.liveSync.targetLatencyTolerance instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.targetLatencyTolerance=a.streaming.liveSyncTargetLatencyTolerance,delete a.streaming.liveSyncTargetLatencyTolerance);a.streaming&&"liveSyncPlaybackRate"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,
"streaming.liveSyncPlaybackRate","Please Use streaming.liveSync.maxPlaybackRate instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.maxPlaybackRate=a.streaming.liveSyncPlaybackRate,delete a.streaming.liveSyncPlaybackRate);a.streaming&&"liveSyncMinPlaybackRate"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncMinPlaybackRate","Please Use streaming.liveSync.minPlaybackRate instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.minPlaybackRate=
a.streaming.liveSyncMinPlaybackRate,delete a.streaming.liveSyncMinPlaybackRate);a.streaming&&"liveSyncPanicMode"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncPanicMode","Please Use streaming.liveSync.panicMode instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.panicMode=a.streaming.liveSyncPanicMode,delete a.streaming.liveSyncPanicMode);a.streaming&&"liveSyncPanicThreshold"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncPanicThreshold",
"Please Use streaming.liveSync.panicThreshold instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.panicThreshold=a.streaming.liveSyncPanicThreshold,delete a.streaming.liveSyncPanicThreshold);if(a.mediaSource&&"sourceBufferExtraFeatures"in a.mediaSource){shaka.Deprecate.deprecateFeature(5,"mediaSource.sourceBufferExtraFeatures configuration","Please Use mediaSource.addExtraFeaturesToSourceBuffer() instead.");var f=a.mediaSource.sourceBufferExtraFeatures;a.mediaSource.addExtraFeaturesToSourceBuffer=
function(){return f};delete a.mediaSource.sourceBufferExtraFeatures}a.manifest&&a.manifest.hls&&"useSafariBehaviorForLive"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.useSafariBehaviorForLive configuration","Please Use liveSync config to keep on live Edge instead."),delete a.manifest.hls.useSafariBehaviorForLive);a.streaming&&"parsePrftBox"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.parsePrftBox configuration","Now fired without needing a configuration."),
delete a.streaming.parsePrftBox);a.manifest&&a.manifest.dash&&"enableAudioGroups"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.enableAudioGroups configuration","Please Use manifest.enableAudioGroups instead."),a.manifest.enableAudioGroups=a.manifest.dash.enableAudioGroups,delete a.manifest.dash.enableAudioGroups);a.streaming&&"dispatchAllEmsgBoxes"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.dispatchAllEmsgBoxes configuration","Please Use mediaSource.dispatchAllEmsgBoxes instead."),
a.mediaSource=a.mediaSource||{},a.mediaSource.dispatchAllEmsgBoxes=a.streaming.dispatchAllEmsgBoxes,delete a.streaming.dispatchAllEmsgBoxes);a.streaming&&"autoLowLatencyMode"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.autoLowLatencyMode configuration","Please Use streaming.lowLatencyMode instead."),a.streaming.lowLatencyMode=a.streaming.autoLowLatencyMode,delete a.streaming.autoLowLatencyMode);a.manifest&&a.manifest.dash&&"ignoreSupplementalCodecs"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,
"manifest.dash.ignoreSupplementalCodecs configuration","Please Use manifest.ignoreSupplementalCodecs instead."),a.manifest.ignoreSupplementalCodecs=a.manifest.dash.ignoreSupplementalCodecs,delete a.manifest.dash.ignoreSupplementalCodecs);a.manifest&&a.manifest.hls&&"ignoreSupplementalCodecs"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.ignoreSupplementalCodecs configuration","Please Use manifest.ignoreSupplementalCodecs instead."),a.manifest.ignoreSupplementalCodecs=a.manifest.hls.ignoreSupplementalCodecs,
delete a.manifest.hls.ignoreSupplementalCodecs);a.manifest&&a.manifest.dash&&"updatePeriod"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.updatePeriod configuration","Please Use manifest.updatePeriod instead."),a.manifest.updatePeriod=a.manifest.dash.updatePeriod,delete a.manifest.dash.updatePeriod);a.manifest&&a.manifest.hls&&"updatePeriod"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.updatePeriod configuration","Please Use manifest.updatePeriod instead."),
a.manifest.updatePeriod=a.manifest.hls.updatePeriod,delete a.manifest.hls.updatePeriod);a.manifest&&a.manifest.dash&&"ignoreDrmInfo"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.ignoreDrmInfo configuration","Please Use manifest.ignoreDrmInfo instead."),a.manifest.ignoreDrmInfo=a.manifest.dash.ignoreDrmInfo,delete a.manifest.dash.ignoreDrmInfo);if(a.drm&&a.drm.advanced){d=!1;for(var g in a.drm.advanced){var h=a.drm.advanced[g];e=h.videoRobustness;h=h.audioRobustness;"videoRobustness"in
a.drm.advanced[g]&&!Array.isArray(a.drm.advanced[g].videoRobustness)&&(a.drm.advanced[g].videoRobustness=[e],d=!0);"audioRobustness"in a.drm.advanced[g]&&!Array.isArray(a.drm.advanced[g].audioRobustness)&&(a.drm.advanced[g].audioRobustness=[h],d=!0)}d&&shaka.Deprecate.deprecateFeature(5,"AdvancedDrmConfiguration's videoRobustness and audioRobustness","These properties are no longer strings but array of strings, please update your usage of these properties.")}a.streaming&&"forceHTTP"in a.streaming&&
(shaka.Deprecate.deprecateFeature(5,"streaming.forceHTTP configuration","Please Use networking.forceHTTP instead."),a.networking=a.networking||{},a.networking.forceHTTP=a.streaming.forceHTTP,delete a.streaming.forceHTTP);a.streaming&&"forceHTTPS"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceHTTPS configuration","Please Use networking.forceHTTP instead."),a.networking=a.networking||{},a.networking.forceHTTPS=a.streaming.forceHTTPS,delete a.streaming.forceHTTPS);a.streaming&&"minBytesForProgressEvents"in
a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.minBytesForProgressEvents configuration","Please Use networking.minBytesForProgressEvents instead."),a.networking=a.networking||{},a.networking.minBytesForProgressEvents=a.streaming.minBytesForProgressEvents,delete a.streaming.minBytesForProgressEvents);g=shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,a,this.defaultConfig_());this.applyConfig_(c);return g};
shaka.Player.prototype.configurationForLowLatency=function(a){this.lowLatencyConfig_=a};
shaka.Player.prototype.applyConfig_=function(a){this.manifestFilterer_=new shaka.media.ManifestFilterer(this.config_,this.maxHwRes_,this.drmEngine_);if(this.parser_){var b=shaka.util.ObjectUtils.cloneObject(this.config_.manifest);this.video_&&this.video_.nodeName==="AUDIO"&&(b.disableVideo=!0);this.parser_.configure(b)}this.drmEngine_&&this.drmEngine_.configure(this.config_.drm);if(this.streamingEngine_){this.streamingEngine_.configure(this.config_.streaming);try{if(this.loadMode_!=shaka.Player.LoadMode.DESTROYED&&
this.manifestFilterer_.filterManifestWithRestrictions(this.manifest_))this.onTracksChanged_()}catch(c){this.onError_(c)}this.abrManager_&&this.updateAbrManagerVariants_();!(b=this.streamingEngine_.getCurrentVariant())||b.allowedByApplication&&b.allowedByKeySystem||(shaka.log.debug("Choosing new variant after changing configuration"),this.chooseVariantAndSwitch_())}this.networkingEngine_&&this.networkingEngine_.configure(this.config_.networking);this.mediaSourceEngine_&&(this.mediaSourceEngine_.configure(this.config_.mediaSource),
this.mediaSourceEngine_.setSegmentRelativeVttTiming(this.config_.manifest.segmentRelativeVttTiming));this.textDisplayer_&&this.createAndConfigureTextDisplayer_();this.abrManager_&&(this.abrManager_.configure(this.config_.abr),this.config_.abr.enabled?this.abrManager_.enable():this.abrManager_.disable(),this.onAbrStatusChanged_());this.bufferObserver_&&this.updateBufferingSettings_();this.bufferPoller_&&(this.config_.streaming.rebufferingGoal?this.bufferPoller_.tickEvery(.25):this.bufferPoller_.stop());
this.manifest_&&shaka.Player.applyPlayRange_(this.manifest_.presentationTimeline,this.config_.playRangeStart,this.config_.playRangeEnd);this.adManager_&&this.adManager_.configure(this.config_.ads);this.cmcdManager_&&this.cmcdManager_.configure(this.config_.cmcd);this.cmsdManager_&&this.cmsdManager_.configure(this.config_.cmsd);this.queueManager_&&this.queueManager_.configure(this.config_.queue);this.applyCriteriaConfigChanges_(a)};
shaka.Player.prototype.applyCriteriaConfigChanges_=function(a){if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.currentAdaptationSetCriteria_.getConfiguration){var b=this.currentAdaptationSetCriteria_.getConfiguration();goog.asserts.assert(b,"criteriaConfig must not be null!");var c=!1;a.preferredVideoHdrLevel!=this.config_.preferredVideoHdrLevel&&b.hdrLevel!=this.config_.preferredVideoHdrLevel&&(b.hdrLevel=this.config_.preferredVideoHdrLevel,c=!0);a.preferredVideoLayout!=this.config_.preferredVideoLayout&&
b.videoLayout!=this.config_.preferredVideoLayout&&(b.videoLayout=this.config_.preferredVideoLayout,c=!0);a.preferSpatialAudio!=this.config_.preferSpatialAudio&&b.spatialAudio!=this.config_.preferSpatialAudio&&(b.spatialAudio=this.config_.preferSpatialAudio,c=!0);a.preferredVideoRole!=this.config_.preferredVideoRole&&b.videoRole!=this.config_.preferredVideoRole&&(b.videoRole=this.config_.preferredVideoRole,c=!0);c&&(this.currentAdaptationSetCriteria_.configure(b),this.chooseVariantAndSwitch_())}};
shaka.Player.prototype.getConfiguration=function(){goog.asserts.assert(this.config_,"Config must not be null!");var a=this.defaultConfig_();shaka.util.PlayerConfiguration.mergeConfigObjects(a,this.config_,this.defaultConfig_());return a};shaka.Player.prototype.getConfigurationForLowLatency=function(){return this.lowLatencyConfig_};
shaka.Player.prototype.getNonDefaultConfiguration=function(){goog.asserts.assert(this.config_,"Config must not be null!");var a=this.defaultConfig_();shaka.util.PlayerConfiguration.mergeConfigObjects(a,this.config_,this.defaultConfig_());return shaka.util.ConfigUtils.getDifferenceFromConfigObjects(this.config_,this.defaultConfig_())};shaka.Player.prototype.getSharedConfiguration=function(){goog.asserts.assert(this.config_,"Cannot call getSharedConfiguration after call destroy!");return this.config_};
shaka.Player.prototype.getBufferFullness=function(){if(this.video_){var a=this.video_.buffered.length;a=a?this.video_.buffered.end(a-1):0;var b=this.getConfiguration().streaming.bufferingGoal;b=Math.min(this.video_.currentTime+b,this.seekRange().end);if(a>=b)return 1;if(!(a<=this.video_.currentTime)&&a<b)return(a-this.video_.currentTime)/(b-this.video_.currentTime)}return 0};
shaka.Player.prototype.resetConfiguration=function(){goog.asserts.assert(this.config_,"Cannot be destroyed");var a=this.getConfiguration(),b;for(b in this.config_)delete this.config_[b];shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,this.defaultConfig_(),this.defaultConfig_());this.applyConfig_(a)};shaka.Player.prototype.getLoadMode=function(){return this.loadMode_};shaka.Player.prototype.getManifestType=function(){return this.manifest_?this.manifest_.type:null};
shaka.Player.prototype.getMediaElement=function(){return this.video_};shaka.Player.prototype.getNetworkingEngine=function(){return this.networkingEngine_};shaka.Player.prototype.getAssetUri=function(){return this.assetUri_};shaka.Player.prototype.getAdManager=function(){return this.adManager_?this.adManager_:null};shaka.Player.prototype.getQueueManager=function(){return this.queueManager_?this.queueManager_:null};
shaka.Player.prototype.isLive=function(){return this.manifest_&&!this.isRemotePlayback()?this.manifest_.presentationTimeline.isLive():this.video_&&(this.video_.src||this.isRemotePlayback())?this.video_.duration==Infinity:!1};shaka.Player.prototype.isInProgress=function(){return this.manifest_?this.manifest_.presentationTimeline.isInProgress():!1};
shaka.Player.prototype.isAudioOnly=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.variants;return a.length?!a[0].video:!1}return this.video_&&(this.video_.src||this.isRemotePlayback())?this.video_.videoTracks?this.video_.videoTracks.length==0:this.video_.videoHeight==0:!1};
shaka.Player.prototype.isVideoOnly=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.variants;if(!a.length)return!1;a=a[0];return a.audio||!a.video?!1:!a.video.codecs.includes(",")}return this.video_&&(this.video_.src||this.isRemotePlayback())&&this.video_.audioTracks?this.video_.audioTracks.length==0:!1};
shaka.Player.prototype.seekRange=function(){if(this.manifest_&&!this.isRemotePlayback()){if(!this.fullyLoaded_&&this.manifest_.type==shaka.media.ManifestParser.HLS)return{start:0,end:0};var a=this.manifest_.presentationTimeline;return{start:a.getSeekRangeStart(),end:a.getSeekRangeEnd()}}if(this.video_&&(this.video_.src||this.isRemotePlayback())&&(a=this.video_.seekable)&&a.length){var b=this.config_?this.config_.playRangeStart:0;b=Math.max(a.start(0),b);var c=this.config_?this.config_.playRangeEnd:
Infinity;a=Math.min(a.end(a.length-1),c);return{start:b,end:a}}return{start:0,end:0}};shaka.Player.prototype.goToLive=function(){this.isLive()?this.video_.currentTime=this.seekRange().end:shaka.log.warning("goToLive is for live streams!")};shaka.Player.prototype.isFullyLoaded=function(){return this.fullyLoaded_};shaka.Player.prototype.keySystem=function(){return shaka.drm.DrmUtils.keySystem(this.drmInfo())};
shaka.Player.prototype.drmInfo=function(){return this.drmEngine_?this.drmEngine_.getDrmInfo():null};shaka.Player.prototype.getDrmEngine=function(){return this.drmEngine_};shaka.Player.prototype.getExpiration=function(){return this.drmEngine_?this.drmEngine_.getExpiration():Infinity};shaka.Player.prototype.getActiveSessionsMetadata=function(){return this.drmEngine_?this.drmEngine_.getActiveSessionsMetadata():[]};
shaka.Player.prototype.getKeyStatuses=function(){return this.drmEngine_?this.drmEngine_.getKeyStatuses():{}};shaka.Player.prototype.isBuffering=function(){var a=shaka.media.BufferingObserver.State;return this.bufferObserver_?this.bufferObserver_.getState()==a.STARVING:!!this.assetUri_};shaka.Player.prototype.getPlaybackRate=function(){return this.video_?this.playRateController_?this.playRateController_.getRealRate():1:0};
shaka.Player.prototype.useTrickPlayTrackIfAvailable=function(a){this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.streamingEngine_&&this.streamingEngine_.setTrickPlay(a)};
shaka.Player.prototype.trickPlay=function(a,b){b=b===void 0?!0:b;goog.asserts.assert(a!=0,"Should never set a trick play rate of 0!");a==0?shaka.log.alwaysWarn("A trick play rate of 0 is unsupported!"):(this.playRateController_.set(a),this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&(this.abrManager_.playbackRateChanged(a),this.useTrickPlayTrackIfAvailable(b&&a!=1)),this.setupTrickPlayEventListeners_(a))};
shaka.Player.prototype.cancelTrickPlay=function(){var a=this.playRateController_.getDefaultRate();this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&this.playRateController_.set(a);this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&(this.playRateController_.set(a),this.abrManager_.playbackRateChanged(a),this.useTrickPlayTrackIfAvailable(!1));this.trickPlayEventManager_.removeAll()};
shaka.Player.prototype.getVariantTracks=function(){if(this.manifest_&&!this.isRemotePlayback()){for(var a=this.streamingEngine_?this.streamingEngine_.getCurrentVariant():null,b=[],c=0,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next();!e.done;e=d.next())if(e=e.value,shaka.util.StreamUtils.isPlayable(e)){var f=shaka.util.StreamUtils.variantToTrack(e);f.active=e==a;f.active||c==1||a==null||e.video!=a.video||e.audio!=a.audio||(f.active=!0);f.active&&c++;b.push(f)}goog.asserts.assert(c<=1,
"It should only have one active track");return b}if(this.video_&&this.video_.audioTracks){var g=this.getActiveHtml5VideoTrack_();a=Array.from(this.video_.audioTracks);return a.length?a.map(function(h){return shaka.util.StreamUtils.html5TrackToShakaTrack(h,g)}):g?[shaka.util.StreamUtils.html5TrackToShakaTrack(null,g)]:[]}return[]};
shaka.Player.prototype.getTextTracks=function(){if(this.manifest_){if(this.isRemotePlayback())return[];for(var a=this.streamingEngine_?this.streamingEngine_.getCurrentTextStream():null,b=[],c=(0,$jscomp.makeIterator)(this.manifest_.textStreams),d=c.next();!d.done;d=c.next()){d=d.value;var e=shaka.util.StreamUtils.textStreamToTrack(d);e.active=d==a;b.push(e)}return b}if(this.video_&&this.video_.src&&this.video_.textTracks){a=this.getFilteredTextTracks_();var f=shaka.util.StreamUtils;return a.map(function(g){return f.html5TextTrackToTrack(g)})}return[]};
shaka.Player.prototype.getImageTracks=function(){var a=shaka.util.StreamUtils,b=this.externalSrcEqualsThumbnailsStreams_;this.manifest_&&(b=this.manifest_.imageStreams);return b.map(function(c){return a.imageStreamToTrack(c)})};
shaka.Player.prototype.getAllThumbnails=function(a){var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1)return e.yield(b.getBestImageStream_(a),2);c=e.yieldResult;if(!c)return e.return(null);d=[];c.segmentIndex.forEachTopLevelReference(function(f){var g=b.parseTilesLayout_(f.getTilesLayout()||c.tilesLayout);if(g)for(var h=g.rows*g.columns,k=f.trueEndTime-f.startTime,l=0;l<h;l++){var m=b.getThumbnailByReference_(f,c,f.startTime+k*l/h,g);d.push(m)}});
c.closeSegmentIndex&&c.closeSegmentIndex();return e.return(d)})};shaka.Player.prototype.parseTilesLayout_=function(a){if(!a)return null;var b=/(\d+)x(\d+)/.exec(a);if(!b)return shaka.log.warning("Tiles layout does not contain a valid format  (columns x rows)"),null;a=parseInt(b[1],10);b=parseInt(b[2],10);return{columns:a,rows:b}};
shaka.Player.prototype.getThumbnails=function(a,b){var c=this,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.nextAddress==1)return l.yield(c.getBestImageStream_(a),2);d=l.yieldResult;if(!d)return l.return(null);d.closeSegmentIndex&&(c.deferredCloseSegmentIndex_.has(d)||(e=new shaka.util.Timer(function(){d.closeSegmentIndex();c.deferredCloseSegmentIndex_.delete(d)}),c.deferredCloseSegmentIndex_.set(d,e)),f=c.deferredCloseSegmentIndex_.get(d),f.tickAfter(5));g=d.segmentIndex.find(b);
if(g==null)return l.return(null);h=d.segmentIndex.get(g);return(k=c.parseTilesLayout_(h.getTilesLayout()||d.tilesLayout))?l.return(c.getThumbnailByReference_(h,d,b,k)):l.return(null)})};
shaka.Player.prototype.getBestImageStream_=function(a){var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.nextAddress==1){if(b.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&b.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)return e.return(null);c=b.externalSrcEqualsThumbnailsStreams_;b.manifest_&&(c=b.manifest_.imageStreams);d=c[0];if(!d)return e.return(null);a!=null&&(d=c.find(function(f){return f.id==a}));return d?d.segmentIndex?e.jumpTo(2):e.yield(d.createSegmentIndex(),
2):e.return(null)}return e.return(d)})};
shaka.Player.prototype.getThumbnailByReference_=function(a,b,c,d){var e=b.width||0,f=b.height||0,g=e/d.columns,h=f/d.rows,k=d.columns*d.rows,l=a.trueEndTime-a.startTime;l=a.getTileDuration()||l/k;var m=a.startTime,n=0,p=0;k>1&&(p=Math.floor((c-a.startTime)/l),m=a.startTime+p*l,n=p%d.columns*g,p=Math.floor(p/d.columns)*h);d=!1;if(c=a.getThumbnailSprite())d=!0,h=c.height,n=c.positionX,p=c.positionY,g=c.width;return{segment:a,imageHeight:f,imageWidth:e,height:h,positionX:n,positionY:p,startTime:m,duration:l,
uris:a.getUris(),startByte:a.getStartByte(),endByte:a.getEndByte(),width:g,sprite:d,mimeType:a.mimeType||b.mimeType,codecs:a.codecs||b.codecs}};
shaka.Player.prototype.selectTextTrack=function(a){var b=this,c=function(){var d=b.manifest_.textStreams.find(function(e){return e.id==a.id});d?d==b.streamingEngine_.getCurrentTextStream()?shaka.log.debug("Text track already selected."):(b.addTextStreamToSwitchHistory_(d,!1),b.streamingEngine_.switchTextStream(d),b.onTextChanged_(),b.setTextDisplayerLanguage_(),b.currentTextLanguage_=d.language):b.isRemotePlayback()||shaka.log.error("No stream with id",a.id)};if(this.manifest_&&this.playhead_&&(c(),
!this.isRemotePlayback()))return;(function(){if(b.video_&&b.video_.textTracks){var d=b.getFilteredTextTracks_(),e=d.find(function(h){return shaka.util.StreamUtils.html5TrackId(h)===a.id});if(e){if(b.textDisplayer_ instanceof shaka.text.NativeTextDisplayer){d=(0,$jscomp.makeIterator)(d);for(var f=d.next();!f.done;f=d.next()){f=f.value;var g=f===e?b.isTextVisible_?"showing":"hidden":"disabled";f.mode!==g&&(f.mode=g)}}else d=d.find(function(h){return h.mode!=="disabled"}),d!==e&&(d&&(d.mode="disabled",
b.loadEventManager_.unlisten(d,"cuechange"),b.textDisplayer_.remove(0,Infinity)),e&&b.enableNativeTrack_(e));b.onTextChanged_();b.setTextDisplayerLanguage_()}else shaka.log.error("No track with id",a.id)}})()};
shaka.Player.prototype.enableNativeTrack_=function(a){var b=this;this.loadEventManager_.listen(a,"cuechange",function(){b.textDisplayer_.remove(0,Math.max(0,b.video_.currentTime-b.config_.streaming.bufferBehind));var c={periodStart:0,segmentStart:0,segmentEnd:b.video_.duration,vttOffset:0},d=[],e=Array.from(a.activeCues||[]);e=(0,$jscomp.makeIterator)(e);for(var f=e.next();!f.done;f=e.next())if(f=shaka.text.Utils.mapNativeCueToShakaCue(f.value)){var g=b.config_.mediaSource.modifyCueCallback;g&&g(f,
null,c);d.push(f)}b.textDisplayer_.append(d)});a.mode=document.pictureInPictureElement?"showing":"hidden"};
shaka.Player.prototype.selectVariantTrack=function(a,b,c){var d=this;b=b===void 0?!1:b;c=c===void 0?0:c;var e=function(){var f=d.manifest_.variants.find(function(h){return h.id==a.id});if(f)if(shaka.util.StreamUtils.isPlayable(f)){var g=d.streamingEngine_.getCurrentVariant();d.config_.abr.enabled&&(g.video!=f.video||g.audio&&f.audio&&g.audio.language==f.audio.language&&g.audio.channelsCount==f.audio.channelsCount&&g.audio.label==f.audio.label)&&shaka.log.alwaysWarn("Changing tracks while abr manager is enabled will likely result in the selected track being overridden. Consider disabling abr before calling selectVariantTrack().");
d.isRemotePlayback()?d.switchVariant_(f,!1,!1,0):d.switchVariant_(f,!1,b||!1,c||0);d.currentAdaptationSetCriteria_.configure({language:f.language,role:f.audio&&f.audio.roles&&f.audio.roles[0]||"",videoRole:f.video&&f.video.roles&&f.video.roles[0]||"",channelCount:f.audio&&f.audio.channelsCount?f.audio.channelsCount:0,hdrLevel:f.video&&f.video.hdr?f.video.hdr:"",spatialAudio:f.audio&&f.audio.spatialAudio?f.audio.spatialAudio:!1,videoLayout:f.video&&f.video.videoLayout?f.video.videoLayout:"",audioLabel:f.audio&&
f.audio.label?f.audio.label:"",videoLabel:f.video&&f.video.label?f.video.label:"",codecSwitchingStrategy:d.config_.mediaSource.codecSwitchingStrategy,audioCodec:f.audio&&f.audio.codecs?f.audio.codecs:"",activeAudioCodec:g.audio&&g.audio.codecs?g.audio.codecs:"",activeAudioChannelCount:g.audio&&g.audio.channelsCount?g.audio.channelsCount:0,preferredAudioCodecs:d.config_.preferredAudioCodecs,preferredAudioChannelCount:d.config_.preferredAudioChannelCount});d.updateAbrManagerVariants_()}else shaka.log.error("Unable to switch to restricted track",
a.id);else d.isRemotePlayback()||shaka.log.error("No variant with id",a.id)};if(this.manifest_&&this.playhead_&&(e(),!this.isRemotePlayback()))return;(function(){if(a.originalAudioId&&d.video_&&d.video_.audioTracks){var f=Array.from(d.video_.audioTracks);f=(0,$jscomp.makeIterator)(f);for(var g=f.next();!g.done;g=f.next())if(g=g.value,shaka.util.StreamUtils.html5TrackId(g)==a.id){d.switchHtml5Track_(g);break}}})()};
shaka.Player.prototype.selectAudioTrack=function(a,b){var c=this;b=b===void 0?0:b;var d=function(){var e=c.currentAdaptationSetCriteria_.getConfiguration();e.audioCodec=a.codecs||"";e.audioLabel=a.label||"";e.channelCount=a.channelsCount||0;e.language=a.language;e.role=a.roles[0]||"";e.spatialAudio=a.spatialAudio;c.currentAdaptationSetCriteria_.configure(e);c.chooseVariantAndSwitch_(!0,b,!1,!1)};if(this.manifest_&&this.playhead_&&(d(),!this.isRemotePlayback()))return;(function(){if(c.video_&&c.video_.audioTracks){var e=
shaka.util.LanguageUtils,f=e.normalize(a.language),g=Array.from(c.video_.audioTracks),h=null;g=(0,$jscomp.makeIterator)(g);for(var k=g.next();!k.done;k=g.next()){k=k.value;var l=k.language||"und";if(k.label==a.label&&e.normalize(l)==f&&k.kind==a.roles[0]){h=k;break}}h&&c.switchHtml5Track_(h)}})()};
shaka.Player.prototype.getAudioTracks=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.getVariantTracks();if(!a.length)return[];var b=a.find(function(f){return f.active});if(!b)return[];var c=a;this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE||this.isRemotePlayback()||(c=a.filter(function(f){return f.originalVideoId===b.originalVideoId&&(f.audioCodec||shaka.util.MimeUtils.RAW_FORMATS.includes(f.audioMimeType||""))}));if(!c.length)return[];a=new Map;c=(0,$jscomp.makeIterator)(c);
for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=d.originalAudioId;e||d.audioId==null||(e=String(d.audioId));!e&&d.codecs.includes(",")&&d.audioCodec&&(e="muxed-in-video");e&&(e+=[d.language,d.label,d.channelsCount,d.spatialAudio].join("_"),a.set(e,{active:d.active,language:d.language,label:d.label,mimeType:d.audioMimeType,codecs:d.audioCodec,primary:d.primary,roles:d.audioRoles||[],accessibilityPurpose:d.accessibilityPurpose,channelsCount:d.channelsCount,audioSamplingRate:d.audioSamplingRate,
spatialAudio:d.spatialAudio,originalLanguage:d.originalLanguage}))}return Array.from(a.values())}return this.video_&&this.video_.audioTracks?Array.from(this.video_.audioTracks).map(function(f){return shaka.util.StreamUtils.html5AudioTrackToTrack(f)}):[]};
shaka.Player.prototype.selectVideoTrack=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?0:c;var d=shaka.util.ArrayUtils,e=this.getVariantTracks();if(e.length){var f=e.find(function(g){return g.active});f&&(e=e.find(function(g){return g.audioId===f.audioId&&(g.videoBandwidth||g.bandwidth)==a.bandwidth&&g.width==a.width&&g.height==a.height&&g.frameRate==a.frameRate&&g.pixelAspectRatio==a.pixelAspectRatio&&g.hdr==a.hdr&&g.colorGamut==a.colorGamut&&g.videoLayout==a.videoLayout&&g.videoMimeType==a.mimeType&&
g.videoCodec==a.codecs&&d.equal(g.videoRoles,a.roles)&&g.videoLabel==a.label}))&&!e.active&&this.selectVariantTrack(e,b,c)}};
shaka.Player.prototype.getVideoTracks=function(){if(this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS||this.isRemotePlayback())return[];var a=this.getVariantTracks();if(!a.length)return[];var b=a.find(function(f){return f.active});if(!b)return[];var c=a.filter(function(f){return f.originalAudioId===b.originalAudioId&&f.audioId===b.audioId&&f.audioGroupId===b.audioGroupId&&f.videoCodec});if(!c.length)return[];a=new Map;c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=
d.originalVideoId;e||d.videoId==null||(e=String(d.videoId));e&&a.set(e,{active:d.active,bandwidth:d.videoBandwidth||d.bandwidth,width:d.width,height:d.height,frameRate:d.frameRate,pixelAspectRatio:d.pixelAspectRatio,hdr:d.hdr,colorGamut:d.colorGamut,videoLayout:d.videoLayout,mimeType:d.videoMimeType,codecs:d.videoCodec,roles:d.videoRoles||[],label:d.videoLabel})}return Array.from(a.values())};shaka.Player.prototype.getAudioLanguagesAndRoles=function(){return shaka.Player.getLanguageAndRolesFrom_(this.getVariantTracks())};
shaka.Player.prototype.getTextLanguagesAndRoles=function(){return shaka.Player.getLanguageAndRolesFrom_(this.getTextTracks())};shaka.Player.prototype.getAudioLanguages=function(){return Array.from(shaka.Player.getLanguagesFrom_(this.getVariantTracks()))};shaka.Player.prototype.getTextLanguages=function(){return Array.from(shaka.Player.getLanguagesFrom_(this.getTextTracks()))};
shaka.Player.prototype.selectAudioLanguage=function(a,b,c,d,e,f,g){var h=this;c=c===void 0?0:c;d=d===void 0?0:d;e=e===void 0?"":e;f=f===void 0?!1:f;g=g===void 0?"":g;var k=function(){var l=h.streamingEngine_.getCurrentVariant();h.currentAdaptationSetCriteria_=h.config_.adaptationSetCriteriaFactory();h.currentAdaptationSetCriteria_.configure({language:a,role:b||"",videoRole:l.video&&l.video.roles&&l.video.roles[0]||"",channelCount:c||0,hdrLevel:"",spatialAudio:f||!1,videoLayout:"",audioLabel:g||"",
videoLabel:"",codecSwitchingStrategy:h.config_.mediaSource.codecSwitchingStrategy,audioCodec:e||"",activeAudioCodec:l.audio&&l.audio.codecs?l.audio.codecs:"",activeAudioChannelCount:l.audio&&l.audio.channelsCount?l.audio.channelsCount:0,preferredAudioCodecs:h.config_.preferredAudioCodecs,preferredAudioChannelCount:h.config_.preferredAudioChannelCount});var m=function(r,t){return r.video||t.video?r.video&&t.video?Math.abs((r.video.height||0)-(t.video.height||0))+Math.abs((r.video.width||0)-(t.video.width||
0)):Infinity:0},n=h.currentAdaptationSetCriteria_.create(h.manifest_.variants),p=null;n=(0,$jscomp.makeIterator)(n.values());for(var q=n.next();!q.done;q=n.next())q=q.value,shaka.util.StreamUtils.isPlayable(q)&&(!p||m(p,l)>m(q,l))&&(p=q);p==l?shaka.log.debug("Audio already selected."):p?(l=shaka.util.StreamUtils.variantToTrack(p),h.selectVariantTrack(l,!0,d||0)):h.chooseVariantAndSwitch_()};if(this.manifest_&&this.playhead_&&(k(),!this.isRemotePlayback()))return;(function(){if(h.video_&&h.video_.audioTracks){var l=
shaka.util.StreamUtils.filterStreamsByLanguageAndRole(h.getVariantTracks(),a,b||"",!1)[0];l&&h.selectVariantTrack(l)}})()};
shaka.Player.prototype.selectTextLanguage=function(a,b,c){var d=this;c=c===void 0?!1:c;var e=function(){d.currentTextLanguage_=a;d.currentTextRole_=b||"";d.currentTextForced_=c||!1;var f=d.chooseTextStream_();f&&(f==d.streamingEngine_.getCurrentTextStream()?shaka.log.debug("Text track already selected."):(d.addTextStreamToSwitchHistory_(f,!1),d.shouldStreamText_()&&(d.streamingEngine_.switchTextStream(f),d.onTextChanged_(),d.setTextDisplayerLanguage_())))};if(this.manifest_&&this.playhead_&&(e(),
!this.isRemotePlayback()))return;(function(){var f=shaka.util.StreamUtils.filterStreamsByLanguageAndRole(d.getTextTracks(),a,b||"",c||!1)[0];f&&d.selectTextTrack(f)})()};
shaka.Player.prototype.selectVariantsByLabel=function(a,b,c){var d=this;b=b===void 0?!0:b;c=c===void 0?0:c;var e=function(){for(var f=null,g=(0,$jscomp.makeIterator)(d.manifest_.variants),h=g.next();!h.done;h=g.next())if(h=h.value,h.audio.label==a){f=h;break}f==null?shaka.log.warning("No variants were found with label: "+a+". Ignoring the request to switch."):(d.currentAdaptationSetCriteria_=d.config_.adaptationSetCriteriaFactory(),d.currentAdaptationSetCriteria_.configure({language:f.language,role:"",
videoRole:"",channelCount:0,hdrLevel:"",spatialAudio:!1,videoLayout:"",videoLabel:"",audioLabel:a,codecSwitchingStrategy:d.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:d.config_.preferredAudioCodecs,preferredAudioChannelCount:d.config_.preferredAudioChannelCount}),d.chooseVariantAndSwitch_(b,c))};if(this.manifest_&&this.playhead_&&(e(),!this.isRemotePlayback()))return;(function(){if(d.video_&&d.video_.audioTracks){var f=
Array.from(d.video_.audioTracks),g=null;f=(0,$jscomp.makeIterator)(f);for(var h=f.next();!h.done;h=f.next())h=h.value,h.label==a&&(g=h);g&&d.switchHtml5Track_(g)}})()};shaka.Player.prototype.isTextTrackVisible=function(){var a=this.isTextVisible_;if(this.textDisplayer_){var b=this.textDisplayer_.isTextVisible();goog.asserts.assert(b==a,"text visibility has fallen out of sync");return b}return a};shaka.Player.prototype.getChaptersTracks=function(){return this.externalChaptersStreams_.map(function(a){return shaka.util.StreamUtils.textStreamToTrack(a)})};
shaka.Player.prototype.getChapters=function(a){shaka.Deprecate.deprecateFeature(5,"getChapters","Please use an getChaptersAsync.");if(!this.externalChaptersStreams_.length)return[];var b=shaka.util.LanguageUtils,c=b.normalize(a);a=this.externalChaptersStreams_.filter(function(g){return b.normalize(g.language)==c});if(!a.length)return[];var d=[],e=new Set;a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next())f=f.value,f.segmentIndex&&f.segmentIndex.forEachTopLevelReference(function(g){var h=
g.getUris()[0],k=g.startTime+"-"+g.endTime+"-"+h;g={id:k,title:h,startTime:g.startTime,endTime:g.endTime};e.has(k)||(d.push(g),e.add(k))});return d};
shaka.Player.prototype.getChaptersAsync=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.nextAddress){case 1:if(!b.externalChaptersStreams_.length)return m.return([]);c=shaka.util.LanguageUtils;d=c.normalize(a);e=b.externalChaptersStreams_.filter(function(n){return c.normalize(n.language)==d});if(!e.length)return m.return([]);f=[];g=new Set;h=(0,$jscomp.makeIterator)(e);k=h.next();case 2:if(k.done){m.jumpTo(4);break}l=k.value;if(l.segmentIndex){m.jumpTo(5);
break}return m.yield(l.createSegmentIndex(),5);case 5:l.segmentIndex.forEachTopLevelReference(function(n){var p=n.getUris()[0],q=n.startTime+"-"+n.endTime+"-"+p;n={id:q,title:p,startTime:n.startTime,endTime:n.endTime};g.has(q)||(f.push(n),g.add(q))});k=h.next();m.jumpTo(2);break;case 4:return m.return(f)}})};
shaka.Player.prototype.getFilteredTextTracks_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).filter(function(a){return a.kind!="metadata"&&a.kind!="chapters"&&a.label!=shaka.Player.TextTrackLabel})};shaka.Player.prototype.getGeneratedTextTrack_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).find(function(a){return a.label==shaka.Player.TextTrackLabel})};
shaka.Player.prototype.getMetadataTracks_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).filter(function(a){return a.kind=="metadata"})};
shaka.Player.prototype.setTextTrackVisibility=function(a){a=!!a;this.isTextVisible_!=a&&(this.isTextVisible_=a,this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE?(this.textDisplayer_.setTextVisibility(a),this.config_.streaming.alwaysStreamText||(a?this.streamingEngine_.getCurrentTextStream()||(a=shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.currentTextLanguage_,this.currentTextRole_,this.currentTextForced_),a.length>0&&(this.streamingEngine_.switchTextStream(a[0]),
this.onTextChanged_(),this.setTextDisplayerLanguage_())):this.streamingEngine_.unloadTextStream())):this.video_&&this.video_.src&&this.video_.textTracks&&this.textDisplayer_.setTextVisibility(a),this.onTextTrackVisibility_())};
shaka.Player.prototype.getPlayheadTimeAsDate=function(){if(this.playhead_)var a=this.playhead_.getTime();else{if(this.startTime_==null)return new Date;if(this.startTime_ instanceof Date)return this.startTime_;a=this.startTime_}if(this.manifest_&&!this.isRemotePlayback()){var b=this.manifest_.presentationTimeline;b=b.getInitialProgramDateTime()||b.getPresentationStartTime();return new Date((b+a)*1E3)}if(this.video_&&this.video_.getStartDate)return b=this.video_.getStartDate(),isNaN(b.getTime())?(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get playhead time as Date!"),
null):new Date(b.getTime()+a*1E3);shaka.log.warning("No way to get playhead time as Date!");return null};
shaka.Player.prototype.getPresentationStartTimeAsDate=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.presentationTimeline;a=a.getInitialProgramDateTime()||a.getPresentationStartTime();return a===null?(shaka.log.info("Manifest appears to have no PDT or PST"),null):new Date(a*1E3)}if(this.video_&&this.video_.getStartDate)return a=this.video_.getStartDate(),isNaN(a.getTime())?(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get presentation start time as Date!"),null):
a;shaka.log.warning("No way to get presentation start time as Date!");return null};shaka.Player.prototype.getSegmentAvailabilityDuration=function(){if(!this.isLive())return shaka.log.warning("getSegmentAvailabilityDuration is for live streams!"),null;if(this.manifest_)return this.manifest_.presentationTimeline.getSegmentAvailabilityDuration();shaka.log.warning("No way to get segment segment availability duration!");return null};
shaka.Player.prototype.getBufferedInfo=function(){if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE)return this.mediaSourceEngine_.getBufferedInfo();var a={total:[],audio:[],video:[],text:[]};this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&(a.total=shaka.media.TimeRangesUtils.getBufferedInfo(this.video_.buffered));return a};
shaka.Player.prototype.getLiveLatency=function(){if(!this.video_||!this.video_.currentTime)return null;var a=this.getPresentationStartTimeAsDate();if(!a)return null;a=a.getTime()+this.video_.currentTime*1E3;return Math.floor(Date.now()-a)};shaka.Player.prototype.getBandwidthEstimate=function(){return this.abrManager_?this.abrManager_.getBandwidthEstimate():NaN};
shaka.Player.prototype.getStats=function(){if(this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&this.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)return shaka.util.Stats.getEmptyBlob();this.updateStateHistory_();goog.asserts.assert(this.video_,"If we have stats, we should have video_");var a=this.video_,b=a.currentTime/a.duration;isNaN(b)||this.isLive()||this.stats_.setCompletionPercent(Math.round(100*b));this.playhead_&&(this.stats_.setGapsJumped(this.playhead_.getGapsJumped()),this.stats_.setStallsDetected(this.playhead_.getStallsDetected()));
a.getVideoPlaybackQuality&&(b=a.getVideoPlaybackQuality(),this.stats_.setDroppedFrames(Number(b.droppedVideoFrames),Number(b.totalVideoFrames)),this.stats_.setCorruptedFrames(Number(b.corruptedVideoFrames)));b=this.drmEngine_?this.drmEngine_.getLicenseTime():NaN;this.stats_.setLicenseTime(b);this.stats_.setResolution(a.videoWidth||NaN,a.videoHeight||NaN);this.stats_.setCodecs("");this.isLive()&&(a=this.getLiveLatency(),a!=null&&this.stats_.setLiveLatency(a/1E3));b=this.getVariantTracks().find(function(e){return e.active});
a=this.getTextTracks().find(function(e){return e.active});if(b){if(b.bandwidth){var c=this.playRateController_?this.playRateController_.getRealRate():1,d=c*b.bandwidth;a&&a.bandwidth&&(d+=c*a.bandwidth);this.stats_.setCurrentStreamBandwidth(d)}b.width&&b.height&&this.stats_.setResolution(b.width||NaN,b.height||NaN);b=b.codecs;a&&(b+=","+(a.codecs||a.mimeType));b&&this.stats_.setCodecs(b)}this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE||this.isRemotePlayback()||(this.manifest_&&(this.stats_.setManifestPeriodCount(this.manifest_.periodCount),
this.stats_.setManifestGapCount(this.manifest_.gapCount),this.manifest_.presentationTimeline&&(a=this.manifest_.presentationTimeline.getMaxSegmentDuration(),this.stats_.setMaxSegmentDuration(a))),a=this.abrManager_.getBandwidthEstimate(),this.stats_.setBandwidthEstimate(a));this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&this.stats_.addBytesDownloaded(NaN);return this.stats_.getBlob()};
shaka.Player.prototype.addTextTrackAsync=function(a,b,c,d,e,f,g){g=g===void 0?!1:g;var h=this,k,l,m,n,p,q,r,t,w,v,u,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.nextAddress){case 1:if(h.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&h.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding text tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.CONTENT_NOT_LOADED);
c!="subtitles"&&c!="captions"&&shaka.log.alwaysWarn("Using a kind value different of `subtitles` or `captions` can cause unwanted issues.");if(d){z.jumpTo(2);break}return z.yield(h.getTextMimetype_(a),3);case 3:d=z.yieldResult;case 2:k=[];h.adManager_&&(k=h.adManager_.getCuePoints());if(h.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS){z.jumpTo(4);break}l=shaka.device.DeviceFactory.getDevice();g&&l.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&(c="forced");return z.yield(h.addSrcTrackElement_(a,
b,c,d,f||"",k),5);case 5:m=z.yieldResult;if(m.track)return h.onTracksChanged_(),h.onTextChanged_(),z.return(shaka.util.StreamUtils.html5TextTrackToTrack(m.track));shaka.log.error("Cannot add this text when loaded with src=");throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS);case 4:n=shaka.util.ManifestParserUtils.ContentType;p=h.seekRange();q=p.end-p.start;h.manifest_&&(q=h.manifest_.presentationTimeline.getDuration());
if(q==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM);if(!k.length){z.jumpTo(6);break}goog.asserts.assert(h.networkingEngine_,"Need networking engine.");return z.yield(h.getTextData_(a,h.networkingEngine_,h.config_.streaming.retryParameters),7);case 7:r=z.yieldResult,t=h.convertToWebVTT_(r,d,k),w=new Blob([t],{type:"text/vtt"}),a=shaka.media.MediaSourceEngine.createObjectURL(w),
d="text/vtt";case 6:v={id:h.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:shaka.media.SegmentIndex.forSingleSegment(0,q,[a]),mimeType:d||"",codecs:e||"",kind:c,encrypted:!1,drmInfos:[],keyIds:new Set,language:b,originalLanguage:b,label:f||null,type:n.TEXT,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!!g,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,
accessibilityPurpose:null,external:!0,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(d||"",e||"")]),isAudioMuxedInVideo:!1,baseOriginalId:null};u=shaka.util.MimeUtils.getFullType(v.mimeType,v.codecs);x=shaka.text.TextEngine.isTypeSupported(u);if(!x)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,d);h.manifest_.textStreams.push(v);h.onTracksChanged_();h.onTextChanged_();return z.return(shaka.util.StreamUtils.textStreamToTrack(v))}})};
shaka.Player.prototype.addThumbnailsTrack=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){switch(B.nextAddress){case 1:if(c.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&c.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding image tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.CONTENT_NOT_LOADED);
if(b){B.jumpTo(2);break}return B.yield(c.getTextMimetype_(a),3);case 3:b=B.yieldResult;case 2:if(b!="text/vtt")throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.UNSUPPORTED_EXTERNAL_THUMBNAILS_URI,a);d=shaka.util.ManifestParserUtils.ContentType;e=c.seekRange();f=e.end-e.start;c.manifest_&&(f=c.manifest_.presentationTimeline.getDuration());if(f==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_THUMBNAILS_TO_LIVE_STREAM);goog.asserts.assert(c.networkingEngine_,"Need networking engine.");return B.yield(c.getTextData_(a,c.networkingEngine_,c.config_.streaming.retryParameters),4);case 4:g=B.yieldResult;h=shaka.text.TextEngine.findParser(b);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,b);k=h();l={periodStart:0,segmentStart:0,segmentEnd:f,vttOffset:0};m=shaka.util.BufferUtils.toUint8(g);
n=k.parseMedia(m,l,a,[]);p=[];q=(0,$jscomp.makeIterator)(n);r=q.next();for(t={};!r.done;t={uris$jscomp$10:void 0,cue$jscomp$44:void 0},r=q.next())t.cue$jscomp$44=r.value,t.uris$jscomp$10=null,w=function(C){return function(){C.uris$jscomp$10==null&&(C.uris$jscomp$10=shaka.util.ManifestParserUtils.resolveUris([a],[C.cue$jscomp$44.payload]));return C.uris$jscomp$10||[]}}(t),v=new shaka.media.SegmentReference(t.cue$jscomp$44.startTime,t.cue$jscomp$44.endTime,w,0,null,null,0,0,Infinity),t.cue$jscomp$44.payload.includes("#xywh")&&
(u=t.cue$jscomp$44.payload.split("#xywh=")[1].split(","),u.length===4&&v.setThumbnailSprite({height:parseInt(u[3],10),positionX:parseInt(u[0],10),positionY:parseInt(u[1],10),width:parseInt(u[2],10)})),p.push(v);x=b;if(!p.length){B.jumpTo(5);break}return B.yield(shaka.net.NetworkingUtils.getMimeType(p[0].getUris()[0],c.networkingEngine_,c.config_.manifest.retryParameters),6);case 6:x=B.yieldResult;case 5:return z={id:c.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},
segmentIndex:new shaka.media.SegmentIndex(p),mimeType:x||"",codecs:"",kind:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:"und",originalLanguage:null,label:null,type:d.IMAGE,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,tilesLayout:"1x1",accessibilityPurpose:null,external:!0,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(x||"","")]),isAudioMuxedInVideo:!1,
baseOriginalId:null},c.loadMode_==shaka.Player.LoadMode.SRC_EQUALS?c.externalSrcEqualsThumbnailsStreams_.push(z):c.manifest_.imageStreams.push(z),c.onTracksChanged_(),B.return(shaka.util.StreamUtils.imageStreamToTrack(z))}})};
shaka.Player.prototype.addChaptersTrack=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.nextAddress){case 1:if(d.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&d.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding chapters tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.CONTENT_NOT_LOADED);
if(c){x.jumpTo(2);break}return x.yield(d.getTextMimetype_(a),3);case 3:c=x.yieldResult;case 2:e=shaka.util.ManifestParserUtils.ContentType;f=d.seekRange();g=f.end-f.start;d.manifest_&&(g=d.manifest_.presentationTimeline.getDuration());if(g==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_CHAPTERS_TO_LIVE_STREAM);goog.asserts.assert(d.networkingEngine_,"Need networking engine.");return x.yield(d.getTextData_(a,
d.networkingEngine_,d.config_.streaming.retryParameters),4);case 4:h=x.yieldResult;k=shaka.text.TextEngine.findParser(c);if(!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,c);l=k();m={periodStart:0,segmentStart:0,segmentEnd:g,vttOffset:0};n=shaka.util.BufferUtils.toUint8(h);p=l.parseMedia(n,m,a,[]);q=[];r=(0,$jscomp.makeIterator)(p);t=r.next();for(w={};!t.done;w={cue$jscomp$45:void 0},t=r.next())w.cue$jscomp$45=
t.value,v=new shaka.media.SegmentReference(w.cue$jscomp$45.startTime,w.cue$jscomp$45.endTime,function(z){return function(){return[z.cue$jscomp$45.payload]}}(w),0,null,null,0,0,Infinity),q.push(v);u={id:d.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex(q),mimeType:"text/plain",codecs:"",kind:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:b,originalLanguage:b,label:null,type:e.TEXT,primary:!1,
trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!0,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType("text/plain","")]),isAudioMuxedInVideo:!1,baseOriginalId:null};d.externalChaptersStreams_.push(u);d.onTracksChanged_();return x.return(shaka.util.StreamUtils.textStreamToTrack(u))}})};
shaka.Player.prototype.getTextMimetype_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.nextAddress){case 1:return d.setCatchFinallyBlocks(2),goog.asserts.assert(b.networkingEngine_,"Need networking engine."),d.yield(shaka.net.NetworkingUtils.getMimeType(a,b.networkingEngine_,b.config_.streaming.retryParameters),4);case 4:c=d.yieldResult;d.leaveTryBlock(3);break;case 2:d.enterCatchBlock();case 3:if(c)return d.return(c);shaka.log.error("The mimeType has not been provided and it could not be deduced from its uri.");
throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.TEXT_COULD_NOT_GUESS_MIME_TYPE,a);}})};
shaka.Player.prototype.addSrcTrackElement_=function(a,b,c,d,e,f){var g=this,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.nextAddress==1){if(d=="text/vtt"&&!f.length)return n.jumpTo(2);goog.asserts.assert(g.networkingEngine_,"Need networking engine.");return n.yield(g.getTextData_(a,g.networkingEngine_,g.config_.streaming.retryParameters),3)}n.nextAddress!=2&&(h=n.yieldResult,k=g.convertToWebVTT_(h,d,f),l=new Blob([k],{type:"text/vtt"}),a=shaka.media.MediaSourceEngine.createObjectURL(l),
d="text/vtt");m=document.createElement("track");m.src=g.cmcdManager_.appendTextTrackData(a);m.label=e;m.kind=c;m.srclang=b;g.video_.getAttribute("crossorigin")||g.video_.setAttribute("crossorigin","anonymous");g.video_.appendChild(m);g.externalSrcEqualsTextTracks_.push(m);return n.return(m)})};
shaka.Player.prototype.getTextData_=function(a,b,c){var d=this,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return e=shaka.net.NetworkingEngine.RequestType.SEGMENT,f=shaka.net.NetworkingEngine.makeRequest([a],c),f.method="GET",d.cmcdManager_.applyTextData(f),h.yield(b.request(e,f).promise,2);g=h.yieldResult;return h.return(g.data)})};
shaka.Player.prototype.convertToWebVTT_=function(a,b,c){var d=shaka.text.TextEngine.findParser(b);if(d)return b=d(),d={periodStart:0,segmentStart:0,segmentEnd:this.video_.duration,vttOffset:0},a=shaka.util.BufferUtils.toUint8(a),a=b.parseMedia(a,d,null,[]),shaka.text.WebVttGenerator.convert(a,c);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,b);};
shaka.Player.prototype.setMaxHardwareResolution=function(a,b){this.maxHwRes_.width=a;this.maxHwRes_.height=b};shaka.Player.prototype.retryStreaming=function(a){return this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE?this.streamingEngine_.retry(a===void 0?.1:a):!1};
shaka.Player.prototype.getManifest=function(){shaka.log.alwaysWarn("Shaka Player's internal Manifest structure is NOT covered by semantic versioning compatibility guarantees.  It may change at any time!  Please consider filing a feature request for whatever you use getManifest() for.");return this.manifest_};shaka.Player.prototype.getManifestParserFactory=function(){return this.parserFactory_};
shaka.Player.prototype.getFetchedPlaybackInfo=function(){var a={video:null,audio:null,text:null};if(this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE)return a;var b=shaka.util.ManifestParserUtils.ContentType,c=this.streamingEngine_.getCurrentVariant(),d=this.streamingEngine_.getCurrentTextStream(),e=this.video_.currentTime;c=(0,$jscomp.makeIterator)([c.video,c.audio,d]);for(d=c.next();!d.done;d=c.next())if((d=d.value)&&d.segmentIndex){var f=d.segmentIndex.find(e);f=d.segmentIndex.get(f);f={codecs:f.codecs||
d.codecs,mimeType:f.mimeType||d.mimeType,bandwidth:f.bandwidth||d.bandwidth};d.type==b.VIDEO?(f.width=d.width,f.height=d.height,a.video=f):d.type==b.AUDIO?a.audio=f:d.type==b.TEXT&&(a.text=f)}return a};shaka.Player.prototype.addVariantToSwitchHistory_=function(a,b){this.stats_.getSwitchHistory().updateCurrentVariant(a,b)};shaka.Player.prototype.addTextStreamToSwitchHistory_=function(a,b){this.stats_.getSwitchHistory().updateCurrentText(a,b)};
shaka.Player.prototype.defaultConfig_=function(){var a=this,b=shaka.util.PlayerConfiguration.createDefault();b.streaming.failureCallback=function(c){a.defaultStreamingFailureCallback_(c)};b.textDisplayFactory=function(){if(a.videoContainer_){var c=a.video_;c=c.webkitDisplayingFullscreen||c.webkitPresentationMode&&c.webkitPresentationMode!="inline"?!1:!0}else c=!1;if(c)return new shaka.text.UITextDisplayer(a.video_,a.videoContainer_);if("track"in document.createElement("track"))return new shaka.text.NativeTextDisplayer(a);
shaka.log.warning("Text tracks are not supported by the browser, disabling.");return new shaka.text.StubTextDisplayer};return b};shaka.Player.prototype.setVideoContainer=function(a){this.videoContainer_=a};
shaka.Player.prototype.defaultStreamingFailureCallback_=function(a){if(this.isLive()){var b=null;a.code==shaka.util.Error.Code.BAD_HTTP_STATUS||a.code==shaka.util.Error.Code.HTTP_ERROR?(b=1,this.config_.streaming.lowLatencyMode&&(b=.1)):a.code==shaka.util.Error.Code.TIMEOUT&&(b=.1);b!=null&&(a.severity=shaka.util.Error.Severity.RECOVERABLE,shaka.log.warning("Live streaming error.  Retrying automatically..."),this.retryStreaming(b))}};
shaka.Player.prototype.makeTextStreamsForClosedCaptions_=function(a){for(var b=shaka.util.ManifestParserUtils.ContentType,c=shaka.util.ManifestParserUtils.TextStreamKind,d=shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE,e=shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE,f=new Set,g=(0,$jscomp.makeIterator)(a.textStreams),h=g.next();!h.done;h=g.next())h=h.value,h.mimeType!=d&&h.mimeType!=e||f.add(h.originalId);g=(0,$jscomp.makeIterator)(a.variants);for(h=g.next();!h.done;h=g.next())if((h=h.value.video)&&
h.closedCaptions)for(var k=(0,$jscomp.makeIterator)(h.closedCaptions.keys()),l=k.next();!l.done;l=k.next())if(l=l.value,!f.has(l)){var m=l.startsWith("CC")?d:e,n=new shaka.media.MetaSegmentIndex,p=h.closedCaptions.get(l);m={id:this.nextExternalStreamId_++,originalId:l,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:n,mimeType:m,codecs:"",kind:c.CLOSED_CAPTION,encrypted:!1,drmInfos:[],keyIds:new Set,language:p,originalLanguage:p,label:null,type:b.TEXT,primary:!1,trickModeVideo:null,
dependencyStream:null,emsgSchemeIdUris:null,roles:h.roles,forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!1,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(m,"")]),isAudioMuxedInVideo:!1,baseOriginalId:null};a.textStreams.push(m);f.add(l)}};
shaka.Player.prototype.adjustStartTime_=function(a,b){var c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return c=a.audio,d=a.video,e=function(k,l){var m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.nextAddress==1)return k?k.segmentIndex?q.jumpTo(2):q.yield(k.createSegmentIndex(),2):q.return(null);n=(m=k.segmentIndex.getIteratorForTime(l))?m.next().value:null;if(!n)return q.return(null);p=n.startTime;goog.asserts.assert(p<=
l,"Segment should start before target time!");return q.return(p)})},h.yield(e(c,b),2);if(h.nextAddress!=3)return f=h.yieldResult,h.yield(e(d,b),3);g=h.yieldResult;return g!=null&&f!=null?h.return(Math.max(g,f)):g!=null?h.return(g):f!=null?h.return(f):h.return(b)})};
shaka.Player.prototype.updateBufferState_=function(){var a=this.isBuffering();shaka.log.v2("Player changing buffering state to",a);if(this.stats_&&this.bufferObserver_&&this.playhead_){this.config_.streaming.rebufferingGoal==0?this.playRateController_.setBuffering(!1):this.playRateController_.setBuffering(a);this.cmcdManager_&&this.cmcdManager_.setBuffering(a);this.updateStateHistory_();var b=this.config_.streaming.liveSync.dynamicTargetLatency.maxAttempts;if(this.config_.streaming.liveSync.dynamicTargetLatency.enabled&&
a&&this.rebufferingCount_<b){b=this.config_.streaming.liveSync.dynamicTargetLatency.maxLatency;var c=this.config_.streaming.liveSync.targetLatencyTolerance,d=this.config_.streaming.liveSync.dynamicTargetLatency.rebufferIncrement;this.currentTargetLatency_&&(this.currentTargetLatency_=Math.min(this.currentTargetLatency_+ ++this.rebufferingCount_*d,b-c))}}b=shaka.util.FakeEvent.EventName.Buffering;a=(new Map).set("buffering",a);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};
shaka.Player.prototype.onRateChange_=function(){var a=this.video_.playbackRate;a!=0&&(this.playRateController_&&(this.playRateController_.set(a),this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.abrManager_.playbackRateChanged(a),this.setupTrickPlayEventListeners_(a)),a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.RateChange),this.dispatchEvent(a))};
shaka.Player.prototype.setupTrickPlayEventListeners_=function(a){var b=this;this.trickPlayEventManager_.removeAll();this.trickPlayEventManager_.listen(this.video_,"timeupdate",function(){var c=b.video_.currentTime,d=b.seekRange(),e=b.isLive(),f=e?b.config_.streaming.safeSeekOffset:0;a>0?(!e||a>=1)&&Math.floor(c)>=Math.floor(d.end)&&b.cancelTrickPlay():Math.floor(c)<=Math.floor(d.start+f)&&b.cancelTrickPlay()})};
shaka.Player.prototype.updateStateHistory_=function(){if(this.stats_&&this.bufferObserver_){var a=shaka.media.BufferingObserver.State,b=this.stats_.getStateHistory(),c="playing";this.bufferObserver_.getState()==a.STARVING?c="buffering":this.isEnded()?c="ended":this.video_.paused&&(c="paused");b.update(c)&&(a=shaka.util.FakeEvent.EventName.StateChanged,c=(new Map).set("newstate",c),this.dispatchEvent(shaka.Player.makeEvent_(a,c)))}};
shaka.Player.prototype.onTimeUpdate_=function(){var a=this.video_.playbackRate,b=this.isLive();if(this.config_.streaming.vodDynamicPlaybackRate&&!b){var c=this.config_.streaming.vodDynamicPlaybackRateLowBufferRate,d=this.getBufferFullness(),e=this.config_.streaming.vodDynamicPlaybackRateBufferRatio;d<=e?a!=c&&(shaka.log.debug("Buffer fullness ratio ("+d+") is less than the vodDynamicPlaybackRateBufferRatio ("+e+"). Updating playbackRate to "+c),this.trickPlay(c,!1)):d==1&&a!==this.playRateController_.getDefaultRate()&&
(shaka.log.debug("Buffer is full. Cancel trick play."),this.cancelTrickPlay())}if(b&&(b=this.seekRange(),Number.isFinite(b.end)&&!(this.video_.currentTime<b.start||this.video_.paused))){c=this.config_.streaming.liveSync.targetLatencyTolerance;d=this.config_.streaming.liveSync.dynamicTargetLatency.enabled;e=this.config_.streaming.liveSync.dynamicTargetLatency.stabilityThreshold;if(this.config_.streaming.liveSync&&this.config_.streaming.liveSync.enabled){var f=this.config_.streaming.liveSync.targetLatency;
var g=f+c;var h=Math.max(0,f-c);var k=this.config_.streaming.liveSync.maxPlaybackRate;var l=this.config_.streaming.liveSync.minPlaybackRate}else this.manifest_&&this.manifest_.serviceDescription&&(f=this.manifest_.serviceDescription.targetLatency,this.manifest_.serviceDescription.targetLatency!=null?g=this.manifest_.serviceDescription.targetLatency+c:this.manifest_.serviceDescription.maxLatency!=null&&(g=this.manifest_.serviceDescription.maxLatency),this.manifest_.serviceDescription.targetLatency!=
null?h=Math.max(0,this.manifest_.serviceDescription.targetLatency-c):this.manifest_.serviceDescription.minLatency!=null&&(h=this.manifest_.serviceDescription.minLatency),k=this.manifest_.serviceDescription.maxPlaybackRate||this.config_.streaming.liveSync.maxPlaybackRate,l=this.manifest_.serviceDescription.minPlaybackRate||this.config_.streaming.liveSync.minPlaybackRate);this.currentTargetLatency_||typeof f!=="number"||(this.currentTargetLatency_=f);var m=this.config_.streaming.liveSync.dynamicTargetLatency.maxAttempts;
d&&this.targetLatencyReached_&&this.currentTargetLatency_!==null&&typeof f==="number"&&this.rebufferingCount_<m&&Date.now()-this.targetLatencyReached_>e*1E3&&(e=this.config_.streaming.liveSync.dynamicTargetLatency.minLatency,this.currentTargetLatency_=Math.max(this.currentTargetLatency_-(f-e)/2,e+c),this.targetLatencyReached_=Date.now());d&&this.currentTargetLatency_!==null&&(g=this.currentTargetLatency_+c,h=this.currentTargetLatency_-c);f=b.end-this.video_.currentTime;c=0;this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&
(d=this.video_.buffered,d.length>0&&(c=d.end(d.length-1),c=Math.max(k,c-b.end)));b=this.config_.streaming.liveSync.panicMode;d=this.config_.streaming.liveSync.panicThreshold*1E3;e=Date.now()-this.bufferObserver_.getLastRebufferTime();b&&!l&&(l=this.config_.streaming.liveSync.minPlaybackRate);b&&l&&e<=d?a!=l&&(shaka.log.debug("Time since last rebuffer ("+e+"s) is less than the live sync panicThreshold ("+d+"s). Updating playbackRate to "+l),this.trickPlay(l,!1)):g!=void 0&&k&&f-c>g?(a!=k&&(shaka.log.debug("Latency ("+
f+"s) is greater than live sync maxLatency ("+g+"s). Updating playbackRate to "+k),this.trickPlay(k,!1)),this.targetLatencyReached_=null):h!=void 0&&l&&f-c<h?(a!=l&&(shaka.log.debug("Latency ("+f+"s) is smaller than live sync minLatency ("+h+"s). Updating playbackRate to "+l),this.trickPlay(l,!1)),this.targetLatencyReached_=null):a!==this.playRateController_.getDefaultRate()&&(this.cancelTrickPlay(),this.targetLatencyReached_=Date.now())}};
shaka.Player.prototype.onVideoProgress_=function(){var a=this;if(this.video_){var b=function(e,f){return(shaka.util.NumberUtils.isFloatEqual(e,f)||f>e)&&a.completionPercent_<e?(a.completionPercent_=e,!0):!1},c=this.seekRange();c=c.end-c.start;c=c>0?this.video_.currentTime/c:0;if(!isNaN(c)){c*=100;if(b(0,c))var d=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Started);else if(b(25,c))d=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.FirstQuartile);else if(b(50,c))d=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Midpoint);
else if(b(75,c))d=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ThirdQuartile);else{if(b(100,c)||c>100)d=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Complete);a.config_&&a.config_.playRangeEnd!=Infinity&&a.isEnded()&&a.video_.pause()}d&&this.dispatchEvent(d)}}};shaka.Player.prototype.onSeek_=function(){this.playheadObservers_&&this.playheadObservers_.notifyOfSeek(!this.playhead_.getIsJumpingGap());this.streamingEngine_&&this.streamingEngine_.seeked();this.bufferObserver_&&this.pollBufferState_(shaka.util.MediaElementEvent.SEEKING)};
shaka.Player.prototype.updateAbrManagerVariants_=function(){try{goog.asserts.assert(this.manifest_,"Manifest should exist by now!"),this.manifestFilterer_.checkRestrictedVariants(this.manifest_)}catch(b){return this.onError_(b),!1}var a=shaka.util.StreamUtils.getPlayableVariants(this.manifest_.variants);a=this.currentAdaptationSetCriteria_.create(a);a=this.abrManager_.setVariants(Array.from(a.values()));return typeof a=="boolean"?a:!0};
shaka.Player.prototype.chooseVariant_=function(a){a=a===void 0?!1:a;if(this.updateAbrManagerVariants_()){if(!this.config_.abr.enabled){var b=this.currentAdaptationSetCriteria_;typeof b.getLastAdaptationSet!="function"&&(shaka.Deprecate.deprecateFeature(5,"AdaptationSetCriteria w/o getLastAdaptationSet","Please use an AdaptationSetCriteria with getLastAdaptationSet."),b.getLastAdaptationSet=function(){return null});if(b=b.getLastAdaptationSet())if(b=Array.from(b.values()),b.length){var c=this.streamingEngine_.getCurrentVariant();
if(c&&c.video&&(b=b.find(function(d){return d.video==c.video})))return b}}return this.abrManager_.chooseVariant(a)}return null};
shaka.Player.prototype.checkVariants_=function(){goog.asserts.assert(this.manifest_,"Should have manifest!");for(var a=Date.now()/1E3,b=!1,c=!0,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next();!e.done;e=d.next()){e=e.value;if(e.disabledUntilTime>0&&e.disabledUntilTime<=a){e.disabledUntilTime=0;b=!0;var f=shaka.log,g=f.v2,h="";e.video&&(h+="video:"+e.video.id);e.audio&&(h=h+(h?"&":"")+("audio:"+e.audio.id));g.call(f,"Re-enabled variant with "+h)}e.disabledUntilTime>0&&(c=!1)}c&&this.checkVariantsTimer_.stop();
b&&this.chooseVariantAndSwitch_(!1,void 0,!1,!1)};shaka.Player.prototype.chooseTextStream_=function(){return shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.currentTextLanguage_,this.currentTextRole_,this.currentTextForced_)[0]||null};
shaka.Player.prototype.chooseVariantAndSwitch_=function(a,b,c,d){a=a===void 0?!0:a;b=b===void 0?0:b;c=c===void 0?!1:c;d=d===void 0?!0:d;goog.asserts.assert(this.config_,"Must not be destroyed");var e=this.chooseVariant_();e&&this.switchVariant_(e,d,a,b,c)};
shaka.Player.prototype.switchVariant_=function(a,b,c,d,e){e=e===void 0?!1:e;var f=this.streamingEngine_.getCurrentVariant();if(a==f)shaka.log.debug("Variant already selected."),c&&this.streamingEngine_.switchVariant(a,c,d,!0);else{this.addVariantToSwitchHistory_(a,b);this.streamingEngine_.switchVariant(a,c,d,e,b);c=null;f&&(c=shaka.util.StreamUtils.variantToTrack(f));f=shaka.util.StreamUtils.variantToTrack(a);f.active=!0;this.lcevcDec_&&this.lcevcDec_.updateVariant(a,this.getManifestType());if(b)this.onAdaptation_(c,
f);else this.onVariantChanged_(c,f);this.checkAudioTracksChanged_(c,f)}};
shaka.Player.prototype.switchHtml5Track_=function(a){var b=shaka.util.StreamUtils;goog.asserts.assert(this.video_&&this.video_.audioTracks,"Video and video.audioTracks should not be null!");var c=Array.from(this.video_.audioTracks).find(function(e){return e.enabled});a.enabled=!0;if(c){a.id!==c.id&&(c.enabled=!1);var d=this.getActiveHtml5VideoTrack_();c=b.html5TrackToShakaTrack(c,d);a=b.html5TrackToShakaTrack(a,d);this.onVariantChanged_(c,a);this.checkAudioTracksChanged_(c,a)}};
shaka.Player.prototype.getActiveHtml5VideoTrack_=function(){return this.video_&&this.video_.videoTracks?Array.from(this.video_.videoTracks).find(function(a){return a.selected}):null};
shaka.Player.prototype.setInitialTextState_=function(a,b){b?(goog.asserts.assert(this.config_,"Must not be destroyed"),shaka.util.StreamUtils.shouldInitiallyShowText(a.audio,b,this.config_)&&(this.isTextVisible_=!0),this.isTextVisible_&&(this.textDisplayer_.setTextVisibility(!0),goog.asserts.assert(this.shouldStreamText_(),"Should be streaming text"))):(this.isTextVisible_=!1,this.textDisplayer_.setTextVisibility(!1));this.onTextTrackVisibility_()};
shaka.Player.prototype.onManifestUpdate_=function(){this.parser_&&this.parser_.update&&this.parser_.update()};
shaka.Player.prototype.onSegmentAppended_=function(a,b,c,d){if(c!=shaka.util.ManifestParserUtils.ContentType.TEXT){if(this.playhead_){this.playhead_.notifyOfBufferingChange();var e=this.mediaSourceEngine_.bufferStart(c);!this.isLive()&&this.video_.paused&&!this.video_.seeking&&e!=null&&e>0&&this.playhead_.getTime()<e&&this.playhead_.setStartTime(e)}this.pollBufferState_()}a=(new Map).set("start",a).set("end",b).set("contentType",c).set("isMuxed",d);this.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.SegmentAppended,
a))};shaka.Player.prototype.switch_=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?0:c;shaka.log.debug("switch_");goog.asserts.assert(this.config_.abr.enabled,"AbrManager should not call switch while disabled!");this.manifest_&&this.streamingEngine_&&a!=this.streamingEngine_.getCurrentVariant()&&this.switchVariant_(a,!0,b,c)};shaka.Player.prototype.onAdaptation_=function(a,b){a=(new Map).set("oldTrack",a).set("newTrack",b);a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Adaptation,a);this.delayDispatchEvent_(a)};
shaka.Player.prototype.onTracksChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);this.delayDispatchEvent_(a);this.onAudioTracksChanged_()};shaka.Player.prototype.onVariantChanged_=function(a,b){a=(new Map).set("oldTrack",a).set("newTrack",b);a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.VariantChanged,a);this.delayDispatchEvent_(a)};
shaka.Player.prototype.checkAudioTracksChanged_=function(a,b){var c=!1;a&&a.audioId==b.audioId&&a.audioGroupId==b.audioGroupId||(c=!0);if(c)this.onAudioTracksChanged_()};shaka.Player.prototype.onAudioTracksChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.AudioTracksChanged);this.delayDispatchEvent_(a)};shaka.Player.prototype.onTextChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TextChanged);this.delayDispatchEvent_(a)};
shaka.Player.prototype.onTextTrackVisibility_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TextTrackVisibility);this.delayDispatchEvent_(a)};shaka.Player.prototype.onAbrStatusChanged_=function(){this.config_.abr.enabled||this.restoreDisabledVariants_();var a=(new Map).set("newStatus",this.config_.abr.enabled);this.delayDispatchEvent_(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.AbrStatusChanged,a))};
shaka.Player.prototype.setTextDisplayerLanguage_=function(){var a=this.getTextTracks().find(function(b){return b.active});a&&this.textDisplayer_&&this.textDisplayer_.setTextLanguage&&this.textDisplayer_.setTextLanguage(a.language)};
shaka.Player.prototype.restoreDisabledVariants_=function(a){a=a===void 0?!0:a;if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE){goog.asserts.assert(this.manifest_,"Should have manifest!");shaka.log.v2("Restoring all disabled streams...");this.checkVariantsTimer_.stop();for(var b=(0,$jscomp.makeIterator)(this.manifest_.variants),c=b.next();!c.done;c=b.next())c.value.disabledUntilTime=0;a&&this.updateAbrManagerVariants_()}};
shaka.Player.prototype.disableStream=function(a,b){if(!this.config_.abr.enabled||this.loadMode_===shaka.Player.LoadMode.DESTROYED||!navigator.onLine||b==0||!this.manifest_)return!1;if(this.manifest_.variants.some(function(h){var k=h[a.type];return k&&k.id!==a.id&&!h.disabledUntilTime?shaka.util.StreamUtils.isAudio(a)?a.language===k.language:!0:!1})){for(var c=!1,d=!1,e=(0,$jscomp.makeIterator)(this.manifest_.variants),f=e.next();!f.done;f=e.next()){f=f.value;var g=f[a.type];g&&(g.id===a.id?(f.disabledUntilTime=
Date.now()/1E3+b,c=!0,shaka.log.v2("Disabled stream "+a.type+":"+a.id+" for "+b+" seconds...")):g.trickModeVideo&&g.trickModeVideo.id==a.id&&(d=!0))}if(!c&&d)return!1;goog.asserts.assert(c,"Must have disabled stream");this.checkVariantsTimer_.tickEvery(1);b=this.getBufferedInfo().video.reduce(function(h,k){return h+k.end-k.start},0);this.chooseVariantAndSwitch_(!1,b,!0,!1);return!0}shaka.log.warning("No alternate stream found for active "+a.type+" stream. Will ignore request to disable stream...");
return!1};
shaka.Player.prototype.onError_=function(a){var b=this,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.nextAddress){case 1:goog.asserts.assert(a instanceof shaka.util.Error,"Wrong error type!");if(b.loadMode_==shaka.Player.LoadMode.DESTROYED)return k.return();a.severity===shaka.util.Error.Severity.RECOVERABLE&&b.stats_.addNonFatalError();c=!0;if(!(b.fullyLoaded_&&b.manifest_&&b.streamingEngine_)||a.code!=shaka.util.Error.Code.VIDEO_ERROR&&a.code!=shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_FAILED&&a.code!=
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW&&a.code!=shaka.util.Error.Code.STREAMING_NOT_ALLOWED&&a.code!=shaka.util.Error.Code.TRANSMUXING_FAILED){k.jumpTo(2);break}d=shaka.device.DeviceFactory.getDevice();if(d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&a.code==shaka.util.Error.Code.VIDEO_ERROR)return k.return();k.setCatchFinallyBlocks(3);return k.yield(b.streamingEngine_.resetMediaSource(),5);case 5:e=k.yieldResult;c=!e;e&&(f=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.MediaSourceRecovered),
b.dispatchEvent(f));k.leaveTryBlock(2);break;case 3:k.enterCatchBlock(),c=!0;case 2:if(!c)return k.return();a.severity===shaka.util.Error.Severity.CRITICAL&&b.restoreDisabledVariants_(!1);g=shaka.util.FakeEvent.EventName.Error;h=shaka.Player.makeEvent_(g,(new Map).set("detail",a));b.dispatchEvent(h);h.defaultPrevented&&(a.handled=!0);k.jumpToEnd()}})};shaka.Player.prototype.addFont=function(a,b){return shaka.util.Dom.addFont(a,b)};
shaka.Player.prototype.onRegionEvent_=function(a,b,c){c=c===void 0?this:c;b={schemeIdUri:b.schemeIdUri,value:b.value,startTime:b.startTime,endTime:b.endTime,id:b.id,timescale:b.timescale,eventElement:b.eventElement,eventNode:b.eventNode};b=(new Map).set("detail",b);c.dispatchEvent(shaka.Player.makeEvent_(a,b))};
shaka.Player.prototype.onMediaQualityChange_=function(a,b,c){c=c===void 0?!1:c;a={bandwidth:a.bandwidth,audioSamplingRate:a.audioSamplingRate,codecs:a.codecs,contentType:a.contentType,frameRate:a.frameRate,height:a.height,mimeType:a.mimeType,channelsCount:a.channelsCount,pixelAspectRatio:a.pixelAspectRatio,width:a.width,label:a.label,roles:a.roles,language:a.language};b=(new Map).set("mediaQuality",a).set("position",b);this.dispatchEvent(shaka.Player.makeEvent_(c?shaka.util.FakeEvent.EventName.AudioTrackChanged:
shaka.util.FakeEvent.EventName.MediaQualityChanged,b))};
shaka.Player.prototype.videoErrorToShakaError_=function(a){a=a===void 0?!0:a;goog.asserts.assert(this.video_.error,"Video error expected, but missing!");if(!this.video_.error)return a?new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.VIDEO_ERROR):null;var b=this.video_.error.code;if(!a&&b==1)return null;if(a=this.video_.error.msExtendedCode)a<0&&(a+=4294967296),a=a.toString(16);return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.VIDEO_ERROR,b,a,this.video_.error.message)};shaka.Player.prototype.onVideoError_=function(a){if(a=this.videoErrorToShakaError_(!1))this.onError_(a)};
shaka.Player.prototype.onKeyStatus_=function(a){var b=this;goog.asserts.assert(this.streamingEngine_,"Cannot be called in src= mode");var c=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.KeyStatusChanged);this.dispatchEvent(c);var d=Object.keys(a);d.length==0&&shaka.log.warning("Got a key status event without any key statuses, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");d.length==1&&d[0]==""&&(d=
["00"],a={"00":a[""]});var e=d.length==1&&d[0]=="00";e&&shaka.log.warning("Got a synthetic key status event, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");var f=shaka.media.ManifestFilterer.restrictedStatuses;c=!1;goog.asserts.assert(this.drmEngine_,"drmEngine should be non-null here.");if(d.length){d=this.keySystem();for(var g=shaka.util.MapUtils.asMap(this.config_.drm.clearKeys),h=function(t,w){t.allowedByKeySystem=
!0;w=(0,$jscomp.makeIterator)(w);for(var v=w.next();!v.done;v=w.next())if(v=v.value,(v=a[e?"00":v])||b.drmEngine_.hasManifestInitData())t.allowedByKeySystem=t.allowedByKeySystem&&!!v&&!f.includes(v)},k=(0,$jscomp.makeIterator)(this.manifest_.variants),l=k.next();!l.done;l=k.next()){l=l.value;var m=shaka.util.StreamUtils.getVariantStreams(l);m=(0,$jscomp.makeIterator)(m);for(var n=m.next();!n.done;n=m.next()){n=n.value;var p=l.allowedByKeySystem;if(n.keyIds.size)if(n.drmInfos.length&&!g.size&&this.manifest_.type==
shaka.media.ManifestParser.HLS)for(var q=(0,$jscomp.makeIterator)(n.drmInfos),r=q.next();!r.done;r=q.next())r=r.value,r.keySystem==d&&(r.keyIds.size?h(l,r.keyIds):h(l,n.keyIds));else h(l,n.keyIds);p!=l.allowedByKeySystem&&(c=!0)}}}if(c&&(this.onTracksChanged_(),!this.updateAbrManagerVariants_()))return;(c=this.streamingEngine_.getCurrentVariant())&&!c.allowedByKeySystem&&(shaka.log.debug("Choosing new streams after key status changed"),this.chooseVariantAndSwitch_())};
shaka.Player.prototype.shouldStreamText_=function(){return this.config_.streaming.alwaysStreamText||this.isTextTrackVisible()};shaka.Player.applyPlayRange_=function(a,b,c){b>0&&(a.isLive()?shaka.log.warning("|playRangeStart| has been configured for live content. Ignoring the setting."):a.setUserSeekStart(b));b=a.getDuration();c<b&&(a.isLive()?shaka.log.warning("|playRangeEnd| has been configured for live content. Ignoring the setting."):a.setDuration(c))};
shaka.Player.prototype.delayDispatchEvent_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.nextAddress==1)return c.yield(Promise.resolve(),2);b.loadMode_!=shaka.Player.LoadMode.DESTROYED&&b.dispatchEvent(a);c.jumpToEnd()})};shaka.Player.getLanguagesFrom_=function(a){var b=new Set;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.language?b.add(shaka.util.LanguageUtils.normalize(c.language)):b.add("und");return b};
shaka.Player.getLanguageAndRolesFrom_=function(a){for(var b=new Map,c=new Map,d=0;d<a.length;d++){var e=a[d],f="und",g=[];e.language&&(f=shaka.util.LanguageUtils.normalize(e.language));(g=e.type=="variant"?e.audioRoles:e.roles)&&g.length||(g=[""]);b.has(f)||b.set(f,new Set);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,b.get(f).add(h),e.label&&(c.has(f)||c.set(f,new Map),c.get(f).set(h,e.label))}var k=[];b.forEach(function(l,m){l=(0,$jscomp.makeIterator)(l);for(var n=
l.next();!n.done;n=l.next()){n=n.value;var p=null;c.has(m)&&c.get(m).has(n)&&(p=c.get(m).get(n));k.push({language:m,role:n,label:p})}});return k};shaka.Player.prototype.createAbortLoadError_=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.LOAD_INTERRUPTED)};shaka.Player.prototype.isRemotePlayback=function(){return this.video_&&this.video_.remote?this.video_.remote.state!="disconnected":!1};
shaka.Player.prototype.isEnded=function(){return!this.video_||this.video_.ended?!0:this.fullyLoaded_&&!this.isLive()&&this.video_.currentTime>=this.seekRange().end};goog.exportSymbol("shaka.Player",shaka.Player);goog.exportProperty(shaka.Player.prototype,"isEnded",shaka.Player.prototype.isEnded);goog.exportProperty(shaka.Player.prototype,"isRemotePlayback",shaka.Player.prototype.isRemotePlayback);goog.exportProperty(shaka.Player.prototype,"addFont",shaka.Player.prototype.addFont);
goog.exportProperty(shaka.Player.prototype,"setVideoContainer",shaka.Player.prototype.setVideoContainer);goog.exportProperty(shaka.Player.prototype,"getFetchedPlaybackInfo",shaka.Player.prototype.getFetchedPlaybackInfo);goog.exportProperty(shaka.Player.prototype,"getManifestParserFactory",shaka.Player.prototype.getManifestParserFactory);goog.exportProperty(shaka.Player.prototype,"getManifest",shaka.Player.prototype.getManifest);goog.exportProperty(shaka.Player.prototype,"retryStreaming",shaka.Player.prototype.retryStreaming);
goog.exportProperty(shaka.Player.prototype,"setMaxHardwareResolution",shaka.Player.prototype.setMaxHardwareResolution);goog.exportProperty(shaka.Player.prototype,"addChaptersTrack",shaka.Player.prototype.addChaptersTrack);goog.exportProperty(shaka.Player.prototype,"addThumbnailsTrack",shaka.Player.prototype.addThumbnailsTrack);goog.exportProperty(shaka.Player.prototype,"addTextTrackAsync",shaka.Player.prototype.addTextTrackAsync);goog.exportProperty(shaka.Player.prototype,"getStats",shaka.Player.prototype.getStats);
goog.exportProperty(shaka.Player.prototype,"getBufferedInfo",shaka.Player.prototype.getBufferedInfo);goog.exportProperty(shaka.Player.prototype,"getSegmentAvailabilityDuration",shaka.Player.prototype.getSegmentAvailabilityDuration);goog.exportProperty(shaka.Player.prototype,"getPresentationStartTimeAsDate",shaka.Player.prototype.getPresentationStartTimeAsDate);goog.exportProperty(shaka.Player.prototype,"getPlayheadTimeAsDate",shaka.Player.prototype.getPlayheadTimeAsDate);
goog.exportProperty(shaka.Player.prototype,"setTextTrackVisibility",shaka.Player.prototype.setTextTrackVisibility);goog.exportProperty(shaka.Player.prototype,"getChaptersAsync",shaka.Player.prototype.getChaptersAsync);goog.exportProperty(shaka.Player.prototype,"getChapters",shaka.Player.prototype.getChapters);goog.exportProperty(shaka.Player.prototype,"getChaptersTracks",shaka.Player.prototype.getChaptersTracks);goog.exportProperty(shaka.Player.prototype,"isTextTrackVisible",shaka.Player.prototype.isTextTrackVisible);
goog.exportProperty(shaka.Player.prototype,"selectVariantsByLabel",shaka.Player.prototype.selectVariantsByLabel);goog.exportProperty(shaka.Player.prototype,"selectTextLanguage",shaka.Player.prototype.selectTextLanguage);goog.exportProperty(shaka.Player.prototype,"selectAudioLanguage",shaka.Player.prototype.selectAudioLanguage);goog.exportProperty(shaka.Player.prototype,"getTextLanguages",shaka.Player.prototype.getTextLanguages);goog.exportProperty(shaka.Player.prototype,"getAudioLanguages",shaka.Player.prototype.getAudioLanguages);
goog.exportProperty(shaka.Player.prototype,"getTextLanguagesAndRoles",shaka.Player.prototype.getTextLanguagesAndRoles);goog.exportProperty(shaka.Player.prototype,"getAudioLanguagesAndRoles",shaka.Player.prototype.getAudioLanguagesAndRoles);goog.exportProperty(shaka.Player.prototype,"getVideoTracks",shaka.Player.prototype.getVideoTracks);goog.exportProperty(shaka.Player.prototype,"selectVideoTrack",shaka.Player.prototype.selectVideoTrack);
goog.exportProperty(shaka.Player.prototype,"getAudioTracks",shaka.Player.prototype.getAudioTracks);goog.exportProperty(shaka.Player.prototype,"selectAudioTrack",shaka.Player.prototype.selectAudioTrack);goog.exportProperty(shaka.Player.prototype,"selectVariantTrack",shaka.Player.prototype.selectVariantTrack);goog.exportProperty(shaka.Player.prototype,"selectTextTrack",shaka.Player.prototype.selectTextTrack);goog.exportProperty(shaka.Player.prototype,"getThumbnails",shaka.Player.prototype.getThumbnails);
goog.exportProperty(shaka.Player.prototype,"getAllThumbnails",shaka.Player.prototype.getAllThumbnails);goog.exportProperty(shaka.Player.prototype,"getImageTracks",shaka.Player.prototype.getImageTracks);goog.exportProperty(shaka.Player.prototype,"getTextTracks",shaka.Player.prototype.getTextTracks);goog.exportProperty(shaka.Player.prototype,"getVariantTracks",shaka.Player.prototype.getVariantTracks);goog.exportProperty(shaka.Player.prototype,"cancelTrickPlay",shaka.Player.prototype.cancelTrickPlay);
goog.exportProperty(shaka.Player.prototype,"trickPlay",shaka.Player.prototype.trickPlay);goog.exportProperty(shaka.Player.prototype,"useTrickPlayTrackIfAvailable",shaka.Player.prototype.useTrickPlayTrackIfAvailable);goog.exportProperty(shaka.Player.prototype,"getPlaybackRate",shaka.Player.prototype.getPlaybackRate);goog.exportProperty(shaka.Player.prototype,"isBuffering",shaka.Player.prototype.isBuffering);goog.exportProperty(shaka.Player.prototype,"getKeyStatuses",shaka.Player.prototype.getKeyStatuses);
goog.exportProperty(shaka.Player.prototype,"getActiveSessionsMetadata",shaka.Player.prototype.getActiveSessionsMetadata);goog.exportProperty(shaka.Player.prototype,"getExpiration",shaka.Player.prototype.getExpiration);goog.exportProperty(shaka.Player.prototype,"drmInfo",shaka.Player.prototype.drmInfo);goog.exportProperty(shaka.Player.prototype,"keySystem",shaka.Player.prototype.keySystem);goog.exportProperty(shaka.Player.prototype,"isFullyLoaded",shaka.Player.prototype.isFullyLoaded);
goog.exportProperty(shaka.Player.prototype,"goToLive",shaka.Player.prototype.goToLive);goog.exportProperty(shaka.Player.prototype,"seekRange",shaka.Player.prototype.seekRange);goog.exportProperty(shaka.Player.prototype,"isVideoOnly",shaka.Player.prototype.isVideoOnly);goog.exportProperty(shaka.Player.prototype,"isAudioOnly",shaka.Player.prototype.isAudioOnly);goog.exportProperty(shaka.Player.prototype,"isInProgress",shaka.Player.prototype.isInProgress);
goog.exportProperty(shaka.Player.prototype,"isLive",shaka.Player.prototype.isLive);goog.exportProperty(shaka.Player.prototype,"getQueueManager",shaka.Player.prototype.getQueueManager);goog.exportProperty(shaka.Player.prototype,"getAdManager",shaka.Player.prototype.getAdManager);goog.exportProperty(shaka.Player.prototype,"getAssetUri",shaka.Player.prototype.getAssetUri);goog.exportProperty(shaka.Player.prototype,"getNetworkingEngine",shaka.Player.prototype.getNetworkingEngine);
goog.exportProperty(shaka.Player.prototype,"getMediaElement",shaka.Player.prototype.getMediaElement);goog.exportProperty(shaka.Player.prototype,"getManifestType",shaka.Player.prototype.getManifestType);goog.exportProperty(shaka.Player.prototype,"getLoadMode",shaka.Player.prototype.getLoadMode);goog.exportProperty(shaka.Player.prototype,"resetConfiguration",shaka.Player.prototype.resetConfiguration);goog.exportProperty(shaka.Player.prototype,"getBufferFullness",shaka.Player.prototype.getBufferFullness);
goog.exportProperty(shaka.Player.prototype,"getNonDefaultConfiguration",shaka.Player.prototype.getNonDefaultConfiguration);goog.exportProperty(shaka.Player.prototype,"getConfigurationForLowLatency",shaka.Player.prototype.getConfigurationForLowLatency);goog.exportProperty(shaka.Player.prototype,"getConfiguration",shaka.Player.prototype.getConfiguration);goog.exportProperty(shaka.Player.prototype,"configurationForLowLatency",shaka.Player.prototype.configurationForLowLatency);
goog.exportProperty(shaka.Player.prototype,"configure",shaka.Player.prototype.configure);goog.exportProperty(shaka.Player.prototype,"releaseAllMutexes",shaka.Player.prototype.releaseAllMutexes);goog.exportProperty(shaka.Player.prototype,"destroyAllPreloads",shaka.Player.prototype.destroyAllPreloads);goog.exportProperty(shaka.Player.prototype,"preload",shaka.Player.prototype.preload);goog.exportProperty(shaka.Player.prototype,"detachAndSavePreload",shaka.Player.prototype.detachAndSavePreload);
goog.exportProperty(shaka.Player.prototype,"unloadAndSavePreload",shaka.Player.prototype.unloadAndSavePreload);goog.exportProperty(shaka.Player.prototype,"load",shaka.Player.prototype.load);goog.exportProperty(shaka.Player.prototype,"updateStartTime",shaka.Player.prototype.updateStartTime);goog.exportProperty(shaka.Player.prototype,"unload",shaka.Player.prototype.unload);goog.exportProperty(shaka.Player.prototype,"detach",shaka.Player.prototype.detach);
goog.exportProperty(shaka.Player.prototype,"attachCanvas",shaka.Player.prototype.attachCanvas);goog.exportProperty(shaka.Player.prototype,"attach",shaka.Player.prototype.attach);goog.exportProperty(shaka.Player,"probeSupport",shaka.Player.probeSupport);goog.exportProperty(shaka.Player,"isBrowserSupported",shaka.Player.isBrowserSupported);goog.exportProperty(shaka.Player,"setQueueManagerFactory",shaka.Player.setQueueManagerFactory);goog.exportProperty(shaka.Player,"setAdManagerFactory",shaka.Player.setAdManagerFactory);
goog.exportProperty(shaka.Player,"registerSupportPlugin",shaka.Player.registerSupportPlugin);goog.exportProperty(shaka.Player.prototype,"destroy",shaka.Player.prototype.destroy);shaka.Player.LoadMode={DESTROYED:0,NOT_LOADED:1,MEDIA_SOURCE:2,SRC_EQUALS:3};goog.exportProperty(shaka.Player,"LoadMode",shaka.Player.LoadMode);shaka.Player.TYPICAL_BUFFERING_THRESHOLD_=.5;shaka.Player.version="v4.16.3-debug";goog.exportProperty(shaka.Player,"version",shaka.Player.version);shaka.Deprecate.init(shaka.Player.version);
shaka.Player.supportPlugins_=new Map;shaka.Player.adManagerFactory_=null;shaka.Player.queueManagerFactory_=null;shaka.Player.TextTrackLabel="Shaka Player TextTrack";shaka.polyfill=function(){};shaka.polyfill.installAll=function(){for(var a=(0,$jscomp.makeIterator)(shaka.polyfill.polyfills_),b=a.next();!b.done;b=a.next()){b=b.value;try{b.callback()}catch(c){shaka.log.alwaysWarn("Error installing polyfill!",c)}}};shaka.polyfill.register=function(a,b){a={priority:b||0,callback:a};for(b=0;b<shaka.polyfill.polyfills_.length;b++)if(shaka.polyfill.polyfills_[b].priority<a.priority){shaka.polyfill.polyfills_.splice(b,0,a);return}shaka.polyfill.polyfills_.push(a)};
goog.exportSymbol("shaka.polyfill",shaka.polyfill);goog.exportProperty(shaka.polyfill,"register",shaka.polyfill.register);goog.exportProperty(shaka.polyfill,"installAll",shaka.polyfill.installAll);shaka.polyfill.polyfills_=[];shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess=function(a,b,c){this.mksa_=a;this.videoScheme_=b||null;this.audioScheme_=c||null;this.keySystem=a.keySystem};
shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess.prototype.getConfiguration=function(){var a=this.mksa_.getConfiguration();if(a.videoCapabilities)for(var b=(0,$jscomp.makeIterator)(a.videoCapabilities),c=b.next();!c.done;c=b.next())c.value.encryptionScheme=this.videoScheme_;if(a.audioCapabilities)for(b=(0,$jscomp.makeIterator)(a.audioCapabilities),c=b.next();!c.done;c=b.next())c.value.encryptionScheme=this.audioScheme_;return a};
shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess.prototype.createMediaKeys=function(){return this.mksa_.createMediaKeys()};shaka.polyfill.EncryptionSchemeUtils=function(){};shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme=function(a){if(a.startsWith("com.apple"))return"cbcs";if(a.startsWith("com.widevine")||a.startsWith("com.microsoft")||a.startsWith("com.chromecast")||a.startsWith("org.w3")||a.startsWith("com.huawei"))return"cenc";shaka.log.alwaysWarn("EmeEncryptionSchemePolyfill: Unknown key system:",a,"Please contribute!");return null};
shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme=function(a){if(!a)return!1;a=a.getConfiguration();var b=a.audioCapabilities&&a.audioCapabilities[0];return(a=a.videoCapabilities&&a.videoCapabilities[0]||b)&&a.encryptionScheme!==void 0?!0:!1};shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme=function(a,b){return!a||a==b||(a=="cbcs"||a=="cbcs-1-9")&&shaka.device.DeviceFactory.getDevice().supportsCbcsWithoutEncryptionSchemeSupport()?!0:!1};shaka.polyfill.EmeEncryptionScheme=function(){};
shaka.polyfill.EmeEncryptionScheme.install=function(){shaka.device.DeviceFactory.getDevice().supportsEncryptionSchemePolyfill()&&(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_||navigator.emeEncryptionSchemePolyfilled?shaka.log.debug("EmeEncryptionSchemePolyfill:","Already installed."):navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration?(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_=navigator.requestMediaKeySystemAccess,shaka.log.debug("EmeEncryptionSchemePolyfill:",
"Waiting to detect encryptionScheme support."),navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.probeRMKSA_,navigator.emeEncryptionSchemePolyfilled=!0):shaka.log.debug("EmeEncryptionSchemePolyfill:","EME not found"))};
shaka.polyfill.EmeEncryptionScheme.probeRMKSA_=function(a,b){var c=this,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1)return d="EmeEncryptionSchemePolyfill:",goog.asserts.assert(c==navigator,'bad "this" for requestMediaKeySystemAccess'),g.yield(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_.call(c,a,b),2);e=g.yieldResult;if(f=shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme(e))return shaka.log.debug(d,"Native encryptionScheme support found."),
navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.originalRMKSA_,g.return(e);shaka.log.debug(d,"No native encryptionScheme support found. Patching encryptionScheme support.");navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_;return g.return(shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_.call(c,a,b))})};
shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){if(t.nextAddress==1){goog.asserts.assert(c==navigator,'bad "this" for requestMediaKeySystemAccess');d=shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme(a);e=[];f=(0,$jscomp.makeIterator)(b);for(g=f.next();!g.done;g=f.next())h=g.value,k=shaka.polyfill.EmeEncryptionScheme.filterCapabilities_(h.videoCapabilities,d),l=shaka.polyfill.EmeEncryptionScheme.filterCapabilities_(h.audioCapabilities,
d),h.videoCapabilities&&h.videoCapabilities.length&&!k.length||h.audioCapabilities&&h.audioCapabilities.length&&!l.length||(m=Object.assign({},h),m.videoCapabilities=k,m.audioCapabilities=l,e.push(m));if(!e.length)throw n=Error("Unsupported keySystem or supportedConfigurations."),n.name="NotSupportedError",n.code=DOMException.NOT_SUPPORTED_ERR,n;return t.yield(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_.call(c,a,e),2)}p=t.yieldResult;r=q=null;e[0]&&(e[0].videoCapabilities&&(q=e[0].videoCapabilities[0].encryptionScheme),
e[0].audioCapabilities&&(r=e[0].audioCapabilities[0].encryptionScheme));return t.return(new shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess(p,q,r))})};shaka.polyfill.EmeEncryptionScheme.filterCapabilities_=function(a,b){return a?a.filter(function(c){return shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(c.encryptionScheme,b)}):a};goog.exportProperty(shaka.polyfill,"EmeEncryptionScheme",shaka.polyfill.EmeEncryptionScheme);
goog.exportProperty(shaka.polyfill.EmeEncryptionScheme,"install",shaka.polyfill.EmeEncryptionScheme.install);shaka.polyfill.register(shaka.polyfill.EmeEncryptionScheme.install);shaka.polyfill.MCapEncryptionScheme=function(){};
shaka.polyfill.MCapEncryptionScheme.install=function(){shaka.device.DeviceFactory.getDevice().supportsEncryptionSchemePolyfill()&&(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_||navigator.mediaCapabilitiesEncryptionSchemePolyfilled?shaka.log.debug("McEncryptionSchemePolyfill:","Already installed."):navigator.mediaCapabilities?(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,shaka.log.debug("McEncryptionSchemePolyfill:","Waiting to detect encryptionScheme support."),
navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.probeDecodingInfo_,navigator.mediaCapabilitiesEncryptionSchemePolyfilled=!0):shaka.log.debug("McEncryptionSchemePolyfill:","MediaCapabilities not found"))};
shaka.polyfill.MCapEncryptionScheme.probeDecodingInfo_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.nextAddress){case 1:return c="McEncryptionSchemePolyfill:",goog.asserts.assert(b==navigator.mediaCapabilities,'bad "this" for decodingInfo'),g.yield(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_.call(b,a),2);case 2:d=g.yieldResult;if(!d.supported||!a.keySystemConfiguration)return g.return(d);e=d.keySystemAccess;if(f=shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme(e))return shaka.log.debug(c,
"Native encryptionScheme support found."),navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_,g.return(d);shaka.log.debug(c,"No native encryptionScheme support found. Patching encryptionScheme support.");navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_;if(e){g.jumpTo(3);break}return g.yield(shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_(a),4);case 4:return d.keySystemAccess=g.yieldResult,
g.return(d);case 3:return g.return(shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_.call(b,a))}})};
shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_=function(a){var b=this,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.nextAddress){case 1:return goog.asserts.assert(b==navigator.mediaCapabilities,'bad "this" for decodingInfo'),d=c=null,!a.keySystemConfiguration||(e=a.keySystemConfiguration,f=e.keySystem,d=e.audio&&e.audio.encryptionScheme,c=e.video&&e.video.encryptionScheme,g=shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme(f),h={powerEfficient:!1,
smooth:!1,supported:!1,keySystemAccess:null,configuration:a},shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(d,g)&&shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(c,g))?l.yield(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_.call(b,a),2):l.return(h);case 2:k=l.yieldResult;if(k.keySystemAccess){k.keySystemAccess=new shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess(k.keySystemAccess,c,d);l.jumpTo(3);break}if(!a.keySystemConfiguration){l.jumpTo(3);break}return l.yield(shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_(a),
5);case 5:k.keySystemAccess=l.yieldResult;case 3:return l.return(k)}})};shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_=function(a){var b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.nextAddress==1)return b=shaka.polyfill.MCapEncryptionScheme.convertToMediaKeySystemConfig_(a),d.yield(navigator.requestMediaKeySystemAccess(a.keySystemConfiguration.keySystem,[b]),2);c=d.yieldResult;return d.return(c)})};
shaka.polyfill.MCapEncryptionScheme.convertToMediaKeySystemConfig_=function(a){var b=a.keySystemConfiguration,c=[],d=[];b.audio&&c.push({robustness:b.audio.robustness||"",contentType:a.audio.contentType,encryptionScheme:b.audio.encryptionScheme});b.video&&d.push({robustness:b.video.robustness||"",contentType:a.video.contentType,encryptionScheme:b.video.encryptionScheme});a={initDataTypes:b.initDataType?[b.initDataType]:[],distinctiveIdentifier:b.distinctiveIdentifier,persistentState:b.persistentState,
sessionTypes:b.sessionTypes};c.length&&(a.audioCapabilities=c);d.length&&(a.videoCapabilities=d);return a};goog.exportProperty(shaka.polyfill,"MCapEncryptionScheme",shaka.polyfill.MCapEncryptionScheme);goog.exportProperty(shaka.polyfill.MCapEncryptionScheme,"install",shaka.polyfill.MCapEncryptionScheme.install);shaka.polyfill.register(shaka.polyfill.MCapEncryptionScheme.install,-2);shaka.polyfill.MediaCapabilities=function(){};shaka.polyfill.MediaCapabilities.install=function(){shaka.device.DeviceFactory.getDevice().supportsMediaCapabilities()?shaka.log.info("MediaCapabilities: Native mediaCapabilities support found."):(shaka.log.info("MediaCapabilities: install"),navigator.mediaCapabilities||(navigator.mediaCapabilities={}),shaka.polyfill.MediaCapabilities.originalMcap=navigator.mediaCapabilities,navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MediaCapabilities.decodingInfo_)};
shaka.polyfill.MediaCapabilities.decodingInfo_=function(a){var b,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.nextAddress){case 1:b={supported:!1,powerEfficient:!0,smooth:!0,keySystemAccess:null,configuration:a};c=shaka.device.DeviceFactory.getDevice();d=a.video;e=a.audio;if(a.type!="media-source"){if(a.type=="file"){if(d&&(f=d.contentType,g=c.supportsMediaType(f),!g)||e&&(h=e.contentType,k=c.supportsMediaType(h),!k))return q.return(b)}else return q.return(b);
q.jumpTo(2);break}if(!c.supportsMediaSource())return q.return(b);if(!d){q.jumpTo(3);break}return q.yield(shaka.polyfill.MediaCapabilities.checkVideoSupport_(d),4);case 4:if(l=q.yieldResult,!l)return q.return(b);case 3:if(e&&(m=shaka.polyfill.MediaCapabilities.checkAudioSupport_(e),!m))return q.return(b);case 2:if(!a.keySystemConfiguration)return b.supported=!0,q.return(b);n=a.keySystemConfiguration;return q.yield(shaka.polyfill.MediaCapabilities.checkDrmSupport_(d,e,n),6);case 6:if(p=q.yieldResult)b.supported=
!0,b.keySystemAccess=p;case 5:return q.return(b)}})};shaka.polyfill.MediaCapabilities.checkVideoSupport_=function(a){var b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.nextAddress==1?(b=shaka.device.DeviceFactory.getDevice(),c=b.getDeviceType(),c!==shaka.device.IDevice.DeviceType.CAST?e.jumpTo(2):e.yield(shaka.polyfill.MediaCapabilities.canCastDisplayType_(a),3)):e.nextAddress!=2?(d=e.yieldResult,e.return(d)):e.return(shaka.media.Capabilities.isTypeSupported(a.contentType))})};
shaka.polyfill.MediaCapabilities.checkAudioSupport_=function(a){var b=shaka.device.DeviceFactory.getDevice().getDeviceType(),c=a.contentType;b===shaka.device.IDevice.DeviceType.CAST&&a.spatialRendering&&(c+="; spatialRendering=true");return shaka.media.Capabilities.isTypeSupported(c)};
shaka.polyfill.MediaCapabilities.checkDrmSupport_=function(a,b,c){var d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.nextAddress){case 1:d=shaka.util.MimeUtils;e=[];f=[];c.audio&&(g={robustness:c.audio.robustness||"",contentType:b.contentType},shaka.device.DeviceFactory.getDevice().misreportAC3UsingDrm()&&b.contentType.includes('codecs="ac-3"')&&(g.contentType='audio/mp4; codecs="ec-3"'),c.audio.encryptionScheme&&(g.encryptionScheme=c.audio.encryptionScheme),
e.push(g));c.video&&(h={robustness:c.video.robustness||"",contentType:a.contentType},c.video.encryptionScheme&&(h.encryptionScheme=c.video.encryptionScheme),f.push(h));k={initDataTypes:[c.initDataType],distinctiveIdentifier:c.distinctiveIdentifier,persistentState:c.persistentState,sessionTypes:c.sessionTypes};e.length&&(k.audioCapabilities=e);f.length&&(k.videoCapabilities=f);l=a?a.contentType:"";m=b?b.contentType:"";n=d.getBasicType(l)+";"+d.getCodecBase(l);p=d.getBasicType(m)+";"+d.getCodecBase(m);
q=c.keySystem;r=null;t.setCatchFinallyBlocks(2);if(shaka.drm.DrmUtils.hasMediaKeySystemAccess(n,p,q)){r=shaka.drm.DrmUtils.getMediaKeySystemAccess(n,p,q);t.jumpTo(4);break}return t.yield(navigator.requestMediaKeySystemAccess(c.keySystem,[k]),5);case 5:r=t.yieldResult,shaka.drm.DrmUtils.setMediaKeySystemAccess(n,p,q,r);case 4:t.leaveTryBlock(3);break;case 2:t.enterCatchBlock(),shaka.log.info("navigator.requestMediaKeySystemAccess failed.");case 3:return t.return(r)}})};
shaka.polyfill.MediaCapabilities.canCastDisplayType_=function(a){var b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.nextAddress==1){if(!(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType))return shaka.log.warning("Expected cast APIs to be available! Falling back to shaka.media.Capabilities.isTypeSupported() for type support."),g.return(shaka.media.Capabilities.isTypeSupported(a.contentType));b=a.contentType;a.width&&a.height&&a.width>1280&&a.height>
720&&(b+="; width="+a.width+"; height="+a.height);a.framerate&&(c=Math.round(a.framerate),c<24||c>30)&&(b+="; framerate="+a.framerate);d=a.transferFunction||"";switch(d){case "":case "srgb":break;case "pq":b+="; eotf=smpte2084";break;case "hlg":b+="; eotf=arib-std-b67";break;default:return g.return(!1)}e=!1;f=shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_;return f.has(b)?(e=f.get(b),g.jumpTo(2)):g.yield(cast.__platform__.canDisplayType(b),3)}g.nextAddress!=2&&(e=g.yieldResult,f.set(b,
e));return g.return(e)})};goog.exportProperty(shaka.polyfill,"MediaCapabilities",shaka.polyfill.MediaCapabilities);goog.exportProperty(shaka.polyfill.MediaCapabilities,"install",shaka.polyfill.MediaCapabilities.install);shaka.polyfill.MediaCapabilities.originalMcap=null;goog.exportProperty(shaka.polyfill.MediaCapabilities,"originalMcap",shaka.polyfill.MediaCapabilities.originalMcap);shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_=new Map;
shaka.polyfill.register(shaka.polyfill.MediaCapabilities.install,-1);shaka.polyfill.MediaSource=function(){};
shaka.polyfill.MediaSource.install=function(){shaka.log.debug("MediaSource.install");var a=shaka.device.IDevice.BrowserEngine,b=shaka.device.DeviceFactory.getDevice();a=b.getBrowserEngine()===a.WEBKIT?b.getVersion():null;window.MediaSource||window.ManagedMediaSource?a&&window.MediaSource?a<=12?(shaka.log.info("Patching Safari 8-12 MSE bugs."),shaka.polyfill.MediaSource.stubAbort_(),shaka.polyfill.MediaSource.patchRemovalRange_()):a<=15&&(shaka.log.info("Patching Safari 13 & 14 & 15 MSE bugs."),shaka.polyfill.MediaSource.stubAbort_()):
shaka.log.info("Using native MSE as-is."):shaka.log.info("No MSE implementation available.");b=(0,$jscomp.makeIterator)(b.rejectCodecs());for(a=b.next();!a.done;a=b.next())a=a.value,shaka.log.info("Rejecting "+a+"."),shaka.polyfill.MediaSource.rejectCodec_(a);(window.MediaSource||window.ManagedMediaSource)&&shaka.polyfill.MediaSource.rejectContainer_("mp2t");window.MediaSource&&MediaSource.isTypeSupported('video/webm; codecs="vp9"')&&!MediaSource.isTypeSupported('video/webm; codecs="vp09.00.10.08"')&&
(shaka.log.info("Patching vp09 support queries."),shaka.polyfill.MediaSource.patchVp09_())};shaka.polyfill.MediaSource.stubAbort_=function(){var a=MediaSource.prototype.addSourceBuffer;MediaSource.prototype.addSourceBuffer=function(){var b=$jscomp.getRestArguments.apply(0,arguments);b=a.apply(this,b);b.abort=function(){};return b}};shaka.polyfill.MediaSource.patchRemovalRange_=function(){var a=SourceBuffer.prototype.remove;SourceBuffer.prototype.remove=function(b,c){return a.call(this,b,c-.001)}};
shaka.polyfill.MediaSource.rejectContainer_=function(a){if(window.MediaSource){var b=MediaSource.isTypeSupported.bind(MediaSource);MediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getContainerType(d)!=a&&b(d)}}if(window.ManagedMediaSource){var c=ManagedMediaSource.isTypeSupported.bind(ManagedMediaSource);window.ManagedMediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getContainerType(d)!=a&&c(d)}}};
shaka.polyfill.MediaSource.rejectCodec_=function(a){var b=MediaSource.isTypeSupported.bind(MediaSource);MediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getCodecBase(d)!=a&&b(d)};if(window.ManagedMediaSource){var c=ManagedMediaSource.isTypeSupported.bind(ManagedMediaSource);window.ManagedMediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getCodecBase(d)!=a&&c(d)}}};
shaka.polyfill.MediaSource.patchVp09_=function(){var a=MediaSource.isTypeSupported;shaka.device.DeviceFactory.getDevice().supportStandardVP9Checking()&&(MediaSource.isTypeSupported=function(b){var c=b.split(/ *; */),d=c.findIndex(function(g){return g.startsWith("codecs=")});if(d<0)return a(b);var e=c[d].replace("codecs=","").replace(/"/g,"").split(/\s*,\s*/),f=e.findIndex(function(g){return g.startsWith("vp09")});f>=0&&(e[f]="vp9",c[d]='codecs="'+e.join(",")+'"',b=c.join("; "));return a(b)})};
goog.exportProperty(shaka.polyfill,"MediaSource",shaka.polyfill.MediaSource);goog.exportProperty(shaka.polyfill.MediaSource,"install",shaka.polyfill.MediaSource.install);shaka.polyfill.register(shaka.polyfill.MediaSource.install);shaka.polyfill.PatchedMediaKeysApple=function(){};shaka.polyfill.PatchedMediaKeysApple.defaultInstall=function(){window.HTMLVideoElement&&window.WebKitMediaKeys&&(navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration||shaka.polyfill.PatchedMediaKeysApple.install())};
shaka.polyfill.PatchedMediaKeysApple.install=function(a){var b=shaka.polyfill.PatchedMediaKeysApple;if(window.HTMLVideoElement&&window.WebKitMediaKeys&&window.shakaMediaKeysPolyfill!=b.apiName_){if(a===void 0?0:a)b.enableUninstall=!0,b.originalHTMLMediaElementPrototypeMediaKeys=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"mediaKeys"),b.originalHTMLMediaElementPrototypeSetMediaKeys=HTMLMediaElement.prototype.setMediaKeys,b.originalWindowMediaKeys=window.MediaKeys,b.originalWindowMediaKeySystemAccess=
window.MediaKeySystemAccess,b.originalNavigatorRequestMediaKeySystemAccess=navigator.requestMediaKeySystemAccess;shaka.log.info("Using Apple-prefixed EME");delete HTMLMediaElement.prototype.mediaKeys;HTMLMediaElement.prototype.mediaKeys=null;HTMLMediaElement.prototype.setMediaKeys=b.setMediaKeys;window.MediaKeys=b.MediaKeys;window.MediaKeySystemAccess=b.MediaKeySystemAccess;navigator.requestMediaKeySystemAccess=b.requestMediaKeySystemAccess;window.shakaMediaKeysPolyfill=b.apiName_;shaka.util.StreamUtils.clearDecodingConfigCache();
shaka.drm.DrmUtils.clearMediaKeySystemAccessMap()}};
shaka.polyfill.PatchedMediaKeysApple.uninstall=function(){var a=shaka.polyfill.PatchedMediaKeysApple;window.shakaMediaKeysPolyfill==a.apiName_&&a.enableUninstall&&(shaka.log.info("Un-installing Apple-prefixed EME"),a.enableUninstall=!1,Object.defineProperty(HTMLMediaElement.prototype,"mediaKeys",a.originalHTMLMediaElementPrototypeMediaKeys),HTMLMediaElement.prototype.setMediaKeys=a.originalHTMLMediaElementPrototypeSetMediaKeys,window.MediaKeys=a.originalWindowMediaKeys,window.MediaKeySystemAccess=
a.originalWindowMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=a.originalNavigatorRequestMediaKeySystemAccess,a.originalWindowMediaKeys=null,a.originalWindowMediaKeySystemAccess=null,a.originalHTMLMediaElementPrototypeSetMediaKeys=null,a.originalNavigatorRequestMediaKeySystemAccess=null,a.originalHTMLMediaElementPrototypeMediaKeys=null,window.shakaMediaKeysPolyfill="",shaka.util.StreamUtils.clearDecodingConfigCache(),shaka.drm.DrmUtils.clearMediaKeySystemAccessMap())};
shaka.polyfill.PatchedMediaKeysApple.requestMediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysApple.requestMediaKeySystemAccess");goog.asserts.assert(this==navigator,'bad "this" for requestMediaKeySystemAccess');var c=shaka.polyfill.PatchedMediaKeysApple;try{var d=new c.MediaKeySystemAccess(a,b);return Promise.resolve(d)}catch(e){return Promise.reject(e)}};
shaka.polyfill.PatchedMediaKeysApple.setMediaKeys=function(a){shaka.log.debug("PatchedMediaKeysApple.setMediaKeys");goog.asserts.assert(this instanceof HTMLMediaElement,'bad "this" for setMediaKeys');var b=shaka.polyfill.PatchedMediaKeysApple,c=this.mediaKeys;c&&c!=a&&(goog.asserts.assert(c instanceof b.MediaKeys,"non-polyfill instance of oldMediaKeys"),c.setMedia(null));delete this.mediaKeys;return(this.mediaKeys=a)?(goog.asserts.assert(a instanceof b.MediaKeys,"non-polyfill instance of newMediaKeys"),
a.setMedia(this)):Promise.resolve()};
shaka.polyfill.PatchedMediaKeysApple.onWebkitNeedKey_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitNeedKey_",a);goog.asserts.assert(this.mediaKeys instanceof shaka.polyfill.PatchedMediaKeysApple.MediaKeys,"non-polyfill instance of newMediaKeys");goog.asserts.assert(a.initData!=null,"missing init data!");a=shaka.util.BufferUtils.toUint8(a.initData);if(shaka.util.BufferUtils.toDataView(a).getUint32(0,!0)+4!=a.byteLength)throw new RangeError("Malformed FairPlay init data");a=shaka.util.StringUtils.fromUTF16(a.subarray(4),
!0);a=shaka.util.StringUtils.toUTF8(a);var b=new Event("encrypted");b.initDataType="skd";b.initData=shaka.util.BufferUtils.toArrayBuffer(a);this.dispatchEvent(b)};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysApple",shaka.polyfill.PatchedMediaKeysApple);goog.exportProperty(shaka.polyfill.PatchedMediaKeysApple,"uninstall",shaka.polyfill.PatchedMediaKeysApple.uninstall);goog.exportProperty(shaka.polyfill.PatchedMediaKeysApple,"install",shaka.polyfill.PatchedMediaKeysApple.install);
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess");this.keySystem=a;if(a.startsWith("com.apple.fps"))for(a=(0,$jscomp.makeIterator)(b),b=a.next();!b.done;b=a.next())if(b=this.checkConfig_(b.value)){this.configuration_=b;return}a=Error("Unsupported keySystem");a.name="NotSupportedError";a.code=DOMException.NOT_SUPPORTED_ERR;throw a;};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.checkConfig_=function(a){if(a.persistentState=="required")return null;var b={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",initDataTypes:a.initDataTypes,sessionTypes:["temporary"],label:a.label},c=!1,d=!1;if(a.audioCapabilities)for(var e=(0,$jscomp.makeIterator)(a.audioCapabilities),f=e.next();!f.done;f=e.next())if(f=f.value,f.contentType){c=!0;var g=f.contentType.split(";")[0];
WebKitMediaKeys.isTypeSupported(this.keySystem,g)&&(b.audioCapabilities.push(f),d=!0)}if(a.videoCapabilities)for(a=(0,$jscomp.makeIterator)(a.videoCapabilities),e=a.next();!e.done;e=a.next())e=e.value,e.contentType&&(c=!0,f=e.contentType.split(";")[0],WebKitMediaKeys.isTypeSupported(this.keySystem,f)&&(b.videoCapabilities.push(e),d=!0));c||(d=WebKitMediaKeys.isTypeSupported(this.keySystem,"video/mp4"));return d?b:null};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.createMediaKeys=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess.createMediaKeys");var a=new shaka.polyfill.PatchedMediaKeysApple.MediaKeys(this.keySystem);return Promise.resolve(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.getConfiguration=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess.getConfiguration");return this.configuration_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys");this.nativeMediaKeys_=new WebKitMediaKeys(a);this.eventManager_=new shaka.util.EventManager};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.createSession=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys.createSession");a=a||"temporary";if(a!="temporary")throw new TypeError("Session type "+a+" is unsupported on this platform.");return new shaka.polyfill.PatchedMediaKeysApple.MediaKeySession(this.nativeMediaKeys_,a)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.setServerCertificate=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys.setServerCertificate");return Promise.resolve(!1)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.setMedia=function(a){var b=this,c=shaka.polyfill.PatchedMediaKeysApple;this.eventManager_.removeAll();if(!a)return Promise.resolve();this.eventManager_.listen(a,"webkitneedkey",c.onWebkitNeedKey_);try{return shaka.util.MediaReadyState.waitForReadyState(a,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){a.webkitSetMediaKeys(b.nativeMediaKeys_)}),Promise.resolve()}catch(d){return Promise.reject(d)}};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.getStatusForPolicy=function(a){return Promise.resolve("usable")};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession=function(a,b){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession");shaka.util.FakeEventTarget.call(this);this.nativeMediaKeySession_=null;this.nativeMediaKeys_=a;this.updatePromise_=this.generateRequestPromise_=null;this.eventManager_=new shaka.util.EventManager;this.sessionId="";this.expiration=NaN;this.closed=new shaka.util.PublicPromise;this.keyStatuses=new shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap;this.onkeystatuseschange=null};
$jscomp.inherits(shaka.polyfill.PatchedMediaKeysApple.MediaKeySession,shaka.util.FakeEventTarget);
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.generateRequest=function(a,b){var c=this;shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.generateRequest");this.generateRequestPromise_=new shaka.util.PublicPromise;try{var d=this.nativeMediaKeys_.createSession("video/mp4",shaka.util.BufferUtils.toUint8(b));this.nativeMediaKeySession_=d;this.sessionId=d.sessionId||"";this.eventManager_.listen(this.nativeMediaKeySession_,"webkitkeymessage",function(e){return c.onWebkitKeyMessage_(e)});
this.eventManager_.listen(d,"webkitkeyadded",function(e){return c.onWebkitKeyAdded_(e)});this.eventManager_.listen(d,"webkitkeyerror",function(e){return c.onWebkitKeyError_(e)});this.updateKeyStatus_("status-pending")}catch(e){this.generateRequestPromise_.reject(e)}return this.generateRequestPromise_};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.load=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.load");return Promise.reject(Error("MediaKeySession.load not yet supported"))};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.update=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.update");this.updatePromise_=new shaka.util.PublicPromise;try{this.nativeMediaKeySession_.update(shaka.util.BufferUtils.toUint8(a))}catch(b){this.updatePromise_.reject(b)}return this.updatePromise_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.close=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.close");try{this.nativeMediaKeySession_.close(),this.closed.resolve(),this.eventManager_.removeAll()}catch(a){this.closed.reject(a)}return this.closed};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.remove=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.remove");return Promise.reject(Error("MediaKeySession.remove is only applicable for persistent licenses, which are not supported on this platform"))};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyMessage_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyMessage_",a);goog.asserts.assert(this.generateRequestPromise_,"generateRequestPromise_ should be set before now!");this.generateRequestPromise_&&(this.generateRequestPromise_.resolve(),this.generateRequestPromise_=null);var b=this.keyStatuses.getStatus()==void 0;a=(new Map).set("messageType",b?"license-request":"license-renewal").set("message",shaka.util.BufferUtils.toArrayBuffer(a.message));
a=new shaka.util.FakeEvent("message",a);this.dispatchEvent(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyAdded_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyAdded_",a);goog.asserts.assert(!this.generateRequestPromise_,"Key added during generate!");goog.asserts.assert(this.updatePromise_,"updatePromise_ should be set before now!");this.updatePromise_&&(this.updateKeyStatus_("usable"),this.updatePromise_.resolve(),this.updatePromise_=null)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyError_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyError_",a);a=Error("EME PatchedMediaKeysApple key error");a.errorCode=this.nativeMediaKeySession_.error;if(this.generateRequestPromise_!=null)this.generateRequestPromise_.reject(a),this.generateRequestPromise_=null;else if(this.updatePromise_!=null)this.updatePromise_.reject(a),this.updatePromise_=null;else switch(this.nativeMediaKeySession_.error.code){case WebKitMediaKeyError.MEDIA_KEYERR_OUTPUT:case WebKitMediaKeyError.MEDIA_KEYERR_HARDWARECHANGE:this.updateKeyStatus_("output-not-allowed");
break;default:this.updateKeyStatus_("internal-error")}};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.updateKeyStatus_=function(a){this.keyStatuses.setStatus(a);a=new shaka.util.FakeEvent("keystatuseschange");this.dispatchEvent(a);if(this.onkeystatuseschange)this.onkeystatuseschange(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap=function(){this.size=0;this.status_=void 0};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.setStatus=function(a){this.size=a==void 0?0:1;this.status_=a};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.getStatus=function(){return this.status_};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.forEach=function(a){this.status_&&a(this.status_,shaka.drm.DrmUtils.DUMMY_KEY_ID.value())};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.get=function(a){if(this.has(a))return this.status_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.has=function(a){var b=shaka.drm.DrmUtils.DUMMY_KEY_ID.value();return this.status_&&shaka.util.BufferUtils.equal(a,b)?!0:!1};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.entries=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.keys=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.values=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};shaka.polyfill.PatchedMediaKeysApple.apiName_="apple";shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysApple.defaultInstall);shaka.polyfill.PatchedMediaKeysCert=function(){};shaka.polyfill.PatchedMediaKeysCert.install=function(){if(window.MediaKeys){var a=shaka.device.DeviceFactory.getDevice();MediaKeys.prototype.setServerCertificate&&a.supportsServerCertificate()||(shaka.log.info("Patching MediaKeys.setServerCertificate"),MediaKeys.prototype.setServerCertificate=shaka.polyfill.PatchedMediaKeysCert.setServerCertificate_)}};
shaka.polyfill.PatchedMediaKeysCert.setServerCertificate_=function(a){shaka.log.debug("PatchedMediaKeysCert.setServerCertificate");return Promise.resolve(!1)};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysCert",shaka.polyfill.PatchedMediaKeysCert);goog.exportProperty(shaka.polyfill.PatchedMediaKeysCert,"install",shaka.polyfill.PatchedMediaKeysCert.install);shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysCert.install);shaka.polyfill.PatchedMediaKeysWebkit=function(){};
shaka.polyfill.PatchedMediaKeysWebkit.install=function(){var a=shaka.polyfill.PatchedMediaKeysWebkit;if(!(!window.HTMLVideoElement||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration)){if(HTMLMediaElement.prototype.webkitGenerateKeyRequest)shaka.log.info("Using webkit-prefixed EME v0.1b"),a.prefix_="webkit";else if(HTMLMediaElement.prototype.generateKeyRequest)shaka.log.info("Using nonprefixed EME v0.1b");else return;goog.asserts.assert(HTMLMediaElement.prototype[a.prefixApi_("generateKeyRequest")],
"PatchedMediaKeysWebkit APIs not available!");navigator.requestMediaKeySystemAccess=a.requestMediaKeySystemAccess;delete HTMLMediaElement.prototype.mediaKeys;HTMLMediaElement.prototype.mediaKeys=null;HTMLMediaElement.prototype.setMediaKeys=a.setMediaKeys;window.MediaKeys=a.MediaKeys;window.MediaKeySystemAccess=a.MediaKeySystemAccess;window.shakaMediaKeysPolyfill=a.apiName_}};
shaka.polyfill.PatchedMediaKeysWebkit.prefixApi_=function(a){var b=shaka.polyfill.PatchedMediaKeysWebkit.prefix_;return b?b+a.charAt(0).toUpperCase()+a.slice(1):a};shaka.polyfill.PatchedMediaKeysWebkit.requestMediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.requestMediaKeySystemAccess");goog.asserts.assert(this==navigator,'bad "this" for requestMediaKeySystemAccess');var c=shaka.polyfill.PatchedMediaKeysWebkit;try{var d=new c.MediaKeySystemAccess(a,b);return Promise.resolve(d)}catch(e){return Promise.reject(e)}};
shaka.polyfill.PatchedMediaKeysWebkit.setMediaKeys=function(a){shaka.log.debug("PatchedMediaKeysWebkit.setMediaKeys");goog.asserts.assert(this instanceof HTMLMediaElement,'bad "this" for setMediaKeys');var b=shaka.polyfill.PatchedMediaKeysWebkit,c=this.mediaKeys;c&&c!=a&&(goog.asserts.assert(c instanceof b.MediaKeys,"non-polyfill instance of oldMediaKeys"),c.setMedia(null));delete this.mediaKeys;if(this.mediaKeys=a)goog.asserts.assert(a instanceof b.MediaKeys,"non-polyfill instance of newMediaKeys"),
a.setMedia(this);return Promise.resolve()};shaka.polyfill.PatchedMediaKeysWebkit.getVideoElement_=function(){var a=document.getElementsByTagName("video");return a.length?a[0]:document.createElement("video")};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysWebkit",shaka.polyfill.PatchedMediaKeysWebkit);goog.exportProperty(shaka.polyfill.PatchedMediaKeysWebkit,"install",shaka.polyfill.PatchedMediaKeysWebkit.install);
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess");this.internalKeySystem_=this.keySystem=a;var c=!1;a=="org.w3.clearkey"&&(this.internalKeySystem_="webkit-org.w3.clearkey",c=!1);var d=!1,e=shaka.polyfill.PatchedMediaKeysWebkit.getVideoElement_();b=(0,$jscomp.makeIterator)(b);for(var f=b.next();!f.done;f=b.next()){f=f.value;var g={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",
initDataTypes:f.initDataTypes,sessionTypes:["temporary"],label:f.label},h=!1;if(f.audioCapabilities)for(var k=(0,$jscomp.makeIterator)(f.audioCapabilities),l=k.next();!l.done;l=k.next())if(l=l.value,l.contentType){h=!0;var m=l.contentType.split(";")[0];e.canPlayType(m,this.internalKeySystem_)&&(g.audioCapabilities.push(l),d=!0)}if(f.videoCapabilities)for(k=(0,$jscomp.makeIterator)(f.videoCapabilities),l=k.next();!l.done;l=k.next())l=l.value,l.contentType&&(h=!0,e.canPlayType(l.contentType,this.internalKeySystem_)&&
(g.videoCapabilities.push(l),d=!0));h||(d=e.canPlayType("video/mp4",this.internalKeySystem_)||e.canPlayType("video/webm",this.internalKeySystem_));f.persistentState=="required"&&(c?(g.persistentState="required",g.sessionTypes=["persistent-license"]):d=!1);if(d){this.configuration_=g;return}}c="Unsupported keySystem";if(a=="org.w3.clearkey"||a=="com.widevine.alpha")c="None of the requested configurations were supported.";a=Error(c);a.name="NotSupportedError";a.code=DOMException.NOT_SUPPORTED_ERR;throw a;
};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess.prototype.createMediaKeys=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess.createMediaKeys");var a=new shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys(this.internalKeySystem_);return Promise.resolve(a)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess.prototype.getConfiguration=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess.getConfiguration");return this.configuration_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys");this.keySystem_=a;this.media_=null;this.eventManager_=new shaka.util.EventManager;this.newSessions_=[];this.sessionMap_=new Map};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.setMedia=function(a){var b=this;this.media_=a;this.eventManager_.removeAll();var c=shaka.polyfill.PatchedMediaKeysWebkit.prefix_;a&&(this.eventManager_.listen(a,c+"needkey",function(d){return b.onWebkitNeedKey_(d)}),this.eventManager_.listen(a,c+"keymessage",function(d){return b.onWebkitKeyMessage_(d)}),this.eventManager_.listen(a,c+"keyadded",function(d){return b.onWebkitKeyAdded_(d)}),this.eventManager_.listen(a,c+"keyerror",function(d){return b.onWebkitKeyError_(d)}))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.createSession=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.createSession");a=a||"temporary";if(a!="temporary"&&a!="persistent-license")throw new TypeError("Session type "+a+" is unsupported on this platform.");var b=shaka.polyfill.PatchedMediaKeysWebkit,c=this.media_||document.createElement("video");c.src||(c.src="about:blank");a=new b.MediaKeySession(c,this.keySystem_,a);this.newSessions_.push(a);return a};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.setServerCertificate=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.setServerCertificate");return Promise.resolve(!1)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.getStatusForPolicy=function(a){return Promise.resolve("usable")};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitNeedKey_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitNeedKey_",a);goog.asserts.assert(this.media_,"media_ not set in onWebkitNeedKey_");var b=new CustomEvent("encrypted");b.initDataType="cenc";b.initData=shaka.util.BufferUtils.toArrayBuffer(a.initData);this.media_.dispatchEvent(b)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyMessage_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyMessage_",a);var b=this.findSession_(a.sessionId);if(b){var c=b.keyStatuses.getStatus()==void 0;a=(new Map).set("messageType",c?"licenserequest":"licenserenewal").set("message",a.message);a=new shaka.util.FakeEvent("message",a);b.generated();b.dispatchEvent(a)}else shaka.log.error("Session not found",a.sessionId)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyAdded_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyAdded_",a);a=this.findSession_(a.sessionId);goog.asserts.assert(a,"unable to find session in onWebkitKeyAdded_");a&&a.ready()};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyError_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyError_",a);var b=this.findSession_(a.sessionId);goog.asserts.assert(b,"unable to find session in onWebkitKeyError_");b&&b.handleError(a)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.findSession_=function(a){var b=this.sessionMap_.get(a);return b?(shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.findSession_",b),b):(b=this.newSessions_.shift())?(b.sessionId=a,this.sessionMap_.set(a,b),shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.findSession_",b),b):null};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession=function(a,b,c){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession");shaka.util.FakeEventTarget.call(this);this.media_=a;this.initialized_=!1;this.updatePromise_=this.generatePromise_=null;this.keySystem_=b;this.type_=c;this.sessionId="";this.expiration=NaN;this.closed=new shaka.util.PublicPromise;this.keyStatuses=new shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap;this.onkeystatuseschange=null};
$jscomp.inherits(shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession,shaka.util.FakeEventTarget);shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generated=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.generated");this.generatePromise_&&(this.generatePromise_.resolve(),this.generatePromise_=null)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.ready=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.ready");this.updateKeyStatus_("usable");this.updatePromise_&&this.updatePromise_.resolve();this.updatePromise_=null};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.handleError=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.handleError",a);var b=Error("EME v0.1b key error"),c=a.errorCode;c.systemCode=a.systemCode;b.errorCode=c;!a.sessionId&&this.generatePromise_?(a.systemCode==45&&(b.message="Unsupported session type."),this.generatePromise_.reject(b),this.generatePromise_=null):a.sessionId&&this.updatePromise_?(this.updatePromise_.reject(b),this.updatePromise_=null):(b=a.systemCode,
a.errorCode.code==MediaKeyError.MEDIA_KEYERR_OUTPUT?this.updateKeyStatus_("output-restricted"):b==1?this.updateKeyStatus_("expired"):this.updateKeyStatus_("internal-error"))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generate_=function(a,b){var c=this,d=shaka.polyfill.PatchedMediaKeysWebkit;if(this.initialized_)return Promise.reject(Error("The session is already initialized."));this.initialized_=!0;try{if(this.type_=="persistent-license"){var e=shaka.util.StringUtils;if(b)var f=shaka.util.BufferUtils.toUint8(e.toUTF8("LOAD_SESSION|"+b));else{goog.asserts.assert(a,"expecting init data");var g=e.toUTF8("PERSISTENT|");f=shaka.util.Uint8ArrayUtils.concat(g,
a)}}else goog.asserts.assert(this.type_=="temporary","expected temporary session"),goog.asserts.assert(!b,"unexpected offline session ID"),goog.asserts.assert(a,"expecting init data"),f=shaka.util.BufferUtils.toUint8(a);goog.asserts.assert(f,"init data not set!")}catch(k){return Promise.reject(k)}goog.asserts.assert(this.generatePromise_==null,"generatePromise_ should be null");this.generatePromise_=new shaka.util.PublicPromise;var h=d.prefixApi_("generateKeyRequest");try{this.media_[h](this.keySystem_,
f)}catch(k){if(k.name!="InvalidStateError")return this.generatePromise_=null,Promise.reject(k);(new shaka.util.Timer(function(){try{c.media_[h](c.keySystem_,f)}catch(l){c.generatePromise_.reject(l),c.generatePromise_=null}})).tickAfter(.01)}return this.generatePromise_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.update_=function(a,b){var c=this,d=shaka.polyfill.PatchedMediaKeysWebkit;if(this.updatePromise_)this.updatePromise_.then(function(){return c.update_(a,b)}).catch(function(){return c.update_(a,b)});else{this.updatePromise_=a;if(this.keySystem_=="webkit-org.w3.clearkey"){var e=shaka.util.Uint8ArrayUtils;var f=shaka.util.StringUtils.fromUTF8(b);var g=JSON.parse(f);g.keys[0].kty!="oct"&&(this.updatePromise_.reject(Error("Response is not a valid JSON Web Key Set.")),
this.updatePromise_=null);f=e.fromBase64(g.keys[0].k);e=e.fromBase64(g.keys[0].kid)}else f=shaka.util.BufferUtils.toUint8(b),e=null;d=d.prefixApi_("addKey");try{this.media_[d](this.keySystem_,f,e,this.sessionId)}catch(h){this.updatePromise_.reject(h),this.updatePromise_=null}}};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.updateKeyStatus_=function(a){this.keyStatuses.setStatus(a);a=new shaka.util.FakeEvent("keystatuseschange");this.dispatchEvent(a);if(this.onkeystatuseschange)this.onkeystatuseschange(a)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generateRequest=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.generateRequest");return this.generate_(b,null)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.load=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.load");return this.type_=="persistent-license"?this.generate_(null,a):Promise.reject(Error("Not a persistent session."))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.update=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.update",a);goog.asserts.assert(this.sessionId,"update without session ID");var b=new shaka.util.PublicPromise;this.update_(b,a);return b};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.close=function(){var a=shaka.polyfill.PatchedMediaKeysWebkit;shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.close");if(this.type_!="persistent-license"){if(!this.sessionId)return this.closed.reject(Error("The session is not callable.")),this.closed;a=a.prefixApi_("cancelKeyRequest");try{this.media_[a](this.keySystem_,this.sessionId)}catch(b){shaka.log.debug(a+" exception",b)}}this.closed.resolve();return this.closed};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.remove=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.remove");return this.type_!="persistent-license"?Promise.reject(Error("Not a persistent session.")):this.close()};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap=function(){this.size=0;this.status_=void 0};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.setStatus=function(a){this.size=a==void 0?0:1;this.status_=a};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.getStatus=function(){return this.status_};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.forEach=function(a){this.status_&&a(this.status_,shaka.drm.DrmUtils.DUMMY_KEY_ID.value())};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.get=function(a){if(this.has(a))return this.status_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.has=function(a){var b=shaka.drm.DrmUtils.DUMMY_KEY_ID.value();return this.status_&&shaka.util.BufferUtils.equal(a,b)?!0:!1};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.entries=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.keys=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.values=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};shaka.polyfill.PatchedMediaKeysWebkit.prefix_="";shaka.polyfill.PatchedMediaKeysWebkit.apiName_="webkit";shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysWebkit.install);shaka.polyfill.RandomUUID=function(){};shaka.polyfill.RandomUUID.install=function(){shaka.log.debug("randomUUID.install");window.crypto?"randomUUID"in window.crypto?shaka.log.debug("RandomUUID: Native window.crypto.randomUUID() support found."):window.crypto.randomUUID=shaka.polyfill.RandomUUID.randomUUID_:shaka.log.debug("window.crypto must be available to install randomUUID polyfill.")};
shaka.polyfill.RandomUUID.randomUUID_=function(){var a=URL.createObjectURL(new Blob),b=a.toString();URL.revokeObjectURL(a);return b.substr(b.lastIndexOf("/")+1)};goog.exportProperty(shaka.polyfill,"RandomUUID",shaka.polyfill.RandomUUID);goog.exportProperty(shaka.polyfill.RandomUUID,"install",shaka.polyfill.RandomUUID.install);shaka.polyfill.register(shaka.polyfill.RandomUUID.install);shaka.polyfill.Symbol=function(){};shaka.polyfill.Symbol.install=function(){shaka.log.debug("Symbol.install");var a=Symbol.prototype;"description"in a||Object.defineProperty(a,"description",{get:shaka.polyfill.Symbol.getSymbolDescription_})};shaka.polyfill.Symbol.getSymbolDescription_=function(){var a=/\((.*)\)/.exec(this.toString());return a?a[1]:void 0};goog.exportProperty(shaka.polyfill,"Symbol",shaka.polyfill.Symbol);goog.exportProperty(shaka.polyfill.Symbol,"install",shaka.polyfill.Symbol.install);
shaka.polyfill.register(shaka.polyfill.Symbol.install);shaka.polyfill.TypedArray=function(){};shaka.polyfill.TypedArray.install=function(){for(var a=(0,$jscomp.makeIterator)([Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array]),b=a.next();!b.done;b=a.next())b=b.value,b.prototype.indexOf||(b.prototype.indexOf=shaka.polyfill.TypedArray.indexOf_),b.prototype.lastIndexOf||(b.prototype.lastIndexOf=shaka.polyfill.TypedArray.lastIndexOf_),b.prototype.includes||(b.prototype.includes=shaka.polyfill.TypedArray.includes_)};
shaka.polyfill.TypedArray.indexOf_=function(a,b){return Array.prototype.indexOf.call(this,a,b)};shaka.polyfill.TypedArray.lastIndexOf_=function(a,b){return Array.prototype.lastIndexOf.call(this,a,b)};shaka.polyfill.TypedArray.includes_=function(a,b){return this.indexOf(a,b)!==-1};goog.exportProperty(shaka.polyfill,"TypedArray",shaka.polyfill.TypedArray);goog.exportProperty(shaka.polyfill.TypedArray,"install",shaka.polyfill.TypedArray.install);shaka.polyfill.register(shaka.polyfill.TypedArray.install);shaka.polyfill.VideoPlayPromise=function(){};shaka.polyfill.VideoPlayPromise.install=function(){shaka.log.debug("VideoPlayPromise.install");if(window.HTMLMediaElement){var a=HTMLMediaElement.prototype.play;HTMLMediaElement.prototype.play=function(){var b=a.apply(this);b&&b.catch(function(){});return b}}};goog.exportProperty(shaka.polyfill,"VideoPlayPromise",shaka.polyfill.VideoPlayPromise);goog.exportProperty(shaka.polyfill.VideoPlayPromise,"install",shaka.polyfill.VideoPlayPromise.install);shaka.polyfill.register(shaka.polyfill.VideoPlayPromise.install);shaka.polyfill.VideoPlaybackQuality=function(){};shaka.polyfill.VideoPlaybackQuality.install=function(){if(window.HTMLVideoElement){var a=HTMLVideoElement.prototype;!a.getVideoPlaybackQuality&&("webkitDroppedFrameCount"in a||typeof shaka.util.Dom.anyMediaElement().webkitDroppedFrameCount==="number")&&(a.getVideoPlaybackQuality=shaka.polyfill.VideoPlaybackQuality.webkit_)}};
shaka.polyfill.VideoPlaybackQuality.webkit_=function(){return{droppedVideoFrames:this.webkitDroppedFrameCount,totalVideoFrames:this.webkitDecodedFrameCount,corruptedVideoFrames:0,creationTime:NaN,totalFrameDelay:0}};goog.exportProperty(shaka.polyfill,"VideoPlaybackQuality",shaka.polyfill.VideoPlaybackQuality);goog.exportProperty(shaka.polyfill.VideoPlaybackQuality,"install",shaka.polyfill.VideoPlaybackQuality.install);shaka.polyfill.register(shaka.polyfill.VideoPlaybackQuality.install);shaka.polyfill.VTTCue=function(){};
shaka.polyfill.VTTCue.install=function(){if(window.VTTCue)shaka.log.info("Using native VTTCue.");else if(window.TextTrackCue){var a=null,b=TextTrackCue.length;b==3?(shaka.log.info("Using VTTCue polyfill from 3 argument TextTrackCue."),a=shaka.polyfill.VTTCue.from3ArgsTextTrackCue_):b==6?(shaka.log.info("Using VTTCue polyfill from 6 argument TextTrackCue."),a=shaka.polyfill.VTTCue.from6ArgsTextTrackCue_):shaka.polyfill.VTTCue.canUse3ArgsTextTrackCue_()&&(shaka.log.info("Using VTTCue polyfill from 3 argument TextTrackCue."),a=
shaka.polyfill.VTTCue.from3ArgsTextTrackCue_);a?window.VTTCue=function(c,d,e){return a(c,d,e)}:shaka.log.error("No recognized signature for TextTrackCue found!")}else shaka.log.error("VTTCue not available.")};shaka.polyfill.VTTCue.from3ArgsTextTrackCue_=function(a,b,c){return new window.TextTrackCue(a,b,c)};shaka.polyfill.VTTCue.from6ArgsTextTrackCue_=function(a,b,c){return new window.TextTrackCue(a+"-"+b+"-"+c,a,b,c)};
shaka.polyfill.VTTCue.canUse3ArgsTextTrackCue_=function(){try{return!!shaka.polyfill.VTTCue.from3ArgsTextTrackCue_(1,2,"")}catch(a){return!1}};goog.exportProperty(shaka.polyfill,"VTTCue",shaka.polyfill.VTTCue);goog.exportProperty(shaka.polyfill.VTTCue,"install",shaka.polyfill.VTTCue.install);shaka.polyfill.register(shaka.polyfill.VTTCue.install);shaka.text.TtmlTextParser=function(){this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.text.TtmlTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"TTML does not have init segments")};shaka.text.TtmlTextParser.prototype.setSequenceMode=function(a){};shaka.text.TtmlTextParser.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.text.TtmlTextParser.prototype.parseMedia=function(a,b,c,d){var e=shaka.text.TtmlTextParser,f=shaka.util.TXml,g=e.parameterNs_,h=e.styleNs_,k=shaka.util.StringUtils.fromUTF8(a);a=[];if(k=="")return a;var l=f.parseXmlString(k,"tt",!0);if(!l)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_XML,"Failed to parse TTML.");k=f.getElementsByTagName(l,"body")[0];if(!k)return[];var m=f.getAttributeNSList(l,g,"frameRate"),n=f.getAttributeNSList(l,
g,"subFrameRate"),p=f.getAttributeNSList(l,g,"frameRateMultiplier"),q=f.getAttributeNSList(l,g,"tickRate"),r=f.getAttributeNSList(l,g,"cellResolution"),t=l.attributes["xml:space"]||"default";g=f.getAttributeNSList(l,h,"extent");if(t!="default"&&t!="preserve")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_XML,"Invalid xml:space value: "+t);h=t=="default";e=new e.RateInfo_(m,n,p,q);m=this.getCellResolution_(r);n=f.getElementsByTagName(l,
"metadata")[0];n=(n?n.children:[]).filter(function(w){return w!="\n"});p=f.getElementsByTagName(l,"style");l=f.getElementsByTagName(l,"region");q=[];r=(0,$jscomp.makeIterator)(l);for(t=r.next();!t.done;t=r.next())(t=this.parseCueRegion_(t.value,p,g))&&q.push(t);if(f.findChildren(k,"p").length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"<p> can only be inside <div> in TTML");g=(0,$jscomp.makeIterator)(f.findChildren(k,
"div"));for(r=g.next();!r.done;r=g.next())if(f.findChildren(r.value,"span").length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"<span> can only be inside <p> in TTML");if(b=this.parseCue_(k,b,e,n,p,l,q,h,m,null,!1,c,d))b.backgroundColor||(b.backgroundColor="transparent"),a.push(b);return a};
shaka.text.TtmlTextParser.prototype.parseCue_=function(a,b,c,d,e,f,g,h,k,l,m,n,p){var q=shaka.util.TXml,r=shaka.util.StringUtils,t=l;if(q.isText(a)){if(!m)return null;var w={tagName:"span",children:[q.getTextContents(a)],attributes:{},parent:null}}else w=a;goog.asserts.assert(w,"cueElement should be non-null!");for(var v=null,u=(0,$jscomp.makeIterator)(shaka.text.TtmlTextParser.smpteNsList_),x=u.next();!x.done&&!(v=this.getElementsFromCollection_(w,"backgroundImage",d,"#",x.value)[0]);x=u.next());
u=null;x=q.getAttributeNSList(w,shaka.text.TtmlTextParser.smpteNsList_,"backgroundImage");var z=/^(urn:)(mpeg:[a-z0-9][a-z0-9-]{0,31}:)(subs:)([0-9]+)$/;if(x&&z.test(x)){u=parseInt(x.split(":").pop(),10)-1;if(u>=p.length)return null;u=p[u]}else n&&x&&!x.startsWith("#")&&(z=new goog.Uri(n),x=new goog.Uri(x),(x=z.resolve(x).toString())&&(u=x));if(a.tagName=="p"||v||u)m=!0;a=m;x=(w.attributes["xml:space"]||(h?"default":"preserve"))=="default";z=w.children.every(q.isText);h=[];if(!z)for(var B=(0,$jscomp.makeIterator)(w.children),
C=B.next();!C.done;C=B.next())(C=this.parseCue_(C.value,b,c,d,e,f,g,x,k,w,m,n,p))&&h.push(C);d=l!=null;n=q.getTextContents(w);n=w.children.length&&n&&/\S/.test(n);B=w.attributes.begin||w.attributes.end||w.attributes.dur;if(!(B||n||w.tagName=="br"||h.length!=0||d&&!x))return null;p=this.parseTime_(w,c);n=p.start;for(p=p.end;t&&q.isNode(t)&&t.tagName!="tt";)p=this.resolveTime_(t,c,n,p),n=p.start,p=p.end,t=t.parent;n==null&&(n=0);n+=b.periodStart;p=p==null?Infinity:p+b.periodStart;this.manifestType_!==
shaka.media.ManifestParser.HLS&&(n=Math.max(n,b.segmentStart),p=Math.min(p,b.segmentEnd));if(!B&&h.length>0)for(n=Infinity,p=0,b=(0,$jscomp.makeIterator)(h),c=b.next();!c.done;c=b.next())c=c.value,n=Math.min(n,c.startTime),p=Math.max(p,c.endTime);if(w.tagName=="br")return e=new shaka.text.Cue(n,p,""),e.lineBreak=!0,e;b="";z&&(b=r.htmlUnescape(shaka.util.TXml.getTextContents(w)||""),x&&(b=b.replace(/\s+/g," ")));r=new shaka.text.Cue(n,p,b);r.nestedCues=h;m||(r.isContainer=!0);k&&(r.cellResolution=
k);k=this.getElementsFromCollection_(w,"region",f,"")[0];if(w.attributes.region&&k&&k.attributes["xml:id"]){var y=k.attributes["xml:id"];r.region=g.filter(function(A){return A.id==y})[0]}g=k;l&&d&&!w.attributes.region&&!w.attributes.style&&(g=this.getElementsFromCollection_(l,"region",f,"")[0]);this.addStyle_(r,w,g,v,u,e,a,h.length==0);return r};
shaka.text.TtmlTextParser.prototype.parseCueRegion_=function(a,b,c){var d=shaka.text.TtmlTextParser,e=new shaka.text.CueRegion,f=a.attributes["xml:id"];if(!f)return shaka.log.warning("TtmlTextParser parser encountered a region with no id. Region will be ignored."),null;e.id=f;f=null;c&&(f=d.percentValues_.exec(c)||d.pixelValues_.exec(c));c=f?Number(f[1]):null;f=f?Number(f[2]):null;var g,h=this.getStyleAttributeFromRegion_(a,b,"extent");if(h){var k=(g=d.percentValues_.exec(h))||d.pixelValues_.exec(h);
k!=null&&(e.width=Number(k[1]),e.height=Number(k[2]),g||(c!=null&&(e.width=e.width*100/c),f!=null&&(e.height=e.height*100/f)),e.widthUnits=g||c!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX,e.heightUnits=g||f!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX)}if(a=this.getStyleAttributeFromRegion_(a,b,"origin"))if(k=(g=d.percentValues_.exec(a))||d.pixelValues_.exec(a),k!=null)e.viewportAnchorX=Number(k[1]),e.viewportAnchorY=Number(k[2]),g?h||(e.width=
100-e.viewportAnchorX,e.widthUnits=shaka.text.CueRegion.units.PERCENTAGE,e.height=100-e.viewportAnchorY,e.heightUnits=shaka.text.CueRegion.units.PERCENTAGE):(f!=null&&(e.viewportAnchorY=e.viewportAnchorY*100/f),c!=null&&(e.viewportAnchorX=e.viewportAnchorX*100/c)),e.viewportAnchorUnits=g||c!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX;return e};
shaka.text.TtmlTextParser.prototype.convertTTMLrgbaToHTMLrgba_=function(a){var b=a.match(/rgba\(([^)]+)\)/);return b&&(b=b[1].split(","),b.length==4)?(b[3]=String(Number(b[3])/255),"rgba("+b.join(",")+")"):a};
shaka.text.TtmlTextParser.prototype.addStyle_=function(a,b,c,d,e,f,g,h){var k=shaka.text.TtmlTextParser,l=shaka.util.TXml,m=shaka.text.Cue;g=g||h;this.getStyleAttribute_(b,c,f,"direction",g)=="rtl"&&(a.direction=m.direction.HORIZONTAL_RIGHT_TO_LEFT);h=this.getStyleAttribute_(b,c,f,"writingMode",g);h=="tb"||h=="tblr"?a.writingMode=m.writingMode.VERTICAL_LEFT_TO_RIGHT:h=="tbrl"?a.writingMode=m.writingMode.VERTICAL_RIGHT_TO_LEFT:h=="rltb"||h=="rl"?a.direction=m.direction.HORIZONTAL_RIGHT_TO_LEFT:h&&
(a.direction=m.direction.HORIZONTAL_LEFT_TO_RIGHT);(h=this.getStyleAttribute_(b,c,f,"textAlign",!0))?(a.positionAlign=k.textAlignToPositionAlign_.get(h),a.lineAlign=k.textAlignToLineAlign_.get(h),goog.asserts.assert(h.toUpperCase()in m.textAlign,h.toUpperCase()+" Should be in Cue.textAlign values!"),a.textAlign=m.textAlign[h.toUpperCase()]):a.textAlign=m.textAlign.CENTER;if(h=this.getStyleAttribute_(b,c,f,"displayAlign",!0))goog.asserts.assert(h.toUpperCase()in m.displayAlign,h.toUpperCase()+" Should be in Cue.displayAlign values!"),
a.displayAlign=m.displayAlign[h.toUpperCase()];if(h=this.getStyleAttribute_(b,c,f,"color",g))a.color=this.convertTTMLrgbaToHTMLrgba_(h);if(h=this.getStyleAttribute_(b,c,f,"backgroundColor",g))a.backgroundColor=this.convertTTMLrgbaToHTMLrgba_(h);if(h=this.getStyleAttribute_(b,c,f,"border",g))a.border=h;if(h=this.getStyleAttribute_(b,c,f,"fontFamily",g))switch(h){case "monospaceSerif":a.fontFamily="Courier New,Liberation Mono,Courier,monospace";break;case "proportionalSansSerif":a.fontFamily="Arial,Helvetica,Liberation Sans,sans-serif";
break;case "sansSerif":a.fontFamily="sans-serif";break;case "monospaceSansSerif":a.fontFamily="Consolas,monospace";break;case "proportionalSerif":a.fontFamily="serif";break;default:a.fontFamily=h.split(",").filter(function(n){return n!="default"}).join(",")}(h=this.getStyleAttribute_(b,c,f,"fontWeight",g))&&h=="bold"&&(a.fontWeight=m.fontWeight.BOLD);h=this.getStyleAttribute_(b,c,f,"wrapOption",g);a.wrapLine=h&&h=="noWrap"?!1:!0;(h=this.getStyleAttribute_(b,c,f,"lineHeight",g))&&h.match(k.unitValues_)&&
(a.lineHeight=h);(h=this.getStyleAttribute_(b,c,f,"fontSize",g))&&(h.match(k.unitValues_)||h.match(k.percentValue_))&&(a.fontSize=h);if(h=this.getStyleAttribute_(b,c,f,"fontStyle",g))goog.asserts.assert(h.toUpperCase()in m.fontStyle,h.toUpperCase()+" Should be in Cue.fontStyle values!"),a.fontStyle=m.fontStyle[h.toUpperCase()];d?(e=d.attributes.imageType||d.attributes.imagetype,m=d.attributes.encoding,d=l.getTextContents(d).trim(),e=="PNG"&&m=="Base64"&&d&&(a.backgroundImage="data:image/png;base64,"+
d)):e&&(a.backgroundImage=e);if(d=this.getStyleAttribute_(b,c,f,"textOutline",g))d=d.split(" "),d[0].match(k.unitValues_)?a.textStrokeColor=a.color:(a.textStrokeColor=this.convertTTMLrgbaToHTMLrgba_(d[0]),d.shift()),d[0]&&d[0].match(k.unitValues_)?a.textStrokeWidth=d[0]:a.textStrokeColor="";(d=this.getStyleAttribute_(b,c,f,"letterSpacing",g))&&d.match(k.unitValues_)&&(a.letterSpacing=d);(d=this.getStyleAttribute_(b,c,f,"linePadding",g))&&d.match(k.unitValues_)&&(a.linePadding=d);if(k=this.getStyleAttribute_(b,
c,f,"opacity",g))a.opacity=parseFloat(k);(k=this.getStyleAttributeFromRegion_(c,f,"textDecoration"))&&this.addTextDecoration_(a,k);(k=this.getStyleAttributeFromElement_(b,f,"textDecoration"))&&this.addTextDecoration_(a,k);if(k=this.getStyleAttribute_(b,c,f,"textCombine",g))a.textCombineUpright=k;switch(this.getStyleAttribute_(b,c,f,"ruby",g)){case "container":a.rubyTag="ruby";break;case "text":a.rubyTag="rt"}};
shaka.text.TtmlTextParser.prototype.addTextDecoration_=function(a,b){var c=shaka.text.Cue;b=(0,$jscomp.makeIterator)(b.split(" "));for(var d=b.next();!d.done;d=b.next())switch(d.value){case "underline":a.textDecoration.includes(c.textDecoration.UNDERLINE)||a.textDecoration.push(c.textDecoration.UNDERLINE);break;case "noUnderline":a.textDecoration.includes(c.textDecoration.UNDERLINE)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.UNDERLINE);break;case "lineThrough":a.textDecoration.includes(c.textDecoration.LINE_THROUGH)||
a.textDecoration.push(c.textDecoration.LINE_THROUGH);break;case "noLineThrough":a.textDecoration.includes(c.textDecoration.LINE_THROUGH)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.LINE_THROUGH);break;case "overline":a.textDecoration.includes(c.textDecoration.OVERLINE)||a.textDecoration.push(c.textDecoration.OVERLINE);break;case "noOverline":a.textDecoration.includes(c.textDecoration.OVERLINE)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.OVERLINE)}};
shaka.text.TtmlTextParser.prototype.getStyleAttribute_=function(a,b,c,d,e){e=e===void 0?!0:e;return(a=this.getStyleAttributeFromElement_(a,c,d))?a:e?this.getStyleAttributeFromRegion_(b,c,d):null};shaka.text.TtmlTextParser.prototype.getStyleAttributeFromRegion_=function(a,b,c){if(!a)return null;var d=shaka.util.TXml.getAttributeNSList(a,shaka.text.TtmlTextParser.styleNs_,c);return d?d:this.getInheritedStyleAttribute_(a,b,c)};
shaka.text.TtmlTextParser.prototype.getStyleAttributeFromElement_=function(a,b,c){var d=shaka.util.TXml.getAttributeNSList(a,shaka.text.TtmlTextParser.styleNs_,c);return d?d:this.getInheritedStyleAttribute_(a,b,c)};
shaka.text.TtmlTextParser.prototype.getInheritedStyleAttribute_=function(a,b,c){var d=shaka.util.TXml,e=shaka.text.TtmlTextParser.styleNs_,f=shaka.text.TtmlTextParser.styleEbuttsNs_;a=this.getElementsFromCollection_(a,"style",b,"");for(var g=null,h=0;h<a.length;h++){var k=d.getAttributeNS(a[h],f,c);k||(k=d.getAttributeNSList(a[h],e,c));k||(k=this.getStyleAttributeFromElement_(a[h],b,c));k&&(g=k)}return g};
shaka.text.TtmlTextParser.prototype.getElementsFromCollection_=function(a,b,c,d,e){var f=[];if(!a||c.length<1)return f;if(a=this.getInheritedAttribute_(a,b,e))for(a=a.split(" "),a=(0,$jscomp.makeIterator)(a),b=a.next();!b.done;b=a.next()){b=b.value;e=(0,$jscomp.makeIterator)(c);for(var g=e.next();!g.done;g=e.next())if(g=g.value,d+g.attributes["xml:id"]==b){f.push(g);break}}return f};
shaka.text.TtmlTextParser.prototype.getInheritedAttribute_=function(a,b,c){for(var d=null,e=shaka.util.TXml;!d&&!(d=c?e.getAttributeNS(a,c,b):a.attributes[b])&&(a=a.parent,a););return d};shaka.text.TtmlTextParser.prototype.resolveTime_=function(a,b,c,d){a=this.parseTime_(a,b);c==null?c=a.start:a.start!=null&&(c+=a.start);d==null?d=a.end:a.start!=null&&(d+=a.start);return{start:c,end:d}};
shaka.text.TtmlTextParser.prototype.parseTime_=function(a,b){var c=this.parseTimeAttribute_(a.attributes.begin,b),d=this.parseTimeAttribute_(a.attributes.end,b);a=this.parseTimeAttribute_(a.attributes.dur,b);d==null&&a!=null&&(d=c+a);return{start:c,end:d}};
shaka.text.TtmlTextParser.prototype.parseTimeAttribute_=function(a,b){var c=null,d=shaka.text.TtmlTextParser;if(d.timeColonFormatFrames_.test(a))c=this.parseColonTimeWithFrames_(b,a);else if(d.timeColonFormat_.test(a))c=this.parseTimeFromRegex_(d.timeColonFormat_,a);else if(d.timeColonFormatMilliseconds_.test(a))c=this.parseTimeFromRegex_(d.timeColonFormatMilliseconds_,a);else if(d.timeFramesFormat_.test(a))c=this.parseFramesTime_(b,a);else if(d.timeTickFormat_.test(a))c=this.parseTickTime_(b,a);
else if(d.timeHMSFormat_.test(a))c=this.parseTimeFromRegex_(d.timeHMSFormat_,a);else if(a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"Could not parse cue time range in TTML");return c};shaka.text.TtmlTextParser.prototype.parseFramesTime_=function(a,b){b=shaka.text.TtmlTextParser.timeFramesFormat_.exec(b);return Number(b[1])/a.frameRate};
shaka.text.TtmlTextParser.prototype.parseTickTime_=function(a,b){b=shaka.text.TtmlTextParser.timeTickFormat_.exec(b);return Number(b[1])/a.tickRate};shaka.text.TtmlTextParser.prototype.parseColonTimeWithFrames_=function(a,b){b=shaka.text.TtmlTextParser.timeColonFormatFrames_.exec(b);var c=Number(b[1]),d=Number(b[2]),e=Number(b[3]),f=Number(b[4]);f+=(Number(b[5])||0)/a.subFrameRate;e+=f/a.frameRate;return e+d*60+c*3600};
shaka.text.TtmlTextParser.prototype.parseTimeFromRegex_=function(a,b){a=a.exec(b);return a==null||a[0]==""?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+(Number(a[2])||0)*60+(Number(a[1])||0)*3600};shaka.text.TtmlTextParser.prototype.getCellResolution_=function(a){if(!a)return null;var b=/^(\d+) (\d+)$/.exec(a);if(!b)return null;a=parseInt(b[1],10);b=parseInt(b[2],10);return{columns:a,rows:b}};goog.exportSymbol("shaka.text.TtmlTextParser",shaka.text.TtmlTextParser);
goog.exportProperty(shaka.text.TtmlTextParser.prototype,"parseMedia",shaka.text.TtmlTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"setManifestType",shaka.text.TtmlTextParser.prototype.setManifestType);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"setSequenceMode",shaka.text.TtmlTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"parseInit",shaka.text.TtmlTextParser.prototype.parseInit);
shaka.text.TtmlTextParser.RateInfo_=function(a,b,c,d){this.frameRate=Number(a)||30;this.subFrameRate=Number(b)||1;this.tickRate=Number(d);this.tickRate==0&&(this.tickRate=a?this.frameRate*this.subFrameRate:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=Number(a[1])/Number(a[2]))};shaka.text.TtmlTextParser.percentValues_=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/;shaka.text.TtmlTextParser.percentValue_=/^(\d{1,4}(?:\.\d+)?|100)%$/;
shaka.text.TtmlTextParser.unitValues_=/^(\d+px|\d+em|\d*\.?\d+c)$/;shaka.text.TtmlTextParser.pixelValues_=/^(\d+)px (\d+)px$/;shaka.text.TtmlTextParser.timeColonFormatFrames_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/;shaka.text.TtmlTextParser.timeColonFormat_=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/;shaka.text.TtmlTextParser.timeColonFormatMilliseconds_=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/;shaka.text.TtmlTextParser.timeFramesFormat_=/^(\d*(?:\.\d*)?)f$/;shaka.text.TtmlTextParser.timeTickFormat_=/^(\d*(?:\.\d*)?)t$/;
shaka.text.TtmlTextParser.timeHMSFormat_=RegExp("^(?:(\\d*(?:\\.\\d*)?)h)?(?:(\\d*(?:\\.\\d*)?)m)?(?:(\\d*(?:\\.\\d*)?)s)?(?:(\\d*(?:\\.\\d*)?)ms)?$");shaka.text.TtmlTextParser.textAlignToLineAlign_=(new Map).set("left",shaka.text.Cue.lineAlign.START).set("center",shaka.text.Cue.lineAlign.CENTER).set("right",shaka.text.Cue.lineAlign.END).set("start",shaka.text.Cue.lineAlign.START).set("end",shaka.text.Cue.lineAlign.END);
shaka.text.TtmlTextParser.textAlignToPositionAlign_=(new Map).set("left",shaka.text.Cue.positionAlign.LEFT).set("center",shaka.text.Cue.positionAlign.CENTER).set("right",shaka.text.Cue.positionAlign.RIGHT);shaka.text.TtmlTextParser.parameterNs_=["http://www.w3.org/ns/ttml#parameter","http://www.w3.org/2006/10/ttaf1#parameter"];shaka.text.TtmlTextParser.styleNs_=["http://www.w3.org/ns/ttml#styling","http://www.w3.org/2006/10/ttaf1#styling"];shaka.text.TtmlTextParser.styleEbuttsNs_="urn:ebu:tt:style";
shaka.text.TtmlTextParser.smpteNsList_=["http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt","http://www.smpte-ra.org/schemas/2052-1/2013/smpte-tt"];shaka.text.TextEngine.registerParser("application/ttml+xml",function(){return new shaka.text.TtmlTextParser});shaka.text.Mp4TtmlParser=function(){this.parser_=new shaka.text.TtmlTextParser};
shaka.text.Mp4TtmlParser.prototype.parseInit=function(a){var b=shaka.util.Mp4Parser,c=!1;(new b).box("moov",b.children).box("trak",b.children).box("mdia",b.children).box("minf",b.children).box("stbl",b.children).fullBox("stsd",b.sampleDescription).box("stpp",function(d){c=!0;d.parser.stop()}).parse(a);if(!c)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_TTML);};shaka.text.Mp4TtmlParser.prototype.setSequenceMode=function(a){this.parser_.setSequenceMode(a)};
shaka.text.Mp4TtmlParser.prototype.setManifestType=function(a){this.parser_.setManifestType(a)};
shaka.text.Mp4TtmlParser.prototype.parseMedia=function(a,b,c){var d=shaka.util.Mp4Parser,e=[],f=null,g=[],h=new Map,k=[];(new d).box("moof",d.children).box("traf",d.children).fullBox("tfhd",function(v){goog.asserts.assert(v.flags!=null,"A TFHD box should have a valid flags value");f=shaka.util.Mp4BoxParsers.parseTFHD(v.reader,v.flags).defaultSampleSize}).fullBox("trun",function(v){goog.asserts.assert(v.version!=null,"A TRUN box should have a valid version value");goog.asserts.assert(v.flags!=null,
"A TRUN box should have a valid flags value");v=shaka.util.Mp4BoxParsers.parseTRUN(v.reader,v.version,v.flags);v=(0,$jscomp.makeIterator)(v.sampleData);for(var u=v.next();!u.done;u=v.next())k.push(u.value.sampleSize||f||0)}).fullBox("subs",function(v){for(var u=v.reader,x=u.readUint32(),z=-1,B=0;B<x;B++){var C=u.readUint32();z+=C;C=u.readUint16();for(var y=[],A=0;A<C;A++)v.version==1?y.push(u.readUint32()):y.push(u.readUint16()),u.readUint8(),u.readUint8(),u.readUint32();h.set(z,y)}}).box("mdat",
d.allData(function(v){g.push(v)},!1)).parse(a,!1);if(g.length==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_TTML);d=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(g));for(var l=0,m=0;m<k.length;m++){var n=shaka.util.BufferUtils.toUint8(d,l,k[m]);l+=k[m];var p=h.get(m);if(p&&p.length){n=shaka.util.BufferUtils.toUint8(n,0,p[0]);for(var q=[],r=p[0],t=1;t<p.length;t++){var w=
shaka.util.BufferUtils.toUint8(a,r,p[t]);w=shaka.util.Uint8ArrayUtils.toStandardBase64(w);q.push("data:image/png;base64,"+w);r+=p[t]}e=e.concat(this.parser_.parseMedia(n,b,c,q))}else e=e.concat(this.parser_.parseMedia(n,b,c,[]))}return e};goog.exportSymbol("shaka.text.Mp4TtmlParser",shaka.text.Mp4TtmlParser);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"parseMedia",shaka.text.Mp4TtmlParser.prototype.parseMedia);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"setManifestType",shaka.text.Mp4TtmlParser.prototype.setManifestType);
goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"setSequenceMode",shaka.text.Mp4TtmlParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"parseInit",shaka.text.Mp4TtmlParser.prototype.parseInit);shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml"',function(){return new shaka.text.Mp4TtmlParser});
shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1i"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im2i"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im2t"',function(){return new shaka.text.Mp4TtmlParser});
shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.etd1"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.etd1|im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1t|etd1"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.TTML.im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.VttTextParser=function(){this.sequenceMode_=!1;this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.text.VttTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"VTT does not have init segments")};shaka.text.VttTextParser.prototype.setSequenceMode=function(a){this.sequenceMode_=a};shaka.text.VttTextParser.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.text.VttTextParser.prototype.parseMedia=function(a,b){var c=shaka.text.VttTextParser;a=shaka.util.StringUtils.fromUTF8(a);a=a.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");var d=a.split(/\n{2,}/m);if(!/^WEBVTT($|[ \t\n])/m.test(d[0]))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);a=b.vttOffset;this.manifestType_==shaka.media.ManifestParser.HLS&&(d[0].includes("X-TIMESTAMP-MAP")?a=this.computeHlsOffset_(d[0],b):b.periodStart&&
b.vttOffset==b.periodStart&&(a=0));b=[];for(var e=(0,$jscomp.makeIterator)(d[0].split("\n")),f=e.next();!f.done;f=e.next())f=f.value,/^Region:/.test(f)&&(f=c.parseRegion_(f),b.push(f));e=new Map;shaka.text.Cue.addDefaultTextColor(e);f=[];d=(0,$jscomp.makeIterator)(d.slice(1));for(var g=d.next();!g.done;g=d.next())g=g.value.split("\n"),c.parseStyle_(g,e),(g=c.parseCue_(g,a,b,e))&&f.push(g);return f};
shaka.text.VttTextParser.prototype.computeHlsOffset_=function(a,b){var c=a.match(/LOCAL:((?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3}))/m);a=a.match(/MPEGTS:(\d+)/m);if(!c||!a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);c=shaka.util.TextParser.parseTime(c[1]);if(c==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);a=Number(a[1]);
for(var d=shaka.text.VttTextParser.MPEG_TIMESCALE_,e=shaka.text.VttTextParser.TS_ROLLOVER_/d,f=b.segmentStart-b.periodStart;f>=e;)f-=e,a+=shaka.text.VttTextParser.TS_ROLLOVER_;return b.periodStart+a/d-c};
shaka.text.VttTextParser.parseRegion_=function(a){var b=shaka.text.VttTextParser;a=new shaka.util.TextParser(a);var c=new shaka.text.CueRegion;a.readWord();a.skipWhitespace();for(var d=a.readWord();d;)b.parseRegionSetting_(c,d)||shaka.log.warning("VTT parser encountered an invalid VTTRegion setting: ",d," The setting will be ignored."),a.skipWhitespace(),d=a.readWord();return c};
shaka.text.VttTextParser.parseStyle_=function(a,b){if((a.length!=1||a[0])&&!/^NOTE($|[ \t])/.test(a[0])&&a[0]=="STYLE"){for(var c=[],d=-1,e=1;e<a.length;e++)a[e].includes("::cue")&&(c.push([]),d=c.length-1),d!=-1&&(c[d].push(a[e]),a[e].includes("}")&&(d=-1));a=(0,$jscomp.makeIterator)(c);for(c=a.next();!c.done;c=a.next()){e=c.value;c="global";(d=e[0].match(/\((.*)\)/))&&(c=d.pop());d=e.slice(1,-1);e[0].includes("}")&&(e=/\{(.*?)\}/.exec(e[0]))&&(d=e[1].split(";"));(e=b.get(c))||(e=new shaka.text.Cue(0,
0,""));for(var f=!1,g=0;g<d.length;g++){var h=/^\s*([^:]+):\s*(.*)/.exec(d[g]);if(h){var k=h[1].trim(),l=h[2].trim().replace(";","");switch(k){case "background-color":case "background":f=!0;e.backgroundColor=l;break;case "color":f=!0;e.color=l;break;case "font-family":f=!0;e.fontFamily=l;break;case "font-size":f=!0;e.fontSize=l;break;case "font-weight":if(parseInt(l,10)>=700||l=="bold")f=!0,e.fontWeight=shaka.text.Cue.fontWeight.BOLD;break;case "font-style":switch(l){case "normal":f=!0;e.fontStyle=
shaka.text.Cue.fontStyle.NORMAL;break;case "italic":f=!0;e.fontStyle=shaka.text.Cue.fontStyle.ITALIC;break;case "oblique":f=!0,e.fontStyle=shaka.text.Cue.fontStyle.OBLIQUE}break;case "opacity":f=!0;e.opacity=parseFloat(l);break;case "text-combine-upright":f=!0;e.textCombineUpright=l;break;case "text-shadow":f=!0;e.textShadow=l;break;case "white-space":f=!0;e.wrapLine=l!="noWrap";break;default:shaka.log.warning("VTT parser encountered an unsupported style: ",h)}}}f&&b.set(c,e)}}};
shaka.text.VttTextParser.parseCue_=function(a,b,c,d){var e=shaka.text.VttTextParser;if(a.length==1&&!a[0]||/^NOTE($|[ \t])/.test(a[0])||a[0]=="STYLE"||a[0]=="REGION")return null;var f=null;a[0].includes("--\x3e")||(f=a[0],a.splice(0,1));var g=new shaka.util.TextParser(a[0]),h=g.parseTime(),k=g.readRegex(/[ \t]+--\x3e[ \t]+/g),l=g.parseTime();if(h==null||k==null||l==null)return shaka.log.alwaysWarn("Failed to parse VTT time code. Cue skipped:",f,a),null;h+=b;l+=b;b=a.slice(1).join("\n").trim();d.has("global")?
(a=d.get("global").clone(),a.startTime=h,a.endTime=l,a.payload=b):a=new shaka.text.Cue(h,l,b);g.skipWhitespace();for(h=g.readWord();h;)e.parseCueSetting(a,h,c)||shaka.log.warning("VTT parser encountered an invalid VTT setting: ",h," The setting will be ignored."),g.skipWhitespace(),h=g.readWord();shaka.text.Cue.parseCuePayload(a,d);f!=null&&(a.id=f);return a};
shaka.text.VttTextParser.parseCueSetting=function(a,b,c){var d=shaka.text.VttTextParser,e;if(e=/^align:(start|middle|center|end|left|right)$/.exec(b))d.setTextAlign_(a,e[1]);else if(e=/^vertical:(lr|rl)$/.exec(b))d.setVerticalWritingMode_(a,e[1]);else if(e=/^size:([\d.]+)%$/.exec(b))a.size=Number(e[1]);else if(e=/^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/.exec(b))a.position=Number(e[1]),e[2]&&d.setPositionAlign_(a,e[2]);else if(e=/^region:(.*)$/.exec(b)){if(b=d.getRegionById_(c,
e[1]))a.region=b}else return d.parsedLineValueAndInterpretation_(a,b);return!0};shaka.text.VttTextParser.getRegionById_=function(a,b){a=a.filter(function(c){return c.id==b});if(!a.length)return shaka.log.warning("VTT parser could not find a region with id: ",b," The region will be ignored."),null;goog.asserts.assert(a.length==1,"VTTRegion ids should be unique!");return a[0]};
shaka.text.VttTextParser.parseRegionSetting_=function(a,b){var c;if(c=/^id=(.*)$/.exec(b))a.id=c[1];else if(c=/^width=(\d{1,2}|100)%$/.exec(b))a.width=Number(c[1]);else if(c=/^lines=(\d+)$/.exec(b))a.height=Number(c[1]),a.heightUnits=shaka.text.CueRegion.units.LINES;else if(c=/^regionanchor=(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(b))a.regionAnchorX=Number(c[1]),a.regionAnchorY=Number(c[2]);else if(c=/^viewportanchor=(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(b))a.viewportAnchorX=Number(c[1]),a.viewportAnchorY=
Number(c[2]);else if(/^scroll=up$/.exec(b))a.scroll=shaka.text.CueRegion.scrollMode.UP;else return!1;return!0};shaka.text.VttTextParser.setTextAlign_=function(a,b){var c=shaka.text.Cue;b=="middle"?a.textAlign=c.textAlign.CENTER:(goog.asserts.assert(b.toUpperCase()in c.textAlign,b.toUpperCase()+" Should be in Cue.textAlign values!"),a.textAlign=c.textAlign[b.toUpperCase()])};
shaka.text.VttTextParser.setPositionAlign_=function(a,b){var c=shaka.text.Cue;a.positionAlign=b=="line-left"||b=="start"?c.positionAlign.LEFT:b=="line-right"||b=="end"?c.positionAlign.RIGHT:b=="center"||b=="middle"?c.positionAlign.CENTER:c.positionAlign.AUTO};shaka.text.VttTextParser.setVerticalWritingMode_=function(a,b){var c=shaka.text.Cue;a.writingMode=b=="lr"?c.writingMode.VERTICAL_LEFT_TO_RIGHT:c.writingMode.VERTICAL_RIGHT_TO_LEFT};
shaka.text.VttTextParser.parsedLineValueAndInterpretation_=function(a,b){var c=shaka.text.Cue,d;if(d=/^line:([\d.]+)%(?:,(start|end|center))?$/.exec(b))a.lineInterpretation=c.lineInterpretation.PERCENTAGE,a.line=Number(d[1]),d[2]&&(goog.asserts.assert(d[2].toUpperCase()in c.lineAlign,d[2].toUpperCase()+" Should be in Cue.lineAlign values!"),a.lineAlign=c.lineAlign[d[2].toUpperCase()]);else if(d=/^line:(-?\d+)(?:,(start|end|center))?$/.exec(b))a.lineInterpretation=c.lineInterpretation.LINE_NUMBER,
a.line=Number(d[1]),d[2]&&(goog.asserts.assert(d[2].toUpperCase()in c.lineAlign,d[2].toUpperCase()+" Should be in Cue.lineAlign values!"),a.lineAlign=c.lineAlign[d[2].toUpperCase()]);else return!1;return!0};goog.exportSymbol("shaka.text.VttTextParser",shaka.text.VttTextParser);goog.exportProperty(shaka.text.VttTextParser.prototype,"parseMedia",shaka.text.VttTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.VttTextParser.prototype,"setManifestType",shaka.text.VttTextParser.prototype.setManifestType);
goog.exportProperty(shaka.text.VttTextParser.prototype,"setSequenceMode",shaka.text.VttTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.VttTextParser.prototype,"parseInit",shaka.text.VttTextParser.prototype.parseInit);shaka.text.VttTextParser.MPEG_TIMESCALE_=9E4;shaka.text.VttTextParser.TS_ROLLOVER_=8589934592;shaka.text.TextEngine.registerParser("text/vtt",function(){return new shaka.text.VttTextParser});shaka.text.TextEngine.registerParser('text/vtt; codecs="vtt"',function(){return new shaka.text.VttTextParser});
shaka.text.TextEngine.registerParser('text/vtt; codecs="wvtt"',function(){return new shaka.text.VttTextParser});shaka.text.Mp4VttParser=function(){this.timescale_=null};
shaka.text.Mp4VttParser.prototype.parseInit=function(a){var b=this,c=shaka.util.Mp4Parser,d=!1;(new c).box("moov",c.children).box("trak",c.children).box("mdia",c.children).fullBox("mdhd",function(e){goog.asserts.assert(e.version==0||e.version==1,"MDHD version can only be 0 or 1");e=shaka.util.Mp4BoxParsers.parseMDHD(e.reader,e.version);b.timescale_=e.timescale}).box("minf",c.children).box("stbl",c.children).fullBox("stsd",c.sampleDescription).box("wvtt",function(e){d=!0}).parse(a);if(!this.timescale_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);if(!d)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);};shaka.text.Mp4VttParser.prototype.setSequenceMode=function(a){};shaka.text.Mp4VttParser.prototype.setManifestType=function(a){};
shaka.text.Mp4VttParser.prototype.parseMedia=function(a,b){if(!a.length)return[];if(!this.timescale_)throw shaka.log.error("No init segment for MP4+VTT!"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);var c=shaka.util.Mp4Parser,d=0,e=[],f,g=[],h=!1,k=!1,l=!1,m=null;(new c).box("moof",c.children).box("traf",c.children).fullBox("tfdt",function(x){h=!0;goog.asserts.assert(x.version==0||x.version==1,"TFDT version can only be 0 or 1");
d=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(x.reader,x.version).baseMediaDecodeTime}).fullBox("tfhd",function(x){goog.asserts.assert(x.flags!=null,"A TFHD box should have a valid flags value");m=shaka.util.Mp4BoxParsers.parseTFHD(x.reader,x.flags).defaultSampleDuration}).fullBox("trun",function(x){k=!0;goog.asserts.assert(x.version!=null,"A TRUN box should have a valid version value");goog.asserts.assert(x.flags!=null,"A TRUN box should have a valid flags value");e=shaka.util.Mp4BoxParsers.parseTRUN(x.reader,
x.version,x.flags).sampleData}).box("mdat",c.allData(function(x){goog.asserts.assert(!l,"VTT cues in mp4 with multiple MDAT are not currently supported");l=!0;f=x},!1)).parse(a,!1);if(!l&&!h&&!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);a=d;c=new shaka.util.DataViewReader(f,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);for(var n=(0,$jscomp.makeIterator)(e),p=n.next();!p.done;p=n.next()){p=p.value;var q=p.sampleDuration||
m,r=p.sampleCompositionTimeOffset?d+p.sampleCompositionTimeOffset:a;a=r+(q||0);var t=0;do{var w=c.readUint32();t+=w;var v=c.readUint32();v=shaka.util.Mp4Parser.typeToString(v);var u=null;v=="vttc"?w>8&&(u=c.readBytes(w-8,!1)):(v!="vtte"&&shaka.log.error("Unknown box "+v+"! Skipping!"),c.skip(w-8));q?u&&(goog.asserts.assert(this.timescale_!=null,"Timescale should not be null!"),w=shaka.text.Mp4VttParser.parseVTTC_(u,b.periodStart+r/this.timescale_,b.periodStart+a/this.timescale_),g.push(w)):shaka.log.error("WVTT sample duration unknown, and no default found!");
goog.asserts.assert(!p.sampleSize||t<=p.sampleSize,"The samples do not fit evenly into the sample sizes given in the TRUN box!")}while(p.sampleSize&&t<p.sampleSize)}goog.asserts.assert(!c.hasMoreData(),"MDAT which contain VTT cues and non-VTT data are not currently supported!");return g.filter(shaka.util.Functional.isNotNull)};
shaka.text.Mp4VttParser.parseVTTC_=function(a,b,c){var d,e,f;(new shaka.util.Mp4Parser).box("payl",shaka.util.Mp4Parser.allData(function(g){d=shaka.util.StringUtils.fromUTF8(g)},!1)).box("iden",shaka.util.Mp4Parser.allData(function(g){e=shaka.util.StringUtils.fromUTF8(g)},!1)).box("sttg",shaka.util.Mp4Parser.allData(function(g){f=shaka.util.StringUtils.fromUTF8(g)},!1)).parse(a);return d?shaka.text.Mp4VttParser.assembleCue_(d,e,f,b,c):null};
shaka.text.Mp4VttParser.assembleCue_=function(a,b,c,d,e){a=new shaka.text.Cue(d,e,a);shaka.text.Cue.parseCuePayload(a);b&&(a.id=b);if(c)for(b=new shaka.util.TextParser(c),c=b.readWord();c;)shaka.text.VttTextParser.parseCueSetting(a,c,[])||shaka.log.warning("VTT parser encountered an invalid VTT setting: ",c," The setting will be ignored."),b.skipWhitespace(),c=b.readWord();return a};goog.exportSymbol("shaka.text.Mp4VttParser",shaka.text.Mp4VttParser);
goog.exportProperty(shaka.text.Mp4VttParser.prototype,"parseMedia",shaka.text.Mp4VttParser.prototype.parseMedia);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"setManifestType",shaka.text.Mp4VttParser.prototype.setManifestType);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"setSequenceMode",shaka.text.Mp4VttParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"parseInit",shaka.text.Mp4VttParser.prototype.parseInit);
shaka.text.TextEngine.registerParser('application/mp4; codecs="wvtt"',function(){return new shaka.text.Mp4VttParser});shaka.transmuxer.ADTS=function(){};shaka.transmuxer.ADTS.parseHeader=function(a,b){var c=shaka.transmuxer.ADTS,d=c.getHeaderLength(a,b);return b+d<=a.length&&(a=c.getFullFrameLength(a,b)-d,a>0)?{headerLength:d,frameLength:a}:null};
shaka.transmuxer.ADTS.parseInfo=function(a,b){var c=[96E3,88200,64E3,48E3,44100,32E3,24E3,22050,16E3,12E3,11025,8E3,7350],d=(a[b+2]&60)>>>2;if(d>c.length-1)return null;var e=((a[b+2]&192)>>>6)+1,f=(a[b+2]&1)<<2;f|=(a[b+3]&192)>>>6;return{sampleRate:c[d],channelCount:f,codec:"mp4a.40."+e}};shaka.transmuxer.ADTS.isHeaderPattern=function(a,b){return a[b]===255&&(a[b+1]&246)===240};shaka.transmuxer.ADTS.getHeaderLength=function(a,b){return a[b+1]&1?7:9};
shaka.transmuxer.ADTS.getFullFrameLength=function(a,b){return(a[b+3]&3)<<11|a[b+4]<<3|(a[b+5]&224)>>>5};shaka.transmuxer.ADTS.isHeader=function(a,b){var c=shaka.transmuxer.ADTS;return b+1<a.length&&c.isHeaderPattern(a,b)};shaka.transmuxer.ADTS.probe=function(a,b){var c=shaka.transmuxer.ADTS;if(c.isHeader(a,b)){var d=c.getHeaderLength(a,b);if(b+d>=a.length)return!1;var e=c.getFullFrameLength(a,b);if(e<=d)return!1;b+=e;return b===a.length||c.isHeader(a,b)}return!1};
shaka.transmuxer.ADTS.getFrameDuration=function(a){return shaka.transmuxer.ADTS.AAC_SAMPLES_PER_FRAME*9E4/a};
shaka.transmuxer.ADTS.getSilentFrame=function(a,b){switch(a){case "mp4a.40.2":if(b===1)return new Uint8Array([0,200,0,128,35,128]);if(b===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(b===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(b===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(b===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(b===6)return new Uint8Array([0,200,0,128,32,132,1,38,
64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(b===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(b===2||b===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null};
shaka.transmuxer.ADTS.AAC_SAMPLES_PER_FRAME=1024;shaka.transmuxer.AacTransmuxer=function(a){this.originalMimeType_=a;this.frameIndex_=0;this.initSegments=new Map;this.lastInitSegment_=null};shaka.transmuxer.AacTransmuxer.prototype.destroy=function(){this.initSegments.clear()};shaka.transmuxer.AacTransmuxer.prototype.isSupported=function(a,b){b=shaka.media.Capabilities;return this.isAacContainer_(a)?b.isTypeSupported(this.convertCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a)):!1};
shaka.transmuxer.AacTransmuxer.prototype.isAacContainer_=function(a){return a.toLowerCase().split(";")[0]=="audio/aac"};shaka.transmuxer.AacTransmuxer.prototype.convertCodecs=function(a,b){return this.isAacContainer_(b)?'audio/mp4; codecs="'+(shaka.util.MimeUtils.getCodecs(b)||"mp4a.40.2")+'"':b};shaka.transmuxer.AacTransmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.AacTransmuxer.prototype.transmux=function(a,b,c,d){for(var e=shaka.transmuxer.ADTS,f=shaka.util.BufferUtils.toUint8(a),g=shaka.util.Id3Utils.getID3Data(f),h=g.length;h<f.length&&!e.probe(f,h);h++);a=c.endTime*1E3;g=shaka.util.Id3Utils.getID3Frames(g);g.length&&c&&(g=g.find(function(p){return p.description==="com.apple.streaming.transportStreamTimestamp"}))&&(a=g.data);g=e.parseInfo(f,h);if(!g)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));b.audioSamplingRate=g.sampleRate;b.channelsCount=g.channelCount;for(var k=[];h<f.length;){var l=e.parseHeader(f,h);if(!l)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));var m=l.headerLength+l.frameLength;if(h+m<=f.length){var n=f.subarray(h+l.headerLength,h+m);k.push({data:n,size:l.frameLength,duration:e.AAC_SAMPLES_PER_FRAME,
cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}})}h+=m}e=g.sampleRate;a=Math.floor(a*e/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:g.codec,encrypted:b.encrypted&&b.drmInfos.length>0,timescale:e,duration:d,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:a,samples:k},stream:b};d=new shaka.util.Mp4Generator([d]);c=b.id+
"_"+c.discontinuitySequence;this.initSegments.has(c)?b=this.initSegments.get(c):(b=d.initSegment(),this.initSegments.set(c,b));c=this.lastInitSegment_!==b;d=d.segmentData();this.lastInitSegment_=b;this.frameIndex_++;return Promise.resolve({data:d,init:c?b:null})};goog.exportSymbol("shaka.transmuxer.AacTransmuxer",shaka.transmuxer.AacTransmuxer);goog.exportProperty(shaka.transmuxer.AacTransmuxer.prototype,"transmux",shaka.transmuxer.AacTransmuxer.prototype.transmux);
goog.exportProperty(shaka.transmuxer.AacTransmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.AacTransmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.AacTransmuxer.prototype,"convertCodecs",shaka.transmuxer.AacTransmuxer.prototype.convertCodecs);goog.exportProperty(shaka.transmuxer.AacTransmuxer.prototype,"isSupported",shaka.transmuxer.AacTransmuxer.prototype.isSupported);goog.exportProperty(shaka.transmuxer.AacTransmuxer.prototype,"destroy",shaka.transmuxer.AacTransmuxer.prototype.destroy);
shaka.transmuxer.TransmuxerEngine.registerTransmuxer("audio/aac",function(){return new shaka.transmuxer.AacTransmuxer("audio/aac")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);shaka.transmuxer.Ac3=function(){};
shaka.transmuxer.Ac3.parseFrame=function(a,b){if(b+8>a.length||a[b]!==11||a[b+1]!==119)return null;var c=a[b+4]>>6;if(c>=3)return null;var d=a[b+4]&63,e=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,
896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][d*3+c]*2;if(b+e>a.length)return null;var f=a[b+6]>>5,g=0;f===2?g+=2:(f&1&&f!==1&&(g+=2),f&4&&(g+=2));g=(a[b+6]<<8|a[b+7])>>12-g&1;var h=a[b+5]&7;a=new Uint8Array([c<<6|a[b+5]>>3<<1|h>>2,(h&3)<<6|f<<3|g<<2|d>>4,d<<4&224]);return{sampleRate:[48E3,44100,32E3][c],channelCount:[2,1,2,3,3,4,4,5][f]+g,audioConfig:a,frameLength:e}};
shaka.transmuxer.Ac3.probe=function(a,b){if(a[b]===11&&a[b+1]===119){var c=0,d=5;b+=d;for(var e,f;d>0;){f=a[b];var g=Math.min(d,8),h=8-g;e=4278190080>>>24+h<<h;e=(f&e)>>h;c=c?c<<g|e:e;b+=1;d-=g}if(c<16)return!0}return!1};shaka.transmuxer.Ac3.AC3_SAMPLES_PER_FRAME=1536;shaka.transmuxer.Ac3Transmuxer=function(a){this.originalMimeType_=a;this.frameIndex_=0;this.initSegments=new Map;this.lastInitSegment_=null};shaka.transmuxer.Ac3Transmuxer.prototype.destroy=function(){this.initSegments.clear()};shaka.transmuxer.Ac3Transmuxer.prototype.isSupported=function(a,b){b=shaka.media.Capabilities;return this.isAc3Container_(a)?b.isTypeSupported(this.convertCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a)):!1};
shaka.transmuxer.Ac3Transmuxer.prototype.isAc3Container_=function(a){return a.toLowerCase().split(";")[0]=="audio/ac3"};shaka.transmuxer.Ac3Transmuxer.prototype.convertCodecs=function(a,b){return this.isAc3Container_(b)?shaka.device.DeviceFactory.getDevice().requiresEC3InitSegments()?'audio/mp4; codecs="ec-3"':'audio/mp4; codecs="ac-3"':b};shaka.transmuxer.Ac3Transmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.Ac3Transmuxer.prototype.transmux=function(a,b,c,d){var e=shaka.transmuxer.Ac3;a=shaka.util.BufferUtils.toUint8(a);for(var f=shaka.util.Id3Utils.getID3Data(a),g=f.length;g<a.length&&!e.probe(a,g);g++);var h=c.endTime*1E3;f=shaka.util.Id3Utils.getID3Frames(f);f.length&&c&&(f=f.find(function(p){return p.description==="com.apple.streaming.transportStreamTimestamp"}))&&(h=f.data);f=0;for(var k=new Uint8Array([]),l=[];g<a.length;){var m=e.parseFrame(a,g);if(!m)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));b.audioSamplingRate=m.sampleRate;b.channelsCount=m.channelCount;f=m.sampleRate;k=m.audioConfig;var n=a.subarray(g,g+m.frameLength);l.push({data:n,size:m.frameLength,duration:e.AC3_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});g+=m.frameLength}e=Math.floor(h*f/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ac-3",
encrypted:b.encrypted&&b.drmInfos.length>0,timescale:f,duration:d,videoNalus:[],audioConfig:k,videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:e,samples:l},stream:b};d=new shaka.util.Mp4Generator([d]);c=b.id+"_"+c.discontinuitySequence;this.initSegments.has(c)?b=this.initSegments.get(c):(b=d.initSegment(),this.initSegments.set(c,b));c=this.lastInitSegment_!==b;d=d.segmentData();this.lastInitSegment_=b;this.frameIndex_++;return Promise.resolve({data:d,
init:c?b:null})};goog.exportSymbol("shaka.transmuxer.Ac3Transmuxer",shaka.transmuxer.Ac3Transmuxer);goog.exportProperty(shaka.transmuxer.Ac3Transmuxer.prototype,"transmux",shaka.transmuxer.Ac3Transmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.Ac3Transmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.Ac3Transmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.Ac3Transmuxer.prototype,"convertCodecs",shaka.transmuxer.Ac3Transmuxer.prototype.convertCodecs);
goog.exportProperty(shaka.transmuxer.Ac3Transmuxer.prototype,"isSupported",shaka.transmuxer.Ac3Transmuxer.prototype.isSupported);goog.exportProperty(shaka.transmuxer.Ac3Transmuxer.prototype,"destroy",shaka.transmuxer.Ac3Transmuxer.prototype.destroy);shaka.transmuxer.TransmuxerEngine.registerTransmuxer("audio/ac3",function(){return new shaka.transmuxer.Ac3Transmuxer("audio/ac3")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);shaka.transmuxer.Ec3=function(){};
shaka.transmuxer.Ec3.parseFrame=function(a,b){if(b+8>a.length||!shaka.transmuxer.Ec3.probe(a,b))return null;var c=new shaka.util.ExpGolomb(a.subarray(b+2));c.skipBits(2);c.skipBits(3);var d=c.readBits(11)+1<<1,e=c.readBits(2);if(e==3){e=c.readBits(2);e=[24E3,22060,16E3][e];var f=3}else e=[48E3,44100,32E3][e],f=c.readBits(2);var g=c.readBits(3),h=c.readBits(1);c=c.readBits(5);if(b+d>a.byteLength)return null;a=Math.floor(d*e/([1,2,3,6][f]*16));a=new Uint8Array([(a&8160)>>5,(a&31)<<3,e<<6|c<<1|0,0|g<<
1|h<<0,0]);return{sampleRate:e,channelCount:[2,1,2,3,3,4,4,5][g]+h,audioConfig:a,frameLength:d}};shaka.transmuxer.Ec3.probe=function(a,b){return(a[b]<<8|a[b+1]<<0)===2935?!0:!1};shaka.transmuxer.Ec3.EC3_SAMPLES_PER_FRAME=1536;shaka.transmuxer.Ec3Transmuxer=function(a){this.originalMimeType_=a;this.frameIndex_=0;this.initSegments=new Map;this.lastInitSegment_=null};shaka.transmuxer.Ec3Transmuxer.prototype.destroy=function(){this.initSegments.clear()};shaka.transmuxer.Ec3Transmuxer.prototype.isSupported=function(a,b){b=shaka.media.Capabilities;return this.isEc3Container_(a)?b.isTypeSupported(this.convertCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a)):!1};
shaka.transmuxer.Ec3Transmuxer.prototype.isEc3Container_=function(a){return a.toLowerCase().split(";")[0]=="audio/ec3"};shaka.transmuxer.Ec3Transmuxer.prototype.convertCodecs=function(a,b){return this.isEc3Container_(b)?'audio/mp4; codecs="ec-3"':b};shaka.transmuxer.Ec3Transmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.Ec3Transmuxer.prototype.transmux=function(a,b,c,d){var e=shaka.transmuxer.Ec3;a=shaka.util.BufferUtils.toUint8(a);for(var f=shaka.util.Id3Utils.getID3Data(a),g=f.length;g<a.length&&!e.probe(a,g);g++);var h=c.endTime*1E3;f=shaka.util.Id3Utils.getID3Frames(f);f.length&&c&&(f=f.find(function(p){return p.description==="com.apple.streaming.transportStreamTimestamp"}))&&(h=f.data);f=0;for(var k=new Uint8Array([]),l=[];g<a.length;){var m=e.parseFrame(a,g);if(!m)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));b.audioSamplingRate=m.sampleRate;b.channelsCount=m.channelCount;f=m.sampleRate;k=m.audioConfig;var n=a.subarray(g,g+m.frameLength);l.push({data:n,size:m.frameLength,duration:e.EC3_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});g+=m.frameLength}e=Math.floor(h*f/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ec-3",
encrypted:b.encrypted&&b.drmInfos.length>0,timescale:f,duration:d,videoNalus:[],audioConfig:k,videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:e,samples:l},stream:b};d=new shaka.util.Mp4Generator([d]);c=b.id+"_"+c.discontinuitySequence;this.initSegments.has(c)?b=this.initSegments.get(c):(b=d.initSegment(),this.initSegments.set(c,b));c=this.lastInitSegment_!==b;d=d.segmentData();this.lastInitSegment_=b;this.frameIndex_++;return Promise.resolve({data:d,
init:c?b:null})};goog.exportSymbol("shaka.transmuxer.Ec3Transmuxer",shaka.transmuxer.Ec3Transmuxer);goog.exportProperty(shaka.transmuxer.Ec3Transmuxer.prototype,"transmux",shaka.transmuxer.Ec3Transmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.Ec3Transmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.Ec3Transmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.Ec3Transmuxer.prototype,"convertCodecs",shaka.transmuxer.Ec3Transmuxer.prototype.convertCodecs);
goog.exportProperty(shaka.transmuxer.Ec3Transmuxer.prototype,"isSupported",shaka.transmuxer.Ec3Transmuxer.prototype.isSupported);goog.exportProperty(shaka.transmuxer.Ec3Transmuxer.prototype,"destroy",shaka.transmuxer.Ec3Transmuxer.prototype.destroy);shaka.transmuxer.TransmuxerEngine.registerTransmuxer("audio/ec3",function(){return new shaka.transmuxer.Ec3Transmuxer("audio/ec3")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);shaka.transmuxer.H264=function(){};
shaka.transmuxer.H264.parseInfo=function(a){var b=shaka.transmuxer.H264;if(!a.length)return null;var c=a.find(function(w){return w.type==b.NALU_TYPE_SPS_});a=a.find(function(w){return w.type==b.NALU_TYPE_PPS_});if(!c||!a)return null;var d=new shaka.util.ExpGolomb(c.data),e=d.readUnsignedByte();d.readUnsignedByte();d.readUnsignedByte();d.skipExpGolomb();if(b.PROFILES_WITH_OPTIONAL_SPS_DATA_.includes(e)&&(e=d.readUnsignedExpGolomb(),e===3&&d.skipBits(1),d.skipExpGolomb(),d.skipExpGolomb(),d.skipBits(1),
d.readBoolean())){e=e!==3?8:12;for(var f=0;f<e;f++)d.readBoolean()&&(f<6?d.skipScalingList(16):d.skipScalingList(64))}d.skipExpGolomb();e=d.readUnsignedExpGolomb();if(e===0)d.readUnsignedExpGolomb();else if(e===1)for(d.skipBits(1),d.skipExpGolomb(),d.skipExpGolomb(),e=d.readUnsignedExpGolomb(),f=0;f<e;f++)d.skipExpGolomb();d.skipExpGolomb();d.skipBits(1);var g=d.readUnsignedExpGolomb(),h=d.readUnsignedExpGolomb(),k=d.readBits(1);k===0&&d.skipBits(1);d.skipBits(1);var l=0,m=0,n=0,p=0;d.readBoolean()&&
(l=d.readUnsignedExpGolomb(),m=d.readUnsignedExpGolomb(),n=d.readUnsignedExpGolomb(),p=d.readUnsignedExpGolomb());f=e=1;if(d.readBoolean()&&d.readBoolean()){var q=d.readUnsignedByte(),r=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],t=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];q>0&&q<=16?(e=r[q-1],f=t[q-1]):q===255&&(e=d.readBits(16),f=d.readBits(16))}d=(2-k)*(h+1)*16-n*2-p*2;g=(g+1)*16-l*2-m*2;l=[];c=c.fullData;l.push(c.byteLength>>>8&255);l.push(c.byteLength&255);l=l.concat.apply(l,(0,$jscomp.arrayFromIterable)(c));
c=[];a=a.fullData;c.push(a.byteLength>>>8&255);c.push(a.byteLength&255);c=c.concat.apply(c,(0,$jscomp.arrayFromIterable)(a));a=new Uint8Array([1,l[3],l[4],l[5],255,225].concat(l).concat([1]).concat(c));return{height:d,width:g,videoConfig:a,hSpacing:e,vSpacing:f}};
shaka.transmuxer.H264.getVideoSamples=function(a){for(var b=shaka.transmuxer.H264,c=[],d=null,e=!1,f=function(){if(d&&d.nalus.length&&d.frame){for(var t=[],w=(0,$jscomp.makeIterator)(d.nalus),v=w.next();!v.done;v=w.next()){v=v.value;var u=v.fullData.byteLength,x=new Uint8Array(4);x[0]=u>>24&255;x[1]=u>>16&255;x[2]=u>>8&255;x[3]=u&255;t.push(x);t.push(v.fullData)}d.data=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(t));c.push(d)}},g=function(t){d=
{data:new Uint8Array([]),frame:!1,isKeyframe:!1,pts:t.pts,dts:t.dts,nalus:[]}},h=0;h<a.length;h++){var k=a[h],l=k.nalus,m=!1;d&&l.length&&!e&&(f(),g(k));l=(0,$jscomp.makeIterator)(k.nalus);for(var n=l.next();!n.done;n=l.next()){n=n.value;var p=!1;switch(n.type){case b.NALU_TYPE_NDR_:var q=!1;p=!0;var r=n.data;m&&r.length>4&&(r=(new shaka.util.ExpGolomb(r)).readSliceType(),r===2||r===4||r===7||r===9)&&(q=!0);q&&d&&d.frame&&!d.isKeyframe&&(f(),d=null);d||g(k);d.frame=!0;d.isKeyframe=q;break;case b.NALU_TYPE_IDR_:p=
!0;d&&d.frame&&!d.isKeyframe&&(f(),d=null);d||g(k);d.frame=!0;d.isKeyframe=!0;break;case b.NALU_TYPE_SEI_:p=!0;break;case b.NALU_TYPE_SPS_:m=p=!0;break;case b.NALU_TYPE_PPS_:p=!0;break;case b.NALU_TYPE_AUD_:e=p=!0;d&&d.frame&&(f(),d=null);d||g(k);break;case b.NALU_TYPE_FILLER_DATA_:p=!0;break;default:p=!1}d&&p&&d.nalus.push(n)}}f();return c};shaka.transmuxer.H264.NALU_TYPE_NDR_=1;shaka.transmuxer.H264.NALU_TYPE_IDR_=5;shaka.transmuxer.H264.NALU_TYPE_SEI_=6;shaka.transmuxer.H264.NALU_TYPE_SPS_=7;
shaka.transmuxer.H264.NALU_TYPE_PPS_=8;shaka.transmuxer.H264.NALU_TYPE_AUD_=9;shaka.transmuxer.H264.NALU_TYPE_FILLER_DATA_=12;shaka.transmuxer.H264.PROFILES_WITH_OPTIONAL_SPS_DATA_=[100,110,122,244,44,83,86,118,128,138,139,134];shaka.transmuxer.H265=function(){};
shaka.transmuxer.H265.parseInfo=function(a){var b=shaka.transmuxer.H265;if(!a.length)return null;var c=a.find(function(h){return h.type==b.NALU_TYPE_VPS_}),d=a.find(function(h){return h.type==b.NALU_TYPE_SPS_}),e=a.find(function(h){return h.type==b.NALU_TYPE_PPS_});if(!c||!d||!e)return null;var f=b.parseVPS_(c.fullData);a=b.parseSPS_(d.fullData);var g=b.parsePPS_(e.fullData);c=b.getVideoConfiguration_(c.fullData,d.fullData,e.fullData,{numTemporalLayers:f.numTemporalLayers,temporalIdNested:f.temporalIdNested,
generalProfileSpace:a.generalProfileSpace,generalTierFlag:a.generalTierFlag,generalLevelIdc:a.generalLevelIdc,generalProfileIdc:a.generalProfileIdc,generalProfileCompatibilityFlags1:a.generalProfileCompatibilityFlags1,generalProfileCompatibilityFlags2:a.generalProfileCompatibilityFlags2,generalProfileCompatibilityFlags3:a.generalProfileCompatibilityFlags3,generalProfileCompatibilityFlags4:a.generalProfileCompatibilityFlags4,generalConstraintIndicatorFlags1:a.generalConstraintIndicatorFlags1,generalConstraintIndicatorFlags2:a.generalConstraintIndicatorFlags2,
generalConstraintIndicatorFlags3:a.generalConstraintIndicatorFlags3,generalConstraintIndicatorFlags4:a.generalConstraintIndicatorFlags4,generalConstraintIndicatorFlags5:a.generalConstraintIndicatorFlags5,generalConstraintIndicatorFlags6:a.generalConstraintIndicatorFlags6,minSpatialSegmentationIdc:a.minSpatialSegmentationIdc,chromaFormatIdc:a.chromaFormatIdc,bitDepthLumaMinus8:a.bitDepthLumaMinus8,bitDepthChromaMinus8:a.bitDepthChromaMinus8,parallelismType:g.parallelismType,frameRateFps:a.frameRateFps,
frameRateFixed:a.frameRateFixed});return{height:a.height,width:a.width,videoConfig:c,hSpacing:a.sarWidth,vSpacing:a.sarHeight}};shaka.transmuxer.H265.parseVPS_=function(a){var b=new shaka.util.ExpGolomb(a,!0);b.readUnsignedByte();b.readUnsignedByte();b.readBits(4);b.readBits(2);b.readBits(6);a=b.readBits(3);b=b.readBoolean();return{numTemporalLayers:a+1,temporalIdNested:b}};
shaka.transmuxer.H265.parseSPS_=function(a){a=new shaka.util.ExpGolomb(a,!0);a.readUnsignedByte();a.readUnsignedByte();var b=0,c=0,d=0,e=0;a.readBits(4);var f=a.readBits(3);a.readBoolean();for(var g=a.readBits(2),h=a.readBits(1),k=a.readBits(5),l=a.readUnsignedByte(),m=a.readUnsignedByte(),n=a.readUnsignedByte(),p=a.readUnsignedByte(),q=a.readUnsignedByte(),r=a.readUnsignedByte(),t=a.readUnsignedByte(),w=a.readUnsignedByte(),v=a.readUnsignedByte(),u=a.readUnsignedByte(),x=a.readUnsignedByte(),z=[],
B=[],C=0;C<f;C++)z.push(a.readBoolean()),B.push(a.readBoolean());if(f>0)for(C=f;C<8;C++)a.readBits(2);for(C=0;C<f;C++)z[C]&&a.readBits(88),B[C]&&a.readUnsignedByte();a.readUnsignedExpGolomb();z=a.readUnsignedExpGolomb();z==3&&a.readBits(1);B=a.readUnsignedExpGolomb();C=a.readUnsignedExpGolomb();a.readBoolean()&&(b+=a.readUnsignedExpGolomb(),c+=a.readUnsignedExpGolomb(),d+=a.readUnsignedExpGolomb(),e+=a.readUnsignedExpGolomb());var y=a.readUnsignedExpGolomb(),A=a.readUnsignedExpGolomb(),D=a.readUnsignedExpGolomb();
if(a.readBoolean())for(var E=0;E<=f;E++)a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb();else a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();a.readUnsignedExpGolomb();if(a.readBoolean()&&a.readBoolean())for(E=0;E<4;E++)for(var F=0;F<(E===3?2:6);F++)if(a.readBoolean()){var L=Math.min(64,1<<4+(E<<1));E>1&&a.readExpGolomb();
for(var K=0;K<L;K++)a.readExpGolomb()}else a.readUnsignedExpGolomb();a.readBoolean();a.readBoolean();a.readBoolean()&&(a.readUnsignedByte(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readBoolean());E=a.readUnsignedExpGolomb();for(L=F=0;L<E;L++)if(K=!1,L!==0&&(K=a.readBoolean()),K){L===E&&a.readUnsignedExpGolomb();a.readBoolean();a.readUnsignedExpGolomb();for(var J=K=0;J<=F;J++){var I=a.readBoolean(),G=!1;I||(G=a.readBoolean());(I||G)&&K++}F=K}else{J=a.readUnsignedExpGolomb();K=a.readUnsignedExpGolomb();
F=J+K;for(I=0;I<J;I++)a.readUnsignedExpGolomb(),a.readBoolean();for(J=0;J<K;J++)a.readUnsignedExpGolomb(),a.readBoolean()}if(a.readBoolean())for(E=a.readUnsignedExpGolomb(),F=0;F<E;F++){for(L=0;L<D+4;L++)a.readBits(1);a.readBits(1)}E=D=1;F=!0;L=1;J=K=0;a.readBoolean();a.readBoolean();if(a.readBoolean()){if(a.readBoolean()){I=a.readUnsignedByte();G=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2];var M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];I>0&&I<=16?(D=G[I-1],E=M[I-1]):I===255&&(D=a.readBits(16),
E=a.readBits(16))}a.readBoolean()&&a.readBoolean();a.readBoolean()&&(a.readBits(3),a.readBoolean(),a.readBoolean()&&(a.readUnsignedByte(),a.readUnsignedByte(),a.readUnsignedByte()));a.readBoolean()&&(a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb());a.readBoolean();a.readBoolean();a.readBoolean();if(I=a.readBoolean())a.skipExpGolomb(),a.skipExpGolomb(),a.skipExpGolomb(),a.skipExpGolomb();if(a.readBoolean()&&(L=a.readBits(32),K=a.readBits(32),a.readBoolean()&&a.readUnsignedExpGolomb(),a.readBoolean())){M=
!1;I=a.readBoolean();G=a.readBoolean();if(I||G){if(M=a.readBoolean())a.readUnsignedByte(),a.readBits(5),a.readBoolean(),a.readBits(5);a.readBits(4);a.readBits(4);M&&a.readBits(4);a.readBits(5);a.readBits(5);a.readBits(5)}for(var H=0;H<=f;H++){F=a.readBoolean();var P=!0,Q=1;F||(P=a.readBoolean());var O=!1;P?a.readUnsignedExpGolomb():O=a.readBoolean();O||(Q=a.readUnsignedExpGolomb()+1);if(I){for(P=0;P<Q;P++)a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),M&&(a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb());
a.readBoolean()}if(G){for(P=0;P<Q;P++)a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),M&&(a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb());a.readBoolean()}}}a.readBoolean()&&(a.readBoolean(),a.readBoolean(),a.readBoolean(),J=a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb())}return{generalLevelIdc:x,generalProfileSpace:g,generalTierFlag:h,generalProfileIdc:k,generalProfileCompatibilityFlags1:l,generalProfileCompatibilityFlags2:m,
generalProfileCompatibilityFlags3:n,generalProfileCompatibilityFlags4:p,generalConstraintIndicatorFlags1:q,generalConstraintIndicatorFlags2:r,generalConstraintIndicatorFlags3:t,generalConstraintIndicatorFlags4:w,generalConstraintIndicatorFlags5:v,generalConstraintIndicatorFlags6:u,minSpatialSegmentationIdc:J,chromaFormatIdc:z,bitDepthLumaMinus8:y,bitDepthChromaMinus8:A,width:B-(b+c)*(z===1||z===2?2:1),height:C-(d+e)*(z===1?2:1),sarWidth:D,sarHeight:E,frameRateFps:K/L,frameRateFixed:F}};
shaka.transmuxer.H265.parsePPS_=function(a){var b=new shaka.util.ExpGolomb(a,!0);b.readUnsignedByte();b.readUnsignedByte();b.readUnsignedExpGolomb();b.readUnsignedExpGolomb();b.readBoolean();b.readBoolean();b.readBits(3);b.readBoolean();b.readBoolean();b.readUnsignedExpGolomb();b.readUnsignedExpGolomb();b.readExpGolomb();b.readBoolean();b.readBoolean();b.readBoolean()&&b.readUnsignedExpGolomb();b.readExpGolomb();b.readExpGolomb();b.readBoolean();b.readBoolean();b.readBoolean();b.readBoolean();a=b.readBoolean();
b=b.readBoolean();var c=1;b&&a?c=0:b?c=3:a&&(c=2);return{parallelismType:c}};
shaka.transmuxer.H265.getVideoConfiguration_=function(a,b,c,d){var e=new Uint8Array(23+(5+a.byteLength)+(5+b.byteLength)+(5+c.byteLength));e[0]=1;e[1]=(d.generalProfileSpace&3)<<6|(d.generalTierFlag?1:0)<<5|d.generalProfileIdc&31;e[2]=d.generalProfileCompatibilityFlags1;e[3]=d.generalProfileCompatibilityFlags2;e[4]=d.generalProfileCompatibilityFlags3;e[5]=d.generalProfileCompatibilityFlags4;e[6]=d.generalConstraintIndicatorFlags1;e[7]=d.generalConstraintIndicatorFlags2;e[8]=d.generalConstraintIndicatorFlags3;
e[9]=d.generalConstraintIndicatorFlags4;e[10]=d.generalConstraintIndicatorFlags5;e[11]=d.generalConstraintIndicatorFlags6;e[12]=d.generalLevelIdc;e[13]=240|(d.minSpatialSegmentationIdc&3840)>>8;e[14]=d.minSpatialSegmentationIdc&255;e[15]=252|d.parallelismType&3;e[16]=252|d.chromaFormatIdc&3;e[17]=248|d.bitDepthLumaMinus8&7;e[18]=248|d.bitDepthChromaMinus8&7;e[19]=0;e[20]=parseInt(d.frameRateFps,10);e[21]=((d.frameRateFixed?1:0)&3)<<6|(d.numTemporalLayers&7)<<3|(d.temporalIdNested?1:0)<<2|3;e[22]=
3;a=[a,b,c];b=23;c=a.length-1;for(d=0;d<a.length;d+=1)e.set(new Uint8Array([32+d|(d===c?128:0),0,1]),b),b+=3,e.set(new Uint8Array([a[d].byteLength>>8,a[d].byteLength&255]),b),b+=2,e.set(a[d],b),b+=a[d].byteLength;return e};
shaka.transmuxer.H265.parseFrame=function(a){var b=shaka.transmuxer.H265,c=!1,d=[],e=!1;a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next()){f=f.value;switch(f.type){case b.NALU_TYPE_TRAIL_N_:case b.NALU_TYPE_TRAIL_R_:var g=e=!0;break;case b.NALU_TYPE_IDR_W_RADL_:case b.NALU_TYPE_IDR_N_LP_:case b.NALU_TYPE_CRA_NUT_:c=g=e=!0;break;case b.NALU_TYPE_VPS_:g=!0;break;case b.NALU_TYPE_SPS_:g=!0;break;case b.NALU_TYPE_PPS_:g=!0;break;case b.NALU_TYPE_AUD_:e=g=!0;break;case b.NALU_TYPE_SEI_PREFIX_:case b.NALU_TYPE_SEI_SUFFIX_:g=
!0;break;default:g=!1}if(e&&g){g=f.fullData.byteLength;var h=new Uint8Array(4);h[0]=g>>24&255;h[1]=g>>16&255;h[2]=g>>8&255;h[3]=g&255;d.push(h);d.push(f.fullData)}}return d.length?{data:shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(d)),isKeyframe:c}:null};shaka.transmuxer.H265.NALU_TYPE_TRAIL_N_=1;shaka.transmuxer.H265.NALU_TYPE_TRAIL_R_=0;shaka.transmuxer.H265.NALU_TYPE_IDR_W_RADL_=19;shaka.transmuxer.H265.NALU_TYPE_IDR_N_LP_=20;
shaka.transmuxer.H265.NALU_TYPE_CRA_NUT_=21;shaka.transmuxer.H265.NALU_TYPE_VPS_=32;shaka.transmuxer.H265.NALU_TYPE_SPS_=33;shaka.transmuxer.H265.NALU_TYPE_PPS_=34;shaka.transmuxer.H265.NALU_TYPE_AUD_=35;shaka.transmuxer.H265.NALU_TYPE_SEI_PREFIX_=39;shaka.transmuxer.H265.NALU_TYPE_SEI_SUFFIX_=40;shaka.transmuxer.MpegAudio=function(){};
shaka.transmuxer.MpegAudio.parseHeader=function(a,b){var c=shaka.transmuxer.MpegAudio,d=a[b+1]>>3&3,e=a[b+1]>>1&3,f=a[b+2]>>4&15,g=a[b+2]>>2&3;if(d!==1&&f!==0&&f!==15&&g!==3){var h=a[b+3]>>6;f=c.BITRATES_MAP_[(d===3?3-e:e===3?3:4)*14+f-1]*1E3;g=c.SAMPLING_RATE_MAP_[(d===3?0:d===2?1:2)*3+g];var k=h===3?1:2;d=c.SAMPLES_COEFFICIENTS_[d][e];var l=c.BYTES_IN_SLOT_[e];c=d*8*l;d=Math.floor(d*f/g+(a[b+2]>>1&1))*l;(l=(l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i))?parseInt(l[1],10):0)&&l<=87&&e===2&&
f>=224E3&&h===0&&(a[b+3]|=128);return{sampleRate:g,channelCount:k,frameLength:d,samplesPerFrame:c}}return null};shaka.transmuxer.MpegAudio.isHeaderPattern=function(a,b){return a[b]===255&&(a[b+1]&224)===224&&(a[b+1]&6)!==0};shaka.transmuxer.MpegAudio.isHeader=function(a,b){return b+1<a.length&&shaka.transmuxer.MpegAudio.isHeaderPattern(a,b)};
shaka.transmuxer.MpegAudio.probe=function(a,b){var c=shaka.transmuxer.MpegAudio;if(b+1<a.length&&c.isHeaderPattern(a,b)){var d=c.parseHeader(a,b),e=4;d&&d.frameLength&&(e=d.frameLength);b+=e;return b===a.length||c.isHeader(a,b)}return!1};
shaka.transmuxer.MpegAudio.BITRATES_MAP_=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160];shaka.transmuxer.MpegAudio.SAMPLING_RATE_MAP_=[44100,48E3,32E3,22050,24E3,16E3,11025,12E3,8E3];shaka.transmuxer.MpegAudio.SAMPLES_COEFFICIENTS_=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]];
shaka.transmuxer.MpegAudio.BYTES_IN_SLOT_=[0,1,1,4];shaka.transmuxer.MpegAudio.MPEG_AUDIO_SAMPLE_PER_FRAME=1152;shaka.transmuxer.Mp3Transmuxer=function(a){this.originalMimeType_=a;this.frameIndex_=0;this.initSegments=new Map;this.lastInitSegment_=null};shaka.transmuxer.Mp3Transmuxer.prototype.destroy=function(){this.initSegments.clear()};shaka.transmuxer.Mp3Transmuxer.prototype.isSupported=function(a,b){b=shaka.media.Capabilities;return this.isMpegContainer_(a)?b.isTypeSupported(this.convertCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a)):!1};
shaka.transmuxer.Mp3Transmuxer.prototype.isMpegContainer_=function(a){return a.toLowerCase().split(";")[0]=="audio/mpeg"};shaka.transmuxer.Mp3Transmuxer.prototype.convertCodecs=function(a,b){return this.isMpegContainer_(b)?'audio/mp4; codecs="mp3"':b};shaka.transmuxer.Mp3Transmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.Mp3Transmuxer.prototype.transmux=function(a,b,c,d){for(var e=shaka.transmuxer.MpegAudio,f=shaka.util.BufferUtils.toUint8(a),g=shaka.util.Id3Utils.getID3Data(f).length;g<f.length&&!e.probe(f,g);g++);var h;for(a=[];g<f.length;){var k=e.parseHeader(f,g);if(!k)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));h||(h=k);g+k.frameLength<=f.length&&a.push({data:f.subarray(g,
g+k.frameLength),size:k.frameLength,duration:e.MPEG_AUDIO_SAMPLE_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});g+=k.frameLength}if(!h)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));e=h.samplesPerFrame*9E4/h.sampleRate*this.frameIndex_;d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"mp3",
encrypted:b.encrypted&&b.drmInfos.length>0,timescale:h.sampleRate,duration:d,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:e,samples:a},stream:b};d=new shaka.util.Mp4Generator([d]);c=b.id+"_"+c.discontinuitySequence;this.initSegments.has(c)?b=this.initSegments.get(c):(b=d.initSegment(),this.initSegments.set(c,b));c=this.lastInitSegment_!==b;d=d.segmentData();this.lastInitSegment_=b;this.frameIndex_++;
return Promise.resolve({data:d,init:c?b:null})};goog.exportSymbol("shaka.transmuxer.Mp3Transmuxer",shaka.transmuxer.Mp3Transmuxer);goog.exportProperty(shaka.transmuxer.Mp3Transmuxer.prototype,"transmux",shaka.transmuxer.Mp3Transmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.Mp3Transmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.Mp3Transmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.Mp3Transmuxer.prototype,"convertCodecs",shaka.transmuxer.Mp3Transmuxer.prototype.convertCodecs);
goog.exportProperty(shaka.transmuxer.Mp3Transmuxer.prototype,"isSupported",shaka.transmuxer.Mp3Transmuxer.prototype.isSupported);goog.exportProperty(shaka.transmuxer.Mp3Transmuxer.prototype,"destroy",shaka.transmuxer.Mp3Transmuxer.prototype.destroy);shaka.transmuxer.TransmuxerEngine.registerTransmuxer("audio/mpeg",function(){return new shaka.transmuxer.Mp3Transmuxer("audio/mpeg")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);shaka.transmuxer.MpegTsTransmuxer=function(a){this.originalMimeType_=a;this.tsParser_=null};shaka.transmuxer.MpegTsTransmuxer.prototype.destroy=function(){};
shaka.transmuxer.MpegTsTransmuxer.prototype.isSupported=function(a,b){b=shaka.media.Capabilities;if(!this.isTsContainer_(a))return!1;var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.MimeUtils,e=d.getCodecs(a),f=d.splitCodecs(e);e=shaka.util.ManifestParserUtils.guessCodecsSafe(c.AUDIO,f);f=shaka.util.ManifestParserUtils.guessCodecsSafe(c.VIDEO,f);return!e||f||d.getNormalizedCodec(e)!="mp3"?!1:b.isTypeSupported(this.convertCodecs(c.AUDIO,a))};
shaka.transmuxer.MpegTsTransmuxer.prototype.isTsContainer_=function(a){return a.toLowerCase().split(";")[0]=="video/mp2t"};shaka.transmuxer.MpegTsTransmuxer.prototype.convertCodecs=function(a,b){return this.isTsContainer_(b)?"audio/mpeg":b};shaka.transmuxer.MpegTsTransmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.MpegTsTransmuxer.prototype.transmux=function(a,b,c,d,e){b=shaka.transmuxer.MpegAudio;var f=shaka.util.ManifestParserUtils.ContentType;d=shaka.util.Uint8ArrayUtils;this.tsParser_?this.tsParser_.clearData():this.tsParser_=new shaka.util.TsParser;this.tsParser_.setDiscontinuitySequence(c.discontinuitySequence);a=shaka.util.BufferUtils.toUint8(a);a=this.tsParser_.parse(a);if(a.getCodecs().audio!="mp3"||e!=f.AUDIO)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));c=new Uint8Array([]);e=(0,$jscomp.makeIterator)(a.getAudioData());for(a=e.next();!a.done;a=e.next())if(a=a.value.data)for(f=0;f<a.length;){var g=b.parseHeader(a,f);g?(f+g.frameLength<=a.length&&(c=d.concat(c,a.subarray(f,f+g.frameLength))),f+=g.frameLength):f++}return Promise.resolve(c)};goog.exportSymbol("shaka.transmuxer.MpegTsTransmuxer",shaka.transmuxer.MpegTsTransmuxer);
goog.exportProperty(shaka.transmuxer.MpegTsTransmuxer.prototype,"transmux",shaka.transmuxer.MpegTsTransmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.MpegTsTransmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.MpegTsTransmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.MpegTsTransmuxer.prototype,"convertCodecs",shaka.transmuxer.MpegTsTransmuxer.prototype.convertCodecs);goog.exportProperty(shaka.transmuxer.MpegTsTransmuxer.prototype,"isSupported",shaka.transmuxer.MpegTsTransmuxer.prototype.isSupported);
goog.exportProperty(shaka.transmuxer.MpegTsTransmuxer.prototype,"destroy",shaka.transmuxer.MpegTsTransmuxer.prototype.destroy);shaka.transmuxer.TransmuxerEngine.registerTransmuxer("video/mp2t",function(){return new shaka.transmuxer.MpegTsTransmuxer("video/mp2t")},shaka.transmuxer.TransmuxerEngine.PluginPriority.PREFERRED_SECONDARY);shaka.transmuxer.Opus=function(){};
shaka.transmuxer.Opus.getAudioConfig=function(a){var b=[];switch(a.channelConfigCode){case 1:case 2:b=[0];break;case 0:b=[255,1,1,0,1];break;case 128:b=[255,2,0,0,1];break;case 3:b=[1,2,1,0,2,1];break;case 4:b=[1,2,2,0,1,2,3];break;case 5:b=[1,3,2,0,4,1,2,3];break;case 6:b=[1,4,2,0,4,1,2,3,5];break;case 7:b=[1,4,2,0,4,1,2,3,5,6];break;case 8:b=[1,5,3,0,6,1,2,3,4,5,7];break;case 130:b=[1,1,2,0,1];break;case 131:b=[1,1,3,0,1,2];break;case 132:b=[1,1,4,0,1,2,3];break;case 133:b=[1,1,5,0,1,2,3,4];break;
case 134:b=[1,1,6,0,1,2,3,4,5];break;case 135:b=[1,1,7,0,1,2,3,4,5,6];break;case 136:b=[1,1,8,0,1,2,3,4,5,6,7]}return new Uint8Array([0,a.channelCount,0,0,a.sampleRate>>>24&255,a.sampleRate>>>17&255,a.sampleRate>>>8&255,a.sampleRate>>>0&255,0,0].concat((0,$jscomp.arrayFromIterable)(b)))};shaka.transmuxer.Opus.OPUS_AUDIO_SAMPLE_PER_FRAME=960;shaka.transmuxer.TsTransmuxer=function(a){this.originalMimeType_=a;this.frameIndex_=0;this.initSegments=new Map;this.lastInitSegment_=this.aacTransmuxer_=this.tsParser_=null};shaka.transmuxer.TsTransmuxer.prototype.destroy=function(){this.initSegments.clear();this.aacTransmuxer_&&this.aacTransmuxer_.destroy()};
shaka.transmuxer.TsTransmuxer.prototype.isSupported=function(a,b){var c=shaka.media.Capabilities;if(!this.isTsContainer_(a))return!1;var d=shaka.util.ManifestParserUtils.ContentType,e=shaka.util.MimeUtils,f=a;b&&(f=this.convertCodecs(b,a));f=e.getCodecs(f);f=e.splitCodecs(f);var g=shaka.util.ManifestParserUtils.guessCodecsSafe(d.AUDIO,f),h=shaka.util.ManifestParserUtils.guessCodecsSafe(d.VIDEO,f);f=shaka.transmuxer.TsTransmuxer;if(g&&(g=e.getNormalizedCodec(g),!f.SUPPORTED_AUDIO_CODECS_.includes(g))||
h&&(e=e.getNormalizedCodec(h),!f.SUPPORTED_VIDEO_CODECS_.includes(e)))return!1;if(b)return c.isTypeSupported(this.convertCodecs(b,a));b=this.convertCodecs(d.AUDIO,a);a=this.convertCodecs(d.VIDEO,a);return c.isTypeSupported(b)||c.isTypeSupported(a)};shaka.transmuxer.TsTransmuxer.prototype.isTsContainer_=function(a){return a.toLowerCase().split(";")[0]=="video/mp2t"};
shaka.transmuxer.TsTransmuxer.prototype.convertCodecs=function(a,b){if(this.isTsContainer_(b)){var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.StreamUtils;b=shaka.util.MimeUtils.getCodecs(b).replace("mp4a.40.34","mp3").split(",").map(function(e){return d.getCorrectAudioCodecs(e,"audio/mp4")}).map(d.getCorrectVideoCodecs).join(",");return a==c.AUDIO?'audio/mp4; codecs="'+b+'"':'video/mp4; codecs="'+b+'"'}return b};shaka.transmuxer.TsTransmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.TsTransmuxer.prototype.transmux=function(a,b,c,d,e){var f=shaka.util.ManifestParserUtils.ContentType,g=shaka.util.BufferUtils.toUint8(a);if(e==f.AUDIO&&!shaka.util.TsParser.probe(g)){f=shaka.util.Id3Utils.getID3Data(g);for(var h=f.length;h<g.length;h++)if(shaka.transmuxer.MpegAudio.probe(g,h))return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));for(h=f.length;h<
g.length;h++)if(shaka.transmuxer.ADTS.probe(g,h))return this.aacTransmuxer_||(this.aacTransmuxer_=new shaka.transmuxer.AacTransmuxer("audio/aac")),this.aacTransmuxer_.transmux(a,b,c,d,e);return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null))}this.tsParser_?this.tsParser_.clearData():this.tsParser_=new shaka.util.TsParser;this.tsParser_.setDiscontinuitySequence(c.discontinuitySequence);
a=this.tsParser_.parse(g);g=[];h=a.getCodecs();try{var k=null;if(e==f.VIDEO){switch(h.video){case "avc":k=this.getAvcStreamInfo_(a,b,d,c);break;case "hvc":k=this.getHvcStreamInfo_(a,b,d,c)}k&&(g.push(k),k=null)}if(e==f.AUDIO){switch(h.audio){case "aac":k=this.getAacStreamInfo_(a,b,d,c);break;case "ac3":k=this.getAc3StreamInfo_(a,b,d,c);break;case "ec3":k=this.getEc3StreamInfo_(a,b,d,c);break;case "mp3":k=this.getMp3StreamInfo_(a,b,d,c);break;case "opus":k=this.getOpusStreamInfo_(a,b,d,c)}k&&g.push(k)}}catch(l){return l&&
l.code==shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA?Promise.resolve(new Uint8Array([])):Promise.reject(l)}if(!g.length)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,c?c.getUris()[0]:null));d=new shaka.util.Mp4Generator(g);c=b.id+"_"+c.discontinuitySequence;this.initSegments.has(c)?b=this.initSegments.get(c):(b=d.initSegment(),this.initSegments.set(c,b));c=this.lastInitSegment_!==b;d=d.segmentData();
this.lastInitSegment_=b;this.frameIndex_++;return Promise.resolve({data:d,init:c?b:null})};
shaka.transmuxer.TsTransmuxer.prototype.getAacStreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.ADTS,f=shaka.util.TsParser.Timescale,g=shaka.util.Uint8ArrayUtils,h=[],k=null,l=null,m=null;a=(0,$jscomp.makeIterator)(a.getAudioData());for(var n=a.next();!n.done;n=a.next()){var p=n.value;if(n=p.data){var q=0;if(l==-1&&m)n=g.concat(m,p.data),l=null;else if(l!=null&&m){q=Math.max(0,l);var r=g.concat(m,n.subarray(0,q));h.push({data:r,size:r.byteLength,duration:e.AAC_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,
isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});l=m=null}r=e.parseInfo(n,q);if(!r)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);b.audioSamplingRate=r.sampleRate;b.channelsCount=r.channelCount;k==null&&p.pts!==null&&(k=p.pts);for(;q<n.length;){p=e.parseHeader(n,q);if(!p){m=n.subarray(q,n.length);l=-1;break}var t=p.headerLength+p.frameLength;l=Math.max(0,q+t-n.length);
if(l!=0)m=n.subarray(q+p.headerLength,q+t);else if(q+t<=n.length){var w=n.subarray(q+p.headerLength,q+t);h.push({data:w,size:p.frameLength,duration:e.AAC_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}})}q+=t}}}if(!r||k==null){k=d.startTime*f;r=shaka.util.MimeUtils.splitCodecs(b.codecs);g=shaka.util.ManifestParserUtils.guessCodecsSafe(shaka.util.ManifestParserUtils.ContentType.AUDIO,r);if(!g||!b.channelsCount||!b.audioSamplingRate)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);r={sampleRate:b.audioSamplingRate,channelCount:b.channelsCount,codec:g};g=e.getSilentFrame(g,b.channelsCount);if(!g)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);d=k+(d.endTime-d.startTime)*f;for(l=k;l<d;)h.push({data:g,size:g.byteLength,duration:e.AAC_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,
isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}}),l+=e.AAC_SAMPLES_PER_FRAME/r.sampleRate*f}e=r.sampleRate;f=k/f*e;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:r.codec,encrypted:b.encrypted&&b.drmInfos.length>0,timescale:e,duration:c,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:f,samples:h},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getAc3StreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.Ac3,f=shaka.util.TsParser.Timescale,g=[],h=0,k=new Uint8Array([]),l=null;a=(0,$jscomp.makeIterator)(a.getAudioData());for(var m=a.next();!m.done;m=a.next()){var n=m.value;m=n.data;l==null&&n.pts!==null&&(l=n.pts);for(n=0;n<m.length;){var p=e.parseFrame(m,n);if(p){b.audioSamplingRate=p.sampleRate;b.channelsCount=p.channelCount;h=p.sampleRate;k=p.audioConfig;var q=m.subarray(n,n+p.frameLength);g.push({data:q,
size:p.frameLength,duration:e.AC3_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});n+=p.frameLength}else n++}}if(h==0||k.byteLength==0||l==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);d=l/f*h;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ac-3",encrypted:b.encrypted&&b.drmInfos.length>0,
timescale:h,duration:c,videoNalus:[],audioConfig:k,videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:d,samples:g},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getEc3StreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.Ec3,f=shaka.util.TsParser.Timescale,g=[],h=0,k=new Uint8Array([]),l=null;a=(0,$jscomp.makeIterator)(a.getAudioData());for(var m=a.next();!m.done;m=a.next()){var n=m.value;m=n.data;l==null&&n.pts!==null&&(l=n.pts);for(n=0;n<m.length;){var p=e.parseFrame(m,n);if(p){b.audioSamplingRate=p.sampleRate;b.channelsCount=p.channelCount;h=p.sampleRate;k=p.audioConfig;var q=m.subarray(n,n+p.frameLength);g.push({data:q,
size:p.frameLength,duration:e.EC3_SAMPLES_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});n+=p.frameLength}else n++}}if(h==0||k.byteLength==0||l==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);d=l/f*h;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ec-3",encrypted:b.encrypted&&b.drmInfos.length>0,
timescale:h,duration:c,videoNalus:[],audioConfig:k,videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:d,samples:g},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getMp3StreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.MpegAudio,f=shaka.util.TsParser.Timescale,g=[],h,k=null;a=(0,$jscomp.makeIterator)(a.getAudioData());for(var l=a.next();!l.done;l=a.next()){var m=l.value;if(l=m.data)for(k==null&&m.pts!==null&&(k=m.pts),m=0;m<l.length;){var n=e.parseHeader(l,m);n?(h||(h=n),m+n.frameLength<=l.length&&g.push({data:l.subarray(m,m+n.frameLength),size:n.frameLength,duration:e.MPEG_AUDIO_SAMPLE_PER_FRAME,cts:0,flags:{isLeading:0,
isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}}),m+=n.frameLength):m++}}if(!h||k==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);d=h.sampleRate;f=k/f*d;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"mp3",encrypted:b.encrypted&&b.drmInfos.length>0,timescale:d,duration:c,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:new Uint8Array([]),
hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:f,samples:g},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getOpusStreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.Opus,f=shaka.util.TsParser.Timescale,g=[],h=null,k=a.getOpusMetadata();if(!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);var l=e.getAudioConfig(k),m=k.sampleRate;a=(0,$jscomp.makeIterator)(a.getAudioData());for(var n=a.next();!n.done;n=a.next()){var p=n.value;n=p.data;h==null&&p.pts!==null&&
(h=p.pts);for(var q=0;q<n.length;){p=(n[q+1]&16)!==0;var r=(n[q+1]&8)!==0;q+=2;for(var t=0;n[q]===255;)t+=255,q+=1;t+=n[q];q+=1;q+=p?2:0;q+=r?2:0;p=n.slice(q,q+t);g.push({data:p,size:p.byteLength,duration:e.OPUS_AUDIO_SAMPLE_PER_FRAME,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0}});q+=t}}if(l.byteLength==0||h==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?
d.getUris()[0]:null);b.audioSamplingRate=k.sampleRate;b.channelsCount=k.channelCount;d=h/f*m;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"opus",encrypted:b.encrypted&&b.drmInfos.length>0,timescale:m,duration:c,videoNalus:[],audioConfig:l,videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:d,samples:g},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getAvcStreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.H264,f=shaka.util.TsParser.Timescale,g=[],h=null;a=a.getVideoData();var k=e.getVideoSamples(a);if(!k.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA,d?d.getUris()[0]:null);for(var l=0;l<k.length;l++){var m=k[l];h==null&&(h=m.dts);g.push({data:m.data,size:m.data.byteLength,duration:l+1<k.length?(k[l+1].dts||
0)-(m.dts||0):k.length>1?(m.dts||0)-(k[l-1].dts||0):(d.endTime-d.startTime)*f,cts:Math.round((m.pts||0)-(m.dts||0)),flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:m.isKeyframe?2:1,isNonSync:m.isKeyframe?0:1}})}k=[];a=(0,$jscomp.makeIterator)(a);for(l=a.next();!l.done;l=a.next())k.push.apply(k,(0,$jscomp.arrayFromIterable)(l.value.nalus));e=e.parseInfo(k);if(!e||h==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,
d?d.getUris()[0]:null);b.height=e.height;b.width=e.width;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.VIDEO,codecs:"avc1",encrypted:b.encrypted&&b.drmInfos.length>0,timescale:f,duration:c,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:e.videoConfig,hSpacing:e.hSpacing,vSpacing:e.vSpacing,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:h,samples:g},stream:b}};
shaka.transmuxer.TsTransmuxer.prototype.getHvcStreamInfo_=function(a,b,c,d){var e=shaka.transmuxer.H265,f=shaka.util.TsParser.Timescale,g=[],h=null,k=[];a=a.getVideoData();if(!a.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_NO_VIDEO_DATA,d?d.getUris()[0]:null);for(var l=0;l<a.length;l++){var m=a[l],n=m.nalus;k.push.apply(k,(0,$jscomp.arrayFromIterable)(n));if(n=e.parseFrame(n))h==null&&m.dts!=null&&(h=m.dts),
g.push({data:n.data,size:n.data.byteLength,duration:l+1<a.length?(a[l+1].dts||0)-(m.dts||0):a.length>1?(m.dts||0)-(a[l-1].dts||0):(d.endTime-d.startTime)*f,cts:Math.round((m.pts||0)-(m.dts||0)),flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n.isKeyframe?2:1,isNonSync:n.isKeyframe?0:1}})}e=e.parseInfo(k);if(!e||h==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.TRANSMUXING_FAILED,d?d.getUris()[0]:null);
b.height=e.height;b.width=e.width;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.VIDEO,codecs:"hvc1",encrypted:b.encrypted&&b.drmInfos.length>0,timescale:f,duration:c,videoNalus:[],audioConfig:new Uint8Array([]),videoConfig:e.videoConfig,hSpacing:e.hSpacing,vSpacing:e.vSpacing,data:{sequenceNumber:this.frameIndex_,baseMediaDecodeTime:h,samples:g},stream:b}};goog.exportSymbol("shaka.transmuxer.TsTransmuxer",shaka.transmuxer.TsTransmuxer);
goog.exportProperty(shaka.transmuxer.TsTransmuxer.prototype,"transmux",shaka.transmuxer.TsTransmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.TsTransmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.TsTransmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.TsTransmuxer.prototype,"convertCodecs",shaka.transmuxer.TsTransmuxer.prototype.convertCodecs);goog.exportProperty(shaka.transmuxer.TsTransmuxer.prototype,"isSupported",shaka.transmuxer.TsTransmuxer.prototype.isSupported);
goog.exportProperty(shaka.transmuxer.TsTransmuxer.prototype,"destroy",shaka.transmuxer.TsTransmuxer.prototype.destroy);shaka.transmuxer.TsTransmuxer.SUPPORTED_AUDIO_CODECS_=["aac","ac-3","ec-3","mp3","opus"];shaka.transmuxer.TsTransmuxer.SUPPORTED_VIDEO_CODECS_=["avc","hevc"];shaka.transmuxer.TransmuxerEngine.registerTransmuxer("video/mp2t",function(){return new shaka.transmuxer.TsTransmuxer("video/mp2t")},shaka.transmuxer.TransmuxerEngine.PluginPriority.PREFERRED);shaka.util.FairPlayUtils=function(){shaka.drm.FairPlay.apply(this,arguments)};$jscomp.inherits(shaka.util.FairPlayUtils,shaka.drm.FairPlay);goog.exportSymbol("shaka.util.FairPlayUtils",shaka.util.FairPlayUtils);shaka.util.PeriodCombiner=function(){this.variants_=[];this.audioStreams_=[];this.videoStreams_=[];this.textStreams_=[];this.imageStreams_=[];this.useStreamOnce_=!1;this.usedPeriodIds_=new Set};
shaka.util.PeriodCombiner.prototype.release=function(){var a=this.audioStreams_.concat(this.videoStreams_,this.textStreams_,this.imageStreams_);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())b=b.value,b.segmentIndex&&b.segmentIndex.release();this.audioStreams_=[];this.videoStreams_=[];this.textStreams_=[];this.imageStreams_=[];this.variants_=[];this.useStreamOnce_=!1;this.usedPeriodIds_.clear()};shaka.util.PeriodCombiner.prototype.getVariants=function(){return this.variants_};
shaka.util.PeriodCombiner.prototype.getTextStreams=function(){return this.textStreams_.slice()};shaka.util.PeriodCombiner.prototype.getImageStreams=function(){return this.imageStreams_};
shaka.util.PeriodCombiner.prototype.deleteStream=function(a,b){if(a){var c=shaka.util.ManifestParserUtils.ContentType;if(a.type==c.AUDIO){c=(0,$jscomp.makeIterator)(this.audioStreams_);for(var d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a})}else if(a.type==c.VIDEO)for(c=(0,$jscomp.makeIterator)(this.videoStreams_),d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a}),d.trickModeVideo&&
(d.trickModeVideo.matchedStreams=d.trickModeVideo.matchedStreams.filter(function(e){return e!==a})),d.dependencyStream&&(d.dependencyStream.matchedStreams=d.dependencyStream.matchedStreams.filter(function(e){return e!==a}));else if(a.type==c.TEXT)for(c=(0,$jscomp.makeIterator)(this.textStreams_),d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a});else if(a.type==c.IMAGE)for(c=(0,$jscomp.makeIterator)(this.imageStreams_),d=c.next();!d.done;d=
c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a});a.segmentIndex&&a.closeSegmentIndex();this.usedPeriodIds_.delete(b)}};
shaka.util.PeriodCombiner.prototype.getStreamsPerPeriod_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.PeriodCombiner,e=[],f=[],g=[],h=[];a=(0,$jscomp.makeIterator)(a);for(var k=a.next();!k.done;k=a.next()){var l=k.value;k=new Map(l.audioStreams.map(function(q){return[d.generateAudioKey_(q),q]}));var m=new Map(l.videoStreams.map(function(q){return[d.generateVideoKey_(q),q]})),n=new Map(l.textStreams.map(function(q){return[d.generateTextKey_(q),q]}));l=new Map(l.imageStreams.map(function(q){return[d.generateImageKey_(q),
q]}));if(b){var p=d.dummyStream_(c.TEXT);n.set(d.generateTextKey_(p),p);p=d.dummyStream_(c.IMAGE);l.set(d.generateImageKey_(p),p)}e.push(k);f.push(m);g.push(n);h.push(l)}return{audioStreamsPerPeriod:e,videoStreamsPerPeriod:f,textStreamsPerPeriod:g,imageStreamsPerPeriod:h}};
shaka.util.PeriodCombiner.prototype.combinePeriods=function(a,b,c){c=c===void 0?!1:c;var d=this,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I,G,M,H,P;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Q){if(Q.nextAddress==1){e=shaka.util.ManifestParserUtils.ContentType;if(!b&&a.length==1)return f=d.getStreamsPerPeriod_(a,!1),g=f.audioStreamsPerPeriod,h=f.videoStreamsPerPeriod,k=f.textStreamsPerPeriod,l=f.imageStreamsPerPeriod,d.audioStreams_=Array.from(g[0].values()),d.videoStreams_=
Array.from(h[0].values()),d.textStreams_=Array.from(k[0].values()),d.imageStreams_=Array.from(l[0].values()),Q.jumpTo(2);m=c?d.usedPeriodIds_.size:0;n=-1;for(p=0;p<a.length;p++)q=a[p],d.usedPeriodIds_.has(q.id)||(d.usedPeriodIds_.add(q.id),n==-1&&(n=p));if(n==-1)return Q.return();r=d.getStreamsPerPeriod_(a,!0);t=r.audioStreamsPerPeriod;w=r.videoStreamsPerPeriod;v=r.textStreamsPerPeriod;u=r.imageStreamsPerPeriod;return Q.yield(Promise.all([d.combine_(d.audioStreams_,t,n,shaka.util.PeriodCombiner.cloneStream_,
shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.videoStreams_,w,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.textStreams_,v,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.imageStreams_,u,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m)]),2)}x=0;z=[];if(d.videoStreams_.length&&d.audioStreams_.length)for(F=(0,$jscomp.makeIterator)(d.audioStreams_),
L=F.next();!L.done;L=F.next())for(K=L.value,J=(0,$jscomp.makeIterator)(d.videoStreams_),I=J.next();!I.done;I=J.next())G=I.value,M=shaka.drm.DrmUtils.getCommonDrmInfos(K.drmInfos,G.drmInfos),K.drmInfos.length&&G.drmInfos.length&&!M.length?shaka.log.warning("Incompatible DRM in audio & video, skipping variant creation.",K,G):(H=(K.bandwidth||0)+(G.bandwidth||0),K.dependencyStream&&(H+=K.dependencyStream.bandwidth||0),G.dependencyStream&&(H+=G.dependencyStream.bandwidth||0),P=x++,z.push({id:P,language:K.language,
disabledUntilTime:0,primary:K.primary,audio:K,video:G,bandwidth:H,drmInfos:M,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]}));else for(B=d.videoStreams_.length?d.videoStreams_:d.audioStreams_,C=(0,$jscomp.makeIterator)(B),y=C.next();!y.done;y=C.next())A=y.value,D=x++,E=A.bandwidth||0,A.dependencyStream&&(E+=A.dependencyStream.bandwidth||0),z.push({id:D,language:A.language,disabledUntilTime:0,primary:A.primary,audio:A.type==e.AUDIO?A:null,video:A.type==e.VIDEO?A:null,bandwidth:E,drmInfos:A.drmInfos,
allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]});d.variants_=z;Q.jumpToEnd()})};
shaka.util.PeriodCombiner.combineDbStreams=function(a){var b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E,F,L,K,J,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.nextAddress){case 1:b=shaka.util.ManifestParserUtils.ContentType;c=shaka.util.PeriodCombiner;if(a.length==1)return G.return(a[0]);d=a.map(function(M){return new Map(M.filter(function(H){return H.type===b.AUDIO}).map(function(H){return[c.generateAudioKey_(H),H]}))});e=a.map(function(M){return new Map(M.filter(function(H){return H.type===
b.VIDEO}).map(function(H){return[c.generateVideoKey_(H),H]}))});f=a.map(function(M){return new Map(M.filter(function(H){return H.type===b.TEXT}).map(function(H){return[c.generateTextKey_(H),H]}))});g=a.map(function(M){return new Map(M.filter(function(H){return H.type===b.IMAGE}).map(function(H){return[c.generateImageKey_(H),H]}))});h=(0,$jscomp.makeIterator)(f);for(k=h.next();!k.done;k=h.next())l=k.value,m=c.dummyStreamDB_(b.TEXT),l.set(c.generateTextKey_(m),m);n=(0,$jscomp.makeIterator)(g);for(p=
n.next();!p.done;p=n.next())q=p.value,r=c.dummyStreamDB_(b.IMAGE),q.set(c.generateImageKey_(r),r);t=new shaka.util.PeriodCombiner;return G.yield(t.combine_([],d,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),2);case 2:return w=G.yieldResult,G.yield(t.combine_([],e,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),3);case 3:return v=G.yieldResult,G.yield(t.combine_([],f,0,shaka.util.PeriodCombiner.cloneStreamDB_,
shaka.util.PeriodCombiner.concatenateStreamDBs_,0),4);case 4:return u=G.yieldResult,G.yield(t.combine_([],g,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),5);case 5:x=G.yieldResult;z=0;if(v.length&&w.length)for(D=(0,$jscomp.makeIterator)(w),E=D.next();!E.done;E=D.next())for(F=E.value,L=(0,$jscomp.makeIterator)(v),K=L.next();!K.done;K=L.next())J=K.value,I=z++,J.variantIds.push(I),F.variantIds.push(I);else for(B=v.concat(w),C=(0,$jscomp.makeIterator)(B),
y=C.next();!y.done;y=C.next())A=y.value,A.variantIds=[z++];return G.return(v.concat(w).concat(u).concat(x))}})};
shaka.util.PeriodCombiner.prototype.combine_=function(a,b,c,d,e,f){var g=this,h,k,l,m,n,p,q,r,t,w,v,u,x,z,B,C,y,A,D,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(F){switch(F.nextAddress){case 1:h=[];for(k=0;k<b.length;k++)k>=c?h.push(new Set(b[k].values())):h.push(new Set);l=(0,$jscomp.makeIterator)(a);m=l.next();case 2:if(m.done){F.jumpTo(4);break}n=m.value;return F.yield(g.extendExistingOutputStream_(n,b,c,e,h,f),5);case 5:p=F.yieldResult;if(!p)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.PERIOD_FLATTENING_FAILED);m=l.next();F.jumpTo(2);break;case 4:q=(0,$jscomp.makeIterator)(h);for(r=q.next();!r.done;r=q.next())for(t=r.value,w=(0,$jscomp.makeIterator)(t),v=w.next();!v.done;v=w.next())u=v.value,(x=g.createNewOutputStream_(a,u,b,d,e,h))&&a.push(x);z=(0,$jscomp.makeIterator)(h);for(B=z.next();!B.done;B=z.next())for(C=B.value,y=(0,$jscomp.makeIterator)(C),A=y.next(),D={};!A.done;D={stream$jscomp$131:void 0},A=y.next())if(D.stream$jscomp$131=
A.value,!shaka.util.PeriodCombiner.isDummy_(D.stream$jscomp$131)&&(E=a.some(function(L){return function(K){return g.areAVStreamsCompatible_(L.stream$jscomp$131,K)}}(D))))throw shaka.log.error("Unused stream in period-flattening!",D.stream$jscomp$131,a),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.PERIOD_FLATTENING_FAILED);return F.return(a)}})};
shaka.util.PeriodCombiner.prototype.extendExistingOutputStream_=function(a,b,c,d,e,f){var g=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.nextAddress==1)return g.findMatchesInAllPeriods_(b,a,f>0),goog.asserts.assert(a.createSegmentIndex,"outputStream should be a Stream type!"),a.matchedStreams?a.segmentIndex?h.yield(shaka.util.PeriodCombiner.extendOutputSegmentIndex_(a,c+f),2):h.jumpTo(2):(shaka.log.error("No matches extending output stream!",a,b),h.return(!1));shaka.util.PeriodCombiner.extendOutputStream_(a,
c,d,e,f);return h.return(!0)})};
shaka.util.PeriodCombiner.extendOutputSegmentIndex_=function(a,b){var c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.nextAddress==1){c=[];d=a.matchedStreams;goog.asserts.assert(d,"matched streams should be valid");for(e=b;e<d.length;e++)f=d[e],c.push(f.createSegmentIndex()),f.trickModeVideo&&!f.trickModeVideo.segmentIndex&&c.push(f.trickModeVideo.createSegmentIndex()),f.dependencyStream&&!f.dependencyStream.segmentIndex&&c.push(f.dependencyStream.createSegmentIndex());return k.yield(Promise.all(c),
2)}if(a.segmentIndex instanceof shaka.media.MetaSegmentIndex)for(g=b;g<d.length;g++)h=d[g],goog.asserts.assert(h.segmentIndex,"stream should have a segmentIndex."),h.segmentIndex&&a.segmentIndex.appendSegmentIndex(h.segmentIndex);k.jumpToEnd()})};
shaka.util.PeriodCombiner.prototype.createNewOutputStream_=function(a,b,c,d,e,f){if(shaka.util.PeriodCombiner.isDummy_(b))return null;var g=d(b);this.findMatchesInAllPeriods_(c,g);g.createSegmentIndex&&(g.createSegmentIndex=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(g.segmentIndex)return h.jumpTo(0);g.segmentIndex=new shaka.media.MetaSegmentIndex;return h.yield(shaka.util.PeriodCombiner.extendOutputSegmentIndex_(g,0),0)})},g.closeSegmentIndex=function(){g.segmentIndex&&
(g.segmentIndex.release(),g.segmentIndex=null);if(g.matchedStreams)for(var h=(0,$jscomp.makeIterator)(g.matchedStreams),k=h.next();!k.done;k=h.next())k=k.value,k.segmentIndex&&!shaka.util.PeriodCombiner.isStreamActivelyUsed_(k,g,a)&&(k.segmentIndex.release(),k.segmentIndex=null)});if(!g.matchedStreams||!g.matchedStreams.length)return null;shaka.util.PeriodCombiner.extendOutputStream_(g,0,e,f,0);return g};
shaka.util.PeriodCombiner.extendOutputStream_=function(a,b,c,d,e){var f=shaka.util.ManifestParserUtils.ContentType,g=shaka.util.LanguageUtils,h=a.matchedStreams;goog.asserts.assert(a.matchedStreams,"matchedStreams should be non-null");for(b+=e;b<h.length;b++){var k=h[b];c(a,k);var l=!0;a.type==f.AUDIO&&g.relatedness(a.language,k.language)==0&&(l=!1);if(l&&((l=d[b-e])&&l.delete(k),k.fullMimeTypes))for(k=(0,$jscomp.makeIterator)(k.fullMimeTypes.values()),l=k.next();!l.done;l=k.next())a.fullMimeTypes.add(l.value)}};
shaka.util.PeriodCombiner.cloneStream_=function(a){var b=Object.assign({},a);b.originalId=null;b.createSegmentIndex=function(){return Promise.resolve()};b.closeSegmentIndex=function(){};b.roles=b.roles.slice();b.segmentIndex=null;b.emsgSchemeIdUris=[];b.keyIds=new Set(a.keyIds);b.closedCaptions=a.closedCaptions?new Map(a.closedCaptions):null;b.trickModeVideo=null;b.dependencyStream=null;return b};
shaka.util.PeriodCombiner.cloneStreamDB_=function(a){var b=Object.assign({},a);b.roles=b.roles.slice();b.keyIds=new Set(a.keyIds);b.segments=[];b.variantIds=[];b.closedCaptions=a.closedCaptions?new Map(a.closedCaptions):null;return b};
shaka.util.PeriodCombiner.concatenateStreams_=function(a,b){var c=function(f,g){f||(f=[]);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,f.includes(h)||f.push(h);return f};a.roles=c(a.roles,b.roles);b.emsgSchemeIdUris&&(a.emsgSchemeIdUris=c(a.emsgSchemeIdUris,b.emsgSchemeIdUris));c=(0,$jscomp.makeIterator)(b.keyIds);for(var d=c.next();!d.done;d=c.next())a.keyIds.add(d.value);a.originalId==null?a.originalId=b.originalId:(c=b.originalId||"")&&!a.originalId.endsWith(c)&&
(a.originalId+=","+c);c=shaka.drm.DrmUtils.getCommonDrmInfos(a.drmInfos,b.drmInfos);if(b.drmInfos.length&&a.drmInfos.length&&!c.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.INCONSISTENT_DRM_ACROSS_PERIODS);a.drmInfos=c;a.encrypted=a.encrypted||b.encrypted;if(b.closedCaptions)for(a.closedCaptions||(a.closedCaptions=new Map),c=(0,$jscomp.makeIterator)(b.closedCaptions),d=c.next();!d.done;d=c.next()){var e=(0,$jscomp.makeIterator)(d.value);
d=e.next().value;e=e.next().value;a.closedCaptions.set(d,e)}a.bandwidth&&b.bandwidth&&(a.bandwidth=Math.max(a.bandwidth,b.bandwidth));b.trickModeVideo?(a.trickModeVideo||(a.trickModeVideo=shaka.util.PeriodCombiner.cloneStream_(b.trickModeVideo),a.trickModeVideo.matchedStreams=[],a.trickModeVideo.createSegmentIndex=function(){if(a.trickModeVideo.segmentIndex)return Promise.resolve();var f=new shaka.media.MetaSegmentIndex;goog.asserts.assert(a.trickModeVideo.matchedStreams,"trickmode matched streams should exist");
for(var g=(0,$jscomp.makeIterator)(a.trickModeVideo.matchedStreams),h=g.next();!h.done;h=g.next())h=h.value,goog.asserts.assert(h.segmentIndex,"trickmode segment index should exist"),f.appendSegmentIndex(h.segmentIndex);a.trickModeVideo.segmentIndex=f;return Promise.resolve()}),a.trickModeVideo.matchedStreams.push(b.trickModeVideo),shaka.util.PeriodCombiner.concatenateStreams_(a.trickModeVideo,b.trickModeVideo)):a.trickModeVideo&&(a.trickModeVideo.matchedStreams.push(b),shaka.util.PeriodCombiner.concatenateStreams_(a.trickModeVideo,
b));b.dependencyStream?(a.dependencyStream||(a.dependencyStream=shaka.util.PeriodCombiner.cloneStream_(b.dependencyStream),a.dependencyStream.matchedStreams=[],a.dependencyStream.createSegmentIndex=function(){if(a.dependencyStream.segmentIndex)return Promise.resolve();var f=new shaka.media.MetaSegmentIndex;goog.asserts.assert(a.dependencyStream.matchedStreams,"dependency video matched streams should exist");for(var g=(0,$jscomp.makeIterator)(a.dependencyStream.matchedStreams),h=g.next();!h.done;h=
g.next())h=h.value,goog.asserts.assert(h.segmentIndex,"dependency video segment index should exist"),f.appendSegmentIndex(h.segmentIndex);a.dependencyStream.segmentIndex=f;return Promise.resolve()}),a.dependencyStream.matchedStreams.push(b.dependencyStream),shaka.util.PeriodCombiner.concatenateStreams_(a.dependencyStream,b.dependencyStream)):a.dependencyStream&&(a.dependencyStream.matchedStreams.push(b),shaka.util.PeriodCombiner.concatenateStreams_(a.dependencyStream,b))};
shaka.util.PeriodCombiner.concatenateStreamDBs_=function(a,b){var c=a.roles;c||(c=[]);for(var d=(0,$jscomp.makeIterator)(b.roles),e=d.next();!e.done;e=d.next())e=e.value,c.includes(e)||c.push(e);a.roles=c;c=(0,$jscomp.makeIterator)(b.keyIds);for(d=c.next();!d.done;d=c.next())a.keyIds.add(d.value);a.encrypted=a.encrypted&&b.encrypted;a.segments.push.apply(a.segments,(0,$jscomp.arrayFromIterable)(b.segments));if(b.closedCaptions)for(a.closedCaptions||(a.closedCaptions=new Map),b=(0,$jscomp.makeIterator)(b.closedCaptions),
c=b.next();!c.done;c=b.next())d=(0,$jscomp.makeIterator)(c.value),c=d.next().value,d=d.next().value,a.closedCaptions.set(c,d)};shaka.util.PeriodCombiner.prototype.findMatchesInAllPeriods_=function(a,b,c){c=(c===void 0?0:c)?b.matchedStreams:[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=this.findBestMatchInPeriod_(d.value,b);if(!d)return;c.push(d)}b.matchedStreams=c};
shaka.util.PeriodCombiner.prototype.findBestMatchInPeriod_=function(a,b){var c=this,d={audio:shaka.util.PeriodCombiner.generateAudioKey_,video:shaka.util.PeriodCombiner.generateVideoKey_,text:shaka.util.PeriodCombiner.generateTextKey_,image:shaka.util.PeriodCombiner.generateImageKey_}[b.type],e=null,f=d(b);if(a.has(f))e=a.get(f);else{f={audio:function(l,m){return c.areAVStreamsCompatible_(l,m)},video:function(l,m){return c.areAVStreamsCompatible_(l,m)},text:shaka.util.PeriodCombiner.areTextStreamsCompatible_,
image:shaka.util.PeriodCombiner.areImageStreamsCompatible_}[b.type];for(var g={audio:shaka.util.PeriodCombiner.isAudioStreamBetterMatch_,video:shaka.util.PeriodCombiner.isVideoStreamBetterMatch_,text:shaka.util.PeriodCombiner.isTextStreamBetterMatch_,image:shaka.util.PeriodCombiner.isImageStreamBetterMatch_}[b.type],h=(0,$jscomp.makeIterator)(a.values()),k=h.next();!k.done;k=h.next())k=k.value,!f(b,k)||b.fastSwitching!=k.fastSwitching||e&&!g(b,e,k)||(e=k)}this.useStreamOnce_&&!shaka.util.PeriodCombiner.isDummy_(e)&&
a.delete(d(e));return e};shaka.util.PeriodCombiner.areAVStreamsExactMatch_=function(a,b){return a.mimeType===b.mimeType&&a.codecs===b.codecs};shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_=function(a,b){return a.mimeType!=b.mimeType?!1:shaka.util.PeriodCombiner.getCodec_(a.codecs)===shaka.util.PeriodCombiner.getCodec_(b.codecs)};shaka.util.PeriodCombiner.prototype.setUseStreamOnce=function(a){this.useStreamOnce_=a};
shaka.util.PeriodCombiner.prototype.areAVStreamsCompatible_=function(a,b){return a.drmInfos&&!shaka.drm.DrmUtils.areDrmCompatible(a.drmInfos,b.drmInfos)?!1:!0};shaka.util.PeriodCombiner.areTextStreamsCompatible_=function(a,b){return b.language?a.forced!==b.forced||shaka.util.LanguageUtils.relatedness(a.language,b.language)==0||b.kind!=a.kind?!1:!0:!0};shaka.util.PeriodCombiner.areImageStreamsCompatible_=function(a,b){return!0};
shaka.util.PeriodCombiner.isAudioStreamBetterMatch_=function(a,b,c){var d=shaka.util.LanguageUtils,e=shaka.util.PeriodCombiner.BetterOrWorse,f=e.BETTER;e=e.WORSE;var g=shaka.util.PeriodCombiner.compareCodecs_(a,b,c);if(g===f)return!0;if(g===e)return!1;g=d.relatedness(a.language,b.language);d=d.relatedness(a.language,c.language);if(d>g)return!0;if(d<g)return!1;if(b.label!==c.label){if(a.label===b.label)return!1;if(a.label===c.label)return!0}if(a.roles.length){d=b.roles.filter(function(h){return a.roles.includes(h)});
g=c.roles.filter(function(h){return a.roles.includes(h)});if(g.length>d.length)return!0;if(g.length<d.length)return!1;if(c.roles.length!==b.roles.length)return c.roles.length<b.roles.length}else{if(!c.roles.length&&b.roles.length)return!0;if(c.roles.length&&!b.roles.length)return!1}if(!b.primary&&c.primary)return!0;if(b.primary&&!c.primary)return!1;d=shaka.util.PeriodCombiner.compareClosestPreferLower(a.channelsCount,b.channelsCount,c.channelsCount);if(d==f)return!0;if(d==e)return!1;d=shaka.util.PeriodCombiner.compareClosestPreferLower(a.audioSamplingRate,
b.audioSamplingRate,c.audioSamplingRate);return d==f?!0:d==e?!1:a.bandwidth&&shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_(a.bandwidth,b.bandwidth,c.bandwidth)==f?!0:!1};
shaka.util.PeriodCombiner.isVideoStreamBetterMatch_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER;d=d.WORSE;var f=shaka.util.PeriodCombiner.compareCodecs_(a,b,c);if(f===e)return!0;if(f===d)return!1;f=shaka.util.PeriodCombiner.compareClosestPreferLower(a.width*a.height,b.width*b.height,c.width*c.height);if(f==e)return!0;if(f==d)return!1;if(a.frameRate){f=shaka.util.PeriodCombiner.compareClosestPreferLower(a.frameRate,b.frameRate,c.frameRate);if(f==e)return!0;if(f==d)return!1}return a.bandwidth&&
shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_(a.bandwidth,b.bandwidth,c.bandwidth)==e?!0:!1};
shaka.util.PeriodCombiner.isTextStreamBetterMatch_=function(a,b,c){var d=shaka.util.LanguageUtils,e=d.relatedness(a.language,b.language);d=d.relatedness(a.language,c.language);if(d>e)return!0;if(d<e)return!1;if(!b.primary&&c.primary)return!0;if(b.primary&&!c.primary)return!1;if(b.label!==c.label){if(a.label===b.label)return!1;if(a.label===c.label)return!0}if(a.roles.length){e=b.roles.filter(function(f){return a.roles.includes(f)});d=c.roles.filter(function(f){return a.roles.includes(f)});if(d.length>
e.length)return!0;if(d.length<e.length)return!1}else{if(!c.roles.length&&b.roles.length)return!0;if(c.roles.length&&!b.roles.length)return!1}return c.mimeType!=a.mimeType||c.codecs!=a.codecs||b.mimeType==a.mimeType&&b.codecs==a.codecs?!1:!0};shaka.util.PeriodCombiner.isImageStreamBetterMatch_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse.BETTER;return shaka.util.PeriodCombiner.compareClosestPreferLower(a.width*a.height,b.width*b.height,c.width*c.height)==d?!0:!1};
shaka.util.PeriodCombiner.dummyStreamDB_=function(a){return{id:0,originalId:"",groupId:null,primary:!1,type:a,mimeType:"",codecs:"",language:"",originalLanguage:null,label:null,width:null,height:null,encrypted:!1,keyIds:new Set,segments:[],variantIds:[],roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,external:!1,fastSwitching:!1,isAudioMuxedInVideo:!1,baseOriginalId:null}};
shaka.util.PeriodCombiner.dummyStream_=function(a){return{id:0,originalId:"",groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex([]),mimeType:"",codecs:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:"",originalLanguage:null,label:null,type:a,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,
external:!1,fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null}};shaka.util.PeriodCombiner.compareClosestPreferLower=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.WORSE;if(b==a&&a!=c)return f;if(c==a&&a!=b)return e;if(b>a){if(c<=a||c-a<b-a)return e;if(c-a>b-a)return f}else{if(c>a)return f;if(a-c<a-b)return e;if(a-c>a-b)return f}return d.EQUAL};
shaka.util.PeriodCombiner.compareCodecs_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.EQUAL;d=d.WORSE;var g=shaka.util.PeriodCombiner.areAVStreamsExactMatch_(a,b),h=shaka.util.PeriodCombiner.areAVStreamsExactMatch_(a,c);if(g&&!h)return d;if(!g&&h)return e;b=shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_(a,b);a=shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_(a,c);return b&&!a?d:!b&&a?e:f};
shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.WORSE;b=Math.abs(a-b);a=Math.abs(a-c);return a<b?e:b<a?f:d.EQUAL};shaka.util.PeriodCombiner.isDummy_=function(a){var b=shaka.util.ManifestParserUtils.ContentType;switch(a.type){case b.TEXT:return!a.language;case b.IMAGE:return!a.tilesLayout;default:return!1}};
shaka.util.PeriodCombiner.generateVideoKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.fastSwitching,a.width,a.frameRate,a.codecs,a.mimeType,a.label,a.roles,a.closedCaptions?Array.from(a.closedCaptions.entries()):null,a.bandwidth,a.dependencyStream?a.dependencyStream.baseOriginalId:null,Array.from(a.keyIds)])};
shaka.util.PeriodCombiner.generateAudioKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.fastSwitching,a.channelsCount,a.language,a.bandwidth,a.label,a.codecs,a.mimeType,a.roles,a.audioSamplingRate,a.primary,a.dependencyStream?a.dependencyStream.baseOriginalId:null,Array.from(a.keyIds)])};shaka.util.PeriodCombiner.generateTextKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.language,a.label,a.codecs,a.mimeType,a.bandwidth,a.roles])};
shaka.util.PeriodCombiner.generateImageKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.width,a.codecs,a.mimeType])};shaka.util.PeriodCombiner.generateKey_=function(a){return JSON.stringify(a)};shaka.util.PeriodCombiner.getCodec_=function(a){if(!shaka.util.PeriodCombiner.memoizedCodecs.has(a)){var b=shaka.util.MimeUtils.getNormalizedCodec(a);shaka.util.PeriodCombiner.memoizedCodecs.set(a,b)}return shaka.util.PeriodCombiner.memoizedCodecs.get(a)};
shaka.util.PeriodCombiner.isStreamActivelyUsed_=function(a,b,c){c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next())if(d=d.value,d!==b&&d.segmentIndex&&d.matchedStreams&&d.matchedStreams.includes(a))return shaka.log.v2("Stream "+a.id+" is already used in output stream "+(d.id+", cannot close it now.")),!0;shaka.log.v2("Stream "+a.id+" not used anywhere else besides "+(b.id+", good to close."));return!1};goog.exportSymbol("shaka.util.PeriodCombiner",shaka.util.PeriodCombiner);
goog.exportProperty(shaka.util.PeriodCombiner.prototype,"setUseStreamOnce",shaka.util.PeriodCombiner.prototype.setUseStreamOnce);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"combinePeriods",shaka.util.PeriodCombiner.prototype.combinePeriods);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"deleteStream",shaka.util.PeriodCombiner.prototype.deleteStream);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getImageStreams",shaka.util.PeriodCombiner.prototype.getImageStreams);
goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getTextStreams",shaka.util.PeriodCombiner.prototype.getTextStreams);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getVariants",shaka.util.PeriodCombiner.prototype.getVariants);shaka.util.PeriodCombiner.BetterOrWorse={BETTER:1,EQUAL:0,WORSE:-1};shaka.util.PeriodCombiner.memoizedCodecs=new Map;shaka.util.XmlUtils=function(){};
shaka.util.XmlUtils.parseXmlString=function(a,b){var c=new DOMParser,d=shaka.util.XmlUtils.trustedHTMLFromString_.value()(a);a=null;try{a=c.parseFromString(d,"text/xml")}catch(e){return shaka.log.error("XML parsing exception:",e),null}goog.asserts.assert(a,"Parsed XML document cannot be null!");c=a.documentElement;if(!c)return shaka.log.error("XML document was empty!"),null;d=c.getElementsByTagName("parsererror");if(d.length)return shaka.log.error("XML parser error found:",d[0]),null;if(c.tagName!=
b)return shaka.log.error('XML tag name does not match expected "'+b+'":',c.tagName),null;if(!("createNodeIterator"in document))return c;for(b=document.createNodeIterator(a,NodeFilter.SHOW_ALL);a=b.nextNode();)if(a instanceof HTMLElement||a instanceof SVGElement)return shaka.log.error("XML document embeds unsafe content!"),null;return c};
shaka.util.XmlUtils.parseXml=function(a,b){try{var c=shaka.util.StringUtils.fromBytesAutoDetect(a);return shaka.util.XmlUtils.parseXmlString(c,b)}catch(d){return shaka.log.error("parseXmlString threw!",d),null}};shaka.util.XmlUtils.toArrayBuffer=function(a){return shaka.util.StringUtils.toUTF8(a.outerHTML)};
shaka.util.XmlUtils.trustedHTMLFromString_=new shaka.util.Lazy(function(){if(typeof trustedTypes!=="undefined"){var a=trustedTypes.createPolicy("shaka-player#xml",{createHTML:function(b){return b}});return function(b){return a.createHTML(b)}}return function(b){return b}});}).call(exportTo,innerGlobal,innerGlobal,undefined);if(typeof exports!="undefined")for(var k in exportTo.shaka)exports[k]=exportTo.shaka[k];else if(typeof define=="function"&&define.amd)define(function(){return exportTo.shaka});else innerGlobal.shaka=exportTo.shaka})();

//# sourceMappingURL=shaka-player.hls.debug.map