/*
 @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.TYPED_ARRAY_CLASSES=function(){var a="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");$jscomp.global.BigInt64Array&&(a.push("BigInt64"),a.push("BigUint64"));return a}();$jscomp.polyfillTypedArrayMethod=function(a,b,c,d){if(b)for(var e=0;e<$jscomp.TYPED_ARRAY_CLASSES.length;e++){var f=$jscomp.TYPED_ARRAY_CLASSES[e]+"Array.prototype."+a;$jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(f,b,c,d):$jscomp.polyfillUnisolated(f,b,c,d)}};
$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.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.getNextAddressJsc=function(){return this.nextAddress};$jscomp.generator.Context.prototype.getNextAddressJsc=function(){return this.nextAddress};
$jscomp.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult};$jscomp.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult};$jscomp.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype["return"]=$jscomp.generator.Context.prototype.return;
$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks;$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};$jscomp.generator.Context.prototype.yield=$jscomp.generator.Context.prototype.yield;
$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.yieldAll=$jscomp.generator.Context.prototype.yieldAll;$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpTo=$jscomp.generator.Context.prototype.jumpTo;
$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};$jscomp.generator.Context.prototype.jumpToEnd=$jscomp.generator.Context.prototype.jumpToEnd;$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;b!=void 0&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setCatchFinallyBlocks=$jscomp.generator.Context.prototype.setCatchFinallyBlocks;
$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.setFinallyBlock=$jscomp.generator.Context.prototype.setFinallyBlock;$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};$jscomp.generator.Context.prototype.leaveTryBlock=$jscomp.generator.Context.prototype.leaveTryBlock;
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterCatchBlock=$jscomp.generator.Context.prototype.enterCatchBlock;$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.enterFinallyBlock=$jscomp.generator.Context.prototype.enterFinallyBlock;$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.leaveFinallyBlock=$jscomp.generator.Context.prototype.leaveFinallyBlock;$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};$jscomp.generator.Context.prototype.forIn=$jscomp.generator.Context.prototype.forIn;$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.Context.PropertyIterator.prototype.getNext=$jscomp.generator.Context.PropertyIterator.prototype.getNext;$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.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");$jscomp.defineProperty(Array.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.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.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.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b){return b})}},"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.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.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.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.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.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.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.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("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.toObject=function(a){if(a==null)throw new TypeError("No nullish arg");return Object(a)};$jscomp.assign=$jscomp.ASSUME_ES6||$jscomp.TRUST_ES6_POLYFILLS&&typeof Object.assign=="function"?Object.assign:function(a,b){a=$jscomp.toObject(a);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("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("Array.prototype.entries",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b,c){return[b,c]})}},"es6","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.clz32",function(a){return a?a:function(b){b=Number(b)>>>0;if(b===0)return 32;var c=0;(b&4294901760)===0&&(b<<=16,c+=16);(b&4278190080)===0&&(b<<=8,c+=8);(b&4026531840)===0&&(b<<=4,c+=4);(b&3221225472)===0&&(b<<=2,c+=2);(b&2147483648)===0&&c++;return 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("Object.values",function(a){return a?a:function(b){var c=[],d;for(d in b)$jscomp.owns(b,d)&&c.push(b[d]);return c}},"es8","es3");$jscomp.polyfill("Math.log2",function(a){return a?a:function(b){return Math.log(b)/Math.LN2}},"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");$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.atMethod=function(a){a=Math.trunc(a)||0;a<0&&(a+=this.length);if(!(a<0||a>=this.length))return this[a]};$jscomp.polyfill("Array.prototype.at",function(a){return a?a:$jscomp.atMethod},"es_next","es5");$jscomp.typedArrayAt=function(a){return a?a:$jscomp.atMethod};$jscomp.polyfillTypedArrayMethod("at",$jscomp.typedArrayAt,"es_next","es5");$jscomp.polyfill("String.prototype.at",function(a){return a?a:$jscomp.atMethod},"es_next","es5");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={util:{}};
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.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.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.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.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};/*
 @license
 Copyright 2006 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_)};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.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};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,d){d=new Set(d);d=[].concat((0,$jscomp.arrayFromIterable)(d)).sort().join("#");return a+"#"+b+"#"+c+"#"+d};shaka.drm.DrmUtils.hasMediaKeySystemAccess=function(a,b,c,d){var e=shaka.drm.DrmUtils;a=e.generateKeySystemCacheKey_(a,b,c,d);return e.memoizedMediaKeySystemAccessRequests_.has(a)};
shaka.drm.DrmUtils.getMediaKeySystemAccess=function(a,b,c,d){var e=shaka.drm.DrmUtils;a=e.generateKeySystemCacheKey_(a,b,c,d);return e.memoizedMediaKeySystemAccessRequests_.get(a)||null};shaka.drm.DrmUtils.setMediaKeySystemAccess=function(a,b,c,d,e){var f=shaka.drm.DrmUtils;a=f.generateKeySystemCacheKey_(a,b,c,d);f.memoizedMediaKeySystemAccessRequests_.set(a,e)};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.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.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.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.BufferUtils.toUint8(a);return Uint8Array.prototype.toBase64?a.toBase64({alphabet:"base64",omitPadding:!1}):(a=shaka.util.StringUtils.fromCharCode(a),btoa(a))};
shaka.util.Uint8ArrayUtils.toBase64=function(a,b){b=b==void 0?!0:b;return Uint8Array.prototype.toBase64?shaka.util.BufferUtils.toUint8(a).toBase64({alphabet:"base64url",omitPadding:!b}):(a=shaka.util.Uint8ArrayUtils.toStandardBase64(a).replace(/\+/g,"-").replace(/\//g,"_"),b?a:a.replace(/[=]*$/,""))};
shaka.util.Uint8ArrayUtils.fromBase64=function(a){if(!("fromBase64"in Uint8Array)){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}a=a.replace(/\s+/g,"");b=/[-_]/.test(a);return Uint8Array.fromBase64(a,{alphabet:b?"base64url":"base64"})};shaka.util.Uint8ArrayUtils.fromHex=function(a){if(!("fromHex"in Uint8Array)){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}return Uint8Array.fromHex(a)};
shaka.util.Uint8ArrayUtils.toHex=function(a){var b=shaka.util.BufferUtils.toUint8(a);if(!Uint8Array.prototype.toHex){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}return b.toHex()};shaka.util.Uint8ArrayUtils.concat=function(){var a=$jscomp.getRestArguments.apply(0,arguments);return shaka.util.Uint8ArrayUtils.concatRange(a,0,a.length)};
shaka.util.Uint8ArrayUtils.concatRange=function(a,b,c){b=b===void 0?0:b;c=c===void 0?a.length:c;for(var d=shaka.util.BufferUtils,e=0,f=b;f<c;++f)e+=a[f].byteLength;e=new Uint8Array(e);for(f=0;b<c;++b){var g=a[b];ArrayBuffer.isView(g)&&g.BYTES_PER_ELEMENT===1?e.set(g,f):e.set(d.toUint8(g),f);f+=g.byteLength}return e};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,e){b={keySystem:a,encryptionScheme:b,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",sessionType:"",initData:c||[],keyIds:new Set,mediaTypes:e};d&&(b.keySystemUris=new Set([d]));!c&&shaka.drm.DrmUtils.isFairPlayKeySystem(a)&&b.initData.push({initDataType:"sinf",initData:new Uint8Array(0),keyId:null});return b};
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/,/^mp2v/,/^dvh/,/^dva/,/^dav/];shaka.util.ManifestParserUtils.AUDIO_CODEC_REGEXPS=[/^vorbis$/,/^Opus$/,/^opus$/,/^fLaC$/,/^flac$/,/^mp4a/,/^[ae]c-3$/,/^ac-4/,/^dts[cehx]?$/,/^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.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.ui={};shaka.ui.Localization=function(a){shaka.util.FakeEventTarget.call(this);this.fallbackLocale_=shaka.util.LanguageUtils.normalize(a);this.currentMap_=new Map;this.currentLocales_=new Set;this.localizations_=new Map};$jscomp.inherits(shaka.ui.Localization,shaka.util.FakeEventTarget);shaka.ui.Localization.prototype.release=function(){shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.ui.Localization.prototype.changeLocale=function(a){var b=this,c=shaka.ui.Localization;this.currentLocales_.clear();a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())this.currentLocales_.add(shaka.util.LanguageUtils.normalize(d.value));this.updateCurrentMap_();a=shaka.util.Iterables.filter(this.currentLocales_,function(e){return!b.localizations_.has(e)});a.length&&this.dispatchEvent(new shaka.util.FakeEvent(c.UNKNOWN_LOCALES,(new Map).set("locales",a)));a=shaka.util.Iterables.filter(this.currentLocales_,
function(e){return b.localizations_.has(e)});a=(new Map).set("locales",a.length?a:[this.fallbackLocale_]);this.dispatchEvent(new shaka.util.FakeEvent(c.LOCALE_CHANGED,a))};
shaka.ui.Localization.prototype.insert=function(a,b,c){var d=shaka.ui.Localization,e=shaka.ui.Localization.ConflictResolution,f=shaka.util.FakeEvent;a=shaka.util.LanguageUtils.normalize(a);c===void 0&&(c=e.USE_NEW);var g=this.localizations_.get(a)||new Map;b.forEach(function(h,k){g.has(k)&&c!=e.USE_NEW||g.set(k,h)});this.localizations_.set(a,g);this.updateCurrentMap_();this.dispatchEvent(new f(d.LOCALE_UPDATED));return this};
shaka.ui.Localization.prototype.resolveDictionary=function(a){for(var b=(0,$jscomp.makeIterator)(a.keys()),c=b.next();!c.done;c=b.next())c=c.value,a.set(c,this.resolve(c))};shaka.ui.Localization.prototype.resolve=function(a){var b=shaka.ui.Localization,c=shaka.util.FakeEvent,d=this.currentMap_.get(a);if(d)return d;a=(new Map).set("locales",Array.from(this.currentLocales_)).set("missing",a);this.dispatchEvent(new c(b.UNKNOWN_LOCALIZATION,a));return""};
shaka.ui.Localization.prototype.getCurrentLocales=function(){return this.currentLocales_};
shaka.ui.Localization.prototype.updateCurrentMap_=function(){for(var a=this,b=shaka.util.LanguageUtils,c=this.localizations_,d=this.fallbackLocale_,e=this.currentLocales_,f=new Set,g=(0,$jscomp.makeIterator)(e),h=g.next(),k={};!h.done;k={locale$jscomp$10:void 0},h=g.next()){k.locale$jscomp$10=h.value;f.add(k.locale$jscomp$10);f.add(b.getBase(k.locale$jscomp$10));h=shaka.util.Iterables.filter(c.keys(),function(m){return function(n){return b.areSiblings(n,m.locale$jscomp$10)}}(k));h.sort();h=(0,$jscomp.makeIterator)(h);
for(var l=h.next();!l.done;l=h.next())f.add(l.value);k=shaka.util.Iterables.filter(c.keys(),function(m){return function(n){return b.getBase(n)==m.locale$jscomp$10}}(k));k.sort();k=(0,$jscomp.makeIterator)(k);for(h=k.next();!h.done;h=k.next())f.add(h.value)}f.add(d);d=[];f=(0,$jscomp.makeIterator)(f);for(g=f.next();!g.done;g=f.next())(g=c.get(g.value))&&d.push(g);d.reverse();this.currentMap_.clear();c=(0,$jscomp.makeIterator)(d);for(f=c.next();!f.done;f=c.next())f.value.forEach(function(m,n){a.currentMap_.set(n,
m)});c=this.currentMap_.keys();f=new Set;d=(0,$jscomp.makeIterator)(this.currentLocales_);for(g=d.next();!g.done;g=d.next())g=this.localizations_.get(g.value)||new Map,shaka.ui.Localization.findMissingKeys_(g,c,f);f.size>0&&(e=(new Map).set("locales",Array.from(e)).set("missing",Array.from(f)),this.dispatchEvent(new shaka.util.FakeEvent(shaka.ui.Localization.MISSING_LOCALIZATIONS,e)))};
shaka.ui.Localization.findMissingKeys_=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())d=d.value,a.get(d)||c.add(d)};goog.exportSymbol("shaka.ui.Localization",shaka.ui.Localization);goog.exportProperty(shaka.ui.Localization.prototype,"getCurrentLocales",shaka.ui.Localization.prototype.getCurrentLocales);goog.exportProperty(shaka.ui.Localization.prototype,"resolve",shaka.ui.Localization.prototype.resolve);
goog.exportProperty(shaka.ui.Localization.prototype,"resolveDictionary",shaka.ui.Localization.prototype.resolveDictionary);goog.exportProperty(shaka.ui.Localization.prototype,"insert",shaka.ui.Localization.prototype.insert);goog.exportProperty(shaka.ui.Localization.prototype,"changeLocale",shaka.ui.Localization.prototype.changeLocale);goog.exportProperty(shaka.ui.Localization.prototype,"release",shaka.ui.Localization.prototype.release);shaka.ui.Localization.ConflictResolution={USE_OLD:0,USE_NEW:1};
goog.exportProperty(shaka.ui.Localization,"ConflictResolution",shaka.ui.Localization.ConflictResolution);shaka.ui.Localization.UNKNOWN_LOCALES="unknown-locales";goog.exportProperty(shaka.ui.Localization,"UNKNOWN_LOCALES",shaka.ui.Localization.UNKNOWN_LOCALES);shaka.ui.Localization.UNKNOWN_LOCALIZATION="unknown-localization";goog.exportProperty(shaka.ui.Localization,"UNKNOWN_LOCALIZATION",shaka.ui.Localization.UNKNOWN_LOCALIZATION);shaka.ui.Localization.MISSING_LOCALIZATIONS="missing-localizations";
goog.exportProperty(shaka.ui.Localization,"MISSING_LOCALIZATIONS",shaka.ui.Localization.MISSING_LOCALIZATIONS);shaka.ui.Localization.LOCALE_CHANGED="locale-changed";goog.exportProperty(shaka.ui.Localization,"LOCALE_CHANGED",shaka.ui.Localization.LOCALE_CHANGED);shaka.ui.Localization.LOCALE_UPDATED="locale-updated";goog.exportProperty(shaka.ui.Localization,"LOCALE_UPDATED",shaka.ui.Localization.LOCALE_UPDATED);shaka.ui.Locales={};
shaka.ui.Locales.addTo=function(a){a.insert("ar",new Map([["AD_DURATION","\u0645\u062f\u0629 \u0627\u0644\u0625\u0639\u0644\u0627\u0646"],["AD_PROGRESS","\u0627\u0644\u0625\u0639\u0644\u0627\u0646 [AD_ON] \u0645\u0646 [NUM_ADS]"],["AD_STATISTICS","\u0625\u062d\u0635\u0627\u0621\u0627\u062a \u0627\u0644\u0625\u0639\u0644\u0627\u0646\u0627\u062a"],["AD_TIME","\u0627\u0644\u0625\u0639\u0644\u0627\u0646: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u062a\u0644\u0642\u0627\u0626\u064a"],["BACK",
"\u0631\u062c\u0648\u0639"],["CAPTIONS","\u0627\u0644\u062a\u0631\u062c\u0645\u0629 \u0648\u0627\u0644\u0634\u0631\u062d"],["CAST","\u0625\u0631\u0633\u0627\u0644..."],["CHAPTERS","\u0627\u0644\u0641\u0635\u0648\u0644"],["DOWNLOAD_VIDEO_FRAME","\u062d\u0641\u0638 \u0625\u0637\u0627\u0631 \u0627\u0644\u0641\u064a\u062f\u064a\u0648"],["ENTER_LOOP_MODE","\u062a\u0643\u0631\u0627\u0631 \u0627\u0644\u0641\u064a\u062f\u064a\u0648 \u0627\u0644\u062d\u0627\u0644\u064a"],["ENTER_PICTURE_IN_PICTURE",'\u0627\u0644\u062f\u062e\u0648\u0644 \u0641\u064a \u0648\u0636\u0639 "\u0646\u0627\u0641\u0630\u0629 \u0636\u0645\u0646 \u0646\u0627\u0641\u0630\u0629"'],
["EXIT_FULL_SCREEN","\u0625\u0646\u0647\u0627\u0621 \u0648\u0636\u0639 \u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629"],["EXIT_LOOP_MODE","\u0625\u064a\u0642\u0627\u0641 \u062a\u0643\u0631\u0627\u0631 \u0627\u0644\u0641\u064a\u062f\u064a\u0648 \u0627\u0644\u062d\u0627\u0644\u064a"],["EXIT_PICTURE_IN_PICTURE",'\u0627\u0644\u062e\u0631\u0648\u062c \u0645\u0646 \u0648\u0636\u0639 "\u0646\u0627\u0641\u0630\u0629 \u0636\u0645\u0646 \u0646\u0627\u0641\u0630\u0629"'],["FAST_FORWARD","\u062a\u0642\u062f\u064a\u0645 \u0633\u0631\u064a\u0639"],
["FULL_SCREEN","\u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629"],["LANGUAGE","\u0627\u0644\u0644\u063a\u0629"],["LIVE","\u0645\u0628\u0627\u0634\u0631"],["LOOP","\u062a\u0643\u0631\u0627\u0631"],["MORE_SETTINGS","\u0645\u0632\u064a\u062f \u0645\u0646 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a"],["MULTIPLE_LANGUAGES","\u0644\u063a\u0627\u062a \u0645\u062a\u0639\u062f\u062f\u0629"],["MUTE","\u0643\u062a\u0645 \u0627\u0644\u0635\u0648\u062a"],["NOT_APPLICABLE","\u063a\u064a\u0631 \u0633\u0627\u0631\u064d"],
["OFF","\u0625\u064a\u0642\u0627\u0641"],["ON","\u062a\u0634\u063a\u064a\u0644"],["PAUSE","\u0625\u064a\u0642\u0627\u0641 \u0645\u0624\u0642\u062a"],["PICTURE_IN_PICTURE","\u0646\u0627\u0641\u0630\u0629 \u0636\u0645\u0646 \u0627\u0644\u0646\u0627\u0641\u0630\u0629"],["PLAY","\u0627\u0644\u062a\u0634\u063a\u064a\u0644"],["PLAYBACK_RATE","\u0633\u0631\u0639\u0629 \u0627\u0644\u062a\u0634\u063a\u064a\u0644"],["QUALITY","\u0627\u0644\u062c\u0648\u062f\u0629"],["RECENTER_VR","\u0625\u0639\u0627\u062f\u0629 \u0627\u0644\u062a\u0648\u0633\u064a\u0637"],
["REPLAY","\u0625\u0639\u0627\u062f\u0629 \u0627\u0644\u062a\u0634\u063a\u064a\u0644"],["RESOLUTION","\u062f\u0631\u062c\u0629 \u0627\u0644\u062f\u0642\u0629"],["REWIND","\u062a\u0631\u062c\u064a\u0639"],["SEEK","\u0627\u0644\u0628\u062d\u062b \u0628\u0627\u0644\u062a\u0645\u0631\u064a\u0631"],["SKIP_AD","\u062a\u062e\u0637\u0651\u064a \u0627\u0644\u0625\u0639\u0644\u0627\u0646"],["SKIP_TO_LIVE","\u0627\u0644\u0627\u0646\u062a\u0642\u0627\u0644 \u0625\u0644\u0649 \u0628\u062b \u0645\u0628\u0627\u0634\u0631"],
["STATISTICS","\u0627\u0644\u0625\u062d\u0635\u0627\u0621\u0627\u062a"],["SUBTITLE_FORCED","\u0639\u0631\u0636 \u0625\u062c\u0628\u0627\u0631\u064a"],["SURROUND","\u0635\u0648\u062a \u0645\u062d\u064a\u0637\u064a"],["TOGGLE_STEREOSCOPIC","\u0625\u064a\u0642\u0627\u0641 \u0627\u0644\u0639\u0631\u0636 \u0627\u0644\u0645\u062c\u0633\u0651\u0645 \u0623\u0648 \u062a\u0641\u0639\u064a\u0644\u0647"],["UNDETERMINED_LANGUAGE","\u063a\u064a\u0631 \u0645\u062d\u062f\u062f"],["UNMUTE","\u0625\u0639\u0627\u062f\u0629 \u0627\u0644\u0635\u0648\u062a"],
["UNRECOGNIZED_LANGUAGE","\u063a\u064a\u0631 \u0645\u0639\u0631\u0648\u0641"],["VOLUME","\u0645\u0633\u062a\u0648\u0649 \u0627\u0644\u0635\u0648\u062a"]]));a.insert("de",new Map([["AD_DURATION","Dauer der Werbeanzeige"],["AD_PROGRESS","Werbung\u00a0[AD_ON] von\u00a0[NUM_ADS]"],["AD_STATISTICS","Anzeigenstatistiken"],["AD_TIME","Werbeanzeige: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Automatisch"],["BACK","Zur\u00fcck"],["CAPTIONS","Untertitel"],["CAST","Streamen..."],["CHAPTERS","Kapitel"],
["DOWNLOAD_VIDEO_FRAME","Videoframe speichern"],["ENTER_LOOP_MODE","In Endlosschleife spielen"],["ENTER_PICTURE_IN_PICTURE","Bild im Bild aktivieren"],["EXIT_FULL_SCREEN","Vollbildmodus beenden"],["EXIT_LOOP_MODE","Endlosschleife stoppen"],["EXIT_PICTURE_IN_PICTURE","Bild im Bild beenden"],["FAST_FORWARD","Vorspulen"],["FULL_SCREEN","Vollbildmodus"],["LANGUAGE","Sprache"],["LIVE","Live"],["LOOP","Schleife"],["MORE_SETTINGS","Weitere Einstellungen"],["MULTIPLE_LANGUAGES","Mehrere Sprachen"],["MUTE",
"Stummschalten"],["NOT_APPLICABLE","Nicht zutreffend"],["OFF","Aus"],["ON","Ein"],["PAUSE","Pause"],["PICTURE_IN_PICTURE","Bild im Bild"],["PLAY","Wiedergabe"],["PLAYBACK_RATE","Geschwindigkeit"],["QUALITY","Qualit\u00e4t"],["RECENTER_VR","Zentrieren"],["REPLAY","Noch einmal wiedergeben"],["RESOLUTION","Aufl\u00f6sung"],["REWIND","Zur\u00fcckspulen"],["SEEK","Suche"],["SKIP_AD","\u00dcberspringen"],["SKIP_TO_LIVE","Zum Live-Videostream wechseln"],["STATISTICS","Statistiken"],["SUBTITLE_FORCED","Erzwungen"],
["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Einstellung \u201estereoskopisch\u201c ein\u2011/ausschalten"],["UNDETERMINED_LANGUAGE","Unbestimmt"],["UNMUTE","Stummschaltung aufheben"],["UNRECOGNIZED_LANGUAGE","Unbekannt"],["VOLUME","Lautst\u00e4rke"]]));a.insert("en",new Map([["AD_DURATION","Ad duration"],["AD_PROGRESS","Ad [AD_ON] of [NUM_ADS]"],["AD_STATISTICS","Ad statistics"],["AD_TIME","Ad: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Auto"],["BACK","Back"],["CAPTIONS","Captions"],["CAST",
"Cast..."],["CHAPTERS","Chapters"],["DOWNLOAD_VIDEO_FRAME","Save video frame"],["ENTER_LOOP_MODE","Loop the current video"],["ENTER_PICTURE_IN_PICTURE","Enter Picture-in-Picture"],["EXIT_FULL_SCREEN","Exit full screen"],["EXIT_LOOP_MODE","Stop looping the current video"],["EXIT_PICTURE_IN_PICTURE","Exit Picture-in-Picture"],["FAST_FORWARD","Fast-forward"],["FULL_SCREEN","Full screen"],["LANGUAGE","Language"],["LIVE","Live"],["LOOP","Loop"],["MORE_SETTINGS","More settings"],["MULTIPLE_LANGUAGES","Multiple languages"],
["MUTE","Mute"],["NOT_APPLICABLE","Not applicable"],["OFF","Off"],["ON","On"],["PAUSE","Pause"],["PICTURE_IN_PICTURE","Picture-in-Picture"],["PLAY","Play"],["PLAYBACK_RATE","Playback speed"],["QUALITY","Quality"],["RECENTER_VR","Recenter"],["REPLAY","Replay"],["RESOLUTION","Resolution"],["REWIND","Rewind"],["SEEK","Seek"],["SKIP_AD","Skip Ad"],["SKIP_NEXT","Next"],["SKIP_PREVIOUS","Previous"],["SKIP_TO_LIVE","Skip ahead to live"],["STATISTICS","Statistics"],["SUBTITLE_FORCED","Forced"],["SURROUND",
"Surround"],["TOGGLE_STEREOSCOPIC","Toggle stereoscopic"],["UNDETERMINED_LANGUAGE","Undetermined"],["UNMUTE","Unmute"],["UNRECOGNIZED_LANGUAGE","Unrecognized"],["VOLUME","Volume"]]));a.insert("en-GB",new Map([["AD_DURATION","Ad duration"],["AD_PROGRESS","Ad [AD_ON] of [NUM_ADS]"],["AD_STATISTICS","Ad statistics"],["AD_TIME","Ad: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Auto"],["BACK","Back"],["CAPTIONS","Captions"],["CAST","Cast..."],["CHAPTERS","Chapters"],["DOWNLOAD_VIDEO_FRAME","Save video frame"],
["ENTER_LOOP_MODE","Loop the current video"],["ENTER_PICTURE_IN_PICTURE","Enter picture-in-picture"],["EXIT_FULL_SCREEN","Exit full screen"],["EXIT_LOOP_MODE","Stop looping the current video"],["EXIT_PICTURE_IN_PICTURE","Exit picture-in-picture"],["FAST_FORWARD","Fast-forward"],["FULL_SCREEN","Full screen"],["LANGUAGE","Language"],["LIVE","Live"],["LOOP","Loop"],["MORE_SETTINGS","More settings"],["MULTIPLE_LANGUAGES","Multiple languages"],["MUTE","Mute"],["NOT_APPLICABLE","Not applicable"],["OFF",
"Off"],["ON","On"],["PAUSE","Pause"],["PICTURE_IN_PICTURE","Picture-in-picture"],["PLAY","Play"],["PLAYBACK_RATE","Playback speed"],["QUALITY","Quality"],["RECENTER_VR","Recentre"],["REPLAY","Replay"],["RESOLUTION","Resolution"],["REWIND","Rewind"],["SEEK","Seek"],["SKIP_AD","Skip ad"],["SKIP_TO_LIVE","Skip ahead to live"],["STATISTICS","Statistics"],["SUBTITLE_FORCED","Forced"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Toggle stereoscopic"],["UNDETERMINED_LANGUAGE","Undetermined"],["UNMUTE",
"Unmute"],["UNRECOGNIZED_LANGUAGE","Unrecognised"],["VOLUME","volume"]]));a.insert("es",new Map([["AD_DURATION","Duraci\u00f3n del anuncio"],["AD_PROGRESS","Anuncio [AD_ON] de [NUM_ADS]"],["AD_STATISTICS","Estad\u00edsticas del anuncio"],["AD_TIME","Anuncio: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Autom\u00e1tico"],["BACK","Atr\u00e1s"],["CAPTIONS","Subt\u00edtulos"],["CAST","Enviar..."],["CHAPTERS","Cap\u00edtulos"],["DOWNLOAD_VIDEO_FRAME","Guardar fotograma"],["ENTER_LOOP_MODE","Reproducir en bucle el v\u00eddeo actual"],
["ENTER_PICTURE_IN_PICTURE","Activar el modo imagen en imagen"],["EXIT_FULL_SCREEN","Salir del modo de pantalla completa"],["EXIT_LOOP_MODE","Dejar de reproducir en bucle el v\u00eddeo actual"],["EXIT_PICTURE_IN_PICTURE","Salir del modo imagen en imagen"],["FAST_FORWARD","Avanzar r\u00e1pidamente"],["FULL_SCREEN","Pantalla completa"],["LANGUAGE","Idioma"],["LIVE","En directo"],["LOOP","Reproducir en bucle"],["MORE_SETTINGS","M\u00e1s ajustes"],["MULTIPLE_LANGUAGES","Varios idiomas"],["MUTE","Silenciar"],
["NOT_APPLICABLE","No aplicable"],["OFF","Desactivado"],["ON","Activado"],["PAUSE","Pausar"],["PICTURE_IN_PICTURE","Imagen en imagen"],["PLAY","Reproducir"],["PLAYBACK_RATE","Velocidad de reproducci\u00f3n"],["QUALITY","Calidad"],["RECENTER_VR","Volver a centrar"],["REPLAY","Volver a reproducir"],["RESOLUTION","Resoluci\u00f3n"],["REWIND","Rebobinar"],["SEEK","Buscar"],["SKIP_AD","Saltar anuncio"],["SKIP_NEXT","Siguiente"],["SKIP_PREVIOUS","Anterior"],["SKIP_TO_LIVE","Ir al v\u00eddeo en directo"],
["STATISTICS","Estad\u00edsticas"],["SUBTITLE_FORCED","Forzado"],["SURROUND","Envolvente"],["TOGGLE_STEREOSCOPIC","Activar/Desactivar estereosc\u00f3pica"],["UNDETERMINED_LANGUAGE","Sin especificar"],["UNMUTE","Activar sonido"],["UNRECOGNIZED_LANGUAGE","No reconocida"],["VOLUME","Volumen"]]));a.insert("es-419",new Map([["AD_DURATION","Duraci\u00f3n del anuncio"],["AD_PROGRESS","Anuncio [AD_ON] de [NUM_ADS]"],["AD_STATISTICS","Estad\u00edsticas de anuncios"],["AD_TIME","Anuncio: [AD_TIME]"],["AIRPLAY",
"AirPlay"],["AUTO_QUALITY","Autom\u00e1tico"],["BACK","Atr\u00e1s"],["CAPTIONS","Subt\u00edtulos"],["CAST","Transmitir..."],["CHAPTERS","Cap\u00edtulos"],["DOWNLOAD_VIDEO_FRAME","Guardar fotograma"],["ENTER_LOOP_MODE","Repetir indefinidamente el video actual"],["ENTER_PICTURE_IN_PICTURE","Ingresar al modo de pantalla en pantalla"],["EXIT_FULL_SCREEN","Salir de pantalla completa"],["EXIT_LOOP_MODE","Detener la repetici\u00f3n indefinida del video actual"],["EXIT_PICTURE_IN_PICTURE","Salir del modo de pantalla en pantalla"],
["FAST_FORWARD","Avanzar"],["FULL_SCREEN","Pantalla completa"],["LANGUAGE","Idioma"],["LIVE","En directo"],["LOOP","Repetir indefinidamente"],["MORE_SETTINGS","M\u00e1s opciones de configuraci\u00f3n"],["MULTIPLE_LANGUAGES","Varios idiomas"],["MUTE","Silenciar"],["NOT_APPLICABLE","No aplicable"],["OFF","Desactivado"],["ON","Activado"],["PAUSE","Detener"],["PICTURE_IN_PICTURE","Pantalla en pantalla"],["PLAY","Reproducir"],["PLAYBACK_RATE","Velocidad de reproducci\u00f3n"],["QUALITY","Calidad"],["RECENTER_VR",
"Volver a centrar"],["REPLAY","Volver a reproducir"],["RESOLUTION","Resoluci\u00f3n"],["REWIND","Retroceder"],["SEEK","Buscar"],["SKIP_AD","Omitir anuncio"],["SKIP_TO_LIVE","Adelantar hasta la transmisi\u00f3n en vivo"],["STATISTICS","Estad\u00edsticas"],["SUBTITLE_FORCED","Forzado"],["SURROUND","Sonido envolvente"],["TOGGLE_STEREOSCOPIC","Activar o desactivar el modo estereosc\u00f3pico"],["UNDETERMINED_LANGUAGE","Sin especificar"],["UNMUTE","Dejar de silenciar"],["UNRECOGNIZED_LANGUAGE","No reconocida"],
["VOLUME","Volumen"]]));a.insert("fr",new Map([["AD_DURATION","Dur\u00e9e de l'annonce"],["AD_PROGRESS","Annonce\u00a0[AD_ON] sur\u00a0[NUM_ADS]"],["AD_STATISTICS","Statistiques sur les annonces"],["AD_TIME","Annonce\u00a0: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Automatique"],["BACK","Retour"],["CAPTIONS","Sous-titres"],["CAST","Caster\u2026"],["CHAPTERS","Chapitres"],["DOWNLOAD_VIDEO_FRAME","T\u00e9l\u00e9charger l'image de la vid\u00e9o"],["ENTER_LOOP_MODE","Lire en boucle la vid\u00e9o en cours"],
["ENTER_PICTURE_IN_PICTURE","Utiliser le mode Picture-in-Picture"],["EXIT_FULL_SCREEN","Quitter le mode plein \u00e9cran"],["EXIT_LOOP_MODE","Arr\u00eater la lecture en boucle de la vid\u00e9o en cours"],["EXIT_PICTURE_IN_PICTURE","Quitter le mode\u00a0PIP (Picture-in-picture)"],["FAST_FORWARD","Avance rapide"],["FULL_SCREEN","Plein \u00e9cran"],["LANGUAGE","Langue"],["LIVE","En direct"],["LOOP","R\u00e9p\u00e9ter"],["MORE_SETTINGS","Plus de param\u00e8tres"],["MULTIPLE_LANGUAGES","Plusieurs langues"],
["MUTE","Couper le son"],["NOT_APPLICABLE","Non applicable"],["OFF","D\u00e9sactiv\u00e9e"],["ON","Activ\u00e9e"],["PAUSE","Pause"],["PICTURE_IN_PICTURE","Picture-in-Picture"],["PLAY","Visionner"],["PLAYBACK_RATE","Vitesse de lecture"],["QUALITY","Qualit\u00e9"],["RECENTER_VR","Recentrer"],["REPLAY","Revoir"],["RESOLUTION","R\u00e9solution"],["REWIND","Retour arri\u00e8re"],["SEEK","Chercher"],["SKIP_AD","Passer l'annonce"],["SKIP_NEXT","Suivante"],["SKIP_PREVIOUS","Pr\u00e9c\u00e9dente"],["SKIP_TO_LIVE",
"Acc\u00e9der \u00e0 la partie la plus r\u00e9cente du direct"],["STATISTICS","Statistiques"],["SUBTITLE_FORCED","Forc\u00e9"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Activer/D\u00e9sactiver le mode st\u00e9r\u00e9oscopique"],["UNDETERMINED_LANGUAGE","Langue ind\u00e9termin\u00e9e"],["UNMUTE","R\u00e9activer le son"],["UNRECOGNIZED_LANGUAGE","Non reconnu"],["VOLUME","Volume"]]));a.insert("it",new Map([["AD_DURATION","Durata dell'annuncio"],["AD_PROGRESS","Annuncio [AD_ON] di [NUM_ADS]"],["AD_STATISTICS",
"Statistiche sugli annunci"],["AD_TIME","Annuncio: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Automatica"],["BACK","Indietro"],["CAPTIONS","Sottotitoli"],["CAST","Trasmetti..."],["CHAPTERS","Capitoli"],["DOWNLOAD_VIDEO_FRAME","Salva fotogramma"],["ENTER_LOOP_MODE","Riproduci in loop il video corrente"],["ENTER_PICTURE_IN_PICTURE","Attiva Picture in picture"],["EXIT_FULL_SCREEN","Esci da schermo intero"],["EXIT_LOOP_MODE","Interrompi riproduzione in loop del video corrente"],["EXIT_PICTURE_IN_PICTURE",
"Esci da Picture in picture"],["FAST_FORWARD","Avanti veloce"],["FULL_SCREEN","Schermo intero"],["LANGUAGE","Lingua"],["LIVE","Dal vivo"],["LOOP","Riproduci in loop"],["MORE_SETTINGS","Altre impostazioni"],["MULTIPLE_LANGUAGES","Pi\u00f9 lingue"],["MUTE","Disattiva audio"],["NOT_APPLICABLE","Non applicabile"],["OFF","Disattivo"],["ON","Attivo"],["PAUSE","Metti in pausa"],["PICTURE_IN_PICTURE","Picture in picture"],["PLAY","Riproduci"],["PLAYBACK_RATE","Velocit\u00e0 di riproduzione"],["QUALITY","Qualit\u00e0"],
["RECENTER_VR","Ricentra"],["REPLAY","Riproduci di nuovo"],["RESOLUTION","Risoluzione"],["REWIND","Riavvolgi"],["SEEK","Cerca"],["SKIP_AD","Salta annuncio"],["SKIP_TO_LIVE","Passa alla trasmissione dal vivo"],["STATISTICS","Statistiche"],["SUBTITLE_FORCED","Forzata"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Pulsante di attivazione/disattivazione stereoscopico"],["UNDETERMINED_LANGUAGE","Indeterminata"],["UNMUTE","Riattiva audio"],["UNRECOGNIZED_LANGUAGE","Non riconosciuto"],["VOLUME","Volume"]]));
a.insert("ja",new Map([["AD_DURATION","\u5e83\u544a\u518d\u751f\u6642\u9593"],["AD_PROGRESS","[AD_ON] \u756a\u76ee\u306e\u5e83\u544a\uff08\u5168 [NUM_ADS] \u500b\uff09"],["AD_STATISTICS","\u5e83\u544a\u306e\u7d71\u8a08\u60c5\u5831"],["AD_TIME","\u5e83\u544a: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u81ea\u52d5"],["BACK","\u623b\u308b"],["CAPTIONS","\u5b57\u5e55"],["CAST","\u30ad\u30e3\u30b9\u30c8..."],["CHAPTERS","\u7ae0"],["DOWNLOAD_VIDEO_FRAME","\u52d5\u753b\u30d5\u30ec\u30fc\u30e0\u3092\u4fdd\u5b58"],
["ENTER_LOOP_MODE","\u73fe\u5728\u306e\u52d5\u753b\u3092\u30eb\u30fc\u30d7\u518d\u751f"],["ENTER_PICTURE_IN_PICTURE","\u30d4\u30af\u30c1\u30e3\u30fc \u30a4\u30f3 \u30d4\u30af\u30c1\u30e3\u30fc\u3092\u958b\u59cb"],["EXIT_FULL_SCREEN","\u5168\u753b\u9762\u8868\u793a\u3092\u7d42\u4e86"],["EXIT_LOOP_MODE","\u73fe\u5728\u306e\u52d5\u753b\u306e\u30eb\u30fc\u30d7\u518d\u751f\u3092\u505c\u6b62"],["EXIT_PICTURE_IN_PICTURE","\u30d4\u30af\u30c1\u30e3\u30fc \u30a4\u30f3 \u30d4\u30af\u30c1\u30e3\u30fc\u3092\u7d42\u4e86"],
["FAST_FORWARD","\u65e9\u9001\u308a"],["FULL_SCREEN","\u5168\u753b\u9762\u8868\u793a"],["LANGUAGE","\u8a00\u8a9e"],["LIVE","\u30e9\u30a4\u30d6"],["LOOP","\u30eb\u30fc\u30d7"],["MORE_SETTINGS","\u8a73\u7d30\u8a2d\u5b9a"],["MULTIPLE_LANGUAGES","\u591a\u8a00\u8a9e"],["MUTE","\u30df\u30e5\u30fc\u30c8"],["NOT_APPLICABLE","\u8a72\u5f53\u306a\u3057"],["OFF","\u30aa\u30d5"],["ON","\u30aa\u30f3"],["PAUSE","\u4e00\u6642\u505c\u6b62"],["PICTURE_IN_PICTURE","\u30d4\u30af\u30c1\u30e3\u30fc \u30a4\u30f3 \u30d4\u30af\u30c1\u30e3\u30fc"],
["PLAY","\u518d\u751f"],["PLAYBACK_RATE","\u518d\u751f\u901f\u5ea6"],["QUALITY","\u54c1\u8cea"],["RECENTER_VR","\u4e2d\u5fc3\u3092\u518d\u8a2d\u5b9a"],["REPLAY","\u3082\u3046\u4e00\u5ea6\u518d\u751f"],["RESOLUTION","\u89e3\u50cf\u5ea6"],["REWIND","\u5dfb\u304d\u623b\u3057"],["SEEK","\u30b7\u30fc\u30af\u518d\u751f"],["SKIP_AD","\u5e83\u544a\u3092\u30b9\u30ad\u30c3\u30d7"],["SKIP_TO_LIVE","\u30e9\u30a4\u30d6\u914d\u4fe1\u307e\u3067\u30b9\u30ad\u30c3\u30d7"],["STATISTICS","\u7d71\u8a08\u60c5\u5831"],
["SUBTITLE_FORCED","\u5f37\u5236"],["SURROUND","\u30b5\u30e9\u30a6\u30f3\u30c9"],["TOGGLE_STEREOSCOPIC","\u7acb\u4f53\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u308b"],["UNDETERMINED_LANGUAGE","\u4e0d\u660e"],["UNMUTE","\u30df\u30e5\u30fc\u30c8\u3092\u89e3\u9664"],["UNRECOGNIZED_LANGUAGE","\u4e0d\u660e"],["VOLUME","\u97f3\u91cf"]]));a.insert("ko",new Map([["AD_DURATION","\uad11\uace0 \uae30\uac04"],["AD_PROGRESS","\uad11\uace0 [AD_ON]/[NUM_ADS]"],["AD_STATISTICS","\uad11\uace0 \ud1b5\uacc4"],["AD_TIME",
"\uad11\uace0: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\uc790\ub3d9"],["BACK","\ub4a4\ub85c"],["CAPTIONS","\uc790\ub9c9"],["CAST","\uc804\uc1a1..."],["CHAPTERS","\uc7a5"],["DOWNLOAD_VIDEO_FRAME","\ub3d9\uc601\uc0c1 \ud504\ub808\uc784 \uc800\uc7a5"],["ENTER_LOOP_MODE","\ud604\uc7ac \ub3d9\uc601\uc0c1 \ubc18\ubcf5 \uc7ac\uc0dd"],["ENTER_PICTURE_IN_PICTURE","PIP \ubaa8\ub4dc \uc2dc\uc791"],["EXIT_FULL_SCREEN","\uc804\uccb4\ud654\uba74 \ub2eb\uae30"],["EXIT_LOOP_MODE","\ud604\uc7ac \ub3d9\uc601\uc0c1 \ubc18\ubcf5 \uc7ac\uc0dd \uc911\uc9c0"],
["EXIT_PICTURE_IN_PICTURE","PIP \ubaa8\ub4dc \uc885\ub8cc"],["FAST_FORWARD","\ube68\ub9ac \uac10\uae30"],["FULL_SCREEN","\uc804\uccb4\ud654\uba74"],["LANGUAGE","\uc5b8\uc5b4"],["LIVE","\uc2e4\uc2dc\uac04"],["LOOP","\ubc18\ubcf5 \uc7ac\uc0dd"],["MORE_SETTINGS","\uc124\uc815 \ub354\ubcf4\uae30"],["MULTIPLE_LANGUAGES","\uc5ec\ub7ec \uc5b8\uc5b4"],["MUTE","\uc74c\uc18c\uac70"],["NOT_APPLICABLE","\ud574\ub2f9 \uc0ac\ud56d \uc5c6\uc74c"],["OFF","\uc0ac\uc6a9 \uc548\ud568"],["ON","\uc0ac\uc6a9"],["PAUSE",
"\uc77c\uc2dc\uc911\uc9c0"],["PICTURE_IN_PICTURE","PIP \ubaa8\ub4dc"],["PLAY","\uc7ac\uc0dd"],["PLAYBACK_RATE","\uc7ac\uc0dd \uc18d\ub3c4"],["QUALITY","\ud488\uc9c8"],["RECENTER_VR","\uc911\uc2ec \uc7ac\uc124\uc815"],["REPLAY","\ub2e4\uc2dc\ubcf4\uae30"],["RESOLUTION","\ud574\uc0c1\ub3c4"],["REWIND","\ub418\uac10\uae30"],["SEEK","\ucc3e\uae30"],["SKIP_AD","\uad11\uace0 \uac74\ub108\ub6f0\uae30"],["SKIP_TO_LIVE","\ub77c\uc774\ube0c \ub3d9\uc601\uc0c1\uc73c\ub85c \uac74\ub108\ub6f0\uae30"],["STATISTICS",
"\ud1b5\uacc4"],["SUBTITLE_FORCED","\uac15\uc81c"],["SURROUND","\uc11c\ub77c\uc6b4\ub4dc"],["TOGGLE_STEREOSCOPIC","\uc785\uccb4 \ubcf4\uae30 \uc804\ud658"],["UNDETERMINED_LANGUAGE","\ubbf8\uc815"],["UNMUTE","\uc74c\uc18c\uac70 \ud574\uc81c"],["UNRECOGNIZED_LANGUAGE","\uc54c \uc218 \uc5c6\uc74c"],["VOLUME","\ubcfc\ub968"]]));a.insert("nl",new Map([["AD_DURATION","Advertentieduur"],["AD_PROGRESS","Advertentie [AD_ON] van [NUM_ADS]"],["AD_STATISTICS","Advertentiestatistieken"],["AD_TIME","Advertentie: [AD_TIME]"],
["AIRPLAY","AirPlay"],["AUTO_QUALITY","Automatisch"],["BACK","Terug"],["CAPTIONS","Ondertiteling"],["CAST","Casten..."],["CHAPTERS","Hoofdstukken"],["DOWNLOAD_VIDEO_FRAME","Videoframe opslaan"],["ENTER_LOOP_MODE","De huidige video lussen"],["ENTER_PICTURE_IN_PICTURE","Scherm-in-scherm openen"],["EXIT_FULL_SCREEN","Volledig scherm sluiten"],["EXIT_LOOP_MODE","De huidige video niet meer lussen"],["EXIT_PICTURE_IN_PICTURE","Scherm-in-scherm afsluiten"],["FAST_FORWARD","Vooruitspoelen"],["FULL_SCREEN",
"Volledig scherm"],["LANGUAGE","Taal"],["LIVE","Live"],["LOOP","Lussen"],["MORE_SETTINGS","Meer instellingen"],["MULTIPLE_LANGUAGES","Meerdere talen"],["MUTE","Geluid uitzetten"],["NOT_APPLICABLE","Niet van toepassing"],["OFF","Uit"],["ON","Aan"],["PAUSE","Onderbreken"],["PICTURE_IN_PICTURE","Scherm-in-scherm"],["PLAY","Afspelen"],["PLAYBACK_RATE","Afspeelsnelheid"],["QUALITY","Kwaliteit"],["RECENTER_VR","Opnieuw centreren"],["REPLAY","Opnieuw afspelen"],["RESOLUTION","Resolutie"],["REWIND","Terugspoelen"],
["SEEK","Zoeken"],["SKIP_AD","Advertentie overslaan"],["SKIP_TO_LIVE","Doorgaan naar live"],["STATISTICS","Statistieken"],["SUBTITLE_FORCED","Afgedwongen"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Stereoscopisch aan-/uitzetten"],["UNDETERMINED_LANGUAGE","Onbepaald"],["UNMUTE","Geluid aanzetten"],["UNRECOGNIZED_LANGUAGE","Onbekend"],["VOLUME","Volume"]]));a.insert("pl",new Map([["AD_DURATION","Czas trwania reklamy"],["AD_PROGRESS","Reklama\u00a0[AD_ON] z\u00a0[NUM_ADS]"],["AD_STATISTICS","Statystyki reklam"],
["AD_TIME","Reklama: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Automatycznie"],["BACK","Wstecz"],["CAPTIONS","Napisy"],["CAST","Przesy\u0142aj..."],["CHAPTERS","Rozdzia\u0142y"],["DOWNLOAD_VIDEO_FRAME","Zapisz klatk\u0119 filmu"],["ENTER_LOOP_MODE","Odtwarzaj bie\u017c\u0105cy film w\u00a0p\u0119tli"],["ENTER_PICTURE_IN_PICTURE","W\u0142\u0105cz tryb obrazu w\u00a0obrazie"],["EXIT_FULL_SCREEN","Zamknij pe\u0142ny ekran"],["EXIT_LOOP_MODE","Wy\u0142\u0105cz odtwarzanie bie\u017c\u0105cego filmu w\u00a0p\u0119tli"],
["EXIT_PICTURE_IN_PICTURE","Wy\u0142\u0105cz tryb obrazu w\u00a0obrazie"],["FAST_FORWARD","Przewi\u0144 do przodu"],["FULL_SCREEN","Pe\u0142ny ekran"],["LANGUAGE","J\u0119zyk"],["LIVE","Na \u017cywo"],["LOOP","Odtwarzaj w\u00a0p\u0119tli"],["MORE_SETTINGS","Wi\u0119cej ustawie\u0144"],["MULTIPLE_LANGUAGES","Wiele j\u0119zyk\u00f3w"],["MUTE","Wycisz"],["NOT_APPLICABLE","Nie dotyczy"],["OFF","Wy\u0142\u0105czone"],["ON","W\u0142\u0105czone"],["PAUSE","Wstrzymaj"],["PICTURE_IN_PICTURE","Obraz w\u00a0obrazie"],
["PLAY","Odtw\u00f3rz"],["PLAYBACK_RATE","Szybko\u015b\u0107 odtwarzania"],["QUALITY","Jako\u015b\u0107"],["RECENTER_VR","Wy\u015brodkuj"],["REPLAY","Odtw\u00f3rz ponownie"],["RESOLUTION","Rozdzielczo\u015b\u0107"],["REWIND","Przewi\u0144 do ty\u0142u"],["SEEK","Szukaj"],["SKIP_AD","Pomi\u0144 reklam\u0119"],["SKIP_NEXT","Dalej"],["SKIP_PREVIOUS","Poprzedni"],["SKIP_TO_LIVE","Przejd\u017a do transmisji na \u017cywo"],["STATISTICS","Statystyki"],["SUBTITLE_FORCED","Wymuszone"],["SURROUND","Przestrzenny"],
["TOGGLE_STEREOSCOPIC","Prze\u0142\u0105cz tryb stereoskopowy"],["UNDETERMINED_LANGUAGE","Nie okre\u015blono"],["UNMUTE","Wy\u0142\u0105cz wyciszenie"],["UNRECOGNIZED_LANGUAGE","Nierozpoznany"],["VOLUME","G\u0142o\u015bno\u015b\u0107"]]));a.insert("pt-BR",new Map([["AD_DURATION","Dura\u00e7\u00e3o do an\u00fancio"],["AD_PROGRESS","An\u00fancio [AD_ON] de [NUM_ADS]"],["AD_STATISTICS","Estat\u00edsticas de an\u00fancios"],["AD_TIME","An\u00fancio: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Autom\u00e1tica"],
["BACK","Voltar"],["CAPTIONS","Legendas"],["CAST","Transmitir..."],["CHAPTERS","Cap\u00edtulos"],["DOWNLOAD_VIDEO_FRAME","Salvar frame do v\u00eddeo"],["ENTER_LOOP_MODE","Repetir o v\u00eddeo atual"],["ENTER_PICTURE_IN_PICTURE","Entrar no modo picture-in-picture"],["EXIT_FULL_SCREEN","Sair do modo tela cheia"],["EXIT_LOOP_MODE","Parar repeti\u00e7\u00e3o do v\u00eddeo atual"],["EXIT_PICTURE_IN_PICTURE","Sair de picture-in-picture"],["FAST_FORWARD","Avan\u00e7ar"],["FULL_SCREEN","Tela cheia"],["LANGUAGE",
"Idioma"],["LIVE","Ao vivo"],["LOOP","Repetir"],["MORE_SETTINGS","Mais defini\u00e7\u00f5es"],["MULTIPLE_LANGUAGES","V\u00e1rios idiomas"],["MUTE","Desativar som"],["NOT_APPLICABLE","N\u00e3o relevante"],["OFF","Desativado"],["ON","Ativado"],["PAUSE","Pausar"],["PICTURE_IN_PICTURE","Picture-in-picture"],["PLAY","Reproduzir"],["PLAYBACK_RATE","Velocidade da reprodu\u00e7\u00e3o"],["QUALITY","Qualidade"],["RECENTER_VR","Centralizar"],["REPLAY","Repetir"],["RESOLUTION","Resolu\u00e7\u00e3o"],["REWIND",
"Voltar"],["SEEK","Procurar"],["SKIP_AD","Pular an\u00fancio"],["SKIP_TO_LIVE","Pular para transmiss\u00e3o ao vivo"],["STATISTICS","Estat\u00edsticas"],["SUBTITLE_FORCED","Exibi\u00e7\u00e3o for\u00e7ada"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC","Alternar imagem estereosc\u00f3pica"],["UNDETERMINED_LANGUAGE","Indeterminado"],["UNMUTE","Ativar som"],["UNRECOGNIZED_LANGUAGE","N\u00e3o reconhecido"],["VOLUME","Volume"]]));a.insert("ru",new Map([["AD_DURATION","\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u043a\u043b\u0430\u043c\u044b"],
["AD_PROGRESS","\u0420\u0435\u043a\u043b\u0430\u043c\u0430 [AD_ON] \u0438\u0437 [NUM_ADS]"],["AD_STATISTICS","\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439"],["AD_TIME","\u0420\u0435\u043a\u043b\u0430\u043c\u0430: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u0410\u0432\u0442\u043e"],["BACK","\u041d\u0430\u0437\u0430\u0434"],["CAPTIONS","\u0421\u0443\u0431\u0442\u0438\u0442\u0440\u044b"],["CAST","\u0422\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c..."],
["CHAPTERS","\u042d\u043f\u0438\u0437\u043e\u0434\u044b"],["DOWNLOAD_VIDEO_FRAME","\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u0434\u0440 \u0432\u0438\u0434\u0435\u043e"],["ENTER_LOOP_MODE","\u0417\u0430\u0446\u0438\u043a\u043b\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0438\u0434\u0435\u043e"],["ENTER_PICTURE_IN_PICTURE",'\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c "\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435"'],
["EXIT_FULL_SCREEN","\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c"],["EXIT_LOOP_MODE","\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0435\u043e"],["EXIT_PICTURE_IN_PICTURE",'\u0412\u044b\u0439\u0442\u0438 \u0438\u0437 \u0440\u0435\u0436\u0438\u043c\u0430 "\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435"'],
["FAST_FORWARD","\u041f\u0435\u0440\u0435\u043c\u043e\u0442\u043a\u0430 \u0432\u043f\u0435\u0440\u0435\u0434"],["FULL_SCREEN","\u041f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c"],["LANGUAGE","\u042f\u0437\u044b\u043a"],["LIVE","\u041f\u0440\u044f\u043c\u043e\u0439 \u044d\u0444\u0438\u0440"],["LOOP","\u0417\u0430\u0446\u0438\u043a\u043b\u0438\u0442\u044c"],["MORE_SETTINGS","\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438"],
["MULTIPLE_LANGUAGES","\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f\u0437\u044b\u043a\u043e\u0432"],["MUTE","\u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0432\u0443\u043a"],["NOT_APPLICABLE","\u041d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e"],["OFF","\u0412\u044b\u043a\u043b."],["ON","\u0412\u043a\u043b."],["PAUSE","\u041f\u0430\u0443\u0437\u0430"],["PICTURE_IN_PICTURE","\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435"],
["PLAY","\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438"],["PLAYBACK_RATE","\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f"],["QUALITY","\u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e"],["RECENTER_VR","\u0426\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e"],["REPLAY","\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c"],
["RESOLUTION","\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435"],["REWIND","\u041f\u0435\u0440\u0435\u043c\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0437\u0430\u0434"],["SEEK","\u041f\u0435\u0440\u0435\u043c\u043e\u0442\u043a\u0430"],["SKIP_AD","\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c"],["SKIP_TO_LIVE","\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0440\u044f\u043c\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438"],
["STATISTICS","\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430"],["SUBTITLE_FORCED","\u0421\u0443\u0431\u0442\u0438\u0442\u0440\u044b \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e"],["SURROUND","\u041e\u0431\u044a\u0435\u043c\u043d\u044b\u0439 \u0437\u0432\u0443\u043a"],["TOGGLE_STEREOSCOPIC","\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0442\u0435\u0440\u0435\u043e\u0441\u043a\u043e\u043f\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0435\u0436\u0438\u043c"],
["UNDETERMINED_LANGUAGE","\u041d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e"],["UNMUTE","\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0432\u0443\u043a"],["UNRECOGNIZED_LANGUAGE","\u041d\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043e"],["VOLUME","\u0413\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c"]]));a.insert("th",new Map([["AD_DURATION","\u0e23\u0e30\u0e22\u0e30\u0e40\u0e27\u0e25\u0e32\u0e42\u0e06\u0e29\u0e13\u0e32"],["AD_PROGRESS","\u0e42\u0e06\u0e29\u0e13\u0e32 [AD_ON] \u0e08\u0e32\u0e01 [NUM_ADS] \u0e23\u0e32\u0e22\u0e01\u0e32\u0e23"],
["AD_STATISTICS","\u0e2a\u0e16\u0e34\u0e15\u0e34\u0e42\u0e06\u0e29\u0e13\u0e32"],["AD_TIME","\u0e42\u0e06\u0e29\u0e13\u0e32: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u0e2d\u0e31\u0e15\u0e42\u0e19\u0e21\u0e31\u0e15\u0e34"],["BACK","\u0e01\u0e25\u0e31\u0e1a"],["CAPTIONS","\u0e04\u0e33\u0e1a\u0e23\u0e23\u0e22\u0e32\u0e22\u0e41\u0e17\u0e19\u0e40\u0e2a\u0e35\u0e22\u0e07"],["CAST","\u0e41\u0e04\u0e2a\u0e15\u0e4c..."],["CHAPTERS","\u0e1a\u0e17"],["DOWNLOAD_VIDEO_FRAME","\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e40\u0e1f\u0e23\u0e21\u0e27\u0e34\u0e14\u0e35\u0e42\u0e2d"],
["ENTER_LOOP_MODE","\u0e27\u0e19\u0e0b\u0e49\u0e33\u0e27\u0e34\u0e14\u0e35\u0e42\u0e2d\u0e1b\u0e31\u0e08\u0e08\u0e38\u0e1a\u0e31\u0e19"],["ENTER_PICTURE_IN_PICTURE","\u0e40\u0e02\u0e49\u0e32\u0e2a\u0e39\u0e48\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e20\u0e32\u0e1e\u0e0b\u0e49\u0e2d\u0e19\u0e20\u0e32\u0e1e"],["EXIT_FULL_SCREEN","\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e41\u0e1a\u0e1a\u0e40\u0e15\u0e47\u0e21\u0e2b\u0e19\u0e49\u0e32\u0e08\u0e2d"],["EXIT_LOOP_MODE",
"\u0e2b\u0e22\u0e38\u0e14\u0e27\u0e19\u0e0b\u0e49\u0e33\u0e27\u0e34\u0e14\u0e35\u0e42\u0e2d\u0e1b\u0e31\u0e08\u0e08\u0e38\u0e1a\u0e31\u0e19"],["EXIT_PICTURE_IN_PICTURE","\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e20\u0e32\u0e1e\u0e0b\u0e49\u0e2d\u0e19\u0e20\u0e32\u0e1e"],["FAST_FORWARD","\u0e01\u0e23\u0e2d\u0e44\u0e1b\u0e02\u0e49\u0e32\u0e07\u0e2b\u0e19\u0e49\u0e32"],["FULL_SCREEN","\u0e40\u0e15\u0e47\u0e21\u0e2b\u0e19\u0e49\u0e32\u0e08\u0e2d"],["LANGUAGE","\u0e20\u0e32\u0e29\u0e32"],
["LIVE","\u0e2a\u0e14"],["LOOP","\u0e25\u0e39\u0e1b"],["MORE_SETTINGS","\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21"],["MULTIPLE_LANGUAGES","\u0e2b\u0e25\u0e32\u0e22\u0e20\u0e32\u0e29\u0e32"],["MUTE","\u0e1b\u0e34\u0e14\u0e40\u0e2a\u0e35\u0e22\u0e07"],["NOT_APPLICABLE","\u0e44\u0e21\u0e48\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e02\u0e49\u0e2d\u0e07"],["OFF","\u0e1b\u0e34\u0e14"],["ON","\u0e40\u0e1b\u0e34\u0e14"],["PAUSE","\u0e2b\u0e22\u0e38\u0e14\u0e0a\u0e31\u0e48\u0e27\u0e04\u0e23\u0e32\u0e27"],
["PICTURE_IN_PICTURE","\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e20\u0e32\u0e1e\u0e0b\u0e49\u0e2d\u0e19\u0e20\u0e32\u0e1e"],["PLAY","\u0e40\u0e25\u0e48\u0e19"],["PLAYBACK_RATE","\u0e04\u0e27\u0e32\u0e21\u0e40\u0e23\u0e47\u0e27\u0e43\u0e19\u0e01\u0e32\u0e23\u0e40\u0e25\u0e48\u0e19"],["QUALITY","\u0e04\u0e38\u0e13\u0e20\u0e32\u0e1e"],["RECENTER_VR","\u0e08\u0e31\u0e14\u0e01\u0e36\u0e48\u0e07\u0e01\u0e25\u0e32\u0e07\u0e43\u0e2b\u0e21\u0e48"],["REPLAY","\u0e40\u0e25\u0e48\u0e19\u0e0b\u0e49\u0e33"],
["RESOLUTION","\u0e04\u0e27\u0e32\u0e21\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14"],["REWIND","\u0e01\u0e23\u0e2d\u0e01\u0e25\u0e31\u0e1a"],["SEEK","\u0e04\u0e49\u0e19\u0e2b\u0e32"],["SKIP_AD","\u0e02\u0e49\u0e32\u0e21\u0e42\u0e06\u0e29\u0e13\u0e32"],["SKIP_TO_LIVE","\u0e02\u0e49\u0e32\u0e21\u0e44\u0e1b\u0e17\u0e35\u0e48\u0e01\u0e32\u0e23\u0e16\u0e48\u0e32\u0e22\u0e17\u0e2d\u0e14\u0e2a\u0e14"],["STATISTICS","\u0e2a\u0e16\u0e34\u0e15\u0e34"],["SUBTITLE_FORCED","\u0e1a\u0e31\u0e07\u0e04\u0e31\u0e1a"],
["SURROUND","\u0e40\u0e0b\u0e2d\u0e23\u0e4c\u0e23\u0e32\u0e27\u0e14\u0e4c"],["TOGGLE_STEREOSCOPIC","\u0e40\u0e1b\u0e34\u0e14/\u0e1b\u0e34\u0e14\u0e1f\u0e35\u0e40\u0e08\u0e2d\u0e23\u0e4c\u0e2a\u0e32\u0e21\u0e21\u0e34\u0e15\u0e34"],["UNDETERMINED_LANGUAGE","\u0e44\u0e21\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14"],["UNMUTE","\u0e40\u0e1b\u0e34\u0e14\u0e40\u0e2a\u0e35\u0e22\u0e07"],["UNRECOGNIZED_LANGUAGE","\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e23\u0e39\u0e49\u0e08\u0e31\u0e01"],["VOLUME","\u0e23\u0e30\u0e14\u0e31\u0e1a\u0e40\u0e2a\u0e35\u0e22\u0e07"]]));
a.insert("tr",new Map([["AD_DURATION","Reklam s\u00fcresi"],["AD_PROGRESS","[AD_ON]/[NUM_ADS] reklam"],["AD_STATISTICS","Reklam istatistikleri"],["AD_TIME","Reklam: [AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","Otomatik"],["BACK","Geri"],["CAPTIONS","Altyaz\u0131lar"],["CAST","Yay\u0131nla..."],["CHAPTERS","B\u00f6l\u00fcmler"],["DOWNLOAD_VIDEO_FRAME","Video karesini kaydet"],["ENTER_LOOP_MODE","Mevcut videoyu d\u00f6ng\u00fcye al"],["ENTER_PICTURE_IN_PICTURE","Pencere i\u00e7inde Pencere moduna gir"],
["EXIT_FULL_SCREEN","Tam ekrandan \u00e7\u0131k"],["EXIT_LOOP_MODE","Mevcut videonun d\u00f6ng\u00fcs\u00fcn\u00fc durdur"],["EXIT_PICTURE_IN_PICTURE","Pencere \u0130\u00e7inde Pencereden \u00c7\u0131k"],["FAST_FORWARD","\u0130leri sar"],["FULL_SCREEN","Tam ekran"],["LANGUAGE","Dil"],["LIVE","Canl\u0131"],["LOOP","D\u00f6ng\u00fc"],["MORE_SETTINGS","Daha fazla ayar"],["MULTIPLE_LANGUAGES","Birden \u00e7ok dil"],["MUTE","Sesi kapat"],["NOT_APPLICABLE","Ge\u00e7erli de\u011fil"],["OFF","Kapal\u0131"],
["ON","A\u00e7\u0131k"],["PAUSE","Duraklat"],["PICTURE_IN_PICTURE","Pencere \u0130\u00e7inde Pencere"],["PLAY","Oynat"],["PLAYBACK_RATE","\u00c7alma h\u0131z\u0131"],["QUALITY","Kalite"],["RECENTER_VR","Ortala"],["REPLAY","Tekrar Oynat"],["RESOLUTION","\u00c7\u00f6z\u00fcn\u00fcrl\u00fck"],["REWIND","Geri sar"],["SEEK","Ara"],["SKIP_AD","Reklam\u0131 Atla"],["SKIP_TO_LIVE","Canl\u0131 yay\u0131na atla"],["STATISTICS","\u0130statistikler"],["SUBTITLE_FORCED","Zorunlu"],["SURROUND","Surround"],["TOGGLE_STEREOSCOPIC",
"Stereoskopik modu a\u00e7/kapat"],["UNDETERMINED_LANGUAGE","Belirsiz"],["UNMUTE","Sesi a\u00e7"],["UNRECOGNIZED_LANGUAGE","Tan\u0131nmayan"],["VOLUME","Ses"]]));a.insert("zh",new Map([["AD_DURATION","\u5e7f\u544a\u6301\u7eed\u65f6\u95f4"],["AD_PROGRESS","\u5e7f\u544a [AD_ON]/[NUM_ADS]"],["AD_STATISTICS","\u5e7f\u544a\u7edf\u8ba1\u4fe1\u606f"],["AD_TIME","\u5e7f\u544a\uff1a[AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u81ea\u52a8"],["BACK","\u8fd4\u56de"],["CAPTIONS","\u5b57\u5e55"],["CAST",
"\u6295\u653e\u2026"],["CHAPTERS","\u7ae0\u8282"],["DOWNLOAD_VIDEO_FRAME","\u4fdd\u5b58\u89c6\u9891\u5e27"],["ENTER_LOOP_MODE","\u5faa\u73af\u64ad\u653e\u5f53\u524d\u89c6\u9891"],["ENTER_PICTURE_IN_PICTURE","\u8fdb\u5165\u201c\u753b\u4e2d\u753b\u201d\u6a21\u5f0f"],["EXIT_FULL_SCREEN","\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f"],["EXIT_LOOP_MODE","\u505c\u6b62\u5faa\u73af\u64ad\u653e\u5f53\u524d\u89c6\u9891"],["EXIT_PICTURE_IN_PICTURE","\u9000\u51fa\u201c\u753b\u4e2d\u753b\u201d\u6a21\u5f0f"],["FAST_FORWARD",
"\u5feb\u8fdb"],["FULL_SCREEN","\u5168\u5c4f"],["LANGUAGE","\u8bed\u8a00"],["LIVE","\u76f4\u64ad"],["LOOP","\u5faa\u73af\u64ad\u653e"],["MORE_SETTINGS","\u66f4\u591a\u8bbe\u7f6e"],["MULTIPLE_LANGUAGES","\u591a\u79cd\u8bed\u8a00"],["MUTE","\u9759\u97f3"],["NOT_APPLICABLE","\u4e0d\u9002\u7528"],["OFF","\u5173\u95ed"],["ON","\u5f00\u542f"],["PAUSE","\u6682\u505c"],["PICTURE_IN_PICTURE","\u753b\u4e2d\u753b"],["PLAY","\u64ad\u653e"],["PLAYBACK_RATE","\u64ad\u653e\u901f\u5ea6"],["QUALITY","\u753b\u8d28"],
["RECENTER_VR","\u91cd\u65b0\u7f6e\u4e2d"],["REPLAY","\u91cd\u653e"],["RESOLUTION","\u5206\u8fa8\u7387"],["REWIND","\u5feb\u9000"],["SEEK","\u8fdb\u5ea6"],["SKIP_AD","\u8df3\u8fc7\u5e7f\u544a"],["SKIP_TO_LIVE","\u8df3\u81f3\u5f53\u524d\u76f4\u64ad"],["STATISTICS","\u7edf\u8ba1\u4fe1\u606f"],["SUBTITLE_FORCED","\u5df2\u5f3a\u5236\u663e\u793a"],["SURROUND","\u73af\u7ed5\u58f0"],["TOGGLE_STEREOSCOPIC","\u5207\u6362\u7acb\u4f53\u58f0"],["UNDETERMINED_LANGUAGE","\u672a\u786e\u5b9a"],["UNMUTE","\u53d6\u6d88\u9759\u97f3"],
["UNRECOGNIZED_LANGUAGE","\u65e0\u6cd5\u8bc6\u522b"],["VOLUME","\u97f3\u91cf"]]));a.insert("zh-TW",new Map([["AD_DURATION","\u5ee3\u544a\u9577\u5ea6"],["AD_PROGRESS","\u5ee3\u544a [AD_ON]/[NUM_ADS]"],["AD_STATISTICS","\u5ee3\u544a\u7d71\u8a08\u8cc7\u6599"],["AD_TIME","\u5ee3\u544a\uff1a[AD_TIME]"],["AIRPLAY","AirPlay"],["AUTO_QUALITY","\u81ea\u52d5"],["BACK","\u8fd4\u56de"],["CAPTIONS","\u5b57\u5e55"],["CAST","\u6295\u653e..."],["CHAPTERS","\u7ae0\u7bc0"],["DOWNLOAD_VIDEO_FRAME","\u5132\u5b58\u5f71\u7247\u5f71\u683c"],
["ENTER_LOOP_MODE","\u5faa\u74b0\u64ad\u653e\u76ee\u524d\u7684\u5f71\u7247"],["ENTER_PICTURE_IN_PICTURE","\u9032\u5165\u5b50\u6bcd\u756b\u9762"],["EXIT_FULL_SCREEN","\u9000\u51fa\u5168\u87a2\u5e55\u6a21\u5f0f"],["EXIT_LOOP_MODE","\u505c\u6b62\u5faa\u74b0\u64ad\u653e\u76ee\u524d\u7684\u5f71\u7247"],["EXIT_PICTURE_IN_PICTURE","\u96e2\u958b\u5b50\u6bcd\u756b\u9762"],["FAST_FORWARD","\u5feb\u8f49"],["FULL_SCREEN","\u5168\u87a2\u5e55"],["LANGUAGE","\u8a9e\u8a00"],["LIVE","\u76f4\u64ad"],["LOOP","\u5faa\u74b0\u64ad\u653e"],
["MORE_SETTINGS","\u986f\u793a\u66f4\u591a\u8a2d\u5b9a"],["MULTIPLE_LANGUAGES","\u591a\u7a2e\u8a9e\u8a00"],["MUTE","\u975c\u97f3"],["NOT_APPLICABLE","\u4e0d\u9069\u7528"],["OFF","\u95dc\u9589"],["ON","\u958b\u555f"],["PAUSE","\u66ab\u505c"],["PICTURE_IN_PICTURE","\u5b50\u6bcd\u756b\u9762"],["PLAY","\u64ad\u653e"],["PLAYBACK_RATE","\u64ad\u653e\u901f\u5ea6"],["QUALITY","\u97f3\u8cea"],["RECENTER_VR","\u91cd\u65b0\u7f6e\u4e2d"],["REPLAY","\u91cd\u64ad"],["RESOLUTION","\u89e3\u6790\u5ea6"],["REWIND",
"\u5012\u8f49"],["SEEK","\u641c\u5c0b"],["SKIP_AD","\u7565\u904e\u5ee3\u544a"],["SKIP_TO_LIVE","\u8df3\u81f3\u5f53\u524d\u76f4\u64ad"],["STATISTICS","\u7d71\u8a08\u8cc7\u6599"],["SUBTITLE_FORCED","\u5f37\u5236\u986f\u793a"],["SURROUND","\u74b0\u5834\u97f3\u6548"],["TOGGLE_STEREOSCOPIC","\u5207\u63db\u7acb\u9ad4\u5f71\u50cf"],["UNDETERMINED_LANGUAGE","\u4e0d\u660e"],["UNMUTE","\u53d6\u6d88\u975c\u97f3"],["UNRECOGNIZED_LANGUAGE","\u7121\u6cd5\u8fa8\u8b58"],["VOLUME","\u97f3\u91cf"]]))};
shaka.ui.Locales.Ids={AIRPLAY:"AIRPLAY",EXIT_PICTURE_IN_PICTURE:"EXIT_PICTURE_IN_PICTURE",BACK:"BACK",MUTE:"MUTE",RESOLUTION:"RESOLUTION",MORE_SETTINGS:"MORE_SETTINGS",UNMUTE:"UNMUTE",MULTIPLE_LANGUAGES:"MULTIPLE_LANGUAGES",SKIP_NEXT:"SKIP_NEXT",LANGUAGE:"LANGUAGE",ENTER_LOOP_MODE:"ENTER_LOOP_MODE",ON:"ON",SURROUND:"SURROUND",SEEK:"SEEK",PICTURE_IN_PICTURE:"PICTURE_IN_PICTURE",PLAYBACK_RATE:"PLAYBACK_RATE",TOGGLE_STEREOSCOPIC:"TOGGLE_STEREOSCOPIC",SKIP_PREVIOUS:"SKIP_PREVIOUS",CAST:"CAST",AUTO_QUALITY:"AUTO_QUALITY",
ENTER_PICTURE_IN_PICTURE:"ENTER_PICTURE_IN_PICTURE",EXIT_LOOP_MODE:"EXIT_LOOP_MODE",PAUSE:"PAUSE",SUBTITLE_FORCED:"SUBTITLE_FORCED",FAST_FORWARD:"FAST_FORWARD",UNDETERMINED_LANGUAGE:"UNDETERMINED_LANGUAGE",SKIP_AD:"SKIP_AD",SKIP_TO_LIVE:"SKIP_TO_LIVE",STATISTICS:"STATISTICS",REPLAY:"REPLAY",REWIND:"REWIND",QUALITY:"QUALITY",DOWNLOAD_VIDEO_FRAME:"DOWNLOAD_VIDEO_FRAME",AD_PROGRESS:"AD_PROGRESS",UNRECOGNIZED_LANGUAGE:"UNRECOGNIZED_LANGUAGE",VOLUME:"VOLUME",EXIT_FULL_SCREEN:"EXIT_FULL_SCREEN",LOOP:"LOOP",
FULL_SCREEN:"FULL_SCREEN",NOT_APPLICABLE:"NOT_APPLICABLE",OFF:"OFF",LIVE:"LIVE",AD_TIME:"AD_TIME",CAPTIONS:"CAPTIONS",CHAPTERS:"CHAPTERS",AD_STATISTICS:"AD_STATISTICS",RECENTER_VR:"RECENTER_VR",PLAY:"PLAY",AD_DURATION:"AD_DURATION"};shaka.abr={};shaka.abr.Ewma=function(a){goog.asserts.assert(a>0,"expected halfLife to be positive");this.logHalf_=Math.log(.5);this.alpha_=Math.exp(this.logHalf_/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(this.logHalf_/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.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$30:void 0},d=a.next()){e.item$jscomp$30=d.value;d=b.findIndex(function(f){return function(g){return c(f.item$jscomp$30,g)}}(e));if(d==-1)return!1;b[d]=b[b.length-1];b.pop()}return b.length==0};
shaka.util.ArrayUtils.partition=function(a,b){var c=[],d=[];a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next())e=e.value,b(e)?c.push(e):d.push(e);return[c,d]};shaka.util.ArrayUtils.binarySearch=function(a,b){for(var c=0,d=a.length;c<d;){var e=c+d>>>1;b(a[e])?c=e+1:d=e}return c};
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.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.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;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.removeBuffer=function(a,b,c){a===shaka.util.ManifestParserUtils.ContentType.VIDEO&&this.dec_&&this.dec_.flushBuffer(b,c)};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.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","audio/x-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))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.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.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];var d=b.split(",");if(b=a.find(function(e){return d.includes(e.tagName)}))return b;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(g,h){h=h===void 0?!1:h;for(var k=[];a[e];)if(a.charCodeAt(e)==60){if(a.charCodeAt(e+1)===47){h=e+2;e=a.indexOf(">",e);h=a.substring(h,e);var l=h.indexOf(g);if(l==-1){var m=g.indexOf(".");m>0&&(g=g.substring(0,m),l=h.indexOf(g))}if(l==-1)throw k=a.substring(0,e).split("\n"),Error("Unexpected close tag\nLine: "+(k.length-1)+"\nColumn: "+(k[k.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"){l=a.indexOf("]]\x3e",e);l==-1?(k.push(a.substr(e+9)),e=a.length):(k.push(a.substring(e+9,l)),e=l+3);continue}e++;continue}if(f>512)throw Error("XML is too deeply nested");f++;a:{m=h;e++;var n=d(),p={};for(l=[];a.charCodeAt(e)!==62&&a[e];){var q=a.charCodeAt(e);if(q>64&&q<91||q>96&&
q<123){q=d();for(var r=a.charCodeAt(e);r&&r!==39&&r!==34&&!(r>64&&r<91||r>96&&r<123)&&r!==62;)e++,r=a.charCodeAt(e);var t=e+1;e=a.indexOf(a[e],t);t=(" "+a.slice(t,e)).slice(1);if(r===39||r===34){if(e===-1){m={tagName:n,attributes:p,children:l,parent:null};if(b)for(n=0;n<l.length;n++)typeof l[n]!=="string"&&(l[n].parent=m);l=m;break a}}else t=null,e--;q.startsWith("xmlns:")&&(r=q.split(":"),shaka.util.TXml.setKnownNameSpace(t,r[1]));n==="tt"&&q==="xml:space"&&t==="preserve"&&(m=!0);p[q]=t}e++}a.charCodeAt(e-
1)!==47?(e++,l=c(n,m)):e++;m={tagName:n,attributes:p,children:l,parent:null};n=l.length;for(p=0;p<n;p++)q=l[p],typeof q!=="string"?b&&(q.parent=m):p==n-1&&q=="\n"&&l.pop();l=m}f--;k.push(l);if(typeof l==="string")break;l.tagName[0]==="?"&&l.children&&(k.push.apply(k,(0,$jscomp.arrayFromIterable)(l.children)),l.children=[])}else l=e,e=a.indexOf("<",e)-1,e===-2&&(e=a.length),l=(" "+a.slice(l,e+1)).slice(1),h?l.length>0&&k.push(l):k.length&&l.length==1&&l[0]=="\n"?k.push(l):l.trim().length>0&&k.push(l),
e++;return k}function d(){for(var g=e;"\r\n\t>/= ".indexOf(a[e])===-1&&a[e];)e++;return(" "+a.slice(g,e)).slice(1)}var e=0,f=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);var c=[];a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())d=d.value,typeof d==="string"&&c.push(d);c=c.join("");return c===""?null:b.htmlUnescape(c)};
shaka.util.TXml.getContents=function(a){for(var b=(0,$jscomp.makeIterator)(a.children),c=b.next();!c.done;c=b.next())if(typeof c.value!=="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||a===""&&d!==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";case a==="lvc1":return"lcevc"}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"||a==="audio/x-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.external_=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,e){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(e):shaka.Deprecate.deprecateFeature(5,"Text parsers w/ setManifestType",'Text parsers should have a "setManifestType" method!'),this.segmentRelativeVttTiming_=d,this.external_=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,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1)return goog.asserts.assert(e.parser_,"The parser should already be initialized"),q.yield(Promise.resolve(),2);if(!e.parser_||!e.displayer_)return q.return();if(b==null||c==null)return e.parser_.parseInit(shaka.util.BufferUtils.toUint8(a)),q.return();f=e.external_?0:e.timestampOffset_;g=e.segmentRelativeVttTiming_||e.external_?
b:e.timestampOffset_;h={periodStart:f,segmentStart:b,segmentEnd:c,vttOffset:g};k=e.parser_.parseMedia(shaka.util.BufferUtils.toUint8(a),h,d,[]);l=(0,$jscomp.makeIterator)(k);for(m=l.next();!m.done;m=l.next())n=m.value,e.modifyCueCallback_(n,d||null,h);p=k.filter(function(r){return r.startTime>=e.appendWindowStart_&&r.startTime<e.appendWindowEnd_});e.displayer_.append(p);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_);q.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.getNextAddressJsc()==1)return e.yield(Promise.resolve(),2);if(a>=b||c&&(d.removeClosedCaptions_(a,b),d.selectedClosedCaptionId_===""))return e.return();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.Timer=function(a){this.onTick_=a;this.cancelPending_=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.schedule_(function(){b.onTick_()},a);return this};shaka.util.Timer.prototype.tickEvery=function(a){this.stop();goog.DEBUG&&shaka.util.Timer.activeTimers.set(this,Error("Timer created").stack);this.scheduleRepeating_(a);return this};
shaka.util.Timer.prototype.stop=function(){var a;(a=this.cancelPending_)==null||a.call(this);this.cancelPending_=null;goog.DEBUG&&shaka.util.Timer.activeTimers.delete(this)};shaka.util.Timer.prototype.schedule_=function(a,b){var c=!0,d=null;this.cancelPending_=function(){clearTimeout(d);c=!1};d=setTimeout(function(){c&&a()},b*1E3)};shaka.util.Timer.prototype.scheduleRepeating_=function(a){var b=this;this.schedule_(function(){b.scheduleRepeating_(a);b.onTick_()},a)};
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.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(t){return function(u){return u.codecs.startsWith(t.textFormat)||u.mimeType.startsWith(t.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;h=(0,$jscomp.makeIterator)(h);for(c=h.next();!c.done;c=h.next())c=c.value,b.push(String(c.video.width||0),c);var m=[];b.forEach(function(t,u){t=0;var w=[];u=(0,$jscomp.makeIterator)(u);for(var v=u.next(),x={};!v.done;x={variant$jscomp$4:void 0},v=u.next())x.variant$jscomp$4=v.value,v=d.filter(function(y){return function(A){return y.variant$jscomp$4.decodingInfos[0][A]}}(x)).length,v>t?(t=v,w=[x.variant$jscomp$4]):v==t&&w.push(x.variant$jscomp$4);m.push.apply(m,
(0,$jscomp.arrayFromIterable)(w))});h=m}b=new Set;c=(0,$jscomp.makeIterator)(h);for(f=c.next();!f.done;f=c.next())f=f.value,f.video&&b.add(f.video);if(b.size){var n={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};f=Array.from(b).sort(function(t,u){return t.bandwidth&&u.bandwidth&&t.bandwidth!=u.bandwidth?t.bandwidth-u.bandwidth:t.width!=u.width?t.width-u.width:t.codecs&&u.codecs?(t=g.getNormalizedCodec(t.codecs),u=g.getNormalizedCodec(u.codecs),
(n[t]||1)-(n[u]||1)):0});var p=[];b=new Map;c=function(t){var u=[String(t.width||""),String(t.height||""),String(Math.round(t.frameRate||0)),t.hdr||"",t.fastSwitching];t.dependencyStream&&u.push(t.dependencyStream.baseOriginalId||"");t.roles&&u.push(t.roles.sort().join("_"));return u.join(";")};f=(0,$jscomp.makeIterator)(f);for(e=f.next();!e.done;e=f.next()){e=e.value;k=c(e);l=b.get(k)||[];if(l.length){var q=g.getNormalizedCodec(l[l.length-1].codecs),r=g.getNormalizedCodec(e.codecs);q==r&&(l.push(e),
p.push(e.id))}else l.push(e),p.push(e.id);b.set(k,l)}a.variants=h.filter(function(t){var u=t.video;return u&&!p.includes(u.id)?(shaka.log.debug("Dropping Variant (better codec available)",t),!1):!0})}else a.variants=h};
shaka.util.StreamUtils.choosePreferredCodecs=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next(),e={};!d.done;e={videoCodec$jscomp$4:void 0},d=b.next())if(e.videoCodec$jscomp$4=d.value,d=a.filter(function(f){return function(g){return g.video&&g.video.codecs.startsWith(f.videoCodec$jscomp$4)}}(e)),d.length){a=d;break}c=(0,$jscomp.makeIterator)(c);b=c.next();for(d={};!b.done;d={audioCodec$jscomp$4:void 0},b=c.next())if(d.audioCodec$jscomp$4=b.value,b=a.filter(function(f){return function(g){return g.audio&&
g.audio.codecs.startsWith(f.audioCodec$jscomp$4)}}(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(g,h,k){return g>=h&&g<=k};if(a&&a.video&&a.video.width&&a.video.height){var e=a.video.width,f=a.video.height;f>e&&(f=(0,$jscomp.makeIterator)([f,e]),e=f.next().value,f=f.next().value);if(!d(e,b.minWidth,Math.min(b.maxWidth,c.width))||!d(f,b.minHeight,Math.min(b.maxHeight,c.height))||!d(e*f,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.getNextAddressJsc()==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.getNextAddressJsc()==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.getNextAddressJsc()==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,u,w,v,x,y,A,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){switch(D.getNextAddressJsc()){case 1:if(e=a.some(function(z){return z.decodingInfos.length}))return shaka.log.debug("Already got the variants' decodingInfo."),D.return();f=(0,$jscomp.makeIterator)(d);g=f.next();h={};case 2:if(g.done){D.jumpTo(4);break}h.preferredKeySystem=g.value;k=!1;l=(0,$jscomp.makeIterator)(a);m=l.next();
case 5:if(m.done){D.jumpTo(7);break}n=m.value;p=shaka.util.StreamUtils.getDecodingConfigs_(n,b,c).filter(function(z){return function(C){C=C[0];C=C.keySystemConfiguration&&C.keySystemConfiguration.keySystem;return!C||C===z.preferredKeySystem}}(h));q=(0,$jscomp.makeIterator)(p);r=q.next();case 8:if(r.done){D.jumpTo(10);break}t=r.value;return D.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(n,t),9);case 9:r=q.next();D.jumpTo(8);break;case 10:n.decodingInfos.some(function(z){return z.supported})&&
(k=!0);m=l.next();D.jumpTo(5);break;case 7:if(k)return D.return();h={preferredKeySystem:void 0};g=f.next();D.jumpTo(2);break;case 4:u=(0,$jscomp.makeIterator)(a),w=u.next();case 12:if(w.done){D.jumpTo(0);break}v=w.value;x=shaka.util.StreamUtils.getDecodingConfigs_(v,b,c).filter(function(z){z=z[0];z=z.keySystemConfiguration&&z.keySystemConfiguration.keySystem;return!z||!d.includes(z)});y=(0,$jscomp.makeIterator)(x);A=y.next();case 15:if(A.done){w=u.next();D.jumpTo(12);break}B=A.value;return D.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(v,
B),16);case 16:A=y.next(),D.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 u=r.next();!u.done;u=r.next()){u=u.value;if(u.initData&&
u.initData.length){for(var w=new Set,v=(0,$jscomp.makeIterator)(u.initData),x=v.next();!x.done;x=v.next())w.add(x.value.initDataType);w.size>1&&shaka.log.v2("DrmInfo contains more than one initDataType,","and we use the initDataType of the first initData.",u);t.initDataType=u.initData[0].initDataType}u.distinctiveIdentifierRequired&&(t.distinctiveIdentifier="required");u.persistentStateRequired&&(t.persistentState="required");u.sessionType&&(t.sessionTypes=[u.sessionType]);d&&(t.audio?(u.encryptionScheme&&
(t.audio.encryptionScheme=t.audio.encryptionScheme||u.encryptionScheme),t.audio.robustness=t.audio.robustness||u.audioRobustness):(t.audio={robustness:u.audioRobustness},u.encryptionScheme&&(t.audio.encryptionScheme=u.encryptionScheme)),t.audio.robustness==""&&delete t.audio.robustness);e&&(t.video?(u.encryptionScheme&&(t.video.encryptionScheme=t.video.encryptionScheme||u.encryptionScheme),t.video.robustness=t.video.robustness||u.videoRobustness):(t.video={robustness:u.videoRobustness},u.encryptionScheme&&
(t.video.encryptionScheme=u.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.getNextAddressJsc()){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.getYieldResultJsc(),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.pixelAspectRatio=f.pixelAspectRatio||a.pixelAspectRatio,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&&(a.kind=="description"&&(b.accessibilityPurpose=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED),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(){a.config_.useNetworkInformation&&navigator.onLine&&(a.bandwidthEstimator_=new shaka.abr.EwmaBandwidthEstimator,a.config_&&a.bandwidthEstimator_.configure(a.config_.advanced),a.trySuggestStreams())});
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_&&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));c&&e&&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;this.variants_.length&&this.trySuggestStreams()};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&&this.switch_&&(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)&&(c=c.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.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.getNextAddressJsc()==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.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,u=!1,w;return shaka.util.AbortableOperation.notAbortable(d.attempt()).chain(function(){if(h.destroyed_)return shaka.util.AbortableOperation.aborted();w=Date.now();var v=shaka.net.NetworkingEngine.RequestType.SEGMENT,x=0;b.requestStartTime=Date.now();var y=n(b.uris[e],b,a,function(D,z,C){q&&q.stop();r&&r.tickAfter(B/1E3);if(h.onProgressUpdated_&&a==v){x++;b.packetNumber=x;var E=h.allowSwitch_(c);h.onProgressUpdated_(D,z,E,b,c);m=!0;g.setBytes(C)}},function(D){u=!0;b.timeToFirstByte=
Date.now()-b.requestStartTime;if(h.onHeadersReceived_)h.onHeadersReceived_(D,b,a)},{minBytesForProgressEvents:h.config_.minBytesForProgressEvents});if(!p)return y;var A=b.retryParameters.connectionTimeout;A&&(q=new shaka.util.Timer(function(){t=!0;y.abort()}),q.tickAfter(A/1E3));var B=b.retryParameters.stallTimeout;B&&(r=new shaka.util.Timer(function(){t=!0;y.abort()}));return y}).chain(function(v){q&&q.stop();r&&r.stop();v.timeMs==void 0&&(v.timeMs=Date.now()-w);var x=v.headers[shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_];
if(x){var y=new goog.Uri(v.uri);h.hostCommonAccessTokenMap_.set(y.getDomain(),x)}x={response:v,gotProgress:m};if(!u&&h.onHeadersReceived_)h.onHeadersReceived_(v.headers,b,a);if(h.onDownloadCompleted_)h.onDownloadCompleted_(b,v);return x},function(v){q&&q.stop();r&&r.stop();if(h.onDownloadFailed_){var x=null,y=0;v instanceof shaka.util.Error&&(x=v,v.code==shaka.util.Error.Code.BAD_HTTP_STATUS&&(y=v.data[1]));h.onDownloadFailed_(b,x,y,t)}if(h.destroyed_)return shaka.util.AbortableOperation.aborted();
t&&(v=new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,b.uris[e],a));if(v instanceof shaka.util.Error){if(v.code==shaka.util.Error.Code.OPERATION_ABORTED)throw v;if(v.code==shaka.util.Error.Code.ATTEMPTS_EXHAUSTED)throw goog.asserts.assert(f,"Should have last error"),f;if(v.severity==shaka.util.Error.Severity.RECOVERABLE){x=(new Map).set("error",v);x=new shaka.util.FakeEvent("retry",x);x.cancelable=!0;h.dispatchEvent(x);if(x.defaultPrevented)throw v;
e=(e+1)%b.uris.length;return h.send_(a,b,c,d,e,v,g)}}throw v;})};
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.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.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.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.boxes=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())this.box(c.value,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,"boxes",shaka.util.Mp4Parser.prototype.boxes);goog.exportProperty(shaka.util.Mp4Parser.prototype,"box",shaka.util.Mp4Parser.prototype.box);shaka.util.Mp4Parser.BoxType_={BASIC_BOX:0,FULL_BOX:1};shaka.util.Pssh=function(a){var b=this;this.systemIds=[];this.data=[];(new shaka.util.Mp4Parser).boxes(["moov","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);a=a.reader.readBytes(16,!1);
this.systemIds.push(shaka.util.Uint8ArrayUtils.toHex(a))}};
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.getNextAddressJsc()){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.alwaysWarn("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.getNextAddressJsc()==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,u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){if(A.getNextAddressJsc()==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(B){return B.video&&B.video.drmInfos.length||B.audio&&B.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(B,D){var z=[];B=(0,$jscomp.makeIterator)(B);for(var C=B.next();!C.done;C=B.next()){C=C.value;var E=C[D]||f.has(C.keySystem)&&f.get(C.keySystem)[D]||"";
E==""&&shaka.drm.DrmUtils.isWidevineKeySystem(C.keySystem)&&(D=="audioRobustness"?E=[c.config_.defaultAudioRobustnessForWidevine]:D=="videoRobustness"&&(E=[c.config_.defaultVideoRobustnessForWidevine]));if(typeof E==="string")z.push(C);else if(Array.isArray(E)){E.length===0&&(E=[""]);E=(0,$jscomp.makeIterator)(E);for(var G=E.next();!G.done;G=E.next()){var I={};z.push(Object.assign({},C,(I[D]=G.value,I)))}}}return z};t=new WeakSet;u=(0,$jscomp.makeIterator)(a);for(w=u.next();!w.done;w=u.next())v=w.value,
v.video&&!t.has(v.video)&&(v.video.drmInfos=r(v.video.drmInfos,"videoRobustness"),v.video.drmInfos=r(v.video.drmInfos,"audioRobustness"),t.add(v.video)),v.audio&&!t.has(v.audio)&&(v.audio.drmInfos=r(v.audio.drmInfos,"videoRobustness"),v.audio.drmInfos=r(v.audio.drmInfos,"audioRobustness"),t.add(v.audio));return A.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,A.return(Promise.resolve());y=c.queryMediaKeys_(a);return A.return(d?y:y.catch(function(){}))})};
shaka.drm.DrmEngine.prototype.attachMediaKeys_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){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.getNextAddressJsc()==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.getNextAddressJsc()==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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc())||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.getNextAddressJsc()==1)return goog.asserts.assert(b.mediaKeys_,"Must call init() before removeSession"),f.yield(b.loadOfflineSession_(a,{initData:null,initDataType:null}),2);if(f.getNextAddressJsc()!=3){c=f.getYieldResultJsc();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.getNextAddressJsc()==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.getNextAddressJsc()!=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.updateCurrentDrmInfo=function(a){this.currentDrmInfo_&&(this.currentDrmInfo_.mediaTypes!==a.mediaTypes&&(this.currentDrmInfo_.mediaTypes=a.mediaTypes),shaka.drm.DrmUtils.isClearKeyWihRawKey(a)&&(this.currentDrmInfo_=this.createDrmInfoByInfos_(this.currentDrmInfo_.keySystem,[this.currentDrmInfo_,a])))};
shaka.drm.DrmEngine.prototype.newInitData=function(a,b){if(b.length){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}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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc();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.getNextAddressJsc()){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.getYieldResultJsc(),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});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_:!this.initializedForStorage_&&this.config_.delayLicenseRequestUntilPlayed};
shaka.drm.DrmEngine.prototype.waitForActiveRequests=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.getNextAddressJsc()==1?!a.hasInitData_||a.delayLicenseRequest_()?b.jumpTo(0):b.yield(a.allSessionsLoaded_,3):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,u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){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();A.setCatchFinallyBlocks(2);p=b.playerInterface_.netEngine.request(h,k,{isPreload:b.isPreload_()});b.activeRequests_.push(p);return A.yield(p.promise,4);case 4:n=A.getYieldResultJsc();shaka.util.ArrayUtils.remove(b.activeRequests_,p);A.leaveTryBlock(3);break;case 2:q=A.enterCatchBlock();if(b.destroyer_.destroyed())return A.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 A.return();case 3:if(b.destroyer_.destroyed())return A.return();b.licenseTimeSeconds_+=(Date.now()-m)/1E3;b.config_.logLicenseExchange&&(u=shaka.util.Uint8ArrayUtils.toBase64(n.data),shaka.log.info("EME license response",u));A.setCatchFinallyBlocks(5);shaka.log.v1("Updating session",c.sessionId);return A.yield(c.update(n.data),7);case 7:A.leaveTryBlock(6);break;case 5:return v=(w=A.enterCatchBlock())&&w.message||String(w),x=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.LICENSE_RESPONSE_REJECTED,v),b.onError_(x),e&&e.updatePromise&&e.updatePromise.reject(x),A.return();case 6:if(b.destroyer_.destroyed())return A.return();y=new shaka.util.FakeEvent("drmsessionupdate");b.playerInterface_.onEvent(y);e&&(e.updatePromise&&e.updatePromise.resolve(),b.setLoadSessionTimeoutTimer_(e));A.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,u,w,v,x,y,A,B,D,z,C,E,G,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(F){if(F.getNextAddressJsc()==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 F.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(J,K,H){var M,L,N,P,Q,O,S,V,U,X,Y,T,W;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.getNextAddressJsc()){case 1:R.setCatchFinallyBlocks(2);if(!r.createMediaKeysWhenCheckingSupport())throw Error("Suppressing Firefox Windows DRM in testing!");
return R.yield(K.createMediaKeys(),5);case 5:M=R.getYieldResultJsc();case 4:R.leaveTryBlock(3);break;case 2:return R.enterCatchBlock(),R.return();case 3:N=(L=K.getConfiguration().sessionTypes)?L.includes("persistent-license"):!1;r.misreportsSupportForPersistentLicenses()&&(N=!1);P=K.getConfiguration().videoCapabilities;Q=K.getConfiguration().audioCapabilities;O={persistentState:N,encryptionSchemes:[],videoRobustnessLevels:[],audioRobustnessLevels:[],minHdcpVersions:[]};q.get(J)?O=q.get(J):q.set(J,
O);(S=P[0].encryptionScheme)&&!O.encryptionSchemes.includes(S)&&O.encryptionSchemes.push(S);(V=P[0].robustness)&&!O.videoRobustnessLevels.includes(V)&&O.videoRobustnessLevels.push(V);(U=Q[0].robustness)&&!O.audioRobustnessLevels.includes(U)&&O.audioRobustnessLevels.push(U);if(!(H&&"getStatusForPolicy"in M)){R.jumpTo(0);break}X=(0,$jscomp.makeIterator)(f);Y=X.next();case 7:if(Y.done){R.jumpTo(0);break}T=Y.value;if(O.minHdcpVersions.includes(T)){R.jumpTo(8);break}return R.yield(M.getStatusForPolicy({minHdcpVersion:T}),
10);case 10:if(W=R.getYieldResultJsc(),W=="usable")O.minHdcpVersions.includes(T)||O.minHdcpVersions.push(T);else{R.jumpTo(0);break}case 8:Y=X.next(),R.jumpTo(7)}})};u=function(J,K,H,M,L){L=L===void 0?!1:L;var N,P,Q,O,S,V,U,X,Y,T,W;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.getNextAddressJsc()){case 1:R.setCatchFinallyBlocks(2);N=shaka.util.ObjectUtils.cloneObject(n);P=(0,$jscomp.makeIterator)(N.videoCapabilities);for(Q=P.next();!Q.done;Q=P.next())O=Q.value,O.encryptionScheme=
K,O.robustness=H;S=(0,$jscomp.makeIterator)(N.audioCapabilities);for(V=S.next();!V.done;V=S.next())U=V.value,U.encryptionScheme=K,U.robustness=M;X=shaka.util.ObjectUtils.cloneObject(N);X.persistentState="required";X.sessionTypes=["persistent-license"];Y=[X,N];W=shaka.device.DeviceFactory.getDevice();return W.getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE?R.yield(shaka.util.Functional.promiseWithTimeout(5,navigator.requestMediaKeySystemAccess(J,Y)),7):R.yield(navigator.requestMediaKeySystemAccess(J,
Y),6);case 6:T=R.getYieldResultJsc();R.jumpTo(5);break;case 7:T=R.getYieldResultJsc();case 5:return R.yield(t(J,T,L),8);case 8:R.leaveTryBlock(0);break;case 2:R.enterCatchBlock(),R.jumpToEnd()}})};w=function(J){return shaka.device.DeviceFactory.getDevice().getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&shaka.drm.DrmUtils.isClearKeySystem(J)?!1:!0};v=[];x=(0,$jscomp.makeIterator)(a);for(y=x.next();!y.done;y=x.next())if(A=y.value,q.set(A,null),w(A)){B=!0;D=(0,$jscomp.makeIterator)(p);
for(z=D.next();!z.done;z=D.next())C=z.value,v.push(u(A,C,"","",B)),B=!1;E=(0,$jscomp.makeIterator)(k[A]||[]);for(G=E.next();!G.done;G=E.next())I=G.value,v.push(u(A,null,I,"")),v.push(u(A,null,"",I))}return F.yield(Promise.all(v),2)}return F.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.getNextAddressJsc()==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.getNextAddressJsc()!=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.getNextAddressJsc()==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.getNextAddressJsc()!=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,mediaTypes:b[0].mediaTypes};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$10:void 0},l=a.next()){m.drmInfo$jscomp$10=l.value;b.includes(m.drmInfo$jscomp$10.encryptionScheme)||b.push(m.drmInfo$jscomp$10.encryptionScheme);shaka.drm.DrmUtils.isClearKeySystem(m.drmInfo$jscomp$10.keySystem)&&m.drmInfo$jscomp$10.licenseServerUri.startsWith("data:application/json;base64,")?k.includes(m.drmInfo$jscomp$10.licenseServerUri)||k.push(m.drmInfo$jscomp$10.licenseServerUri):
c.includes(m.drmInfo$jscomp$10.licenseServerUri)||c.push(m.drmInfo$jscomp$10.licenseServerUri);e.includes(m.drmInfo$jscomp$10.serverCertificateUri)||e.push(m.drmInfo$jscomp$10.serverCertificateUri);m.drmInfo$jscomp$10.serverCertificate&&(d.some(function(q){return function(r){return shaka.util.BufferUtils.equal(r,q.drmInfo$jscomp$10.serverCertificate)}}(m))||d.push(m.drmInfo$jscomp$10.serverCertificate));if(m.drmInfo$jscomp$10.initData){l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$10.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$10.keyIds)for(l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$10.keyIds),n=l.next();!n.done;n=l.next())g.add(n.value);if(m.drmInfo$jscomp$10.keySystemUris&&
h)for(m=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$10.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&&(!shaka.drm.DrmUtils.isClearKeySystem(e)||!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.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;this.lastReportedTime_=-1};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,b){shaka.log.v2("BufferingObserver got event",a,"at time",b);var c=this.lastReportedTime_;this.lastReportedTime_=b;var d=void 0;switch(a){case shaka.util.MediaElementEvent.SEEKING:case shaka.util.MediaElementEvent.WAITING:this.lastReportedTime_=-1;d=shaka.media.BufferingObserver.State.STARVING;break;case shaka.util.MediaElementEvent.CAN_PLAY_THROUGH:case shaka.util.MediaElementEvent.PLAYING:case shaka.util.MediaElementEvent.SEEKED:d=shaka.media.BufferingObserver.State.SATISFIED;
break;case shaka.util.MediaElementEvent.TIME_UPDATE:c>=0&&b-c>.01&&(d=shaka.media.BufferingObserver.State.SATISFIED)}return d!==void 0?this.setState(d):!1};shaka.media.BufferingObserver.State={STARVING:0,SATISFIED:1};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.getNextAddressJsc()==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){for(var d=(0,$jscomp.makeIterator)(c.initData||[]),e=d.next();!e.done;e=d.next())e=e.value,this.drmEngine_.newInitData(e.initDataType,e.initData);this.drmEngine_.updateCurrentDrmInfo(c)}};
shaka.media.ManifestFilterer.prototype.checkRestrictedVariants=function(a){var b=shaka.media.ManifestFilterer.restrictedStatuses,c=this.drmEngine_?this.drmEngine_.getKeyStatuses():{},d=Object.keys(c),e=d.length&&d[0]=="00";d=!1;var f=new Set,g=new Set,h=new WeakSet,k=function(m){if(m&&!h.has(m)&&(h.add(m),m.keyIds.size)){m=(0,$jscomp.makeIterator)(m.keyIds);for(var n=m.next();!n.done;n=m.next()){n=n.value;var p=c[e?"00":n];p?b.includes(p)&&g.add(p):f.add(n)}}};a=(0,$jscomp.makeIterator)(a.variants);
for(var l=a.next();!l.done;l=a.next()){l=l.value;if(!l.allowedByApplication)d=!0;else if(l.allowedByKeySystem)return;k(l.audio);k(l.video)}d={hasAppRestrictions:d,missingKeys:Array.from(f),restrictedKeyStatuses:Array.from(g)};throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.RESTRICTIONS_CANNOT_BE_MET,d);};shaka.media.ManifestFilterer.restrictedStatuses=["output-restricted","internal-error"];shaka.config.CodecSwitchingStrategy={RELOAD:"reload",SMOOTH:"smooth"};goog.exportSymbol("shaka.config.CodecSwitchingStrategy",shaka.config.CodecSwitchingStrategy);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.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.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){var 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){var c=shaka.util.Mp4BoxParsers;b.skip(1);var d=b.readUint8(),e=["","A","B","C"][d>>6],f=d&31,g=b.readUint32(),h=(d&32)>>5?"H":"L";d=[b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8()];b=b.readUint8();a=a+("."+e+f)+("."+c.toHex_(c.reverseBits_(g),!0));a+="."+h+b;c="";for(e=d.length;e--;)if((f=d[e])||c)c="."+f.toString(16).toUpperCase()+c;a+=c;return{codec:a}};
shaka.util.Mp4BoxParsers.parseDVCC=function(a,b){var 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){var 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){var c=shaka.util.Mp4BoxParsers,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){var 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(4);a=a.readBytes(4,!1);return{handlerType:String.fromCharCode(a[0],a[1],a[2],a[3])}};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.util.Mp4Generator=function(a){this.streamInfos_=a=a===void 0?[]: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(){if(this.streamInfos_.length===0)throw Error("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));c=this.streamInfos_[0];return a.box.apply(a,["moov",this.mvhd_(c)].concat((0,$jscomp.arrayFromIterable)(b),[this.mvex_(),this.psshs(c.stream)]))};
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([]);b.isStreamEncrypted_(a.stream)&&(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([]);b.isStreamEncrypted_(a.stream)&&(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([]);b.isStreamEncrypted_(a.stream)&&(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([]);b.isStreamEncrypted_(a.stream)&&(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([]);b.isStreamEncrypted_(a.stream)&&(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([]);b.isStreamEncrypted_(a.stream)&&(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));return a.box.apply(a,["mvex"].concat((0,$jscomp.arrayFromIterable)(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.psshs=function(a){var b=[];if(!shaka.util.Mp4Generator.isStreamEncrypted_(a))return new Uint8Array([]);a=(0,$jscomp.makeIterator)(a.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(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});return b.box.apply(b,["mdat"].concat((0,$jscomp.arrayFromIterable)(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.isStreamEncrypted_=function(a){return a.encrypted&&a.drmInfos.length>0};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).boxes(["moov","trak","mdia","minf","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=[];(new shaka.util.Mp4Parser).boxes(["moov","trak","mdia","minf","stbl"],function(n){h.push(n);shaka.util.Mp4Parser.children(n)}).fullBox("stsd",function(n){g=n;h.push(n);shaka.util.Mp4Parser.sampleDescription(n)}).boxes(["encv","enca"],function(n){f=!0;n.parser.stop()}).boxes("dvav dva1 dvh1 dvhe dvc1 dvi1 hev1 hvc1 avc1 avc3".split(" "),function(n){k.push({box:n,
newType:d.BOX_TYPE_ENCV_})}).boxes("ac-3 ec-3 ac-4 Opus fLaC mp4a".split(" "),function(n){k.push({box:n,newType:d.BOX_TYPE_ENCA_})}).parse(b);if(f)return shaka.log.debug("Init segment already indicates encryption."),b;if(k.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);k.reverse();c=(0,$jscomp.makeIterator)(k);for(var l=c.next();!l.done;l=c.next()){l=l.value;var m=shaka.util.Mp4Parser.typeToString(l.newType);shaka.log.debug('Inserting "'+m+'" box into init segment.');e=d.insertEncryptionMetadata_(a,e,g,l.box,h,l.newType)}e=d.insertPsshBoxes_(a,e);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=[];(new shaka.util.Mp4Parser).boxes(["moof","traf"],function(m){f.push(m);shaka.util.Mp4Parser.children(m)}).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){var g=b.start+shaka.util.Mp4Parser.headerSize(b)+4+(d.baseDataOffset!==null?
8:0),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.insertPsshBoxes_=function(a,b){a=(new shaka.util.Mp4Generator).psshs(a);if(a.byteLength===0)return b;var c=0,d=0;(new shaka.util.Mp4Parser).box("moov",function(h){c=h.start;d=h.size;h.parser.stop()}).parse(b);var e=c+d;shaka.media.ContentWorkarounds.updateBoxSize_(b,c,d+a.byteLength);var f=new Uint8Array(b.byteLength+a.byteLength),g=b.subarray(0,e);b=b.subarray(e);f.set(g);f.set(a,e);f.set(b,e+a.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=[];(new shaka.util.Mp4Parser).boxes(["moov","trak","mdia","minf","stbl"],function(e){d.push({start:e.start,size:e.size});shaka.util.Mp4Parser.children(e)}).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.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.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.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.getNextAddressJsc()==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.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.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.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()};/*

 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=Math.min(4,this.workingBytesAvailable_);if(b!==0){for(var c=0,d=0;d<b;d++)c=c<<8|this.data_[a+d];this.workingWord_=c<<(4-b)*8;this.workingBitsAvailable_=b*8;this.workingBytesAvailable_-=b}};
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(){for(var a=0;this.workingBitsAvailable_===0;){if(this.workingBytesAvailable_===0)return a;this.loadWord_()}for(;;){var b=Math.clz32(this.workingWord_);b>this.workingBitsAvailable_&&(b=this.workingBitsAvailable_);a+=b;this.workingWord_<<=b;this.workingBitsAvailable_-=b;if(this.workingBitsAvailable_>0||this.workingBytesAvailable_===0)break;this.loadWord_()}return a};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);shaka.util.TsParser=function(){this.pmtId_=null;this.pmtParsed_=!1;this.videoCodec_=this.videoPid_=null;this.videoData_=[];this.videoDataPesIndices_=[];this.videoPes_=[];this.audioCodec_=this.audioPid_=null;this.audioData_=[];this.audioDataPesIndices_=[];this.audioPes_=[];this.id3Pid_=null;this.id3Data_=[];this.id3DataPesIndices_=[];this.discontinuitySequence_=this.opusMetadata_=this.referenceDts_=this.referencePts_=null};
shaka.util.TsParser.prototype.clearData=function(){this.videoData_=[];this.videoDataPesIndices_=[];this.videoPes_=[];this.audioData_=[];this.audioDataPesIndices_=[];this.audioPes_=[];this.id3Data_=[];this.id3DataPesIndices_=[]};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.videoDataPesIndices_.push(this.videoData_.length),this.videoData_.push(h)):this.videoDataPesIndices_.length&&this.videoData_.push(h);break;case this.audioPid_:h=a.subarray(k,f+b);g?(this.audioDataPesIndices_.push(this.audioData_.length),
this.audioData_.push(h)):this.audioDataPesIndices_.length&&this.audioData_.push(h);break;case this.id3Pid_:h=a.subarray(k,f+b);g?(this.id3DataPesIndices_.push(this.id3Data_.length),this.id3Data_.push(h)):this.id3DataPesIndices_.length&&this.id3Data_.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={audio:-1,video:-1,id3:-1,audioCodec:"",videoCodec:""},d=b+3+((a[b+1]&15)<<8|a[b+2])-4;for(b+=12+((a[b+10]&15)<<8|a[b+11]);b<d;){var e=(a[b+1]&31)<<8|a[b+2],f=(a[b+3]&15)<<8|a[b+4];switch(a[b]){case 6:if(f>0)for(var g=b+5,h=f;h>2;){var k=a[g+1]+2;switch(a[g]){case 5:var l=g+2;l=a[l]<<24|a[l+1]<<16|a[l+2]<<8|a[l+3];c.audio==-1&&l===1332770163?(c.audio=e,c.audioCodec="opus"):c.video==-1&&l===1096167473&&(c.video=e,c.videoCodec="av1");break;
case 106:c.audio==-1&&(c.audio=e,c.audioCodec="ac3");break;case 122:c.audio==-1&&(c.audio=e,c.audioCodec="ec3");break;case 124:c.audio==-1&&(c.audio=e,c.audioCodec="aac");break;case 127:c.audioCodec=="opus"&&(l=null,a[g+2]===128&&(l=a[g+3]),l!=null&&(this.opusMetadata_={channelCount:(l&15)===0?2:l&15,channelConfigCode:l,sampleRate:48E3}))}g+=k;h-=k}break;case 15:c.audio==-1&&(c.audio=e,c.audioCodec="aac");break;case 17:c.audio==-1&&(c.audio=e,c.audioCodec="aac-loas");break;case 21:c.id3==-1&&(c.id3=
e);break;case 27:c.video==-1&&(c.video=e,c.videoCodec="avc");break;case 3:case 4:c.audio==-1&&(c.audio=e,c.audioCodec="mp3");break;case 36:c.video==-1&&(c.video=e,c.videoCodec="hvc");break;case 129:c.audio==-1&&(c.audio=e,c.audioCodec="ac3");break;case 132:case 135:c.audio==-1&&(c.audio=e,c.audioCodec="ec3")}b+=f+5}return c};shaka.util.TsParser.prototype.concatPesPackets_=function(a,b,c){return shaka.util.Uint8ArrayUtils.concatRange(a,b[c],c+1<b.length?b[c+1]:a.length)};
shaka.util.TsParser.prototype.parsePES_=function(a){if((a[0]<<16|a[1]<<8|a[2])!==1)return null;var b=a[4]<<8|a[5];if(b&&b>a.byteLength-6)return null;var c=null,d=null,e=a[7];if(e&192){var f=(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_=f);d=this.referencePts_=c=this.handleRollover_(f,this.referencePts_);e&64&&(d=(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_=d),d=c!=f?this.handleRollover_(d,this.referenceDts_):d);this.referenceDts_=d}f=a[8]+9;return a.byteLength<=f?null:{data:a.subarray(f),packetLength:b,pts:c,dts:d,nalus:[]}};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,n=this.videoCodec_==="hvc";g==-1&&(l=0,m=n?a[0]>>1&63:a[0]&31,g=0,k=1);for(;k<e;){var p=a[k++];if(g)if(g===1)g=p?0:2;else if(p)if(p==1){p=k-g-1;if(l>=0)g={data:a.subarray(l+f,p),fullData:a.subarray(l,p),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)),p>0&&(p=a.subarray(0,p),g.data=shaka.util.Uint8ArrayUtils.concat(g.data,p),g.fullData=shaka.util.Uint8ArrayUtils.concat(g.fullData,p),g.state=0);k<e?(m=n?a[k]>>1&63:a[k]&31,l=k,g=0):g=-1}else g=0;else g=3;else g=p?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;c<this.id3DataPesIndices_.length;c++){var d=this.concatPesPackets_(this.id3Data_,this.id3DataPesIndices_,c);(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.audioDataPesIndices_.length&&!this.audioPes_.length)for(var a=0;a<this.audioDataPesIndices_.length;a++){var b=this.concatPesPackets_(this.audioData_,this.audioDataPesIndices_,a),c=this.parsePES_(b),d=this.audioPes_.length?this.audioPes_[this.audioPes_.length-1]:null;c&&c.pts!=null&&c.dts!=null&&(!d||d.pts!=c.pts&&d.dts!=c.dts)?this.audioPes_.push(c):this.audioPes_.length&&(b=c?c.data:b)&&(d=this.audioPes_[this.audioPes_.length-1],d.data=
shaka.util.Uint8ArrayUtils.concat(d.data,b))}return this.audioPes_};
shaka.util.TsParser.prototype.getVideoData=function(a){a=a===void 0?!0:a;if(this.videoDataPesIndices_.length&&!this.videoPes_.length){for(var b=0;b<this.videoDataPesIndices_.length;b++){var c=this.concatPesPackets_(this.videoData_,this.videoDataPesIndices_,b),d=this.parsePES_(c),e=this.videoPes_.length?this.videoPes_[this.videoPes_.length-1]:null;d&&d.pts!=null&&d.dts!=null&&(!e||e.pts!=d.pts&&e.dts!=d.dts)?this.videoPes_.push(d):this.videoPes_.length&&(c=d?d.data:c)&&(e=this.videoPes_[this.videoPes_.length-
1],e.data=shaka.util.Uint8ArrayUtils.concat(e.data,c))}if(a){b={nalu:null,state:null};e=[];c=(0,$jscomp.makeIterator)(this.videoPes_);for(d=c.next();!d.done;d=c.next())d=d.value,d.nalus=this.parseNalus(d,b),d.nalus.length&&(e.push(d),b.nalu=d.nalus[d.nalus.length-1]);this.videoPes_=e}}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(A){return A.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=[],u=[],w=0;w<e;w++)t.push(d.readBoolean()),u.push(d.readBoolean());if(e>0)for(w=e;w<8;w++)d.readBits(2);for(w=0;w<e;w++)t[w]&&d.readBits(88),u[w]&&d.readUnsignedByte();d.readUnsignedExpGolomb();e=d.readUnsignedExpGolomb();e==3&&d.readBits(1);t=d.readUnsignedExpGolomb();u=d.readUnsignedExpGolomb();var v=w=0,x=0,y=0;d.readBoolean()&&(w+=d.readUnsignedExpGolomb(),v+=d.readUnsignedExpGolomb(),
x+=d.readUnsignedExpGolomb(),y+=d.readUnsignedExpGolomb());b.width=String(t-(w+v)*(e===1||e===2?2:1));b.height=String(u-(x+y)*(e===1?2:1));d=["","A","B","C"][f];k=function(A){for(var B=0,D=0;D<32;D++)B|=(A>>D&1)<<31-D;return B>>>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;var e=a.indexOf(71,d+1);d=e>=0&&e<c?e:d+1}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.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.removeSources_();this.config_.useSourceElements?(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){if(!this.video_||!window.ManagedMediaSource||!this.mediaSource_)shaka.log.warning("Secondary source is used only with ManagedMediaSource");else if(this.config_.useSourceElements){var c;((c=this.secondarySource_)==null?void 0:c.parentElement)===this.video_&&this.video_.removeChild(this.secondarySource_);this.secondarySource_=shaka.util.Dom.createSourceElement(a,b);this.video_.appendChild(this.secondarySource_);this.video_.disableRemotePlayback=
!1}};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="av01.0.31M.10.0.111.09.16.09.0",video/mp4; codecs="av01.0.31M.10.0.112.09.18.09.0",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.03",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,u,w,v,x,y,A,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){if(D.getNextAddressJsc()==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 D.yield(Promise.all(c),2)}r=(0,$jscomp.makeIterator)(a.transmuxers_.values());for(t=r.next();!t.done;t=r.next())u=t.value,u.destroy();a.eventManager_&&(a.eventManager_.release(),a.eventManager_=null);a.video_&&(a.removeSources_(),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(w=(0,$jscomp.makeIterator)(a.queues_),v=w.next();!v.done;v=w.next())x=v.value,y=(0,$jscomp.makeIterator)(x),A=y.next().value,B=y.next().value,goog.asserts.assert(B.length==0,A+" queue should be empty after destroy!");a.queues_.clear();a.lcevcDec_=null;a.tsParsers_.clear();a.playerInterface_=null;D.jumpToEnd()})};
shaka.media.MediaSourceEngine.prototype.removeSources_=function(){if(this.video_){this.video_.removeAttribute("src");var a;((a=this.source_)==null?void 0:a.parentElement)===this.video_&&this.video_.removeChild(this.source_);var b;((b=this.secondarySource_)==null?void 0:b.parentElement)===this.video_&&this.video_.removeChild(this.secondarySource_)}};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.getNextAddressJsc()==1)return f=shaka.util.ManifestParserUtils.ContentType,n.yield(e.mediaSourceOpen_,2);if(n.getNextAddressJsc()!=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));a==e.VIDEO&&c&&b.mimeType=="video/mp4"&&(c=shaka.util.StreamUtils.getCorrectVideoCodecs(c));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_||this.closed())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(t){return t.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,n=[];m&&a.fullBox("emsg",function(t){(t=g.parseEMSG_(c,d.emsgSchemeIdUris,t))&&n.push(t)});var p=c.initSegmentReference.timescale;e=p&&!isNaN(p);var q=0,r=!1;e&&a.fullBox("prft",function(t){goog.asserts.assert(typeof p=="number","Timescale should be a number!");g.parsePrft_(p,t)}).boxes(["moof",
"traf"],l.children).fullBox("tfdt",function(t){r||(goog.asserts.assert(t.version==0||t.version==1,"TFDT version can only be 0 or 1"),goog.asserts.assert(typeof p=="number","Timescale should be a number!"),q=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(t.reader,t.version).baseMediaDecodeTime/p,r=!0,m||t.parser.stop())});(m||e)&&a.parse(b,!1,f);r&&c.timestampOffset==0&&(h=q);b=(0,$jscomp.makeIterator)(n);for(f=b.next();!f.done;f=b.next())this.dispatchEmsg_(f.value,c,h)}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{b=l;if(d!=="https://aomedia.org/emsg/ID3"||h!==4294967295)b+=h/f;return{startTime:l,endTime:b,schemeIdUri:d,value:e,timescale:f,presentationTimeDelta:g,eventDuration:h,id:k,messageData:a}}return null};
shaka.media.MediaSourceEngine.prototype.dispatchEmsg_=function(a,b,c){var d=shaka.util.NumberUtils.isFloatEqual(a.startTime,b.startTime+a.presentationTimeDelta/a.timescale);c&&this.manifestType_==shaka.media.ManifestParser.HLS&&!d&&(b=-c+b.startTime,a.startTime+=b,a.endTime+=b);this.playerInterface_.onEmsg(a);!a.messageData||a.schemeIdUri!="https://aomedia.org/emsg/ID3"&&a.schemeIdUri!="https://developer.apple.com/streaming/emsg-id3"||(b=shaka.util.Id3Utils.getID3Frames(a.messageData),b.length&&(c=
a.startTime,this.playerInterface_.onMetadata([{cueTime:c,data:a.messageData,frames:b,dts:c,pts:c}],0,a.endTime)))};
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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(O){switch(O.getNextAddressJsc()){case 1:n=shaka.util.ManifestParserUtils.ContentType;if(a!=n.TEXT){O.jumpTo(2);break}if(m.manifestType_!=shaka.media.ManifestParser.HLS){O.jumpTo(3);break}return O.yield(m.textSequenceModeOffset_,
4);case 4:p=O.getYieldResultJsc(),m.textEngine_.setTimestampOffset(p);case 3:return O.yield(m.textEngine_.appendBuffer(b,c?c.startTime:null,c?c.endTime:null,c?c.getUris()[0]:null),5);case 5:return O.return();case 2:if(k||!m.needSplitMuxedContent_){O.jumpTo(6);break}return O.yield(m.appendBuffer(n.AUDIO,b,c,d,e,f,g,h,!0),7);case 7:return O.yield(m.appendBuffer(n.VIDEO,b,c,d,e,f,g,h,!0),8);case 8:return O.return();case 6:if(!m.sourceBuffers_.has(a))return shaka.log.warning("Attempted to restore a non-existent source buffer"),
O.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),u=t.timestamp,w=t.metadata,u!=null&&(m.firstVideoTimestamp_==null&&a==n.VIDEO&&(m.firstVideoTimestamp_=u,m.firstVideoReferenceStartTime_=c.startTime,m.firstAudioTimestamp_!=null&&(v=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(v=m.firstVideoTimestamp_-m.firstAudioTimestamp_),
m.audioCompensation_.resolve(v))),m.firstAudioTimestamp_==null&&a==n.AUDIO&&(m.firstAudioTimestamp_=u,m.firstAudioReferenceStartTime_=c.startTime,m.firstVideoTimestamp_!=null&&(x=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(x=m.firstVideoTimestamp_-m.firstAudioTimestamp_),m.audioCompensation_.resolve(x))),y=u,A=shaka.util.MimeUtils.RAW_FORMATS,!m.sequenceMode_&&A.includes(m.sourceBufferTypes_.get(a))&&(y=0),B=c.startTime-y,D=Math.abs(q-B),(D>=.001||f||g)&&(!h||B>0||!q)&&(q=
B,m.attemptTimestampOffsetCalculation_&&(m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,q)},null))),(z=a==n.VIDEO||!m.sourceBuffers_.has(n.VIDEO))&&m.textSequenceModeOffset_.resolve(q)),w.length))m.playerInterface_.onMetadata(w,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_||(C=r.split(";",1)[0],m.captionParser_=m.getCaptionParser(C)),
c?(E=m.captionParser_.parseFrom(b),E.length&&m.textEngine_.storeAndAppendClosedCaptions(E,q)):m.captionParser_.init(b,g,l));if(!m.transmuxers_.has(a)){O.jumpTo(9);break}return O.yield(m.transmuxers_.get(a).transmux(b,d,c,m.mediaSource_.duration,a),10);case 10:G=O.getYieldResultJsc(),ArrayBuffer.isView(G)?b=G:(I=G,I.init!=null&&(F=I.init,m.enqueueOperation_(a,function(){m.append_(a,F,q,d)},c?c.getUris()[0]:null)),b=I.data);case 9:b=m.workAroundBrokenPlatforms_(d,b,c,a);if(!c||!m.sequenceMode_||a==
n.TEXT){O.jumpTo(11);break}if(!f&&!g){O.jumpTo(11);break}J=c.startTime;if(m.manifestType_!=shaka.media.ManifestParser.HLS||m.needSplitMuxedContent_||a!=n.AUDIO||!m.sourceBuffers_.has(n.VIDEO)){O.jumpTo(13);break}return O.yield(m.audioCompensation_,14);case 14:K=O.getYieldResultJsc(),Math.abs(K)>.15&&(J-=K);case 13:m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,J)},null);case 11:return H=null,O.yield(m.enqueueOperation_(a,
function(){goog.DEBUG&&c&&!c.isPreload()&&!h&&(H=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),L=shaka.media.TimeRangesUtils.computeAddedRange(H,M))&&(N=c.endTime-c.startTime,P=L.end-L.start,Q=Math.abs(L.end-c.endTime),N>.1&&(Q>N/2||Math.abs(N-P)>.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",L)),O.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.getNextAddressJsc()==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.getNextAddressJsc()==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.getNextAddressJsc()!=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.getNextAddressJsc()==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.getNextAddressJsc()==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.getYieldResultJsc();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.getNextAddressJsc()==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.removeDependency=function(a,b,c){this.lcevcDec_&&this.lcevcDec_.removeBuffer(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.removeDependency(a,b,c),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,u,w,v,x,y,A,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){switch(D.getNextAddressJsc()){case 1:b.destroyer_.ensureNotDestroyed();c=[];d=Array.from(b.sourceBuffers_.keys());e=new Map;f=(0,$jscomp.makeIterator)(d);g=f.next();for(h={};!g.done;h={ready:void 0},g=f.next())k=g.value,h.ready=new shaka.util.PublicPromise,l={start:function(z){return function(){return z.ready.resolve()}}(h),
p:h.ready,uri:null},m=b.queues_.get(k),m.push(l),c.push(h.ready),e.set(k,l),m.length==1&&l.start();D.setCatchFinallyBlocks(2);return D.yield(Promise.all(c),4);case 4:D.leaveTryBlock(3);break;case 2:n=D.enterCatchBlock();if(b.destroyer_.destroyed()){p=(0,$jscomp.makeIterator)(d);for(q=p.next();!q.done;q=p.next())r=q.value,t=b.queues_.get(r),e.has(r)&&shaka.util.ArrayUtils.remove(t,e.get(r));return D.return()}throw n;case 3:if(goog.DEBUG)for(u=(0,$jscomp.makeIterator)(d),w=u.next();!w.done;w=u.next())v=
w.value,goog.asserts.assert(b.sourceBuffers_.get(v).updating==0,"SourceBuffers should not be updating after a blocking op!");D.setCatchFinallyBlocks(5,6);return D.yield(a(),6);case 6:D.enterFinallyBlock();x=(0,$jscomp.makeIterator)(d);for(y=x.next();!y.done;y=x.next())A=y.value,b.popFromQueue_(A);D.leaveFinallyBlock(0);break;case 5:throw B=D.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.device.DeviceFactory.getDevice().supportsSmoothCodecSwitching()?(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,u,w,v,x,y,A;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){if(B.getNextAddressJsc()==1){if(b.reloadingMediaSource_||b.usingRemotePlayback_)return B.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);
B.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(D){shaka.log.debug("Exception on removeSourceBuffer",D)}}b.transmuxers_.clear();b.sourceBuffers_.clear();n=b.mediaSource_.duration;b.mediaSourceOpen_=new shaka.util.PublicPromise;b.mediaSource_=b.createMediaSource(b.mediaSourceOpen_);
return B.yield(b.mediaSourceOpen_,4)}if(B.getNextAddressJsc()!=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;u=function(){t++;t===r&&(p.resolve(),b.eventManager_.unlisten(q,"addsourcebuffer",u))};b.eventManager_.listen(q,"addsourcebuffer",u);w=(0,$jscomp.makeIterator)(a.keys());for(v=w.next();!v.done;v=w.next())x=v.value,y=a.get(x),b.initSourceBuffer_(x,
y,y.codecs);(A=a.get(c.AUDIO))&&A.isAudioMuxedInVideo&&(b.needSplitMuxedContent_=!0);b.needSplitMuxedContent_&&!b.queues_.has(c.AUDIO)&&b.queues_.set(c.AUDIO,[]);return B.yield(p,2)}B.enterFinallyBlock();b.reloadingMediaSource_=!1;b.destroyer_.ensureNotDestroyed();b.eventManager_.listenOnce(b.video_,shaka.util.MediaElementEvent.LOADED_METADATA,function(){b.destroyer_.destroyed()||(b.video_.currentTime=d)});b.eventManager_.listenOnce(b.video_,shaka.util.MediaElementEvent.CAN_PLAY_THROUGH,function(){b.destroyer_.destroyed()||
(b.video_.autoplay=e,b.playAfterReset_&&(b.playAfterReset_=!1,b.video_.play()))});return B.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);var l=shaka.util.MimeUtils.getFullType(b,k),m=e.getBasicType(this.sourceBufferTypes_.get(a)),n=this.config_.forceTransmux;!shaka.media.Capabilities.isTypeSupported(l)||!this.sequenceMode_&&
shaka.util.MimeUtils.RAW_FORMATS.includes(l)?n=!0:n||b==m||(n=!shaka.device.DeviceFactory.getDevice().supportsContainerChangeType()&&shaka.util.MimeUtils.RAW_FORMATS.includes(b));m=shaka.transmuxer.TransmuxerEngine;if(n&&(k=shaka.util.MimeUtils.getFullTypeWithAllCodecs(b,k),n=m.findTransmuxer(k))){var p=n();g&&h&&(f=!0);l=p.convertCodecs(a,k)}!p&&a===d.VIDEO&&g&&(l=shaka.util.MimeUtils.getFullType(b,c));a=e.getNormalizedCodec(e.getCodecs(l));e=e.getBasicType(l);return{transmuxer:p,transmuxerMuxed:f,
basicType:e,codec:a,mimeType:l}};
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;a=shaka.device.DeviceFactory.getDevice();if(g&&this.config_.codecSwitchingStrategy===
shaka.config.CodecSwitchingStrategy.SMOOTH&&a.supportsSmoothCodecSwitching())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.getNextAddressJsc()==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.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.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&&this.stallDetector_&&!this.stallDetector_.poll())for(var d=shaka.media.TimeRangesUtils.getBufferedInfo(b),e=0;e<d.length-1;e++)if(Math.abs(a-d[e].end)<.1&&d[e+1].start>d[e].end){c=e+1;break}c==null||c==0&&!this.hadSegmentAppended_||(d=b.start(c),(e=this.config_.gapPadding)&&(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.getNextAddressJsc()==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.getNextAddressJsc()!=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};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.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){var b=this.references.length-1;if(b<0)return null;if(a<this.references[0].startTime)return this.numEvicted_;var c=shaka.util.ArrayUtils.binarySearch(this.references,function(e){return e.startTime<=a})-1;if(c<0)return null;var d=this.references[c];b=c<b?this.references[c+1].startTime:d.endTime;return a>=d.startTime&&a<b?c+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,c=shaka.util.ArrayUtils.binarySearch(this.references,function(d){return Math.round(d.startTime*1E3)/1E3<b});this.references.length=c;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){for(var c=Math.max(b,this.references.length>0?this.references[0].startTime:-Infinity),d=0;d<a.length&&a[d].endTime<=c;)d++;d>0&&(a=a.slice(d));c=this.references[0];this.merge(a);a=this.references[0];c&&goog.asserts.assert(c.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=shaka.util.ArrayUtils.binarySearch(this.references,function(c){return c.endTime<=a});b>0&&(this.numEvicted_+=b,this.references=this.references.slice(b))}};
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;var d=shaka.util.ArrayUtils.binarySearch(this.references,function(e){return e.endTime<=a});d>0&&(c||(this.numEvicted_+=
d),this.references=this.references.slice(d));this.references.length!=0&&(c=this.references[this.references.length-1],b=new shaka.media.SegmentReference(c.startTime,b,c.getUrisInner,c.startByte,c.endByte,c.initSegmentReference,c.timestampOffset,c.appendWindowStart,c.appendWindowEnd,c.partialReferences,c.tilesLayout,c.tileDuration,c.syncTime,c.status,c.aesKey),b.mimeType=c.mimeType,b.codecs=c.codecs,b.discontinuitySequence=c.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.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_.isPaused()||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&&a<=16)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.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()});this.eventManager_.listen(a,"seeked",function(){b.pollingLoop_.tickNow();
a.paused||b.pollingLoop_.tickEvery(.25)})};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.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$3:void 0},c=b.next())d.initSegmentReference$jscomp$3=c.value,a.some(function(e){return function(f){return shaka.media.InitSegmentReference.equal(f.initSegmentReference,e.initSegmentReference$jscomp$3)}}(d))||this.abortPrefetchedSegment_(d.initSegmentReference$jscomp$3)};
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.getNextAddressJsc()==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.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.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,timescale: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,timescale:null}};
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(z){z=z.toLowerCase();switch(z){case "avc1":case "avc3":g.push(z+".42E01E");k=!0;break;case "hev1":case "hvc1":g.push(z+".1.6.L93.90");k=!0;break;case "dvh1":case "dvhe":g.push(z+".05.04");k=!0;break;case "vp09":g.push(z+".00.10.08");k=!0;break;case "av01":g.push(z+".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(z);
h=!0;break;case "apac":f.push("apac.31.00"),h=!0}},m=null,n=null,p=null,q=null,r=null,t=null,u=null,w=null,v,x=function(z){var C=shaka.util.Mp4BoxParsers.audioSampleEntry(z.reader);q=C.channelCount;r=C.sampleRate;l(z.name)},y=function(z){v=z.name;var C=shaka.util.Mp4BoxParsers.visualSampleEntry(z.reader);p=String(C.width);n=String(C.height);z.reader.hasMoreData()&&d.children(z)};(new d).box("moov",d.children).box("trak",d.children).box("mdia",d.children).fullBox("mdhd",function(z){goog.asserts.assert(z.version!=
null,"MDHD is a full box and should have a valid version.");z=shaka.util.Mp4BoxParsers.parseMDHD(z.reader,z.version);m=z.language;w=z.timescale}).box("minf",d.children).box("stbl",d.children).fullBox("stsd",d.sampleDescription).box("mp4a",function(z){var C=shaka.util.Mp4BoxParsers.audioSampleEntry(z.reader);q=C.channelCount;r=C.sampleRate;z.reader.hasMoreData()?d.children(z):l(z.name)}).box("esds",function(z){z=shaka.util.Mp4BoxParsers.parseESDS(z.reader);f.push(z.codec);h=!0}).box("ac-3",x).box("ec-3",
x).box("ac-4",x).box("Opus",x).box("fLaC",x).box("apac",x).box("avc1",y).box("avc3",y).box("hev1",y).box("hvc1",y).box("dva1",y).box("dvav",y).box("dvh1",y).box("dvhe",y).box("vp09",y).box("av01",y).box("avcC",function(z){var C=v||"";switch(v){case "dvav":C="avc3";break;case "dva1":C="avc1"}z=shaka.util.Mp4BoxParsers.parseAVCC(C,z.reader);g.push(z.codec);k=!0}).box("hvcC",function(z){var C=v||"";switch(v){case "dvh1":C="hvc1";break;case "dvhe":C="hev1"}z=shaka.util.Mp4BoxParsers.parseHVCC(C,z.reader);
g.push(z.codec);k=!0}).box("dvcC",function(z){var C=v||"";switch(v){case "hvc1":C="dvh1";break;case "hev1":C="dvhe";break;case "avc1":C="dva1";break;case "avc3":C="dvav";break;case "av01":C="dav1"}z=shaka.util.Mp4BoxParsers.parseDVCC(C,z.reader);g.push(z.codec);k=!0}).box("dvvC",function(z){var C=v||"";switch(v){case "hvc1":C="dvh1";break;case "hev1":C="dvhe";break;case "avc1":C="dva1";break;case "avc3":C="dvav";break;case "av01":C="dav1"}z=shaka.util.Mp4BoxParsers.parseDVVC(C,z.reader);g.push(z.codec);
k=!0}).fullBox("vpcC",function(z){z=shaka.util.Mp4BoxParsers.parseVPCC(v||"",z.reader);g.push(z.codec);k=!0}).box("av1C",function(z){var C=v||"";switch(v){case "dav1":C="av01"}z=shaka.util.Mp4BoxParsers.parseAV1C(C,z.reader);g.push(z.codec);k=!0}).box("enca",d.audioSampleEntry).box("encv",d.visualSampleEntry).box("sinf",d.children).box("frma",function(z){z=shaka.util.Mp4BoxParsers.parseFRMA(z.reader).codec;l(z)}).box("colr",function(z){g=g.map(function(G){return G.startsWith("av01.")?shaka.util.Mp4BoxParsers.updateAV1CodecWithCOLRBox(G,
z.reader):G});var C=shaka.util.Mp4BoxParsers.parseCOLR(z.reader),E=C.colorGamut;t=C.videoRange;u=E}).parse(a||b,!0,!0);if(!f.length&&!g.length)return null;x=h&&!k;y=new Map;if(k&&!c){c=new shaka.media.ClosedCaptionParser("video/mp4");a&&c.init(a);try{c.parseFrom(b);for(var A=(0,$jscomp.makeIterator)(c.getStreams()),B=A.next();!B.done;B=A.next()){var D=B.value;y.set(D,D)}}catch(z){shaka.log.debug("Error detecting CC streams",z)}c.reset()}a=f.concat(g);return{type:x?"audio":"video",mimeType:x?"audio/mp4":
"video/mp4",codecs:e.codecsFiltering(a).join(", "),language:m,height:n,width:p,channelCount:q,sampleRate:r,closedCaptions:y,videoRange:t,colorGamut:u,frameRate:null,timescale:w}};
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.getNextAddressJsc()==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.getNextAddressJsc()!=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.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.getNextAddressJsc()){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.getYieldResultJsc();
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.getYieldResultJsc(),e=l.headers["content-type"];case 3:return m.return(e?e.toLowerCase().split(";").shift():"")}})};
shaka.net.NetworkingUtils.getExtension=function(a){for(var b=a.length,c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d===63||d===35){b=c;break}}for(c=b-1;c>=0;c--){d=a.charCodeAt(c);if(d===46){if(c+1<b)return a.slice(c+1,b).toLowerCase();break}if(d===47)break}return""};shaka.net.NetworkingUtils.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.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.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.getNextAddressJsc()==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.getNextAddressJsc()==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.getNextAddressJsc()){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.getNextAddressJsc()==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.getNextAddressJsc()==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.getNextAddressJsc()!=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.getNextAddressJsc()==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$46:void 0},e=d.next())if(f.variant$jscomp$46=e.value,f.variant$jscomp$46.audio)if(this.audioPrefetchMap_.has(f.variant$jscomp$46.audio)){if(e=this.audioPrefetchMap_.get(f.variant$jscomp$46.audio),e.resetLimit(a),!(a>0&&b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$46.audio.language,
k)}}(f)))){var g=this.mediaStates_.get(f.variant$jscomp$46.audio.type);e!==(g&&g.segmentPrefetch)&&e.clearAll();this.audioPrefetchMap_.delete(f.variant$jscomp$46.audio)}}else a<=0||!b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$46.audio.language,k)}}(f))||!(e=this.createSegmentPrefetch_(f.variant$jscomp$46.audio))||(f.variant$jscomp$46.audio.segmentIndex||f.variant$jscomp$46.audio.createSegmentIndex(),this.audioPrefetchMap_.set(f.variant$jscomp$46.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.getNextAddressJsc()){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.stream&&!a.stream.isAudioMuxedInVideo&&
l.push(a);m=a.type===c.AUDIO?c.VIDEO:c.AUDIO;(n=b.mediaStates_.get(m))&&n.stream&&!n.stream.isAudioMuxedInVideo&&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&&((c=this.mediaStates_.get(b.TEXT))&&shaka.media.StreamingEngine.isEmbeddedText_(c)&&(c.endOfStream=!0),(c=this.mediaStates_.get(b.AUDIO))&&c.stream.isAudioMuxedInVideo&&(c.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 d=Infinity,(a=a.lastSegmentReference)&&(d=a.endTime-
a.startTime),Math.min(d/2,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=(0,$jscomp.makeIterator)(this.mediaStates_.values());for(var m=k.next();!m.done;m=k.next())m=m.value,shaka.media.StreamingEngine.isEmbeddedText_(m)||m.stream.isAudioMuxedInVideo||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){if((d=a.segmentIterator.current())&&a.lastSegmentReference){b=shaka.util.NumberUtils;var e=a.lastSegmentReference.endTime;b.isFloatEqual(a.lastSegmentReference.startTime,d.startTime,.002)&&b.isFloatEqual(e,d.endTime,.002)&&(d=a.segmentIterator.next().value)}return 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),e=this.playerInterface_.getPlaybackRate()<0,a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,e)),a=a.segmentIterator&&a.segmentIterator.next().value,a==null&&shaka.log.warning(d,"cannot find segment","endTime:",b),a;var f=this.manifest_.sequenceMode||this.shouldUseCrossBoundaryLogic_()?
0:this.config_.inaccurateManifestTolerance;c=Math.max(b-f,0);var g=this.playerInterface_.mediaSourceEngine.getDuration(),h=shaka.media.StreamingEngine.LOOKUP_TIME_DURATION_THRESHOLD_;Math.abs(c-g)<h&&(f=h,c=Math.max(b-f,0));shaka.log.v1(d,"looking up segment","lookupTime:",c,"presentationTime:",b);h=this.playerInterface_.getPlaybackRate()<0;g=null;f&&(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(c,!1,h)),g=a.segmentIterator&&a.segmentIterator.next().value);g||
(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,h)),g=a.segmentIterator&&a.segmentIterator.next().value);for(;((e=g)==null?void 0:e.getStatus())===shaka.media.SegmentReference.Status.MISSING;)h=f=void 0,g=(h=(f=a.segmentIterator)==null?void 0:f.next().value)!=null?h:null;g==null&&shaka.log.warning(d,"cannot find segment","lookupTime:",c,"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,u,w,v,x,y,A,B,D,z,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){switch(E.getNextAddressJsc()){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),w=u=!1,x=function(G){var I,F,J,K;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.getNextAddressJsc()){case 1:if(u)return H.return();w=!0;e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return H.return();H.setCatchFinallyBlocks(2);t=shaka.util.Uint8ArrayUtils.concat(t,G);I=!1;F=0;(new shaka.util.Mp4Parser).box("mdat",function(M){F=M.size+M.start;I=!0}).parse(t,!1,!0);if(!I){H.jumpTo(4);
break}J=t.subarray(0,F);t=t.subarray(F);return H.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:H.leaveTryBlock(0);break;case 2:v=K=H.enterCatchBlock(),H.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.getYieldResultJsc();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:y=E.getYieldResultJsc();if(v)throw v;if(w){E.jumpTo(10);break}u=!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,y,!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;A=l.next().value;shaka.log.v2(h,"advancing to next segment",A);a.performingUpdate=!1;a.recovering=!1;B=e.playerInterface_.mediaSourceEngine.getBufferedInfo();D=B[a.type];shaka.log.v1(h,"finished fetch and append",JSON.stringify(D));if(!a.waitingToClearBuffer)if(z=
null,a.type===f.VIDEO?z=e.mediaStates_.get(f.AUDIO):a.type===f.AUDIO&&(z=e.mediaStates_.get(f.VIDEO)),z&&z.type==f.AUDIO)e.playerInterface_.onSegmentAppended(c,a.stream,z.stream.isAudioMuxedInVideo,!1);else e.playerInterface_.onSegmentAppended(c,a.stream,a.stream.codecs.includes(","),!1);e.cancelUpdate_(a);e.scheduleUpdate_(a,0);E.leaveTryBlock(0);break;case 2:C=E.enterCatchBlock();e.destroyer_.ensureNotDestroyed(C);if(e.fatalError_)return E.return();goog.asserts.assert(C instanceof shaka.util.Error,
"Should only receive a Shaka error");a.performingUpdate=!1;if(C.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)C.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(C.code==
shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR)return E.yield(e.handleQuotaExceeded_(a,C),0);shaka.log.error(h,"failed fetch and append: code="+C.code);a.hasError=!0;C.category==shaka.util.Error.Category.NETWORK&&a.segmentPrefetch&&a.segmentPrefetch.removeReference(c);C.severity=shaka.util.Error.Severity.CRITICAL;return E.yield(e.handleStreamingError_(a,C),0)}}})};
shaka.media.StreamingEngine.prototype.fetchAndAppendDependency_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(w){switch(w.getNextAddressJsc()){case 1:e=shaka.util.ManifestParserUtils.ContentType;f=a.stream;for(k=(h=(g=f.segmentIndex)&&g.getIteratorForTime(b))&&h.next().value;k&&d.requestedDependencySegments_.includes(k.startTime);)k=h&&h.next().value;if(!k){w.jumpTo(0);break}l=k.initSegmentReference;if(!l||shaka.media.InitSegmentReference.equal(l,
a.lastInitSegmentReference)){w.jumpTo(3);break}a.lastInitSegmentReference=l;w.setCatchFinallyBlocks(4);return w.yield(d.fetch_(a,l),6);case 6:m=w.getYieldResultJsc();if(!d.playerInterface_)return w.return();d.playerInterface_.mediaSourceEngine.appendDependency(m,0,f);d.requestedDependencySegments_=[];w.leaveTryBlock(3);break;case 4:throw n=w.enterCatchBlock(),a.lastInitSegmentReference=null,n;case 3:if(a.lastSegmentReference&&a.lastSegmentReference==k){w.jumpTo(0);break}a.lastSegmentReference=k;w.setCatchFinallyBlocks(8);
return w.yield(d.fetch_(a,k),10);case 10:p=w.getYieldResultJsc();if(!d.playerInterface_)return w.return();d.playerInterface_.mediaSourceEngine.appendDependency(p,0,f);d.requestedDependencySegments_.push(k.startTime);w.leaveTryBlock(9);break;case 8:throw q=w.enterCatchBlock(),a.lastSegmentReference=null,q;case 9:if(!d.playerInterface_)return w.return();if(!a.waitingToClearBuffer)if(r=null,a.type===e.VIDEO?r=d.mediaStates_.get(e.AUDIO):a.type===e.AUDIO&&(r=d.mediaStates_.get(e.VIDEO)),r&&r.type==e.AUDIO)d.playerInterface_.onSegmentAppended(k,
a.stream,r.stream.isAudioMuxedInVideo,!0);else d.playerInterface_.onSegmentAppended(k,a.stream,a.stream.codecs.includes(","),!0);t=Math.max.apply(Math,[0].concat((0,$jscomp.arrayFromIterable)(d.requestedDependencySegments_)));u=d.playerInterface_.getPresentationTime();if(u+c>t)return w.yield(d.fetchAndAppendDependency_(a,k.startTime,c),0);w.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,r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.getNextAddressJsc()){case 1:d=shaka.media.StreamingEngine.logPrefix_(a);e=!1;f=(0,$jscomp.makeIterator)(c.mediaStates_.values());for(g=f.next();!g.done;g=f.next())if(h=g.value,h!=a&&h.recovering){e=!0;break}if(e){shaka.log.debug(d,"MediaSource threw QuotaExceededError:","waiting for another stream to recover...");u.jumpTo(2);
break}if(c.config_.avoidEvictionOnQuotaExceededError){(k=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);if(l=c.playerInterface_.disableStream(a.stream,k))return u.return();c.scheduleUpdate_(a,4);return u.return()}m=Math.round(100*c.bufferingScale_);if(m>20){c.bufferingScale_-=.2;u.jumpTo(3);break}if(m>4){c.bufferingScale_-=.04;u.jumpTo(3);break}(n=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);p=c.playerInterface_.disableStream(a.stream,
n);if(!p){shaka.log.error(d,"MediaSource threw QuotaExceededError too many times");a.hasError=!0;c.fatalError_=!0;c.playerInterface_.onError(b);u.jumpTo(5);break}c.bufferingScale_=1;q=c.playerInterface_.getPresentationTime();return u.yield(c.evict_(a,q),5);case 5:return u.return();case 3:return r=Math.round(100*c.bufferingScale_),shaka.log.warning(d,"MediaSource threw QuotaExceededError:","reducing buffering goals by "+(100-r)+"%"),a.recovering=!0,t=c.playerInterface_.getPresentationTime(),u.yield(c.evict_(a,
t),2);case 2:c.scheduleUpdate_(a,4),u.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,u,w,v,x,y,A,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){switch(D.getNextAddressJsc()){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){D.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);u=a.lastCodecs&&a.lastMimeType&&d.playerInterface_.mediaSourceEngine.isResetMediaSourceNecessary(a.type,r,p,d.getStreamsByType_());if(!u){D.jumpTo(3);break}w=null;a.type===e.VIDEO?w=d.mediaStates_.get(e.AUDIO):a.type===e.AUDIO&&(w=d.mediaStates_.get(e.VIDEO));if(!w){D.jumpTo(3);break}return D.yield(d.abortOperations_(w).catch(function(){}),5);case 5:w.lastInitSegmentReference=null,w.lastAppendWindowStart=null,w.lastAppendWindowEnd=null,d.forceClearBuffer_(w);case 3:return D.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"),v=d.fetch_(a,b.initSegmentReference),x=function(){var z,C,E,G,I,F,J,K,H,M,L,N,P;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Q){switch(Q.getNextAddressJsc()){case 1:return Q.setCatchFinallyBlocks(2),Q.yield(v,4);case 4:return z=
Q.getYieldResultJsc(),d.destroyer_.ensureNotDestroyed(),C=null,E=new Map,G={projection:null,hfov:null},a.stream&&(I=a.stream.videoLayout)&&(F=I.split("/"),F.includes("PROJ-RECT")?G.projection="rect":F.includes("PROJ-EQUI")?G.projection="equi":F.includes("PROJ-HEQU")?G.projection="hequ":F.includes("PROJ-PRIM")?G.projection="prim":F.includes("PROJ-AIV")&&(G.projection="hequ")),J=new shaka.util.Mp4Parser,K=shaka.util.Mp4Parser,H=shaka.util.Mp4BoxParsers,J.box("moov",K.children).box("trak",K.children).box("mdia",
K.children).fullBox("mdhd",function(O){goog.asserts.assert(O.version!=null,"MDHD is a full box and should have a valid version.");C=H.parseMDHD(O.reader,O.version).timescale}).fullBox("hdlr",function(O){goog.asserts.assert(O.version!=null,"HDLR is a full box and should have a valid version.");switch(H.parseHDLR(O.reader).handlerType){case "soun":E.set(e.AUDIO,C);break;case "vide":E.set(e.VIDEO,C)}C=null}),a.type!==e.VIDEO||G.projection||J.box("minf",K.children).box("stbl",K.children).fullBox("stsd",
K.sampleDescription).boxes("encv avc1 avc3 hev1 hvc1 dvav dva1 dvh1 dvhe dvc1 dvi1".split(" "),K.visualSampleEntry).box("vexu",K.children).box("proj",K.children).fullBox("prji",function(O){O=H.parsePRJI(O.reader);G.projection=O.projection}).box("hfov",function(O){O=H.parseHFOV(O.reader);G.hfov=O.hfov}),J.parse(z,!0,!0),a.type===e.VIDEO&&d.updateSpatialVideoInfo_(G),E.has(a.type)?b.initSegmentReference.timescale=E.get(a.type):C!=null&&(b.initSegmentReference.timescale=C),M=a.stream.segmentIndex,M instanceof
shaka.media.MetaSegmentIndex&&(L=M.getTimelineForTime(b.startTime)),shaka.log.v1(h,"appending init segment"),N=a.stream.closedCaptions&&a.stream.closedCaptions.size>0,Q.yield(d.playerInterface_.beforeAppendSegment(a.type,z),5);case 5:return Q.yield(d.playerInterface_.mediaSourceEngine.appendBuffer(a.type,z,null,a.stream,N,a.seeked,c,!1,!1,L),6);case 6:Q.leaveTryBlock(0);break;case 2:throw P=Q.enterCatchBlock(),a.lastInitSegmentReference=null,P;}})},y=b.startTime,k&&(A=d.playerInterface_.mediaSourceEngine.bufferEnd(a.type),
A!=null&&(y=A)),d.playerInterface_.onInitSegmentAppended(y,b.initSegmentReference),l.push(x()))),B=a.lastSegmentReference?a.lastSegmentReference.discontinuitySequence:-1,b.discontinuitySequence!=B&&l.push(d.playerInterface_.mediaSourceEngine.resync(a.type,b.startTime)),D.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.getNextAddressJsc()){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.getNextAddressJsc()){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 u,w,v,x,y,A;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){goog.asserts.assert(t.version!=null,"TFDT is a full box and should have a valid version.");u=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(t.reader,t.version);w=u.baseMediaDecodeTime;
if(!w)return B.return();goog.asserts.assert(typeof n=="number","Should be an number!");v=-w/n;x=Number(a.lastTimestampOffset)||0;if(!(x<v))return B.jumpTo(0);y=a.lastAppendWindowStart;A=a.lastAppendWindowEnd;goog.asserts.assert(typeof y=="number","Should be an number!");goog.asserts.assert(typeof A=="number","Should be an number!");return B.yield(h.setProperties_(a,v,y,A,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.getNextAddressJsc()==1){c.lastTextMediaStateBeforeUnload_==a&&(c.lastTextMediaStateBeforeUnload_=null);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 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.getNextAddressJsc()!=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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc();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.net.NetworkingUtils.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.getNextAddressJsc()==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.getNextAddressJsc()!=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.Timer(function(){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return g.setCatchFinallyBlocks(2),
g.yield(c.onUpdate_(a),4);if(g.getNextAddressJsc()!=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,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 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),l.return()):l.yield(c.failureCallbackBackoff_.attempt(),2);case 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),l.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){l.jumpTo(3);break}f=c.playerInterface_.getPresentationTime();g=c.playerInterface_.mediaSourceEngine.bufferEnd(a.type);for(h=c.getSegmentReferenceNeeded_(a,
f,g);((k=h)==null?void 0:k.getStatus())===shaka.media.SegmentReference.Status.MISSING;)a.lastSegmentReference=h,h=c.getSegmentReferenceNeeded_(a,f,g);if(!h){l.jumpTo(3);break}return l.yield(c.playerInterface_.mediaSourceEngine.resync(a.type,h.startTime),5);case 5:return a.performingUpdate=!1,a.hasError=!1,c.cancelUpdate_(a),c.scheduleUpdate_(a,0),l.return();case 3:if(!b.handled||b.code!=shaka.util.Error.Code.SEGMENT_MISSING)c.playerInterface_.onError(b);b.handled||c.config_.failureCallback(b);l.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.getNextAddressJsc()==1){d=Date.now()/1E3;e=c.config_.minTimeBetweenRecoveries;if(!a&&(!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.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(!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,d=shaka.util.ManifestParserUtils.ContentType;if(a.type===d.TEXT)return!1;var e=a.lastInitSegmentReference;if(!e)return!1;var f=shaka.config.CrossBoundaryStrategy,g=shaka.media.StreamingEngine.logPrefix_(a),h=b.initSegmentReference,k=e.boundaryEnd!==h.boundaryEnd;this.config_.crossBoundaryStrategy===f.RESET_TO_ENCRYPTED&&(e.encrypted||h.encrypted||(k=!1),e.encrypted&&(shaka.log.debug(g,"stream is encrypted, discard crossBoundaryStrategy"),
this.config_.crossBoundaryStrategy=f.KEEP));this.config_.crossBoundaryStrategy===f.RESET_ON_ENCRYPTION_CHANGE&&e.encrypted==h.encrypted&&(k=!1);if(this.config_.crossBoundaryStrategy===f.KEEP&&e.mimeType&&h.mimeType){var l=shaka.util.MimeUtils;f=l.getNormalizedCodec(l.getCodecs(e.mimeType));l=l.getNormalizedCodec(l.getCodecs(h.mimeType));e.mimeType==h.mimeType&&f==l&&(k=!1)}(this.mediaStates_.get(d.VIDEO)||this.mediaStates_.get(d.AUDIO))===a&&k&&(this.crossBoundarySeek_||a.seeked)&&(shaka.log.debug(g,
"reset mediaSource","from=",a.lastInitSegmentReference,"to=",b.initSegmentReference),this.crossBoundarySeek_=!1,this.resetMediaSource(!0).then(function(){var m=shaka.util.FakeEvent.EventName.BoundaryCrossed,n=(new Map).set("oldEncrypted",e.encrypted).set("newEncrypted",h.encrypted);c.playerInterface_.onEvent(new shaka.util.FakeEvent(m,n))}));return k};
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.media.StreamingEngine.LOOKUP_TIME_DURATION_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,g=new Set(["__proto__","constructor","prototype"]);var h=f?c.constructor==Object&&Object.keys(d).length==0:c.constructor==Object&&Object.keys(c).length==0;for(var k=f||h,l=!0,m=(0,$jscomp.makeIterator)(Object.keys(b)),n=m.next();!n.done;n=m.next()){n=n.value;var p=e+"."+n,q=f?d[e]:c[n];g.has(n)?(shaka.log.alwaysError("Invalid config, dangerous key "+p),l=!1):k||
n in c?b[n]===void 0?q===void 0||k?delete a[n]:a[n]=shaka.util.ObjectUtils.cloneObject(q):h?a[n]=b[n]:q.constructor==Object&&b[n]&&b[n].constructor==Object?(a[n]||(a[n]=shaka.util.ObjectUtils.cloneObject(q)),n=shaka.util.ConfigUtils.mergeConfigObjects(a[n],b[n],q,d,p),l=l&&n):typeof b[n]!=typeof q||b[n]==null||typeof b[n]!="function"&&b[n].constructor!=q.constructor?(shaka.log.alwaysError("Invalid config, wrong type for "+p),l=!1):typeof c[n]=="function"&&c[n].length!=b[n].length?(shaka.log.alwaysWarn("Unexpected number of arguments for "+
p),a[n]=b[n]):Array.isArray(a[n])?a[n]=b[n].slice():a[n]=b[n]:(shaka.log.alwaysError("Invalid config, unrecognized key "+p),l=!1)}return l};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.config.RepeatMode={OFF:0,ALL:1,SINGLE:2};goog.exportSymbol("shaka.config.RepeatMode",shaka.config.RepeatMode);shaka.drm.FairPlay=function(){};shaka.drm.FairPlay.isFairPlaySupported=function(){var a;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==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.getNextAddressJsc()!=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.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(c){return shaka.util.MimeUtils.getCodecBase(c)});b=shaka.util.MimeUtils.splitCodecs(b.codecs).map(function(c){return shaka.util.MimeUtils.getCodecBase(c)});return shaka.util.ArrayUtils.hasSameElements(a,b)};shaka.media.AdaptationSet.areRolesEqual_=function(a,b){return shaka.util.ArrayUtils.hasSameElements(a,b)};
goog.exportSymbol("shaka.media.AdaptationSet",shaka.media.AdaptationSet);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=shaka.device.DeviceFactory.getDevice();b=this.config_.codecSwitchingStrategy==shaka.config.CodecSwitchingStrategy.SMOOTH&&b.supportsSmoothCodecSwitching();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.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;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.getNextAddressJsc()==1)return navigator.storage&&navigator.storage.estimate?m.yield(navigator.storage.estimate(),3):m.return(!0);l=m.getYieldResultJsc();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,m){return shaka.util.ConfigUtils.referenceParametersAndReturn([k,l,m],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:!1},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){a>=0&&(this.loadLatencySeconds_=a)};shaka.util.Stats.prototype.setManifestTime=function(a){a>=0&&(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){a>=0&&(this.drmTimeSeconds_=a)};shaka.util.Stats.prototype.setLicenseTime=function(a){a>=0&&(this.licenseTimeSeconds_=a)};shaka.util.Stats.prototype.setLiveLatency=function(a){a>=0&&(this.liveLatencySeconds_=a)};
shaka.util.Stats.prototype.setMaxSegmentDuration=function(a){a>=0&&(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.getNextAddressJsc()){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:return c.yield(a.validatePrefetchedVariant_(),
8);case 8:a.throwIfDestroyed_();if(!a.allowPrefetch_){c.jumpTo(9);break}return c.yield(a.prefetchInner_(),10);case 10:a.throwIfDestroyed_();case 9:if(!a.allowPrefetch_||!a.drmEngine_){c.jumpTo(11);break}return c.yield(a.drmEngine_.waitForActiveRequests(),12);case 12:a.throwIfDestroyed_();case 11: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.getNextAddressJsc()){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.getYieldResultJsc(),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.getNextAddressJsc()){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.getYieldResultJsc();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;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){a.currentAdaptationSetCriteria_||(a.currentAdaptationSetCriteria_=a.config_.adaptationSetCriteriaFactory(),a.currentAdaptationSetCriteria_.configure({language:a.config_.preferredAudioLanguage,role:a.config_.preferredAudioRole,videoRole:a.config_.preferredVideoRole,channelCount:0,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 b.jumpTo(0);a.prefetchedVariant_=a.configureAbrManagerAndChooseVariant_();
return a.prefetchedVariant_?b.yield(a.createSegmentIndexFromVariant_(a.prefetchedVariant_),0):b.jumpTo(0)})};shaka.media.PreloadManager.prototype.shouldCreateSegmentIndexBeforeDrmEngineInitialization_=function(){if(this.prefetchedVariant_)return!1;goog.asserts.assert(this.manifest_,"The manifest should already be parsed.");return this.manifest_.variants.length?this.manifest_.variants.length==1||this.manifest_.type==shaka.media.ManifestParser.HLS?!0:!1:!1};
shaka.media.PreloadManager.prototype.validatePrefetchedVariant_=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1)return!a.prefetchedVariant_||a.manifest_.variants.includes(a.prefetchedVariant_)?b.jumpTo(0):b.yield(a.closeSegmentIndexFromVariant_(a.prefetchedVariant_),3);a.prefetchedVariant_=a.configureAbrManagerAndChooseVariant_();return a.prefetchedVariant_?b.yield(a.createSegmentIndexFromVariant_(a.prefetchedVariant_),0):b.jumpTo(0)})};
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.getNextAddressJsc()==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.createSegmentIndexFromVariant_=function(a){var b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)([a.video,a.audio]);for(d=c.next();!d.done;d=c.next())(e=d.value)&&!e.segmentIndex&&b.push(e.createSegmentIndex());return b.length>0?f.yield(Promise.all(b),0):f.jumpTo(0)})};
shaka.media.PreloadManager.prototype.closeSegmentIndexFromVariant_=function(a){var b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)([a.video,a.audio]);for(d=c.next();!d.done;d=c.next())(e=d.value)&&e.segmentIndex&&e.closeSegmentIndex&&b.push(e.closeSegmentIndex());return b.length>0?f.yield(Promise.all(b),0):f.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.getNextAddressJsc()==1)return a.destroyed_=!0,!a.parser_||a.parserEntrusted_?e.jumpTo(2):e.yield(a.parser_.stop(),2);if(e.getNextAddressJsc()!=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};/*
 @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$267=(0,$jscomp.makeIterator)(Object.keys(mozilla.LanguageMapping)),
$jscomp$key$2089745539$0$key$jscomp$105=$jscomp$iter$267.next();!$jscomp$key$2089745539$0$key$jscomp$105.done;$jscomp$key$2089745539$0$key$jscomp$105=$jscomp$iter$267.next()){var key$jscomp$105=$jscomp$key$2089745539$0$key$jscomp$105.value;mozilla.LanguageMapping[key$jscomp$105.toLowerCase()]=mozilla.LanguageMapping[key$jscomp$105]};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$18:void 0},c=a.next())d.cue$jscomp$18=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(e.cue$jscomp$18,f)}}(d))||b.push(d.cue$jscomp$18);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(){var c;(c=b.timer_)==null||c.stop();b.timer_=null;b.eventManager_.unlisten(b.player_,shaka.util.FakeEvent.EventName.TextChanged,b.onTextChanged_);b.eventManager_.unlisten(b.video_.textTracks,"change",b.onChange_);c=(0,$jscomp.makeIterator)(b.trackNodes_.values());
for(var 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);if(e.language)if(e.language in mozilla.LanguageMapping)f.srclang=e.language;else{var g=shaka.util.LanguageUtils.getBase(e.language),h=void 0;f.srclang=(h=g)!=null?h:"und"}else f.srclang="und";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}var a;(a=this.timer_)==null||a.stop();this.timer_=null;var b;(b=this.eventManager_)==null||b.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===shaka.util.ManifestParserUtils.TextStreamKind.CLOSED_CAPTION?"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.pendingResize_=!1;this.resizeObserver_=null;"ResizeObserver"in window&&(this.resizeObserver_=new ResizeObserver(function(){c.pendingResize_||(c.pendingResize_=!0,requestAnimationFrame(function(){c.pendingResize_=!1;c.textContainer_&&c.textContainer_.parentElement&&c.isTextVisible_&&c.updateCaptions_(!0)}))}),goog.asserts.assert(this.videoContainer_,"this.videoContainer_ must be non-null"),
this.resizeObserver_.observe(this.videoContainer_));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$26:void 0},c=a.next())d.cue$jscomp$26=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(f,e.cue$jscomp$26)}}(d))||this.cues_.push(d.cue$jscomp$26);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")+"-"+a.regionAnchorX+"x"+a.regionAnchorY};
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)k=b.backgroundImage.replace(/['"()\\]/g,""),f.backgroundImage="url('"+k+"')",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="flex-start";
else if(b.textAlign==e.textAlign.RIGHT||b.textAlign==e.textAlign.END)f.width="100%",f.alignItems="flex-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_.has(a)&&this.requestTimestampMap_.delete(a);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);if(!Object.keys(a).length)return;Object.assign(b.headers,a)}else{var d=shaka.util.CmcdManager.toQuery(a);if(!d)return;b.uris=b.uris.map(function(e){return shaka.util.CmcdManager.appendQueryToUri(e,d)})}this.getResponseModeEnabledTargets().length>0||!this.requestTimestampMap_.has(b)||this.requestTimestampMap_.delete(b)};
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 "audio/x-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.getNextAddressJsc()==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.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.getNextAddressJsc()==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.getNextAddressJsc()!=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,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){d.preloadDueAdManagerTimer_.stop();if(d.preloadDueAdManager_)return h.jumpTo(0);d.preloadDueAdManagerVideo_=d.video_;d.preloadDueAdManagerVideoEnded_=d.isEnded();f=e.saveLivePosition||!1;g=!0;d.isLive()&&(g=f);return h.yield(d.detachAndSavePreload(!0,g),3)}d.preloadDueAdManager_=h.getYieldResultJsc();h.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(f.getNextAddressJsc()==1)return d.video_||!d.preloadDueAdManagerVideo_?f.jumpTo(0):f.yield(d.attach(d.preloadDueAdManagerVideo_,
!0),3);d.preloadDueAdManagerVideo_=null;f.jumpToEnd()})}));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.getNextAddressJsc()){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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc(),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.getNextAddressJsc()){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.getYieldResultJsc())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.getNextAddressJsc()==1){if(b.loadMode_==shaka.Player.LoadMode.DESTROYED)throw b.createAbortLoadError_();return c.yield(b.unload(!1,a),2)}if(c.getNextAddressJsc()!=3)return c.yield(b.atomicOperationAcquireMutex_("detach"),3);if(c.getYieldResultJsc())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.getNextAddressJsc()==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,u,w,v,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.getNextAddressJsc()){case 1:return c.loadMode_!=shaka.Player.LoadMode.DESTROYED&&(c.loadMode_=shaka.Player.LoadMode.NOT_LOADED),y.yield(c.atomicOperationAcquireMutex_("unload"),2);case 2:if(y.getYieldResultJsc())return y.return();y.setFinallyBlock(3);c.fullyLoaded_=!1;c.makeStateChangeEvent_("unload");
c.closeLcevcDec_();d=c.cleanupOnUnload_.map(function(A){return A()});c.cleanupOnUnload_=[];return y.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_){y.jumpTo(6);break}return y.yield(c.parser_.stop(),7);case 7:c.parser_=null,c.parserFactory_=null;case 6:c.abrManager_&&c.abrManager_.stop();if(!c.streamingEngine_){y.jumpTo(8);break}return y.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_){y.jumpTo(10);break}return y.yield(c.drmEngine_.destroy(),11);case 11:c.drmEngine_=null;case 10:if(!c.mediaSourceEngine_){y.jumpTo(12);break}return y.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_){y.jumpTo(14);break}return y.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_){y.jumpTo(16);break}return y.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_=[];u=(0,$jscomp.makeIterator)(c.deferredCloseSegmentIndex_.values());for(w=u.next();!w.done;w=u.next())v=w.value,v.stop();c.deferredCloseSegmentIndex_.clear();c.externalChaptersStreams_=[];c.completionPercent_=-1;c.networkingEngine_&&c.networkingEngine_.clearCommonAccessTokenMap();c.updateBufferState_();case 3:y.enterFinallyBlock();c.mutex_.release();y.leaveFinallyBlock(4);break;case 4:x=shaka.device.DeviceFactory.getDevice();
if(a&&x.supportsMediaSource()&&!c.mediaSourceEngine_&&c.video_)return y.yield(c.initializeMediaSourceEngineInner_(),0);y.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,u,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){case 1:if(d.loadMode_==shaka.Player.LoadMode.DESTROYED)throw d.createAbortLoadError_();if(d.video_||!d.preloadDueAdManagerVideo_){x.jumpTo(2);break}return x.yield(d.attach(d.preloadDueAdManagerVideo_,!0),3);case 3:d.preloadDueAdManagerVideo_=null;case 2:e=null;f="";c=(g=c)==null?void 0:g.toLowerCase();
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 x.yield(d.mutex_.acquire("load"),4);case 4: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_){x.jumpTo(5);break}d.assetUri_=
f;return x.yield(d.unload(!1),5);case 5:h=++d.operationId_;k=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==1)return d.operationId_==h?y.jumpTo(0):e?y.yield(e.destroy(),3):y.jumpTo(3);throw d.createAbortLoadError_();})};l=function(y,A){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){switch(B.getNextAddressJsc()){case 1:return B.setFinallyBlock(2),B.yield(d.mutex_.acquire(A),4);case 4:return B.yield(k(),5);case 5:return B.yield(y(),
6);case 6:return B.yield(k(),7);case 7:e&&d.config_&&e.reconfigure(d.config_);case 2:B.enterFinallyBlock(),d.mutex_.release(),B.leaveFinallyBlock(0)}})};x.setCatchFinallyBlocks(7,8);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();x.jumpTo(10);break}if(c){x.jumpTo(10);break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==
1)return y.yield(d.guessMimeType_(f),2);c=y.getYieldResultJsc();y.jumpToEnd()})},"guessMimeType_"),10);case 10:m=!!e;if(e){e.setEventHandoffTarget(d);d.stats_=e.getStats();x.jumpTo(13);break}return x.yield(d.preloadInner_(f,b,c,!0,d.config_),14);case 14:(e=x.getYieldResultJsc())?(e.markIsLoad(),e.setEventHandoffTarget(d),d.stats_=e.getStats(),e.start(),e.waitForFinish().catch(function(){})):d.stats_=new shaka.util.Stats;case 13:n=!e;p=Date.now()/1E3;d.stats_=e?e.getStats():new shaka.util.Stats;d.assetUri_=
f;d.mimeType_=c||null;d.updateBufferState_();q=function(){var y=d.video_?d.video_.buffered:null;return{start:shaka.media.TimeRangesUtils.bufferStart(y)||0,end:shaka.media.TimeRangesUtils.bufferEnd(y)||0}};d.metadataRegionTimeline_=new shaka.media.RegionTimeline(q);d.metadataRegionTimeline_.addEventListener("regionadd",function(y){d.dispatchMetadataEvent_(y.region,shaka.util.FakeEvent.EventName.MetadataAdded)});if(n)return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){goog.asserts.assert(c,
"We should know the mimeType by now!");return y.yield(d.initializeSrcEqualsDrmInner_(c),0)})},"initializeSrcEqualsDrmInner_"),25);d.emsgRegionTimeline_=new shaka.media.RegionTimeline(q);return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==1)return y.yield(e.waitForManifest(),2);d.parserFactory_=e.getParserFactory();d.parser_=e.receiveParser();d.manifest_=e.getManifest();y.jumpToEnd()})},"waitForFinish"),17);case 17:if(d.mediaSourceEngine_){x.jumpTo(18);
break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.initializeMediaSourceEngineInner_(),0)})},"initializeMediaSourceEngineInner_"),18);case 18: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!')),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(e.waitForFinish(),
0)})},"waitForFinish"),20);case 20: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(r=e.getCurrentAdaptationSetCriteria())d.currentAdaptationSetCriteria_=r;m&&d.video_&&d.video_.nodeName==="AUDIO"&&(d.makeManifestAudioOnly_(),d.configure("manifest.disableVideo",!0));if(e.getDrmEngine()){x.jumpTo(21);break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(e.initializeDrm(d.video_),
0)})},"drmEngine_.init"),21);case 21:return d.drmEngine_=e.receiveDrmEngine(),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.drmEngine_.attach(d.video_),0)})},"drmEngine_.attach"),23);case 23:return t=d.config_.abrFactory,d.abrManager_&&d.abrManagerFactory_==t||(d.abrManagerFactory_=t,d.abrManager_&&d.abrManager_.release(),d.abrManager_=t(),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)),u=e.receiveSegmentPrefetchesById(),w=e.getPrefetchedVariant(),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.loadInner_(p,w,u),0)})},"loadInner_"),24);case 24:e.stopQueuingLatePhaseQueuedOperations();d.mimeType_&&shaka.device.DeviceFactory.getDevice().supportsAirPlay()&&shaka.util.MimeUtils.isHlsType(d.mimeType_)&&d.mediaSourceEngine_.addSecondarySource(d.assetUri_,
d.mimeType_);x.jumpTo(16);break;case 25:return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){goog.asserts.assert(c,"We should know the mimeType by now!");return y.yield(d.srcEqualsInner_(p,c),0)})},"srcEqualsInner_"),16);case 16:d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Loaded));case 8:x.enterFinallyBlock();if(!e){x.jumpTo(27);break}return x.yield(e.destroy(),27);case 27:d.preloadNextUrl_=null;x.leaveFinallyBlock(0);break;case 7:v=
x.enterCatchBlock();if(!v||v.code==shaka.util.Error.Code.LOAD_INTERRUPTED){x.jumpTo(29);break}return x.yield(d.unload(!1),29);case 29: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,c){a=a===void 0?!0:a;b=b===void 0?!1:b;c=c===void 0?!1:c;var d=this,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){return f.getNextAddressJsc()==1?f.yield(d.savePreload_(c),2):f.getNextAddressJsc()!=3?(e=f.getYieldResultJsc(),f.yield(d.unload(a,b),3)):f.return(e)})};
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.getNextAddressJsc()==1?e.yield(c.savePreload_(b),2):e.getNextAddressJsc()!=3?(d=e.getYieldResultJsc(),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.getNextAddressJsc()==1){c=null;if(!(b.manifest_&&b.parser_&&b.parserFactory_&&b.assetUri_&&b.config_))return f.jumpTo(2);d=b.video_.currentTime;a||(d=null);return f.yield(b.makePreloadManager_(b.assetUri_,d,b.mimeType_,b.config_,!0,!1),3)}f.getNextAddressJsc()!=2&&(c=f.getYieldResultJsc(),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,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1)return goog.asserts.assert(e.config_,"Config must not be null!"),c=(f=c)==null?void 0:f.toLowerCase(),g=e.defaultConfig_(),shaka.util.PlayerConfiguration.mergeConfigObjects(g,d||e.config_,e.defaultConfig_()),k.yield(e.preloadInner_(a,b,c,!1,g),2);if(h=k.getYieldResultJsc())h.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 k.return(h)})};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.getNextAddressJsc()==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.getNextAddressJsc()!=2&&(c=m.getYieldResultJsc());if(g=f.shouldUseSrcEquals_(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,u,w,v,x,y,A;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){if(B.getNextAddressJsc()==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 B.jumpTo(2);n=shaka.device.DeviceFactory.getDevice();goog.asserts.assert(n,"device must be non-null");return B.yield(n.detectMaxHardwareResolution(),3)}B.getNextAddressJsc()!=2&&(p=B.getYieldResultJsc(),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(D){var z,
C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){if(E.getNextAddressJsc()==1)return E.yield(q.filterManifest(D),2);if(E.getNextAddressJsc()!=4){z=E.getYieldResultJsc();if(!z)return E.jumpTo(0);C=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return E.yield(Promise.resolve(),4)}h.dispatchEvent(C);E.jumpToEnd()})},makeTextStreamsForClosedCaptions:function(D){return g.makeTextStreamsForClosedCaptions_(D)},onTimelineRegionAdded:function(D){h.getRegionTimeline().addRegion(D)},
onEvent:function(D){return h.dispatchEvent(D)},onError:function(D){return h.onError(D)},isLowLatencyMode:function(){return m().streaming.lowLatencyMode},updateDuration:function(){g.streamingEngine_&&h.hasBeenAttached()&&g.streamingEngine_.updateDuration()},newDrmInfo:function(D){var z=h.getDrmEngine(),C=z?z.getDrmInfo():null;C&&z.getMediaKeys()&&q.processDrmInfos(C.keySystem,D)},onManifestUpdated:function(){var D=shaka.util.FakeEvent.EventName.ManifestUpdated,z=(new Map).set("isLive",g.isLive());
h.dispatchEvent(shaka.Player.makeEvent_(D,z));h.addQueuedOperation(!1,function(){if(g.adManager_)g.adManager_.onManifestUpdated(g.isLive())})},getBandwidthEstimate:function(){return g.abrManager_.getBandwidthEstimate()},onMetadata:function(D,z,C,E){var G=D;if(D=="com.apple.hls.interstitial"||D=="com.apple.hls.overlay")G="com.apple.quicktime.HLS",D={startTime:z,endTime:C,values:E},g.adManager_&&(goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onHLSInterstitialMetadata(g,g.video_,D));E=
(0,$jscomp.makeIterator)(E);D=E.next();for(var I={};!D.done;I={payload$jscomp$7:void 0},D=E.next())I.payload$jscomp$7=D.value,I.payload$jscomp$7.name!="ID"&&h.addQueuedOperation(!1,function(F){return function(){g.addMetadataToRegionTimeline_(z,C,G,F.payload$jscomp$7)}}(I))},disableStream:function(D){return g.disableStream(D,g.config_.streaming.maxDisabledTime)},addFont:function(D,z){return g.addFont(D,z)}};t=new shaka.media.RegionTimeline(function(){return g.seekRange()});t.addEventListener("regionadd",
function(D){var z=D.region;g.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionAdded,z,h);h.addQueuedOperation(!1,function(){g.adManager_&&(g.adManager_.onDashTimedMetadata(z),goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onDASHInterstitialMetadata(g,g.video_,z))})});u=null;k.streaming.observeQualityChanges&&(u=new shaka.media.QualityObserver(function(){return g.getBufferedInfo()}),u.addEventListener("qualitychange",function(D){g.onMediaQualityChange_(D.quality,D.position)}),
u.addEventListener("audiotrackchange",function(D){g.onMediaQualityChange_(D.quality,D.position,!0)}));w=!0;v={netEngine:g.networkingEngine_,onError:function(D){return h.onError(D)},onKeyStatus:function(D){h.addQueuedOperation(!0,function(){if(g.drmEngine_)g.onKeyStatus_(D)})},onExpirationUpdated:function(D,z){var C=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ExpirationUpdated);h.dispatchEvent(C);if((C=h.getParser())&&C.onExpirationUpdated)C.onExpirationUpdated(D,z)},onEvent:function(D){h.dispatchEvent(D);
D.type==shaka.util.FakeEvent.EventName.DrmSessionUpdate&&w&&(w=!1,D=Date.now()/1E3-h.getStartTimeOfDRM(),(g.stats_||h.getStats()).setDrmTime(D),g.lcevcDec_&&g.lcevcDec_.hideCanvas())}};x=g.createNetworkingEngine(l);g.networkingEngine_.copyFiltersInto(x);y=function(){return g.createDrmEngine(v)};A={config:k,manifestPlayerInterface:r,regionTimeline:t,qualityObserver:u,createDrmEngine:y,manifestFilterer:q,networkingEngine:x,allowPrefetch:e};h=new shaka.media.PreloadManager(a,c,b,A);return B.return(h)})};
shaka.Player.prototype.guessMimeType_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==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.getYieldResultJsc();shaka.util.MimeUtils.isHlsType(d)?(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){var b=shaka.util.MimeUtils;if(!shaka.device.DeviceFactory.getDevice().supportsMediaSource())return!0;if(a){var c=(this.video_||shaka.util.Dom.anyMediaElement()).canPlayType(a)!="";if(!c)return!1;var d=shaka.media.ManifestParser.isSupported(a);if(!d)return!0;goog.asserts.assert(c&&d,"Both native and MSE playback should be possible!");if(b.isHlsType(a))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(b.isDashType(a))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.getNextAddressJsc()==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.setupPlayRateController_=function(a){var b=this;this.playRateController_=new shaka.media.PlayRateController({getRate:function(){return a.playbackRate},getDefaultRate:function(){return a.defaultPlaybackRate},setRate:function(c){a.playbackRate=c},movePlayhead:function(c){var d=a.currentTime;if(shaka.media.TimeRangesUtils.isBuffered(a.buffered,d)&&!(a.readyState<=HTMLMediaElement.HAVE_CURRENT_DATA)){c=d+c;var e=b.seekRange();c<e.start?d!==e.start&&(a.currentTime=e.start):c>e.end?
d!==e.end&&(a.currentTime=e.end):a.currentTime=c}},isPaused:function(){return a.paused}})};
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.getNextAddressJsc()==1)return c.streamingEngine_&&a.remote.state=="disconnected"?f.yield(c.streamingEngine_.resetMediaSource(),3):f.jumpTo(2);if(f.getNextAddressJsc()!=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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(L){switch(L.getNextAddressJsc()){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.setupPlayRateController_(e);d.addBasicMediaListeners_(e,a);"onchange"in window.screen&&d.loadEventManager_.listen(window.screen,"change",function(){if(d.currentAdaptationSetCriteria_.getConfiguration){var N=d.currentAdaptationSetCriteria_.getConfiguration();N.hdrLevel=="AUTO"?d.updateAbrManagerVariants_():d.config_.preferredVideoHdrLevel=="AUTO"&&d.config_.abr.enabled&&(N.hdrLevel="AUTO",d.currentAdaptationSetCriteria_.configure(N),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(N,P,Q){return d.switch_(N,
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||(q=d.chooseVariant_(!0),b||(m=q),goog.asserts.assert(m,"Must choose an initial variant!"));r=[];n=p||m;t=(0,$jscomp.makeIterator)([n.video,
n.audio]);for(u=t.next();!u.done;u=t.next())(w=u.value)&&!w.segmentIndex&&(r.push(w.createSegmentIndex()),w.dependencyStream&&r.push(w.dependencyStream.createSegmentIndex()));if(!(r.length>0)){L.jumpTo(4);break}return L.yield(Promise.all(r),4);case 4:if(!n||n.disabledUntilTime!=0){L.jumpTo(2);break}d.updateAbrManagerVariants_();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(N){d.playhead_=d.createPlayhead(N);d.playheadObservers_=d.createPlayheadObserversForMSE_(N);d.startBufferManagement_(e,!1)};d.config_.streaming.startAtSegmentBoundary||(x=d.startTime_,x==null&&d.manifest_.startTime&&(x=d.manifest_.startTime),v(x));if(p){L.jumpTo(7);break}goog.asserts.assert(m,"Must have chosen an initial variant!");if(!d.config_.streaming.startAtSegmentBoundary){L.jumpTo(8);
break}y=d.manifest_.presentationTimeline;d.startTime_ instanceof Date&&(B=y.getInitialProgramDateTime()||y.getPresentationStartTime(),goog.asserts.assert(B!=null,"Presentation start time should not be null!"),D=d.startTime_.getTime()/1E3-B,D!=null&&(A=D));A==null&&(A=typeof d.startTime_==="number"?d.startTime_:d.isLive()?Infinity:d.video_.currentTime);d.startTime_==null&&d.manifest_.startTime&&(A=d.manifest_.startTime);z=y.getSeekRangeStart();C=y.getSeekRangeEnd();A<z?A=z:A>C&&(A=C);return L.yield(d.adjustStartTime_(m,
A),9);case 9:E=L.getYieldResultJsc(),v(E);case 8:d.switchVariant_(m,!0,!1,0);case 7:return d.playhead_.ready(),G=d.getTextTracks().find(function(N){return N.active}),G||((I=d.chooseTextStream_())&&d.addTextStreamToSwitchHistory_(I,!0),m&&d.setInitialTextState_(m,I),I&&d.shouldStreamText_()&&(d.streamingEngine_.switchTextStream(I),d.setTextDisplayerLanguage_())),L.yield(d.streamingEngine_.start(c),10);case 10:d.config_.abr.enabled&&(d.abrManager_.enable(),d.onAbrStatusChanged_());d.onTracksChanged_();
F=d.manifest_.variants.some(function(N){return N.primary});d.config_.preferredAudioLanguage||F||shaka.log.warning("No preferred audio language set.  We have chosen an arbitrary language initially");if((J=d.isLive())&&(d.config_.streaming.liveSync&&d.config_.streaming.liveSync.enabled||d.manifest_.serviceDescription||d.config_.streaming.liveSync.panicMode)||d.config_.streaming.vodDynamicPlaybackRate)K=function(){return d.onTimeUpdate_()},d.loadEventManager_.listen(e,"timeupdate",K);J||(H=function(){return d.onVideoProgress_()},
d.loadEventManager_.listen(e,"timeupdate",H),d.onVideoProgress_(),d.manifest_.nextUrl&&(d.config_.streaming.preloadNextUrlWindow>0&&(M=function(){var N;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==1){N=d.seekRange().end-d.video_.currentTime;if(isNaN(N)||!(N<=d.config_.streaming.preloadNextUrlWindow))return P.jumpTo(0);d.loadEventManager_.unlisten(e,"timeupdate",M);goog.asserts.assert(d.manifest_.nextUrl,"this.manifest_.nextUrl should be valid.");return P.yield(d.preload(d.manifest_.nextUrl),
4)}d.preloadNextUrl_=P.getYieldResultJsc();P.jumpToEnd()})},d.loadEventManager_.listen(e,"timeupdate",M)),d.loadEventManager_.listen(e,"ended",function(){d.load(d.preloadNextUrl_||d.manifest_.nextUrl)})));if(d.adManager_)d.adManager_.onManifestUpdated(J);L.jumpToEnd()}})};
shaka.Player.prototype.initializeSrcEqualsDrmInner_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){return f.getNextAddressJsc()==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.getNextAddressJsc()){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.setupPlayRateController_(d);c.startBufferManagement_(d,!0);d.textTracks&&(c.createAndConfigureTextDisplayer_(),f=function(u){if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer)){var w=c.getFilteredTextTracks_().find(function(v){return v.mode!=="disabled"});w&&(w.mode=u?"showing":"hidden");c.textDisplayer_ instanceof shaka.text.SimpleTextDisplayer&&(w=c.getGeneratedTextTrack_())&&
(w.mode=!u&&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=function(){return new Promise(function(u){var w=new shaka.util.Timer(u);c.loadEventManager_.listen(d.textTracks,"change",function(){return w.tickAfter(.5)});w.tickAfter(.5)})},m=new shaka.util.PublicPromise,shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_METADATA,c.loadEventManager_,function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){if(u.getNextAddressJsc()==
1)return c.playhead_.ready(),c.mimeType_&&shaka.util.MimeUtils.isHlsType(c.mimeType_)?u.yield(l(),3):(m.resolve(),u.jumpTo(0));m.resolve();u.jumpToEnd()})}),shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_CURRENT_DATA,c.loadEventManager_,function(){var u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){if(A.getNextAddressJsc()==1)return A.yield(l(),2);if(e)return A.return();c.setupPreferredAudioOnSrc_();u=c.getFilteredTextTracks_();u.some(function(B){return B.mode===
"showing"})&&(c.isTextVisible_=!0,c.textDisplayer_.setTextVisibility(!0));if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer))for(u.length&&(c.textDisplayer_.enableTextDisplayer?c.textDisplayer_.enableTextDisplayer():shaka.Deprecate.deprecateFeature(5,"Text displayer w/ enableTextDisplayer",'Text displayer should have a "enableTextDisplayer" method')),w=!1,v=(0,$jscomp.makeIterator)(u),x=v.next();!x.done;x=v.next())y=x.value,y.mode!=="disabled"&&(w?(y.mode="disabled",shaka.log.alwaysWarn("Found more than one enabled text track, disabling it",
y)):(c.enableNativeTrack_(y),w=!0));c.setupPreferredTextOnSrc_();A.jumpToEnd()})}),d.error?m.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.'),m.resolve()),c.loadEventManager_.listenOnce(d,"error",function(){m.reject(c.videoErrorToShakaError_())}),
t.yield(shaka.util.Functional.promiseWithTimeout(c.config_.streaming.loadTimeout,m),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 u=c.seekRange().end;r!=u&&(c.adManager_.onManifestUpdated(c.isLive()),r=u)})));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$41:void 0},
f=e.next())g.cue$jscomp$41=f.value,g.cue$jscomp$41.type=="com.apple.quicktime.HLS"&&g.cue$jscomp$41.startTime!=null&&(f=d.find(function(h){return function(k){return k.startTime==h.cue$jscomp$41.startTime&&k.endTime==h.cue$jscomp$41.endTime}}(g)),f||(f={startTime:g.cue$jscomp$41.startTime,endTime:g.cue$jscomp$41.endTime,values:[]},d.push(f)),f.values.push(g.cue$jscomp$41.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)});
this.loadEventManager_.listen(a,d.TIME_UPDATE,function(e){return c.pollBufferState_(d.TIME_UPDATE)});b&&(this.loadEventManager_.listen(a,d.PROGRESS,function(e){return c.pollBufferState_(d.PROGRESS)}),this.loadEventManager_.listen(a,d.STALLED,function(e){return c.pollBufferState_(d.STALLED)}))};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.video_.currentTime)&&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,e){a.onSegmentAppended_(b.startTime,b.endTime,c.type,d,e);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=Math.min(this.video_.currentTime+this.config_.streaming.bufferingGoal,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!");if(a==0)shaka.log.alwaysWarn("A trick play rate of 0 is unsupported!");else{var c=this.video_.playbackRate,d=this.playRateController_.getRealRate();this.playRateController_.set(a);this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&(this.abrManager_.playbackRateChanged(a),this.useTrickPlayTrackIfAvailable(b&&a!=1));this.setupTrickPlayEventListeners_(a);if(c===0&&this.video_.playbackRate===
0&&a!=d)this.onRateChange_()}};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.getNextAddressJsc()==1)return e.yield(b.getBestImageStream_(a),2);c=e.getYieldResultJsc();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)/h,l=0;l<h;l++){var m=b.getThumbnailByReference_(f,c,f.startTime+l*
k,g);if(!m)break;d.push(m)}});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;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return h.yield(c.getBestImageStream_(a),2);d=h.getYieldResultJsc();if(!d)return h.return(null);e=d.segmentIndex.find(b);if(e==null)return h.return(null);f=d.segmentIndex.get(e);return(g=c.parseTilesLayout_(f.getTilesLayout()||d.tilesLayout))?h.return(c.getThumbnailByReference_(f,d,b,g)):h.return(null)})};
shaka.Player.prototype.getBestImageStream_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){if(b.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&b.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)return f.return(null);c=b.externalSrcEqualsThumbnailsStreams_;b.manifest_&&(c=b.manifest_.imageStreams);d=c[0];if(!d)return f.return(null);a!=null&&(d=c.find(function(g){return g.id==a}));return d?d.segmentIndex?f.jumpTo(2):f.yield(d.createSegmentIndex(),
2):f.return(null)}d.closeSegmentIndex&&(b.deferredCloseSegmentIndex_.has(d)||(e=new shaka.util.Timer(function(){d&&(d.closeSegmentIndex(),b.deferredCloseSegmentIndex_.delete(d))}),b.deferredCloseSegmentIndex_.set(d,e)),b.deferredCloseSegmentIndex_.get(d).tickAfter(5));return f.return(d)})};
shaka.Player.prototype.getThumbnailByReference_=function(a,b,c,d){var e=shaka.util.NumberUtils,f=b.width||0,g=b.height||0,h=f/d.columns,k=g/d.rows,l=d.columns*d.rows,m=a.trueEndTime-a.startTime;m=a.getTileDuration()||m/l;var n=a.startTime,p=0,q=0;l>1&&(q=Math.floor((c-a.startTime)/m+1E-4),n=a.startTime+q*m,p=q%d.columns*h,q=Math.floor(q/d.columns)*k);if(n>=a.endTime||e.isFloatEqual(n,a.endTime,1E-4))return null;d=!1;if(e=a.getThumbnailSprite())d=!0,k=e.height,p=e.positionX,q=e.positionY,h=e.width;
return{segment:a,imageHeight:g,imageWidth:f,height:k,positionX:p,positionY:q,startTime:n,duration:m,uris:a.getUris(),startByte:a.getStartByte(),endByte:a.getEndByte(),width:h,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;var f=c.streamingEngine_.getCurrentVariant();if(f=f&&f.audio)e.activeAudioCodec=f.codecs||"",e.activeAudioChannelCount=f.channelsCount||0;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()){var e=d.value;d=[e.language,e.originalLanguage,e.label||"",(e.audioRoles||[]).join(","),e.channelsCount,e.spatialAudio,e.audioCodec||"",e.accessibilityPurpose||""].join("_");e={active:e.active,language:e.language,label:e.label,mimeType:e.audioMimeType,codecs:e.audioCodec,primary:e.primary,roles:e.audioRoles||[],accessibilityPurpose:e.accessibilityPurpose,channelsCount:e.channelsCount,audioSamplingRate:e.audioSamplingRate,spatialAudio:e.spatialAudio,originalLanguage:e.originalLanguage};
a.has(d)?!a.get(d).active&&e.active&&a.set(d,e):a.set(d,e)}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=shaka.util.MimeUtils,f=this.getVariantTracks();if(f.length){var g=f.find(function(k){return k.active});if(g){f=f.filter(function(k){return(k.videoBandwidth||k.bandwidth)==a.bandwidth&&k.width==a.width&&k.height==a.height&&k.frameRate==a.frameRate&&k.pixelAspectRatio==a.pixelAspectRatio&&k.hdr==a.hdr&&k.colorGamut==a.colorGamut&&k.videoLayout==a.videoLayout&&k.videoMimeType==a.mimeType&&
k.videoCodec==a.codecs&&d.equal(k.videoRoles,a.roles)&&k.videoLabel==a.label});var h;(h=f.length==1?f[0]:f.find(function(k){return k.audioId===g.audioId}))||(h=f.find(function(k){return k.language==g.language&&k.label===g.label&&k.channelsCount===g.channelsCount&&k.spatialAudio===g.spatialAudio&&k.audioMimeType===g.audioMimeType&&e.getNormalizedCodec(k.audioCodec||"")===e.getNormalizedCodec(g.audioCodec||"")&&d.equal(k.audioRoles,g.audioRoles)}));h&&!h.active&&this.selectVariantTrack(h,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;this.isVideoOnly()||(c=a.filter(function(f){var g=shaka.util.ArrayUtils,h=shaka.util.MimeUtils;return f.videoCodec&&f.audioGroupId===b.audioGroupId&&f.originalAudioId===b.originalAudioId?f.audioId===b.audioId?!0:f.language===b.language&&f.label===b.label&&
f.channelsCount===b.channelsCount&&f.spatialAudio===b.spatialAudio&&f.audioMimeType===b.audioMimeType&&h.getNormalizedCodec(f.audioCodec||"")===h.getNormalizedCodec(b.audioCodec||"")&&g.equal(f.audioRoles,b.audioRoles):!1}));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.getNextAddressJsc()){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(),b instanceof Date&&!isNaN(b.getTime())?
new Date(b.getTime()+a*1E3):(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get playhead time as Date!"),null);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(),a instanceof Date&&!isNaN(a.getTime())?a:(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get presentation start time as Date!"),
null);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,u,w,v,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.getNextAddressJsc()){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){y.jumpTo(2);break}return y.yield(h.getTextMimetype_(a),3);case 3:d=y.getYieldResultJsc();case 2:k=[];h.adManager_&&(k=h.adManager_.getCuePoints());if(h.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS){y.jumpTo(4);break}l=shaka.device.DeviceFactory.getDevice();g&&l.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&
(c="forced");return y.yield(h.addSrcTrackElement_(a,b,c,d,f||"",k),5);case 5:m=y.getYieldResultJsc();if(m.track)return h.onTracksChanged_(),h.onTextChanged_(),y.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){y.jumpTo(6);break}return y.yield(h.getTextData_(a),7);case 7:r=y.getYieldResultJsc(),t=h.convertToWebVTT_(r,d,k),u=new Blob([t],{type:"text/vtt"}),a=shaka.media.MediaSourceEngine.createObjectURL(u),d="text/vtt";case 6:w={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};v=shaka.util.MimeUtils.getFullType(w.mimeType,w.codecs);x=shaka.text.TextEngine.isTypeSupported(v);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(w);h.onTracksChanged_();h.onTextChanged_();return y.return(shaka.util.StreamUtils.textStreamToTrack(w))}})};
shaka.Player.prototype.addThumbnailsTrack=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){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){A.jumpTo(2);break}return A.yield(c.getTextMimetype_(a),3);case 3:b=A.getYieldResultJsc();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);return A.yield(c.getTextData_(a),4);case 4:g=A.getYieldResultJsc();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$5:void 0,cue$jscomp$43:void 0},r=q.next())t.cue$jscomp$43=r.value,t.uris$jscomp$5=null,u=function(B){return function(){B.uris$jscomp$5==null&&(B.uris$jscomp$5=shaka.util.ManifestParserUtils.resolveUris([a],[B.cue$jscomp$43.payload]));return B.uris$jscomp$5||[]}}(t),w=new shaka.media.SegmentReference(t.cue$jscomp$43.startTime,t.cue$jscomp$43.endTime,u,0,null,null,0,0,Infinity),t.cue$jscomp$43.payload.includes("#xywh")&&(v=t.cue$jscomp$43.payload.split("#xywh=")[1].split(","),v.length===
4&&w.setThumbnailSprite({height:parseInt(v[3],10),positionX:parseInt(v[0],10),positionY:parseInt(v[1],10),width:parseInt(v[2],10)})),p.push(w);x=b;if(!p.length){A.jumpTo(5);break}return A.yield(c.getTextMimetype_(p[0].getUris()[0]),6);case 6:x=A.getYieldResultJsc();case 5:return y={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(y):
c.manifest_.imageStreams.push(y),c.onTracksChanged_(),A.return(shaka.util.StreamUtils.imageStreamToTrack(y))}})};
shaka.Player.prototype.addChaptersTrack=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){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.getYieldResultJsc();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);h=shaka.text.TextEngine.findParser(c);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,c);return x.yield(d.getTextData_(a),4);case 4:k=x.getYieldResultJsc();l=h();m={periodStart:0,segmentStart:0,segmentEnd:g,vttOffset:0};n=shaka.util.BufferUtils.toUint8(k);p=l.parseMedia(n,m,a,[]);q=[];r=(0,$jscomp.makeIterator)(p);t=r.next();for(u={};!t.done;u={cue$jscomp$44:void 0},t=r.next())u.cue$jscomp$44=t.value,w=new shaka.media.SegmentReference(u.cue$jscomp$44.startTime,u.cue$jscomp$44.endTime,function(y){return function(){return[y.cue$jscomp$44.payload]}}(u),
0,null,null,0,0,Infinity),q.push(w);v={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(v);d.onTracksChanged_();return x.return(shaka.util.StreamUtils.textStreamToTrack(v))}})};
shaka.Player.prototype.getTextMimetype_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){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.getYieldResultJsc();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.getNextAddressJsc()==1)return d!="text/vtt"||f.length?n.yield(g.getTextData_(a),3):n.jumpTo(2);n.getNextAddressJsc()!=2&&(h=n.getYieldResultJsc(),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){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return goog.asserts.assert(b.networkingEngine_,"Need networking engine."),c=shaka.net.NetworkingEngine.RequestType.SEGMENT,d=b.config_.streaming.retryParameters,e=shaka.net.NetworkingEngine.makeRequest([a],d),e.method="GET",b.cmcdManager_.applyTextData(e),g.yield(b.networkingEngine_.request(c,e).promise,2);f=g.getYieldResultJsc();return g.return(f.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.getNextAddressJsc()==1)return c=a.audio,d=a.video,e=function(k,l){var m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==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.getNextAddressJsc()!=3)return f=h.getYieldResultJsc(),h.yield(e(d,b),3);g=h.getYieldResultJsc();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?(a=this.getPlaybackRate(),a!==0&&a!==1&&(a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.RateChange),this.dispatchEvent(a))):(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.isQuartile_=function(a,b){return(shaka.util.NumberUtils.isFloatEqual(a,b,.01)||b>a)&&this.completionPercent_<a?(this.completionPercent_=a,!0):!1};shaka.Player.prototype.checkEnded_=function(){this.config_&&this.config_.playRangeEnd!=Infinity&&this.isEnded()&&this.video_.pause()};
shaka.Player.prototype.onVideoProgress_=function(){if(this.video_){var a=this.seekRange();a=a.end-a.start;a=a>0?this.video_.currentTime/a:0;if(!isNaN(a)){a*=100;if(this.isQuartile_(0,a))var b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Started);else if(this.isQuartile_(25,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.FirstQuartile);else if(this.isQuartile_(50,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Midpoint);else if(this.isQuartile_(75,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ThirdQuartile);
else{if(this.isQuartile_(100,a)||a>100)b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Complete);this.checkEnded_()}b&&this.dispatchEvent(b)}}};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,e){var f=shaka.util.NumberUtils;if(c!=shaka.util.ManifestParserUtils.ContentType.TEXT){if(this.playhead_){this.playhead_.notifyOfBufferingChange();var g=this.mediaSourceEngine_.bufferStart(c);!this.isLive()&&this.video_.paused&&!this.video_.seeking&&g!=null&&g>0&&this.playhead_.getTime()<g&&!f.isFloatEqual(this.playhead_.getTime(),g,.001)&&this.playhead_.setStartTime(g)}this.pollBufferState_()}a=(new Map).set("start",a).set("end",b).set("contentType",
c).set("isMuxed",d).set("isDependency",e);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.getNextAddressJsc()){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.getYieldResultJsc();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;if(this.streamingEngine_){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,u){t.allowedByKeySystem=!0;u=(0,$jscomp.makeIterator)(u);for(var w=
u.next();!w.done;w=u.next())if(w=w.value,(w=a[e?"00":w])||b.drmEngine_.hasManifestInitData())t.allowedByKeySystem=t.allowedByKeySystem&&!!w&&!f.includes(w)},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)}}}c&&(this.onTracksChanged_(),(c=this.streamingEngine_.getCurrentVariant())&&!c.allowedByKeySystem?(shaka.log.debug("Choosing new streams after key status changed"),this.chooseVariantAndSwitch_()):this.updateAbrManagerVariants_())}};
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.getNextAddressJsc()==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.37-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.ads={};shaka.ads.AdsStats=function(){this.loadTimes_=[];this.errors_=this.skipped_=this.playedCompletely_=this.overlayAds_=this.started_=0};shaka.ads.AdsStats.prototype.addLoadTime=function(a){this.loadTimes_.push(a)};shaka.ads.AdsStats.prototype.incrementStarted=function(){this.started_++};shaka.ads.AdsStats.prototype.incrementOverlayAds=function(){this.overlayAds_++};shaka.ads.AdsStats.prototype.incrementPlayedCompletely=function(){this.playedCompletely_++};
shaka.ads.AdsStats.prototype.incrementSkipped=function(){this.skipped_++};shaka.ads.AdsStats.prototype.incrementErrors=function(){this.errors_++};shaka.ads.AdsStats.prototype.getAverageLoadTime_=function(){return this.loadTimes_.length?this.loadTimes_.reduce(function(a,b){return a+b},0)/this.loadTimes_.length:0};
shaka.ads.AdsStats.prototype.getBlob=function(){return{loadTimes:this.loadTimes_,averageLoadTime:this.getAverageLoadTime_(),started:this.started_,overlayAds:this.overlayAds_,playedCompletely:this.playedCompletely_,skipped:this.skipped_,errors:this.errors_}};shaka.ads.ClientSideAd=function(a,b,c){var d=this;this.ad_=a;this.manager_=b;this.video_=c;this.isPaused_=!1;this.volume_=this.manager_.getVolume();this.eventManager_=new shaka.util.EventManager;this.eventManager_.listen(this.manager_,google.ima.AdEvent.Type.PAUSED,function(){d.isPaused_=!0});this.eventManager_.listen(this.manager_,google.ima.AdEvent.Type.RESUMED,function(){d.isPaused_=!1})};shaka.ads.ClientSideAd.prototype.needsSkipUI=function(){return!1};
shaka.ads.ClientSideAd.prototype.isClientRendering=function(){return!0};shaka.ads.ClientSideAd.prototype.hasCustomClick=function(){return!0};shaka.ads.ClientSideAd.prototype.isUsingAnotherMediaElement=function(){return!0};shaka.ads.ClientSideAd.prototype.getDuration=function(){return this.ad_.getDuration()};shaka.ads.ClientSideAd.prototype.getMinSuggestedDuration=function(){return this.ad_.getMinSuggestedDuration()};shaka.ads.ClientSideAd.prototype.getRemainingTime=function(){return this.manager_.getRemainingTime()};
shaka.ads.ClientSideAd.prototype.isPaused=function(){return this.isPaused_};shaka.ads.ClientSideAd.prototype.isSkippable=function(){return this.ad_.getSkipTimeOffset()>=0};shaka.ads.ClientSideAd.prototype.getTimeUntilSkippable=function(){var a=this.ad_.getSkipTimeOffset();a=this.getRemainingTime()-a;return Math.max(a,0)};shaka.ads.ClientSideAd.prototype.canSkipNow=function(){return this.manager_.getAdSkippableState()};shaka.ads.ClientSideAd.prototype.skip=function(){return this.manager_.skip()};
shaka.ads.ClientSideAd.prototype.setPaused=function(a){this.isPaused_=a};shaka.ads.ClientSideAd.prototype.pause=function(){return this.manager_.pause()};shaka.ads.ClientSideAd.prototype.play=function(){return this.manager_.resume()};shaka.ads.ClientSideAd.prototype.getVolume=function(){return this.manager_.getVolume()};shaka.ads.ClientSideAd.prototype.setVolume=function(a){this.video_.volume=a;return this.manager_.setVolume(a)};
shaka.ads.ClientSideAd.prototype.isMuted=function(){return this.manager_.getVolume()==0};shaka.ads.ClientSideAd.prototype.isLinear=function(){return this.ad_.isLinear()};shaka.ads.ClientSideAd.prototype.resize=function(a,b){this.manager_.resize(a,b)};shaka.ads.ClientSideAd.prototype.setMuted=function(a){(this.video_.muted=a)?(this.volume_=this.getVolume(),this.manager_.setVolume(0)):this.manager_.setVolume(this.volume_)};
shaka.ads.ClientSideAd.prototype.setInitialMuted=function(a){this.volume_=a;this.manager_.setVolume(0)};shaka.ads.ClientSideAd.prototype.getSequenceLength=function(){var a=this.ad_.getAdPodInfo();return a==null?1:a.getTotalAds()};shaka.ads.ClientSideAd.prototype.getPositionInSequence=function(){var a=this.ad_.getAdPodInfo();return a==null?1:a.getAdPosition()};shaka.ads.ClientSideAd.prototype.getTitle=function(){return this.ad_.getTitle()};shaka.ads.ClientSideAd.prototype.getDescription=function(){return this.ad_.getDescription()};
shaka.ads.ClientSideAd.prototype.getVastMediaBitrate=function(){return this.ad_.getVastMediaBitrate()};shaka.ads.ClientSideAd.prototype.getVastMediaHeight=function(){return this.ad_.getVastMediaHeight()};shaka.ads.ClientSideAd.prototype.getVastMediaWidth=function(){return this.ad_.getVastMediaWidth()};shaka.ads.ClientSideAd.prototype.getVastAdId=function(){return""};shaka.ads.ClientSideAd.prototype.getAdId=function(){return this.ad_.getAdId()};shaka.ads.ClientSideAd.prototype.getCreativeAdId=function(){return this.ad_.getCreativeAdId()};
shaka.ads.ClientSideAd.prototype.getAdvertiserName=function(){return this.ad_.getAdvertiserName()};shaka.ads.ClientSideAd.prototype.getMediaUrl=function(){return this.ad_.getMediaUrl()};shaka.ads.ClientSideAd.prototype.getTimeOffset=function(){var a=this.ad_.getAdPodInfo();return a==null?0:a.getTimeOffset()};shaka.ads.ClientSideAd.prototype.getPodIndex=function(){var a=this.ad_.getAdPodInfo();return a==null?0:a.getPodIndex()};
shaka.ads.ClientSideAd.prototype.release=function(){this.manager_=this.ad_=null};goog.exportSymbol("shaka.ads.ClientSideAd",shaka.ads.ClientSideAd);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"release",shaka.ads.ClientSideAd.prototype.release);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getPodIndex",shaka.ads.ClientSideAd.prototype.getPodIndex);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getTimeOffset",shaka.ads.ClientSideAd.prototype.getTimeOffset);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getMediaUrl",shaka.ads.ClientSideAd.prototype.getMediaUrl);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getAdvertiserName",shaka.ads.ClientSideAd.prototype.getAdvertiserName);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getCreativeAdId",shaka.ads.ClientSideAd.prototype.getCreativeAdId);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getAdId",shaka.ads.ClientSideAd.prototype.getAdId);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getVastAdId",shaka.ads.ClientSideAd.prototype.getVastAdId);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getVastMediaWidth",shaka.ads.ClientSideAd.prototype.getVastMediaWidth);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getVastMediaHeight",shaka.ads.ClientSideAd.prototype.getVastMediaHeight);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getVastMediaBitrate",shaka.ads.ClientSideAd.prototype.getVastMediaBitrate);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getDescription",shaka.ads.ClientSideAd.prototype.getDescription);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getTitle",shaka.ads.ClientSideAd.prototype.getTitle);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getPositionInSequence",shaka.ads.ClientSideAd.prototype.getPositionInSequence);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getSequenceLength",shaka.ads.ClientSideAd.prototype.getSequenceLength);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"setMuted",shaka.ads.ClientSideAd.prototype.setMuted);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"resize",shaka.ads.ClientSideAd.prototype.resize);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isLinear",shaka.ads.ClientSideAd.prototype.isLinear);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isMuted",shaka.ads.ClientSideAd.prototype.isMuted);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"setVolume",shaka.ads.ClientSideAd.prototype.setVolume);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getVolume",shaka.ads.ClientSideAd.prototype.getVolume);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"play",shaka.ads.ClientSideAd.prototype.play);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"pause",shaka.ads.ClientSideAd.prototype.pause);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"skip",shaka.ads.ClientSideAd.prototype.skip);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"canSkipNow",shaka.ads.ClientSideAd.prototype.canSkipNow);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getTimeUntilSkippable",shaka.ads.ClientSideAd.prototype.getTimeUntilSkippable);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isSkippable",shaka.ads.ClientSideAd.prototype.isSkippable);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isPaused",shaka.ads.ClientSideAd.prototype.isPaused);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getRemainingTime",shaka.ads.ClientSideAd.prototype.getRemainingTime);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getMinSuggestedDuration",shaka.ads.ClientSideAd.prototype.getMinSuggestedDuration);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"getDuration",shaka.ads.ClientSideAd.prototype.getDuration);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isUsingAnotherMediaElement",shaka.ads.ClientSideAd.prototype.isUsingAnotherMediaElement);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"hasCustomClick",shaka.ads.ClientSideAd.prototype.hasCustomClick);
goog.exportProperty(shaka.ads.ClientSideAd.prototype,"isClientRendering",shaka.ads.ClientSideAd.prototype.isClientRendering);goog.exportProperty(shaka.ads.ClientSideAd.prototype,"needsSkipUI",shaka.ads.ClientSideAd.prototype.needsSkipUI);shaka.ads.Utils=function(){};
shaka.ads.Utils.parseVastToInterstitials=function(a,b){var c=shaka.util.TXml,d=[];a=(0,$jscomp.makeIterator)(c.findChildren(a,"Ad"));for(var e=a.next();!e.done;e=a.next())if(e=c.findChild(e.value,"InLine"))if(e=c.findChild(e,"Creatives")){e=(0,$jscomp.makeIterator)(c.findChildren(e,"Creative"));for(var f=e.next();!f.done;f=e.next()){f=f.value;var g=c.findChild(f,"Linear");g&&shaka.ads.Utils.processLinearAd_(d,b,g);if(f=c.findChild(f,"NonLinearAds"))for(f=c.findChildren(f,"NonLinear"),f=(0,$jscomp.makeIterator)(f),
g=f.next();!g.done;g=f.next())shaka.ads.Utils.processNonLinearAd_(d,b,g.value)}}return d};
shaka.ads.Utils.processLinearAd_=function(a,b,c){var d=shaka.util.TXml,e=0;b!=null&&(e=b);var f=null;c.attributes.skipoffset&&(f=shaka.util.TextParser.parseTime(c.attributes.skipoffset),isNaN(f)&&(f=null));var g=d.findChild(c,"MediaFiles");if(g){var h=null;(c=d.findChild(c,"VideoClicks"))&&(c=d.findChild(c,"ClickThrough"))&&(c=d.getContents(c))&&(h=c);g=c=d.findChildren(g,"MediaFile");c=c.filter(function(l){return l.attributes.delivery=="streaming"});c.length&&(g=c);g=g.sort(function(l,m){l=parseInt(l.attributes.height,
10)||0;return(parseInt(m.attributes.height,10)||0)-l});g=(0,$jscomp.makeIterator)(g);for(c=g.next();!c.done;c=g.next())if(c=c.value,!c.attributes.apiFramework){var k=d.getContents(c);if(k){a.push({id:null,groupId:null,startTime:e,endTime:null,uri:k,mimeType:c.attributes.type||null,isSkippable:f!=null,skipOffset:f,skipFor:null,canJump:!1,resumeOffset:0,playoutLimit:null,once:!0,pre:b==null,post:b==Infinity,timelineRange:!1,loop:!1,overlay:null,displayOnBackground:!1,currentVideo:null,background:null,
clickThroughUrl:h});break}}}};
shaka.ads.Utils.processNonLinearAd_=function(a,b,c){var d=shaka.util.TXml,e=d.findChild(c,"StaticResource");if(e)var f=e.attributes.creativeType;else{e=d.findChild(c,"HTMLResource");if(!e)return;f="text/html"}if(e=d.getContents(e)){f==="text/html"&&(e="data:text/html;charset=UTF-8,"+encodeURIComponent(e));var g=d.parseAttr(c,"width",d.parseInt)||d.parseAttr(c,"expandedWidth",d.parseInt),h=d.parseAttr(c,"height",d.parseInt)||d.parseAttr(c,"expandedHeight",d.parseInt);if(g||h){var k=null,l=d.findChild(c,
"NonLinearClickThrough");l&&(d=d.getContents(l))&&(k=d);d=null;(c=c.attributes.minSuggestedDuration)&&(d=shaka.util.TextParser.parseTime(c));c=0;b!=null&&(c=b);a.push({id:null,groupId:null,startTime:c,endTime:null,uri:e,mimeType:f,isSkippable:!1,skipOffset:null,skipFor:null,canJump:!1,resumeOffset:0,playoutLimit:d,once:!0,pre:b==null,post:b==Infinity,timelineRange:!1,loop:!1,overlay:{viewport:{x:0,y:0},topLeft:{x:0,y:0},size:{x:g||0,y:h||0}},displayOnBackground:!1,currentVideo:null,background:null,
clickThroughUrl:k})}}};shaka.ads.Utils.parseVMAP=function(a){var b=shaka.util.TXml,c=[];a=(0,$jscomp.makeIterator)(b.findChildren(a,"vmap:AdBreak"));for(var d=a.next();!d.done;d=a.next()){var e=d.value;if(d=e.attributes.timeOffset)d=d=="start"?null:d=="end"?Infinity:shaka.util.TextParser.parseTime(d),(e=b.findChild(e,"vmap:AdSource"))&&(e=b.findChild(e,"vmap:AdTagURI"))&&(e=b.getTextContents(e))&&c.push({time:d,uri:e})}return c};goog.exportSymbol("shaka.ads.Utils",shaka.ads.Utils);
shaka.ads.Utils.ADS_LOADED="ads-loaded";goog.exportProperty(shaka.ads.Utils,"ADS_LOADED",shaka.ads.Utils.ADS_LOADED);shaka.ads.Utils.AD_STARTED="ad-started";goog.exportProperty(shaka.ads.Utils,"AD_STARTED",shaka.ads.Utils.AD_STARTED);shaka.ads.Utils.AD_FIRST_QUARTILE="ad-first-quartile";goog.exportProperty(shaka.ads.Utils,"AD_FIRST_QUARTILE",shaka.ads.Utils.AD_FIRST_QUARTILE);shaka.ads.Utils.AD_MIDPOINT="ad-midpoint";goog.exportProperty(shaka.ads.Utils,"AD_MIDPOINT",shaka.ads.Utils.AD_MIDPOINT);
shaka.ads.Utils.AD_THIRD_QUARTILE="ad-third-quartile";goog.exportProperty(shaka.ads.Utils,"AD_THIRD_QUARTILE",shaka.ads.Utils.AD_THIRD_QUARTILE);shaka.ads.Utils.AD_COMPLETE="ad-complete";goog.exportProperty(shaka.ads.Utils,"AD_COMPLETE",shaka.ads.Utils.AD_COMPLETE);shaka.ads.Utils.AD_STOPPED="ad-stopped";goog.exportProperty(shaka.ads.Utils,"AD_STOPPED",shaka.ads.Utils.AD_STOPPED);shaka.ads.Utils.AD_SKIPPED="ad-skipped";goog.exportProperty(shaka.ads.Utils,"AD_SKIPPED",shaka.ads.Utils.AD_SKIPPED);
shaka.ads.Utils.AD_VOLUME_CHANGED="ad-volume-changed";goog.exportProperty(shaka.ads.Utils,"AD_VOLUME_CHANGED",shaka.ads.Utils.AD_VOLUME_CHANGED);shaka.ads.Utils.AD_MUTED="ad-muted";goog.exportProperty(shaka.ads.Utils,"AD_MUTED",shaka.ads.Utils.AD_MUTED);shaka.ads.Utils.AD_PAUSED="ad-paused";goog.exportProperty(shaka.ads.Utils,"AD_PAUSED",shaka.ads.Utils.AD_PAUSED);shaka.ads.Utils.AD_RESUMED="ad-resumed";goog.exportProperty(shaka.ads.Utils,"AD_RESUMED",shaka.ads.Utils.AD_RESUMED);
shaka.ads.Utils.AD_SKIP_STATE_CHANGED="ad-skip-state-changed";goog.exportProperty(shaka.ads.Utils,"AD_SKIP_STATE_CHANGED",shaka.ads.Utils.AD_SKIP_STATE_CHANGED);shaka.ads.Utils.CUEPOINTS_CHANGED="ad-cue-points-changed";goog.exportProperty(shaka.ads.Utils,"CUEPOINTS_CHANGED",shaka.ads.Utils.CUEPOINTS_CHANGED);shaka.ads.Utils.IMA_AD_MANAGER_LOADED="ima-ad-manager-loaded";goog.exportProperty(shaka.ads.Utils,"IMA_AD_MANAGER_LOADED",shaka.ads.Utils.IMA_AD_MANAGER_LOADED);
shaka.ads.Utils.IMA_STREAM_MANAGER_LOADED="ima-stream-manager-loaded";goog.exportProperty(shaka.ads.Utils,"IMA_STREAM_MANAGER_LOADED",shaka.ads.Utils.IMA_STREAM_MANAGER_LOADED);shaka.ads.Utils.AD_CLICKED="ad-clicked";goog.exportProperty(shaka.ads.Utils,"AD_CLICKED",shaka.ads.Utils.AD_CLICKED);shaka.ads.Utils.AD_PROGRESS="ad-progress";goog.exportProperty(shaka.ads.Utils,"AD_PROGRESS",shaka.ads.Utils.AD_PROGRESS);shaka.ads.Utils.AD_BUFFERING="ad-buffering";
goog.exportProperty(shaka.ads.Utils,"AD_BUFFERING",shaka.ads.Utils.AD_BUFFERING);shaka.ads.Utils.AD_IMPRESSION="ad-impression";goog.exportProperty(shaka.ads.Utils,"AD_IMPRESSION",shaka.ads.Utils.AD_IMPRESSION);shaka.ads.Utils.AD_DURATION_CHANGED="ad-duration-changed";goog.exportProperty(shaka.ads.Utils,"AD_DURATION_CHANGED",shaka.ads.Utils.AD_DURATION_CHANGED);shaka.ads.Utils.AD_CLOSED="ad-closed";goog.exportProperty(shaka.ads.Utils,"AD_CLOSED",shaka.ads.Utils.AD_CLOSED);
shaka.ads.Utils.AD_LOADED="ad-loaded";goog.exportProperty(shaka.ads.Utils,"AD_LOADED",shaka.ads.Utils.AD_LOADED);shaka.ads.Utils.ALL_ADS_COMPLETED="all-ads-completed";goog.exportProperty(shaka.ads.Utils,"ALL_ADS_COMPLETED",shaka.ads.Utils.ALL_ADS_COMPLETED);shaka.ads.Utils.AD_LINEAR_CHANGED="ad-linear-changed";goog.exportProperty(shaka.ads.Utils,"AD_LINEAR_CHANGED",shaka.ads.Utils.AD_LINEAR_CHANGED);shaka.ads.Utils.AD_METADATA="ad-metadata";goog.exportProperty(shaka.ads.Utils,"AD_METADATA",shaka.ads.Utils.AD_METADATA);
shaka.ads.Utils.AD_RECOVERABLE_ERROR="ad-recoverable-error";goog.exportProperty(shaka.ads.Utils,"AD_RECOVERABLE_ERROR",shaka.ads.Utils.AD_RECOVERABLE_ERROR);shaka.ads.Utils.AD_ERROR="ad-error";goog.exportProperty(shaka.ads.Utils,"AD_ERROR",shaka.ads.Utils.AD_ERROR);shaka.ads.Utils.AD_BREAK_READY="ad-break-ready";goog.exportProperty(shaka.ads.Utils,"AD_BREAK_READY",shaka.ads.Utils.AD_BREAK_READY);shaka.ads.Utils.AD_INTERACTION="ad-interaction";goog.exportProperty(shaka.ads.Utils,"AD_INTERACTION",shaka.ads.Utils.AD_INTERACTION);
shaka.ads.Utils.AD_CONTENT_PAUSE_REQUESTED="ad-content-pause-requested";goog.exportProperty(shaka.ads.Utils,"AD_CONTENT_PAUSE_REQUESTED",shaka.ads.Utils.AD_CONTENT_PAUSE_REQUESTED);shaka.ads.Utils.AD_CONTENT_RESUME_REQUESTED="ad-content-resume-requested";goog.exportProperty(shaka.ads.Utils,"AD_CONTENT_RESUME_REQUESTED",shaka.ads.Utils.AD_CONTENT_RESUME_REQUESTED);shaka.ads.Utils.AD_CONTENT_ATTACH_REQUESTED="ad-content-attach-requested";
goog.exportProperty(shaka.ads.Utils,"AD_CONTENT_ATTACH_REQUESTED",shaka.ads.Utils.AD_CONTENT_ATTACH_REQUESTED);shaka.ads.ClientSideAdManager=function(a,b,c,d,e){var f=this;this.adContainer_=a;this.video_=b;this.videoPlayed_=!1;this.resizeObserver_=this.config_=null;this.requestAdsStartTime_=NaN;this.onEvent_=e;this.ad_=null;this.eventManager_=new shaka.util.EventManager;google.ima.settings.setLocale(c);google.ima.settings.setDisableCustomPlaybackForIOS10Plus(!0);this.adDisplayContainer_=new google.ima.AdDisplayContainer(this.adContainer_,this.video_);this.adDisplayContainer_.initialize();this.adsLoader_=new google.ima.AdsLoader(this.adDisplayContainer_);
this.adsLoader_.getSettings().setPlayerType("shaka-player");this.adsLoader_.getSettings().setPlayerVersion(shaka.Player.version);this.imaAdsManager_=null;this.adsRenderingSettings_=d||new google.ima.AdsRenderingSettings;this.eventManager_.listen(this.adsLoader_,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,function(g){f.onAdsManagerLoaded_(g)});this.eventManager_.listen(this.adsLoader_,google.ima.AdErrorEvent.Type.AD_ERROR,function(g){f.onAdError_(g)});this.eventManager_.listen(this.video_,
"ended",function(){f.adsLoader_.contentComplete()});this.eventManager_.listenOnce(this.video_,"play",function(){f.videoPlayed_=!0})};shaka.ads.ClientSideAdManager.prototype.configure=function(a){this.config_=a};
shaka.ads.ClientSideAdManager.prototype.requestAds=function(a){goog.asserts.assert(a.adTagUrl||a.adsResponse,"The ad tag needs to be set up before requesting ads, or adsResponse must be filled.");this.imaAdsManager_&&this.imaAdsManager_.destroy();this.adsLoader_&&this.adsLoader_.contentComplete();this.requestAdsStartTime_=Date.now()/1E3;this.adsLoader_.requestAds(a)};shaka.ads.ClientSideAdManager.prototype.updateAdsRenderingSettings=function(a){this.adsRenderingSettings_=a;this.imaAdsManager_&&this.imaAdsManager_.updateAdsRenderingSettings(this.adsRenderingSettings_)};
shaka.ads.ClientSideAdManager.prototype.stop=function(){this.imaAdsManager_&&this.imaAdsManager_.stop();this.adContainer_&&shaka.util.Dom.removeAllChildren(this.adContainer_)};shaka.ads.ClientSideAdManager.prototype.release=function(){this.stop();this.resizeObserver_&&this.resizeObserver_.disconnect();this.eventManager_&&this.eventManager_.release();this.imaAdsManager_&&this.imaAdsManager_.destroy();this.adsLoader_.destroy();this.adDisplayContainer_.destroy()};
shaka.ads.ClientSideAdManager.prototype.onAdError_=function(a){shaka.log.warning("There was an ad error from the IMA SDK: "+a.getError());shaka.log.warning("Resuming playback.");a=(new Map).set("originalEvent",a);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_ERROR,a));this.onAdComplete_(null);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.CUEPOINTS_CHANGED,(new Map).set("cuepoints",[])))};
shaka.ads.ClientSideAdManager.prototype.onAdsManagerLoaded_=function(a){var b=this;goog.asserts.assert(this.video_!=null,"Video should not be null!");var c=Date.now()/1E3-this.requestAdsStartTime_;this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.ADS_LOADED,(new Map).set("loadTime",c)));if(this.config_.customPlayheadTracker){var d={currentTime:this.video_.currentTime};this.imaAdsManager_=a.getAdsManager(d,this.adsRenderingSettings_);this.video_.muted?this.imaAdsManager_.setVolume(0):this.imaAdsManager_.setVolume(this.video_.volume);
this.eventManager_.listen(this.video_,"timeupdate",function(){b.video_.duration&&(d.currentTime=b.video_.currentTime)});this.eventManager_.listen(this.video_,"volumechange",function(){b.ad_&&(b.ad_.setVolume(b.video_.volume),b.video_.muted&&b.ad_.setMuted(!0))})}else this.imaAdsManager_=a.getAdsManager(this.video_,this.adsRenderingSettings_);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.IMA_AD_MANAGER_LOADED,(new Map).set("imaAdManager",this.imaAdsManager_)));c=this.imaAdsManager_.getCuePoints();
if(c.length){a=[];c=(0,$jscomp.makeIterator)(c);for(var e=c.next();!e.done;e=c.next())a.push({start:e.value,end:null});this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.CUEPOINTS_CHANGED,(new Map).set("cuepoints",a)))}this.addImaEventListeners_();try{this.imaAdsManager_.init(this.video_.offsetWidth,this.video_.offsetHeight),this.eventManager_.listen(this.video_,"loadeddata",function(){b.imaAdsManager_.resize(b.video_.offsetWidth,b.video_.offsetHeight)}),"ResizeObserver"in window?(this.resizeObserver_=
new ResizeObserver(function(){b.imaAdsManager_.resize(b.video_.offsetWidth,b.video_.offsetHeight)}),this.resizeObserver_.observe(this.video_)):this.eventManager_.listen(document,"fullscreenchange",function(){b.imaAdsManager_.resize(b.video_.offsetWidth,b.video_.offsetHeight)}),this.videoPlayed_||this.config_.skipPlayDetection?this.imaAdsManager_.start():this.eventManager_.listenOnce(this.video_,"play",function(){b.videoPlayed_=!0;b.imaAdsManager_.start()})}catch(f){this.onAdComplete_(null)}};
shaka.ads.ClientSideAdManager.prototype.addImaEventListeners_=function(){var a=this,b=function(c,d){c=(new Map).set("originalEvent",c);a.onEvent_(new shaka.util.FakeEvent(d,c))};this.eventManager_.listen(this.imaAdsManager_,google.ima.AdErrorEvent.Type.AD_ERROR,function(c){a.onAdError_(c)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,function(c){a.onAdStart_(c)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.STARTED,function(c){a.onAdStart_(c)});
this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.FIRST_QUARTILE,function(c){b(c,shaka.ads.Utils.AD_FIRST_QUARTILE)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.MIDPOINT,function(c){b(c,shaka.ads.Utils.AD_MIDPOINT)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.THIRD_QUARTILE,function(c){b(c,shaka.ads.Utils.AD_THIRD_QUARTILE)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.COMPLETE,function(c){b(c,shaka.ads.Utils.AD_COMPLETE)});
this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,function(c){a.onAdComplete_(c)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,function(c){b(c,shaka.ads.Utils.ALL_ADS_COMPLETED);a.onAdComplete_(c)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.SKIPPED,function(c){b(c,shaka.ads.Utils.AD_SKIPPED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.VOLUME_CHANGED,function(c){b(c,
shaka.ads.Utils.AD_VOLUME_CHANGED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.VOLUME_MUTED,function(c){b(c,shaka.ads.Utils.AD_MUTED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.PAUSED,function(c){a.ad_&&(a.ad_.setPaused(!0),b(c,shaka.ads.Utils.AD_PAUSED))});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.RESUMED,function(c){a.ad_&&(a.ad_.setPaused(!1),b(c,shaka.ads.Utils.AD_RESUMED))});this.eventManager_.listen(this.imaAdsManager_,
google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED,function(c){a.ad_&&b(c,shaka.ads.Utils.AD_SKIP_STATE_CHANGED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.CLICK,function(c){b(c,shaka.ads.Utils.AD_CLICKED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.AD_PROGRESS,function(c){b(c,shaka.ads.Utils.AD_PROGRESS)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.AD_BUFFERING,function(c){b(c,shaka.ads.Utils.AD_BUFFERING)});this.eventManager_.listen(this.imaAdsManager_,
google.ima.AdEvent.Type.IMPRESSION,function(c){b(c,shaka.ads.Utils.AD_IMPRESSION)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.DURATION_CHANGE,function(c){b(c,shaka.ads.Utils.AD_DURATION_CHANGED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.USER_CLOSE,function(c){b(c,shaka.ads.Utils.AD_CLOSED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.LOADED,function(c){b(c,shaka.ads.Utils.AD_LOADED)});this.eventManager_.listen(this.imaAdsManager_,
google.ima.AdEvent.Type.LINEAR_CHANGED,function(c){b(c,shaka.ads.Utils.AD_LINEAR_CHANGED)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.AD_METADATA,function(c){b(c,shaka.ads.Utils.AD_METADATA)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.LOG,function(c){b(c,shaka.ads.Utils.AD_RECOVERABLE_ERROR)});this.eventManager_.listen(this.imaAdsManager_,google.ima.AdEvent.Type.AD_BREAK_READY,function(c){b(c,shaka.ads.Utils.AD_BREAK_READY)});this.eventManager_.listen(this.imaAdsManager_,
google.ima.AdEvent.Type.INTERACTION,function(c){b(c,shaka.ads.Utils.AD_INTERACTION)})};
shaka.ads.ClientSideAdManager.prototype.onAdStart_=function(a){goog.asserts.assert(this.imaAdsManager_,"Should have an ads manager at this point!");var b=a.getAd();if(b){this.ad_=new shaka.ads.ClientSideAd(b,this.imaAdsManager_,this.video_);if(a.type==google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED&&!this.config_.supportsMultipleMediaElements)this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_CONTENT_PAUSE_REQUESTED));a=(new Map).set("ad",this.ad_).set("sdkAdObject",b).set("originalEvent",
a);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STARTED,a));this.ad_.isLinear()&&(this.adContainer_.setAttribute("ad-active","true"),this.config_.customPlayheadTracker||this.video_.pause(),this.video_.muted?this.ad_.setInitialMuted(this.video_.volume):this.ad_.setVolume(this.video_.volume))}else shaka.log.alwaysWarn("The IMA SDK fired a "+a.type+" event with no associated ad. Unable to play ad!")};
shaka.ads.ClientSideAdManager.prototype.onAdComplete_=function(a){if(a&&a.type==google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED&&!this.config_.supportsMultipleMediaElements)this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_CONTENT_RESUME_REQUESTED));this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED,(new Map).set("originalEvent",a)));this.ad_&&this.ad_.isLinear()&&(this.adContainer_.removeAttribute("ad-active"),this.config_.customPlayheadTracker||this.video_.ended||this.video_.play())};shaka.ads.InterstitialAd=function(a,b,c,d,e,f){this.video_=a;this.interstitial_=b;this.skipOffset_=(this.isSkippable_=b.isSkippable)?b.skipOffset||0:b.skipOffset;this.skipFor_=b.skipFor;this.onSkip_=c;this.sequenceLength_=d;this.adPosition_=e;this.isUsingAnotherMediaElement_=f;this.overlay_=b.overlay};shaka.ads.InterstitialAd.prototype.needsSkipUI=function(){return!0};shaka.ads.InterstitialAd.prototype.isClientRendering=function(){return!0};
shaka.ads.InterstitialAd.prototype.hasCustomClick=function(){return this.interstitial_.clickThroughUrl!=null};shaka.ads.InterstitialAd.prototype.isUsingAnotherMediaElement=function(){return this.isUsingAnotherMediaElement_};shaka.ads.InterstitialAd.prototype.getDuration=function(){var a=this.video_.duration;return isNaN(a)?-1:a};shaka.ads.InterstitialAd.prototype.getMinSuggestedDuration=function(){return this.getDuration()};
shaka.ads.InterstitialAd.prototype.getRemainingTime=function(){var a=this.video_.duration;return isNaN(a)?-1:a-this.video_.currentTime};shaka.ads.InterstitialAd.prototype.isPaused=function(){return this.video_.paused};shaka.ads.InterstitialAd.prototype.isSkippable=function(){return this.isSkippable_&&this.skipFor_!=null?this.getDuration()-this.getRemainingTime()<this.skipOffset_+this.skipFor_:this.isSkippable_};
shaka.ads.InterstitialAd.prototype.getTimeUntilSkippable=function(){if(this.isSkippable()){var a=this.getRemainingTime()+this.skipOffset_-this.getDuration();return Math.max(a,0)}return Math.max(this.getRemainingTime(),0)};shaka.ads.InterstitialAd.prototype.canSkipNow=function(){return this.isSkippable_&&this.getTimeUntilSkippable()==0};shaka.ads.InterstitialAd.prototype.skip=function(){if(this.canSkipNow())this.onSkip_()};shaka.ads.InterstitialAd.prototype.pause=function(){return this.video_.pause()};
shaka.ads.InterstitialAd.prototype.play=function(){return this.video_.play()};shaka.ads.InterstitialAd.prototype.getVolume=function(){return this.video_.volume};shaka.ads.InterstitialAd.prototype.setVolume=function(a){this.video_.volume=a};shaka.ads.InterstitialAd.prototype.isMuted=function(){return this.video_.muted};shaka.ads.InterstitialAd.prototype.isLinear=function(){return this.overlay_==null};shaka.ads.InterstitialAd.prototype.resize=function(a,b){};
shaka.ads.InterstitialAd.prototype.setMuted=function(a){this.video_.muted=a};shaka.ads.InterstitialAd.prototype.getSequenceLength=function(){return this.sequenceLength_};shaka.ads.InterstitialAd.prototype.getPositionInSequence=function(){return this.adPosition_};shaka.ads.InterstitialAd.prototype.getTitle=function(){return""};shaka.ads.InterstitialAd.prototype.getDescription=function(){return""};shaka.ads.InterstitialAd.prototype.getVastMediaBitrate=function(){return 0};
shaka.ads.InterstitialAd.prototype.getVastMediaHeight=function(){return 0};shaka.ads.InterstitialAd.prototype.getVastMediaWidth=function(){return 0};shaka.ads.InterstitialAd.prototype.getVastAdId=function(){return""};shaka.ads.InterstitialAd.prototype.getAdId=function(){return this.interstitial_.id||""};shaka.ads.InterstitialAd.prototype.getCreativeAdId=function(){return""};shaka.ads.InterstitialAd.prototype.getAdvertiserName=function(){return""};shaka.ads.InterstitialAd.prototype.getMediaUrl=function(){return this.interstitial_.uri};
shaka.ads.InterstitialAd.prototype.getTimeOffset=function(){return this.interstitial_.pre?0:this.interstitial_.post?-1:this.interstitial_.startTime};shaka.ads.InterstitialAd.prototype.getPodIndex=function(){return 0};shaka.ads.InterstitialAd.prototype.release=function(){this.video_=null};goog.exportSymbol("shaka.ads.InterstitialAd",shaka.ads.InterstitialAd);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"release",shaka.ads.InterstitialAd.prototype.release);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getPodIndex",shaka.ads.InterstitialAd.prototype.getPodIndex);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getTimeOffset",shaka.ads.InterstitialAd.prototype.getTimeOffset);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getMediaUrl",shaka.ads.InterstitialAd.prototype.getMediaUrl);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getAdvertiserName",shaka.ads.InterstitialAd.prototype.getAdvertiserName);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getCreativeAdId",shaka.ads.InterstitialAd.prototype.getCreativeAdId);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getAdId",shaka.ads.InterstitialAd.prototype.getAdId);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getVastAdId",shaka.ads.InterstitialAd.prototype.getVastAdId);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getVastMediaWidth",shaka.ads.InterstitialAd.prototype.getVastMediaWidth);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getVastMediaHeight",shaka.ads.InterstitialAd.prototype.getVastMediaHeight);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getVastMediaBitrate",shaka.ads.InterstitialAd.prototype.getVastMediaBitrate);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getDescription",shaka.ads.InterstitialAd.prototype.getDescription);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getTitle",shaka.ads.InterstitialAd.prototype.getTitle);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getPositionInSequence",shaka.ads.InterstitialAd.prototype.getPositionInSequence);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getSequenceLength",shaka.ads.InterstitialAd.prototype.getSequenceLength);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"setMuted",shaka.ads.InterstitialAd.prototype.setMuted);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"resize",shaka.ads.InterstitialAd.prototype.resize);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isLinear",shaka.ads.InterstitialAd.prototype.isLinear);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isMuted",shaka.ads.InterstitialAd.prototype.isMuted);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"setVolume",shaka.ads.InterstitialAd.prototype.setVolume);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getVolume",shaka.ads.InterstitialAd.prototype.getVolume);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"play",shaka.ads.InterstitialAd.prototype.play);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"pause",shaka.ads.InterstitialAd.prototype.pause);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"skip",shaka.ads.InterstitialAd.prototype.skip);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"canSkipNow",shaka.ads.InterstitialAd.prototype.canSkipNow);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getTimeUntilSkippable",shaka.ads.InterstitialAd.prototype.getTimeUntilSkippable);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isSkippable",shaka.ads.InterstitialAd.prototype.isSkippable);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isPaused",shaka.ads.InterstitialAd.prototype.isPaused);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getRemainingTime",shaka.ads.InterstitialAd.prototype.getRemainingTime);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getMinSuggestedDuration",shaka.ads.InterstitialAd.prototype.getMinSuggestedDuration);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"getDuration",shaka.ads.InterstitialAd.prototype.getDuration);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isUsingAnotherMediaElement",shaka.ads.InterstitialAd.prototype.isUsingAnotherMediaElement);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"hasCustomClick",shaka.ads.InterstitialAd.prototype.hasCustomClick);
goog.exportProperty(shaka.ads.InterstitialAd.prototype,"isClientRendering",shaka.ads.InterstitialAd.prototype.isClientRendering);goog.exportProperty(shaka.ads.InterstitialAd.prototype,"needsSkipUI",shaka.ads.InterstitialAd.prototype.needsSkipUI);shaka.ads.InterstitialStaticAd=function(a,b,c){this.interstitial_=a;this.sequenceLength_=b;this.adPosition_=c;this.isLinear_=a.overlay==null};shaka.ads.InterstitialStaticAd.prototype.needsSkipUI=function(){return!0};shaka.ads.InterstitialStaticAd.prototype.isClientRendering=function(){return!0};shaka.ads.InterstitialStaticAd.prototype.hasCustomClick=function(){return this.interstitial_.clickThroughUrl!=null};shaka.ads.InterstitialStaticAd.prototype.isUsingAnotherMediaElement=function(){return!1};
shaka.ads.InterstitialStaticAd.prototype.getDuration=function(){return-1};shaka.ads.InterstitialStaticAd.prototype.getMinSuggestedDuration=function(){return this.getDuration()};shaka.ads.InterstitialStaticAd.prototype.getRemainingTime=function(){return-1};shaka.ads.InterstitialStaticAd.prototype.isPaused=function(){return!1};shaka.ads.InterstitialStaticAd.prototype.isSkippable=function(){return!1};shaka.ads.InterstitialStaticAd.prototype.getTimeUntilSkippable=function(){return 0};
shaka.ads.InterstitialStaticAd.prototype.canSkipNow=function(){return!1};shaka.ads.InterstitialStaticAd.prototype.skip=function(){};shaka.ads.InterstitialStaticAd.prototype.pause=function(){};shaka.ads.InterstitialStaticAd.prototype.play=function(){};shaka.ads.InterstitialStaticAd.prototype.getVolume=function(){return 1};shaka.ads.InterstitialStaticAd.prototype.setVolume=function(a){};shaka.ads.InterstitialStaticAd.prototype.isMuted=function(){return!1};
shaka.ads.InterstitialStaticAd.prototype.isLinear=function(){return this.isLinear_};shaka.ads.InterstitialStaticAd.prototype.resize=function(a,b){};shaka.ads.InterstitialStaticAd.prototype.setMuted=function(a){};shaka.ads.InterstitialStaticAd.prototype.getSequenceLength=function(){return this.sequenceLength_};shaka.ads.InterstitialStaticAd.prototype.getPositionInSequence=function(){return this.adPosition_};shaka.ads.InterstitialStaticAd.prototype.getTitle=function(){return""};
shaka.ads.InterstitialStaticAd.prototype.getDescription=function(){return""};shaka.ads.InterstitialStaticAd.prototype.getVastMediaBitrate=function(){return 0};shaka.ads.InterstitialStaticAd.prototype.getVastMediaHeight=function(){return 0};shaka.ads.InterstitialStaticAd.prototype.getVastMediaWidth=function(){return 0};shaka.ads.InterstitialStaticAd.prototype.getVastAdId=function(){return""};shaka.ads.InterstitialStaticAd.prototype.getAdId=function(){return this.interstitial_.id||""};
shaka.ads.InterstitialStaticAd.prototype.getCreativeAdId=function(){return""};shaka.ads.InterstitialStaticAd.prototype.getAdvertiserName=function(){return""};shaka.ads.InterstitialStaticAd.prototype.getMediaUrl=function(){return this.interstitial_.uri};shaka.ads.InterstitialStaticAd.prototype.getTimeOffset=function(){return this.interstitial_.pre?0:this.interstitial_.post?-1:this.interstitial_.startTime};shaka.ads.InterstitialStaticAd.prototype.getPodIndex=function(){return 0};
shaka.ads.InterstitialStaticAd.prototype.release=function(){};goog.exportSymbol("shaka.ads.InterstitialStaticAd",shaka.ads.InterstitialStaticAd);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"release",shaka.ads.InterstitialStaticAd.prototype.release);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getPodIndex",shaka.ads.InterstitialStaticAd.prototype.getPodIndex);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getTimeOffset",shaka.ads.InterstitialStaticAd.prototype.getTimeOffset);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getMediaUrl",shaka.ads.InterstitialStaticAd.prototype.getMediaUrl);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getAdvertiserName",shaka.ads.InterstitialStaticAd.prototype.getAdvertiserName);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getCreativeAdId",shaka.ads.InterstitialStaticAd.prototype.getCreativeAdId);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getAdId",shaka.ads.InterstitialStaticAd.prototype.getAdId);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getVastAdId",shaka.ads.InterstitialStaticAd.prototype.getVastAdId);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getVastMediaWidth",shaka.ads.InterstitialStaticAd.prototype.getVastMediaWidth);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getVastMediaHeight",shaka.ads.InterstitialStaticAd.prototype.getVastMediaHeight);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getVastMediaBitrate",shaka.ads.InterstitialStaticAd.prototype.getVastMediaBitrate);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getDescription",shaka.ads.InterstitialStaticAd.prototype.getDescription);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getTitle",shaka.ads.InterstitialStaticAd.prototype.getTitle);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getPositionInSequence",shaka.ads.InterstitialStaticAd.prototype.getPositionInSequence);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getSequenceLength",shaka.ads.InterstitialStaticAd.prototype.getSequenceLength);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"setMuted",shaka.ads.InterstitialStaticAd.prototype.setMuted);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"resize",shaka.ads.InterstitialStaticAd.prototype.resize);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isLinear",shaka.ads.InterstitialStaticAd.prototype.isLinear);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isMuted",shaka.ads.InterstitialStaticAd.prototype.isMuted);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"setVolume",shaka.ads.InterstitialStaticAd.prototype.setVolume);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getVolume",shaka.ads.InterstitialStaticAd.prototype.getVolume);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"play",shaka.ads.InterstitialStaticAd.prototype.play);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"pause",shaka.ads.InterstitialStaticAd.prototype.pause);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"skip",shaka.ads.InterstitialStaticAd.prototype.skip);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"canSkipNow",shaka.ads.InterstitialStaticAd.prototype.canSkipNow);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getTimeUntilSkippable",shaka.ads.InterstitialStaticAd.prototype.getTimeUntilSkippable);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isSkippable",shaka.ads.InterstitialStaticAd.prototype.isSkippable);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isPaused",shaka.ads.InterstitialStaticAd.prototype.isPaused);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getRemainingTime",shaka.ads.InterstitialStaticAd.prototype.getRemainingTime);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getMinSuggestedDuration",shaka.ads.InterstitialStaticAd.prototype.getMinSuggestedDuration);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"getDuration",shaka.ads.InterstitialStaticAd.prototype.getDuration);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isUsingAnotherMediaElement",shaka.ads.InterstitialStaticAd.prototype.isUsingAnotherMediaElement);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"hasCustomClick",shaka.ads.InterstitialStaticAd.prototype.hasCustomClick);goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"isClientRendering",shaka.ads.InterstitialStaticAd.prototype.isClientRendering);
goog.exportProperty(shaka.ads.InterstitialStaticAd.prototype,"needsSkipUI",shaka.ads.InterstitialStaticAd.prototype.needsSkipUI);shaka.ads.InterstitialAdManager=function(a,b,c,d){var e=this;this.config_=null;this.adContainer_=a;this.basePlayer_=b;this.baseVideo_=c;this.adVideo_=null;this.usingBaseVideo_=!0;this.video_=this.baseVideo_;this.onEvent_=d;this.hlsInterstitialIds_=new Set;this.interstitialIds_=new Set;this.interstitials_=new Set;this.preloadManagerInterstitials_=new Map;this.preloadOnDomElements_=new Map;this.player_=new shaka.Player;this.updatePlayerConfig_();this.eventManager_=new shaka.util.EventManager;this.adEventManager_=
new shaka.util.EventManager;this.playingAd_=!1;this.lastOnSkip_=this.playoutLimitTimer_=this.lastPlayedAd_=this.lastTime_=null;this.usingListeners_=!1;this.videoCallbackId_=-1;var f=function(g){return g?g.overlay?!0:e.baseVideo_.ended?g.post:e.baseVideo_.paused?!1:!0:!1};this.checkForInterstitials_=function(){if(!e.playingAd_&&e.lastTime_&&!e.basePlayer_.isRemotePlayback()){e.lastTime_=e.baseVideo_.currentTime;var g=e.getCurrentInterstitial_();g&&f(g)&&e.setupAd_(g,1,1,Date.now())}};this.onTimeUpdate_=
function(){if(!(e.playingAd_||e.lastTime_||e.basePlayer_.isRemotePlayback())){e.baseVideo_.paused||(e.lastTime_=e.baseVideo_.currentTime);var g;e.lastPlayedAd_||(g=e.getCurrentInterstitial_(!0));g||(g=e.getCurrentInterstitial_());g&&f(g)&&e.setupAd_(g,1,1,Date.now())}};this.onSeeked_=function(){if(!e.playingAd_&&e.lastTime_&&!e.basePlayer_.isRemotePlayback()){var g=e.baseVideo_.currentTime;e.lastPlayedAd_&&!e.lastPlayedAd_.pre&&!e.lastPlayedAd_.post&&g<(e.lastPlayedAd_.endTime||e.lastPlayedAd_.startTime)&&
(e.lastPlayedAd_=null)}};this.timeUpdateTimer_=new shaka.util.Timer(this.checkForInterstitials_);this.pollTimer_=new shaka.util.Timer(function(){var g,h,k,l,m,n,p,q,r,t,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(w){switch(w.getNextAddressJsc()){case 1:if(!e.interstitials_.size||e.lastTime_==null){w.jumpTo(0);break}g=e.basePlayer_.getLoadMode();if(g==shaka.Player.LoadMode.DESTROYED||g==shaka.Player.LoadMode.NOT_LOADED)return w.return();h=!1;k=Array.from(e.interstitials_);l=e.basePlayer_.seekRange();
m=(0,$jscomp.makeIterator)(k);n=m.next();case 3:if(n.done){w.jumpTo(5);break}p=n.value;if(p==e.lastPlayedAd_){w.jumpTo(4);break}q=p.endTime||p.startTime;if(!(l.start-q>=1)){r=p.startTime-e.lastTime_;r>0&&r<=10&&(!e.preloadManagerInterstitials_.has(p)&&e.isPreloadAllowed_(p)&&e.preloadManagerInterstitials_.set(p,e.player_.preload(p.uri,null,p.mimeType||void 0)),e.checkPreloadOnDomElements_(p));w.jumpTo(4);break}if(!e.preloadManagerInterstitials_.has(p)){w.jumpTo(7);break}return w.yield(e.preloadManagerInterstitials_.get(p),
8);case 8:(t=w.getYieldResultJsc())&&t.destroy(),e.preloadManagerInterstitials_.delete(p);case 7:e.removePreloadOnDomElements_(p),u=p.id||JSON.stringify(p),e.interstitialIds_.has(u)&&e.interstitialIds_.delete(u),e.interstitials_.delete(p),e.removeEventListeners_(),p.overlay||(h=!0);case 4:n=m.next();w.jumpTo(3);break;case 5:h&&e.cuepointsChanged_(),w.jumpToEnd()}})});this.configure(this.basePlayer_.getConfiguration().ads)};
shaka.ads.InterstitialAdManager.prototype.configure=function(a){this.config_=a;this.playingAd_||this.determineIfUsingBaseVideo_()};
shaka.ads.InterstitialAdManager.prototype.addEventListeners_=function(){var a=this;if(!this.usingListeners_&&this.interstitials_.size){this.eventManager_.listen(this.baseVideo_,"playing",this.onTimeUpdate_);this.eventManager_.listen(this.baseVideo_,"timeupdate",this.onTimeUpdate_);this.eventManager_.listen(this.baseVideo_,"seeked",this.onSeeked_);this.eventManager_.listen(this.baseVideo_,"ended",this.checkForInterstitials_);if("requestVideoFrameCallback"in this.baseVideo_&&!this.isSmartTV_()){var b=
this.baseVideo_,c=function(d,e){a.videoCallbackId_!=-1&&(a.checkForInterstitials_(),a.videoCallbackId_!=-1&&(a.videoCallbackId_=b.requestVideoFrameCallback(c)))};this.videoCallbackId_=b.requestVideoFrameCallback(c)}else this.timeUpdateTimer_.tickEvery(.025);this.pollTimer_&&this.pollTimer_.tickEvery(1);this.usingListeners_=!0}};
shaka.ads.InterstitialAdManager.prototype.removeEventListeners_=function(){this.usingListeners_&&!this.interstitials_.size&&(this.eventManager_.unlisten(this.baseVideo_,"playing",this.onTimeUpdate_),this.eventManager_.unlisten(this.baseVideo_,"timeupdate",this.onTimeUpdate_),this.eventManager_.unlisten(this.baseVideo_,"seeked",this.onSeeked_),this.eventManager_.unlisten(this.baseVideo_,"ended",this.checkForInterstitials_),this.videoCallbackId_!=-1&&(this.baseVideo_.cancelVideoFrameCallback(this.videoCallbackId_),
this.videoCallbackId_=-1),this.timeUpdateTimer_&&this.timeUpdateTimer_.stop(),this.pollTimer_&&this.pollTimer_.stop(),this.usingListeners_=!1)};
shaka.ads.InterstitialAdManager.prototype.determineIfUsingBaseVideo_=function(){if(this.adContainer_&&this.config_){var a=this.config_.supportsMultipleMediaElements,b=this.baseVideo_;b.controls?a=!1:b.webkitPresentationMode&&b.webkitPresentationMode!=="inline"?a=!1:b.webkitDisplayingFullscreen&&(a=!1);this.usingBaseVideo_==a&&((this.usingBaseVideo_=!a)?(this.video_=this.baseVideo_,this.adVideo_&&(this.adVideo_.parentElement&&this.adContainer_.removeChild(this.adVideo_),this.adVideo_=null)):(this.adVideo_||
(this.adVideo_=this.createMediaElement_()),this.video_=this.adVideo_))}else this.usingBaseVideo_=!0};
shaka.ads.InterstitialAdManager.prototype.stop=function(){this.adEventManager_&&this.adEventManager_.removeAll();this.hlsInterstitialIds_.clear();this.interstitialIds_.clear();this.interstitials_.clear();this.player_.destroyAllPreloads();if(this.preloadManagerInterstitials_.size){var a=Array.from(this.preloadManagerInterstitials_.values());a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())(b=b.value)&&b.then(function(c){c&&c.destroy()})}this.preloadManagerInterstitials_.clear();
if(this.preloadOnDomElements_.size)for(a=Array.from(this.preloadOnDomElements_.keys()),a=(0,$jscomp.makeIterator)(a),b=a.next();!b.done;b=a.next())this.removePreloadOnDomElements_(b.value);this.preloadOnDomElements_.clear();this.player_.detach();this.playingAd_=!1;this.lastPlayedAd_=this.lastTime_=null;this.usingBaseVideo_=!0;this.video_=this.baseVideo_;this.adVideo_=null;this.removeBaseStyles_();this.removeEventListeners_();this.adContainer_&&shaka.util.Dom.removeAllChildren(this.adContainer_);this.playoutLimitTimer_&&
(this.playoutLimitTimer_.stop(),this.playoutLimitTimer_=null)};shaka.ads.InterstitialAdManager.prototype.release=function(){this.stop();this.eventManager_&&this.eventManager_.release();this.adEventManager_&&this.adEventManager_.release();this.timeUpdateTimer_&&(this.timeUpdateTimer_.stop(),this.timeUpdateTimer_=null);this.pollTimer_&&(this.pollTimer_.stop(),this.pollTimer_=null);this.player_.destroy()};shaka.ads.InterstitialAdManager.prototype.getPlayer=function(){return this.player_};
shaka.ads.InterstitialAdManager.prototype.addMetadata=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){c=null;if(d=a.values.find(function(g){return g.key=="ID"}))c=d.data;if(c){if(b.hlsInterstitialIds_.has(c))return f.return();b.hlsInterstitialIds_.add(c)}b.updatePlayerConfig_();e=[];return a&&a.values.find(function(g){return g.key=="X-OVERLAY-ID"})?(e=b.getOverlaysInfo_(a),f.jumpTo(2)):f.yield(b.getInterstitialsInfo_(a),3)}f.getNextAddressJsc()!=
2&&(e=f.getYieldResultJsc());e.length?b.addInterstitials(e):shaka.log.alwaysWarn("Unsupported HLS interstitial",a);f.jumpToEnd()})};
shaka.ads.InterstitialAdManager.prototype.addRegion=function(a){var b=shaka.util.TXml,c=a.schemeIdUri=="urn:mpeg:dash:event:alternativeMPD:replace:2025",d=a.schemeIdUri=="urn:mpeg:dash:event:alternativeMPD:insert:2025";if(c||d){for(var e=a.startTime,f=a.endTime,g=null,h=0,k,l=(0,$jscomp.makeIterator)(a.eventNode.children),m=l.next();!m.done;m=l.next())if(m=m.value,m.tagName=="AlternativeMPD"){if(m=m.attributes.uri){k=m;break}}else if(m.tagName=="InsertPresentation"||m.tagName=="ReplacePresentation"){var n=
m.attributes.uri||m.attributes.url;if(n){k=shaka.util.StringUtils.htmlUnescape(n);(l=b.parseAttr(m,"maxDuration",b.parseInt))&&(g=l/a.timescale);(b=b.parseAttr(m,"returnOffset",b.parseInt))&&(h=b/a.timescale);c&&h&&(f=e+h);break}}k?this.addInterstitials([{id:a.id,groupId:null,startTime:e,endTime:f,uri:k,mimeType:null,isSkippable:!1,skipOffset:null,skipFor:null,canJump:!0,resumeOffset:d?h:null,playoutLimit:g,once:!1,pre:!1,post:!1,timelineRange:c&&!d,loop:!1,overlay:null,displayOnBackground:!1,currentVideo:null,
background:null,clickThroughUrl:null}]):shaka.log.warning("Unsupported alternative media presentation",a)}else shaka.log.warning("Unsupported alternative media presentation",a)};
shaka.ads.InterstitialAdManager.prototype.addOverlayRegion=function(a){var b=shaka.util.TXml;goog.asserts.assert(a.eventNode,"Need a region eventNode");var c=b.findChild(a.eventNode,"OverlayEvent"),d=c.attributes.uri,e=c.attributes.mimeType,f=c.attributes.loop=="true",g=b.parseAttr(c,"z",b.parseInt);if(d&&g!=0){var h=null,k=b.findChild(c,"Background");k&&(h=(h=k.attributes.uri)?"center / contain no-repeat url('"+h+"')":b.getContents(k));k=1920;var l=1080,m=b.findChild(c,"Viewport");if(m){k=b.parseAttr(m,
"x",b.parseInt);if(k==null){shaka.log.warning("Unsupported OverlayEvent",a);return}l=b.parseAttr(m,"y",b.parseInt);if(l==null){shaka.log.warning("Unsupported OverlayEvent",a);return}}var n={viewport:{x:k,y:l},topLeft:{x:0,y:0},size:{x:k,y:l}},p=b.findChild(c,"Overlay");if(m&&p){var q=b.findChild(p,"TopLeft"),r=b.findChild(p,"Size");if(q&&r){p=b.parseAttr(q,"x",b.parseInt);if(p==null){shaka.log.warning("Unsupported OverlayEvent",a);return}q=b.parseAttr(q,"y",b.parseInt);if(q==null){shaka.log.warning("Unsupported OverlayEvent",
a);return}var t=b.parseAttr(r,"x",b.parseInt);if(t==null){shaka.log.warning("Unsupported OverlayEvent",a);return}r=b.parseAttr(r,"y",b.parseInt);if(r==null){shaka.log.warning("Unsupported OverlayEvent",a);return}n.topLeft.x=p;n.topLeft.y=q;n.size.x=t;n.size.y=r}}p=null;c=b.findChild(c,"Squeeze");if(m&&c&&(r=b.findChild(c,"TopLeft"),c=b.findChild(c,"Size"),r&&c)){m=b.parseAttr(r,"x",b.parseInt);if(m==null){shaka.log.warning("Unsupported OverlayEvent",a);return}p=b.parseAttr(r,"y",b.parseInt);if(p==
null){shaka.log.warning("Unsupported OverlayEvent",a);return}r=b.parseAttr(c,"x",b.parseInt);if(r==null){shaka.log.warning("Unsupported OverlayEvent",a);return}b=b.parseAttr(c,"y",b.parseInt);if(b==null){shaka.log.warning("Unsupported OverlayEvent",a);return}p={viewport:{x:k,y:l},topLeft:{x:m,y:p},size:{x:r,y:b}}}this.addInterstitials([{id:a.id,groupId:null,startTime:a.startTime,endTime:a.endTime,uri:d,mimeType:e,isSkippable:!1,skipOffset:null,skipFor:null,canJump:!0,resumeOffset:null,playoutLimit:null,
once:!1,pre:!1,post:!1,timelineRange:!0,loop:f,overlay:n,displayOnBackground:g==-1,currentVideo:p,background:h,clickThroughUrl:null}])}else shaka.log.warning("Unsupported OverlayEvent",a)};
shaka.ads.InterstitialAdManager.prototype.addAdUrlInterstitial=function(a){var b=this,c,d,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.getNextAddressJsc()==1)return c=shaka.net.NetworkingEngine,d={type:c.AdvancedRequestType.INTERSTITIAL_AD_URL},p.yield(b.makeAdRequest_(a,d),2);if(p.getNextAddressJsc()!=3){e=p.getYieldResultJsc();f=shaka.util.TXml.parseXml(e,"VAST,vmap:VMAP");if(!f)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.ADS,
shaka.util.Error.Code.VAST_INVALID_XML);g=[];if(f.tagName=="VAST")return g=shaka.ads.Utils.parseVastToInterstitials(f,b.lastTime_),p.jumpTo(3);if(f.tagName!="vmap:VMAP")return p.jumpTo(3);h=function(q){var r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){if(u.getNextAddressJsc()==1)return u.yield(b.makeAdRequest_(q.uri,d),2);r=u.getYieldResultJsc();t=shaka.util.TXml.parseXml(r,"VAST");if(!t)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.ADS,
shaka.util.Error.Code.VAST_INVALID_XML);g.push.apply(g,(0,$jscomp.arrayFromIterable)(shaka.ads.Utils.parseVastToInterstitials(t,q.time)));u.jumpToEnd()})};k=[];l=(0,$jscomp.makeIterator)(shaka.ads.Utils.parseVMAP(f));for(m=l.next();!m.done;m=l.next())n=m.value,k.push(h(n));return k.length?p.yield(Promise.all(k),3):p.jumpTo(3)}b.addInterstitials(g);p.jumpToEnd()})};
shaka.ads.InterstitialAdManager.prototype.addInterstitials=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:c=!1,d=(0,$jscomp.makeIterator)(a),e=d.next();case 2:if(e.done){m.jumpTo(4);break}f=e.value;if(!f.uri){shaka.log.alwaysWarn("Missing URL in interstitial",f);m.jumpTo(3);break}if(f.mimeType){m.jumpTo(5);break}m.setCatchFinallyBlocks(6);g=b.player_.getNetworkingEngine();goog.asserts.assert(g,"Need networking engine");
return m.yield(shaka.net.NetworkingUtils.getMimeType(f.uri,g,b.basePlayer_.getConfiguration().streaming.retryParameters),8);case 8:f.mimeType=m.getYieldResultJsc();m.leaveTryBlock(5);break;case 6:m.enterCatchBlock();case 5:h=f.id||JSON.stringify(f);if(b.interstitialIds_.has(h)){m.jumpTo(3);break}f.loop&&!f.overlay&&shaka.log.alwaysWarn("Loop is only supported in overlay interstitials",f);f.overlay||(c=!0);b.interstitialIds_.add(h);b.interstitials_.add(f);k=!1;f.pre&&b.lastTime_==null?k=!0:f.startTime!=
0||f.canJump?b.lastTime_!=null&&(l=f.startTime-b.lastTime_,l>0&&l<=10&&(k=!0)):k=!0;k&&(!b.preloadManagerInterstitials_.has(f)&&b.isPreloadAllowed_(f)&&b.preloadManagerInterstitials_.set(f,b.player_.preload(f.uri,null,f.mimeType||void 0)),b.checkPreloadOnDomElements_(f));case 3:e=d.next();m.jumpTo(2);break;case 4:c&&b.cuepointsChanged_(),b.addEventListeners_(),m.jumpToEnd()}})};
shaka.ads.InterstitialAdManager.prototype.createMediaElement_=function(){var a=document.createElement(this.baseVideo_.tagName);a.autoplay=!0;a.style.position="absolute";a.style.top="0";a.style.left="0";a.style.width="100%";a.style.height="100%";a.style.display="none";a.setAttribute("playsinline","");return a};
shaka.ads.InterstitialAdManager.prototype.getCurrentInterstitial_=function(a,b){a=a===void 0?!1:a;b=b===void 0?null:b;var c=0,d=null;if(this.interstitials_.size&&this.lastTime_!=null){var e=this.baseVideo_.ended,f=Array.from(this.interstitials_).sort(function(m,n){return n.startTime-m.startTime}),g=f;g=a?f.filter(function(m){return m.pre}):e?f.filter(function(m){return m.post}):f.filter(function(m){return!m.pre&&!m.post});f=(0,$jscomp.makeIterator)(g);for(g=f.next();!g.done;g=f.next()){g=g.value;
var h=!1;if(a)h=g.pre;else if(e)h=g.post;else if(!g.pre&&!g.post){var k=this.lastTime_-Math.round(g.startTime*1E3)/1E3,l=1;this.config_.allowStartInMiddleOfInterstitial&&g.endTime&&g.endTime!=Infinity&&(l=g.endTime-g.startTime);(k>0||k==0&&this.lastTime_==0)&&(k<=l||!g.canJump)&&(h=b==null&&this.lastPlayedAd_&&!this.lastPlayedAd_.pre&&!this.lastPlayedAd_.post&&this.lastPlayedAd_.startTime>=g.startTime?!1:!0)}h&&(!this.lastPlayedAd_||g.startTime>=this.lastPlayedAd_.startTime)&&(c==(b||0)?d=g:d&&!g.canJump&&
Math.round(g.startTime*1E3)/1E3-Math.round(d.startTime*1E3)/1E3>.001&&(d=g,c=0),c++)}}return d};
shaka.ads.InterstitialAdManager.prototype.setupAd_=function(a,b,c,d,e){e=e===void 0?0:e;shaka.log.info("Starting interstitial",a.startTime,"at",this.lastTime_);this.lastPlayedAd_=a;this.determineIfUsingBaseVideo_();goog.asserts.assert(this.video_,"Must have video");this.usingBaseVideo_||!this.adContainer_||this.video_.parentElement||this.adContainer_.appendChild(this.video_);c==1&&b==1&&(b=Array.from(this.interstitials_).filter(function(f){return a.pre?f.pre==a.pre:a.post?f.post==a.post:Math.abs(f.startTime-
a.startTime)<.001}).length);a.once&&(e++,this.interstitials_.delete(a),this.removeEventListeners_(),a.overlay||this.cuepointsChanged_());a.mimeType&&(a.mimeType.startsWith("image/")||a.mimeType==="text/html")?a.overlay?(shaka.log.info("Starting interstitial",a),this.setupStaticAd_(a,b,c,e)):shaka.log.alwaysWarn("Unsupported interstitial",a):this.usingBaseVideo_&&a.overlay?shaka.log.alwaysWarn("Unsupported interstitial",a):(shaka.log.info("Starting interstitial",a),this.setupVideoAd_(a,b,c,d,e))};
shaka.ads.InterstitialAdManager.prototype.setupStaticAd_=function(a,b,c,d){var e=this;this.playingAd_=!0;var f=a.overlay;goog.asserts.assert(f,"Must have overlay");var g=a.mimeType=="text/html"?"iframe":"img",h=document.createElement(g);h.style.objectFit="contain";h.style.position="absolute";h.style.border="none";this.setBaseStyles_(a);var k=function(){e.playoutLimitTimer_&&(e.playoutLimitTimer_.stop(),e.playoutLimitTimer_=null);e.adContainer_.removeChild(h);e.removeBaseStyles_(a);e.sendEvent_(shaka.ads.Utils.AD_STOPPED);
e.adEventManager_.removeAll();var p=e.getCurrentInterstitial_(a.pre,c-d);p?e.setupAd_(p,b,++c,Date.now(),d):e.playingAd_=!1},l=new shaka.ads.InterstitialStaticAd(a,b,c);this.sendEvent_(shaka.ads.Utils.AD_IMPRESSION);this.sendEvent_(shaka.ads.Utils.AD_STARTED,(new Map).set("ad",l));g=="iframe"?h.src=a.uri:(h.src=a.uri,h.onerror=function(p){e.sendEvent_(shaka.ads.Utils.AD_ERROR,(new Map).set("originalEvent",p));k()});l=f.viewport;var m=f.topLeft;f=f.size;l.x==0&&l.y==0?(h.width=a.overlay.size.x,h.height=
a.overlay.size.y,h.style.bottom="10%",h.style.left="0",h.style.right="0",h.style.width="100%",a.overlay.size.y||g!="iframe"||(h.style.height="auto")):(h.style.height=f.y/l.y*100+"%",h.style.left=m.x/l.x*100+"%",h.style.top=m.y/l.y*100+"%",h.style.width=f.x/l.x*100+"%");this.adContainer_.appendChild(h);var n=Date.now();this.playoutLimitTimer_&&this.playoutLimitTimer_.stop();this.playoutLimitTimer_=new shaka.util.Timer(function(){a.playoutLimit&&(Date.now()-n)/1E3>a.playoutLimit?(e.sendEvent_(shaka.ads.Utils.AD_COMPLETE),
k()):a.endTime&&e.baseVideo_.currentTime>a.endTime?(e.sendEvent_(shaka.ads.Utils.AD_COMPLETE),k()):e.baseVideo_.currentTime<a.startTime&&(e.sendEvent_(shaka.ads.Utils.AD_SKIPPED),k())});a.playoutLimit&&!a.endTime?this.playoutLimitTimer_.tickAfter(a.playoutLimit):a.endTime&&this.playoutLimitTimer_.tickEvery(.025);this.adEventManager_.listen(this.baseVideo_,"seeked",function(){var p=e.baseVideo_.currentTime;if(p<a.startTime||a.endTime&&p>a.endTime)e.playoutLimitTimer_&&e.playoutLimitTimer_.stop(),e.sendEvent_(shaka.ads.Utils.AD_SKIPPED),
k()});a.clickThroughUrl&&this.adEventManager_.listen(h,"click",function(p){a.clickThroughUrl&&window.open(a.clickThroughUrl,"_blank")})};
shaka.ads.InterstitialAdManager.prototype.setupVideoAd_=function(a,b,c,d,e){var f=this,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.getNextAddressJsc()){case 1:goog.asserts.assert(f.video_,"Must have video");g=Date.now();f.playingAd_=!0;h=!1;k=function(){if(!f.usingBaseVideo_&&!a.overlay&&a.resumeOffset==null)if(a.timelineRange&&a.endTime&&a.endTime!=Infinity)f.baseVideo_.currentTime!=a.endTime&&(f.baseVideo_.currentTime=a.endTime);
else{var I=Date.now();f.baseVideo_.currentTime+=(I-d)/1E3;d=I}};l=function(I){var F,J;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(K){if(K.getNextAddressJsc()==1){k();F=f.getCurrentInterstitial_(a.pre,c-e);if(I&&a.groupId)for(;F&&F.groupId==a.groupId;)c++,F=f.getCurrentInterstitial_(a.pre,c-e);f.playoutLimitTimer_&&(!a.groupId||F&&F.groupId!=a.groupId)&&(f.playoutLimitTimer_.stop(),f.playoutLimitTimer_=null);f.removeBaseStyles_(a);if(F&&!F.overlay)return K.jumpTo(2);a.post&&(f.lastTime_=
null,f.lastPlayedAd_=null);return f.usingBaseVideo_?K.yield(f.player_.detach(),4):K.yield(f.player_.unload(),4)}K.getNextAddressJsc()!=2&&(f.usingBaseVideo_&&(J=a.resumeOffset,J==null&&(J=a.timelineRange&&a.endTime&&a.endTime!=Infinity?a.endTime-(f.lastTime_||0):(Date.now()-d)/1E3),f.sendEvent_(shaka.ads.Utils.AD_CONTENT_RESUME_REQUESTED,(new Map).set("offset",J))),f.sendEvent_(shaka.ads.Utils.AD_STOPPED),f.adEventManager_.removeAll(),f.playingAd_=!1,f.usingBaseVideo_?f.cuepointsChanged_():(f.video_.style.display=
"none",k(),f.baseVideo_.ended||f.baseVideo_.play()));f.determineIfUsingBaseVideo_();F&&(f.sendEvent_(shaka.ads.Utils.AD_STOPPED),f.adEventManager_.removeAll(),f.setupAd_(F,b,++c,d,e));K.jumpToEnd()})};m=function(I){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(F){if(h)return F.return();h=!0;f.sendEvent_(shaka.ads.Utils.AD_ERROR,(new Map).set("originalEvent",I));return F.yield(l(!1),0)})};n=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(I){if(I.getNextAddressJsc()==
1){if(h)return I.return();h=!0;return I.yield(l(!1),2)}f.sendEvent_(shaka.ads.Utils.AD_COMPLETE);I.jumpToEnd()})};f.lastOnSkip_=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(I){if(h)return I.return();h=!0;f.sendEvent_(shaka.ads.Utils.AD_SKIPPED);return I.yield(l(!0),0)})};p=new shaka.ads.InterstitialAd(f.video_,a,f.lastOnSkip_,b,c,!f.usingBaseVideo_);f.usingBaseVideo_||(p.setMuted(f.baseVideo_.muted),p.setVolume(f.baseVideo_.volume));f.sendEvent_(shaka.ads.Utils.AD_STARTED,
(new Map).set("ad",p));(q=p.canSkipNow())&&f.sendEvent_(shaka.ads.Utils.AD_SKIP_STATE_CHANGED);f.adEventManager_.listenOnce(f.player_,"error",m);f.adEventManager_.listen(f.video_,"timeupdate",function(){if(f.video_.duration){var I=p.canSkipNow();q!=I&&p.getRemainingTime()>0&&p.getDuration()>0&&f.sendEvent_(shaka.ads.Utils.AD_SKIP_STATE_CHANGED);q=I;!f.usingBaseVideo_&&!a.overlay&&a.resumeOffset==null&&a.timelineRange&&a.endTime&&a.endTime!=Infinity&&f.baseVideo_.currentTime!=a.endTime&&f.basePlayer_.seekRange().end>=
a.endTime&&(f.baseVideo_.currentTime=a.endTime)}});f.adEventManager_.listenOnce(f.player_,"firstquartile",function(){k();f.sendEvent_(shaka.ads.Utils.AD_FIRST_QUARTILE)});f.adEventManager_.listenOnce(f.player_,"midpoint",function(){k();f.sendEvent_(shaka.ads.Utils.AD_MIDPOINT)});f.adEventManager_.listenOnce(f.player_,"thirdquartile",function(){k();f.sendEvent_(shaka.ads.Utils.AD_THIRD_QUARTILE)});f.adEventManager_.listenOnce(f.player_,"complete",n);f.adEventManager_.listen(f.video_,"play",function(){f.sendEvent_(shaka.ads.Utils.AD_RESUMED)});
f.adEventManager_.listen(f.video_,"pause",function(){var I=f.player_.getConfiguration();f.video_.currentTime>=I.playRangeEnd?n():f.sendEvent_(shaka.ads.Utils.AD_PAUSED)});f.adEventManager_.listen(f.video_,"volumechange",function(){f.video_.muted?f.sendEvent_(shaka.ads.Utils.AD_MUTED):f.sendEvent_(shaka.ads.Utils.AD_VOLUME_CHANGED);f.usingBaseVideo_||(f.baseVideo_.volume=f.video_.volume,f.baseVideo_.muted=f.video_.muted)});a.clickThroughUrl&&(r=f.adContainer_||f.video_,f.adEventManager_.listen(r,"click",
function(I){a.clickThroughUrl&&(p.isPaused()||p.pause(),window.open(a.clickThroughUrl,"_blank"))}));if(!f.usingBaseVideo_||c!=1){G.jumpTo(2);break}f.sendEvent_(shaka.ads.Utils.AD_CONTENT_PAUSE_REQUESTED,(new Map).set("saveLivePosition",!0));t=new shaka.util.PublicPromise;u=function(I){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(F){if(F.getNextAddressJsc()==1)return I.state!="detach"?F.jumpTo(0):f.isSmartTV_()?F.yield(new Promise(function(J){return(new shaka.util.Timer(J)).tickAfter(.1)}),
3):F.jumpTo(3);t.resolve();f.adEventManager_.unlisten(f.basePlayer_,"onstatechange",u);F.jumpToEnd()})};f.adEventManager_.listen(f.basePlayer_,"onstatechange",u);return G.yield(t,2);case 2:return f.setBaseStyles_(a),f.usingBaseVideo_||(f.video_.style.display="",a.overlay?(f.video_.loop=a.loop,w=a.overlay.viewport,v=a.overlay.topLeft,x=a.overlay.size,f.video_.style.height=x.y/w.y*100+"%",f.video_.style.left=v.x/w.x*100+"%",f.video_.style.top=v.y/w.y*100+"%",f.video_.style.width=x.x/w.x*100+"%"):(f.baseVideo_.pause(),
a.resumeOffset!=null&&a.resumeOffset!=0&&(f.baseVideo_.currentTime+=a.resumeOffset),f.video_.loop=!1,f.video_.style.height="100%",f.video_.style.left="0",f.video_.style.top="0",f.video_.style.width="100%")),G.setCatchFinallyBlocks(4),f.updatePlayerConfig_(),a.startTime&&a.endTime&&a.endTime!=Infinity&&a.startTime!=a.endTime&&(y=a.endTime-a.startTime,y>0&&f.player_.configure("playRangeEnd",y)),a.playoutLimit&&!f.playoutLimitTimer_&&(f.playoutLimitTimer_=(new shaka.util.Timer(function(){f.lastOnSkip_()})).tickAfter(a.playoutLimit),
f.player_.configure("playRangeEnd",a.playoutLimit)),G.yield(f.player_.attach(f.video_),6);case 6:return A=null,a.pre||a.post||!f.config_.allowStartInMiddleOfInterstitial||f.lastTime_==null||(B=f.lastTime_-a.startTime,Math.abs(B)>.25&&(A=B)),f.preloadManagerInterstitials_.has(a)?G.yield(f.preloadManagerInterstitials_.get(a),10):G.yield(f.player_.load(a.uri,A,a.mimeType||void 0),8);case 10:return D=G.getYieldResultJsc(),f.preloadManagerInterstitials_.delete(a),D?G.yield(f.player_.load(D),8):G.yield(f.player_.load(a.uri,
A,a.mimeType||void 0),8);case 8:a.overlay&&f.baseVideo_.paused?f.video_.pause():f.video_.play();z=(Date.now()-g)/1E3;f.sendEvent_(shaka.ads.Utils.ADS_LOADED,(new Map).set("loadTime",z));f.usingBaseVideo_&&f.baseVideo_.play();a.overlay&&(a.pre||a.post||f.basePlayer_.isLive()&&!(a.startTime>0)||(C=function(){var I=f.baseVideo_.currentTime-a.startTime;Math.abs(I-f.video_.currentTime)>.1&&(f.video_.currentTime=I)},f.adEventManager_.listenOnce(f.video_,"playing",C),f.adEventManager_.listen(f.baseVideo_,
"seeking",C)),f.adEventManager_.listen(f.baseVideo_,"seeked",function(){var I=f.baseVideo_.currentTime;(I<a.startTime||a.endTime&&I>a.endTime)&&f.lastOnSkip_()}));G.leaveTryBlock(0);break;case 4:E=G.enterCatchBlock();if(!f.playingAd_)return G.return();m(E);G.jumpToEnd()}})};
shaka.ads.InterstitialAdManager.prototype.setBaseStyles_=function(a){a.displayOnBackground&&(this.baseVideo_.style.zIndex="1");if(a.currentVideo!=null){var b=a.currentVideo;this.baseVideo_.style.transformOrigin="top left";var c=!0,d=[],e=b.topLeft.x/b.viewport.x*100;e>0&&e<=100&&(d.push("translateX("+e+"%)"),c=!1);e=b.topLeft.y/b.viewport.y*100;e>0&&e<=100&&(d.push("translateY("+e+"%)"),c=!1);e=b.size.x/b.viewport.x;e<1&&d.push("scaleX("+e+")");b=b.size.y/b.viewport.y;e<1&&d.push("scaleY("+b+")");
d.length&&(this.baseVideo_.style.transform=d.join(" "));c&&(this.baseVideo_.style.transition="transform 250ms")}this.adContainer_&&(a.clickThroughUrl?(this.adContainer_.setAttribute("ad-active","true"),this.adContainer_.style.pointerEvents=""):this.adContainer_.style.pointerEvents="none",a.background&&(this.adContainer_.style.background=a.background));this.adVideo_&&(this.adVideo_.style.background=a.overlay?"":"rgb(0, 0, 0)")};
shaka.ads.InterstitialAdManager.prototype.removeBaseStyles_=function(a){if(!a||a.displayOnBackground)this.baseVideo_.style.zIndex="";a&&a.currentVideo==null||(this.baseVideo_.style.transformOrigin="",this.baseVideo_.style.transition="",this.baseVideo_.style.transform="");this.adContainer_&&(this.adContainer_.removeAttribute("ad-active"),this.adContainer_.style.pointerEvents="",!a||a.background)&&(this.adContainer_.style.background="");this.adVideo_&&(this.adVideo_.style.background="")};
shaka.ads.InterstitialAdManager.prototype.getInterstitialsInfo_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V,U,X,Y,T;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(W){switch(W.getNextAddressJsc()){case 1:c=[];if(!a)return W.return(c);d=a.values.find(function(R){return R.key=="X-ASSET-URI"});e=a.values.find(function(R){return R.key=="X-ASSET-LIST"});if(!d&&!e)return W.return(c);f=null;if(g=a.values.find(function(R){return R.key==
"ID"}))f=g.data;h=f==null?Math.floor(a.startTime*10)/10:a.startTime;(k=a.endTime)&&a.endTime!=Infinity&&typeof a.endTime=="number"&&(k=f==null?Math.floor(a.endTime*10)/10:a.endTime);l=a.values.find(function(R){return R.key=="X-RESTRICT"});n=m=!0;l&&l.data&&(p=l.data,m=!p.includes("SKIP"),n=!p.includes("JUMP"));q=m?0:null;if(r=a.values.find(function(R){return R.key=="X-ENABLE-SKIP-AFTER"}))t=r.data,q=parseFloat(t),isNaN(q)&&(q=m?0:null);u=null;if(w=a.values.find(function(R){return R.key=="X-ENABLE-SKIP-FOR"}))v=
w.data,u=parseFloat(v),isNaN(q)&&(u=null);x=null;if(y=a.values.find(function(R){return R.key=="X-RESUME-OFFSET"}))A=y.data,x=parseFloat(A),isNaN(x)&&(x=null);B=null;if(D=a.values.find(function(R){return R.key=="X-PLAYOUT-LIMIT"}))z=D.data,B=parseFloat(z),isNaN(B)&&(B=null);G=E=C=!1;if(I=a.values.find(function(R){return R.key=="CUE"}))F=I.data,C=F.includes("ONCE"),E=F.includes("PRE"),G=F.includes("POST");J=!1;(K=a.values.find(function(R){return R.key=="X-TIMELINE-OCCUPIES"}))?(H=K.data,J=H.includes("RANGE")):
!y&&b.basePlayer_.isLive()&&(J=!E&&!G);if(d){M=d.data;if(!M)return W.return(c);c.push({id:f,groupId:null,startTime:h,endTime:k,uri:M,mimeType:null,isSkippable:m,skipOffset:q,skipFor:u,canJump:n,resumeOffset:x,playoutLimit:B,once:C,pre:E,post:G,timelineRange:J,loop:!1,overlay:null,displayOnBackground:!1,currentVideo:null,background:null,clickThroughUrl:null});W.jumpTo(2);break}if(!e){W.jumpTo(2);break}L=e.data;if(!L)return W.return(c);W.setCatchFinallyBlocks(4);N=shaka.net.NetworkingEngine;P={type:N.AdvancedRequestType.INTERSTITIAL_ASSET_LIST};
return W.yield(b.makeAdRequest_(L,P),6);case 6:Q=W.getYieldResultJsc();O=shaka.util.StringUtils.fromUTF8(Q);S=JSON.parse(O);if(V=S["SKIP-CONTROL"])U=V["ENABLE-SKIP-AFTER"],typeof U=="number"&&(q=parseFloat(U),isNaN(U)&&(q=m?0:null)),X=V["ENABLE-SKIP-FOR"],typeof X=="number"&&(u=parseFloat(X),isNaN(X)&&(u=null));for(Y=0;Y<S.ASSETS.length;Y++)T=S.ASSETS[Y],T.URI&&c.push({id:f+"_shaka_asset_"+Y,groupId:f,startTime:h,endTime:k,uri:T.URI,mimeType:null,isSkippable:m,skipOffset:q,skipFor:u,canJump:n,resumeOffset:x,
playoutLimit:B,once:C,pre:E,post:G,timelineRange:J,loop:!1,overlay:null,displayOnBackground:!1,currentVideo:null,background:null,clickThroughUrl:null});W.leaveTryBlock(2);break;case 4:W.enterCatchBlock();case 2:return W.return(c)}})};
shaka.ads.InterstitialAdManager.prototype.getOverlaysInfo_=function(a){var b=[];if(!a)return b;var c=a.values.find(function(u){return u.key=="X-ASSET-URI"});if(!c)return b;c=c.data;if(!c)return b;var d=null,e=a.values.find(function(u){return u.key=="X-OVERLAY-ID"});e&&(d=e.data);e=d==null?Math.floor(a.startTime*10)/10:a.startTime;var f=a.endTime;a.endTime&&a.endTime!=Infinity&&typeof a.endTime=="number"&&(f=d==null?Math.floor(a.endTime*10)/10:a.endTime);var g=!1,h=!1,k=!1,l=a.values.find(function(u){return u.key==
"CUE"});l&&(k=l.data,g=k.includes("ONCE"),h=k.includes("PRE"),k=k.includes("POST"));l=null;var m=a.values.find(function(u){return u.key=="X-ASSET-MIMETYPE"});m&&(l=m.data);m=!1;var n=a.values.find(function(u){return u.key=="X-LOOP"});n&&(m=n.data=="YES");n=1;var p=a.values.find(function(u){return u.key=="X-DEPTH"});p&&(n=parseFloat(p.data),isNaN(n)&&(n=1));p=null;var q=a.values.find(function(u){return u.key=="X-BACKGROUND"});q&&(p=q.data);q=1920;var r=1080,t=a.values.find(function(u){return u.key==
"X-VIEWPORT"});if(t){r=t.data.split("x");if(r.length!=2)return b;q=parseFloat(r[0]);r=parseFloat(r[1])}q={viewport:{x:q,y:r},topLeft:{x:0,y:0},size:{x:q,y:r}};if(r=a.values.find(function(u){return u.key=="X-OVERLAY-POSITION"})){r=r.data.split("x");if(r.length!=2)return b;q.topLeft.x=parseFloat(r[0]);q.topLeft.y=parseFloat(r[1])}if(r=a.values.find(function(u){return u.key=="X-OVERLAY-SIZE"})){r=r.data.split("x");if(r.length!=2)return b;q.size.x=parseFloat(r[0]);q.size.y=parseFloat(r[1])}r=null;if(t=
a.values.find(function(u){return u.key=="X-SQUEEZECURRENT"}))if(r=parseFloat(t.data),isNaN(r)&&(r=1),r={viewport:{x:1920,y:1080},topLeft:{x:0,y:0},size:{x:1920*r,y:1080*r}},a=a.values.find(function(u){return u.key=="X-SQUEEZECURRENT-POSITION"})){a=a.data.split("x");if(a.length!=2)return b;r.topLeft.x=parseFloat(a[0]);r.topLeft.y=parseFloat(a[1])}b.push({id:d,groupId:null,startTime:e,endTime:f,uri:c,mimeType:l,isSkippable:!1,skipOffset:null,skipFor:null,canJump:!0,resumeOffset:null,playoutLimit:null,
once:g,pre:h,post:k,timelineRange:!0,loop:m,overlay:q,displayOnBackground:n==-1,currentVideo:r,background:p,clickThroughUrl:null});return b};
shaka.ads.InterstitialAdManager.prototype.cuepointsChanged_=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.interstitials_),c=b.next(),d={};!c.done;d={shakaCuePoint$jscomp$1:void 0},c=b.next())c=c.value,c.overlay||(d.shakaCuePoint$jscomp$1={start:c.startTime,end:null},c.pre?(d.shakaCuePoint$jscomp$1.start=0,d.shakaCuePoint$jscomp$1.end=null):c.post?(d.shakaCuePoint$jscomp$1.start=-1,d.shakaCuePoint$jscomp$1.end=null):c.timelineRange&&(d.shakaCuePoint$jscomp$1.end=c.endTime),a.find(function(e){return function(f){return e.shakaCuePoint$jscomp$1.start==
f.start&&e.shakaCuePoint$jscomp$1.end==f.end}}(d))||a.push(d.shakaCuePoint$jscomp$1));this.sendEvent_(shaka.ads.Utils.CUEPOINTS_CHANGED,(new Map).set("cuepoints",a))};
shaka.ads.InterstitialAdManager.prototype.updatePlayerConfig_=function(){goog.asserts.assert(this.player_,"Must have player");goog.asserts.assert(this.basePlayer_,"Must have base player");this.player_.configure(this.basePlayer_.getNonDefaultConfiguration());this.player_.configure("ads.disableHLSInterstitial",!0);this.player_.configure("ads.disableDASHInterstitial",!0);this.player_.configure("playRangeEnd",Infinity);var a=this.player_.getNetworkingEngine();goog.asserts.assert(a,"Need networking engine");
this.basePlayer_.getNetworkingEngine().copyFiltersInto(a)};shaka.ads.InterstitialAdManager.prototype.makeAdRequest_=function(a,b){var c=this,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return d=shaka.net.NetworkingEngine.RequestType.ADS,e=shaka.net.NetworkingEngine.makeRequest([a],shaka.net.NetworkingEngine.defaultRetryParameters()),f=c.basePlayer_.getNetworkingEngine().request(d,e,b),h.yield(f.promise,2);g=h.getYieldResultJsc();return h.return(g.data)})};
shaka.ads.InterstitialAdManager.prototype.isPreloadAllowed_=function(a){return(a=a.mimeType)?!a.startsWith("image/")&&a!=="text/html":!0};shaka.ads.InterstitialAdManager.prototype.getInterstitials=function(){return Array.from(this.interstitials_)};
shaka.ads.InterstitialAdManager.prototype.isSmartTV_=function(){var a=shaka.device.DeviceFactory.getDevice().getDeviceType();return a==shaka.device.IDevice.DeviceType.TV||a==shaka.device.IDevice.DeviceType.CONSOLE||a==shaka.device.IDevice.DeviceType.CAST?!0:!1};
shaka.ads.InterstitialAdManager.prototype.checkPreloadOnDomElements_=function(a){if(!(this.preloadOnDomElements_.has(a)||this.config_&&!this.config_.allowPreloadOnDomElements)){var b=function(e){var f=document.createElement("link");f.rel="preload";f.href=e;f.as="image";document.head.appendChild(f);return f},c=[];if(a.background){var d=a.background.match(/url\(('|")?([^'"()]+)('|")\)?/);d&&c.push(b(d[2]))}a.mimeType&&a.mimeType.startsWith("image/")&&c.push(b(a.uri));this.preloadOnDomElements_.set(a,
c)}};shaka.ads.InterstitialAdManager.prototype.removePreloadOnDomElements_=function(a){if(this.preloadOnDomElements_.has(a)){var b=this.preloadOnDomElements_.get(a);b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,c.parentNode.removeChild(c);this.preloadOnDomElements_.delete(a)}};shaka.ads.InterstitialAdManager.prototype.sendEvent_=function(a,b){shaka.log.info("Interstitial event",a);this.onEvent_(new shaka.util.FakeEvent(a,b))};shaka.ads.MediaTailorAd=function(a,b,c,d,e){this.ad_=a;this.skipOffset_=shaka.util.TextParser.parseTime(this.ad_.skipOffset);this.video_=e;this.adPosition_=b;this.totalAds_=c;this.isLinear_=d;this.isSkipped_=!1};shaka.ads.MediaTailorAd.prototype.needsSkipUI=function(){return!0};shaka.ads.MediaTailorAd.prototype.isClientRendering=function(){return!1};shaka.ads.MediaTailorAd.prototype.hasCustomClick=function(){return!1};shaka.ads.MediaTailorAd.prototype.isUsingAnotherMediaElement=function(){return!1};
shaka.ads.MediaTailorAd.prototype.getDuration=function(){return this.ad_.durationInSeconds};shaka.ads.MediaTailorAd.prototype.getMinSuggestedDuration=function(){return this.getDuration()};shaka.ads.MediaTailorAd.prototype.getRemainingTime=function(){return this.ad_.startTimeInSeconds+this.ad_.durationInSeconds-this.video_.currentTime};shaka.ads.MediaTailorAd.prototype.isPaused=function(){return this.video_.paused};
shaka.ads.MediaTailorAd.prototype.isSkippable=function(){return typeof this.skipOffset_=="number"?!0:!1};shaka.ads.MediaTailorAd.prototype.getTimeUntilSkippable=function(){if(typeof this.skipOffset_!="number")return this.getRemainingTime();var a=this.getRemainingTime()+this.skipOffset_-this.getDuration();return Math.max(a,0)};shaka.ads.MediaTailorAd.prototype.canSkipNow=function(){return this.getTimeUntilSkippable()==0};
shaka.ads.MediaTailorAd.prototype.skip=function(){this.isSkipped_=!0;this.video_.currentTime+=this.getRemainingTime()};shaka.ads.MediaTailorAd.prototype.pause=function(){return this.video_.pause()};shaka.ads.MediaTailorAd.prototype.play=function(){return this.video_.play()};shaka.ads.MediaTailorAd.prototype.getVolume=function(){return this.video_.volume};shaka.ads.MediaTailorAd.prototype.setVolume=function(a){this.video_.volume=a};shaka.ads.MediaTailorAd.prototype.isMuted=function(){return this.video_.muted};
shaka.ads.MediaTailorAd.prototype.isLinear=function(){return this.isLinear_};shaka.ads.MediaTailorAd.prototype.resize=function(a,b){};shaka.ads.MediaTailorAd.prototype.setMuted=function(a){this.video_.muted=a};shaka.ads.MediaTailorAd.prototype.getSequenceLength=function(){return this.totalAds_?this.totalAds_:1};shaka.ads.MediaTailorAd.prototype.getPositionInSequence=function(){return this.adPosition_?this.adPosition_:1};shaka.ads.MediaTailorAd.prototype.getTitle=function(){return this.ad_.adTitle};
shaka.ads.MediaTailorAd.prototype.getDescription=function(){return""};shaka.ads.MediaTailorAd.prototype.getVastMediaBitrate=function(){return 0};shaka.ads.MediaTailorAd.prototype.getVastMediaHeight=function(){return 0};shaka.ads.MediaTailorAd.prototype.getVastMediaWidth=function(){return 0};shaka.ads.MediaTailorAd.prototype.getVastAdId=function(){return this.ad_.vastAdId||""};shaka.ads.MediaTailorAd.prototype.getAdId=function(){return this.ad_.adId};
shaka.ads.MediaTailorAd.prototype.getCreativeAdId=function(){return this.ad_.creativeId};shaka.ads.MediaTailorAd.prototype.getAdvertiserName=function(){return""};shaka.ads.MediaTailorAd.prototype.getMediaUrl=function(){return null};shaka.ads.MediaTailorAd.prototype.getTimeOffset=function(){return 0};shaka.ads.MediaTailorAd.prototype.getPodIndex=function(){return 0};shaka.ads.MediaTailorAd.prototype.release=function(){this.totalAds_=this.adPosition_=this.video_=this.ad_=null};
shaka.ads.MediaTailorAd.prototype.isSkipped=function(){return this.isSkipped_};goog.exportSymbol("shaka.ads.MediaTailorAd",shaka.ads.MediaTailorAd);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"release",shaka.ads.MediaTailorAd.prototype.release);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getPodIndex",shaka.ads.MediaTailorAd.prototype.getPodIndex);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getTimeOffset",shaka.ads.MediaTailorAd.prototype.getTimeOffset);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getMediaUrl",shaka.ads.MediaTailorAd.prototype.getMediaUrl);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getAdvertiserName",shaka.ads.MediaTailorAd.prototype.getAdvertiserName);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getCreativeAdId",shaka.ads.MediaTailorAd.prototype.getCreativeAdId);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getAdId",shaka.ads.MediaTailorAd.prototype.getAdId);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getVastAdId",shaka.ads.MediaTailorAd.prototype.getVastAdId);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getVastMediaWidth",shaka.ads.MediaTailorAd.prototype.getVastMediaWidth);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getVastMediaHeight",shaka.ads.MediaTailorAd.prototype.getVastMediaHeight);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getVastMediaBitrate",shaka.ads.MediaTailorAd.prototype.getVastMediaBitrate);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getDescription",shaka.ads.MediaTailorAd.prototype.getDescription);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getTitle",shaka.ads.MediaTailorAd.prototype.getTitle);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getPositionInSequence",shaka.ads.MediaTailorAd.prototype.getPositionInSequence);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getSequenceLength",shaka.ads.MediaTailorAd.prototype.getSequenceLength);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"setMuted",shaka.ads.MediaTailorAd.prototype.setMuted);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"resize",shaka.ads.MediaTailorAd.prototype.resize);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isLinear",shaka.ads.MediaTailorAd.prototype.isLinear);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isMuted",shaka.ads.MediaTailorAd.prototype.isMuted);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"setVolume",shaka.ads.MediaTailorAd.prototype.setVolume);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getVolume",shaka.ads.MediaTailorAd.prototype.getVolume);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"play",shaka.ads.MediaTailorAd.prototype.play);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"pause",shaka.ads.MediaTailorAd.prototype.pause);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"skip",shaka.ads.MediaTailorAd.prototype.skip);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"canSkipNow",shaka.ads.MediaTailorAd.prototype.canSkipNow);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getTimeUntilSkippable",shaka.ads.MediaTailorAd.prototype.getTimeUntilSkippable);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isSkippable",shaka.ads.MediaTailorAd.prototype.isSkippable);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isPaused",shaka.ads.MediaTailorAd.prototype.isPaused);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getRemainingTime",shaka.ads.MediaTailorAd.prototype.getRemainingTime);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getMinSuggestedDuration",shaka.ads.MediaTailorAd.prototype.getMinSuggestedDuration);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"getDuration",shaka.ads.MediaTailorAd.prototype.getDuration);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isUsingAnotherMediaElement",shaka.ads.MediaTailorAd.prototype.isUsingAnotherMediaElement);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"hasCustomClick",shaka.ads.MediaTailorAd.prototype.hasCustomClick);
goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"isClientRendering",shaka.ads.MediaTailorAd.prototype.isClientRendering);goog.exportProperty(shaka.ads.MediaTailorAd.prototype,"needsSkipUI",shaka.ads.MediaTailorAd.prototype.needsSkipUI);shaka.ads.MediaTailorAdManager=function(a,b,c,d){this.adContainer_=a;this.networkingEngine_=b;this.video_=c;this.streamPromise_=null;this.streamRequestStartTime_=NaN;this.onEvent_=d;this.isLive_=!1;this.snapForwardTime_=null;this.adBreaks_=[];this.playedAds_=[];this.mediaTailorAdBreak_=this.mediaTailorAd_=this.ad_=null;this.staticResources_=new Map;this.adListeners_=[];this.eventsSent=[];this.trackingUrl_="";this.firstTrackingRequest_=!0;this.backupUrl_="";this.currentCuePoints_=[];this.eventManager_=
new shaka.util.EventManager};shaka.ads.MediaTailorAdManager.prototype.streamRequest=function(a,b,c){if(this.streamPromise_)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.CURRENT_DAI_REQUEST_NOT_FINISHED));this.streamPromise_=new shaka.util.PublicPromise;this.requestSessionInfo_(a,b);this.backupUrl_=c||"";this.streamRequestStartTime_=Date.now()/1E3;return this.streamPromise_};
shaka.ads.MediaTailorAdManager.prototype.addTrackingUrl=function(a){this.trackingUrl_=a;this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.ADS_LOADED,(new Map).set("loadTime",0)))};
shaka.ads.MediaTailorAdManager.prototype.stop=function(){for(var a=(0,$jscomp.makeIterator)(this.adListeners_),b=a.next();!b.done;b=a.next())b=b.value,this.eventManager_.unlisten(b.target,b.type,b.listener);this.onEnded_();this.adListeners_=[];this.eventsSent=[];this.trackingUrl_="";this.firstTrackingRequest_=!0;this.backupUrl_="";this.snapForwardTime_=null;this.adBreaks_=[];this.playedAds_=[];this.staticResources_.clear()};
shaka.ads.MediaTailorAdManager.prototype.release=function(){this.stop();this.eventManager_&&this.eventManager_.release()};shaka.ads.MediaTailorAdManager.prototype.onManifestUpdated=function(a){this.isLive_=a;this.trackingUrl_!=""&&(this.requestTrackingInfo_(this.trackingUrl_,this.firstTrackingRequest_),this.firstTrackingRequest_=!1)};
shaka.ads.MediaTailorAdManager.prototype.getCuePoints=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.adBreaks_),c=b.next();!c.done;c=b.next()){c=(0,$jscomp.makeIterator)(c.value.ads);for(var d=c.next();!d.done;d=c.next())d=d.value,a.push({start:d.startTimeInSeconds,end:d.startTimeInSeconds+d.durationInSeconds})}return a};
shaka.ads.MediaTailorAdManager.prototype.requestSessionInfo_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(w){if(w.getNextAddressJsc()==1)return d=shaka.net.NetworkingEngine,e=d.RequestType.ADS,f={type:d.AdvancedRequestType.MEDIATAILOR_SESSION_INFO},g=d.makeRequest([a],d.defaultRetryParameters()),g.method="POST",b&&(h=JSON.stringify(b),g.body=shaka.util.StringUtils.toUTF8(h)),k=c.networkingEngine_.request(e,g,f),w.setCatchFinallyBlocks(2),
w.yield(k.promise,4);if(w.getNextAddressJsc()!=2){l=w.getYieldResultJsc();m=shaka.util.StringUtils.fromUTF8(l.data);n=JSON.parse(m);if(n.manifestUrl&&n.trackingUrl)p=new goog.Uri(a),q=new goog.Uri(n.trackingUrl),c.trackingUrl_=p.resolve(q).toString(),r=Date.now()/1E3,t=r-c.streamRequestStartTime_,c.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.ADS_LOADED,(new Map).set("loadTime",t))),u=new goog.Uri(n.manifestUrl),c.streamPromise_.resolve(p.resolve(u).toString()),c.streamPromise_=null;else throw Error("Insufficient data from MediaTailor.");
return w.leaveTryBlock(0)}w.enterCatchBlock();if(!c.backupUrl_.length)return c.streamPromise_.reject("MediaTailor request returned an error and there was no backup asset uri provided."),c.streamPromise_=null,w.return();shaka.log.warning("MediaTailor request returned an error. Falling back to the backup asset uri.");c.streamPromise_.resolve(c.backupUrl_);c.streamPromise_=null;w.jumpToEnd()})};
shaka.ads.MediaTailorAdManager.prototype.requestTrackingInfo_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){if(A.getNextAddressJsc()==1)return d=shaka.net.NetworkingEngine,e=d.RequestType.ADS,f={type:d.AdvancedRequestType.MEDIATAILOR_TRACKING_INFO},g=d.makeRequest([a],d.defaultRetryParameters()),h=c.networkingEngine_.request(e,g,f),A.setCatchFinallyBlocks(2),A.yield(h.promise,4);if(A.getNextAddressJsc()!=2){k=A.getYieldResultJsc();
l=[];m=shaka.util.StringUtils.fromUTF8(k.data);n=JSON.parse(m);if(n.avails.length>0){if(JSON.stringify(c.adBreaks_)!=JSON.stringify(n.avails)){c.adBreaks_=n.avails;p=(0,$jscomp.makeIterator)(c.adBreaks_);for(q=p.next();!q.done;q=p.next())for(r=q.value,t=(0,$jscomp.makeIterator)(r.nonLinearAdsList),u=t.next();!u.done;u=t.next())for(w=u.value,v=(0,$jscomp.makeIterator)(w.nonLinearAdList),x=v.next();!x.done;x=v.next())y=x.value,c.requestStaticResource_(y);l=c.getCuePoints();c.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.CUEPOINTS_CHANGED,
(new Map).set("cuepoints",l)))}}else{if(c.adBreaks_.length)c.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.CUEPOINTS_CHANGED,(new Map).set("cuepoints",l)));c.onEnded_();c.adBreaks_=[]}b&&(c.isLive_||l.length>0)&&c.setupAdBreakListeners_();return A.leaveTryBlock(0)}A.enterCatchBlock();A.jumpToEnd()})};
shaka.ads.MediaTailorAdManager.prototype.requestStaticResource_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1){if(!a.staticResource)return q.return();c=b.getCacheKeyForNonLinear_(a);if(d=b.staticResources_.get(c))return q.return();e=shaka.net.NetworkingEngine;f=e.RequestType.ADS;g={type:e.AdvancedRequestType.MEDIATAILOR_STATIC_RESOURCE};h=e.makeRequest([a.staticResource],e.defaultRetryParameters());k=b.networkingEngine_.request(f,
h,g);q.setCatchFinallyBlocks(2);b.staticResources_.set(c,[]);return q.yield(k.promise,4)}if(q.getNextAddressJsc()!=2)return l=q.getYieldResultJsc(),m=shaka.util.StringUtils.fromUTF8(l.data),n=JSON.parse(m),p=n.apps,b.staticResources_.set(c,p),q.leaveTryBlock(0);q.enterCatchBlock();b.staticResources_.delete(c);q.jumpToEnd()})};
shaka.ads.MediaTailorAdManager.prototype.getCacheKeyForNonLinear_=function(a){return[a.adId,a.adParameters,a.adSystem,a.adTitle,a.creativeAdId,a.creativeId,a.creativeSequence,a.height,a.width,a.staticResource].join("")};
shaka.ads.MediaTailorAdManager.prototype.setupAdBreakListeners_=function(){var a=this;this.onTimeupdate_();this.isLive_||(this.checkForSnapback_(),this.eventManager_.listen(this.video_,"seeked",function(){a.checkForSnapback_()}),this.eventManager_.listen(this.video_,"ended",function(){a.onEnded_()}));this.eventManager_.listen(this.video_,"timeupdate",function(){a.onTimeupdate_()})};
shaka.ads.MediaTailorAdManager.prototype.checkForSnapback_=function(){var a=this.video_.currentTime;if(a!=0&&this.snapForwardTime_==null){for(var b,c,d=(0,$jscomp.makeIterator)(this.adBreaks_),e=d.next();!e.done;e=d.next()){e=e.value;for(var f=(0,$jscomp.makeIterator)(e.ads),g=f.next();!g.done;g=f.next())if(g=g.value,!c)g.startTimeInSeconds<a&&(c=g,b=e);else if(g.startTimeInSeconds<a&&g.startTimeInSeconds>c.startTimeInSeconds+c.durationInSeconds){c=g;b=e;break}}b&&c&&!this.playedAds_.includes(c.adId)&&
(shaka.log.info("Seeking back to the start of the ad break at "+b.startTimeInSeconds+" and will return to "+a),this.snapForwardTime_=a,this.video_.currentTime=b.startTimeInSeconds)}};shaka.ads.MediaTailorAdManager.prototype.onAdBreakEnded_=function(){var a=this.video_.currentTime;this.snapForwardTime_&&this.snapForwardTime_>a&&(this.video_.currentTime=this.snapForwardTime_);this.snapForwardTime_=null};
shaka.ads.MediaTailorAdManager.prototype.onTimeupdate_=function(){if(this.video_.duration&&(this.ad_||this.adBreaks_.length)){var a=this.video_.currentTime,b=!1;if(this.ad_){b=!0;goog.asserts.assert(this.mediaTailorAd_,"Ad should be defined");this.sendInProgressEvents_(a,this.mediaTailorAd_);var c=this.ad_.getRemainingTime(),d=this.ad_.getDuration();this.ad_.canSkipNow()&&c>0&&d>0&&this.sendTrackingEvent_(shaka.ads.MediaTailorAdManager.SKIP_STATE_CHANGED_);if(d>0&&(c<=0||c>d))this.onEnded_()}if(!this.ad_||
!this.ad_.isLinear())if(this.checkLinearAds_(a),this.ad_||this.checkNonLinearAds_(a),b&&!this.ad_)this.onAdBreakEnded_()}};
shaka.ads.MediaTailorAdManager.prototype.sendInProgressEvents_=function(a,b){var c=shaka.ads.MediaTailorAdManager,d=b.startTimeInSeconds+.5*b.durationInSeconds,e=b.startTimeInSeconds+.75*b.durationInSeconds;a>=b.startTimeInSeconds+.25*b.durationInSeconds&&!this.eventsSent.includes(c.FIRSTQUARTILE_)?(this.eventsSent.push(c.FIRSTQUARTILE_),this.sendTrackingEvent_(c.FIRSTQUARTILE_)):a>=d&&!this.eventsSent.includes(c.MIDPOINT_)?(this.eventsSent.push(c.MIDPOINT_),this.sendTrackingEvent_(c.MIDPOINT_)):
a>=e&&!this.eventsSent.includes(c.THIRDQUARTILE_)&&(this.eventsSent.push(c.THIRDQUARTILE_),this.sendTrackingEvent_(c.THIRDQUARTILE_))};
shaka.ads.MediaTailorAdManager.prototype.checkLinearAds_=function(a){for(var b=shaka.ads.MediaTailorAdManager,c=(0,$jscomp.makeIterator)(this.adBreaks_),d=c.next();!d.done;d=c.next()){d=d.value;if(this.ad_&&this.ad_.isLinear())break;for(var e=0;e<d.ads.length;e++){var f=d.ads[e],g=f.startTimeInSeconds+f.durationInSeconds;if(f.startTimeInSeconds<=a&&g>a){if(this.playedAds_.includes(f.adId)){if(this.video_.ended)continue;this.video_.currentTime=g;return}this.onEnded_();this.mediaTailorAdBreak_=d;this.ad_=
new shaka.ads.MediaTailorAd(f,e+1,d.ads.length,!0,this.video_);this.mediaTailorAd_=f;e===0&&this.sendTrackingEvent_(b.BREAK_START_);this.setupCurrentAdListeners_();break}}}};
shaka.ads.MediaTailorAdManager.prototype.checkNonLinearAds_=function(a){for(var b=shaka.ads.MediaTailorAdManager,c=(0,$jscomp.makeIterator)(this.adBreaks_),d=c.next();!d.done;d=c.next()){d=d.value;if(this.ad_)break;for(var e=0;e<d.nonLinearAdsList.length;e++){var f=d.nonLinearAdsList[e];if(f.nonLinearAdList.length){var g=d.startTimeInSeconds,h=this.getCacheKeyForNonLinear_(f.nonLinearAdList[0]);h=this.staticResources_.get(h);if(g<=a&&h&&h.length){this.onEnded_();this.displayNonLinearAd_(h);this.mediaTailorAdBreak_=
d;this.ad_=new shaka.ads.MediaTailorAd(f,e+1,d.ads.length,!1,this.video_);this.mediaTailorAd_=f;e===0&&this.sendTrackingEvent_(b.BREAK_START_);this.setupCurrentAdListeners_();break}}}}};
shaka.ads.MediaTailorAdManager.prototype.displayNonLinearAd_=function(a){a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value,b.data.source.length){var c=document.createElement("img");c.src=b.data.source[0].url;c.style.top=(b.placeholder.top||0)+"%";c.style.height=100-(b.placeholder.top||0)+"%";c.style.left=(b.placeholder.left||0)+"%";c.style.maxWidth=100-(b.placeholder.left||0)+"%";c.style.objectFit="contain";c.style.position="absolute";this.adContainer_.appendChild(c)}};
shaka.ads.MediaTailorAdManager.prototype.onEnded_=function(){if(this.ad_){for(;this.adContainer_.lastChild;)this.adContainer_.removeChild(this.adContainer_.firstChild);this.isLive_||this.playedAds_.push(this.mediaTailorAd_.adId);this.removeCurrentAdListeners_(this.ad_.isSkipped());var a=this.ad_.getPositionInSequence(),b=this.ad_.getSequenceLength();a===b&&this.sendTrackingEvent_(shaka.ads.MediaTailorAdManager.BREAK_END_);this.mediaTailorAdBreak_=this.mediaTailorAd_=this.ad_=null}};
shaka.ads.MediaTailorAdManager.prototype.setupCurrentAdListeners_=function(){var a=this,b=shaka.ads.MediaTailorAdManager,c=!1;this.video_.paused?c=!0:(this.sendTrackingEvent_(b.IMPRESSION_),this.sendTrackingEvent_(b.START_));this.adListeners_.push({target:this.video_,type:"volumechange",listener:function(){a.video_.muted&&a.sendTrackingEvent_(b.MUTE_)}});this.adListeners_.push({target:this.video_,type:"volumechange",listener:function(){a.video_.muted||a.sendTrackingEvent_(b.UNMUTE_)}});this.adListeners_.push({target:this.video_,
type:"play",listener:function(){c?(a.sendTrackingEvent_(b.IMPRESSION_),a.sendTrackingEvent_(b.START_),c=!1):a.sendTrackingEvent_(b.RESUME_)}});this.adListeners_.push({target:this.video_,type:"pause",listener:function(){a.sendTrackingEvent_(b.PAUSE_)}});for(var d=(0,$jscomp.makeIterator)(this.adListeners_),e=d.next();!e.done;e=d.next())e=e.value,this.eventManager_.listen(e.target,e.type,e.listener)};
shaka.ads.MediaTailorAdManager.prototype.removeCurrentAdListeners_=function(a){(a===void 0?0:a)?this.sendTrackingEvent_(shaka.ads.MediaTailorAdManager.SKIPPED_):this.sendTrackingEvent_(shaka.ads.MediaTailorAdManager.COMPLETE_);a=(0,$jscomp.makeIterator)(this.adListeners_);for(var b=a.next();!b.done;b=a.next())b=b.value,this.eventManager_.unlisten(b.target,b.type,b.listener);this.adListeners_=[];this.eventsSent=[]};
shaka.ads.MediaTailorAdManager.prototype.sendTrackingEvent_=function(a){var b=this.mediaTailorAd_.trackingEvents.find(function(g){return g.eventType==a});b||(b=this.mediaTailorAdBreak_.adBreakTrackingEvents.find(function(g){return g.eventType==a}));if(b){var c=shaka.net.NetworkingEngine,d=c.RequestType.ADS,e={type:c.AdvancedRequestType.MEDIATAILOR_TRACKING_EVENT};b=(0,$jscomp.makeIterator)(b.beaconUrls);for(var f=b.next();!f.done;f=b.next())(f=f.value)&&f!=""&&(f=c.makeRequest([f],c.defaultRetryParameters()),
f.method="POST",this.networkingEngine_.request(d,f,e))}switch(a){case shaka.ads.MediaTailorAdManager.IMPRESSION_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_IMPRESSION));break;case shaka.ads.MediaTailorAdManager.START_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STARTED,(new Map).set("ad",this.ad_)));break;case shaka.ads.MediaTailorAdManager.MUTE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_MUTED));break;case shaka.ads.MediaTailorAdManager.UNMUTE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_VOLUME_CHANGED));
break;case shaka.ads.MediaTailorAdManager.RESUME_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_RESUMED));break;case shaka.ads.MediaTailorAdManager.PAUSE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_PAUSED));break;case shaka.ads.MediaTailorAdManager.FIRSTQUARTILE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_FIRST_QUARTILE));break;case shaka.ads.MediaTailorAdManager.MIDPOINT_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_MIDPOINT));break;case shaka.ads.MediaTailorAdManager.THIRDQUARTILE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_THIRD_QUARTILE));
break;case shaka.ads.MediaTailorAdManager.COMPLETE_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_COMPLETE));this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED));break;case shaka.ads.MediaTailorAdManager.SKIPPED_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_SKIPPED));this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED));break;case shaka.ads.MediaTailorAdManager.BREAK_START_:this.adContainer_.setAttribute("ad-active","true");break;case shaka.ads.MediaTailorAdManager.BREAK_END_:this.adContainer_.removeAttribute("ad-active");
break;case shaka.ads.MediaTailorAdManager.SKIP_STATE_CHANGED_:this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_SKIP_STATE_CHANGED))}};shaka.ads.MediaTailorAdManager.IMPRESSION_="impression";shaka.ads.MediaTailorAdManager.START_="start";shaka.ads.MediaTailorAdManager.MUTE_="mute";shaka.ads.MediaTailorAdManager.UNMUTE_="unmute";shaka.ads.MediaTailorAdManager.RESUME_="resume";shaka.ads.MediaTailorAdManager.PAUSE_="pause";shaka.ads.MediaTailorAdManager.FIRSTQUARTILE_="firstQuartile";
shaka.ads.MediaTailorAdManager.MIDPOINT_="midpoint";shaka.ads.MediaTailorAdManager.THIRDQUARTILE_="thirdQuartile";shaka.ads.MediaTailorAdManager.COMPLETE_="complete";shaka.ads.MediaTailorAdManager.SKIPPED_="skip";shaka.ads.MediaTailorAdManager.BREAK_START_="breakStart";shaka.ads.MediaTailorAdManager.BREAK_END_="breakEnd";shaka.ads.MediaTailorAdManager.SKIP_STATE_CHANGED_="skipStateChanged";shaka.ads.ServerSideAd=function(a,b){this.ad_=a;this.adProgressData_=null;this.video_=b};shaka.ads.ServerSideAd.prototype.setProgressData=function(a){this.adProgressData_=a};shaka.ads.ServerSideAd.prototype.needsSkipUI=function(){return!0};shaka.ads.ServerSideAd.prototype.isClientRendering=function(){return!1};shaka.ads.ServerSideAd.prototype.hasCustomClick=function(){return!0};shaka.ads.ServerSideAd.prototype.isUsingAnotherMediaElement=function(){return!1};
shaka.ads.ServerSideAd.prototype.getDuration=function(){return this.adProgressData_?this.adProgressData_.duration:-1};shaka.ads.ServerSideAd.prototype.getMinSuggestedDuration=function(){return this.getDuration()};shaka.ads.ServerSideAd.prototype.getRemainingTime=function(){return this.adProgressData_?this.adProgressData_.duration-this.adProgressData_.currentTime:-1};shaka.ads.ServerSideAd.prototype.isPaused=function(){return this.video_.paused};shaka.ads.ServerSideAd.prototype.isSkippable=function(){return this.ad_.isSkippable()};
shaka.ads.ServerSideAd.prototype.getTimeUntilSkippable=function(){var a=this.ad_.getSkipTimeOffset();a=this.getRemainingTime()-a;return Math.max(a,0)};shaka.ads.ServerSideAd.prototype.canSkipNow=function(){return this.getTimeUntilSkippable()==0};shaka.ads.ServerSideAd.prototype.skip=function(){this.video_.currentTime+=this.getRemainingTime()};shaka.ads.ServerSideAd.prototype.pause=function(){return this.video_.pause()};shaka.ads.ServerSideAd.prototype.play=function(){return this.video_.play()};
shaka.ads.ServerSideAd.prototype.getVolume=function(){return this.video_.volume};shaka.ads.ServerSideAd.prototype.setVolume=function(a){this.video_.volume=a};shaka.ads.ServerSideAd.prototype.isMuted=function(){return this.video_.muted};shaka.ads.ServerSideAd.prototype.isLinear=function(){return!0};shaka.ads.ServerSideAd.prototype.resize=function(a,b){};shaka.ads.ServerSideAd.prototype.setMuted=function(a){this.video_.muted=a};
shaka.ads.ServerSideAd.prototype.getSequenceLength=function(){var a=this.ad_.getAdPodInfo();return a==null?1:a.getTotalAds()};shaka.ads.ServerSideAd.prototype.getPositionInSequence=function(){var a=this.ad_.getAdPodInfo();return a==null?1:a.getAdPosition()};shaka.ads.ServerSideAd.prototype.getTitle=function(){return this.ad_.getTitle()};shaka.ads.ServerSideAd.prototype.getDescription=function(){return this.ad_.getDescription()};shaka.ads.ServerSideAd.prototype.getVastMediaBitrate=function(){return 0};
shaka.ads.ServerSideAd.prototype.getVastMediaHeight=function(){return this.ad_.getVastMediaHeight()};shaka.ads.ServerSideAd.prototype.getVastMediaWidth=function(){return this.ad_.getVastMediaWidth()};shaka.ads.ServerSideAd.prototype.getVastAdId=function(){return""};shaka.ads.ServerSideAd.prototype.getAdId=function(){return this.ad_.getAdId()};shaka.ads.ServerSideAd.prototype.getCreativeAdId=function(){return this.ad_.getCreativeAdId()};shaka.ads.ServerSideAd.prototype.getAdvertiserName=function(){return this.ad_.getAdvertiserName()};
shaka.ads.ServerSideAd.prototype.getMediaUrl=function(){return null};shaka.ads.ServerSideAd.prototype.getTimeOffset=function(){var a=this.ad_.getAdPodInfo();return a==null?0:a.getTimeOffset()};shaka.ads.ServerSideAd.prototype.getPodIndex=function(){var a=this.ad_.getAdPodInfo();return a==null?0:a.getPodIndex()};shaka.ads.ServerSideAd.prototype.release=function(){this.video_=this.adProgressData_=this.ad_=null};goog.exportSymbol("shaka.ads.ServerSideAd",shaka.ads.ServerSideAd);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"release",shaka.ads.ServerSideAd.prototype.release);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getPodIndex",shaka.ads.ServerSideAd.prototype.getPodIndex);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getTimeOffset",shaka.ads.ServerSideAd.prototype.getTimeOffset);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getMediaUrl",shaka.ads.ServerSideAd.prototype.getMediaUrl);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getAdvertiserName",shaka.ads.ServerSideAd.prototype.getAdvertiserName);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getCreativeAdId",shaka.ads.ServerSideAd.prototype.getCreativeAdId);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getAdId",shaka.ads.ServerSideAd.prototype.getAdId);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getVastAdId",shaka.ads.ServerSideAd.prototype.getVastAdId);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getVastMediaWidth",shaka.ads.ServerSideAd.prototype.getVastMediaWidth);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getVastMediaHeight",shaka.ads.ServerSideAd.prototype.getVastMediaHeight);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getVastMediaBitrate",shaka.ads.ServerSideAd.prototype.getVastMediaBitrate);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getDescription",shaka.ads.ServerSideAd.prototype.getDescription);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getTitle",shaka.ads.ServerSideAd.prototype.getTitle);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getPositionInSequence",shaka.ads.ServerSideAd.prototype.getPositionInSequence);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getSequenceLength",shaka.ads.ServerSideAd.prototype.getSequenceLength);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"setMuted",shaka.ads.ServerSideAd.prototype.setMuted);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"resize",shaka.ads.ServerSideAd.prototype.resize);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isLinear",shaka.ads.ServerSideAd.prototype.isLinear);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isMuted",shaka.ads.ServerSideAd.prototype.isMuted);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"setVolume",shaka.ads.ServerSideAd.prototype.setVolume);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getVolume",shaka.ads.ServerSideAd.prototype.getVolume);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"play",shaka.ads.ServerSideAd.prototype.play);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"pause",shaka.ads.ServerSideAd.prototype.pause);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"skip",shaka.ads.ServerSideAd.prototype.skip);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"canSkipNow",shaka.ads.ServerSideAd.prototype.canSkipNow);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getTimeUntilSkippable",shaka.ads.ServerSideAd.prototype.getTimeUntilSkippable);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isSkippable",shaka.ads.ServerSideAd.prototype.isSkippable);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isPaused",shaka.ads.ServerSideAd.prototype.isPaused);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getRemainingTime",shaka.ads.ServerSideAd.prototype.getRemainingTime);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getMinSuggestedDuration",shaka.ads.ServerSideAd.prototype.getMinSuggestedDuration);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"getDuration",shaka.ads.ServerSideAd.prototype.getDuration);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isUsingAnotherMediaElement",shaka.ads.ServerSideAd.prototype.isUsingAnotherMediaElement);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"hasCustomClick",shaka.ads.ServerSideAd.prototype.hasCustomClick);goog.exportProperty(shaka.ads.ServerSideAd.prototype,"isClientRendering",shaka.ads.ServerSideAd.prototype.isClientRendering);
goog.exportProperty(shaka.ads.ServerSideAd.prototype,"needsSkipUI",shaka.ads.ServerSideAd.prototype.needsSkipUI);shaka.ads.ServerSideAdManager=function(a,b,c,d){var e=this;this.adContainer_=a;this.video_=b;this.streamPromise_=this.config_=null;this.streamRequestStartTime_=NaN;this.onEvent_=d;this.isLiveContent_=!1;this.adProgressData_=this.ad_=this.snapForwardTime_=null;this.backupUrl_="";this.currentCuePoints_=[];this.eventManager_=new shaka.util.EventManager;a=new google.ima.dai.api.UiSettings;a.setLocale(c);this.streamManager_=new google.ima.dai.api.StreamManager(this.video_,this.adContainer_,a);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.IMA_STREAM_MANAGER_LOADED,
(new Map).set("imaStreamManager",this.streamManager_)));this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.LOADED,function(f){shaka.log.info("Ad SS Loaded");e.onLoaded_(f)});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.ERROR,function(){shaka.log.info("Ad SS Error");e.onError_()});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,function(){shaka.log.info("Ad Break Started")});this.eventManager_.listen(this.streamManager_,
google.ima.dai.api.StreamEvent.Type.STARTED,function(f){shaka.log.info("Ad Started");e.onAdStart_(f)});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED,function(){shaka.log.info("Ad Break Ended");e.onAdBreakEnded_()});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.AD_PROGRESS,function(f){e.onAdProgress_(f)});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.FIRST_QUARTILE,function(){shaka.log.info("Ad event: First Quartile");
e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_FIRST_QUARTILE))});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.MIDPOINT,function(){shaka.log.info("Ad event: Midpoint");e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_MIDPOINT))});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.THIRD_QUARTILE,function(){shaka.log.info("Ad event: Third Quartile");e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_THIRD_QUARTILE))});
this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.COMPLETE,function(){shaka.log.info("Ad event: Complete");e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_COMPLETE));e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED));e.adContainer_.removeAttribute("ad-active");e.ad_=null});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.SKIPPED,function(){shaka.log.info("Ad event: Skipped");e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_SKIPPED));
e.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED))});this.eventManager_.listen(this.streamManager_,google.ima.dai.api.StreamEvent.Type.CUEPOINTS_CHANGED,function(f){shaka.log.info("Ad event: Cue points changed");e.onCuePointsChanged_(f)})};shaka.ads.ServerSideAdManager.prototype.configure=function(a){this.config_=a};
shaka.ads.ServerSideAdManager.prototype.streamRequest=function(a,b){if(this.streamPromise_)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.CURRENT_DAI_REQUEST_NOT_FINISHED));a instanceof google.ima.dai.api.LiveStreamRequest&&(this.isLiveContent_=!0);this.streamPromise_=new shaka.util.PublicPromise;this.streamManager_.requestStream(a);this.backupUrl_=b||"";this.streamRequestStartTime_=Date.now()/1E3;return this.streamPromise_};
shaka.ads.ServerSideAdManager.prototype.replaceAdTagParameters=function(a){this.streamManager_.replaceAdTagParameters(a)};shaka.ads.ServerSideAdManager.prototype.stop=function(){this.backupUrl_="";this.snapForwardTime_=null;this.currentCuePoints_=[]};shaka.ads.ServerSideAdManager.prototype.release=function(){this.stop();this.eventManager_&&this.eventManager_.release()};shaka.ads.ServerSideAdManager.prototype.onTimedMetadata=function(a,b,c){this.streamManager_.processMetadata(a,b,c)};
shaka.ads.ServerSideAdManager.prototype.onCueMetadataChange=function(a){if(a.key&&a.data){var b={};b[a.key]=a.data;this.streamManager_.onTimedMetadata(b)}};shaka.ads.ServerSideAdManager.prototype.getCuePoints=function(){return this.currentCuePoints_};
shaka.ads.ServerSideAdManager.prototype.checkForSnapback_=function(){var a=this.video_.currentTime;if(a!=0){this.streamManager_.streamTimeForContentTime(a);var b=this.streamManager_.previousCuePointForStreamTime(a);b&&!b.played&&(shaka.log.info("Seeking back to the start of the ad break at "+b.start+" and will return to "+a),this.snapForwardTime_=a,this.video_.currentTime=b.start)}};
shaka.ads.ServerSideAdManager.prototype.onAdStart_=function(a){goog.asserts.assert(this.streamManager_,"Should have a stream manager at this point!");a=a.getAd();this.ad_=new shaka.ads.ServerSideAd(a,this.video_);this.adProgressData_&&this.ad_.setProgressData(this.adProgressData_);this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STARTED,(new Map).set("ad",this.ad_)));this.adContainer_.setAttribute("ad-active","true")};
shaka.ads.ServerSideAdManager.prototype.onAdBreakEnded_=function(){this.adContainer_.removeAttribute("ad-active");var a=this.video_.currentTime;this.snapForwardTime_&&this.snapForwardTime_>a&&(this.video_.currentTime=this.snapForwardTime_,this.snapForwardTime_=null)};
shaka.ads.ServerSideAdManager.prototype.onLoaded_=function(a){var b=this,c=Date.now()/1E3-this.streamRequestStartTime_;this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.ADS_LOADED,(new Map).set("loadTime",c)));a=a.getStreamData().url;this.streamPromise_.resolve(a);this.streamPromise_=null;this.isLiveContent_||this.eventManager_.listen(this.video_,"seeked",function(){b.checkForSnapback_()})};
shaka.ads.ServerSideAdManager.prototype.onError_=function(){this.backupUrl_.length?(shaka.log.warning("IMA stream request returned an error. Falling back to the backup asset uri."),this.streamPromise_.resolve(this.backupUrl_)):this.streamPromise_.reject("IMA Stream request returned an error and there was no backup asset uri provided.");this.streamPromise_=null};shaka.ads.ServerSideAdManager.prototype.onAdProgress_=function(a){this.adProgressData_=a.getStreamData().adProgressData;this.ad_&&this.ad_.setProgressData(this.adProgressData_)};
shaka.ads.ServerSideAdManager.prototype.onCuePointsChanged_=function(a){var b=a.getStreamData();a=[];b=(0,$jscomp.makeIterator)(b.cuepoints);for(var c=b.next();!c.done;c=b.next())c=c.value,a.push({start:c.start,end:c.end});this.currentCuePoints_=a;this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.CUEPOINTS_CHANGED,(new Map).set("cuepoints",a)))};shaka.ads.AdManager=function(){shaka.util.FakeEventTarget.call(this);this.ssAdManager_=this.mtAdManager_=this.csAdManager_=this.interstitialAdManager_=null;this.stats_=new shaka.ads.AdsStats;this.locale_=navigator.language;this.config_=null};$jscomp.inherits(shaka.ads.AdManager,shaka.util.FakeEventTarget);shaka.ads.AdManager.prototype.setLocale=function(a){this.locale_=a};
shaka.ads.AdManager.prototype.configure=function(a){this.config_=a;this.interstitialAdManager_&&this.interstitialAdManager_.configure(this.config_);this.csAdManager_&&this.csAdManager_.configure(this.config_);this.ssAdManager_&&this.ssAdManager_.configure(this.config_)};
shaka.ads.AdManager.prototype.initInterstitial=function(a,b,c){var d=this;a||shaka.log.info("Initializing interstitials without ad container");this.interstitialAdManager_&&this.interstitialAdManager_.release();this.interstitialAdManager_=new shaka.ads.InterstitialAdManager(a,b,c,function(e){return d.processAndDispatchEvent_(e)});goog.asserts.assert(this.config_,"Config must not be null!");this.interstitialAdManager_.configure(this.config_)};
shaka.ads.AdManager.prototype.initClientSide=function(a,b,c){var d=this;if(!window.google||!google.ima||!google.ima.AdsLoader)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.ADS,shaka.util.Error.Code.CS_IMA_SDK_MISSING);this.csAdManager_&&this.csAdManager_.release();this.csAdManager_=new shaka.ads.ClientSideAdManager(a,b,this.locale_,c,function(e){return d.processAndDispatchEvent_(e)});goog.asserts.assert(this.config_,"Config must not be null!");this.csAdManager_.configure(this.config_)};
shaka.ads.AdManager.prototype.release=function(){this.interstitialAdManager_&&(this.interstitialAdManager_.release(),this.interstitialAdManager_=null);this.csAdManager_&&(this.csAdManager_.release(),this.csAdManager_=null);this.mtAdManager_&&(this.mtAdManager_.release(),this.mtAdManager_=null);this.ssAdManager_&&(this.ssAdManager_.release(),this.ssAdManager_=null);shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.ads.AdManager.prototype.onAssetUnload=function(){this.interstitialAdManager_&&this.interstitialAdManager_.stop();this.csAdManager_&&this.csAdManager_.stop();this.mtAdManager_&&this.mtAdManager_.stop();this.ssAdManager_&&this.ssAdManager_.stop();this.dispatchEvent(new shaka.util.FakeEvent(shaka.ads.Utils.AD_STOPPED));this.dispatchEvent(new shaka.util.FakeEvent(shaka.ads.Utils.AD_CONTENT_ATTACH_REQUESTED));this.stats_=new shaka.ads.AdsStats};
shaka.ads.AdManager.prototype.requestClientSideAds=function(a){if(!this.csAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.CS_AD_MANAGER_NOT_INITIALIZED);this.csAdManager_.requestAds(a)};
shaka.ads.AdManager.prototype.updateClientSideAdsRenderingSettings=function(a){if(!this.csAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.CS_AD_MANAGER_NOT_INITIALIZED);this.csAdManager_.updateAdsRenderingSettings(a)};shaka.ads.AdManager.prototype.initMediaTailor=function(a,b,c){var d=this;this.mtAdManager_&&this.mtAdManager_.release();this.mtAdManager_=new shaka.ads.MediaTailorAdManager(a,b,c,function(e){return d.processAndDispatchEvent_(e)})};
shaka.ads.AdManager.prototype.requestMediaTailorStream=function(a,b,c){c=c===void 0?"":c;if(!this.mtAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.MT_AD_MANAGER_NOT_INITIALIZED);return this.mtAdManager_.streamRequest(a,b,c)};
shaka.ads.AdManager.prototype.addMediaTailorTrackingUrl=function(a){if(!this.mtAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.MT_AD_MANAGER_NOT_INITIALIZED);this.mtAdManager_.addTrackingUrl(a)};
shaka.ads.AdManager.prototype.initServerSide=function(a,b){var c=this;if(!window.google||!google.ima||!google.ima.dai)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.ADS,shaka.util.Error.Code.SS_IMA_SDK_MISSING);this.ssAdManager_&&this.ssAdManager_.release();this.ssAdManager_=new shaka.ads.ServerSideAdManager(a,b,this.locale_,function(d){return c.processAndDispatchEvent_(d)});goog.asserts.assert(this.config_,"Config must not be null!");this.ssAdManager_.configure(this.config_)};
shaka.ads.AdManager.prototype.requestServerSideStream=function(a,b){b=b===void 0?"":b;if(!this.ssAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.SS_AD_MANAGER_NOT_INITIALIZED);a.adTagParameters||(a.adTagParameters={});var c=a.adTagParameters;(c.mpt||c.mpv)&&shaka.log.alwaysWarn('You have attempted to set "mpt" and/or "mpv" parameters of the ad tag. Please note that those parameters are used for Shaka adoption tracking and will be overridden.');
a.adTagParameters.mpt="shaka-player";a.adTagParameters.mpv=shaka.Player.version;return this.ssAdManager_.streamRequest(a,b)};
shaka.ads.AdManager.prototype.replaceServerSideAdTagParameters=function(a){if(!this.ssAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.SS_AD_MANAGER_NOT_INITIALIZED);(a.mpt||a.mpv)&&shaka.log.alwaysWarn('You have attempted to set "mpt" and/or "mpv" parameters of the ad tag. Please note that those parameters are used for Shaka adoption tracking and will be overridden.');a.mpt="Shaka Player";a.mpv=shaka.Player.version;this.ssAdManager_.replaceAdTagParameters(a)};
shaka.ads.AdManager.prototype.getServerSideCuePoints=function(){shaka.Deprecate.deprecateFeature(5,"AdManager.getServerSideCuePoints","Please use getCuePoints function.");return this.getCuePoints()};shaka.ads.AdManager.prototype.getCuePoints=function(){var a=[];this.ssAdManager_&&(a=a.concat(this.ssAdManager_.getCuePoints()));this.mtAdManager_&&(a=a.concat(this.mtAdManager_.getCuePoints()));return a};shaka.ads.AdManager.prototype.getStats=function(){return this.stats_.getBlob()};
shaka.ads.AdManager.prototype.onManifestUpdated=function(a){if(this.mtAdManager_)this.mtAdManager_.onManifestUpdated(a)};shaka.ads.AdManager.prototype.onDashTimedMetadata=function(a){if(this.ssAdManager_&&a.schemeIdUri=="urn:google:dai:2018")this.ssAdManager_.onTimedMetadata(a.schemeIdUri,a.eventNode?a.eventNode.attributes.messageData:null,a.startTime)};shaka.ads.AdManager.prototype.onHlsTimedMetadata=function(a,b){if(this.ssAdManager_)this.ssAdManager_.onTimedMetadata("ID3",a.data,b)};
shaka.ads.AdManager.prototype.onCueMetadataChange=function(a){if(this.ssAdManager_)this.ssAdManager_.onCueMetadataChange(a)};shaka.ads.AdManager.prototype.onHLSInterstitialMetadata=function(a,b,c){this.config_&&this.config_.disableHLSInterstitial||(this.interstitialAdManager_||this.initInterstitial(null,a,b),this.interstitialAdManager_&&this.interstitialAdManager_.addMetadata(c))};
shaka.ads.AdManager.prototype.onDASHInterstitialMetadata=function(a,b,c){if(!this.config_||!this.config_.disableDASHInterstitial){var d=c.schemeIdUri;d=="urn:mpeg:dash:event:alternativeMPD:insert:2025"||d=="urn:mpeg:dash:event:alternativeMPD:replace:2025"?(this.interstitialAdManager_||this.initInterstitial(null,a,b),this.interstitialAdManager_&&this.interstitialAdManager_.addRegion(c)):(d=="urn:mpeg:dash:event:2012"||d=="urn:scte:dash:scte214-events")&&c.eventNode&&shaka.util.TXml.findChild(c.eventNode,
"OverlayEvent")&&(this.interstitialAdManager_||this.initInterstitial(null,a,b),this.interstitialAdManager_&&this.interstitialAdManager_.addOverlayRegion(c))}};shaka.ads.AdManager.prototype.addCustomInterstitial=function(a){if(!this.interstitialAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);this.interstitialAdManager_.addInterstitials([a])};
shaka.ads.AdManager.prototype.addAdUrlInterstitial=function(a){if(!this.interstitialAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);return this.interstitialAdManager_.addAdUrlInterstitial(a)};
shaka.ads.AdManager.prototype.getInterstitialPlayer=function(){if(!this.interstitialAdManager_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.ADS,shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);return this.interstitialAdManager_.getPlayer()};
shaka.ads.AdManager.prototype.processAndDispatchEvent_=function(a){if(a&&a.type)switch(a.type){case shaka.ads.Utils.ADS_LOADED:this.stats_.addLoadTime(a.loadTime);break;case shaka.ads.Utils.AD_STARTED:this.stats_.incrementStarted();var b=a.ad;b&&!b.isLinear()&&this.stats_.incrementOverlayAds();break;case shaka.ads.Utils.AD_COMPLETE:this.stats_.incrementPlayedCompletely();break;case shaka.ads.Utils.AD_SKIPPED:this.stats_.incrementSkipped();break;case shaka.ads.Utils.AD_ERROR:this.stats_.incrementErrors()}this.dispatchEvent(a)};
goog.exportSymbol("shaka.ads.AdManager",shaka.ads.AdManager);goog.exportProperty(shaka.ads.AdManager.prototype,"getInterstitialPlayer",shaka.ads.AdManager.prototype.getInterstitialPlayer);goog.exportProperty(shaka.ads.AdManager.prototype,"addAdUrlInterstitial",shaka.ads.AdManager.prototype.addAdUrlInterstitial);goog.exportProperty(shaka.ads.AdManager.prototype,"addCustomInterstitial",shaka.ads.AdManager.prototype.addCustomInterstitial);
goog.exportProperty(shaka.ads.AdManager.prototype,"onDASHInterstitialMetadata",shaka.ads.AdManager.prototype.onDASHInterstitialMetadata);goog.exportProperty(shaka.ads.AdManager.prototype,"onHLSInterstitialMetadata",shaka.ads.AdManager.prototype.onHLSInterstitialMetadata);goog.exportProperty(shaka.ads.AdManager.prototype,"onCueMetadataChange",shaka.ads.AdManager.prototype.onCueMetadataChange);goog.exportProperty(shaka.ads.AdManager.prototype,"onHlsTimedMetadata",shaka.ads.AdManager.prototype.onHlsTimedMetadata);
goog.exportProperty(shaka.ads.AdManager.prototype,"onDashTimedMetadata",shaka.ads.AdManager.prototype.onDashTimedMetadata);goog.exportProperty(shaka.ads.AdManager.prototype,"onManifestUpdated",shaka.ads.AdManager.prototype.onManifestUpdated);goog.exportProperty(shaka.ads.AdManager.prototype,"getStats",shaka.ads.AdManager.prototype.getStats);goog.exportProperty(shaka.ads.AdManager.prototype,"getCuePoints",shaka.ads.AdManager.prototype.getCuePoints);
goog.exportProperty(shaka.ads.AdManager.prototype,"getServerSideCuePoints",shaka.ads.AdManager.prototype.getServerSideCuePoints);goog.exportProperty(shaka.ads.AdManager.prototype,"replaceServerSideAdTagParameters",shaka.ads.AdManager.prototype.replaceServerSideAdTagParameters);goog.exportProperty(shaka.ads.AdManager.prototype,"requestServerSideStream",shaka.ads.AdManager.prototype.requestServerSideStream);goog.exportProperty(shaka.ads.AdManager.prototype,"initServerSide",shaka.ads.AdManager.prototype.initServerSide);
goog.exportProperty(shaka.ads.AdManager.prototype,"addMediaTailorTrackingUrl",shaka.ads.AdManager.prototype.addMediaTailorTrackingUrl);goog.exportProperty(shaka.ads.AdManager.prototype,"requestMediaTailorStream",shaka.ads.AdManager.prototype.requestMediaTailorStream);goog.exportProperty(shaka.ads.AdManager.prototype,"initMediaTailor",shaka.ads.AdManager.prototype.initMediaTailor);goog.exportProperty(shaka.ads.AdManager.prototype,"updateClientSideAdsRenderingSettings",shaka.ads.AdManager.prototype.updateClientSideAdsRenderingSettings);
goog.exportProperty(shaka.ads.AdManager.prototype,"requestClientSideAds",shaka.ads.AdManager.prototype.requestClientSideAds);goog.exportProperty(shaka.ads.AdManager.prototype,"onAssetUnload",shaka.ads.AdManager.prototype.onAssetUnload);goog.exportProperty(shaka.ads.AdManager.prototype,"release",shaka.ads.AdManager.prototype.release);goog.exportProperty(shaka.ads.AdManager.prototype,"initClientSide",shaka.ads.AdManager.prototype.initClientSide);
goog.exportProperty(shaka.ads.AdManager.prototype,"initInterstitial",shaka.ads.AdManager.prototype.initInterstitial);goog.exportProperty(shaka.ads.AdManager.prototype,"configure",shaka.ads.AdManager.prototype.configure);goog.exportProperty(shaka.ads.AdManager.prototype,"setLocale",shaka.ads.AdManager.prototype.setLocale);shaka.ads.AdManager.ADS_LOADED="ads-loaded";goog.exportProperty(shaka.ads.AdManager,"ADS_LOADED",shaka.ads.AdManager.ADS_LOADED);shaka.ads.AdManager.AD_STARTED="ad-started";
goog.exportProperty(shaka.ads.AdManager,"AD_STARTED",shaka.ads.AdManager.AD_STARTED);shaka.ads.AdManager.AD_FIRST_QUARTILE="ad-first-quartile";goog.exportProperty(shaka.ads.AdManager,"AD_FIRST_QUARTILE",shaka.ads.AdManager.AD_FIRST_QUARTILE);shaka.ads.AdManager.AD_MIDPOINT="ad-midpoint";goog.exportProperty(shaka.ads.AdManager,"AD_MIDPOINT",shaka.ads.AdManager.AD_MIDPOINT);shaka.ads.AdManager.AD_THIRD_QUARTILE="ad-third-quartile";goog.exportProperty(shaka.ads.AdManager,"AD_THIRD_QUARTILE",shaka.ads.AdManager.AD_THIRD_QUARTILE);
shaka.ads.AdManager.AD_COMPLETE="ad-complete";goog.exportProperty(shaka.ads.AdManager,"AD_COMPLETE",shaka.ads.AdManager.AD_COMPLETE);shaka.ads.AdManager.AD_STOPPED="ad-stopped";goog.exportProperty(shaka.ads.AdManager,"AD_STOPPED",shaka.ads.AdManager.AD_STOPPED);shaka.ads.AdManager.AD_SKIPPED="ad-skipped";goog.exportProperty(shaka.ads.AdManager,"AD_SKIPPED",shaka.ads.AdManager.AD_SKIPPED);shaka.ads.AdManager.AD_VOLUME_CHANGED="ad-volume-changed";
goog.exportProperty(shaka.ads.AdManager,"AD_VOLUME_CHANGED",shaka.ads.AdManager.AD_VOLUME_CHANGED);shaka.ads.AdManager.AD_MUTED="ad-muted";goog.exportProperty(shaka.ads.AdManager,"AD_MUTED",shaka.ads.AdManager.AD_MUTED);shaka.ads.AdManager.AD_PAUSED="ad-paused";goog.exportProperty(shaka.ads.AdManager,"AD_PAUSED",shaka.ads.AdManager.AD_PAUSED);shaka.ads.AdManager.AD_RESUMED="ad-resumed";goog.exportProperty(shaka.ads.AdManager,"AD_RESUMED",shaka.ads.AdManager.AD_RESUMED);
shaka.ads.AdManager.AD_SKIP_STATE_CHANGED="ad-skip-state-changed";goog.exportProperty(shaka.ads.AdManager,"AD_SKIP_STATE_CHANGED",shaka.ads.AdManager.AD_SKIP_STATE_CHANGED);shaka.ads.AdManager.CUEPOINTS_CHANGED="ad-cue-points-changed";goog.exportProperty(shaka.ads.AdManager,"CUEPOINTS_CHANGED",shaka.ads.AdManager.CUEPOINTS_CHANGED);shaka.ads.AdManager.IMA_AD_MANAGER_LOADED="ima-ad-manager-loaded";goog.exportProperty(shaka.ads.AdManager,"IMA_AD_MANAGER_LOADED",shaka.ads.AdManager.IMA_AD_MANAGER_LOADED);
shaka.ads.AdManager.IMA_STREAM_MANAGER_LOADED="ima-stream-manager-loaded";goog.exportProperty(shaka.ads.AdManager,"IMA_STREAM_MANAGER_LOADED",shaka.ads.AdManager.IMA_STREAM_MANAGER_LOADED);shaka.ads.AdManager.AD_CLICKED="ad-clicked";goog.exportProperty(shaka.ads.AdManager,"AD_CLICKED",shaka.ads.AdManager.AD_CLICKED);shaka.ads.AdManager.AD_PROGRESS="ad-progress";goog.exportProperty(shaka.ads.AdManager,"AD_PROGRESS",shaka.ads.AdManager.AD_PROGRESS);shaka.ads.AdManager.AD_BUFFERING="ad-buffering";
goog.exportProperty(shaka.ads.AdManager,"AD_BUFFERING",shaka.ads.AdManager.AD_BUFFERING);shaka.ads.AdManager.AD_IMPRESSION="ad-impression";goog.exportProperty(shaka.ads.AdManager,"AD_IMPRESSION",shaka.ads.AdManager.AD_IMPRESSION);shaka.ads.AdManager.AD_DURATION_CHANGED="ad-duration-changed";goog.exportProperty(shaka.ads.AdManager,"AD_DURATION_CHANGED",shaka.ads.AdManager.AD_DURATION_CHANGED);shaka.ads.AdManager.AD_CLOSED="ad-closed";goog.exportProperty(shaka.ads.AdManager,"AD_CLOSED",shaka.ads.AdManager.AD_CLOSED);
shaka.ads.AdManager.AD_LOADED="ad-loaded";goog.exportProperty(shaka.ads.AdManager,"AD_LOADED",shaka.ads.AdManager.AD_LOADED);shaka.ads.AdManager.ALL_ADS_COMPLETED="all-ads-completed";goog.exportProperty(shaka.ads.AdManager,"ALL_ADS_COMPLETED",shaka.ads.AdManager.ALL_ADS_COMPLETED);shaka.ads.AdManager.AD_LINEAR_CHANGED="ad-linear-changed";goog.exportProperty(shaka.ads.AdManager,"AD_LINEAR_CHANGED",shaka.ads.AdManager.AD_LINEAR_CHANGED);shaka.ads.AdManager.AD_METADATA="ad-metadata";
goog.exportProperty(shaka.ads.AdManager,"AD_METADATA",shaka.ads.AdManager.AD_METADATA);shaka.ads.AdManager.AD_RECOVERABLE_ERROR="ad-recoverable-error";goog.exportProperty(shaka.ads.AdManager,"AD_RECOVERABLE_ERROR",shaka.ads.AdManager.AD_RECOVERABLE_ERROR);shaka.ads.AdManager.AD_ERROR="ad-error";goog.exportProperty(shaka.ads.AdManager,"AD_ERROR",shaka.ads.AdManager.AD_ERROR);shaka.ads.AdManager.AD_BREAK_READY="ad-break-ready";goog.exportProperty(shaka.ads.AdManager,"AD_BREAK_READY",shaka.ads.AdManager.AD_BREAK_READY);
shaka.ads.AdManager.AD_INTERACTION="ad-interaction";goog.exportProperty(shaka.ads.AdManager,"AD_INTERACTION",shaka.ads.AdManager.AD_INTERACTION);shaka.ads.AdManager.AD_CONTENT_PAUSE_REQUESTED="ad-content-pause-requested";goog.exportProperty(shaka.ads.AdManager,"AD_CONTENT_PAUSE_REQUESTED",shaka.ads.AdManager.AD_CONTENT_PAUSE_REQUESTED);shaka.ads.AdManager.AD_CONTENT_RESUME_REQUESTED="ad-content-resume-requested";goog.exportProperty(shaka.ads.AdManager,"AD_CONTENT_RESUME_REQUESTED",shaka.ads.AdManager.AD_CONTENT_RESUME_REQUESTED);
shaka.ads.AdManager.AD_CONTENT_ATTACH_REQUESTED="ad-content-attach-requested";goog.exportProperty(shaka.ads.AdManager,"AD_CONTENT_ATTACH_REQUESTED",shaka.ads.AdManager.AD_CONTENT_ATTACH_REQUESTED);shaka.Player.setAdManagerFactory(function(){return new shaka.ads.AdManager});shaka.cast={};shaka.cast.CastUtils=function(){};
shaka.cast.CastUtils.serialize=function(a){return JSON.stringify(a,function(b,c){if(typeof c!="function"){b=c instanceof shaka.util.FakeEvent;if(c instanceof Event||b){var d={},e;for(e in c){var f=c[e];f&&typeof f=="object"?e=="detail"?d[e]=f:f instanceof Event||f instanceof shaka.util.FakeEvent?d[e]=shaka.cast.CastUtils.unpackEvent_(f):b&&Array.isArray(f)&&(d[e]=f):e in Event||(d[e]=f)}return d}return c instanceof Error?shaka.cast.CastUtils.unpackError_(c):c instanceof TimeRanges?shaka.cast.CastUtils.unpackTimeRanges_(c):
ArrayBuffer.isView(c)&&c.BYTES_PER_ELEMENT===1?shaka.cast.CastUtils.unpackUint8Array_(c):typeof c=="number"?isNaN(c)?"NaN":isFinite(c)?c:c<0?"-Infinity":"Infinity":c}})};
shaka.cast.CastUtils.deserialize=function(a){return JSON.parse(a,function(b,c){return c=="NaN"?NaN:c=="-Infinity"?-Infinity:c=="Infinity"?Infinity:c&&typeof c=="object"&&c.__type__=="TimeRanges"?shaka.cast.CastUtils.simulateTimeRanges_(c):c&&typeof c=="object"&&c.__type__=="Uint8Array"?shaka.cast.CastUtils.makeUint8Array_(c):c&&typeof c=="object"&&c.__type__=="Error"?shaka.cast.CastUtils.makeError_(c):c&&typeof c=="object"&&c.__type__=="Event"?shaka.cast.CastUtils.makeEvent_(c):c})};
shaka.cast.CastUtils.unpackTimeRanges_=function(a){var b={__type__:"TimeRanges",length:a.length,start:[],end:[]};a=(0,$jscomp.makeIterator)(shaka.media.TimeRangesUtils.getBufferedInfo(a));for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=c.end;b.start.push(c.start);b.end.push(d)}return b};shaka.cast.CastUtils.simulateTimeRanges_=function(a){return{length:a.length,start:function(b){return a.start[b]},end:function(b){return a.end[b]}}};
shaka.cast.CastUtils.unpackUint8Array_=function(a){return{__type__:"Uint8Array",entries:Array.from(a)}};shaka.cast.CastUtils.makeUint8Array_=function(a){return new Uint8Array(a.entries)};shaka.cast.CastUtils.unpackEvent_=function(a){return{__type__:"Event",event:shaka.cast.CastUtils.serialize(a)}};shaka.cast.CastUtils.makeEvent_=function(a){return shaka.cast.CastUtils.deserialize(a.event)};
shaka.cast.CastUtils.unpackError_=function(a){var b=new Set(["name","message","stack"]);for(c in a)b.add(c);var c=(0,$jscomp.makeIterator)(Object.getOwnPropertyNames(a));for(var d=c.next();!d.done;d=c.next())b.add(d.value);c={};b=(0,$jscomp.makeIterator)(b);for(d=b.next();!d.done;d=b.next())d=d.value,c[d]=a[d];return{__type__:"Error",contents:c}};shaka.cast.CastUtils.makeError_=function(a){a=a.contents;var b=Error(a.message),c;for(c in a)b[c]=a[c];return b};shaka.cast.CastUtils.VideoEvents="ended play playing pause pausing ratechange seeked seeking timeupdate volumechange".split(" ");
shaka.cast.CastUtils.VideoAttributes="buffered currentTime duration ended loop muted paused playbackRate seeking videoHeight videoWidth volume".split(" ");shaka.cast.CastUtils.VideoInitStateAttributes=["loop","playbackRate"];shaka.cast.CastUtils.VideoVoidMethods=["pause","play"];
shaka.cast.CastUtils.PlayerGetterMethods=(new Map).set("getAssetUri",2).set("getAudioLanguages",4).set("getAudioLanguagesAndRoles",4).set("getBufferFullness",1).set("getBufferedInfo",2).set("getExpiration",2).set("getKeyStatuses",2).set("getPlaybackRate",2).set("getTextLanguages",4).set("getTextLanguagesAndRoles",4).set("isAudioOnly",10).set("isBuffering",1).set("isInProgress",1).set("isLive",10).set("isTextTrackVisible",1).set("isVideoOnly",10).set("keySystem",10).set("seekRange",1).set("getLoadMode",
10).set("getManifestType",10).set("isFullyLoaded",1).set("isEnded",1).set("getBandwidthEstimate",1).set("isRemotePlayback",1);shaka.cast.CastUtils.LargePlayerGetterMethods=(new Map).set("getConfiguration",4).set("getConfigurationForLowLatency",4).set("getStats",5).set("getAudioTracks",2).set("getChaptersTracks",2).set("getImageTracks",2).set("getVideoTracks",2).set("getTextTracks",2).set("getVariantTracks",2);
shaka.cast.CastUtils.PlayerGetterMethodsThatRequireLive=(new Map).set("getPlayheadTimeAsDate",1).set("getPresentationStartTimeAsDate",20).set("getSegmentAvailabilityDuration",20);shaka.cast.CastUtils.PlayerInitState=[["getConfiguration","configure","getConfigurationForLowLatency","configurationForLowLatency"]];shaka.cast.CastUtils.PlayerInitAfterLoadState=[["isTextTrackVisible","setTextTrackVisibility"]];shaka.cast.CastUtils.PlayerVoidMethods="cancelTrickPlay configure configurationForLowLatency getChapters resetConfiguration retryStreaming selectAudioLanguage selectAudioTrack selectTextLanguage selectTextTrack selectVariantTrack selectVariantsByLabel selectVideoTrack setTextTrackVisibility trickPlay updateStartTime goToLive useTrickPlayTrackIfAvailable".split(" ");
shaka.cast.CastUtils.PlayerPromiseMethods="addChaptersTrack addTextTrackAsync addThumbnailsTrack getAllThumbnails getChaptersAsync getThumbnails attach attachCanvas detach load unload".split(" ");shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE="urn:x-cast:com.google.shaka.v2";shaka.cast.CastUtils.GENERIC_MESSAGE_NAMESPACE="urn:x-cast:com.google.cast.media";shaka.cast.CastSender=function(a,b,c,d,e,f,g){var h=this;this.receiverAppId_=a;this.androidReceiverCompatible_=g;this.statusChangeTimer_=new shaka.util.Timer(b);this.onFirstCastStateUpdate_=c;this.hasJoinedExistingSession_=!1;this.onRemoteEvent_=d;this.onResumeLocal_=e;this.onInitStateRequired_=f;this.isCasting_=this.apiReady_=!1;this.receiverName_="";this.appData_=null;this.onConnectionStatusChangedBound_=function(){return h.onConnectionStatusChanged_()};this.onMessageReceivedBound_=function(k,l){return h.onMessageReceived_(k,
l)};this.cachedProperties_={video:{},player:{}};this.nextAsyncCallId_=0;this.asyncCallPromises_=new Map;this.castPromise_=null;shaka.cast.CastSender.instances_.add(this)};
shaka.cast.CastSender.prototype.destroy=function(){shaka.cast.CastSender.instances_.delete(this);this.rejectAllPromises_();shaka.cast.CastSender.session_&&this.removeListeners_();this.statusChangeTimer_&&(this.statusChangeTimer_.stop(),this.statusChangeTimer_=null);this.onResumeLocal_=this.onRemoteEvent_=null;this.isCasting_=this.apiReady_=!1;this.onMessageReceivedBound_=this.onConnectionStatusChangedBound_=this.castPromise_=this.asyncCallPromises_=this.cachedProperties_=this.appData_=null;return Promise.resolve()};
shaka.cast.CastSender.prototype.apiReady=function(){return this.apiReady_};shaka.cast.CastSender.prototype.hasReceivers=function(){return shaka.cast.CastSender.hasReceivers_};shaka.cast.CastSender.prototype.isCasting=function(){return this.isCasting_};shaka.cast.CastSender.prototype.receiverName=function(){return this.receiverName_};shaka.cast.CastSender.prototype.hasRemoteProperties=function(){return Object.keys(this.cachedProperties_.video).length!=0};
shaka.cast.CastSender.prototype.init=function(){var a=shaka.cast.CastSender;if(this.receiverAppId_.length)if(window.chrome&&chrome.cast&&chrome.cast.isAvailable){this.apiReady_=!0;this.statusChangeTimer_.tickNow();var b=new chrome.cast.SessionRequest(this.receiverAppId_,[],null,this.androidReceiverCompatible_,null);b=new chrome.cast.ApiConfig(b,function(c){return a.onExistingSessionJoined_(c)},function(c){return a.onReceiverStatusChanged_(c)},"origin_scoped");chrome.cast.initialize(b,function(){shaka.log.debug("CastSender: init")},
function(c){shaka.log.error("CastSender: init error",c)});shaka.cast.CastSender.hasReceivers_&&this.statusChangeTimer_.tickAfter(shaka.cast.CastSender.STATUS_DELAY);(b=shaka.cast.CastSender.session_)&&b.status!=chrome.cast.SessionStatus.STOPPED?(shaka.log.debug("CastSender: re-using existing connection"),this.onExistingSessionJoined_(b)):shaka.cast.CastSender.session_=null}else window.__onGCastApiAvailable!==a.onGCastApiAvailable_&&(a.__onGCastApiAvailable_=window.__onGCastApiAvailable||null,window.__onGCastApiAvailable=
a.onGCastApiAvailable_)};shaka.cast.CastSender.prototype.setAppData=function(a){this.appData_=a;this.isCasting_&&this.sendMessage_({type:"appData",appData:this.appData_})};
shaka.cast.CastSender.prototype.cast=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(!a.apiReady_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.CAST,shaka.util.Error.Code.CAST_API_UNAVAILABLE);if(!shaka.cast.CastSender.hasReceivers_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.CAST,shaka.util.Error.Code.NO_CAST_RECEIVERS);if(a.isCasting_)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.CAST,shaka.util.Error.Code.ALREADY_CASTING);a.castPromise_=new shaka.util.PublicPromise;chrome.cast.requestSession(function(c){return a.onSessionInitiated_(c)},function(c){return a.onConnectionError_(c)});return b.yield(a.castPromise_,0)})};shaka.cast.CastSender.prototype.showDisconnectDialog=function(){var a=this;this.isCasting_&&chrome.cast.requestSession(function(b){return a.onSessionInitiated_(b)},function(b){return a.onConnectionError_(b)})};
shaka.cast.CastSender.prototype.forceDisconnect=function(){if(this.isCasting_){this.rejectAllPromises_();if(shaka.cast.CastSender.session_){this.removeListeners_();try{shaka.cast.CastSender.session_.stop(function(){},function(){})}catch(a){}shaka.cast.CastSender.session_=null}this.onConnectionStatusChanged_()}};
shaka.cast.CastSender.prototype.get=function(a,b){var c=this;goog.asserts.assert(a=="video"||a=="player","Unexpected target name");var d=shaka.cast.CastUtils;if(a=="video"){if(d.VideoVoidMethods.includes(b))return function(){var f=$jscomp.getRestArguments.apply(0,arguments);return c.remoteCall_.apply(c,[a,b].concat((0,$jscomp.arrayFromIterable)(f)))}}else if(a=="player"){if(d.PlayerGetterMethodsThatRequireLive.has(b)){var e=this.get("player","isLive")();goog.asserts.assert(e,b+" should be called on a live stream!");
if(!e)return function(){}}if(d.PlayerVoidMethods.includes(b))return function(){var f=$jscomp.getRestArguments.apply(0,arguments);return c.remoteCall_.apply(c,[a,b].concat((0,$jscomp.arrayFromIterable)(f)))};if(d.PlayerPromiseMethods.includes(b))return function(){var f=$jscomp.getRestArguments.apply(0,arguments);return c.remoteAsyncCall_.apply(c,[a,b].concat((0,$jscomp.arrayFromIterable)(f)))};if(d.PlayerGetterMethods.has(b)||d.LargePlayerGetterMethods.has(b))return function(){return c.propertyGetter_(a,
b)}}return this.propertyGetter_(a,b)};shaka.cast.CastSender.prototype.set=function(a,b,c){goog.asserts.assert(a=="video"||a=="player","Unexpected target name");this.cachedProperties_[a][b]=c;this.sendMessage_({type:"set",targetName:a,property:b,value:c})};shaka.cast.CastSender.prototype.onSessionInitiated_=function(a){shaka.log.debug("CastSender: onSessionInitiated");var b=this.onInitStateRequired_();this.onSessionCreated_(a);this.sendMessage_({type:"init",initState:b,appData:this.appData_});this.castPromise_.resolve()};
shaka.cast.CastSender.prototype.onConnectionError_=function(a){var b=shaka.util.Error.Code.UNEXPECTED_CAST_ERROR;switch(a.code){case "cancel":b=shaka.util.Error.Code.CAST_CANCELED_BY_USER;break;case "timeout":b=shaka.util.Error.Code.CAST_CONNECTION_TIMED_OUT;break;case "receiver_unavailable":b=shaka.util.Error.Code.CAST_RECEIVER_APP_UNAVAILABLE}this.castPromise_.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.CAST,b,a))};
shaka.cast.CastSender.prototype.propertyGetter_=function(a,b){goog.asserts.assert(a=="video"||a=="player","Unexpected target name");return this.cachedProperties_[a][b]};shaka.cast.CastSender.prototype.remoteCall_=function(a,b){var c=$jscomp.getRestArguments.apply(2,arguments);goog.asserts.assert(a=="video"||a=="player","Unexpected target name");this.sendMessage_({type:"call",targetName:a,methodName:b,args:c})};
shaka.cast.CastSender.prototype.remoteAsyncCall_=function(a,b){var c=$jscomp.getRestArguments.apply(2,arguments);goog.asserts.assert(a=="video"||a=="player","Unexpected target name");var d=new shaka.util.PublicPromise,e=this.nextAsyncCallId_.toString();this.nextAsyncCallId_++;this.asyncCallPromises_.set(e,d);try{this.sendMessage_({type:"asyncCall",targetName:a,methodName:b,args:c,id:e})}catch(f){d.reject(f)}return d};
shaka.cast.CastSender.onExistingSessionJoined_=function(a){for(var b=(0,$jscomp.makeIterator)(shaka.cast.CastSender.instances_),c=b.next();!c.done;c=b.next())c.value.onExistingSessionJoined_(a)};shaka.cast.CastSender.prototype.onExistingSessionJoined_=function(a){shaka.log.debug("CastSender: onExistingSessionJoined");this.castPromise_=new shaka.util.PublicPromise;this.hasJoinedExistingSession_=!0;this.onSessionInitiated_(a)};
shaka.cast.CastSender.onReceiverStatusChanged_=function(a){for(var b=(0,$jscomp.makeIterator)(shaka.cast.CastSender.instances_),c=b.next();!c.done;c=b.next())c.value.onReceiverStatusChanged_(a)};shaka.cast.CastSender.prototype.onReceiverStatusChanged_=function(a){shaka.log.debug("CastSender: receiver status",a);shaka.cast.CastSender.hasReceivers_=a=="available";this.statusChangeTimer_.tickNow()};
shaka.cast.CastSender.prototype.onSessionCreated_=function(a){shaka.cast.CastSender.session_=a;a.addUpdateListener(this.onConnectionStatusChangedBound_);a.addMessageListener(shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE,this.onMessageReceivedBound_);this.onConnectionStatusChanged_()};
shaka.cast.CastSender.prototype.removeListeners_=function(){var a=shaka.cast.CastSender.session_;a.removeUpdateListener(this.onConnectionStatusChangedBound_);a.removeMessageListener(shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE,this.onMessageReceivedBound_)};
shaka.cast.CastSender.prototype.onConnectionStatusChanged_=function(){var a=shaka.cast.CastSender.session_?shaka.cast.CastSender.session_.status=="connected":!1;shaka.log.info("CastSender: connection status",a);if(this.isCasting_&&!a){this.onResumeLocal_();for(var b in this.cachedProperties_)this.cachedProperties_[b]={};this.rejectAllPromises_()}this.receiverName_=(this.isCasting_=a)?shaka.cast.CastSender.session_.receiver.friendlyName:"";this.statusChangeTimer_.tickNow();this.receiverName_&&shaka.log.info("CastSender: connected to",
this.receiverName_)};shaka.cast.CastSender.prototype.rejectAllPromises_=function(){if(this.asyncCallPromises_)for(var a=(0,$jscomp.makeIterator)(this.asyncCallPromises_.keys()),b=a.next();!b.done;b=a.next()){b=b.value;var c=this.asyncCallPromises_.get(b);this.asyncCallPromises_.delete(b);c.reject(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.LOAD_INTERRUPTED))}};
shaka.cast.CastSender.prototype.onMessageReceived_=function(a,b){a=shaka.cast.CastUtils.deserialize(b);shaka.log.v2("CastSender: message",a);switch(a.type){case "event":var c=a.targetName,d=shaka.util.FakeEvent.fromRealEvent(a.event);this.onRemoteEvent_(c,d);break;case "update":c=a.update;for(d in c){a=this.cachedProperties_[d]||{};for(var e in c[d])a[e]=c[d][e]}this.hasJoinedExistingSession_&&(this.onFirstCastStateUpdate_(),this.hasJoinedExistingSession_=!1);break;case "asyncComplete":if(e=a.id,
d=a.error,b=a.res,a=this.asyncCallPromises_.get(e),this.asyncCallPromises_.delete(e),goog.asserts.assert(a,"Unexpected async id"),a)if(d){e=new shaka.util.Error(d.severity,d.category,d.code);for(c in d)e[c]=d[c];a.reject(e)}else a.resolve(b)}};
shaka.cast.CastSender.prototype.sendMessage_=function(a){a=shaka.cast.CastUtils.serialize(a);var b=shaka.cast.CastSender.session_;try{b.sendMessage(shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE,a,function(){},shaka.log.error)}catch(c){throw shaka.log.error("Cast session sendMessage threw",c),a=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.CAST,shaka.util.Error.Code.CAST_CONNECTION_TIMED_OUT,c),b=new shaka.util.FakeEvent("error",(new Map).set("detail",a)),this.onRemoteEvent_("player",
b),this.forceDisconnect(),a;}};shaka.cast.CastSender.STATUS_DELAY=.02;shaka.cast.CastSender.hasReceivers_=!1;shaka.cast.CastSender.session_=null;shaka.cast.CastSender.__onGCastApiAvailable_=null;shaka.cast.CastSender.instances_=new Set;shaka.cast.CastSender.onSdkLoaded_=function(a){if(a){a=(0,$jscomp.makeIterator)(shaka.cast.CastSender.instances_);for(var b=a.next();!b.done;b=a.next())b.value.init()}};
shaka.cast.CastSender.onGCastApiAvailable_=function(a){shaka.cast.CastSender.__onGCastApiAvailable_?window.__onGCastApiAvailable=shaka.cast.CastSender.__onGCastApiAvailable_:delete window.__onGCastApiAvailable;shaka.cast.CastSender.__onGCastApiAvailable_=null;shaka.cast.CastSender.onSdkLoaded_(a);typeof window.__onGCastApiAvailable==="function"&&window.__onGCastApiAvailable(a)};shaka.cast.CastProxy=function(a,b,c,d){d=d===void 0?!1:d;shaka.util.FakeEventTarget.call(this);var e=this;this.localVideo_=a;this.localPlayer_=b;this.eventManager_=this.playerEventTarget_=this.videoEventTarget_=this.playerProxy_=this.videoProxy_=null;this.receiverAppId_=c;this.androidReceiverCompatible_=d;this.addThumbnailsTrackCalls_=[];this.addTextTrackAsyncCalls_=[];this.addChaptersTrackCalls_=[];this.compiledToExternNames_=new Map;this.sender_=null;this.shouldInitCastSender_()?(this.sender_=new shaka.cast.CastSender(c,
function(){return e.onCastStatusChanged_()},function(){return e.onFirstCastStateUpdate_()},function(f,g){return e.onRemoteEvent_(f,g)},function(){return e.onResumeLocal_()},function(){return e.getInitState_()},d),this.init_()):this.initWithoutSender_()};$jscomp.inherits(shaka.cast.CastProxy,shaka.util.FakeEventTarget);
shaka.cast.CastProxy.prototype.destroy=function(a){this.sender_&&(a===void 0?0:a)&&this.sender_.forceDisconnect();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);a=[];this.localPlayer_&&(a.push(this.localPlayer_.destroy()),this.localPlayer_=null);this.sender_&&(a.push(this.sender_.destroy()),this.sender_=null);this.playerProxy_=this.videoProxy_=this.localVideo_=null;shaka.util.FakeEventTarget.prototype.release.call(this);return Promise.all(a)};
shaka.cast.CastProxy.prototype.getVideo=function(){return this.videoProxy_};shaka.cast.CastProxy.prototype.getPlayer=function(){return this.playerProxy_};shaka.cast.CastProxy.prototype.canCast=function(){return this.sender_?this.sender_.apiReady()&&this.sender_.hasReceivers():!1};shaka.cast.CastProxy.prototype.isCasting=function(){return this.sender_?this.sender_.isCasting():!1};shaka.cast.CastProxy.prototype.receiverName=function(){return this.sender_?this.sender_.receiverName():""};
shaka.cast.CastProxy.prototype.cast=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.getNextAddressJsc()==1?a.sender_?b.yield(a.sender_.cast(),2):b.return():a.localPlayer_?b.yield(a.localPlayer_.unload(),0):b.return()})};shaka.cast.CastProxy.prototype.setAppData=function(a){this.sender_&&this.sender_.setAppData(a)};shaka.cast.CastProxy.prototype.suggestDisconnect=function(){this.sender_&&this.sender_.showDisconnectDialog()};
shaka.cast.CastProxy.prototype.forceDisconnect=function(){this.sender_&&this.sender_.forceDisconnect()};
shaka.cast.CastProxy.prototype.changeReceiverId=function(a,b){b=b===void 0?!1:b;var c=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1){if(a==c.receiverAppId_&&b==c.androidReceiverCompatible_)return d.return();c.receiverAppId_=a;c.androidReceiverCompatible_=b;if(!c.sender_)return d.return();c.sender_.forceDisconnect();return d.yield(c.sender_.destroy(),2)}c.sender_=null;c.sender_=new shaka.cast.CastSender(a,function(){return c.onCastStatusChanged_()},
function(){return c.onFirstCastStateUpdate_()},function(e,f){return c.onRemoteEvent_(e,f)},function(){return c.onResumeLocal_()},function(){return c.getInitState_()},b);c.sender_.init();d.jumpToEnd()})};shaka.cast.CastProxy.prototype.initWithoutSender_=function(){this.videoProxy_=this.localVideo_;this.playerProxy_=this.localPlayer_};
shaka.cast.CastProxy.prototype.init_=function(){var a=this;this.sender_.init();this.eventManager_=new shaka.util.EventManager;for(var b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoEvents),c=b.next();!c.done;c=b.next())this.eventManager_.listen(this.localVideo_,c.value,function(f){return a.videoProxyLocalEvent_(f)});for(var d in shaka.util.FakeEvent.EventName)this.eventManager_.listen(this.localPlayer_,shaka.util.FakeEvent.EventName[d],function(f){return a.playerProxyLocalEvent_(f)});this.videoProxy_=
{};b={};for(var e in this.localVideo_)b={k$jscomp$12:b.k$jscomp$12},b.k$jscomp$12=e,Object.defineProperty(this.videoProxy_,b.k$jscomp$12,{configurable:!1,enumerable:!0,get:function(f){return function(){return a.videoProxyGet_(f.k$jscomp$12)}}(b),set:function(f){return function(g){a.videoProxySet_(f.k$jscomp$12,g)}}(b)});this.playerProxy_={};this.iterateOverPlayerMethods_(function(f,g){goog.asserts.assert(a.playerProxy_,"Must have player proxy!");Object.defineProperty(a.playerProxy_,f,{configurable:!1,
enumerable:!0,get:function(){return a.playerProxyGet_(f)}})});COMPILED&&this.mapCompiledToUncompiledPlayerMethodNames_();this.videoEventTarget_=new shaka.util.FakeEventTarget;this.videoEventTarget_.dispatchTarget=this.videoProxy_;this.playerEventTarget_=new shaka.util.FakeEventTarget;this.playerEventTarget_.dispatchTarget=this.playerProxy_;this.eventManager_.listen(this.localPlayer_,shaka.util.FakeEvent.EventName.Unloading,function(){a.sender_&&a.sender_.isCasting()||a.resetExternalTracks()})};
shaka.cast.CastProxy.prototype.mapCompiledToUncompiledPlayerMethodNames_=function(){var a=this,b=new Map;this.iterateOverPlayerMethods_(function(c,d){b.has(d)?(d=b.get(d),c.length<d.length?a.compiledToExternNames_.set(c,d):a.compiledToExternNames_.set(d,c)):b.set(d,c)})};
shaka.cast.CastProxy.prototype.iterateOverPlayerMethods_=function(a){function b(k){return k=="constructor"||typeof c[k]!="function"?!1:!d.has(k)}goog.asserts.assert(this.localPlayer_,"Must have player!");var c=this.localPlayer_,d=new Set;for(e in c)b(e)&&(d.add(e),a(e,c[e]));var e=Object.getPrototypeOf(c);for(var f=Object.getPrototypeOf({});e&&e!=f;){for(var g=(0,$jscomp.makeIterator)(Object.getOwnPropertyNames(e)),h=g.next();!h.done;h=g.next())h=h.value,b(h)&&(d.add(h),a(h,c[h]));e=Object.getPrototypeOf(e)}};
shaka.cast.CastProxy.prototype.getInitState_=function(){var a={video:{},player:{},playerAfterLoad:{},manifest:this.localPlayer_.getAssetUri(),startTime:null,addThumbnailsTrackCalls:this.addThumbnailsTrackCalls_,addTextTrackAsyncCalls:this.addTextTrackAsyncCalls_,addChaptersTrackCalls:this.addChaptersTrackCalls_};this.localVideo_.pause();for(var b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoInitStateAttributes),c=b.next();!c.done;c=b.next())c=c.value,a.video[c]=this.localVideo_[c];this.localVideo_.ended||
(a.startTime=this.localVideo_.currentTime);b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.PlayerInitState);for(c=b.next();!c.done;c=b.next()){var d=c.value;c=d[1];d=this.localPlayer_[d[0]]();a.player[c]=d}b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.PlayerInitAfterLoadState);for(c=b.next();!c.done;c=b.next())d=c.value,c=d[1],d=this.localPlayer_[d[0]](),a.playerAfterLoad[c]=d;return a};
shaka.cast.CastProxy.prototype.onCastStatusChanged_=function(){var a=new shaka.util.FakeEvent("caststatuschanged");this.dispatchEvent(a)};shaka.cast.CastProxy.prototype.onFirstCastStateUpdate_=function(){var a=new shaka.util.FakeEvent(this.videoProxy_.paused?"pause":"play");this.videoEventTarget_.dispatchEvent(a)};
shaka.cast.CastProxy.prototype.onResumeLocal_=function(){for(var a=this,b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.PlayerInitState),c=b.next();!c.done;c=b.next()){var d=c.value;c=d[1];d=this.sender_.get("player",d[0])();this.localPlayer_[c](d)}var e=this.addThumbnailsTrackCalls_,f=this.addTextTrackAsyncCalls_,g=this.addChaptersTrackCalls_;this.resetExternalTracks();var h=this.sender_.get("player","getAssetUri")();d=this.sender_.get("video","ended");b=Promise.resolve();var k=this.localVideo_.autoplay;
c=null;d||(c=this.sender_.get("video","currentTime"));var l;(d=this.sender_.get("player","getTextTracks")())&&d.length&&(l=d.find(function(p){return p.active}));var m=this.sender_.get("player","isTextTrackVisible")();h&&(this.localVideo_.autoplay=!1,b=this.localPlayer_.load(h,c));var n={};c=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoInitStateAttributes);for(d=c.next();!d.done;d=c.next())d=d.value,n[d]=this.sender_.get("video",d);b.then(function(){if(a.localVideo_){for(var p=(0,$jscomp.makeIterator)(e),
q=p.next();!q.done;q=p.next()){q=q.value;var r;(r=a.getPlayer()).addThumbnailsTrack.apply(r,(0,$jscomp.arrayFromIterable)(q))}p=(0,$jscomp.makeIterator)(f);for(r=p.next();!r.done;r=p.next()){r=r.value;var t;(t=a.getPlayer()).addTextTrackAsync.apply(t,(0,$jscomp.arrayFromIterable)(r))}t=(0,$jscomp.makeIterator)(g);for(p=t.next();!p.done;p=t.next()){p=p.value;var u;(u=a.getPlayer()).addChaptersTrack.apply(u,(0,$jscomp.arrayFromIterable)(p))}u=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoInitStateAttributes);
for(t=u.next();!t.done;t=u.next())t=t.value,a.localVideo_[t]=n[t];u=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.PlayerInitAfterLoadState);for(t=u.next();!t.done;t=u.next())p=t.value,t=p[1],p=a.sender_.get("player",p[0])(),a.localPlayer_[t](p);a.localPlayer_.setTextTrackVisibility(m);l&&a.localPlayer_.selectTextLanguage(l.language,l.roles,l.forced);a.localVideo_.autoplay=k;h&&a.localVideo_.play()}},function(p){goog.asserts.assert(p instanceof shaka.util.Error,"Wrong error type!");var q=shaka.util.FakeEvent.EventName.Error;
p=(new Map).set("detail",p);q=new shaka.util.FakeEvent(q,p);a.localPlayer_.dispatchEvent(q)})};
shaka.cast.CastProxy.prototype.videoProxyGet_=function(a){var b=this;if(a=="addEventListener")return function(d,e,f){return b.videoEventTarget_.addEventListener(d,e,f)};if(a=="removeEventListener")return function(d,e,f){return b.videoEventTarget_.removeEventListener(d,e,f)};if(this.sender_.isCasting()&&!this.sender_.hasRemoteProperties()){var c=this.localVideo_[a];if(typeof c!="function")return c}return this.sender_.isCasting()?this.sender_.get("video",a):(a=this.localVideo_[a],typeof a=="function"&&
(a=a.bind(this.localVideo_)),a)};shaka.cast.CastProxy.prototype.videoProxySet_=function(a,b){this.sender_.isCasting()?this.sender_.set("video",a,b):this.localVideo_[a]=b};shaka.cast.CastProxy.prototype.videoProxyLocalEvent_=function(a){this.sender_.isCasting()||(a=shaka.util.FakeEvent.fromRealEvent(a),this.videoEventTarget_.dispatchEvent(a))};
shaka.cast.CastProxy.prototype.playerProxyGet_=function(a,b){var c=this;b=b===void 0?!1:b;this.compiledToExternNames_.has(a)&&(a=this.compiledToExternNames_.get(a));if(a=="addEventListener")return function(d,e,f){return c.playerEventTarget_.addEventListener(d,e,f)};if(a=="removeEventListener")return function(d,e,f){return c.playerEventTarget_.removeEventListener(d,e,f)};if(a=="getMediaElement")return function(){return c.videoProxy_};if(a=="getSharedConfiguration")return shaka.log.warning("Can't share configuration across a network. Returning copy."),
this.sender_.get("player","getConfiguration");if(a=="getNetworkingEngine")return this.sender_.isCasting()&&shaka.log.warning("NOTE: getNetworkingEngine() is always local!"),function(){return c.localPlayer_.getNetworkingEngine()};if(a=="getDrmEngine")return this.sender_.isCasting()&&shaka.log.warning("NOTE: getDrmEngine() is always local!"),function(){return c.localPlayer_.getDrmEngine()};if(a=="getAdManager")return this.sender_.isCasting()&&shaka.log.warning("NOTE: getAdManager() is always local!"),
function(){return c.localPlayer_.getAdManager()};if(a=="getQueueManager")return function(){return c.localPlayer_.getQueueManager()};if(a=="setVideoContainer")return this.sender_.isCasting()&&shaka.log.warning("NOTE: setVideoContainer() is always local!"),function(d){return c.localPlayer_.setVideoContainer(d)};if(!b){if(a=="addThumbnailsTrack")return function(){var d=$jscomp.getRestArguments.apply(0,arguments);c.addThumbnailsTrackCalls_.push(d);return c.playerProxyGet_(a,!0).apply(null,(0,$jscomp.arrayFromIterable)(d))};
if(a=="addTextTrackAsync")return function(){var d=$jscomp.getRestArguments.apply(0,arguments);c.addTextTrackAsyncCalls_.push(d);return c.playerProxyGet_(a,!0).apply(null,(0,$jscomp.arrayFromIterable)(d))};if(a=="addChaptersTrack")return function(){var d=$jscomp.getRestArguments.apply(0,arguments);c.addChaptersTrackCalls_.push(d);return c.playerProxyGet_(a,!0).apply(null,(0,$jscomp.arrayFromIterable)(d))}}if(this.sender_.isCasting()){if(a=="getManifest"||a=="drmInfo")return function(){shaka.log.alwaysWarn(a+
"() does not work while casting!");return null};if(a=="attach"||a=="detach")return function(){shaka.log.alwaysWarn(a+"() does not work while casting!");return Promise.resolve()};if(a=="getChapters")return function(){shaka.log.alwaysWarn(a+"() does not work while casting!");return[]}}return this.sender_.isCasting()&&!this.sender_.hasRemoteProperties()&&(shaka.cast.CastUtils.PlayerGetterMethods.has(a)||shaka.cast.CastUtils.LargePlayerGetterMethods.has(a))||!this.sender_.isCasting()?(b=this.localPlayer_[a],
goog.asserts.assert(typeof b=="function","only methods on Player"),b.bind(this.localPlayer_)):this.sender_.get("player",a)};shaka.cast.CastProxy.prototype.playerProxyLocalEvent_=function(a){this.sender_.isCasting()||this.playerEventTarget_.dispatchEvent(a)};
shaka.cast.CastProxy.prototype.onRemoteEvent_=function(a,b){goog.asserts.assert(this.sender_.isCasting(),"Should only receive remote events while casting");this.sender_.isCasting()&&(a=="video"?this.videoEventTarget_.dispatchEvent(b):a=="player"&&(b.type==shaka.util.FakeEvent.EventName.Unloading&&this.resetExternalTracks(),this.playerEventTarget_.dispatchEvent(b)))};
shaka.cast.CastProxy.prototype.resetExternalTracks=function(){this.addThumbnailsTrackCalls_=[];this.addTextTrackAsyncCalls_=[];this.addChaptersTrackCalls_=[]};shaka.cast.CastProxy.prototype.shouldInitCastSender_=function(){return window.chrome&&shaka.device.DeviceFactory.getDevice().getDeviceType()!=shaka.device.IDevice.DeviceType.CAST?!0:!1};goog.exportSymbol("shaka.cast.CastProxy",shaka.cast.CastProxy);goog.exportProperty(shaka.cast.CastProxy.prototype,"changeReceiverId",shaka.cast.CastProxy.prototype.changeReceiverId);
goog.exportProperty(shaka.cast.CastProxy.prototype,"forceDisconnect",shaka.cast.CastProxy.prototype.forceDisconnect);goog.exportProperty(shaka.cast.CastProxy.prototype,"suggestDisconnect",shaka.cast.CastProxy.prototype.suggestDisconnect);goog.exportProperty(shaka.cast.CastProxy.prototype,"setAppData",shaka.cast.CastProxy.prototype.setAppData);goog.exportProperty(shaka.cast.CastProxy.prototype,"cast",shaka.cast.CastProxy.prototype.cast);
goog.exportProperty(shaka.cast.CastProxy.prototype,"receiverName",shaka.cast.CastProxy.prototype.receiverName);goog.exportProperty(shaka.cast.CastProxy.prototype,"isCasting",shaka.cast.CastProxy.prototype.isCasting);goog.exportProperty(shaka.cast.CastProxy.prototype,"canCast",shaka.cast.CastProxy.prototype.canCast);goog.exportProperty(shaka.cast.CastProxy.prototype,"getPlayer",shaka.cast.CastProxy.prototype.getPlayer);goog.exportProperty(shaka.cast.CastProxy.prototype,"getVideo",shaka.cast.CastProxy.prototype.getVideo);
goog.exportProperty(shaka.cast.CastProxy.prototype,"destroy",shaka.cast.CastProxy.prototype.destroy);shaka.cast.CastReceiver=function(a,b,c,d){shaka.util.FakeEventTarget.call(this);var e=this;this.video_=a;this.player_=b;this.eventManager_=new shaka.util.EventManager;this.targets_={video:a,player:b};this.appDataCallback_=c||function(){};this.contentIdCallback_=d||function(f){return f};this.metadata_=null;this.isConnected_=!1;this.isIdle_=!0;this.updateNumber_=0;this.startUpdatingUpdateNumber_=!1;this.initialStatusUpdatePending_=!0;this.genericBus_=this.shakaBus_=null;this.pollTimer_=new shaka.util.Timer(function(){e.pollAttributes_()});
this.init_()};$jscomp.inherits(shaka.cast.CastReceiver,shaka.util.FakeEventTarget);shaka.cast.CastReceiver.prototype.isConnected=function(){return this.isConnected_};shaka.cast.CastReceiver.prototype.isIdle=function(){return this.isIdle_};shaka.cast.CastReceiver.prototype.setContentMetadata=function(a){this.metadata_=a};shaka.cast.CastReceiver.prototype.clearContentMetadata=function(){this.metadata_=null};
shaka.cast.CastReceiver.prototype.setContentTitle=function(a){this.metadata_||(this.metadata_={metadataType:cast.receiver.media.MetadataType.GENERIC});this.metadata_.title=a};shaka.cast.CastReceiver.prototype.setContentImage=function(a){this.metadata_||(this.metadata_={metadataType:cast.receiver.media.MetadataType.GENERIC});this.metadata_.images=[{url:a}]};
shaka.cast.CastReceiver.prototype.setContentArtist=function(a){this.metadata_||(this.metadata_={});this.metadata_.artist=a;this.metadata_.metadataType=cast.receiver.media.MetadataType.MUSIC_TRACK};
shaka.cast.CastReceiver.prototype.destroy=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return a.eventManager_&&(a.eventManager_.release(),a.eventManager_=null),b=[],a.player_&&(b.push(a.player_.destroy()),a.player_=null),a.pollTimer_&&(a.pollTimer_.stop(),a.pollTimer_=null),a.video_=null,a.targets_=null,a.appDataCallback_=null,a.isConnected_=!1,a.isIdle_=!0,a.shakaBus_=null,a.genericBus_=null,shaka.util.FakeEventTarget.prototype.release.call(a),
d.yield(Promise.all(b),2);c=cast.receiver.CastReceiverManager.getInstance();c.stop();d.jumpToEnd()})};
shaka.cast.CastReceiver.prototype.init_=function(){var a=this,b=cast.receiver.CastReceiverManager.getInstance();b.onSenderConnected=function(){return a.onSendersChanged_()};b.onSenderDisconnected=function(){return a.onSendersChanged_()};b.onSystemVolumeChanged=function(){return a.fakeVolumeChangeEvent_()};this.genericBus_=b.getCastMessageBus(shaka.cast.CastUtils.GENERIC_MESSAGE_NAMESPACE);this.genericBus_.onMessage=function(e){return a.onGenericMessage_(e)};this.shakaBus_=b.getCastMessageBus(shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE);
this.shakaBus_.onMessage=function(e){return a.onShakaMessage_(e)};goog.DEBUG?shaka.device.DeviceFactory.getDevice().getDeviceType()===shaka.device.IDevice.DeviceType.CAST&&b.start():b.start();b=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoEvents);for(var c=b.next();!c.done;c=b.next())this.eventManager_.listen(this.video_,c.value,function(e){return a.proxyEvent_("video",e)});for(var d in shaka.util.FakeEvent.EventName)this.eventManager_.listen(this.player_,shaka.util.FakeEvent.EventName[d],function(e){return a.proxyEvent_("player",
e)});this.eventManager_.listen(this.video_,"loadeddata",function(){a.startUpdatingUpdateNumber_=!0});this.eventManager_.listen(this.player_,"loading",function(){a.isIdle_=!1;a.onCastStatusChanged_()});this.eventManager_.listen(this.video_,"playing",function(){a.isIdle_=!1;a.onCastStatusChanged_()});this.eventManager_.listen(this.video_,"pause",function(){a.onCastStatusChanged_()});this.eventManager_.listen(this.player_,"unloading",function(){a.isIdle_=!0;a.onCastStatusChanged_()});this.eventManager_.listen(this.video_,
"ended",function(){(new shaka.util.Timer(function(){a.video_&&a.video_.ended&&(a.isIdle_=!0,a.onCastStatusChanged_())})).tickAfter(shaka.cast.CastReceiver.IDLE_INTERVAL)})};shaka.cast.CastReceiver.prototype.onSendersChanged_=function(){this.updateNumber_=0;this.initialStatusUpdatePending_=!0;this.isConnected_=cast.receiver.CastReceiverManager.getInstance().getSenders().length!=0;this.onCastStatusChanged_()};
shaka.cast.CastReceiver.prototype.onCastStatusChanged_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.yield(Promise.resolve(),2);if(!a.player_)return c.return();b=new shaka.util.FakeEvent("caststatuschanged");a.dispatchEvent(b);a.maybeSendMediaInfoMessage_()||a.sendMediaStatus_();c.jumpToEnd()})};
shaka.cast.CastReceiver.prototype.initState_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){switch(D.getNextAddressJsc()){case 1:for(d in a.player)e=a.player[d],c.player_[d](e);c.appDataCallback_(b);f=c.video_.autoplay;return a.manifest?(c.video_.autoplay=!1,D.setCatchFinallyBlocks(5),D.yield(c.player_.load(a.manifest,a.startTime),7)):D.yield(Promise.resolve(),3);case 7:if(a.addThumbnailsTrackCalls)for(g=(0,$jscomp.makeIterator)(a.addThumbnailsTrackCalls),
h=g.next();!h.done;h=g.next())k=h.value,c.player_.addThumbnailsTrack.apply(c.player_,(0,$jscomp.arrayFromIterable)(k));if(a.addTextTrackAsyncCalls)for(l=(0,$jscomp.makeIterator)(a.addTextTrackAsyncCalls),m=l.next();!m.done;m=l.next())n=m.value,c.player_.addTextTrackAsync.apply(c.player_,(0,$jscomp.arrayFromIterable)(n));if(a.addChaptersTrackCalls)for(p=(0,$jscomp.makeIterator)(a.addChaptersTrackCalls),q=p.next();!q.done;q=p.next())r=q.value,c.player_.addChaptersTrack.apply(c.player_,(0,$jscomp.arrayFromIterable)(r));
D.leaveTryBlock(3);break;case 5:return t=D.enterCatchBlock(),goog.asserts.assert(t instanceof shaka.util.Error,"Wrong error type! Error: "+t),u=shaka.util.FakeEvent.EventName.Error,w=(new Map).set("detail",t),v=new shaka.util.FakeEvent(u,w),c.player_&&c.player_.dispatchEvent(v),D.return();case 3:if(!c.player_)return D.return();for(x in a.video)y=a.video[x],c.video_[x]=y;for(A in a.playerAfterLoad)B=a.playerAfterLoad[A],c.player_[A](B);c.video_.autoplay=f;a.manifest&&(c.video_.play(),c.sendMediaStatus_());
D.jumpToEnd()}})};shaka.cast.CastReceiver.prototype.proxyEvent_=function(a,b){this.player_&&(this.pollAttributes_(),this.sendMessage_({type:"event",targetName:a,event:b},this.shakaBus_))};
shaka.cast.CastReceiver.prototype.pollAttributes_=function(){var a=this;this.pollTimer_.tickAfter(shaka.cast.CastReceiver.POLL_INTERVAL);for(var b={video:{},player:{}},c=(0,$jscomp.makeIterator)(shaka.cast.CastUtils.VideoAttributes),d=c.next();!d.done;d=c.next())d=d.value,b.video[d]=this.video_[d];this.player_.isLive()&&shaka.cast.CastUtils.PlayerGetterMethodsThatRequireLive.forEach(function(e,f){a.updateNumber_%e==0&&(b.player[f]=a.player_[f]())});shaka.cast.CastUtils.PlayerGetterMethods.forEach(function(e,
f){a.updateNumber_%e==0&&(b.player[f]=a.player_[f]())});if(c=cast.receiver.CastReceiverManager.getInstance().getSystemVolume())b.video.volume=c.level,b.video.muted=c.muted;this.sendMessage_({type:"update",update:b},this.shakaBus_);shaka.cast.CastUtils.LargePlayerGetterMethods.forEach(function(e,f){a.updateNumber_%e==0&&(e={player:{}},e.player[f]=a.player_[f](),a.sendMessage_({type:"update",update:e},a.shakaBus_))});this.startUpdatingUpdateNumber_&&(this.updateNumber_+=1);this.maybeSendMediaInfoMessage_()};
shaka.cast.CastReceiver.prototype.maybeSendMediaInfoMessage_=function(){return this.initialStatusUpdatePending_&&(this.video_.duration||this.player_.isLive())?(this.sendMediaInfoMessage_(),this.initialStatusUpdatePending_=!1,!0):!1};
shaka.cast.CastReceiver.prototype.sendMediaInfoMessage_=function(a){a=a===void 0?0:a;var b={contentId:this.player_.getAssetUri(),streamType:this.player_.isLive()?"LIVE":"BUFFERED",contentType:""};this.player_.isLive()||(b.duration=this.video_.duration);this.metadata_&&(b.metadata=this.metadata_);this.sendMediaStatus_(a,b)};
shaka.cast.CastReceiver.prototype.fakeVolumeChangeEvent_=function(){var a=cast.receiver.CastReceiverManager.getInstance().getSystemVolume();goog.asserts.assert(a,"System volume should not be null!");a&&this.sendMessage_({type:"update",update:{video:{volume:a.level,muted:a.muted}}},this.shakaBus_);this.sendMessage_({type:"event",targetName:"video",event:{type:"volumechange"}},this.shakaBus_)};
shaka.cast.CastReceiver.prototype.onShakaMessage_=function(a){var b=this,c=shaka.cast.CastUtils.deserialize(a.data);shaka.log.debug("CastReceiver: message",c);switch(c.type){case "init":this.updateNumber_=0;this.startUpdatingUpdateNumber_=!1;this.initialStatusUpdatePending_=!0;this.initState_(c.initState,c.appData);this.pollAttributes_();break;case "appData":this.appDataCallback_(c.appData);break;case "set":var d=c.targetName,e=c.property;c=c.value;if(d=="video")if(a=cast.receiver.CastReceiverManager.getInstance(),
e=="volume"){a.setSystemVolumeLevel(c);break}else if(e=="muted"){a.setSystemVolumeMuted(c);break}this.targets_[d][e]=c;break;case "call":d=this.targets_[c.targetName];d[c.methodName].apply(d,c.args);break;case "asyncCall":d=c.targetName;e=c.methodName;d=="player"&&e=="load"&&(this.updateNumber_=0,this.startUpdatingUpdateNumber_=!1);var f=c.id,g=a.senderId;a=this.targets_[d];c=a[e].apply(a,c.args);d=="player"&&e=="load"&&(c=c.then(function(){b.initialStatusUpdatePending_=!0}));c.then(function(h){return b.sendAsyncComplete_(g,
f,null,h)},function(h){return b.sendAsyncComplete_(g,f,h,null)})}};
shaka.cast.CastReceiver.prototype.onGenericMessage_=function(a){var b=this,c=shaka.cast.CastUtils.deserialize(a.data);shaka.log.debug("CastReceiver: message",c);switch(c.type){case "PLAY":this.video_.play();this.sendMediaStatus_();break;case "PAUSE":this.video_.pause();this.sendMediaStatus_();break;case "SEEK":a=c.currentTime;var d=c.resumeState;a!=null&&(this.video_.currentTime=Number(a));d&&d=="PLAYBACK_START"?(this.video_.play(),this.sendMediaStatus_()):d&&d=="PLAYBACK_PAUSE"&&(this.video_.pause(),
this.sendMediaStatus_());break;case "STOP":this.player_.unload().then(function(){b.player_&&b.sendMediaStatus_()});break;case "GET_STATUS":this.sendMediaInfoMessage_(Number(c.requestId));break;case "VOLUME":d=c.volume;a=d.level;d=d.muted;var e=this.video_.volume,f=this.video_.muted;a!=null&&(this.video_.volume=Number(a));d!=null&&(this.video_.muted=d);e==this.video_.volume&&f==this.video_.muted||this.sendMediaStatus_();break;case "LOAD":this.updateNumber_=0;this.initialStatusUpdatePending_=this.startUpdatingUpdateNumber_=
!1;a=c.media;d=c.currentTime;e=this.contentIdCallback_(a.contentId);f=c.autoplay||!0;this.appDataCallback_(a.customData);f&&(this.video_.autoplay=!0);this.player_.load(e,d).then(function(){b.player_&&b.sendMediaInfoMessage_()}).catch(function(g){goog.asserts.assert(g instanceof shaka.util.Error,"Wrong error type!");var h="LOAD_FAILED";g.category==shaka.util.Error.Category.PLAYER&&g.code==shaka.util.Error.Code.LOAD_INTERRUPTED&&(h="LOAD_CANCELLED");b.sendMessage_({requestId:Number(c.requestId),type:h},
b.genericBus_)});break;default:shaka.log.warning("Unrecognized message type from the generic Chromecast controller!",c.type),this.sendMessage_({requestId:Number(c.requestId),type:"INVALID_REQUEST",reason:"INVALID_COMMAND"},this.genericBus_)}};shaka.cast.CastReceiver.prototype.sendAsyncComplete_=function(a,b,c,d){this.player_&&this.sendMessage_({type:"asyncComplete",id:b,error:c,res:d},this.shakaBus_,a)};
shaka.cast.CastReceiver.prototype.sendMessage_=function(a,b,c){this.isConnected_&&(a=shaka.cast.CastUtils.serialize(a),c?b.getCastChannel(c).send(a):b.broadcast(a))};shaka.cast.CastReceiver.prototype.getPlayState_=function(){var a=shaka.cast.CastReceiver.PLAY_STATE;return this.isIdle_?a.IDLE:this.player_.isBuffering()?a.BUFFERING:this.video_.paused?a.PAUSED:a.PLAYING};
shaka.cast.CastReceiver.prototype.sendMediaStatus_=function(a,b){a=a===void 0?0:a;b=b===void 0?null:b;var c={mediaSessionId:0,playbackRate:this.video_.playbackRate,playerState:this.getPlayState_(),currentTime:this.video_.currentTime,supportedMediaCommands:63,volume:{level:this.video_.volume,muted:this.video_.muted}};b&&(c.media=b);this.sendMessage_({requestId:a,type:"MEDIA_STATUS",status:[c]},this.genericBus_)};goog.exportSymbol("shaka.cast.CastReceiver",shaka.cast.CastReceiver);
goog.exportProperty(shaka.cast.CastReceiver.prototype,"destroy",shaka.cast.CastReceiver.prototype.destroy);goog.exportProperty(shaka.cast.CastReceiver.prototype,"setContentArtist",shaka.cast.CastReceiver.prototype.setContentArtist);goog.exportProperty(shaka.cast.CastReceiver.prototype,"setContentImage",shaka.cast.CastReceiver.prototype.setContentImage);goog.exportProperty(shaka.cast.CastReceiver.prototype,"setContentTitle",shaka.cast.CastReceiver.prototype.setContentTitle);
goog.exportProperty(shaka.cast.CastReceiver.prototype,"clearContentMetadata",shaka.cast.CastReceiver.prototype.clearContentMetadata);goog.exportProperty(shaka.cast.CastReceiver.prototype,"setContentMetadata",shaka.cast.CastReceiver.prototype.setContentMetadata);goog.exportProperty(shaka.cast.CastReceiver.prototype,"isIdle",shaka.cast.CastReceiver.prototype.isIdle);goog.exportProperty(shaka.cast.CastReceiver.prototype,"isConnected",shaka.cast.CastReceiver.prototype.isConnected);
shaka.cast.CastReceiver.POLL_INTERVAL=.5;shaka.cast.CastReceiver.IDLE_INTERVAL=5;shaka.cast.CastReceiver.PLAY_STATE={IDLE:"IDLE",PLAYING:"PLAYING",BUFFERING:"BUFFERING",PAUSED:"PAUSED"};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(y){return y!=null&&y.getChar().trim()!=""})){f=h;break}for(h=c.length-1;h>=0;h--)if(c[h].some(function(y){return y!=null&&y.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 u=t.isUnderlined(),w=t.isItalicized(),v=t.getTextColor(),x=t.getBackgroundColor();if(u!=h||w!=k||v!=l||x!=m)n.payload&&a.nestedCues.push(n),n=shaka.cea.CeaUtils.createStyledCue(d,e,u,w,v,x),h=u,k=w,l=v,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.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.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=[];(new c).boxes("moov trak mdia minf stbl mvex".split(" "),c.children).fullBox("trex",function(g){g=shaka.util.Mp4BoxParsers.parseTREX(g.reader);b.defaultSampleDuration_=g.defaultSampleDuration;b.defaultSampleSize_=g.defaultSampleSize}).fullBox("tkhd",function(g){goog.asserts.assert(g.version!=null,"TKHD is a full box and should have a valid version.");g=shaka.util.Mp4BoxParsers.parseTKHD(g.reader,
g.version);e.push(g.trackId)}).fullBox("mdhd",function(g){goog.asserts.assert(g.version!=null,"MDHD is a full box and should have a valid version.");g=shaka.util.Mp4BoxParsers.parseMDHD(g.reader,g.version);f.push(g.timescale)}).fullBox("stsd",c.sampleDescription).boxes("avc1 avc3 dvav dva1 hev1 hvc1 dvh1 dvhe vvc1 vvi1 dvc1 dvi1".split(" "),function(g){return b.setBitstreamFormat_(g.name)}).box("encv",c.visualSampleEntry).box("sinf",c.children).box("frma",function(g){g=shaka.util.Mp4BoxParsers.parseFRMA(g.reader).codec;
b.setBitstreamFormat_(g)}).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(g,h){b.trackIdToTimescale_.set(g,f[h])})};
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});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.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.dash={};shaka.dash.ContentProtection=function(){this.psshToInitData_=new Map};shaka.dash.ContentProtection.prototype.release=function(){this.psshToInitData_.clear()};
shaka.dash.ContentProtection.prototype.parseFromAdaptationSet=function(a,b,c){var d=shaka.dash.ContentProtection,e=shaka.util.ManifestParserUtils,f=this.parseElements_(a),g=null;a=[];var h=[],k=null,l=new Set(f.map(function(n){return n.keyId}));l.delete(null);var m="cenc";if(l.size>1)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_CONFLICTING_KEY_IDS);if(!b){h=f.filter(function(n){return n.schemeUri==d.Aes128Protection_});
if(h.length>1)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_CONFLICTING_AES_128);h.length&&(k=d.parseAes128_(h[0]));(h=f.find(function(n){return n.schemeUri==d.MP4Protection_}))&&h.encryptionScheme&&(m=h.encryptionScheme);h=f.filter(function(n){return n.schemeUri==d.MP4Protection_?(goog.asserts.assert(!n.init||n.init.length,"Init data must be null or non-empty."),g=n.init||g,!1):n.schemeUri!=d.Aes128Protection_});h.length&&
(a=d.convertElements_(g,m,h,c,l),a.length==0&&(a=[e.createDrmInfo("",m,g)]))}if(f.length&&!k&&(b||!h.length))for(a=[],b=(0,$jscomp.makeIterator)(Object.values(c)),c=b.next();!c.done;c=b.next())c=c.value,shaka.drm.DrmUtils.isClearKeySystem(c)||(c=e.createDrmInfo(c,m,g),a.push(c));if(e=Array.from(l)[0]||null)for(l=(0,$jscomp.makeIterator)(a),m=l.next();!m.done;m=l.next())for(m=(0,$jscomp.makeIterator)(m.value.initData),b=m.next();!b.done;b=m.next())b.value.keyId=e;return{defaultKeyId:e,defaultInit:g,
drmInfos:a,aes128Info:k,firstRepresentation:!0}};
shaka.dash.ContentProtection.prototype.parseFromRepresentation=function(a,b,c,d){var e=this.parseFromAdaptationSet(a,c,d);if(b.firstRepresentation){a=b.drmInfos.length==1&&!b.drmInfos[0].keySystem;c=e.drmInfos.length==0;if(b.drmInfos.length==0||a&&!c)b.drmInfos=e.drmInfos;b.firstRepresentation=!1}else if(e.drmInfos.length>0&&(b.drmInfos=b.drmInfos.filter(function(f){return e.drmInfos.some(function(g){return g.keySystem==f.keySystem})}),b.drmInfos.length==0))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_COMMON_KEY_SYSTEM);return e.defaultKeyId||b.defaultKeyId};
shaka.dash.ContentProtection.getFairPlayLicenseUrl=function(a){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.DASH_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);if(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl"))if(a=shaka.util.TXml.getTextContents(a))return a;return""};
shaka.dash.ContentProtection.getWidevineLicenseUrl=function(a){var b=shaka.util.StringUtils,c=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");return c&&(c=shaka.util.TXml.getTextContents(c))?c:(a=shaka.util.TXml.findChildNS(a.node,"urn:microsoft","laurl"))?b.htmlUnescape(a.attributes.licenseUrl)||"":""};
shaka.dash.ContentProtection.getClearKeyLicenseUrl=function(a){var b=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");return b&&(b=shaka.util.TXml.getTextContents(b))?b:(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.ClearKeyNamespaceUri_,"Laurl"))&&a.attributes.Lic_type==="EME-1.0"&&a&&(a=shaka.util.TXml.getTextContents(a))?a:""};
shaka.dash.ContentProtection.getPlayReadyLicenseUrl=function(a){var b=shaka.util.TXml,c=b.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");if(c&&(c=b.getTextContents(c)))return c;if((c=b.findChildNS(a.node,"urn:microsoft:playready","pro"))&&b.getTextContents(c))return shaka.drm.PlayReady.getLicenseUrl(c);if(a=b.findChildNS(a.node,shaka.dash.ContentProtection.CencNamespaceUri_,"pssh"))if(a=b.getTextContents(a))return a=shaka.util.Pssh.getPsshData(shaka.util.Uint8ArrayUtils.fromBase64(a)),
a=shaka.util.Uint8ArrayUtils.toStandardBase64(a),b=b.parseXmlString("<pro>"+a+"</pro>"),goog.asserts.assert(b,"Must have pro node"),shaka.drm.PlayReady.getLicenseUrl(b);return""};
shaka.dash.ContentProtection.getInitDataFromPro_=function(a){var b=shaka.util.TXml.findChildNS(a.node,"urn:microsoft:playready","pro");if(!b||!shaka.util.TXml.getTextContents(b))return null;var c=shaka.util.Uint8ArrayUtils;b=shaka.util.TXml.getTextContents(b);c=c.fromBase64(b);b=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);var d=new Set;return[{initData:shaka.util.Pssh.createPssh(c,b,d,0),initDataType:"cenc",keyId:a.keyId}]};
shaka.dash.ContentProtection.getInitDataClearKey_=function(a,b){if(b.size==0)return null;var c=new Uint8Array([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75]),d=new Uint8Array([]);return[{initData:shaka.util.Pssh.createPssh(d,c,b,1),initDataType:"cenc",keyId:a.keyId}]};
shaka.dash.ContentProtection.convertElements_=function(a,b,c,d,e){var f=shaka.dash.ContentProtection,g=shaka.util.ManifestParserUtils,h=f.licenseUrlParsers_,k=[];c=(0,$jscomp.makeIterator)(c);for(var l=c.next();!l.done;l=c.next()){l=l.value;var m=d[l.schemeUri];if(m){goog.asserts.assert(!l.init||l.init.length,"Init data must be null or non-empty.");var n=f.getInitDataFromPro_(l),p=null;l.schemeUri===shaka.dash.ContentProtection.ClearKeySchemeUri_&&(p=f.getInitDataClearKey_(l,e));n=g.createDrmInfo(m,
b,l.init||a||n||p);if(m=h.get(m))n.licenseServerUri=m(l);n.serverCertificateUri=f.getServerCertificateUri(l);k.push(n)}}return k};shaka.dash.ContentProtection.getServerCertificateUri=function(a){if(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Certurl"))if(a=shaka.util.TXml.getTextContents(a))return a;return""};
shaka.dash.ContentProtection.prototype.parseElements_=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())(c=this.parseElement_(c.value))&&b.push(c);return b};
shaka.dash.ContentProtection.prototype.parseElement_=function(a){var b=this,c=shaka.dash.ContentProtection.CencNamespaceUri_,d=shaka.util.TXml,e=a.attributes.schemeIdUri,f=d.getAttributeNS(a,c,"default_KID");c=d.findChildrenNS(a,c,"pssh").map(d.getContents);d=a.attributes.value;if(!e)return shaka.log.error("Missing required schemeIdUri attribute on","ContentProtection element",a),null;e=e.toLowerCase();if(f&&(f=f.replace(/-/g,"").toLowerCase(),f.includes(" ")))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED);var g=[];try{g=c.map(function(h){if(!b.psshToInitData_.has(h)){var k=shaka.util.Uint8ArrayUtils.fromBase64(h);b.psshToInitData_.set(h,k)}return{initDataType:"cenc",initData:b.psshToInitData_.get(h),keyId:null}})}catch(h){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_PSSH_BAD_ENCODING);}return{node:a,schemeUri:e,keyId:f,init:g.length>
0?g:null,encryptionScheme:d}};
shaka.dash.ContentProtection.parseAes128_=function(a){if(!window.crypto||!window.crypto.subtle)throw shaka.log.alwaysWarn("Web Crypto API is not available to decrypt AES-128. (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 b=shaka.util.TXml.findChildNS(a.node,"urn:mpeg:dash:schema:sea:2012","SegmentEncryption");if(!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);if(b.attributes.schemeIdUri!="urn:mpeg:dash:sea:aes128-cbc:2013")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);b=shaka.util.TXml.findChildNS(a.node,"urn:mpeg:dash:schema:sea:2012","CryptoPeriod");if(!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);a=b.attributes.IV;
b=shaka.util.StringUtils.htmlUnescape(b.attributes.keyUriTemplate);if(!a||!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);a=shaka.util.Uint8ArrayUtils.fromHex(a.substr(2));if(a.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);return{keyUri:b,iv:a}};
shaka.dash.ContentProtection.licenseUrlParsers_=(new Map).set("com.apple.fps",shaka.dash.ContentProtection.getFairPlayLicenseUrl).set("com.widevine.alpha",shaka.dash.ContentProtection.getWidevineLicenseUrl).set("com.microsoft.playready",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.recommendation",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.software",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.hardware",
shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("org.w3.clearkey",shaka.dash.ContentProtection.getClearKeyLicenseUrl);shaka.dash.ContentProtection.MP4Protection_="urn:mpeg:dash:mp4protection:2011";shaka.dash.ContentProtection.Aes128Protection_="urn:mpeg:dash:sea:2012";shaka.dash.ContentProtection.CencNamespaceUri_="urn:mpeg:cenc:2013";shaka.dash.ContentProtection.ClearKeyNamespaceUri_="http://dashif.org/guidelines/clearKey";shaka.dash.ContentProtection.ClearKeySchemeUri_="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e";
shaka.dash.ContentProtection.DashIfNamespaceUri_="https://dashif.org/CPS";shaka.dash.MpdUtils=function(){};
shaka.dash.MpdUtils.fillUriTemplate=function(a,b,c,d,e,f){var g=(new Map).set("RepresentationID",b).set("Number",c).set("SubNumber",d).set("Bandwidth",e).set("Time",f);return a.replace(/\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g,function(h,k,l,m){if(h=="$$")return"$";var n=g.get(k);goog.asserts.assert(n!==void 0,"Unrecognized identifier");if(n==null)return shaka.log.warning("URL template does not have an available substitution for ",'identifier "'+k+'":',a),
h;k=="RepresentationID"&&l&&(shaka.log.warning("URL template should not contain a width specifier for identifier",'"RepresentationID":',a),l=void 0);k=="Time"&&typeof n!="bigint"&&(goog.asserts.assert(typeof n=="number","Time value should be a number or bigint!"),Math.abs(n-Math.round(n))>=.2&&shaka.log.alwaysWarn("Calculated $Time$ values must be close to integers"),n=Math.round(n));switch(m){case void 0:case "d":case "i":case "u":h=n.toString();break;case "o":h=n.toString(8);break;case "x":h=n.toString(16);
break;case "X":h=n.toString(16).toUpperCase();break;default:goog.asserts.assert(!1,"Unhandled format specifier"),h=n.toString()}l=window.parseInt(l,10)||1;return Array(Math.max(0,l-h.length)+1).join("0")+h})};
shaka.dash.MpdUtils.createTimeline=function(a,b,c,d,e){goog.asserts.assert(b>0&&b<Infinity,"timescale must be a positive, finite integer");goog.asserts.assert(d>0,"period duration must be a positive integer");for(var f=shaka.util.TXml,g=[],h=-c,k=0;k<a.length;++k){var l=a[k],m=a[k+1],n=f.parseAttr(l,"t",f.parseNonNegativeInt),p=f.parseAttr(l,"d",f.parseNonNegativeInt),q=f.parseAttr(l,"r",f.parseInt),r=f.parseAttr(l,"k",f.parseInt)||0;n!=null&&(n-=c);if(p){n=n!=null?n:h;q=q||0;if(q<0)if(m){m=f.parseAttr(m,
"t",f.parseNonNegativeInt);if(m==null){shaka.log.warning('An "S" element cannot have a negative repeat','if the next "S" element does not have a valid start time:','ignoring the remaining "S" elements.',l);break}else if(n>=m){shaka.log.warning('An "S" element cannot have a negative repeat if its start ','time exceeds the next "S" element\'s start time:','ignoring the remaining "S" elements.',l);break}q=Math.ceil((m-n)/p)-1}else{if(d==Infinity){shaka.log.warning('The last "S" element cannot have a negative repeat',
"if the Period has an infinite duration:",'ignoring the last "S" element.',l);break}else if(n/b>=d){shaka.log.warning('The last "S" element cannot have a negative repeat',"if its start time exceeds the Period's duration:",'ignoring the last "S" element.',l);break}q=Math.ceil((d*b-n)/p)-1}g.length>0&&n!=h&&(Math.abs((n-h)/b)>=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&shaka.log.warning("SegmentTimeline contains a large gap/overlap:","the content may have errors in it.",l),g[g.length-
1].end=n/b);for(l=0;l<=q;++l)h=n+p,g.push({start:n/b,unscaledStart:n,end:h/b,unscaledEnd:h,partialSegments:r,segmentPosition:g.length+e}),n=h}else shaka.log.warning('"S" element must have a duration: ignoring this element.',l)}return g};
shaka.dash.MpdUtils.parseSegmentInfo=function(a,b){goog.asserts.assert(b(a.representation),"There must be at least one element of the given type.");var c=shaka.dash.MpdUtils,d=shaka.util.TXml,e=c.inheritAttribute(a,b,"timescale"),f=1;e&&(f=d.parsePositiveInt(e)||1);e=c.inheritAttribute(a,b,"duration");var g=(e=d.parsePositiveInt(e||""))?e/f:null,h=c.inheritAttribute(a,b,"startNumber"),k=Number(c.inheritAttribute(a,b,"presentationTimeOffset"))||0,l=d.parseNonNegativeInt(h||"");if(h==null||l==null)l=
1;h=null;if(b=c.inheritChild(a,b,"SegmentTimeline"))d=d.findChildren(b,"S"),h=c.createTimeline(d,f,k,a.periodInfo.duration||Infinity,l);return{timescale:f,unscaledSegmentDuration:e,segmentDuration:g,startNumber:l,scaledPresentationTimeOffset:k/f||0,unscaledPresentationTimeOffset:k,timeline:h}};
shaka.dash.MpdUtils.getNodes=function(a,b){var c=shaka.util.Functional;goog.asserts.assert(b(a.representation),"There must be at least one element of the given type.");return[b(a.representation),b(a.adaptationSet),b(a.period)].filter(c.isNotNull)};shaka.dash.MpdUtils.inheritAttribute=function(a,b,c){b=shaka.dash.MpdUtils.getNodes(a,b);a=null;b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done&&!(a=d.value.attributes[c]);d=b.next());return a};
shaka.dash.MpdUtils.inheritChild=function(a,b,c){var d=shaka.dash.MpdUtils.getNodes(a,b);a=shaka.util.TXml;b=null;d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done&&!(b=a.findChild(e.value,c));e=d.next());return b};
shaka.dash.MpdUtils.handleXlinkInElement_=function(a,b,c,d,e,f){for(var g=shaka.util.TXml,h=shaka.util.Error,k=shaka.util.ManifestParserUtils,l=shaka.dash.MpdUtils.XlinkNamespaceUri_,m=g.getAttributeNS(a,l,"href"),n=g.getAttributeNS(a,l,"actuate")||"onRequest",p=(0,$jscomp.makeIterator)(Object.keys(a.attributes)),q=p.next();!q.done;q=p.next()){q=q.value;var r=q.split(":"),t=shaka.util.TXml.getKnownNameSpace(l);r[0]==t&&delete a.attributes[q]}if(f>=5)return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,
h.Category.MANIFEST,h.Code.DASH_XLINK_DEPTH_LIMIT));if(n!="onLoad")return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,h.Category.MANIFEST,h.Code.DASH_UNSUPPORTED_XLINK_ACTUATE));var u=k.resolveUris([d],[m]);d=shaka.net.NetworkingEngine.RequestType.MANIFEST;k=shaka.net.NetworkingEngine.makeRequest(u,b);d=e.request(d,k);goog.asserts.assert(d instanceof shaka.util.AbortableOperation,"Unexpected implementation of IAbortableOperation!");return d.chain(function(w){w=g.parseXml(w.data,
a.tagName);if(!w)return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,h.Category.MANIFEST,h.Code.DASH_INVALID_XML,m));for(a.children=[];w.children.length;){var v=w.children.shift();a.children.push(v)}v=(0,$jscomp.makeIterator)(Object.keys(w.attributes));for(var x=v.next();!x.done;x=v.next())x=x.value,a.attributes[x]=w.attributes[x];return shaka.dash.MpdUtils.processXlinks(a,b,c,u[0],e,f+1)})};
shaka.dash.MpdUtils.processXlinks=function(a,b,c,d,e,f){f=f===void 0?0:f;var g=shaka.dash.MpdUtils,h=shaka.util.TXml,k=g.XlinkNamespaceUri_;if(h.getAttributeNS(a,k,"href"))return h=g.handleXlinkInElement_(a,b,c,d,e,f),c&&(h=h.chain(void 0,function(q){return g.processXlinks(a,b,c,d,e,f)})),h;for(var l=[],m=(0,$jscomp.makeIterator)(shaka.util.TXml.getChildNodes(a)),n=m.next(),p={};!n.done;p={child$jscomp$10:void 0},n=m.next())p.child$jscomp$10=n.value,h.getAttributeNS(p.child$jscomp$10,k,"href")=="urn:mpeg:dash:resolve-to-zero:2013"?
a.children=a.children.filter(function(q){return function(r){return r!==q.child$jscomp$10}}(p)):p.child$jscomp$10.tagName!="SegmentTimeline"&&l.push(shaka.dash.MpdUtils.processXlinks(p.child$jscomp$10,b,c,d,e,f));return shaka.util.AbortableOperation.all(l).chain(function(){return a})};shaka.dash.MpdUtils.XlinkNamespaceUri_="http://www.w3.org/1999/xlink";shaka.dash.Mp4SegmentIndexParser=function(){};shaka.dash.Mp4SegmentIndexParser.parse=function(a,b,c,d,e,f,g,h){var k=shaka.dash.Mp4SegmentIndexParser,l,m=(new shaka.util.Mp4Parser).fullBox("sidx",function(n){l=k.parseSIDX_(b,d,e,f,g,c,n,h)});a&&m.parse(a);if(l)return l;shaka.log.error('Invalid box type, expected "sidx".');throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_WRONG_BOX_TYPE);};
shaka.dash.Mp4SegmentIndexParser.parseSIDX_=function(a,b,c,d,e,f,g,h){h=h===void 0?!1:h;goog.asserts.assert(g.version!=null,"SIDX is a full box and should have a valid version.");var k=[];g.reader.skip(4);var l=g.reader.readUint32();if(l==0)throw shaka.log.error("Invalid timescale."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_INVALID_TIMESCALE);if(g.version==0){var m=g.reader.readUint32();var n=g.reader.readUint32()}else m=
g.reader.readUint64(),n=g.reader.readUint64();g.reader.skip(2);var p=g.reader.readUint16();a=(h?-g.size:a)+g.size+n;for(h=0;h<p;h++){var q=g.reader.readUint32();n=(q&2147483648)>>>31;q&=2147483647;var r=g.reader.readUint32();g.reader.skip(4);if(n==1)throw shaka.log.error("Hierarchical SIDXs are not supported."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_TYPE_NOT_SUPPORTED);k.push(new shaka.media.SegmentReference(m/l+c,(m+
r)/l+c,function(){return f},a,a+q-1,b,c,d,e));m+=r;a+=q}g.parser.stop();return k};shaka.dash.EbmlParser=function(a){this.dataView_=shaka.util.BufferUtils.toDataView(a);this.reader_=new shaka.util.DataViewReader(this.dataView_,shaka.util.DataViewReader.Endianness.BIG_ENDIAN)};shaka.dash.EbmlParser.prototype.hasMoreData=function(){return this.reader_.hasMoreData()};
shaka.dash.EbmlParser.prototype.parseElement=function(){var a=this.parseId_(),b=this.parseVint_();b=shaka.dash.EbmlParser.isDynamicSizeValue_(b)?this.dataView_.byteLength-this.reader_.getPosition():shaka.dash.EbmlParser.getVintValue_(b);b=this.reader_.getPosition()+b<=this.dataView_.byteLength?b:this.dataView_.byteLength-this.reader_.getPosition();var c=shaka.util.BufferUtils.toDataView(this.dataView_,this.reader_.getPosition(),b);this.reader_.skip(b);return new shaka.util.EbmlElement(a,c)};
shaka.dash.EbmlParser.prototype.parseId_=function(){var a=this.parseVint_();if(a.length>7)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);var b=0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())b=256*b+c.value;return b};
shaka.dash.EbmlParser.prototype.parseVint_=function(){var a=this.reader_.getPosition(),b=this.reader_.readUint8();if(b==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);b=8-Math.floor(Math.log2(b));goog.asserts.assert(b<=8&&b>=1,"Incorrect log2 value");this.reader_.skip(b-1);return shaka.util.BufferUtils.toUint8(this.dataView_,a,b)};
shaka.dash.EbmlParser.getVintValue_=function(a){if(a.length==8&&a[1]&224)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);for(var b=0,c=0;c<a.length;c++){var d=a[c];b=c==0?d&(1<<8-a.length)-1:256*b+d}return b};
shaka.dash.EbmlParser.isDynamicSizeValue_=function(a){for(var b=shaka.util.BufferUtils,c=(0,$jscomp.makeIterator)(shaka.dash.EbmlParser.DYNAMIC_SIZES),d=c.next();!d.done;d=c.next())if(b.equal(a,new Uint8Array(d.value)))return!0;return!1};shaka.dash.EbmlParser.DYNAMIC_SIZES=[[255],[127,255],[63,255,255],[31,255,255,255],[15,255,255,255,255],[7,255,255,255,255,255],[3,255,255,255,255,255,255],[1,255,255,255,255,255,255,255]];shaka.util.EbmlElement=function(a,b){this.id=a;this.dataView_=b};
shaka.util.EbmlElement.prototype.getOffset=function(){return this.dataView_.byteOffset};shaka.util.EbmlElement.prototype.createParser=function(){return new shaka.dash.EbmlParser(this.dataView_)};
shaka.util.EbmlElement.prototype.getUint=function(){if(this.dataView_.byteLength>8)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);if(this.dataView_.byteLength==8&&this.dataView_.getUint8(0)&224)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);for(var a=0,b=0;b<this.dataView_.byteLength;b++){var c=this.dataView_.getUint8(b);a=256*
a+c}return a};shaka.util.EbmlElement.prototype.getFloat=function(){if(this.dataView_.byteLength==4)return this.dataView_.getFloat32(0);if(this.dataView_.byteLength==8)return this.dataView_.getFloat64(0);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_BAD_FLOATING_POINT_SIZE);};shaka.dash.WebmSegmentIndexParser=function(){};
shaka.dash.WebmSegmentIndexParser.parse=function(a,b,c,d,e,f,g){b=shaka.dash.WebmSegmentIndexParser.parseWebmContainer_(b);a=(new shaka.dash.EbmlParser(a)).parseElement();if(a.id!=shaka.dash.WebmSegmentIndexParser.CUES_ID)throw shaka.log.error("Not a Cues element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUES_ELEMENT_MISSING);return shaka.dash.WebmSegmentIndexParser.parseCues_(a,b.segmentOffset,b.timecodeScale,b.duration,
c,d,e,f,g)};
shaka.dash.WebmSegmentIndexParser.parseWebmContainer_=function(a){a=new shaka.dash.EbmlParser(a);if(a.parseElement().id!=shaka.dash.WebmSegmentIndexParser.EBML_ID)throw shaka.log.error("Not an EBML element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_EBML_HEADER_ELEMENT_MISSING);var b=a.parseElement();if(b.id!=shaka.dash.WebmSegmentIndexParser.SEGMENT_ID)throw shaka.log.error("Not a Segment element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.WEBM_SEGMENT_ELEMENT_MISSING);a=b.getOffset();b=shaka.dash.WebmSegmentIndexParser.parseSegment_(b);return{segmentOffset:a,timecodeScale:b.timecodeScale,duration:b.duration}};
shaka.dash.WebmSegmentIndexParser.parseSegment_=function(a){a=a.createParser();for(var b=null;a.hasMoreData();){var c=a.parseElement();if(c.id==shaka.dash.WebmSegmentIndexParser.INFO_ID){b=c;break}}if(!b)throw shaka.log.error("Not an Info element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_INFO_ELEMENT_MISSING);return shaka.dash.WebmSegmentIndexParser.parseInfo_(b)};
shaka.dash.WebmSegmentIndexParser.parseInfo_=function(a){var b=a.createParser(),c=1E6;for(a=null;b.hasMoreData();){var d=b.parseElement();d.id==shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID?c=d.getUint():d.id==shaka.dash.WebmSegmentIndexParser.DURATION_ID&&(a=d.getFloat())}if(a==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_DURATION_ELEMENT_MISSING);b=c/1E9;return{timecodeScale:b,duration:a*b}};
shaka.dash.WebmSegmentIndexParser.parseCues_=function(a,b,c,d,e,f,g,h,k){var l=[],m=function(){return e};a=a.createParser();for(var n=null,p=null;a.hasMoreData();){var q=a.parseElement();if(q.id==shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID){var r=shaka.dash.WebmSegmentIndexParser.parseCuePoint_(q);r&&(q=c*r.unscaledTime,r=b+r.relativeOffset,n!=null&&(goog.asserts.assert(p!=null,"last offset cannot be null"),l.push(new shaka.media.SegmentReference(n+g,q+g,m,p,r-1,f,g,h,k))),n=q,p=r)}}n!=null&&(goog.asserts.assert(p!=
null,"last offset cannot be null"),l.push(new shaka.media.SegmentReference(n+g,d+g,m,p,null,f,g,h,k)));return l};
shaka.dash.WebmSegmentIndexParser.parseCuePoint_=function(a){var b=a.createParser();a=b.parseElement();if(a.id!=shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID)throw shaka.log.warning("Not a CueTime element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUE_TIME_ELEMENT_MISSING);a=a.getUint();b=b.parseElement();if(b.id!=shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID)throw shaka.log.warning("Not a CueTrackPositions element."),
new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING);b=b.createParser();for(var c=0;b.hasMoreData();){var d=b.parseElement();if(d.id==shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION){c=d.getUint();break}}return{unscaledTime:a,relativeOffset:c}};shaka.dash.WebmSegmentIndexParser.EBML_ID=440786851;shaka.dash.WebmSegmentIndexParser.SEGMENT_ID=408125543;shaka.dash.WebmSegmentIndexParser.INFO_ID=357149030;
shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID=2807729;shaka.dash.WebmSegmentIndexParser.DURATION_ID=17545;shaka.dash.WebmSegmentIndexParser.CUES_ID=475249515;shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID=187;shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID=179;shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID=183;shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION=241;shaka.dash.SegmentBase=function(){};
shaka.dash.SegmentBase.createInitSegment=function(a,b,c){var d=shaka.util.TXml,e=shaka.util.ManifestParserUtils,f=shaka.util.StringUtils;b=shaka.dash.MpdUtils.inheritChild(a,b,"Initialization");if(!b)return null;var g=a.representation.getBaseUris(),h=b.attributes.sourceURL;h&&(g=e.resolveUris(g,[f.htmlUnescape(h)],a.urlParams()));e=0;f=null;if(d=d.parseAttr(b,"range",d.parseRange))e=d.start,f=d.end;d=shaka.dash.SegmentBase.createQualityInfo(a);c=new shaka.media.InitSegmentReference(function(){return g},e,
f,d,null,null,c,a.adaptationSet.encrypted);c.codecs=a.representation.codecs;c.mimeType=a.representation.mimeType;a.periodInfo&&!a.periodInfo.isLastPeriod&&(c.boundaryEnd=a.periodInfo.start+a.periodInfo.duration);return c};
shaka.dash.SegmentBase.createStreamInfo=function(a,b,c){goog.asserts.assert(a.representation.segmentBase,"Should only be called with SegmentBase");var d=shaka.dash.MpdUtils,e=shaka.dash.SegmentBase,f=shaka.util.TXml,g=Number(d.inheritAttribute(a,e.fromInheritance_,"presentationTimeOffset"))||0;d=d.inheritAttribute(a,e.fromInheritance_,"timescale");var h=1;d&&(h=f.parsePositiveInt(d)||1);var k=g/h||0,l=e.createInitSegment(a,e.fromInheritance_,c);e.checkSegmentIndexRangeSupport_(a,l);var m=shaka.util.ObjectUtils.shallowCloneObject(a);
return{endTime:-1,timeline:-1,generateSegmentIndex:function(){return e.generateSegmentIndex_(m,b,l,k)},timescale:h}};
shaka.dash.SegmentBase.generateSegmentIndexFromUris=function(a,b,c,d,e,f,g){var h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){if(G.getNextAddressJsc()==1)return h=a.presentationTimeline,k=!a.dynamic||!a.periodInfo.isLastPeriod,l=a.periodInfo.start,m=a.periodInfo.duration,n=a.representation.mimeType.split("/")[1],p=b,q=null,r=[p(d,e,f,!1),n=="webm"?p(c.getUris(),c.startByte,c.endByte,!0):null],p=null,G.yield(Promise.all(r),2);t=G.getYieldResultJsc();
u=t[0];w=t[1]||null;v=null;x=l-g;y=l;A=m?l+m:Infinity;B=a.representation.getBaseUris();D=B.length!=d.length||B.some(function(I,F){return I!=d[F]});n=="mp4"?v=shaka.dash.Mp4SegmentIndexParser.parse(u,e,B,c,x,y,A,D):(goog.asserts.assert(w,"WebM requires init data"),v=shaka.dash.WebmSegmentIndexParser.parse(u,w,B,c,x,y,A));z=(0,$jscomp.makeIterator)(v);for(C=z.next();!C.done;C=z.next())E=C.value,E.codecs=a.representation.codecs,E.mimeType=a.representation.mimeType,E.bandwidth=a.bandwidth;h.notifySegments(v);
goog.asserts.assert(!q,"Should not call generateSegmentIndex twice");q=new shaka.media.SegmentIndex(v);k&&q.fit(y,A,!0);return G.return(q)})};shaka.dash.SegmentBase.fromInheritance_=function(a){return a.segmentBase};
shaka.dash.SegmentBase.computeIndexRange_=function(a){var b=shaka.dash.MpdUtils,c=shaka.dash.SegmentBase,d=shaka.util.TXml,e=b.inheritChild(a,c.fromInheritance_,"RepresentationIndex");a=b.inheritAttribute(a,c.fromInheritance_,"indexRange");a=d.parseRange(a||"");e&&(a=d.parseAttr(e,"range",d.parseRange,a));return a};
shaka.dash.SegmentBase.computeIndexUris_=function(a){var b=shaka.util.ManifestParserUtils,c=shaka.util.StringUtils,d=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentBase.fromInheritance_,"RepresentationIndex"),e=a.representation.getBaseUris();d&&(c=c.htmlUnescape(d.attributes.sourceURL))&&(e=b.resolveUris(e,[c],a.urlParams()));return e};
shaka.dash.SegmentBase.checkSegmentIndexRangeSupport_=function(a,b){var c=shaka.dash.SegmentBase;c.checkSegmentIndexSupport(a,b);if(!c.computeIndexRange_(a))throw shaka.log.error("SegmentBase does not contain sufficient segment information:","the SegmentBase does not contain @indexRange","or a RepresentationIndex element.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentBase.checkSegmentIndexSupport=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=a.representation.contentType,e=a.representation.mimeType.split("/")[1];if(d!=c.TEXT&&e!="mp4"&&e!="webm")throw shaka.log.error("SegmentBase specifies an unsupported container type.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_CONTAINER);if(e=="webm"&&!b)throw shaka.log.error("SegmentBase does not contain sufficient segment information:",
"the SegmentBase uses a WebM container,","but does not contain an Initialization element.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_WEBM_MISSING_INIT);};
shaka.dash.SegmentBase.generateSegmentIndex_=function(a,b,c,d){var e=shaka.dash.SegmentBase,f=e.computeIndexUris_(a);e=e.computeIndexRange_(a);goog.asserts.assert(e,"Index range should not be null!");return shaka.dash.SegmentBase.generateSegmentIndexFromUris(a,b,c,f,e.start,e.end,d)};
shaka.dash.SegmentBase.createQualityInfo=function(a){var b=a.representation;return{bandwidth:a.bandwidth,audioSamplingRate:b.audioSamplingRate,codecs:b.codecs,contentType:b.contentType,frameRate:b.frameRate||null,height:b.height||null,mimeType:b.mimeType,channelsCount:b.numChannels,pixelAspectRatio:b.pixelAspectRatio||null,width:b.width||null,label:a.adaptationSet.label||null,roles:a.roles||null,language:a.adaptationSet.language||null}};shaka.dash.SegmentList=function(){};
shaka.dash.SegmentList.createStreamInfo=function(a,b,c){goog.asserts.assert(a.representation.segmentList,"Should only be called with SegmentList");var d=shaka.dash.SegmentList,e=shaka.dash.SegmentBase.createInitSegment(a,d.fromInheritance_,c),f=d.parseSegmentListInfo_(a);d.checkSegmentListInfo_(a,f);var g=null,h=null;a.period.id&&a.representation.id&&(h=b.get(a.period.id+","+a.representation.id))&&(g=h.segmentIndex);var k=d.createSegmentReferences_(a.periodInfo.start,a.periodInfo.duration,f.startNumber,
a.representation.getBaseUris,f,e,c,a.representation.mimeType,a.representation.codecs,a.bandwidth,a.urlParams);b=!g;g?(c=a.presentationTimeline.getSegmentAvailabilityStart(),g.mergeAndEvict(k,c)):g=new shaka.media.SegmentIndex(k);a.presentationTimeline.notifySegments(k);a.dynamic&&a.periodInfo.isLastPeriod||g.fit(a.periodInfo.start,a.periodInfo.duration?a.periodInfo.start+a.periodInfo.duration:Infinity,b);h&&(h.segmentIndex=g);return{endTime:-1,timeline:-1,generateSegmentIndex:function(){g&&!g.isEmpty()||
g.merge(k);return Promise.resolve(g)},timescale:f.timescale}};shaka.dash.SegmentList.fromInheritance_=function(a){return a.segmentList};
shaka.dash.SegmentList.parseSegmentListInfo_=function(a){var b=shaka.dash.SegmentList,c=shaka.dash.MpdUtils,d=b.parseMediaSegments_(a);a=c.parseSegmentInfo(a,b.fromInheritance_);b=a.startNumber;b==0&&(shaka.log.warning("SegmentList@startNumber must be > 0"),b=1);c=0;a.segmentDuration?c=a.segmentDuration*(b-1):a.timeline&&a.timeline.length>0&&(c=a.timeline[0].start);return{segmentDuration:a.segmentDuration,startTime:c,startNumber:b,scaledPresentationTimeOffset:a.scaledPresentationTimeOffset,timescale:a.timescale,
timeline:a.timeline,mediaSegments:d}};
shaka.dash.SegmentList.checkSegmentListInfo_=function(a,b){if(!b.segmentDuration&&!b.timeline&&b.mediaSegments.length>1)throw shaka.log.warning("SegmentList does not contain sufficient segment information:","the SegmentList specifies multiple segments,","but does not specify a segment duration or timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);if(!b.segmentDuration&&!a.periodInfo.duration&&
!b.timeline&&b.mediaSegments.length==1)throw shaka.log.warning("SegmentList does not contain sufficient segment information:","the SegmentList specifies one segment,","but does not specify a segment duration, period duration,","or timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);if(b.timeline&&b.timeline.length==0)throw shaka.log.warning("SegmentList does not contain sufficient segment information:",
"the SegmentList has an empty timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentList.createSegmentReferences_=function(a,b,c,d,e,f,g,h,k,l,m){var n=shaka.util.ManifestParserUtils;c=e.mediaSegments.length;e.timeline&&e.timeline.length!=e.mediaSegments.length&&(c=Math.min(e.timeline.length,e.mediaSegments.length),shaka.log.warning("The number of items in the segment timeline and the number of ","segment URLs do not match, truncating",e.mediaSegments.length,"to",c));for(var p=a-e.scaledPresentationTimeOffset,q=b?a+b:Infinity,r=[],t=e.startTime,u={},w=0;w<c;u={uris$jscomp$12:void 0,
segment$jscomp$9:void 0},w++){u.segment$jscomp$9=e.mediaSegments[w];var v=t;t=void 0;e.segmentDuration!=null?t=v+e.segmentDuration:e.timeline?t=e.timeline[w].end:(goog.asserts.assert(e.mediaSegments.length==1&&b,"There should be exactly one segment with a Period duration."),t=v+b);u.uris$jscomp$12=null;var x=function(y){return function(){y.uris$jscomp$12==null&&(y.uris$jscomp$12=n.resolveUris(d(),[y.segment$jscomp$9.mediaUri],m()));return y.uris$jscomp$12}}(u);u=new shaka.media.SegmentReference(a+
v,a+t,x,u.segment$jscomp$9.start,u.segment$jscomp$9.end,f,p,a,q,[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,g);u.codecs=k;u.mimeType=h;u.bandwidth=l;r.push(u)}return r};
shaka.dash.SegmentList.parseMediaSegments_=function(a){var b=[a.representation.segmentList,a.adaptationSet.segmentList,a.period.segmentList].filter(shaka.util.Functional.isNotNull),c=shaka.util.TXml,d=shaka.util.StringUtils;return b.map(function(e){return c.findChildren(e,"SegmentURL")}).reduce(function(e,f){return e.length>0?e:f}).map(function(e){e.attributes.indexRange&&!a.indexRangeWarningGiven&&(a.indexRangeWarningGiven=!0,shaka.log.warning("We do not support the SegmentURL@indexRange attribute on SegmentList.  We only use the SegmentList@duration attribute or SegmentTimeline, which must be accurate."));
var f=d.htmlUnescape(e.attributes.media);e=c.parseAttr(e,"mediaRange",c.parseRange,{start:0,end:null});return{mediaUri:f,start:e.start,end:e.end}})};shaka.dash.SegmentTemplate=function(){};
shaka.dash.SegmentTemplate.createStreamInfo=function(a,b,c,d,e,f,g,h,k,l){goog.asserts.assert(a.representation.segmentTemplate,"Should only be called with SegmentTemplate or segment info defined");var m=shaka.dash.MpdUtils,n=shaka.dash.SegmentTemplate,p=shaka.dash.TimelineSegmentIndex;k||a.representation.initialization||(a.representation.initialization=m.inheritAttribute(a,n.fromInheritance_,"initialization"));var q=a.representation.initialization?n.createInitSegment_(a,g):null,r=n.parseSegmentTemplateInfo_(a);
n.checkSegmentTemplateInfo_(a,r);var t=shaka.util.ObjectUtils.shallowCloneObject(a);if(r.indexTemplate)return shaka.dash.SegmentBase.checkSegmentIndexSupport(a,q),{endTime:-1,timeline:-1,generateSegmentIndex:function(){return n.generateSegmentIndexFromIndexTemplate_(t,b,q,r)},timescale:r.timescale};if(r.segmentDuration)return d||a.adaptationSet.contentType==="image"||a.adaptationSet.contentType==="text"||(p=a.periodInfo.start,d=a.period.id,l=a.periodInfo.duration,d=(d=d!=null&&f.get(d)||l)?p+d:Infinity,
a.presentationTimeline.notifyMaxSegmentDuration(r.segmentDuration),a.presentationTimeline.notifyPeriodDuration(p,d)),{endTime:-1,timeline:-1,generateSegmentIndex:function(){return n.generateSegmentIndexFromDuration_(t,r,e,q,f,g,h,a.representation.segmentSequenceCadence)},timescale:r.timescale};var u=null;d=d=null;a.period.id&&a.representation.id&&(d=a.period.id+","+a.representation.id,d=c.get(d))&&(u=d.segmentIndex);var w=a.periodInfo.start,v=a.periodInfo.duration?w+a.periodInfo.duration:Infinity;
shaka.log.debug("New manifest "+w+" - "+v);if(u)p=u,p.appendTemplateInfo(r,w,v,q,a.dynamic),l=a.presentationTimeline.getSegmentAvailabilityStart(),p.evict(l);else{c=0;k=-1;if(a.period.id!=null&&a.representation.id!=null)if(m=l.get(a.period.id))k=m.timeline;else for(l=(0,$jscomp.makeIterator)(l.values()),m=l.next();!m.done;m=l.next())if(m=m.value,Math.abs(r.scaledPresentationTimeOffset-m.endTime)<=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&m.reps.includes(a.representation.id)){k=
m.timeline;break}else m.timeline>=c&&(c=m.timeline+1);k==-1&&(k=c);shaka.log.debug("Creating TSI with end "+v);u=new p(a.dynamic,r,a.representation.originalId,a.bandwidth,a.representation.getBaseUris,a.urlParams,w,v,q,g,a.representation.segmentSequenceCadence,k)}r.timeline&&a.adaptationSet.contentType!=="image"&&a.adaptationSet.contentType!=="text"&&(p=u.getTimeline(),a.presentationTimeline.notifyTimeRange(p,w));d&&a.dynamic&&(d.segmentIndex=u);p=(p=(p=r.timeline)&&p[p.length-1])?p.end+r.scaledPresentationTimeOffset:
-1;d=-1;u instanceof shaka.dash.TimelineSegmentIndex&&(d=u.continuityTimeline());return{endTime:p,timeline:d,generateSegmentIndex:function(){u instanceof shaka.dash.TimelineSegmentIndex&&u.isEmpty()&&u.appendTemplateInfo(r,w,v,q,a.dynamic);return Promise.resolve(u)},timescale:r.timescale}};
shaka.dash.SegmentTemplate.modifyTimepoints=function(a,b){var c=shaka.util.TXml;a=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentTemplate.fromInheritance_,"SegmentTimeline");goog.asserts.assert(a,"timeline node not found");var d=c.findChildren(a,"S");goog.asserts.assert(d,"timepoints should exist");c.modifyNodes(d,b);a.children=d};
shaka.dash.SegmentTemplate.removeTimepoints=function(a){a=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentTemplate.fromInheritance_,"SegmentTimeline");goog.asserts.assert(a,"timeline node not found");a.children=[]};shaka.dash.SegmentTemplate.fromInheritance_=function(a){return a.segmentTemplate};
shaka.dash.SegmentTemplate.parseSegmentTemplateInfo_=function(a){var b=shaka.dash.SegmentTemplate,c=shaka.dash.MpdUtils,d=shaka.util.StringUtils,e=c.parseSegmentInfo(a,b.fromInheritance_),f=c.inheritAttribute(a,b.fromInheritance_,"media"),g=c.inheritAttribute(a,b.fromInheritance_,"index");b=c.inheritAttribute(a,b.fromInheritance_,"k");c=0;b&&(c=parseInt(b,10));return{unscaledSegmentDuration:e.unscaledSegmentDuration,segmentDuration:e.segmentDuration,timescale:e.timescale,startNumber:e.startNumber,
scaledPresentationTimeOffset:e.scaledPresentationTimeOffset,unscaledPresentationTimeOffset:e.unscaledPresentationTimeOffset,timeline:e.timeline,mediaTemplate:f&&d.htmlUnescape(f),indexTemplate:g,mimeType:a.representation.mimeType,codecs:a.representation.codecs,bandwidth:a.bandwidth,numChunks:c}};
shaka.dash.SegmentTemplate.checkSegmentTemplateInfo_=function(a,b){var c=b.indexTemplate?1:0;c+=b.timeline?1:0;c+=b.segmentDuration?1:0;if(c==0)throw shaka.log.error("SegmentTemplate does not contain any segment information:","the SegmentTemplate must contain either an index URL template","a SegmentTimeline, or a segment duration.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);c!=1&&(shaka.log.warning("SegmentTemplate contains multiple segment information sources:",
"the SegmentTemplate should only contain an index URL template,","a SegmentTimeline or a segment duration.",a.representation),b.indexTemplate?(shaka.log.info("Using the index URL template by default."),b.timeline=null):(goog.asserts.assert(b.timeline,"There should be a timeline"),shaka.log.info("Using the SegmentTimeline by default.")),b.unscaledSegmentDuration=null,b.segmentDuration=null);if(!b.indexTemplate&&!b.mediaTemplate)throw shaka.log.error("SegmentTemplate does not contain sufficient segment information:",
"the SegmentTemplate's media URL template is missing.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentTemplate.generateSegmentIndexFromIndexTemplate_=function(a,b,c,d){var e=shaka.dash.MpdUtils,f=shaka.util.ManifestParserUtils;goog.asserts.assert(d.indexTemplate,"must be using index template");e=e.fillUriTemplate(d.indexTemplate,a.representation.originalId,null,null,a.bandwidth||null,null);f=f.resolveUris(a.representation.getBaseUris(),[e]);return shaka.dash.SegmentBase.generateSegmentIndexFromUris(a,b,c,f,0,null,d.scaledPresentationTimeOffset)};
shaka.dash.SegmentTemplate.generateSegmentIndexFromDuration_=function(a,b,c,d,e,f,g,h){goog.asserts.assert(b.mediaTemplate,"There should be a media template with duration");var k=shaka.dash.MpdUtils,l=shaka.util.ManifestParserUtils,m=a.presentationTimeline,n=a.periodInfo.start,p=a.period.id,q=a.periodInfo.duration,r=function(){var F=p!=null&&e.get(p)||q;return F?n+F:Infinity},t=b.segmentDuration;goog.asserts.assert(t!=null,"Segment duration must not be null!");var u=b.startNumber,w=b.mediaTemplate,
v=a.bandwidth||null,x=a.representation.originalId,y=a.representation.getBaseUris,A=a.urlParams,B=n-b.scaledPresentationTimeOffset,D=function(){var F=[Math.max(m.getSegmentAvailabilityStart(),n),Math.min(m.getSegmentAvailabilityEnd(),r())];goog.asserts.assert(F.every(isFinite),"Available presentation times must be finite!");goog.asserts.assert(F.every(function(J){return J>=0}),"Available presentation times must be positive!");goog.asserts.assert(t!=null,"Segment duration must not be null!");F=F.map(function(J){return J-
n});F=[Math.ceil(F[0]/t),Math.ceil(F[1]/t)-1];a.representation.availabilityTimeOffset&&F[1]++;return F.map(function(J){return J+u})},z=D();c=a.dynamic?Math.max(z[0],z[1]-c+1):z[0];g=g||z[1];var C=function(F){goog.asserts.assert(t!=null,"Segment duration must not be null!");var J=F-u,K=J*t,H=b.unscaledSegmentDuration;goog.asserts.assert(H!=null,"Segment duration must not be null!");var M=J*H;"BigInt"in window&&M>Number.MAX_SAFE_INTEGER&&(M=BigInt(J)*BigInt(H));K+=n;J=K+t;H=Math.min(J,r());goog.asserts.assert(K<
H,"Generated a segment outside of the period!");var L=[],N=b.numChunks;if(N)for(var P=(H-K)/N,Q={},O=0;O<N;Q={subNumber$jscomp$1:void 0},O++){var S=K+P*O,V=S+P;Q.subNumber$jscomp$1=O;Q=function(U){return function(){var X=k.fillUriTemplate(w,x,F,U.subNumber$jscomp$1,v,M);return l.resolveUris(y(),[X],A())}}(Q);S=new shaka.media.SegmentReference(S,V,Q,0,null,d,B,n,r(),[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,f);S.codecs=a.representation.codecs;S.mimeType=a.representation.mimeType;
h==0?O>0&&S.markAsNonIndependent():O%h!=0&&S.markAsNonIndependent();L.push(S)}K=new shaka.media.SegmentReference(K,H,function(){if(N)return[];var U=k.fillUriTemplate(w,x,F,null,v,M);return l.resolveUris(y(),[U],A())},0,null,d,B,n,r(),L,"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,f,L.length>0);K.codecs=a.representation.codecs;K.mimeType=a.representation.mimeType;K.bandwidth=a.bandwidth;K.trueEndTime=J;return K},E=new shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_(c,g,u,n,t,C);
z=m.getSegmentAvailabilityEnd()<r();var G=m.isLive();if(z||G){var I=Math.max(c,g+1);c=t;a.representation.availabilityTimeOffset&&(c=.1);E.updateEvery(c,function(){var F=m.getSegmentAvailabilityStart();E.evict(F);var J=(0,$jscomp.makeIterator)(D());J.next();J=J.next().value;for(var K=[];I<=J;){var H=C(I);K.push(H);I++}return F>r()&&!K.length?null:K})}return Promise.resolve(E)};
shaka.dash.SegmentTemplate.createInitSegment_=function(a,b){var c=shaka.dash.MpdUtils,d=shaka.util.ManifestParserUtils,e=shaka.dash.SegmentTemplate,f=a.representation.initialization;f||(f=c.inheritAttribute(a,e.fromInheritance_,"initialization"));if(!f)return null;f=shaka.util.StringUtils.htmlUnescape(f);var g=a.representation.originalId,h=a.bandwidth||null,k=a.representation.getBaseUris,l=a.urlParams;e=shaka.dash.SegmentBase.createQualityInfo(a);b=new shaka.media.InitSegmentReference(function(){goog.asserts.assert(f,
"Should have returned earlier");var m=c.fillUriTemplate(f,g,null,null,h,null);return d.resolveUris(k(),[m],l())},0,null,e,null,null,b,a.adaptationSet.encrypted);b.codecs=a.representation.codecs;b.mimeType=a.representation.mimeType;a.periodInfo&&!a.periodInfo.isLastPeriod&&(b.boundaryEnd=a.periodInfo.start+a.periodInfo.duration);return b};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_=function(a,b,c,d,e,f){shaka.media.SegmentIndex.call(this,Array(Math.max(0,b-a+1)));this.minPosition_=a;this.startNumber_=c;this.periodStart_=d;this.segmentDuration_=e;this.createReference_=f};$jscomp.inherits(shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_,shaka.media.SegmentIndex);
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.find=function(a){var b=this.references.length-1;if(b<0)return null;var c=this.get(this.numEvicted_);if(!c)return null;if(a<c.startTime)return this.numEvicted_;c=Math.floor((a-this.periodStart_)/this.segmentDuration_)+this.startNumber_-this.minPosition_;if(c<this.numEvicted_)return null;var d=this.get(c);if(!d)return null;b=(b=c-this.numEvicted_<b?this.get(c+1):null)?b.startTime:d.endTime;return a>=d.startTime&&a<b?c:null};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.get=function(a){var b=a-this.numEvicted_;if(b<0||b>=this.references.length)return null;var c=this.references[b];c||(c=this.createReference_(this.minPosition_+a),this.references[b]=c);return c};shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.earliestReference=function(){return this.get(this.numEvicted_)};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.forEachTopLevelReference=function(a){for(var b=0;b<this.references.length;b++){var c=this.get(b+this.numEvicted_);c&&a(c)}};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.evict=function(a){if(!this.getIsImmutable()){var b=this.references.length-1;if(!(b<0)){var c=this.get(this.numEvicted_);!c||c.endTime>a||(a=(b=this.get(this.numEvicted_+b))&&b.endTime<=a?this.references.length:Math.max(0,Math.min(this.references.length,Math.floor((a-this.periodStart_)/this.segmentDuration_+this.startNumber_-1)-(this.minPosition_+this.numEvicted_)+1)),a>0&&(this.numEvicted_+=a,this.references=this.references.slice(a)))}}};
shaka.dash.TimelineSegmentIndex=function(a,b,c,d,e,f,g,h,k,l,m,n){shaka.media.SegmentIndex.call(this,[]);this.dynamic_=a;this.templateInfo_=b;this.representationId_=c;this.bandwidth_=d;this.getBaseUris_=e;this.urlParams_=f;this.periodStart_=g;this.periodEnd_=h;this.initSegmentReference_=k;this.aesKey_=l;this.segmentSequenceCadence_=m;this.timeline_=n;this.fitTimeline()};$jscomp.inherits(shaka.dash.TimelineSegmentIndex,shaka.media.SegmentIndex);
shaka.dash.TimelineSegmentIndex.prototype.getNumReferences=function(){return this.templateInfo_?this.templateInfo_.timeline.length:0};shaka.dash.TimelineSegmentIndex.prototype.release=function(){shaka.media.SegmentIndex.prototype.release.call(this);this.templateInfo_=null};
shaka.dash.TimelineSegmentIndex.prototype.evict=function(a){if(this.templateInfo_){shaka.log.debug(this.representationId_+" Evicting at "+a);var b=this.templateInfo_.timeline;if(b){for(var c=0;c<b.length&&b[c].end+this.periodStart_<=a;)c++;c>0&&(this.templateInfo_.timeline=b.slice(c),this.references.length>=c&&(this.references=this.references.slice(c)),this.numEvicted_+=c,this.getNumReferences()===0&&this.release())}}};
shaka.dash.TimelineSegmentIndex.prototype.appendTemplateInfo=function(a,b,c,d,e){this.updateInitSegmentReference(d);this.dynamic_=e;if(this.templateInfo_){if(this.templateInfo_.unscaledPresentationTimeOffset!==a.unscaledPresentationTimeOffset)for(b=a.unscaledPresentationTimeOffset-this.templateInfo_.unscaledPresentationTimeOffset,shaka.log.error("Possibly suboptimal manifest detected!","presentationTimeOffset is "+a.unscaledPresentationTimeOffset,"which differs "+b+" from the cache template."),d=
0;d<a.timeline.length;d++)e=a.timeline[d],e.unscaledStart+=b,e.unscaledEnd+=b,e.start=(e.unscaledStart+b)/a.timescale,e.end=(e.unscaledEnd+b)/a.timescale;this.templateInfo_.mediaTemplate!==a.mediaTemplate&&(this.templateInfo_.mediaTemplate=a.mediaTemplate);b=this.templateInfo_.timeline;if(b.length){var f=b[b.length-1];a=a.timeline.filter(function(g){return g.end>f.end})}else a=a.timeline.slice();a.length>0&&(shaka.log.debug("Appending "+a.length+" entries"),this.templateInfo_.timeline.push.apply(this.templateInfo_.timeline,
(0,$jscomp.arrayFromIterable)(a)));this.periodEnd_!==c&&(this.periodEnd_=c)}else this.templateInfo_=a,this.periodStart_=b,this.periodEnd_=c;this.fitTimeline()};shaka.dash.TimelineSegmentIndex.prototype.updateInitSegmentReference=function(a){if(this.initSegmentReference_!==a){this.initSegmentReference_=a;for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())(c=c.value)&&c.updateInitSegmentReference(a)}};
shaka.dash.TimelineSegmentIndex.prototype.isBeforeFirstEntry=function(a){return this.templateInfo_&&this.templateInfo_.timeline&&this.templateInfo_.timeline.length?a<this.templateInfo_.timeline[0].start+this.periodStart_:!1};
shaka.dash.TimelineSegmentIndex.prototype.fitTimeline=function(){if(this.templateInfo_&&!this.getIsImmutable()){var a=this.templateInfo_.timeline;goog.asserts.assert(a,"Timeline should be non-null!");var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.start>=this.periodEnd_||c.end<=0||b.push(c);this.templateInfo_.timeline=b;this.evict(this.periodStart_)}};
shaka.dash.TimelineSegmentIndex.prototype.getTimeline=function(){if(!this.templateInfo_)return[];var a=this.templateInfo_.timeline;goog.asserts.assert(a,"Timeline should be non-null!");return a};
shaka.dash.TimelineSegmentIndex.prototype.find=function(a){var b=this;shaka.log.debug("Find "+a);if(this.isBeforeFirstEntry(a))return this.numEvicted_;if(!this.templateInfo_)return null;var c=this.templateInfo_.timeline;if(a<this.periodStart_||a>=this.periodEnd_)return null;var d=c.length-1,e=shaka.util.ArrayUtils.binarySearch(c,function(h){return h.start+b.periodStart_<=a})-1;if(e<0)return null;var f=c[e],g=f.start+this.periodStart_;c=e<d?c[e+1].start+this.periodStart_:this.periodEnd_===Infinity?
f.end+this.periodStart_:this.periodEnd_;return a>=g&&a<c?e+this.numEvicted_:null};
shaka.dash.TimelineSegmentIndex.prototype.get=function(a){var b=this;a-=this.numEvicted_;if(a<0||a>=this.getNumReferences()||!this.templateInfo_)return null;var c=this.references[a];if(!c){c=this.templateInfo_.timeline[a];var d=c.segmentPosition,e=c.unscaledStart+this.templateInfo_.unscaledPresentationTimeOffset,f=this.periodStart_-this.templateInfo_.scaledPresentationTimeOffset,g=this.periodStart_+c.end,h=g;a===this.getNumReferences()-1&&this.periodEnd_!==Infinity&&(h=this.dynamic_&&Math.abs(h-this.periodEnd_)>
.1?Math.min(h,this.periodEnd_):this.periodEnd_);var k=this.templateInfo_.codecs,l=this.templateInfo_.mimeType,m=this.templateInfo_.bandwidth,n=[],p=!1;c.partialSegments&&this.templateInfo_&&this.templateInfo_.mediaTemplate&&(p=this.templateInfo_.mediaTemplate.includes("$SubNumber$"));if(p){p=(c.end-c.start)/c.partialSegments;for(var q={},r=0;r<c.partialSegments;q={uris$jscomp$13:void 0,subNumber$jscomp$2:void 0},r++){var t=c.start+p*r,u=t+p;q.subNumber$jscomp$2=r;q.uris$jscomp$13=null;q=function(w){return function(){if(!b.templateInfo_)return[];
w.uris$jscomp$13==null&&(w.uris$jscomp$13=shaka.dash.TimelineSegmentIndex.createUris_(b.templateInfo_.mediaTemplate,b.representationId_,d,b.bandwidth_,e,w.subNumber$jscomp$2,b.getBaseUris_,b.urlParams_));return w.uris$jscomp$13}}(q);t=new shaka.media.SegmentReference(this.periodStart_+t,this.periodStart_+u,q,0,null,this.initSegmentReference_,f,this.periodStart_,this.periodEnd_,[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,this.aesKey_);t.codecs=k;t.mimeType=l;t.bandwidth=m;this.segmentSequenceCadence_==
0?r>0&&t.markAsNonIndependent():r%this.segmentSequenceCadence_!=0&&t.markAsNonIndependent();n.push(t)}}c=new shaka.media.SegmentReference(this.periodStart_+c.start,h,function(){return n.length>0||!b.templateInfo_?[]:shaka.dash.TimelineSegmentIndex.createUris_(b.templateInfo_.mediaTemplate,b.representationId_,d,b.bandwidth_,e,null,b.getBaseUris_,b.urlParams_)},0,null,this.initSegmentReference_,f,this.periodStart_,this.periodEnd_,n,"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,this.aesKey_,
n.length>0);c.codecs=k;c.mimeType=l;c.trueEndTime=g;c.bandwidth=m;this.references[a]=c}return c};shaka.dash.TimelineSegmentIndex.prototype.forEachTopLevelReference=function(a){this.fitTimeline();for(var b=0;b<this.getNumReferences();b++){var c=this.get(b+this.numEvicted_);c&&a(c)}};shaka.dash.TimelineSegmentIndex.createUris_=function(a,b,c,d,e,f,g,h){a=shaka.dash.MpdUtils.fillUriTemplate(a,b,c,f,d||null,e);return shaka.util.ManifestParserUtils.resolveUris(g(),[a],h()).map(function(k){return k.toString()})};
shaka.dash.TimelineSegmentIndex.prototype.continuityTimeline=function(){return this.timeline_};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.getNextAddressJsc()==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.getNextAddressJsc()!=2)return g=m.getYieldResultJsc(),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.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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==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()),P.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 P.return();r=d.getStreamsPerPeriod_(a,!0);t=r.audioStreamsPerPeriod;u=r.videoStreamsPerPeriod;w=r.textStreamsPerPeriod;v=r.imageStreamsPerPeriod;return P.yield(Promise.all([d.combine_(d.audioStreams_,t,n,shaka.util.PeriodCombiner.cloneStream_,
shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.videoStreams_,u,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.textStreams_,w,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.imageStreams_,v,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m)]),2)}x=0;y=[];if(d.videoStreams_.length&&d.audioStreams_.length)for(G=(0,$jscomp.makeIterator)(d.audioStreams_),
I=G.next();!I.done;I=G.next())for(F=I.value,J=(0,$jscomp.makeIterator)(d.videoStreams_),K=J.next();!K.done;K=J.next())H=K.value,M=shaka.drm.DrmUtils.getCommonDrmInfos(F.drmInfos,H.drmInfos),F.drmInfos.length&&H.drmInfos.length&&!M.length?shaka.log.warning("Incompatible DRM in audio & video, skipping variant creation.",F,H):(L=(F.bandwidth||0)+(H.bandwidth||0),F.dependencyStream&&(L+=F.dependencyStream.bandwidth||0),H.dependencyStream&&(L+=H.dependencyStream.bandwidth||0),N=x++,y.push({id:N,language:F.language,
disabledUntilTime:0,primary:F.primary,audio:F,video:H,bandwidth:L,drmInfos:M,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]}));else for(A=d.videoStreams_.length?d.videoStreams_:d.audioStreams_,B=(0,$jscomp.makeIterator)(A),D=B.next();!D.done;D=B.next())z=D.value,C=x++,E=z.bandwidth||0,z.dependencyStream&&(E+=z.dependencyStream.bandwidth||0),y.push({id:C,language:z.language,disabledUntilTime:0,primary:z.primary,audio:z.type==e.AUDIO?z:null,video:z.type==e.VIDEO?z:null,bandwidth:E,drmInfos:z.drmInfos,
allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]});d.variants_=y;P.jumpToEnd()})};
shaka.util.PeriodCombiner.combineDbStreams=function(a){var b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.getNextAddressJsc()){case 1:b=shaka.util.ManifestParserUtils.ContentType;c=shaka.util.PeriodCombiner;if(a.length==1)return H.return(a[0]);d=a.map(function(M){return new Map(M.filter(function(L){return L.type===b.AUDIO}).map(function(L){return[c.generateAudioKey_(L),L]}))});e=a.map(function(M){return new Map(M.filter(function(L){return L.type===
b.VIDEO}).map(function(L){return[c.generateVideoKey_(L),L]}))});f=a.map(function(M){return new Map(M.filter(function(L){return L.type===b.TEXT}).map(function(L){return[c.generateTextKey_(L),L]}))});g=a.map(function(M){return new Map(M.filter(function(L){return L.type===b.IMAGE}).map(function(L){return[c.generateImageKey_(L),L]}))});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 H.yield(t.combine_([],d,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),2);case 2:return u=H.getYieldResultJsc(),H.yield(t.combine_([],e,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),3);case 3:return w=H.getYieldResultJsc(),H.yield(t.combine_([],f,0,shaka.util.PeriodCombiner.cloneStreamDB_,
shaka.util.PeriodCombiner.concatenateStreamDBs_,0),4);case 4:return v=H.getYieldResultJsc(),H.yield(t.combine_([],g,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),5);case 5:x=H.getYieldResultJsc();y=0;if(w.length&&u.length)for(C=(0,$jscomp.makeIterator)(u),E=C.next();!E.done;E=C.next())for(G=E.value,I=(0,$jscomp.makeIterator)(w),F=I.next();!F.done;F=I.next())J=F.value,K=y++,J.variantIds.push(K),G.variantIds.push(K);else for(A=w.concat(u),B=(0,$jscomp.makeIterator)(A),
D=B.next();!D.done;D=B.next())z=D.value,z.variantIds=[y++];return H.return(w.concat(u).concat(v).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,u,w,v,x,y,A,B,D,z,C,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.getNextAddressJsc()){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){G.jumpTo(4);break}n=m.value;return G.yield(g.extendExistingOutputStream_(n,b,c,e,h,f),5);case 5:p=G.getYieldResultJsc();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();G.jumpTo(2);break;case 4:q=(0,$jscomp.makeIterator)(h);for(r=q.next();!r.done;r=q.next())for(t=r.value,u=(0,$jscomp.makeIterator)(t),w=u.next();!w.done;w=u.next())v=w.value,(x=g.createNewOutputStream_(a,v,b,d,e,h))&&a.push(x);y=(0,$jscomp.makeIterator)(h);for(A=y.next();!A.done;A=y.next())for(B=A.value,D=(0,$jscomp.makeIterator)(B),z=D.next(),C={};!z.done;C={stream$jscomp$113:void 0},z=D.next())if(C.stream$jscomp$113=
z.value,!shaka.util.PeriodCombiner.isDummy_(C.stream$jscomp$113)&&(E=a.some(function(I){return function(F){return g.areAVStreamsCompatible_(I.stream$jscomp$113,F)}}(C))))throw shaka.log.error("Unused stream in period-flattening!",C.stream$jscomp$113,a),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.PERIOD_FLATTENING_FAILED);return G.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.getNextAddressJsc()==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.getNextAddressJsc()==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}});shaka.dash.DashParser=function(){var a=this;this.playerInterface_=this.config_=null;this.manifestUris_=[];this.manifest_=null;this.globalId_=1;this.patchLocationNodes_=[];this.manifestPatchContext_={mpdId:"",type:"",profiles:[],mediaPresentationDuration:null,availabilityTimeOffset:0,getBaseUris:null,publishTime:0};this.contextCache_=new Map;this.continuityCache_=new Map;this.parsedPeriodCache_=new Map;this.streamMap_=new Map;this.indexStreamMap_=new Map;this.periodDurations_=new Map;this.periodCombiner_=
new shaka.util.PeriodCombiner;this.updatePeriod_=0;this.averageUpdateDuration_=new shaka.abr.Ewma(5);this.updateTimer_=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.operationManager_=new shaka.util.OperationManager;this.largestPeriodStartTime_=null;this.lastManifestUpdatePeriodIds_=
[];this.minTotalAvailabilityTimeOffset_=Infinity;this.lowLatencyMode_=!1;this.contentSteeringManager_=null;this.gapCount_=0;this.isLowLatency_=!1;this.eventManager_=new shaka.util.EventManager;this.mediaElement_=null;this.isTransitionFromDynamicToStatic_=!1;this.lastManifestQueryParams_="";this.isPreloadFn_=function(){return!1};this.lastCalculatedBaseUris_=[];this.parsedPrftNodes_=new Set;this.contentProtection_=new shaka.dash.ContentProtection};
shaka.dash.DashParser.prototype.configure=function(a,b){goog.asserts.assert(a.dash!=null,"DashManifestConfiguration should not be null!");var c=this.playerInterface_&&a.updatePeriod!=this.config_.updatePeriod&&a.updatePeriod>=0;this.config_=a;b&&(this.isPreloadFn_=b);c&&this.manifest_&&this.manifest_.presentationTimeline.isLive()&&this.updateNow_();this.contentSteeringManager_&&this.contentSteeringManager_.configure(this.config_);this.periodCombiner_&&this.periodCombiner_.setUseStreamOnce(this.config_.dash.useStreamOnceInPeriodFlattening)};
shaka.dash.DashParser.prototype.start=function(a,b){var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return goog.asserts.assert(c.config_,"Must call configure() before start()!"),c.lowLatencyMode_=b.isLowLatencyMode(),c.manifestUris_=[a],c.playerInterface_=b,e.yield(c.requestManifest_(),2);d=e.getYieldResultJsc();c.playerInterface_&&c.setUpdateTimer_(d);if(!c.playerInterface_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,
shaka.util.Error.Code.OPERATION_ABORTED);goog.asserts.assert(c.manifest_,"Manifest should be non-null!");return e.return(c.manifest_)})};
shaka.dash.DashParser.prototype.stop=function(){for(var a=(0,$jscomp.makeIterator)(this.streamMap_.values()),b=a.next();!b.done;b=a.next())b=b.value,b.segmentIndex&&b.segmentIndex.release();this.periodCombiner_&&this.periodCombiner_.release();this.config_=this.playerInterface_=null;this.manifestUris_=[];this.manifest_=null;this.streamMap_.clear();this.indexStreamMap_.clear();this.contextCache_.clear();this.continuityCache_.clear();this.parsedPeriodCache_.clear();this.manifestPatchContext_={mpdId:"",
type:"",profiles:[],mediaPresentationDuration:null,availabilityTimeOffset:0,getBaseUris:null,publishTime:0};this.periodCombiner_=null;this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);this.contentSteeringManager_&&this.contentSteeringManager_.destroy();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.parsedPrftNodes_.clear();this.contentProtection_.release();return this.operationManager_.destroy()};
shaka.dash.DashParser.prototype.update=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.setCatchFinallyBlocks(2),c.yield(a.requestManifest_(),4);if(c.getNextAddressJsc()!=2)return c.leaveTryBlock(0);b=c.enterCatchBlock();if(!a.playerInterface_||!b)return c.return();goog.asserts.assert(b instanceof shaka.util.Error,"Bad error type");a.playerInterface_.onError(b);c.jumpToEnd()})};
shaka.dash.DashParser.prototype.onExpirationUpdated=function(a,b){};shaka.dash.DashParser.prototype.onInitialVariantChosen=function(a){if(this.manifest_&&this.manifest_.presentationTimeline.isLive()){var b=a.video||a.audio;if(b&&b.segmentIndex){a=this.manifest_.presentationTimeline.getSegmentAvailabilityEnd();var c=b.segmentIndex.find(a);c!=null&&(b=b.segmentIndex.get(c))&&(this.updatePeriod_=b.endTime-a,this.setUpdateTimer_(0))}}};
shaka.dash.DashParser.prototype.banLocation=function(a){this.contentSteeringManager_&&this.contentSteeringManager_.banLocation(a)};shaka.dash.DashParser.prototype.setMediaElement=function(a){this.mediaElement_=a};
shaka.dash.DashParser.prototype.requestManifest_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1)return b=shaka.net.NetworkingEngine.RequestType.MANIFEST,c=shaka.net.NetworkingEngine.AdvancedRequestType.MPD,d="MPD",e=a.getPatchLocationUris_(),f=a.manifestUris_,e.length?(f=e,d="Patch",c=shaka.net.NetworkingEngine.AdvancedRequestType.MPD_PATCH):a.manifestUris_.length>1&&a.contentSteeringManager_&&(g=a.contentSteeringManager_.getLocations("Location",
!0),g.length&&(f=g)),h=shaka.net.NetworkingEngine.makeRequest(f,a.config_.retryParameters),k=Date.now(),q.yield(a.makeNetworkRequest_(h,b,{type:c}),2);if(q.getNextAddressJsc()!=3){l=q.getYieldResultJsc();if(!a.playerInterface_)return q.return(0);l.uri&&l.uri!=l.originalUri&&!a.manifestUris_.includes(l.uri)&&a.manifestUris_.unshift(l.uri);m=new goog.Uri(l.uri);a.lastManifestQueryParams_=m.getQueryData().toString();return q.yield(a.parseManifest_(l.data,l.uri,d),3)}n=Date.now();p=(n-k)/1E3;a.averageUpdateDuration_.sample(1,
p);a.parsedPrftNodes_.clear();return q.return(p)})};
shaka.dash.DashParser.prototype.parseManifest_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){if(t.getNextAddressJsc()==1){e=a;f=d.config_.dash.manifestPreprocessor;g=shaka.util.PlayerConfiguration.defaultManifestPreprocessor;if(f!=g){shaka.Deprecate.deprecateFeature(5,"manifest.dash.manifestPreprocessor configuration","Please Use manifest.dash.manifestPreprocessorTXml instead.");h=shaka.util.XmlUtils.parseXml(e,c);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_INVALID_XML,b);f(h);e=shaka.util.XmlUtils.toArrayBuffer(h)}k=shaka.util.TXml.parseXml(e,c);if(!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_INVALID_XML,b);l=d.config_.dash.manifestPreprocessorTXml;m=shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml;l!=m&&l(k);if(c==="Patch")return t.return(d.processPatchManifest_(k));if(n=d.config_.dash.disableXlinkProcessing)return t.return(d.processManifest_(k,
b));p=d.config_.dash.xlinkFailGracefully;q=shaka.dash.MpdUtils.processXlinks(k,d.config_.retryParameters,p,b,d.playerInterface_.networkingEngine);d.operationManager_.manage(q);return t.yield(q.promise,2)}r=t.getYieldResultJsc();return t.return(d.processManifest_(r,b))})};
shaka.dash.DashParser.prototype.processManifest_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V,U,X,Y,T,W,R,aa,Z,ba,da,ha,pa,ia,ja,fa,ka,ea,la,ma,na,oa;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(ca){switch(ca.getNextAddressJsc()){case 1:d=shaka.util.TXml;goog.asserts.assert(c.config_,"Must call configure() before processManifest_()!");c.contentSteeringManager_&&c.contentSteeringManager_.clearPreviousLocations();e=[b];f=[];g=
new Map;h=d.findChildren(a,"Location");k=(0,$jscomp.makeIterator)(h);for(l=k.next();!l.done;l=k.next())if(m=l.value,n=m.attributes.serviceLocation,p=d.getContents(m))q=shaka.util.ManifestParserUtils.resolveUris(e,[p])[0],n&&(c.contentSteeringManager_?c.contentSteeringManager_.addLocation("Location",n,q):g.set(n,q)),f.push(q);c.contentSteeringManager_?(r=c.contentSteeringManager_.getLocations("Location",!0),r.length>0&&(e=c.manifestUris_=r)):f.length&&(e=c.manifestUris_=f);c.manifestPatchContext_.mpdId=
a.attributes.id||"";c.manifestPatchContext_.publishTime=d.parseAttr(a,"publishTime",d.parseDate)||0;c.patchLocationNodes_=d.findChildren(a,"PatchLocation");t=Promise.resolve();if((u=d.findChild(a,"ContentSteering"))&&c.playerInterface_){w=u.attributes.defaultServiceLocation;if(c.contentSteeringManager_)c.contentSteeringManager_.setBaseUris(e),c.contentSteeringManager_.setDefaultPathwayId(w);else if(c.contentSteeringManager_=new shaka.util.ContentSteeringManager(c.playerInterface_),c.contentSteeringManager_.configure(c.config_),
c.contentSteeringManager_.setManifestType(shaka.media.ManifestParser.DASH),c.contentSteeringManager_.setBaseUris(e),c.contentSteeringManager_.setDefaultPathwayId(w),v=d.getContents(u))(x=d.parseAttr(u,"queryBeforeStart",d.parseBoolean,!1))?t=c.contentSteeringManager_.requestInfo(v):c.contentSteeringManager_.requestInfo(v);y=(0,$jscomp.makeIterator)(g.keys());for(A=y.next();!A.done;A=y.next())B=A.value,D=g.get(B),c.contentSteeringManager_.addLocation("Location",B,D)}z=d.findChildren(a,"BaseURL");C=
!1;if(c.contentSteeringManager_)for(E=(0,$jscomp.makeIterator)(z),G=E.next();!G.done;G=E.next())I=G.value,F=I.attributes.serviceLocation,J=d.getContents(I),F&&J&&(c.contentSteeringManager_.addLocation("BaseURL",F,J),C=!0);c.lastCalculatedBaseUris_.splice(0);C&&c.contentSteeringManager_||(K=z.map(d.getContents),c.lastCalculatedBaseUris_.push.apply(c.lastCalculatedBaseUris_,(0,$jscomp.arrayFromIterable)(shaka.util.ManifestParserUtils.resolveUris(e,K))));H=c.contentSteeringManager_;M=c.lastCalculatedBaseUris_;
L=shaka.dash.DashParser.makeBaseUriGetter_;N=L.call(shaka.dash.DashParser,H,C,M);c.manifestPatchContext_.getBaseUris=N;P=0;z&&z.length&&(P=d.parseAttr(z[0],"availabilityTimeOffset",d.parseFloat)||0);c.manifestPatchContext_.availabilityTimeOffset=P;c.updatePeriod_=d.parseAttr(a,"minimumUpdatePeriod",d.parseDuration,-1);Q=d.parseAttr(a,"availabilityStartTime",d.parseDate);O=d.parseAttr(a,"timeShiftBufferDepth",d.parseDuration);S=c.config_.dash.ignoreSuggestedPresentationDelay;V=null;S||(V=d.parseAttr(a,
"suggestedPresentationDelay",d.parseDuration));U=c.config_.dash.ignoreMaxSegmentDuration;X=null;U||(X=d.parseAttr(a,"maxSegmentDuration",d.parseDuration));Y=a.attributes.type||"static";c.manifest_&&c.manifest_.presentationTimeline&&(c.isTransitionFromDynamicToStatic_=c.manifest_.presentationTimeline.isLive()&&Y=="static");c.manifestPatchContext_.type=Y;if(c.manifest_)for(T=c.manifest_.presentationTimeline,W=T.getSegmentAvailabilityStart(),R=(0,$jscomp.makeIterator)(c.streamMap_.values()),aa=R.next();!aa.done;aa=
R.next())Z=aa.value,Z.segmentIndex&&Z.segmentIndex.evict(W);else ba=c.config_.dash.ignoreMinBufferTime,da=0,ba||(da=d.parseAttr(a,"minBufferTime",d.parseDuration)||0),ha=0,ha=V!=null?Math.min(V,O||Infinity):c.config_.defaultPresentationDelay>0?c.config_.defaultPresentationDelay:Math.min(da*1.5,O||Infinity),T=new shaka.media.PresentationTimeline(Q,ha,c.config_.dash.autoCorrectDrift);T.setStatic(Y=="static");(pa=T.isLive())&&!isNaN(c.config_.availabilityWindowOverride)&&(O=c.config_.availabilityWindowOverride);
O==null&&(O=Infinity);T.setSegmentAvailabilityDuration(O);ia=a.attributes.profiles||"";c.manifestPatchContext_.profiles=ia.split(",");ja={dynamic:Y!="static",presentationTimeline:T,period:null,periodInfo:null,adaptationSet:null,representation:null,bandwidth:0,indexRangeWarningGiven:!1,availabilityTimeOffset:P,mediaPresentationDuration:null,profiles:ia.split(","),roles:null,urlParams:shaka.dash.DashParser.defaultUrlParams_};return ca.yield(t,2);case 2:c.gapCount_=0;fa=c.parsePeriods_(ja,N,a,!1);ka=
fa.duration;ea=fa.periods;(Y!="static"||c.isTransitionFromDynamicToStatic_)&&fa.durationDerivedFromPeriods||T.setDuration(ka||Infinity);c.isLowLatency_&&c.lowLatencyMode_&&T.setAvailabilityTimeOffset(c.minTotalAvailabilityTimeOffset_);T.notifyMaxSegmentDuration(X||1);goog.DEBUG&&!c.isTransitionFromDynamicToStatic_&&T.assertIsValid();c.isLowLatency_&&c.lowLatencyMode_&&(la=V!=null?V:c.config_.defaultPresentationDelay,T.setDelay(la));if(!c.manifest_)return ca.yield(c.periodCombiner_.combinePeriods(ea,
ja.dynamic),6);c.manifest_.periodCount=ea.length;c.manifest_.gapCount=c.gapCount_;return ca.yield(c.postPeriodProcessing_(ea,!1),4);case 6:c.manifest_={presentationTimeline:T,variants:c.periodCombiner_.getVariants(),textStreams:c.periodCombiner_.getTextStreams(),imageStreams:c.periodCombiner_.getImageStreams(),offlineSessionIds:[],sequenceMode:c.config_.dash.sequenceMode,ignoreManifestTimestampsInSegmentsMode:!1,type:shaka.media.ManifestParser.DASH,serviceDescription:c.parseServiceDescription_(a),
nextUrl:c.parseMpdChaining_(a),periodCount:ea.length,gapCount:c.gapCount_,isLowLatency:c.isLowLatency_,startTime:null};if(!T.usingPresentationStartTime()){ca.jumpTo(7);break}ma=shaka.util.TXml;na=ma.findChildren(a,"UTCTiming");return ca.yield(c.parseUtcTiming_(N,na),8);case 8:oa=ca.getYieldResultJsc();if(!c.playerInterface_)return ca.return();T.setClockOffset(oa);case 7:T.lockStartTime(),c.periodCombiner_&&!c.manifest_.presentationTimeline.isLive()&&c.periodCombiner_.release();case 4:c.playerInterface_.makeTextStreamsForClosedCaptions(c.manifest_),
c.cleanStreamMap_(),c.cleanContinuityCache_(ea),ca.jumpToEnd()}})};
shaka.dash.DashParser.prototype.postPeriodProcessing_=function(a,b){var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return e.yield(c.periodCombiner_.combinePeriods(a,!0,b),2);c.manifest_.variants=c.periodCombiner_.getVariants();d=c.periodCombiner_.getTextStreams();d.length>0&&(c.manifest_.textStreams=d);c.manifest_.imageStreams=c.periodCombiner_.getImageStreams();c.playerInterface_.filter(c.manifest_);e.jumpToEnd()})};
shaka.dash.DashParser.prototype.processPatchManifest_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(K){if(K.getNextAddressJsc()==1){c=shaka.util.TXml;d=a.attributes.mpdId;e=c.parseAttr(a,"originalPublishTime",c.parseDate);if(!d||d!==b.manifestPatchContext_.mpdId||e!==b.manifestPatchContext_.publishTime)throw b.patchLocationNodes_=[],new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_INVALID_PATCH);f=[];g=[];h=new Set;k=(0,$jscomp.makeIterator)(c.getChildNodes(a));for(l=k.next();!l.done;l=k.next()){m=l.value;n=!0;p=c.parseXpath(m.attributes.sel||"");q=p[p.length-1];r=c.getContents(m)||"";if(q.name==="MPD")q.attribute==="mediaPresentationDuration"?(t=c.getContents(m)||"",b.parsePatchMediaPresentationDurationChange_(t)):q.attribute==="type"?b.parsePatchMpdTypeChange_(r):q.attribute==="publishTime"?b.manifestPatchContext_.publishTime=c.parseDate(r)||0:
q.attribute===null&&m.tagName==="add"?g.push(m):n=!1;else if(q.name==="PatchLocation")b.updatePatchLocationNodes_(m);else if(q.name==="Period")m.tagName==="add"?g.push(m):m.tagName==="remove"&&q.id&&b.removePatchPeriod_(q.id);else if(q.name==="SegmentTemplate")for(u=b.modifySegmentTemplate_(m),w=(0,$jscomp.makeIterator)(u),v=w.next();!v.done;v=w.next())x=v.value,h.add(x);else if(q.name==="SegmentTimeline"||q.name==="S")for(y=b.modifyTimepoints_(m),A=(0,$jscomp.makeIterator)(y),B=A.next();!B.done;B=
A.next())D=B.value,h.add(D);else n=!1;n||shaka.log.warning("Unhandled "+m.tagName+" operation",m.attributes.sel)}z=(0,$jscomp.makeIterator)(h);for(C=z.next();!C.done;C=z.next())E=C.value,b.parsePatchSegment_(E);G=(0,$jscomp.makeIterator)(g);for(I=G.next();!I.done;I=G.next())F=I.value,f.push.apply(f,(0,$jscomp.arrayFromIterable)(b.parsePatchPeriod_(F)));if(!f.length)return K.jumpTo(2);b.manifest_.periodCount+=f.length;b.manifest_.gapCount=b.gapCount_;return K.yield(b.postPeriodProcessing_(f,!0),2)}b.manifestPatchContext_.type==
"static"&&(J=b.manifestPatchContext_.mediaPresentationDuration,b.manifest_.presentationTimeline.setDuration(J||Infinity));K.jumpToEnd()})};shaka.dash.DashParser.prototype.parsePatchMpdTypeChange_=function(a){this.manifest_.presentationTimeline.setStatic(a=="static");this.manifestPatchContext_.type=a;for(var b=(0,$jscomp.makeIterator)(this.contextCache_.values()),c=b.next();!c.done;c=b.next())c.value.dynamic=a=="dynamic";a=="static"&&(this.updatePeriod_=-1)};
shaka.dash.DashParser.prototype.parsePatchMediaPresentationDurationChange_=function(a){a=shaka.util.TXml.parseDuration(a);if(a!=null){this.manifestPatchContext_.mediaPresentationDuration=a;for(var b=(0,$jscomp.makeIterator)(this.contextCache_.values()),c=b.next();!c.done;c=b.next())c.value.mediaPresentationDuration=a}};
shaka.dash.DashParser.prototype.parsePatchPeriod_=function(a){goog.asserts.assert(this.manifestPatchContext_.getBaseUris,"Must provide getBaseUris on manifestPatchContext_");return this.parsePeriods_({dynamic:this.manifestPatchContext_.type=="dynamic",presentationTimeline:this.manifest_.presentationTimeline,period:null,periodInfo:null,adaptationSet:null,representation:null,bandwidth:0,indexRangeWarningGiven:!1,availabilityTimeOffset:this.manifestPatchContext_.availabilityTimeOffset,profiles:this.manifestPatchContext_.profiles,
mediaPresentationDuration:this.manifestPatchContext_.mediaPresentationDuration,roles:null,urlParams:shaka.dash.DashParser.defaultUrlParams_},this.manifestPatchContext_.getBaseUris,a,!0).periods};
shaka.dash.DashParser.prototype.removePatchPeriod_=function(a){var b=shaka.dash.SegmentTemplate;this.manifest_.periodCount--;for(var c=(0,$jscomp.makeIterator)(this.contextCache_.keys()),d=c.next();!d.done;d=c.next())if(d=d.value,d.startsWith(a)){var e=this.contextCache_.get(d);b.removeTimepoints(e);this.parsePatchSegment_(d);this.contextCache_.delete(d)}this.lastManifestUpdatePeriodIds_=this.lastManifestUpdatePeriodIds_.filter(function(f){return f!==a});this.parsedPeriodCache_.delete(a)};
shaka.dash.DashParser.prototype.getContextIdsFromPath_=function(a){var b="",c="",d=-1,e="";a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next())f=f.value,f.name==="Period"?b=f.id:f.name==="AdaptationSet"?(c=f.id,f.position!==null&&(d=f.position)):f.name==="Representation"&&(e=f.id);a=[];if(e)a.push(b+","+e);else if(c)for(d=(0,$jscomp.makeIterator)(this.contextCache_.values()),e=d.next();!e.done;e=d.next())e=e.value,e.period.id===b&&e.adaptationSet.id===c&&e.representation.id&&a.push(b+
","+e.representation.id);else if(d>-1)for(c=(0,$jscomp.makeIterator)(this.contextCache_.values()),e=c.next();!e.done;e=c.next())e=e.value,e.period.id===b&&e.adaptationSet.position===d&&e.representation.id&&a.push(b+","+e.representation.id);return a};
shaka.dash.DashParser.prototype.modifySegmentTemplate_=function(a){var b=shaka.util.TXml,c=b.parseXpath(a.attributes.sel||""),d=c[c.length-1];if(!d.attribute)return[];c=this.getContextIdsFromPath_(c);for(var e=b.getContents(a)||"",f=(0,$jscomp.makeIterator)(c),g=f.next();!g.done;g=f.next())g=this.contextCache_.get(g.value),goog.asserts.assert(g&&g.representation.segmentTemplate,"cannot modify segment template"),b.modifyNodeAttribute(g.representation.segmentTemplate,a.tagName,d.attribute,e);return c};
shaka.dash.DashParser.prototype.modifyTimepoints_=function(a){var b=shaka.dash.SegmentTemplate,c=shaka.util.TXml.parseXpath(a.attributes.sel||"");c=this.getContextIdsFromPath_(c);for(var d=(0,$jscomp.makeIterator)(c),e=d.next();!e.done;e=d.next())e=this.contextCache_.get(e.value),b.modifyTimepoints(e,a);return c};
shaka.dash.DashParser.prototype.parsePatchSegment_=function(a){var b=this,c=this.contextCache_.get(a),d=this.streamMap_.get(a);goog.asserts.assert(d,"stream should exist");d.segmentIndex&&d.segmentIndex.evict(this.manifest_.presentationTimeline.getSegmentAvailabilityStart());try{var e=shaka.dash.SegmentTemplate.createStreamInfo(c,function(g,h,k,l){return b.requestSegment_(g,h,k,l)},this.streamMap_,!0,this.config_.dash.initialSegmentLimit,this.periodDurations_,c.representation.aesKey,null,!0,this.continuityCache_);
d.createSegmentIndex=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return d.segmentIndex?g.jumpTo(0):g.yield(e.generateSegmentIndex(),3);d.segmentIndex=g.getYieldResultJsc();g.jumpToEnd()})}}catch(g){a=shaka.util.ManifestParserUtils.ContentType;c=c.representation.contentType;var f=c==a.IMAGE;if(c!=a.TEXT&&c!=a.APPLICATION&&!f||g.code!=shaka.util.Error.Code.DASH_NO_SEGMENT_INFO)throw g;}};
shaka.dash.DashParser.prototype.parseServiceDescription_=function(a){var b=shaka.util.TXml,c=b.findChild(a,"ServiceDescription");if(!c)return null;a=b.findChild(c,"Latency");b=b.findChild(c,"PlaybackRate");if(!a&&!b)return null;c={};a&&("target"in a.attributes&&(c.targetLatency=parseInt(a.attributes.target,10)/1E3),"max"in a.attributes&&(c.maxLatency=parseInt(a.attributes.max,10)/1E3),"min"in a.attributes&&(c.minLatency=parseInt(a.attributes.min,10)/1E3));b&&("max"in b.attributes&&(c.maxPlaybackRate=
parseFloat(b.attributes.max)),"min"in b.attributes&&(c.minPlaybackRate=parseFloat(b.attributes.min)));return c};shaka.dash.DashParser.prototype.parseMpdChaining_=function(a){a=shaka.util.TXml.findChildren(a,"SupplementalProperty");if(!a.length)return null;a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value,b.attributes.schemeIdUri=="urn:mpeg:dash:chaining:2016")return b.attributes.value;return null};
shaka.dash.DashParser.prototype.parsePeriods_=function(a,b,c,d){var e=shaka.util.TXml,f=a.mediaPresentationDuration;f||(f=e.parseAttr(c,"mediaPresentationDuration",e.parseDuration),this.manifestPatchContext_.mediaPresentationDuration=f);var g=0;this.manifest_&&this.manifest_.presentationTimeline&&this.isTransitionFromDynamicToStatic_&&(g=this.manifest_.presentationTimeline.getSeekRangeStart());var h=[],k=g;c=e.findChildren(c,"Period");var l=a.dynamic;l||this.parsedPeriodCache_.clear();for(var m=l&&
!d?new Set(this.lastManifestUpdatePeriodIds_.slice(1,-1)):null,n=0;n<c.length;n++){var p=c[n],q=c[n+1],r=e.parseAttr(p,"start",e.parseDuration,k),t=p.attributes.id,u=e.parseAttr(p,"duration",e.parseDuration);r=n==0&&r==0&&this.isTransitionFromDynamicToStatic_?g:r;var w=null;if(q){var v=e.parseAttr(q,"start",e.parseDuration);v!=null&&(w=v-r+g)}else f!=null&&(w=f-r+g);v=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;w&&u&&Math.abs(w-u)>v&&(shaka.log.warning("There is a gap/overlap between Periods",
p),w>u&&this.gapCount_++);w==null&&(w=u);if(this.largestPeriodStartTime_!==null&&t!=null&&r!==null&&r<this.largestPeriodStartTime_&&!this.lastManifestUpdatePeriodIds_.includes(t)&&n+1!=c.length)shaka.log.debug("Skipping Period with ID "+t+" as its start time is smaller than the largest period start time that has been seen, and ID is unseen before");else{r!==null&&(this.largestPeriodStartTime_===null||r>this.largestPeriodStartTime_)&&(this.largestPeriodStartTime_=r);k={start:r,duration:w,node:p,isLastPeriod:w==
null||!q};p=null;u=n>0&&n<c.length-1;l&&m&&u&&!d&&(t!=null||(t=this.periodIdFallback_(r)),m.has(t)&&(t=this.parsedPeriodCache_.get(t))&&(p=t));p||(p=this.parsePeriod_(a,b,k),l&&p.id&&this.parsedPeriodCache_.set(p.id,p));h.push(p);p.id&&w&&this.periodDurations_.set(p.id,w);if(w==null){q&&shaka.log.warning("Skipping Period",n+1,"and any subsequent Periods:","Period",n+1,"does not have a valid start time.",q);k=null;break}k=r+w}}l&&!d&&this.prunePeriodCache_(h);if(d)for(a=(0,$jscomp.makeIterator)(h),
b=a.next();!b.done;b=a.next())b=b.value.id,this.lastManifestUpdatePeriodIds_.includes(b)||this.lastManifestUpdatePeriodIds_.push(b);else this.lastManifestUpdatePeriodIds_=h.map(function(x){return x.id});return f!=null?(k!=null&&Math.abs(k-g-f)>shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&shaka.log.warning("@mediaPresentationDuration does not match the total duration ","of all Periods."),{periods:h,duration:f+g,durationDerivedFromPeriods:!1}):{periods:h,duration:k,durationDerivedFromPeriods:!0}};
shaka.dash.DashParser.prototype.prunePeriodCache_=function(a){a=new Set(a.map(function(d){return d.id}));for(var b=(0,$jscomp.makeIterator)(Array.from(this.parsedPeriodCache_.keys())),c=b.next();!c.done;c=b.next())c=c.value,a.has(c)||this.parsedPeriodCache_.delete(c)};shaka.dash.DashParser.prototype.periodIdFallback_=function(a){return"__shaka_period_"+a};
shaka.dash.DashParser.prototype.cleanStreamMap_=function(){var a=this,b=Array.from(this.indexStreamMap_.keys()).filter(function(h){return!a.lastManifestUpdatePeriodIds_.includes(h)});b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next()){c=c.value;for(var d=!0,e=(0,$jscomp.makeIterator)(this.indexStreamMap_.get(c)),f=e.next();!f.done;f=e.next()){f=f.value;var g=this.streamMap_.get(f);g&&(g.segmentIndex&&!g.segmentIndex.isEmpty()?d=!1:(this.periodCombiner_&&this.periodCombiner_.deleteStream(g,
c),this.streamMap_.delete(f)))}d&&this.indexStreamMap_.delete(c)}};shaka.dash.DashParser.prototype.cleanContinuityCache_=function(a){a=new Set(a.map(function(d){return d.id}));for(var b=(0,$jscomp.makeIterator)(this.continuityCache_.keys()),c=b.next();!c.done;c=b.next())c=c.value,a.has(c)||this.continuityCache_.delete(c)};
shaka.dash.DashParser.prototype.parsePeriod_=function(a,b,c){var d=this,e=shaka.util.Functional,f=shaka.util.TXml,g=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(c.node,"periodInfo.node should exist");a.period=this.createFrame_(c.node,null,b);a.periodInfo=c;a.period.availabilityTimeOffset=a.availabilityTimeOffset;a.period.id||(shaka.log.info("No Period ID given for Period with start time "+c.start+",  Assigning a default"),a.period.id=this.periodIdFallback_(c.start));var h=f.findChildren(c.node,
"EventStream");b=a.presentationTimeline.getSegmentAvailabilityStart();h=(0,$jscomp.makeIterator)(h);for(var k=h.next();!k.done;k=h.next())this.parseEventStream_(c.start,c.duration,k.value,b);b=f.findChildren(c.node,"SupplementalProperty");b=(0,$jscomp.makeIterator)(b);for(h=b.next();!h.done;h=b.next())if(h=h.value,h.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"&&(h=this.getURLParametersFunction_(h)))a.urlParams=h;b=f.findChildren(c.node,"AdaptationSet").map(function(u,w){return d.parseAdaptationSet_(a,
w,u)}).filter(e.isNotNull);if(a.dynamic){h=[];k=(0,$jscomp.makeIterator)(b);for(var l=k.next();!l.done;l=k.next()){l=(0,$jscomp.makeIterator)(l.value.representationIds);for(var m=l.next();!m.done;m=l.next())h.push(m.value)}k=new Set(h);if(h.length!=k.size)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_DUPLICATE_REPRESENTATION_ID);}h=new Map;k=(0,$jscomp.makeIterator)(b);for(l=k.next();!l.done;l=k.next())for(l=(0,$jscomp.makeIterator)(l.value.dependencyStreamMap),
m=l.next();!m.done;m=l.next()){var n=(0,$jscomp.makeIterator)(m.value);m=n.next().value;n=n.next().value;h.set(m,n)}if(h.size)for(k=null,l=(0,$jscomp.makeIterator)(b),m=l.next();!m.done;m=l.next()){m=m.value;n=[];for(var p=(0,$jscomp.makeIterator)(m.streams),q=p.next(),r={};!q.done;r={stream$jscomp$127:void 0},q=p.next())if(r.stream$jscomp$127=q.value,h.has(r.stream$jscomp$127.originalId)){k||(k=f.findChildren(c.node,"AdaptationSet").map(function(u,w){return d.parseAdaptationSet_(a,w,u)}).filter(e.isNotNull));
q=(0,$jscomp.makeIterator)(k);for(var t=q.next();!t.done;t=q.next())if(t=t.value.streams.find(function(u){return function(w){return w.originalId==u.stream$jscomp$127.originalId}}(r)))t.dependencyStream=h.get(t.originalId),t.originalId+=t.dependencyStream.originalId,n.push(t)}n.length&&m.streams.push.apply(m.streams,(0,$jscomp.arrayFromIterable)(n))}c=(0,$jscomp.makeIterator)(shaka.util.ArrayUtils.partition(b,function(u){return!!u.trickModeFor}));e=c.next().value;c=c.next().value;if(!this.config_.disableIFrames)for(e=
(0,$jscomp.makeIterator)(e),f=e.next();!f.done;f=e.next())for(f=f.value,b=f.trickModeFor.split(" "),h=(0,$jscomp.makeIterator)(c),k=h.next();!k.done;k=h.next())if(k=k.value,b.includes(k.id))for(k=(0,$jscomp.makeIterator)(k.streams),l=k.next();!l.done;l=k.next())shaka.util.StreamUtils.setBetterIFrameStream(l.value,f.streams);e=this.getStreamsFromSets_(this.config_.disableAudio,c,g.AUDIO);f=this.getStreamsFromSets_(this.config_.disableVideo,c,g.VIDEO);b=this.getStreamsFromSets_(this.config_.disableText,
c,g.TEXT);g=this.getStreamsFromSets_(this.config_.disableThumbnails,c,g.IMAGE);if(f.length===0&&e.length===0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_EMPTY_PERIOD);return{id:a.period.id,audioStreams:e,videoStreams:f,textStreams:b,imageStreams:g}};
shaka.dash.DashParser.prototype.getStreamsFromSets_=function(a,b,c){return a||!b.length?[]:b.reduce(function(d,e){if(e.contentType!=c)return d;d.push.apply(d,(0,$jscomp.arrayFromIterable)(e.streams));return d},[])};
shaka.dash.DashParser.prototype.parseAdaptationSet_=function(a,b,c){var d=this,e=shaka.util.TXml,f=shaka.util.Functional,g=shaka.util.ManifestParserUtils,h=g.ContentType;a.adaptationSet=this.createFrame_(c,a.period,null);a.adaptationSet.position=b;var k=!1,l=e.findChildren(c,"Role"),m=l.map(function(F){return F.attributes.value}).filter(f.isNotNull),n=void 0;if(b=a.adaptationSet.contentType==h.TEXT)n=g.TextStreamKind.SUBTITLE;f=(0,$jscomp.makeIterator)(l);for(l=f.next();!l.done;l=f.next()){l=l.value;
var p=l.attributes.schemeIdUri;if(p==null||p=="urn:mpeg:dash:role:2011")switch(l=l.attributes.value,l){case "main":k=!0;break;case "caption":case "subtitle":n=l}}l=function(F){switch(F){case 1:case 6:case 13:case 14:case 15:return"SDR";case 16:return"PQ";case 18:return"HLG"}};p=function(F){switch(F){case 1:case 5:case 6:case 7:return"srgb";case 9:return"rec2020";case 11:case 12:return"p3"}};var q=function(F){var J=F.attributes["dvb:fontFamily"];F=F.attributes["dvb:url"];J&&F&&(F=shaka.util.ManifestParserUtils.resolveUris(a.adaptationSet.getBaseUris(),
[F],a.urlParams()),d.playerInterface_.addFont(J,F[0]))},r=e.findChildren(c,"EssentialProperty");f=null;var t=!1,u=null,w=!1;r=(0,$jscomp.makeIterator)(r);for(var v=r.next();!v.done;v=r.next()){v=v.value;var x=v.attributes.schemeIdUri;if(x=="http://dashif.org/guidelines/trickmode")f=v.attributes.value;else if(x=="urn:mpeg:mpegB:cicp:TransferCharacteristics")var y=l(parseInt(v.attributes.value,10));else if(x=="urn:mpeg:mpegB:cicp:ColourPrimaries")var A=p(parseInt(v.attributes.value,10));else x!="urn:mpeg:mpegB:cicp:MatrixCoefficients"&&
(x=="urn:mpeg:dash:ssr:2023"&&this.config_.dash.enableFastSwitching?t=!0:x=="urn:dvb:dash:fontdownload:2014"?q(v):x=="urn:mpeg:dash:urlparam:2014"?(u=this.getURLParametersFunction_(v))||(w=!0):w=!0)}if(w)return null;var B=null;w=e.findChildren(c,"SupplementalProperty");w=(0,$jscomp.makeIterator)(w);for(r=w.next();!r.done;r=w.next())r=r.value,v=r.attributes.schemeIdUri,v=="http://dashif.org/guidelines/last-segment-number"?B=parseInt(r.attributes.value,10)-1:v=="urn:mpeg:mpegB:cicp:TransferCharacteristics"?
y=l(parseInt(r.attributes.value,10)):v=="urn:mpeg:mpegB:cicp:ColourPrimaries"?A=p(parseInt(r.attributes.value,10)):v=="urn:dvb:dash:fontdownload:2014"?q(r):v=="urn:mpeg:dash:urlparam:2014"&&(u=this.getURLParametersFunction_(r));u&&(a.urlParams=u);p=e.findChildren(c,"Accessibility");l=shaka.util.LanguageUtils;var D=new Map;p=(0,$jscomp.makeIterator)(p);for(q=p.next();!q.done;q=p.next())if(u=q.value,q=u.attributes.schemeIdUri,u=u.attributes.value,q=="urn:scte:dash:cc:cea-608:2015"&&!this.config_.disableText)if(q=
1,u!=null)for(u=u.split(";"),w=(0,$jscomp.makeIterator)(u),r=w.next();!r.done;r=w.next())v=r.value,x=r=void 0,v.includes("=")?(v=v.split("="),r=v[0].startsWith("CC")?v[0]:"CC"+v[0],x=v[1]||"und"):(r="CC"+q,u.length==2?q+=2:q++,x=v),D.set(r,l.normalize(x));else D.set("CC1","und");else if(q=="urn:scte:dash:cc:cea-708:2015"&&!this.config_.disableText)if(q=1,u!=null)for(u=(0,$jscomp.makeIterator)(u.split(";")),w=u.next();!w.done;w=u.next())r=w.value,v=w=void 0,r.includes("=")?(r=r.split("="),w="svc"+
r[0],v=r[1].split(",")[0].split(":").pop()):(w="svc"+q,q++,v=r),D.set(w,l.normalize(v));else D.set("svc1","und");else if(q=="urn:mpeg:dash:role:2011")u!=null&&(m.push(u),u=="captions"&&(n=g.TextStreamKind.CLOSED_CAPTION));else if(q=="urn:tva:metadata:cs:AudioPurposeCS:2007")if(u=="1")var z=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED;else u=="2"?z=shaka.media.ManifestParser.AccessibilityPurpose.HARD_OF_HEARING:u=="9"&&(z=shaka.media.ManifestParser.AccessibilityPurpose.SPOKEN_SUBTITLES);
g=e.findChildren(c,"ContentProtection");var C=this.contentProtection_.parseFromAdaptationSet(g,this.config_.ignoreDrmInfo,this.config_.dash.keySystemsByURI);a.adaptationSet.encrypted=g.length>0;var E=shaka.util.LanguageUtils.normalize(a.adaptationSet.language||"und"),G=a.adaptationSet.label,I=new Map;c=e.findChildren(c,"Representation");if(!this.config_.ignoreSupplementalCodecs){g=[];l=(0,$jscomp.makeIterator)(c);for(p=l.next();!p.done;p=l.next())if(q=p.value,p=e.getAttributeNS(q,shaka.dash.DashParser.SCTE214_,
"supplementalCodecs"))q=shaka.util.ObjectUtils.cloneObject(q),q.attributes.codecs=p.split(" ").join(","),q.attributes.id&&(q.attributes.supplementalId=q.attributes.id+"_supplementalCodecs"),g.push(q);c.push.apply(c,(0,$jscomp.arrayFromIterable)(g))}e=c.map(function(F){var J=d.parseRepresentation_(a,C,n,E,G,k,m,D,F,z,B);return J&&(J.hdr=J.hdr||y,J.colorGamut=J.colorGamut||A,J.fastSwitching=t,F=F.attributes.dependencyId)?(J.baseOriginalId=F,I.set(F,J),null):J}).filter(function(F){return!!F});if(e.length==
0&&I.size==0){f=a.adaptationSet.contentType==h.IMAGE;if(this.config_.dash.ignoreEmptyAdaptationSet||b||f)return null;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_EMPTY_ADAPTATION_SET);}if(!a.adaptationSet.contentType||a.adaptationSet.contentType==h.APPLICATION)for(a.adaptationSet.contentType=shaka.dash.DashParser.guessContentType_(e[0].mimeType,e[0].codecs),h=(0,$jscomp.makeIterator)(e),b=h.next();!b.done;b=h.next())b.value.type=
a.adaptationSet.contentType;h=a.adaptationSet.id||"__fake__"+this.globalId_++;b=(0,$jscomp.makeIterator)(e);for(g=b.next();!g.done;g=b.next()){g=g.value;l=(0,$jscomp.makeIterator)(C.drmInfos);for(p=l.next();!p.done;p=l.next())p=p.value,p.keyIds=p.keyIds&&g.keyIds?new Set([].concat((0,$jscomp.arrayFromIterable)(p.keyIds),(0,$jscomp.arrayFromIterable)(g.keyIds))):p.keyIds||g.keyIds;this.config_.enableAudioGroups&&(g.groupId=h)}b=c.map(function(F){return F.attributes.supplementalId||F.attributes.id}).filter(shaka.util.Functional.isNotNull);
return{id:h,contentType:a.adaptationSet.contentType,language:E,main:k,streams:e,drmInfos:C.drmInfos,trickModeFor:f,representationIds:b,dependencyStreamMap:I}};
shaka.dash.DashParser.prototype.getURLParametersFunction_=function(a){var b=this,c=shaka.util.TXml;if((a=c.findChildNS(a,shaka.dash.DashParser.UP_NAMESPACE_,"UrlQueryInfo"))&&c.parseAttr(a,"useMPDUrlQuery",c.parseBoolean,!1)){var d=a.attributes.queryTemplate;if(d)return function(){return d=="$querypart$"?b.lastManifestQueryParams_:d.split("&").map(function(e){if(e=="$querypart$")return b.lastManifestQueryParams_;var f=/\$query:(.*?)\$/g.exec(e);if(f&&f.length==2){f=f[1];var g=(new goog.Uri.QueryData(b.lastManifestQueryParams_)).get(f);
if(g.length)return f+"="+g[0]}return e}).join("&")}}return null};
shaka.dash.DashParser.prototype.parseRepresentation_=function(a,b,c,d,e,f,g,h,k,l,m){var n=this,p=shaka.util.TXml,q=shaka.util.ManifestParserUtils.ContentType;a.representation=this.createFrame_(k,a.adaptationSet,null);var r=a.representation.id;this.minTotalAvailabilityTimeOffset_=Math.min(this.minTotalAvailabilityTimeOffset_,a.representation.availabilityTimeOffset);this.isLowLatency_=this.minTotalAvailabilityTimeOffset_>0;if(!this.verifyRepresentation_(a.representation))return shaka.log.warning("Skipping Representation",a.representation),
null;var t=a.periodInfo.start;a.bandwidth=p.parseAttr(k,"bandwidth",p.parsePositiveInt)||0;a.roles=g;var u=p.findChildren(k,"SupplementalProperty"),w=p.findChildren(k,"EssentialProperty");p=p.findChildren(k,"ContentProtection");k=null;var v=w.find(function(M){return M.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"});v?k=this.getURLParametersFunction_(v):(v=u.find(function(M){return M.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"}))&&(k=this.getURLParametersFunction_(v));k&&(a.urlParams=
k);v=a.representation.contentType;k=v==q.TEXT||v==q.APPLICATION;q=v==q.IMAGE;p.length&&(a.adaptationSet.encrypted=!0);try{var x=void 0;if(b.aes128Info){var y=a.representation.getBaseUris,A=a.urlParams,B=shaka.util.ManifestParserUtils.resolveUris(y(),[b.aes128Info.keyUri],A()),D=shaka.net.NetworkingEngine.RequestType.KEY,z=shaka.net.NetworkingEngine.makeRequest(B,this.config_.retryParameters);x={bitsKey:128,blockCipherMode:"CBC",iv:b.aes128Info.iv,firstMediaSequenceNumber:0,fetchKey:function(){var M,
L,N;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==1)return P.yield(n.makeNetworkRequest_(z,D),2);if(P.getNextAddressJsc()!=3){M=P.getYieldResultJsc();if(!M.data||M.data.byteLength!=16)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.AES_128_INVALID_KEY_LENGTH);L={name:"AES-CBC"};N=x;return P.yield(window.crypto.subtle.importKey("raw",M.data,L,!0,["decrypt"]),3)}N.cryptoKey=P.getYieldResultJsc();
x.fetchKey=void 0;P.jumpToEnd()})}}}a.representation.aesKey=x;y=function(M,L,N,P){return n.requestSegment_(M,L,N,P)};if(a.representation.segmentBase)var C=shaka.dash.SegmentBase.createStreamInfo(a,y,x);else if(a.representation.segmentList)C=shaka.dash.SegmentList.createStreamInfo(a,this.streamMap_,x);else if(a.representation.segmentTemplate)C=shaka.dash.SegmentTemplate.createStreamInfo(a,y,this.streamMap_,!!this.manifest_,this.config_.dash.initialSegmentLimit,this.periodDurations_,x,m,!1,this.continuityCache_);
else{goog.asserts.assert(k,"Must have Segment* with non-text streams.");var E=a.periodInfo.duration||0,G=a.representation.getBaseUris,I=a.representation.mimeType,F=a.representation.codecs;C={endTime:-1,timeline:-1,generateSegmentIndex:function(){var M=shaka.media.SegmentIndex.forSingleSegment(t,E,G());M.forEachTopLevelReference(function(L){L.mimeType=I;L.codecs=F});return Promise.resolve(M)},timescale:1}}}catch(M){if((k||q)&&M.code==shaka.util.Error.Code.DASH_NO_SEGMENT_INFO)return null;throw M;}m=
this.contentProtection_.parseFromRepresentation(p,b,this.config_.ignoreDrmInfo,this.config_.dash.keySystemsByURI);m=new Set(m?[m]:[]);y=u.some(function(M){return M.attributes.schemeIdUri=="tag:dolby.com,2018:dash:EC3_ExtensionType:2018"&&M.attributes.value=="JOC"});u=u.some(function(M){return M.attributes.schemeIdUri=="tag:dolby.com,2016:dash:virtualized_content:2016"&&M.attributes.value=="1"});u=y||u;y=!1;k&&(y=g.includes("forced_subtitle")||g.includes("forced-subtitle"));var J;if(q&&((w=w.find(function(M){return["http://dashif.org/thumbnail_tile",
"http://dashif.org/guidelines/thumbnail_tile"].includes(M.attributes.schemeIdUri)}))&&(J=w.attributes.value),!J))return null;var K;k=a.representation.codecs;a.profiles.includes("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&(k.includes("hvc1.2.4.L153.B0")||k.includes("hev1.2.4.L153.B0"))&&(K="PQ");w=a.representation.id?a.period.id+","+a.representation.id:"";this.patchLocationNodes_.length&&r&&this.contextCache_.set(a.period.id+","+r,this.cloneContext_(a));a.representation.producerReferenceTime&&
this.parseProducerReferenceTime_(a.representation.producerReferenceTime,C,a.presentationTimeline);C.endTime!=-1&&a.period.id!=null&&a.representation.id!=null&&((r=this.continuityCache_.get(a.period.id))?(r.endTime=C.endTime,r.reps.includes(a.representation.id)||r.reps.push(a.representation.id),this.continuityCache_.set(a.period.id,r)):this.continuityCache_.set(a.period.id,{endTime:C.endTime,timeline:C.timeline,reps:[a.representation.id]}));var H=w&&this.streamMap_.has(w)?this.streamMap_.get(w):{id:this.globalId_++,
originalId:a.representation.id,groupId:null,createSegmentIndex:function(){return Promise.resolve()},closeSegmentIndex:function(){H.segmentIndex&&(H.segmentIndex.release(),H.segmentIndex=null)},segmentIndex:null,mimeType:a.representation.mimeType,codecs:k,frameRate:a.representation.frameRate,pixelAspectRatio:a.representation.pixelAspectRatio,bandwidth:a.bandwidth,width:a.representation.width,height:a.representation.height,kind:c,encrypted:b.drmInfos.length>0,drmInfos:b.drmInfos,keyIds:m,language:d,
originalLanguage:a.adaptationSet.language,label:e,type:a.adaptationSet.contentType,primary:f,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:a.representation.emsgSchemeIdUris,roles:g,forced:y,channelsCount:a.representation.numChannels,audioSamplingRate:a.representation.audioSamplingRate,spatialAudio:u,closedCaptions:h,hdr:K,colorGamut:void 0,videoLayout:void 0,tilesLayout:J,accessibilityPurpose:l,external:!1,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(a.representation.mimeType,
a.representation.codecs)]),isAudioMuxedInVideo:!1,baseOriginalId:null};H.createSegmentIndex=function(){var M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(L){if(L.getNextAddressJsc()==1){if(H.segmentIndex)return L.jumpTo(0);M=H;return L.yield(C.generateSegmentIndex(),3)}M.segmentIndex=L.getYieldResultJsc();L.jumpToEnd()})};w&&a.dynamic&&!this.streamMap_.has(w)&&(a=a.period.id||"",this.indexStreamMap_.has(a)||this.indexStreamMap_.set(a,[]),this.streamMap_.set(w,H),this.indexStreamMap_.get(a).push(w));
return H};
shaka.dash.DashParser.prototype.parseProducerReferenceTime_=function(a,b,c){var d=shaka.util.TXml;if(!this.parsedPrftNodes_.has(a)){this.parsedPrftNodes_.add(a);var e=d.parseAttr(a,"presentationTime",d.parseNonNegativeInt)||0,f=d.findChild(a,"UTCTiming");f&&f.attributes.schemeIdUri&&!shaka.dash.DashParser.isNtpScheme_(f.attributes.schemeIdUri)?a=(d.parseAttr(a,"wallClockTime",d.parseDate)||0)*1E3:(a=d.parseAttr(a,"wallClockTime",d.parseNonNegativeInt)||0,a=shaka.util.TimeUtils.convertNtp(a));b=new Date(a-
e/b.timescale*1E3);e=b.getTime()/1E3;isNaN(e)||(c.isStartTimeLocked()||c.setInitialProgramDateTime(e),b={wallClockTime:a,programStartDate:b},c=shaka.util.FakeEvent.EventName.Prft,b=(new Map).set("detail",b),c=new shaka.util.FakeEvent(c,b),this.playerInterface_.onEvent(c))}};
shaka.dash.DashParser.prototype.cloneContext_=function(a){var b=function(c){if(!c)return null;c=shaka.util.ObjectUtils.shallowCloneObject(c);c.segmentBase=null;c.segmentList=null;c.segmentTemplate=shaka.util.TXml.cloneNode(c.segmentTemplate);c.producerReferenceTime=null;return c};a=shaka.util.ObjectUtils.shallowCloneObject(a);a.period=b(a.period);a.adaptationSet=b(a.adaptationSet);a.representation=b(a.representation);a.periodInfo&&(a.periodInfo=shaka.util.ObjectUtils.shallowCloneObject(a.periodInfo),
a.periodInfo.node=null);return a};
shaka.dash.DashParser.prototype.onUpdate_=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){case 1:return goog.asserts.assert(a.updatePeriod_>=0,"There should be an update period"),shaka.log.info("Updating manifest..."),b=0,d.setCatchFinallyBlocks(2),d.yield(a.requestManifest_(),4);case 4:b=d.getYieldResultJsc();d.leaveTryBlock(3);break;case 2:if(c=d.enterCatchBlock(),goog.asserts.assert(c instanceof shaka.util.Error,"Should only receive a Shaka error"),
a.playerInterface_){if(a.config_.raiseFatalErrorOnManifestUpdateRequestFailure)return a.playerInterface_.onError(c),d.return();c.severity=shaka.util.Error.Severity.RECOVERABLE;a.playerInterface_.onError(c)}case 3:if(!a.playerInterface_)return d.return();a.playerInterface_.onManifestUpdated();a.setUpdateTimer_(b);d.jumpToEnd()}})};shaka.dash.DashParser.prototype.updateNow_=function(){this.updateTimer_.tickNow()};
shaka.dash.DashParser.prototype.setUpdateTimer_=function(a){if(!(this.updatePeriod_<0)){var b=this.updatePeriod_;this.config_.updatePeriod>=0&&(b=this.config_.updatePeriod);a=Math.max(b-a,this.averageUpdateDuration_.getEstimate());this.updateTimer_.tickAfter(a)}};
shaka.dash.DashParser.prototype.createFrame_=function(a,b,c){goog.asserts.assert(b||c,"Must provide either parent or getBaseUris");var d=shaka.media.SegmentUtils,e=shaka.util.ManifestParserUtils,f=shaka.util.TXml;b=b||{contentType:"",mimeType:"",codecs:"",emsgSchemeIdUris:[],frameRate:void 0,pixelAspectRatio:void 0,numChannels:null,audioSamplingRate:null,availabilityTimeOffset:0,segmentSequenceCadence:1,encrypted:!1};c=c||b.getBaseUris;var g=f.parseNonNegativeInt,h=f.evalDivision,k=a.attributes.id,
l=a.attributes.supplementalId,m=f.findChildren(a,"BaseURL"),n,p=!1;if(this.contentSteeringManager_)for(var q=(0,$jscomp.makeIterator)(m),r=q.next();!r.done;r=q.next()){var t=r.value;r=t.attributes.serviceLocation;t=f.getContents(t);r&&t&&(this.contentSteeringManager_.addLocation(k,r,t),p=!0)}p&&this.contentSteeringManager_||(n=m.map(f.getContents));var u=this.contentSteeringManager_;q=a.attributes.contentType||b.contentType;r=a.attributes.mimeType||b.mimeType;d=d.codecsFiltering([a.attributes.codecs||
b.codecs]).join(",");h=f.parseAttr(a,"frameRate",h)||b.frameRate;t=a.attributes.sar||b.pixelAspectRatio;var w=this.emsgSchemeIdUris_(f.findChildren(a,"InbandEventStream"),b.emsgSchemeIdUris),v=f.findChildren(a,"AudioChannelConfiguration");v=this.parseAudioChannels_(v)||b.numChannels;var x=f.parseAttr(a,"audioSamplingRate",g)||b.audioSamplingRate;q||(q=shaka.dash.DashParser.guessContentType_(r,d));var y=f.findChild(a,"SegmentBase"),A=f.findChild(a,"SegmentTemplate"),B=y?f.parseAttr(y,"availabilityTimeOffset",
f.parseFloat)||0:0,D=A?f.parseAttr(A,"availabilityTimeOffset",f.parseFloat)||0:0,z=m&&m.length?f.parseAttr(m[0],"availabilityTimeOffset",f.parseFloat)||0:0;B=b.availabilityTimeOffset+z+B+D;D=null;(z=f.findChild(a,"SegmentSequenceProperties"))&&(z=f.parseAttr(z,"cadence",f.parsePositiveInt))&&(D=z);z=a.attributes.label;var C=f.findChildren(a,"Label");C&&C.length&&(C=C[0],f.getTextContents(C)&&(z=f.getTextContents(C)));return{getBaseUris:function(){return e.resolveUris(c(),m.length?u&&p?u.getLocations(k):
n?n:[]:[])},segmentBase:y||b.segmentBase,segmentList:f.findChild(a,"SegmentList")||b.segmentList,segmentTemplate:A||b.segmentTemplate,producerReferenceTime:f.findChild(a,"ProducerReferenceTime")||b.producerReferenceTime,width:f.parseAttr(a,"width",g)||b.width,height:f.parseAttr(a,"height",g)||b.height,contentType:q,mimeType:r,codecs:d,frameRate:h,pixelAspectRatio:t,emsgSchemeIdUris:w,id:l||k,originalId:k,language:a.attributes.lang,numChannels:v,audioSamplingRate:x,availabilityTimeOffset:B,initialization:null,
segmentSequenceCadence:D||b.segmentSequenceCadence,label:z||null,encrypted:!1}};shaka.dash.DashParser.prototype.emsgSchemeIdUris_=function(a,b){b=b.slice();a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value.attributes.schemeIdUri,b.includes(c)||b.push(c);return b};
shaka.dash.DashParser.prototype.parseAudioChannels_=function(a){a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){var c=b.value;if(b=c.attributes.schemeIdUri)if(c=c.attributes.value)switch(b){case "urn:mpeg:dash:outputChannelPositionList:2012":return c.trim().split(/ +/).length;case "urn:mpeg:dash:23003:3:audio_channel_configuration:2011":case "urn:dts:dash:audio_channel_configuration:2012":var d=parseInt(c,10);if(!d){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",
b,c);continue}return d;case "tag:dolby.com,2015:dash:audio_channel_configuration:2015":d=[2,1,2,2,2,2,1,2,2,1,1,1,1,2,1,1,2,2];var e=parseInt(c,16);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",b,c);continue}for(c=b=0;c<d.length;c++)e&1<<c&&(b+=d[c]);if(b)return b;continue;case "tag:dolby.com,2014:dash:audio_channel_configuration:2011":case "urn:dolby:dash:audio_channel_configuration:2011":d=[1,1,1,1,1,2,2,1,1,2,2,2,1,2,1,1].reverse();e=parseInt(c,16);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",
b,c);continue}for(c=b=0;c<d.length;c++)e&1<<c&&(b+=d[c]);if(b)return b;continue;case "urn:mpeg:mpegB:cicp:ChannelConfiguration":d=[0,1,2,3,4,5,6,8,2,3,4,7,8,24,8,12,10,12,14,12,14];e=parseInt(c,10);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",b,c);continue}if(e>0&&e<d.length)return d[e];continue;default:shaka.log.warning("Unrecognized audio channel scheme:",b,c)}}return null};
shaka.dash.DashParser.prototype.verifyRepresentation_=function(a){var b=shaka.util.ManifestParserUtils.ContentType;var c=a.segmentBase?1:0;c+=a.segmentList?1:0;c+=a.segmentTemplate?1:0;if(c==0){if(a.contentType==b.TEXT||a.contentType==b.APPLICATION)return!0;shaka.log.warning("Representation does not contain a segment information source:","the Representation must contain one of SegmentBase, SegmentList,",'SegmentTemplate, or explicitly indicate that it is "text".',a);return!1}c!=1&&(shaka.log.warning("Representation contains multiple segment information sources:",
"the Representation should only contain one of SegmentBase,","SegmentList, or SegmentTemplate.",a),a.segmentBase?(shaka.log.info("Using SegmentBase by default."),a.segmentList=null):(goog.asserts.assert(a.segmentList,"There should be a SegmentList"),shaka.log.info("Using SegmentList by default.")),a.segmentTemplate=null);return!0};
shaka.dash.DashParser.prototype.requestForTiming_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.getNextAddressJsc()==1)return e=[shaka.util.StringUtils.htmlUnescape(b)],f=shaka.util.ManifestParserUtils.resolveUris(a(),e),g=shaka.net.NetworkingEngine.makeRequest(f,d.config_.retryParameters),g.method=c,h=shaka.net.NetworkingEngine.RequestType.TIMING,k=d.playerInterface_.networkingEngine.request(h,g,{isPreload:d.isPreloadFn_()}),d.operationManager_.manage(k),
p.yield(k.promise,2);l=p.getYieldResultJsc();if(c=="HEAD"){if(!l.headers||!l.headers.date)return shaka.log.warning("UTC timing response is missing","expected date header"),p.return(0);m=l.headers.date}else m=shaka.util.StringUtils.fromUTF8(l.data);n=Date.parse(m);return isNaN(n)?(shaka.log.warning("Unable to parse date from UTC timing response"),p.return(0)):p.return(n-Date.now())})};
shaka.dash.DashParser.prototype.parseUtcTiming_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){switch(p.getNextAddressJsc()){case 1:d=b.map(function(q){return{scheme:q.attributes.schemeIdUri,value:q.attributes.value}}),e=c.config_.dash.clockSyncUri,!d.length&&e&&d.push({scheme:"urn:mpeg:dash:utc:http-head:2014",value:e}),f=(0,$jscomp.makeIterator)(d),g=f.next();case 2:if(g.done){p.jumpTo(4);break}h=g.value;p.setCatchFinallyBlocks(5);k=
h.scheme;l=h.value;switch(k){case "urn:mpeg:dash:utc:http-head:2014":case "urn:mpeg:dash:utc:http-head:2012":return p.jumpTo(7);case "urn:mpeg:dash:utc:http-xsdate:2014":case "urn:mpeg:dash:utc:http-iso:2014":case "urn:mpeg:dash:utc:http-xsdate:2012":case "urn:mpeg:dash:utc:http-iso:2012":return p.jumpTo(8);case "urn:mpeg:dash:utc:direct:2014":case "urn:mpeg:dash:utc:direct:2012":return m=Date.parse(l),p.return(isNaN(m)?0:m-Date.now());case "urn:mpeg:dash:utc:http-ntp:2014":case "urn:mpeg:dash:utc:ntp:2014":case "urn:mpeg:dash:utc:sntp:2014":shaka.log.alwaysWarn("NTP UTCTiming scheme is not supported");
break;default:shaka.log.alwaysWarn("Unrecognized scheme in UTCTiming element",k)}p.jumpTo(9);break;case 7:return p.yield(c.requestForTiming_(a,l,"HEAD"),10);case 10:return p.return(p.getYieldResultJsc());case 8:return p.yield(c.requestForTiming_(a,l,"GET"),11);case 11:return p.return(p.getYieldResultJsc());case 9:p.leaveTryBlock(3);break;case 5:n=p.enterCatchBlock(),shaka.log.warning("Error fetching time from UTCTiming elem",n.message);case 3:g=f.next();p.jumpTo(2);break;case 4:return shaka.log.alwaysWarn("A UTCTiming element should always be given in live manifests! This content may not play on clients with bad clocks!"),
p.return(0)}})};
shaka.dash.DashParser.prototype.parseEventStream_=function(a,b,c,d){var e=shaka.util.TXml,f=shaka.util.TXml.parseNonNegativeInt,g=c.attributes.schemeIdUri||"",h=c.attributes.value||"",k=e.parseAttr(c,"timescale",f)||1,l=e.parseAttr(c,"presentationTimeOffset",f)||0;c=(0,$jscomp.makeIterator)(e.findChildren(c,"Event"));for(var m=c.next();!m.done;m=c.next()){m=m.value;var n=e.parseAttr(m,"presentationTime",f)||0,p=e.parseAttr(m,"duration",f)||0;n=Math.max((n-l)/k+a,a);p=n+p/k;b!=null&&(n=Math.min(n,
a+b),p=Math.min(p,a+b));p<d||(m={schemeIdUri:g,value:h,startTime:n,endTime:p,id:m.attributes.id||"",timescale:k,eventElement:e.txmlNodeToDomElement(m),eventNode:e.cloneNode(m)},this.playerInterface_.onTimelineRegionAdded(m))}};
shaka.dash.DashParser.prototype.requestSegment_=function(a,b,c,d){var e=this,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1)return f=shaka.net.NetworkingEngine.RequestType.SEGMENT,g=d?shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT:shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT,h=shaka.net.NetworkingUtils.createSegmentRequest(a,b,c,e.config_.retryParameters),l.yield(e.makeNetworkRequest_(h,f,{type:g}),2);k=l.getYieldResultJsc();
return l.return(k.data)})};shaka.dash.DashParser.guessContentType_=function(a,b){b=shaka.util.MimeUtils.getFullType(a,b);return shaka.text.TextEngine.isTypeSupported(b)?shaka.util.ManifestParserUtils.ContentType.TEXT:a.split("/")[0]};shaka.dash.DashParser.prototype.makeNetworkRequest_=function(a,b,c){c||(c={});c.isPreload=this.isPreloadFn_();a=this.playerInterface_.networkingEngine.request(b,a,c);this.operationManager_.manage(a);return a.promise};
shaka.dash.DashParser.prototype.updatePatchLocationNodes_=function(a){shaka.util.TXml.modifyNodes(this.patchLocationNodes_,a)};
shaka.dash.DashParser.prototype.getPatchLocationUris_=function(){var a=shaka.util.TXml,b=this.manifestPatchContext_.publishTime;if(!this.manifestPatchContext_.mpdId||!b||!this.patchLocationNodes_.length)return[];var c=Date.now()/1E3,d=this.patchLocationNodes_.filter(function(e){e=a.parseNonNegativeInt(e.attributes.ttl);return!e||b+e>c}).map(a.getContents).filter(shaka.util.Functional.isNotNull);return d.length?shaka.util.ManifestParserUtils.resolveUris(this.manifestUris_,d):[]};
shaka.dash.DashParser.isNtpScheme_=function(a){return a==="urn:mpeg:dash:utc:http-ntp:2014"||a==="urn:mpeg:dash:utc:ntp:2014"||a==="urn:mpeg:dash:utc:sntp:2014"};shaka.dash.DashParser.defaultUrlParams_=function(){return""};shaka.dash.DashParser.makeBaseUriGetter_=function(a,b,c){return function(){return a&&b?a.getLocations("BaseURL"):c.slice()}};goog.exportSymbol("shaka.dash.DashParser",shaka.dash.DashParser);shaka.dash.DashParser.SCTE214_="urn:scte:dash:scte214-extensions";
shaka.dash.DashParser.UP_NAMESPACE_="urn:mpeg:dash:schema:urlparam:2014";shaka.media.ManifestParser.registerParserByMime("application/dash+xml",function(){return new shaka.dash.DashParser});shaka.media.ManifestParser.registerParserByMime("video/vnd.mpeg.dash.mpd",function(){return new shaka.dash.DashParser});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.device.AbstractDevice=function(){this.abstractDeviceType_=new shaka.util.Lazy(function(){for(var a=navigator.userAgent.toLowerCase(),b=(0,$jscomp.makeIterator)([{type:shaka.device.IDevice.DeviceType.VR,regex:/oculus|quest/},{type:shaka.device.IDevice.DeviceType.TV,regex:/smart[ _]?tv|android ?tv/},{type:shaka.device.IDevice.DeviceType.MOBILE,regex:/iphone|ipad|ipod|android/}]),c=b.next();!c.done;c=b.next())if(c=c.value,c.regex.test(a))return c.type;a=navigator.userAgentData;var d;b=(a==null?
void 0:(d=a.platform)==null?void 0:d.toLowerCase())||"";if(a){if(a.mobile)return shaka.device.IDevice.DeviceType.MOBILE;if(b.includes("android"))return shaka.device.IDevice.DeviceType.TV}return shaka.device.IDevice.DeviceType.DESKTOP});this.browserEngine_=new shaka.util.Lazy(function(){var a=navigator.userAgent;return navigator.vendor.includes("Apple")&&(a.includes("Version/")||a.includes("OS/"))?shaka.device.IDevice.BrowserEngine.WEBKIT:a.includes("Edge/")?shaka.device.IDevice.BrowserEngine.EDGE:
a.includes("Chrome/")?shaka.device.IDevice.BrowserEngine.CHROMIUM:a.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(){var a=window.ManagedSourceBuffer||window.SourceBuffer;return!!a&&!!a.prototype&&!!a.prototype.changeType};
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||window.matchMedia("(dynamic-range: high)").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+)(?:\.(\d+))?/);a||(a=navigator.userAgent.match(/OS (\d+)(?:_(\d+))?/));return a?[parseInt(a[1],10),parseInt(a[2]||"0",10)]:[0,0]});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()[0]};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!this.supportsMixedClearEncryptedContent_()&&b==="audio"};shaka.device.AppleBrowser.prototype.insertEncryptionDataBeforeClear=function(){return!this.supportsMixedClearEncryptedContent_()};shaka.device.AppleBrowser.prototype.requiresTfhdFix=function(a){return!this.supportsMixedClearEncryptedContent_()&&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.prototype.supportsMixedClearEncryptedContent_=function(){var a=this.version_.value();return a[0]>=27?!0:a[0]===26&&a[1]>=4};
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 shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching.call(this)&&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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc();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.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 shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching.call(a)?navigator.userAgent.match(/Edge?\//)?!a.isWindows_.value():!0:!1});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.supportsSmoothCodecSwitching=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.getNextAddressJsc()){case 1:return a={width:1920,height:1080},b=!1,f.setCatchFinallyBlocks(2),f.yield(window.msdk.device.getDisplayInfo(),4);case 4:c=f.getYieldResultJsc();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.getYieldResultJsc();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("WebOS: config support",c);c=JSON.parse(c);var d,e,f,g;a.supportHdr_=(g=(f=(d=c.configs)==null?void 0:d["tv.model.supportHDR"])!=null?f:(e=c.configs)==null?void 0:e["tv.config.supportDolbyHDRContents"])!=null?g:!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(){return!1};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.requiresClearAndEncryptedInitSegments=function(){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.returnLittleEndianUsingPlayReady=function(){return!0};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.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){return this.attributes.find(function(b){return b.name===a})||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.getExtinfDuration=function(a){a=a.value;var b=a.indexOf(",");return Number(b===-1?a:a.substring(0,b))};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){var b=shaka.util.StringUtils.fromUTF8(a).trim().split(/[\r\n]+/);if(!b[0].startsWith("#EXTM3U"))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=shaka.hls.ManifestTextParser.splitTag_(b);b=c.name;c=c.data;if(c===null)return new shaka.hls.Tag(a,b,[]);if(c.indexOf("=")===-1)return new shaka.hls.Tag(a,b,[],c);c=shaka.hls.ManifestTextParser.parseAttributes_(c);return new shaka.hls.Tag(a,b,c.list,c.value)};
shaka.hls.ManifestTextParser.splitTag_=function(a){var b=a.indexOf(":"),c=b===-1?a.substring(1):a.substring(1,b);if(!c.startsWith("EXT"))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.INVALID_HLS_TAG,a);a=b===-1?null:a.substring(b+1);return{name:c,data:a}};
shaka.hls.ManifestTextParser.parseAttributes_=function(a){var b=[],c=null,d=0,e=a.indexOf(","),f=a.indexOf("=");e!==-1&&e<f&&(c=a.substring(0,e),d=e+1);for(;d<a.length;){for(;a[d]===" ";)d++;f=a.indexOf("=",d);if(f===-1)break;e=a.substring(d,f);d=f+1;if(a[d]==='"'){d++;var g=a.indexOf('"',d);f=g===-1?a.substring(d):a.substring(d,g);d=g===-1?a.length:g+1}else g=a.indexOf(",",d),f=g===-1?a.substring(d):a.substring(d,g),d=g===-1?a.length:g;d<a.length&&a[d]===","&&d++;b.push(new shaka.hls.Attribute(e,
f))}return{value:c,list:b}};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.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){if(!a.startsWith("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);var b=a.substring(5),c=b.indexOf(",");if(c<0)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);a=b.substring(0,c);b=b.substring(c+1);b=decodeURIComponent(b);a=a.split(";");c=a[0];var d=!1;a.length>1&&a[a.length-1].toLowerCase()=="base64"&&(d=!0,a.pop());return{data:d?shaka.util.Uint8ArrayUtils.fromBase64(b):shaka.util.StringUtils.toUTF8(b),contentType:c,typeInfoList:a}};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.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.getNextAddressJsc()==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.getNextAddressJsc()!=3)return d=e.getYieldResultJsc(),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.getNextAddressJsc()==1){if(!a.isLive_())return n.return();b=[];c=Array.from(a.uriToStreamInfosMap_.values());d=c.filter(function(p){return!p.stream.isAudioMuxedInVideo&&p.stream.segmentIndex});if(d.length===0)return shaka.log.warning("No active streams found during update"),n.return();a.lastTargetDuration_=Infinity;a.manifest_.gapCount=0;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),a.determineDuration_());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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(S){switch(S.getNextAddressJsc()){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"),c.push(g.toString());S.setCatchFinallyBlocks(2);return S.yield(b.requestManifest_(c,!0).promise,4);case 4:k=S.getYieldResultJsc();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:u=S.getYieldResultJsc();w=u.keyIds;v=u.drmInfos;x=u.encrypted;y=u.aesEncrypted;r.encrypted||!x||y||(r.encrypted=!0);A=function(V,U){return V.size===
U.size&&[].concat((0,$jscomp.arrayFromIterable)(V)).every(function(X){return U.has(X)})};A(r.keyIds,w)||(r.keyIds=w,r.drmInfos=v,b.playerInterface_.newDrmInfo(r));B=b.createSegments_(m,t,q,a.getUris,a.type);D=B.segments;if(z=B.bandwidth)r.bandwidth=z;C=shaka.media.QualityObserver.createQualityInfo(r);E=(0,$jscomp.makeIterator)(D);for(G=E.next();!G.done;G=E.next())I=G.value,I.initSegmentReference&&(I.initSegmentReference.mediaQuality=C);r.segmentIndex.mergeAndEvict(D,b.presentationTimeline_.getSegmentAvailabilityStart());
D.length&&(F=shaka.hls.Utils.getFirstTagWithNameAsNumber(m.tags,"EXT-X-MEDIA-SEQUENCE",0),K=(J=shaka.hls.Utils.getFirstTagWithName(m.tags,"EXT-X-SKIP"))?Number(J.getAttributeValue("SKIPPED-SEGMENTS")):0,H=b.getNextMediaSequenceAndPart_(F,D),M=H.nextMediaSequence,L=H.nextPart,a.nextMediaSequence=M+K,a.nextPart=L,N=t.get(F),r.segmentIndex.evict(N));if(P=r.segmentIndex.earliestReference())a.minTimestamp=P.startTime,Q=D[D.length-1],goog.asserts.assert(Q,"Should have segments!"),a.maxTimestamp=Q.endTime;
if(O=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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V,U,X,Y,T,W;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.getNextAddressJsc()){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;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(e.type==shaka.hls.PlaylistType.MEDIA)return b.needsClosedCaptionsDetection_=!1,L=shaka.hls.Utils.filterTagsByName(e.tags,"EXT-X-DEFINE"),n=b.parseMediaVariables_(L,b.masterPlaylistUri_),m=d.VIDEO,N="",P=new Map,R.yield(b.convertParsedPlaylistIntoStreamInfo_(b.globalId_++,n,e,l,"",m,N,!0,"Media Playlist",null,P,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");u=c.filterTagsByName(e.tags,"EXT-X-SESSION-KEY");w=c.filterTagsByName(e.tags,"EXT-X-SESSION-DATA");v=c.filterTagsByName(e.tags,"EXT-X-CONTENT-STEERING");b.processSessionData_(w);return R.yield(b.processContentSteering_(v),4);case 4:if(!b.config_.ignoreSupplementalCodecs){x=[];y=(0,$jscomp.makeIterator)(q);
A=y.next();for(B={};!A.done;B={supplementalCodecs$jscomp$1:void 0},A=y.next())if(D=A.value,z=D.getAttributeValue("SUPPLEMENTAL-CODECS"))B.supplementalCodecs$jscomp$1=z.split(/\s*,\s*/).map(function(aa){return aa.split("/")[0]}),C=D.attributes.map(function(aa){return function(Z){var ba=Z.name,da=Z.value;ba=="CODECS"&&(da=aa.supplementalCodecs$jscomp$1.join(","),Z=Z.value.split(","),Z.length>1&&(Z=shaka.util.ManifestParserUtils.guessCodecsSafe(shaka.util.ManifestParserUtils.ContentType.AUDIO,Z))&&(da+=
","+Z));return new shaka.hls.Attribute(ba,da)}}(B)),x.push(new shaka.hls.Tag(D.id,D.name,C,null));q.push.apply(q,(0,$jscomp.arrayFromIterable)(x));E=[];G=(0,$jscomp.makeIterator)(t);I=G.next();for(F={};!I.done;F={supplementalCodecs$jscomp$2:void 0},I=G.next())if(J=I.value,K=J.getAttributeValue("SUPPLEMENTAL-CODECS"))F.supplementalCodecs$jscomp$2=K.split(/\s*,\s*/).map(function(aa){return aa.split("/")[0]}),H=J.attributes.map(function(aa){return function(Z){var ba=Z.name;Z=Z.value;ba=="CODECS"&&(Z=
aa.supplementalCodecs$jscomp$2.join(","));return new shaka.hls.Attribute(ba,Z)}}(F)),E.push(new shaka.hls.Tag(J.id,J.name,H,null));t.push.apply(t,(0,$jscomp.arrayFromIterable)(E))}b.parseCodecs_(q);b.parseClosedCaptions_(p);M=b.parseIFrames_(t);return R.yield(b.createVariantsForTags_(q,u,p,l,b.globalVariables_,M),5);case 5:return g=R.getYieldResultJsc(),h=b.parseTexts_(p),R.yield(b.parseImages_(r,t),6);case 6:k=R.getYieldResultJsc();R.jumpTo(3);break;case 7:Q=R.getYieldResultJsc(),b.uriToStreamInfosMap_.set(b.masterPlaylistUri_,
Q),Q.stream&&(O=shaka.media.QualityObserver.createQualityInfo(Q.stream),Q.stream.segmentIndex.forEachTopLevelReference(function(aa){aa.initSegmentReference&&(aa.initSegmentReference.mediaQuality=O)})),m=Q.stream.type,S=!0,b.config_.disableAudio&&Q.type=="audio"?S=!1:b.config_.disableVideo&&Q.type=="video"&&!Q.stream.codecs.includes(",")&&(S=!1),S&&g.push({id:0,language:b.getLanguage_(N),disabledUntilTime:0,primary:!0,audio:Q.type=="audio"?Q.stream:null,video:Q.type=="video"?Q.stream:null,bandwidth:Q.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),V=b.getUpdatePlaylistDelay_(),b.updatePlaylistTimer_.tickAfter(V)),U=Array.from(b.uriToStreamInfosMap_.values()),b.finalizeStreams_(U),b.determineDuration_(),
goog.asserts.assert(m,"mediaPlaylistType should be non-null"),b.processDateRangeTags_(e.tags,m,n,l));b.manifest_.variants=g;b.manifest_.textStreams=h;b.manifest_.imageStreams=k;b.manifest_.startTime=b.startTime_;if(b.codecInfoInManifest_||!b.config_.hls.disableCodecGuessing){R.jumpTo(8);break}X=[];Y=(0,$jscomp.makeIterator)(b.manifest_.variants);for(T=Y.next();!T.done;T=Y.next())W=T.value,W.audio&&W.audio.codecs===""&&X.push(W.audio.createSegmentIndex()),W.video&&W.video.codecs===""&&X.push(W.video.createSegmentIndex());
return R.yield(Promise.all(X),8);case 8:b.playerInterface_.makeTextStreamsForClosedCaptions(b.manifest_),R.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,u,w;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(v){if(v.getNextAddressJsc()==1){c=shaka.media.SegmentUtils.getBasicInfoFromMimeType(b.config_.hls.mediaPlaylistFullMimeType);if(!a.length)return v.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 v.return(shaka.media.SegmentUtils.getBasicInfoFromMimeType(k));
return v.yield(Promise.all([b.getInfoFromSegment_(e.initSegmentReference,0),b.getInfoFromSegment_(e,f)]),2)}l=v.getYieldResultJsc();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(u=shaka.media.SegmentUtils.getBasicInfoFromTs(p,b.config_.disableAudio,b.config_.disableVideo,b.config_.disableText))return v.return(u)}else if(t||
q.includes(h))if(w=shaka.media.SegmentUtils.getBasicInfoFromMp4(n,p,b.config_.disableText))return v.return(w);return m?v.return(shaka.media.SegmentUtils.getBasicInfoFromMimeType(m)):v.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.getNextAddressJsc()){case 1:if(!a)return l.return({mimeType:null,data:null});d=shaka.net.NetworkingEngine.RequestType.SEGMENT;e=shaka.net.NetworkingUtils.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.getYieldResultJsc();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.getYieldResultJsc();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!=null&&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=shaka.hls.Utils.filterTagsByType(a,"SUBTITLES"),c={};a=(0,$jscomp.makeIterator)(b);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]}a=[];if(!this.config_.disableText)for(var f in c)try{a.push(this.createStreamInfoFromMediaTags_(c[f],new Map).stream)}catch(g){if(!this.config_.hls.ignoreTextStreamFailures)throw g;}f=shaka.util.ManifestParserUtils.ContentType.TEXT;b=
(0,$jscomp.makeIterator)(b);for(c=b.next();!c.done;c=b.next())if(d=c.value.getRequiredAttrValue("GROUP-ID"),c=this.groupIdToCodecsMap_.get(d))if(d=this.groupIdToStreamInfosMap_.get(d))for(d=(0,$jscomp.makeIterator)(d),e=d.next();!e.done;e=d.next())e=e.value,e.stream.codecs=c,e.stream.mimeType=this.guessMimeTypeBeforeLoading_(f,c)||this.guessMimeTypeFallback_(f),this.setFullTypeForStream_(e.stream);return a.filter(function(g){return g})};
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.getNextAddressJsc()==1)return d=a.map(function(g){var h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1){if(h=c.config_.disableThumbnails)return m.return(null);m.setCatchFinallyBlocks(2);return m.yield(c.createStreamInfoFromImageTag_(g),4)}if(m.getNextAddressJsc()!=2)return k=m.getYieldResultJsc(),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.getYieldResultJsc();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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V,U,X,Y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(T){switch(T.getNextAddressJsc()){case 1:h=[];k=new Set;if(g.config_.ignoreDrmInfo||!(b.length>0)){T.jumpTo(2);break}l=(0,$jscomp.makeIterator)(b);m=l.next();case 3:if(m.done){T.jumpTo(2);break}n=m.value;p=n.getRequiredAttrValue("METHOD");q=n.getAttributeValue("KEYFORMAT")||"identity";
r=null;if(p=="NONE"){T.jumpTo(4);break}if(g.isAesMethod_(p)){t=shaka.hls.Utils.constructSegmentUris(d(),n.getRequiredAttrValue("URI"),e);u=t.sort().join("");g.aesKeyMap_.has(u)||(w=shaka.net.NetworkingEngine.RequestType.KEY,v=shaka.net.NetworkingEngine.makeRequest(t,g.config_.retryParameters),x=g.makeNetworkRequest_(v,w).promise,g.aesKeyMap_.set(u,x));T.jumpTo(4);break}if(q=="identity")return T.yield(g.identityDrmParser_(n,"",d,null,e),12);y=g.keyFormatsToDrmParsers_.get(q);if(!y){A=null;T.jumpTo(10);
break}return T.yield(y(n,"",null),11);case 11:A=T.getYieldResultJsc();case 10:r=A;T.jumpTo(6);break;case 12:r=T.getYieldResultJsc();case 6:if(r){if(r.keyIds)for(B=(0,$jscomp.makeIterator)(r.keyIds),D=B.next();!D.done;D=B.next())z=D.value,k.add(z);h.push(r)}else shaka.log.warning("Unsupported HLS KEYFORMAT",q);case 4:m=l.next();T.jumpTo(3);break;case 2:C={};E=(0,$jscomp.makeIterator)(a);for(G=E.next();!G.done;G=E.next())I=G.value,F=I.getTagKey(!g.contentSteeringManager_),C[F]?C[F].push(I):C[F]=[I];
J=[];for(K in C)H=C[K],M=H[0],L=M.getAttributeValue("FRAME-RATE"),N=Number(M.getRequiredAttrValue("BANDWIDTH"))||Number(M.getAttributeValue("AVERAGE-BANDWIDTH")),P=M.getAttributeValue("RESOLUTION"),Q=(0,$jscomp.makeIterator)(P?P.split("x"):[null,null]),O=Q.next().value,S=Q.next().value,V=M.getAttributeValue("VIDEO-RANGE"),(U=M.getAttributeValue("REQ-VIDEO-LAYOUT"))&&U.includes(",")&&(X=U.split(",").filter(function(W){return W=="CH-STEREO"||W=="CH-MONO"}),U=X[0]),U=U||"CH-MONO",Y=g.createStreamInfosForVariantTags_(H,
c,P,L),goog.asserts.assert(Y.audio.length||Y.video.length,"We should have created a stream!"),J.push.apply(J,(0,$jscomp.arrayFromIterable)(g.createVariants_(Y.audio,Y.video,N,O,S,L,V,U,h,k,f)));return T.return(J.filter(function(W){return W!=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(u){return r.includes(u)})});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")||a[1].includes("IMSA")};
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(v){return!v.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 u=e?e.getUris().sort().join(","):"",w=[];g&&g.codecs&&w.push(g.codecs);h&&h.codecs&&w.push(h.codecs);t=[t,u,w.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$53: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$53=++this.globalId_;k=function(r){return function(){return shaka.hls.HlsParser.FAKE_MUXED_URL_+r.id$jscomp$53}}(k);var l=c?h.getRequiredAttrValue("URI"):h.getAttributeValue("URI")||k();
k=h.getRequiredAttrValue("GROUP-ID");d.push(l);e.push(k);f.set(k,l);(h=h.getAttributeValue("PATHWAY-ID"))&&b.set(k,h)}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(",");g=="audio"&&c&&(e+=c);if(this.uriToStreamInfosMap_.has(e))return this.uriToStreamInfosMap_.get(e);
k=this.globalId_++;if(this.contentSteeringManager_)for(f=(0,$jscomp.makeIterator)(f),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.getNextAddressJsc()==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.getNextAddressJsc()!=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(y){return y.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},u=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=u;var w=function(y){var A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(U){switch(U.getNextAddressJsc()){case 1:return A=shaka.util.ManifestParserUtils.ContentType,U.setCatchFinallyBlocks(2),U.yield(y.promise,
4);case 4:B=U.getYieldResultJsc();if(y.aborted)return U.return();D=B.uri;D!=B.originalUri&&(z=t.getUris(),z.includes(D)||t.redirectUris.push(D));C=q.manifestTextParser_.parsePlaylist(B.data);if(C.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(C.tags,"EXT-X-DEFINE");G=q.parseMediaVariables_(E,D);I=!1;(!q.codecInfoInManifest_&&
q.config_.hls.disableCodecGuessing||q.needsClosedCaptionsDetection_&&d==A.VIDEO&&!q.config_.hls.disableClosedCaptionsDetection)&&C.segments.length>0&&(q.needsClosedCaptionsDetection_=!1,I=!0);F=!q.codecInfoInManifest_&&q.config_.hls.disableCodecGuessing;J=q.isLive_();return U.yield(q.convertParsedPlaylistIntoStreamInfo_(a,G,C,u,c,d,e,f,g,h,k,l,m,n,p,void 0,I,F),5);case 5:K=U.getYieldResultJsc();if(y.aborted)return U.return();H=K.stream;q.determineStartTime_(C);q.isLive_()&&!J&&q.changePresentationTimelineToLive_(C);
t.minTimestamp=K.minTimestamp;t.maxTimestamp=K.maxTimestamp;t.canSkipSegments=K.canSkipSegments;t.canBlockReload=K.canBlockReload;t.hasEndList=K.hasEndList;t.mediaSequenceToStartTime=K.mediaSequenceToStartTime;t.nextMediaSequence=K.nextMediaSequence;t.nextPart=K.nextPart;r.segmentIndex=H.segmentIndex;r.encrypted=H.encrypted;r.drmInfos=H.drmInfos;r.keyIds=H.keyIds;r.mimeType=H.mimeType;r.bandwidth=r.bandwidth||H.bandwidth;r.codecs=r.codecs||H.codecs;r.closedCaptions=r.closedCaptions||H.closedCaptions;
r.width=r.width||H.width;r.height=r.height||H.height;r.hdr=r.hdr||H.hdr;r.colorGamut=r.colorGamut||H.colorGamut;r.frameRate=r.frameRate||H.frameRate;r.language=="und"&&H.language!="und"&&(r.language=H.language);r.language=r.language||H.language;r.channelsCount=r.channelsCount||H.channelsCount;r.audioSamplingRate=r.audioSamplingRate||H.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==A.TEXT&&(L=H.segmentIndex.earliestReference())&&L.initSegmentReference&&(r.mimeType="application/mp4",q.setFullTypeForStream_(r));N=shaka.media.QualityObserver.createQualityInfo(r);r.segmentIndex.forEachTopLevelReference(function(X){X.initSegmentReference&&(X.initSegmentReference.mediaQuality=N)});q.hasEnoughInfoToFinalizeStreams_()&&(q.streamsFinalized_?q.finalizeStreams_([t]):(q.streamsFinalized_=!0,P=Array.from(q.uriToStreamInfosMap_.values()),
Q=P.filter(function(X){return X.stream.segmentIndex}),q.finalizeStreams_(Q),q.determineDuration_(),O=q.getUpdatePlaylistDelay_(),O>0&&q.updatePlaylistTimer_.tickAfter(O)));q.processDateRangeTags_(C.tags,r.type,G,u);q.manifest_&&(q.manifest_.startTime=q.startTime_);U.leaveTryBlock(0);break;case 2:S=U.enterCatchBlock();r.closeSegmentIndex();if(S.code===shaka.util.Error.Code.OPERATION_ABORTED)return U.return();V=q.playerInterface_.disableStream(r);if(!V)throw S;U.jumpToEnd()}})},v=null,x;r.createSegmentIndex=
function(){if(v)return v;if(r.isAudioMuxedInVideo){var y=new shaka.media.SegmentIndex([]);r.segmentIndex=y;return Promise.resolve()}x=q.requestManifest_(t.getUris(),!0);return v=new Promise(function(A){A(w(x))})};r.closeSegmentIndex=function(){v&&!r.segmentIndex&&x.abort();r.segmentIndex&&(r.segmentIndex.release(),r.segmentIndex=null);v=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_||!this.manifest_.variants.length)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,u,w){u=u===void 0?!0:u;w=w===void 0?!0:w;var v=this,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M,L,N,P,Q,O,S,V,U,X,Y,T,W,R,aa;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Z){switch(Z.getNextAddressJsc()){case 1:x=c.segments||[];y=x.every(function(ba){return shaka.hls.Utils.getFirstTagWithName(ba.tags,"EXT-X-GAP")?!0:!1});if(!x.length||y)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_EMPTY_MEDIA_PLAYLIST);v.determinePresentationType_(c);v.isLive_()&&v.determineLastTargetDuration_(c);A=v.isLive_()?v.mediaSequenceToStartTimeByType_.get(f):new Map;B=v.createSegments_(c,A,b,d,f);D=B.segments;z=B.bandwidth;F=I=G=E=C=null;if(!(D.length>0&&u)){Z.jumpTo(2);break}return Z.yield(v.getBasicInfoFromSegments_(D),3);case 3:J=Z.getYieldResultJsc(),f!=J.type&&v.isLive_()&&(v.mediaSequenceToStartTimeByType_.set(J.type,v.mediaSequenceToStartTimeByType_.get(f)),
v.mediaSequenceToStartTimeByType_.set(f,new Map)),f=J.type,g=J.language,l=J.channelCount,q=J.sampleRate,v.config_.disableText||(m=J.closedCaptions),E=J.height,C=J.width,G=J.videoRange,I=J.colorGamut,F=J.frameRate,w&&(t=J.mimeType,e=J.codecs);case 2:if(t){Z.jumpTo(4);break}return Z.yield(v.guessMimeType_(f,e,D),5);case 5:t=Z.getYieldResultJsc(),f!=shaka.util.ManifestParserUtils.ContentType.TEXT||e||t!="application/mp4"||!D[0]||D[0].initSegmentReference||(t="text/vtt");case 4:return Z.yield(v.parseDrmInfo_(c,
t,d,b),6);case 6:K=Z.getYieldResultJsc();H=K.drmInfos;M=K.keyIds;L=K.encrypted;N=K.aesEncrypted;if(L&&!H.length&&!N)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_KEYFORMATS_NOT_SUPPORTED);P=v.makeStreamObject_(a,e,f,g,h,k,l,m,n,p,q,r);P.encrypted=L&&!N;P.drmInfos=H;P.keyIds=M;P.mimeType=t;z&&(P.bandwidth=z);v.setFullTypeForStream_(P);f==shaka.util.ManifestParserUtils.ContentType.VIDEO&&(C||E||G||I)&&v.addVideoAttributes_(P,
C,E,F,G,null,I);v.isLive_()&&v.determineLastTargetDuration_(c);Q=D[0].startTime;O=D[D.length-1];S=O.endTime;V=new shaka.media.SegmentIndex(D);P.segmentIndex=V;X=(U=shaka.hls.Utils.getFirstTagWithName(c.tags,"EXT-X-SERVER-CONTROL"))?U.getAttribute("CAN-SKIP-UNTIL")!=null:!1;Y=U?U.getAttribute("CAN-BLOCK-RELOAD")!=null:!1;T=shaka.hls.Utils.getFirstTagWithNameAsNumber(c.tags,"EXT-X-MEDIA-SEQUENCE",0);W=v.getNextMediaSequenceAndPart_(T,D);R=W.nextMediaSequence;aa=W.nextPart;return Z.return({stream:P,
type:f,redirectUris:[],getUris:d,minTimestamp:Q,maxTimestamp:S,canSkipSegments:X,canBlockReload:Y,hasEndList:!1,firstSequenceNumber:-1,nextMediaSequence:R,nextPart:aa,mediaSequenceToStartTime:A})}})};
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)}q=void 0;k=null;c==shaka.util.ManifestParserUtils.ContentType.TEXT?q=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")&&(k=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED);p.length||q!==shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE||p.push(shaka.util.ManifestParserUtils.TextStreamKind.SUBTITLE);q=null;c!=shaka.util.ManifestParserUtils.ContentType.VIDEO&&(q=f);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:q,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:k,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,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(L){switch(L.getNextAddressJsc()){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;u=[];w=new Set;v=(0,$jscomp.makeIterator)(f);x=v.next();case 2:if(x.done){L.jumpTo(4);break}y=x.value;A=(0,$jscomp.makeIterator)(y);B=A.next().value;D=A.next().value;z=B;C=D;E=z.getRequiredAttrValue("METHOD");if(E=="NONE"){L.jumpTo(3);break}r=!0;G=z.getAttributeValue("KEYFORMAT")||"identity";I=null;if(e.isAesMethod_(E)){t=!0;L.jumpTo(3);break}if(G=="identity")return L.yield(e.identityDrmParser_(z,b,c,C,d),11);F=e.keyFormatsToDrmParsers_.get(G);
if(!F){J=null;L.jumpTo(9);break}return L.yield(F(z,b,C),10);case 10:J=L.getYieldResultJsc();case 9:I=J;L.jumpTo(6);break;case 11:I=L.getYieldResultJsc();case 6:if(I){if(I.keyIds)for(K=(0,$jscomp.makeIterator)(I.keyIds),H=K.next();!H.done;H=K.next())M=H.value,w.add(M);u.push(I)}else shaka.log.warning("Unsupported HLS KEYFORMAT",G);case 3:x=v.next();L.jumpTo(2);break;case 4:return L.return({drmInfos:u,keyIds:w,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(u){if(u.getNextAddressJsc()==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)),u.yield(e.aesKeyMap_.get(l),2);if(u.getNextAddressJsc()!=3){r=u.getYieldResultJsc();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 u.yield(window.crypto.subtle.importKey("raw",r.data,t,!0,["decrypt"]),3)}m.cryptoKey=u.getYieldResultJsc();m.fetchKey=void 0;u.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=shaka.hls.Utils.getExtinfDuration(e);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_=
(b=a?a.getAttribute("HOLD-BACK"):null)?Number(b.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");b=e?b+shaka.hls.Utils.getExtinfDuration(e):
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(!this.config_.hls.ignoreManifestProgramDateTime){var u=shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-PROGRAM-DATE-TIME");u&&u.value&&(t=shaka.util.TXml.parseDate(u.value),goog.asserts.assert(t!=null,"EXT-X-PROGRAM-DATE-TIME format not valid"),this.usesProgramDateTime_=
!0)}var w=shaka.media.SegmentReference.Status.AVAILABLE;shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-GAP")&&(this.manifest_.gapCount++,w=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 v=[];u=!1;var x=null,y=!1,A=!1;if(this.lowLatencyMode_&&c.partialSegments.length){p=a&&
window.ReadableStream&&this.config_.hls.allowLowLatencyByteRangeOptimization;for(var B=t,D={},z=0;z<c.partialSegments.length;D={uris$jscomp$24:void 0,pUri:void 0},z++){var C=c.partialSegments[z],E=z==0?b:v[v.length-1],G=z==0?d:E.endTime,I=Number(C.getAttributeValue("DURATION"))||this.partialTargetDuration_;if(I){var F=G+I,J=0,K=null;C.name=="EXT-X-PRELOAD-HINT"?(J=(J=C.getAttributeValue("BYTERANGE-START"))?Number(J):0,(E=C.getAttributeValue("BYTERANGE-LENGTH"))?K=J+Number(E)-1:J&&(K=Number.MAX_SAFE_INTEGER)):
(J=C.getAttributeValue("BYTERANGE"),K=(0,$jscomp.makeIterator)(this.parseByteRange_(E,J)),J=K.next().value,K=K.next().value);D.pUri=C.getAttributeValue("URI");if(D.pUri){E=shaka.media.SegmentReference.Status.AVAILABLE;C.getAttributeValue("GAP")=="YES"&&(this.manifest_.gapCount++,E=shaka.media.SegmentReference.Status.MISSING,y=!0);D.uris$jscomp$24=null;var H=function(L){return function(){L.uris$jscomp$24==null&&(goog.asserts.assert(L.pUri,"Partial uri should be defined!"),L.uris$jscomp$24=shaka.hls.Utils.constructSegmentUris(h(),
L.pUri,e));return L.uris$jscomp$24}}(D);p&&J>=0&&K!=null&&(x=H,u=!0);G=new shaka.media.SegmentReference(G,F,H,J,K,a,0,0,Infinity,[],"",null,B,E,l);C.name=="EXT-X-PRELOAD-HINT"&&(G.markAsPreload(),A=!0);C.getAttributeValue("INDEPENDENT")!="YES"&&z>0&&G.markAsNonIndependent();C=k;C||(v.length&&v[0].mimeType?C=v[0].mimeType:D.pUri&&(C=shaka.hls.HlsParser,D=shaka.net.NetworkingUtils.getExtension(D.pUri),C=C.EXTENSION_MAP_BY_CONTENT_TYPE_.get(g).get(D)||null));C&&(G.mimeType=C,f.MIME_TYPES_WITHOUT_INIT_SEGMENT_.has(C)&&
(G.initSegmentReference=null));v.push(G);B&&(B+=I)}}}}if(n){n=shaka.hls.Utils.getExtinfDuration(n);if(n==0)return null;p=d+n}else if(v.length)p=v[v.length-1].endTime;else return null;u&&(y||v[0].startByte!=0?(u=!1,x=null):v=[]);(n=shaka.hls.Utils.getFirstTagWithName(m,"EXT-X-BYTERANGE"))?(r=(0,$jscomp.makeIterator)(this.parseByteRange_(b,n.value)),q=r.next().value,r=r.next().value):v.length&&(q=v[0].startByte,r=v[v.length-1].endByte);b="";n=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"))&&(n=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,v,b,n,t,w,l,v.length>0&&!!c.verbatimSegmentUri);k&&(a.mimeType=k,f.MIME_TYPES_WITHOUT_INIT_SEGMENT_.has(k)&&(a.initSegmentReference=null));u&&(this.lowLatencyByterangeOptimization_=
!0,a.markAsByterangeOptimization(),A&&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!=null&&!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,G){E=E.getRequiredAttrValue("START-DATE");G=G.getRequiredAttrValue("START-DATE");
return E<G?-1:E>G?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",u=g.getAttributeValue("END-ON-NEXT")=="YES";if(m==null&&u){for(var w=b+1;w<a.length;w++){var v=a[w].getAttributeValue("CLASS")||"com.apple.quicktime.HLS";if(t==v){var x=a[w].getRequiredAttrValue("START-DATE"),y=shaka.util.TXml.parseDate(x);if(!isNaN(y)&&y&&y>k){m=Math.max(0,y-f);break}}}if(m==null)continue}w=["CLASS","START-DATE","END-DATE","DURATION","END-ON-NEXT"];for(var A=[],B=(0,$jscomp.makeIterator)(g.attributes),
D=B.next();!D.done;D=B.next()){var z=D.value;if(!w.includes(z.name)){var C=e.variableSubstitution(z.value,c);if(z.name=="X-ASSET-URI"||z.name=="X-ASSET-LIST")C=e.constructSegmentUris(d(),z.value,c)[0];A.push({key:z.name,description:"",data:C,mimeType:null,pictureType:null})}}if(A.length>1)this.playerInterface_.onMetadata(t,l,m,A)}}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,u=0;this.isLive_()&&b.has(t)&&
(u=b.get(t));u===0&&this.presentationType_==shaka.hls.HlsParser.PresentationType_.LIVE&&b.size>0&&!b.has(t)&&this.presentationTimeline_.getPresentationStartTime()!=null&&(u=this.presentationTimeline_.getSegmentAvailabilityStart());var w=[],v=null;q=[];for(var x=function(C){var E=shaka.hls.HlsParser;C=shaka.net.NetworkingUtils.getExtension(C);if(!C)return null;var G=E.EXTENSION_MAP_BY_CONTENT_TYPE_.get(e).get(C);G||(G=E.RAW_FORMATS_TO_MIME_TYPES_.get(C));return G},y=0;y<f.length;y++){var A=f[y];(t=
shaka.hls.Utils.getFirstTagWithName(A.tags,"EXT-X-MAP"))&&t.id!==h&&(g=this.getInitSegmentReference_(a,A.tags,d,c),h=t.id);t=A.verbatimSegmentUri;var B="";t&&(B=shaka.net.NetworkingUtils.getExtension(t));B!==l&&(k=x(t),l=B);B=y==0?u:v.endTime;t=p+r+y;shaka.hls.Utils.getFirstTagWithName(A.tags,"EXT-X-DISCONTINUITY")&&(n++,v&&v.initSegmentReference&&(v.initSegmentReference.boundaryEnd=B));for(var D=(0,$jscomp.makeIterator)(A.tags),z=D.next();!z.done;z=D.next())z=z.value,z.name=="EXT-X-KEY"&&(m=this.isAesMethod_(z.getRequiredAttrValue("METHOD"))?
this.parseAESDrmTag_(z,a,d,c):void 0);b.set(t,B);if(B=this.createSegmentReference_(g,v,A,B,c,a,e,d,k,m)){if(v=shaka.hls.Utils.getFirstTagWithNameAsNumber(A.tags,"EXT-X-BITRATE"))q.push({bitrate:v,duration:B.endTime-B.startTime}),B.bandwidth=v;else if(B.endByte){if(A=B.getSize())v=B.endTime-B.startTime,A=A*8/v/1E3,q.push({bitrate:A,duration:v}),B.bandwidth=A}else q.length&&(v=q[q.length-1],v.duration+=B.endTime-B.startTime,B.bandwidth=v.bitrate);if(B.bandwidth)for(v=(0,$jscomp.makeIterator)(B.partialReferences),
A=v.next();!A.done;A=v.next())A.value.bandwidth=B.bandwidth;v=B;B.discontinuitySequence=n;this.ignoreManifestProgramDateTimeFor_(e)&&this.minSequenceNumber_!=null&&t<this.minSequenceNumber_||w.push(B)}}a=void 0;q.length&&(a=q.reduce(function(C,E){return C+E.duration},0),a=Math.round(q.reduce(function(C,E){return C+E.bitrate*E.duration},0)/a*1E3));if(q=w.some(function(C){return C.syncTime!=null}))for(b={},c=0;c<w.length;b={forwardI:void 0,forwardAdd:void 0,backwardI:void 0,reference$jscomp$57:void 0,
backwardAdd:void 0},c++)if(b.reference$jscomp$57=w[c],b.reference$jscomp$57.syncTime==null)for(b.forwardAdd=0,b.forwardI=c,d=function(C){return function(){var E=w[C.forwardI];if(E){if(E.syncTime!=null)return E.syncTime+C.forwardAdd;C.forwardAdd-=E.endTime-E.startTime;C.forwardI+=1}return null}}(b),b.backwardAdd=0,b.backwardI=c,f=function(C){return function(){var E=w[C.backwardI];if(E){E!=C.reference$jscomp$57&&(C.backwardAdd+=E.endTime-E.startTime);if(E.syncTime!=null)return E.syncTime+C.backwardAdd;
--C.backwardI}return null}}(b);b.reference$jscomp$57.syncTime==null;)b.reference$jscomp$57.syncTime=f(),b.reference$jscomp$57.syncTime==null&&(b.reference$jscomp$57.syncTime=d());if(q)for(b=(0,$jscomp.makeIterator)(w),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)(w),
c=q.next();!c.done;c=q.next())c.value.syncAgainst(b);return{segments:w,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,u,w;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(v){switch(v.getNextAddressJsc()){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 v.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 v.return(p);if(k=d.guessMimeTypeBeforeLoading_(a,b))return v.return(k);r=shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT;t=shaka.net.NetworkingEngine.makeRequest(l,d.config_.retryParameters);v.setCatchFinallyBlocks(2);t.method="HEAD";return v.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,4);case 4:u=v.getYieldResultJsc();q=u.headers["content-type"];v.leaveTryBlock(3);break;case 2:w=v.enterCatchBlock();if(!w||w.code!=shaka.util.Error.Code.HTTP_ERROR&&
w.code!=shaka.util.Error.Code.BAD_HTTP_STATUS){v.jumpTo(3);break}t.method="GET";d.config_.hls.allowRangeRequestsToGuessMimeType&&(t.headers.Range="bytes=0-0");return v.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,6);case 6:u=v.getYieldResultJsc(),q=u.headers["content-type"];case 3:if(!q){v.jumpTo(7);break}k=q.toLowerCase().split(";")[0];if(k!="application/octet-stream"){v.jumpTo(8);break}if(u.data.byteLength){v.jumpTo(9);break}t.method="GET";return v.yield(d.makeNetworkRequest_(t,f,{type:r}).promise,
10);case 10:u=v.getYieldResultJsc();case 9:shaka.util.TsParser.probe(shaka.util.BufferUtils.toUint8(u.data))&&(k="video/mp2t");case 8:if(k!="application/octet-stream")return v.return(k);case 7:return v.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.getNextAddressJsc()){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()),isFinite(f)?a.updatePlaylistTimer_.tickAfter(f):a.updatePlaylistTimer_.tickAfter(1));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.getNextAddressJsc()==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,null,h);return(l=shaka.drm.FairPlay.defaultGetKeyId(h))||!c?m.jumpTo(2):m.yield(d.getKeyIdFromInitSegment_(c),
3)}m.getNextAddressJsc()!=2&&(l=m.getYieldResultJsc());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];if(!this.psshToInitData_.has(d)){var e=shaka.util.BufferUtils.toUint8(c.data);this.psshToInitData_.set(d,
e)}b=shaka.util.ManifestParserUtils.createDrmInfo("com.widevine.alpha",b,[{initDataType:"cenc",initData:this.psshToInitData_.get(d)}],void 0,c.typeInfoList);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");c=shaka.net.DataUriPlugin.parseRaw(a.split("?")[0]);a=shaka.util.BufferUtils.toUint8(c.data);var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,
95,149]),e=new Set;d=shaka.util.Pssh.createPssh(a,d,e,0);b=shaka.util.ManifestParserUtils.createDrmInfo("com.microsoft.playready",b,[{initDataType:"cenc",initData:d}],void 0,c.typeInfoList);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];if(!this.psshToInitData_.has(d)){var e=shaka.util.BufferUtils.toUint8(c.data);this.psshToInitData_.set(d,
e)}b=shaka.util.ManifestParserUtils.createDrmInfo("com.huawei.wiseplay",b,[{initDataType:"cenc",initData:this.psshToInitData_.get(d)}],void 0,c.typeInfoList);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,u,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){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.getYieldResultJsc(),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:(u=x.getYieldResultJsc())&&
(t=u);case 4:return w=new Map,w.set(t,l),v="cenc",g=="SAMPLE-AES"&&(v="cbcs"),x.return(shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys(w,v))}})};
shaka.hls.HlsParser.prototype.getKeyIdFromInitSegment_=function(a){var b=this,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){c=null;if(b.initSegmentToKidMap_.has(a))return c=b.initSegmentToKidMap_.get(a),h.jumpTo(2);d=shaka.net.NetworkingUtils.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.getNextAddressJsc()!=2&&(g=h.getYieldResultJsc(),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.ManifestParser.registerParserByMime("audio/x-mpegurl",function(){return new shaka.hls.HlsParser});shaka.mss={};shaka.mss.ContentProtection=function(){};shaka.mss.ContentProtection.parseFromProtection=function(a,b){var c=shaka.mss.ContentProtection,d=shaka.util.TXml,e=[];a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next())e=e.concat(d.findChildren(f.value,"ProtectionHeader"));return e.length?c.convertElements_(e,b):[]};shaka.mss.ContentProtection.getPlayReadyLicenseUrl=function(a){return shaka.drm.PlayReady.getLicenseUrl(a)};shaka.mss.ContentProtection.getPlayReadyKID_=function(a){return shaka.drm.PlayReady.getPlayReadyKID(a)};
shaka.mss.ContentProtection.getInitDataFromPro_=function(a,b,c){var d=shaka.util.Uint8ArrayUtils;a=d.fromBase64(shaka.util.TXml.getTextContents(a));b=d.fromHex(b.replace(/-/g,""));d=new Set;return[{initData:shaka.util.Pssh.createPssh(a,b,d,0),initDataType:"cenc",keyId:c}]};
shaka.mss.ContentProtection.convertElements_=function(a,b){for(var c=shaka.mss.ContentProtection,d=shaka.util.ManifestParserUtils,e=c.licenseUrlParsers_,f=[],g=0;g<a.length;g++){var h=a[g],k=h.attributes.SystemID.toLowerCase(),l=b[k];if(l){var m=c.getPlayReadyKID_(h);k=c.getInitDataFromPro_(h,k,m);k=d.createDrmInfo(l,"cenc",k);m&&k.keyIds.add(m);if(l=e.get(l))k.licenseServerUri=l(h);f.push(k)}}return f};
shaka.mss.ContentProtection.licenseUrlParsers_=(new Map).set("com.microsoft.playready",shaka.mss.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.recommendation",shaka.mss.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.software",shaka.mss.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.hardware",shaka.mss.ContentProtection.getPlayReadyLicenseUrl);shaka.mss.MssParser=function(){var a=this;this.playerInterface_=this.config_=null;this.manifestUris_=[];this.manifest_=null;this.globalId_=1;this.updatePeriod_=0;this.presentationTimeline_=null;this.averageUpdateDuration_=new shaka.abr.Ewma(5);this.updateTimer_=new shaka.util.Timer(function(){a.onUpdate_()});this.operationManager_=new shaka.util.OperationManager;this.initSegmentDataByStreamId_=new Map;this.isPreloadFn_=function(){return!1}};
shaka.mss.MssParser.prototype.configure=function(a,b){goog.asserts.assert(a.mss!=null,"MssManifestConfiguration should not be null!");this.config_=a;b&&(this.isPreloadFn_=b)};
shaka.mss.MssParser.prototype.start=function(a,b){var c=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return goog.asserts.assert(c.config_,"Must call configure() before start()!"),c.manifestUris_=[a],c.playerInterface_=b,d.yield(c.requestManifest_(),2);if(!c.playerInterface_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED);c.setUpdateTimer_();goog.asserts.assert(c.manifest_,
"Manifest should be non-null!");return d.return(c.manifest_)})};
shaka.mss.MssParser.prototype.onUpdate_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:return goog.asserts.assert(a.updatePeriod_>=0,"There should be an update period"),shaka.log.info("Updating manifest..."),c.setCatchFinallyBlocks(2),c.yield(a.requestManifest_(),4);case 4:c.leaveTryBlock(3);break;case 2:b=c.enterCatchBlock(),goog.asserts.assert(b instanceof shaka.util.Error,"Should only receive a Shaka error"),a.playerInterface_&&
(b.severity=shaka.util.Error.Severity.RECOVERABLE,a.playerInterface_.onError(b));case 3:if(!a.playerInterface_)return c.return();a.setUpdateTimer_();c.jumpToEnd()}})};shaka.mss.MssParser.prototype.setUpdateTimer_=function(){if(!(this.updatePeriod_<=0)){var a=Math.max(shaka.mss.MssParser.MIN_UPDATE_PERIOD_,this.updatePeriod_,this.averageUpdateDuration_.getEstimate());this.updateTimer_.tickAfter(a)}};
shaka.mss.MssParser.prototype.stop=function(){this.config_=this.playerInterface_=null;this.manifestUris_=[];this.manifest_=null;this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);this.initSegmentDataByStreamId_.clear();return this.operationManager_.destroy()};
shaka.mss.MssParser.prototype.update=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.setCatchFinallyBlocks(2),c.yield(a.requestManifest_(),4);if(c.getNextAddressJsc()!=2)return c.leaveTryBlock(0);b=c.enterCatchBlock();if(!a.playerInterface_||!b)return c.return();goog.asserts.assert(b instanceof shaka.util.Error,"Bad error type");a.playerInterface_.onError(b);c.jumpToEnd()})};
shaka.mss.MssParser.prototype.onExpirationUpdated=function(a,b){};shaka.mss.MssParser.prototype.onInitialVariantChosen=function(a){};shaka.mss.MssParser.prototype.banLocation=function(a){};shaka.mss.MssParser.prototype.setMediaElement=function(a){};
shaka.mss.MssParser.prototype.requestManifest_=function(){var a=this,b,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1)return b=shaka.net.NetworkingEngine.RequestType.MANIFEST,c=shaka.net.NetworkingEngine.AdvancedRequestType.MSS,d=shaka.net.NetworkingEngine.makeRequest(a.manifestUris_,a.config_.retryParameters),e=a.playerInterface_.networkingEngine,f=Date.now(),g=e.request(b,d,{type:c,isPreload:a.isPreloadFn_()}),a.operationManager_.manage(g),
m.yield(g.promise,2);h=m.getYieldResultJsc();if(!a.playerInterface_)return m.return();h.uri&&!a.manifestUris_.includes(h.uri)&&a.manifestUris_.unshift(h.uri);a.parseManifest_(h.data,h.uri);k=Date.now();l=(k-f)/1E3;a.averageUpdateDuration_.sample(1,l);m.jumpToEnd()})};
shaka.mss.MssParser.prototype.parseManifest_=function(a,b){var c=a;a=this.config_.mss.manifestPreprocessor;if(a!=shaka.util.PlayerConfiguration.defaultManifestPreprocessor){shaka.Deprecate.deprecateFeature(5,"manifest.mss.manifestPreprocessor configuration","Please Use manifest.mss.manifestPreprocessorTXml instead.");c=shaka.util.XmlUtils.parseXml(c,"SmoothStreamingMedia");if(!c)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.MSS_INVALID_XML,
b);a(c);c=shaka.util.XmlUtils.toArrayBuffer(c)}a=shaka.util.TXml.parseXml(c,"SmoothStreamingMedia");if(!a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.MSS_INVALID_XML,b);c=this.config_.mss.manifestPreprocessorTXml;c!=shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml&&c(a);this.processManifest_(a,b);return Promise.resolve()};
shaka.mss.MssParser.prototype.processManifest_=function(a,b){var c=shaka.util.TXml;this.presentationTimeline_||(this.presentationTimeline_=new shaka.media.PresentationTimeline(null,0));if(b=c.parseAttr(a,"IsLive",c.parseBoolean,!1))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.MSS_LIVE_CONTENT_NOT_SUPPORTED);this.presentationTimeline_.setStatic(!b);var d=c.parseAttr(a,"TimeScale",c.parseNonNegativeInt,shaka.mss.MssParser.DEFAULT_TIME_SCALE_);
goog.asserts.assert(d&&d>=0,"Timescale must be defined!");var e=c.parseAttr(a,"DVRWindowLength",c.parseNonNegativeInt);b&&(e===0||isNaN(e))&&(e=Infinity);var f=c.parseAttr(a,"CanSeek",c.parseBoolean,!1);e===0&&f&&(e=Infinity);f=null;e&&e>0&&(f=e/d);b&&!isNaN(this.config_.availabilityWindowOverride)&&(f=this.config_.availabilityWindowOverride);f==null&&(f=Infinity);this.presentationTimeline_.setSegmentAvailabilityDuration(f);c=c.parseAttr(a,"Duration",c.parseNonNegativeInt,Infinity);goog.asserts.assert(c&&
c>=0,"Duration must be defined!");b||this.presentationTimeline_.setDuration(c/d);b={variants:[],textStreams:[],timescale:d,duration:c/d};this.parseStreamIndexes_(a,b);this.manifest_?(this.manifest_.variants=b.variants,this.manifest_.textStreams=b.textStreams,this.playerInterface_.filter(this.manifest_)):(this.manifest_={presentationTimeline:this.presentationTimeline_,variants:b.variants,textStreams:b.textStreams,imageStreams:[],offlineSessionIds:[],sequenceMode:this.config_.mss.sequenceMode,ignoreManifestTimestampsInSegmentsMode:!1,
type:shaka.media.ManifestParser.MSS,serviceDescription:null,nextUrl:null,periodCount:1,gapCount:0,isLowLatency:!1,startTime:null},this.presentationTimeline_.lockStartTime())};
shaka.mss.MssParser.prototype.parseStreamIndexes_=function(a,b){var c=shaka.mss.ContentProtection,d=shaka.util.TXml,e=shaka.util.ManifestParserUtils.ContentType,f=d.findChildren(a,"Protection"),g=c.parseFromProtection(f,this.config_.mss.keySystemsBySystemId),h=[];c=[];f=[];a=d.findChildren(a,"StreamIndex");a=(0,$jscomp.makeIterator)(a);for(var k=a.next();!k.done;k=a.next()){k=k.value;var l=d.findChildren(k,"QualityLevel"),m=this.createTimeline_(k,b.timescale,b.duration);l=(0,$jscomp.makeIterator)(l);
for(var n=l.next();!n.done;n=l.next())(n=this.createStream_(k,n.value,m,g,b))&&(n.type!=e.AUDIO||this.config_.disableAudio?n.type!=e.VIDEO||this.config_.disableVideo?n.type!=e.TEXT||this.config_.disableText||f.push(n):c.push(n):h.push(n))}d=[];e=(0,$jscomp.makeIterator)(h.length>0?h:[null]);for(h=e.next();!h.done;h=e.next())for(h=h.value,g=(0,$jscomp.makeIterator)(c.length>0?c:[null]),a=g.next();!a.done;a=g.next())d.push(this.createVariant_(h,a.value));b.variants=d;b.textStreams=f};
shaka.mss.MssParser.prototype.createStream_=function(a,b,c,d,e){var f=this,g=shaka.util.TXml,h=shaka.util.ManifestParserUtils.ContentType,k=shaka.mss.MssParser,l=a.attributes.Type;if(l!=="audio"&&l!=="video"&&l!=="text")return shaka.log.alwaysWarn("Ignoring unrecognized type:",l),null;var m=a.attributes.Language,n=this.globalId_++,p=g.parseAttr(b,"Bitrate",g.parsePositiveInt),q=g.parseAttr(b,"MaxWidth",g.parsePositiveInt),r=g.parseAttr(b,"MaxHeight",g.parsePositiveInt),t=g.parseAttr(b,"Channels",
g.parsePositiveInt);g=g.parseAttr(b,"SamplingRate",g.parsePositiveInt);var u=e.duration;c.length&&(u=c[c.length-1].end-c[0].start);var w=this.presentationTimeline_.getDuration();this.presentationTimeline_.setDuration(Math.min(u,w));(w=a.attributes.Name)&&(w+=b.attributes.Index);w||(w=String(n));var v={id:n,originalId:w,groupId:null,createSegmentIndex:function(){return Promise.resolve()},closeSegmentIndex:function(){return Promise.resolve()},segmentIndex:null,mimeType:"",codecs:"",frameRate:void 0,
pixelAspectRatio:void 0,bandwidth:p||0,width:q||void 0,height:r||void 0,kind:"",encrypted:d.length>0,drmInfos:d,keyIds:new Set,language:shaka.util.LanguageUtils.normalize(m||"und"),originalLanguage:m,label:"",type:"",primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:[],roles:[],forced:!1,channelsCount:t,audioSamplingRate:g,spatialAudio:!1,closedCaptions:null,hdr:void 0,colorGamut:void 0,videoLayout:void 0,tilesLayout:void 0,matchedStreams:[],mssPrivateData:{duration:u,timescale:e.timescale,
codecPrivateData:null},accessibilityPurpose:null,external:!1,fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null};if(d=a.attributes.Subtype)(d=k.ROLE_MAPPING_.get(d))&&v.roles.push(d),d==="main"&&(v.primary=!0);d=b.attributes.FourCC;if(d===null||d==="")d=a.attributes.FourCC;if(!d)if(l==="audio")d="AAC";else if(l==="video")return shaka.log.alwaysWarn('FourCC is not defined whereas it is required for a QualityLevel element for a StreamIndex of type "video"'),null;if(!k.SUPPORTED_CODECS_.includes(d.toUpperCase()))return shaka.log.alwaysWarn("Codec not supported:",
d),null;k=this.getCodecPrivateData_(b,l,d,v);v.mssPrivateData.codecPrivateData=k;switch(l){case "audio":if(!k)return shaka.log.alwaysWarn("Quality unsupported without CodecPrivateData",l),null;v.type=h.AUDIO;v.mimeType="mss/audio/mp4";v.codecs=this.getAACCodec_(b,d,k);break;case "video":if(!k)return shaka.log.alwaysWarn("Quality unsupported without CodecPrivateData",l),null;v.type=h.VIDEO;v.mimeType="mss/video/mp4";v.codecs=this.getH264Codec_(b,k);break;case "text":if(v.type=h.TEXT,v.mimeType="application/mp4",
d==="TTML"||d==="DFXP")v.codecs="stpp"}v.fullMimeTypes.add(shaka.util.MimeUtils.getFullType(v.mimeType,v.codecs));v.createSegmentIndex=function(){if(v.segmentIndex)return Promise.resolve();if(f.initSegmentDataByStreamId_.has(v.id))var x=f.initSegmentDataByStreamId_.get(v.id);else x=[],v.type==h.VIDEO&&(x=v.mssPrivateData.codecPrivateData.split("00000001").slice(1)),x={id:v.id,type:v.type,codecs:v.codecs,encrypted:v.encrypted,timescale:v.mssPrivateData.timescale,duration:v.mssPrivateData.duration,
videoNalus:x,audioConfig:new Uint8Array([]),videoConfig:new Uint8Array([]),hSpacing:0,vSpacing:0,data:null,stream:v},x=(new shaka.util.Mp4Generator([x])).initSegment(),f.initSegmentDataByStreamId_.set(v.id,x);var y=shaka.media.QualityObserver.createQualityInfo(v);x=new shaka.media.InitSegmentReference(function(){return[]},0,null,y,v.mssPrivateData.timescale,x,null,v.encrypted);x=f.createSegments_(x,v,a,c);v.segmentIndex=new shaka.media.SegmentIndex(x);return Promise.resolve()};v.closeSegmentIndex=
function(){v.segmentIndex&&(v.segmentIndex.release(),v.segmentIndex=null)};return v};
shaka.mss.MssParser.prototype.getCodecPrivateData_=function(a,b,c,d){if(a=a.attributes.CodecPrivateData)return a;if(b!=="audio")return null;b=d.channelsCount||2;a=d.audioSamplingRate||44100;var e={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};d=e[a];if(c==="AACH")return c=new Uint8Array(4),a=e[a*2],c[0]=40|d>>1,c[1]=d<<7|b<<3|a>>1,c[2]=a<<7|8,c[3]=0,b=new Uint16Array(2),b[0]=(c[0]<<8)+c[1],b[1]=(c[2]<<8)+c[3],b[0].toString(16)+b[1].toString(16);
c=new Uint8Array(2);c[0]=16|d>>1;c[1]=d<<7|b<<3;b=new Uint16Array(1);b[0]=(c[0]<<8)+c[1];return b[0].toString(16)};shaka.mss.MssParser.prototype.getAACCodec_=function(a,b,c){a=0;b==="AACH"&&(a=5);c?a===0&&(a=(parseInt(c.substr(0,2),16)&248)>>3):(a=2,b==="AACH"&&(a=5));return"mp4a.40."+a};shaka.mss.MssParser.prototype.getH264Codec_=function(a,b){a=/00000001[0-9]7/.exec(b);return a.length&&b?"avc1."+b.substr(b.indexOf(a[0])+10,6):""};
shaka.mss.MssParser.prototype.createSegments_=function(a,b,c,d){var e=this,f=shaka.util.ManifestParserUtils;c=c.attributes.Url;goog.asserts.assert(c,"Missing URL for segments");var g=c.replace("{bitrate}",String(b.bandwidth));c=[];d=(0,$jscomp.makeIterator)(d);for(var h=d.next(),k={};!h.done;k={time$jscomp$48:void 0},h=d.next())k.time$jscomp$48=h.value,h=function(l){return function(){return f.resolveUris(e.manifestUris_,[g.replace("{start time}",String(l.time$jscomp$48.unscaledStart))])}}(k),c.push(new shaka.media.SegmentReference(k.time$jscomp$48.start,
k.time$jscomp$48.end,h,0,null,a,0,0,b.mssPrivateData.duration));return c};
shaka.mss.MssParser.prototype.createTimeline_=function(a,b,c){goog.asserts.assert(b>0&&b<Infinity,"timescale must be a positive, finite integer");goog.asserts.assert(c>0,"duration must be a positive integer");var d=shaka.util.TXml;a=d.findChildren(a,"c");for(var e=[],f=0,g=0;g<a.length;++g){var h=a[g],k=a[g+1],l=d.parseAttr(h,"t",d.parseNonNegativeInt),m=d.parseAttr(h,"d",d.parseNonNegativeInt),n=d.parseAttr(h,"r",d.parseInt);if(!m){shaka.log.warning('"c" element must have a duration:','ignoring the remaining "c" elements.',
h);break}l=l!=null?l:f;(n=n||0)&&n--;if(n<0)if(k){k=d.parseAttr(k,"t",d.parseNonNegativeInt);if(k==null){shaka.log.warning('An "c" element cannot have a negative repeat','if the next "c" element does not have a valid start time:','ignoring the remaining "c" elements.',h);break}else if(l>=k){shaka.log.warning('An "c" element cannot have a negative repeat if its start ','time exceeds the next "c" element\'s start time:','ignoring the remaining "c" elements.',h);break}n=Math.ceil((k-l)/m)-1}else{if(c==
Infinity){shaka.log.warning('The last "c" element cannot have a negative repeat',"if the Period has an infinite duration:",'ignoring the last "c" element.',h);break}else if(l/b>=c){shaka.log.warning('The last "c" element cannot have a negative repeat',"if its start time exceeds the duration:",'ignoring the last "c" element.',h);break}n=Math.ceil((c*b-l)/m)-1}for(h=0;h<=n;++h)f=l+m,e.push({start:l/b,end:f/b,unscaledStart:l}),l=f}return e};
shaka.mss.MssParser.prototype.createVariant_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(!a||a.type==c.AUDIO,"Audio parameter mismatch!");goog.asserts.assert(!b||b.type==c.VIDEO,"Video parameter mismatch!");c=0;a&&a.bandwidth&&a.bandwidth>0&&(c+=a.bandwidth);b&&b.bandwidth&&b.bandwidth>0&&(c+=b.bandwidth);return{id:this.globalId_++,language:a?a.language:"und",disabledUntilTime:0,primary:!!a&&a.primary||!!b&&b.primary,audio:a,video:b,bandwidth:c,allowedByApplication:!0,
allowedByKeySystem:!0,decodingInfos:[]}};goog.exportSymbol("shaka.mss.MssParser",shaka.mss.MssParser);shaka.mss.MssParser.MIN_UPDATE_PERIOD_=3;shaka.mss.MssParser.DEFAULT_TIME_SCALE_=1E7;shaka.mss.MssParser.SUPPORTED_CODECS_="AAC AACL AACH AACP AVC1 H264 TTML DFXP".split(" ");shaka.mss.MssParser.ROLE_MAPPING_=(new Map).set("CAPT","main").set("SUBT","alternate").set("DESC","main");shaka.media.ManifestParser.registerParserByMime("application/vnd.ms-sstr+xml",function(){return new shaka.mss.MssParser});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,u,w,v,x,y,A,B,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.getNextAddressJsc()){case 1:return l=shaka.net.HttpFetchPlugin.fetch_,m=shaka.net.HttpFetchPlugin.ReadableStream_,p=new ArrayBuffer(0),r=q=0,t={},u=Date.now(),z.setCatchFinallyBlocks(2),z.yield(l(a,d),4);case 4:n=z.getYieldResultJsc();t=shaka.net.HttpFetchPlugin.headersToGenericObject_(n.headers);g(t);if(d.method=="HEAD"){z.jumpTo(5);
break}goog.asserts.assert(n.body,"non-HEAD responses should have a body");v=(w=n.headers.get("Content-Length"))?parseInt(w,10):0;if(!n.body)return z.yield(n.arrayBuffer(),9);x=n.clone().body.getReader();y=function(C){var E=function(){var G,I,F,J,K;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.getNextAddressJsc()){case 1:return H.setCatchFinallyBlocks(2),H.yield(x.read(),4);case 4:G=H.getYieldResultJsc();H.leaveTryBlock(3);break;case 2:return I=H.enterCatchBlock(),shaka.log.v1("error reading from stream",
I.message),H.return();case 3:if(G.done){H.jumpTo(5);break}q+=G.value.byteLength;if(!h){H.jumpTo(5);break}return H.yield(h(G.value),5);case 5:F=Date.now();J=q-r;if(F-u>100&&J>=k||G.done)K=G.done?0:v-q,f(F-u,J,K),r=q,u=F;G.done?(goog.asserts.assert(!G.value,'readObj should be unset when "done" is true.'),C.close()):(C.enqueue(G.value),E());H.jumpToEnd()}})};E()};new m({start:y});return z.yield(n.arrayBuffer(),8);case 8:p=z.getYieldResultJsc();z.jumpTo(5);break;case 9:p=z.getYieldResultJsc(),A=Date.now(),
f(A-u,p.byteLength,0);case 5:b.headers.Range&&(B=b.headers.Range.replace("bytes=","").split("-").filter(function(C){return C}).map(function(C){return parseInt(C,10)}),B.length==2&&p.byteLength!=B[1]-B[0]+1&&shaka.log.alwaysWarn("Payload length does not match range requested bytes",b,n));z.leaveTryBlock(3);break;case 2:D=z.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,D,c);case 3:return z.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!");t=g.response;try{var u=shaka.net.HttpPluginUtils.makeResponse(p,t,g.status,a,g.responseURL,b,c);m(u)}catch(w){goog.asserts.assert(w instanceof shaka.util.Error,"Wrong error type!"),n(w)}};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 u=Date.now(),w=f.minBytesForProgressEvents||0,v=t.loaded-k;if(u-h>100&&v>=w||t.lengthComputable&&t.loaded==t.total)d(u-h,v,g.readyState==4?0:t.total-t.loaded),k=t.loaded,h=u};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;var d=c.indexOf(": ");d!==-1&&(a[c.slice(0,d).toLowerCase()]=c.slice(d+2))}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);shaka.offline={};shaka.offline.DownloadInfo=function(a,b,c,d,e){this.ref=a;this.estimateId=b;this.groupId=c;this.isInitSegment=d;this.refPosition=e};shaka.offline.DownloadInfo.idForSegmentRef=function(a){var b=a.getSegmentData(!1);return b?shaka.util.Uint8ArrayUtils.toBase64(b):a.getUris().map(function(c){return"{"+encodeURI(c.split("#xywh=")[0])+"}"}).join("")+":"+a.startByte+":"+a.endByte};shaka.offline.DownloadInfo.prototype.getRefId=function(){return shaka.offline.DownloadInfo.idForSegmentRef(this.ref)};
shaka.offline.DownloadInfo.prototype.makeSegmentRequest=function(a){return shaka.net.NetworkingUtils.createSegmentRequest(this.ref.getUris(),this.ref.startByte,this.ref.endByte,a.streaming.retryParameters)};shaka.offline.DownloadProgressEstimator=function(){this.actualDownloaded_=this.estimatedDownloaded_=this.estimatedTotal_=0;this.pending_=new Map;this.nextId_=0};shaka.offline.DownloadProgressEstimator.prototype.open=function(a){this.estimatedTotal_+=a;var b=this.nextId_;this.nextId_++;this.pending_.set(b,a);return b};
shaka.offline.DownloadProgressEstimator.prototype.close=function(a,b){if(this.pending_.has(a)){var c=this.pending_.get(a);this.pending_.delete(a);this.estimatedDownloaded_+=c;this.actualDownloaded_+=b}};shaka.offline.DownloadProgressEstimator.prototype.getEstimatedProgress=function(){return this.estimatedTotal_==0?0:this.estimatedDownloaded_/this.estimatedTotal_};shaka.offline.DownloadProgressEstimator.prototype.getTotalDownloaded=function(){return this.actualDownloaded_};shaka.offline.DownloadManager=function(a){var b=this;this.networkingEngine_=a;this.groups_=new Map;this.destroyer_=new shaka.util.Destroyer(function(){return b.abortAll().catch(function(){})});this.abortCallbacks_=[];this.onProgress_=function(c,d){};this.onInitData_=function(c,d){};this.estimator_=new shaka.offline.DownloadProgressEstimator;this.aborted_=!1};shaka.offline.DownloadManager.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.offline.DownloadManager.prototype.setCallbacks=function(a,b){this.onProgress_=a;this.onInitData_=b};shaka.offline.DownloadManager.prototype.abortAll=function(){this.aborted_=!0;var a=this.abortCallbacks_.map(function(b){return b()});this.abortCallbacks_=[];return Promise.all(a)};shaka.offline.DownloadManager.prototype.isAborted=function(){return this.aborted_};shaka.offline.DownloadManager.prototype.addDownloadEstimate=function(a){return this.estimator_.open(a)};
shaka.offline.DownloadManager.prototype.queue=function(a,b,c,d,e){var f=this;this.destroyer_.ensureNotDestroyed();var g=(this.groups_.get(a)||Promise.resolve()).then(function(){var h,k,l,m,n,p,q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(r){if(r.getNextAddressJsc()==1)return r.yield(f.fetchSegment_(b),2);h=r.getYieldResultJsc();if(f.destroyer_.destroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.OPERATION_ABORTED);
if(d)for(m in k=shaka.util.BufferUtils.toUint8(h),l=new shaka.util.Pssh(k),l.data)n=Number(m),p=l.data[n],q=l.systemIds[n],f.onInitData_(p,q);f.estimator_.close(c,h.byteLength);f.onProgress_(f.estimator_.getEstimatedProgress(),f.estimator_.getTotalDownloaded());return r.return(e(h))})});this.groups_.set(a,g);return g};
shaka.offline.DownloadManager.prototype.queueData=function(a,b,c,d,e){var f=this;this.destroyer_.ensureNotDestroyed();var g=(this.groups_.get(a)||Promise.resolve()).then(function(){if(f.destroyer_.destroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.OPERATION_ABORTED);if(d){var h=shaka.util.BufferUtils.toUint8(b);h=new shaka.util.Pssh(h);for(var k in h.data){var l=Number(k);f.onInitData_(h.data[l],h.systemIds[l])}}f.estimator_.close(c,
b.byteLength);f.onProgress_(f.estimator_.getEstimatedProgress(),f.estimator_.getTotalDownloaded());return e(b)});this.groups_.set(a,g);return g};shaka.offline.DownloadManager.prototype.queueWork=function(a,b){this.destroyer_.ensureNotDestroyed();var c=(this.groups_.get(a)||Promise.resolve()).then(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.yield(b(),0)})});this.groups_.set(a,c);return c};
shaka.offline.DownloadManager.prototype.waitToFinish=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.getNextAddressJsc()==1?b.yield(Promise.all(a.groups_.values()),2):b.return(a.estimator_.getTotalDownloaded())})};
shaka.offline.DownloadManager.prototype.fetchSegment_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return c=shaka.net.NetworkingEngine.RequestType.SEGMENT,d=b.networkingEngine_.request(c,a),e=function(){return d.abort()},b.abortCallbacks_.push(e),g.yield(d.promise,2);f=g.getYieldResultJsc();shaka.util.ArrayUtils.remove(b.abortCallbacks_,e);return g.return(f.data)})};shaka.offline.indexeddb={};shaka.offline.indexeddb.DBOperation=function(a,b){var c=this;this.transaction_=a;this.store_=a.objectStore(b);this.promise_=new shaka.util.PublicPromise;a.onabort=function(d){d.preventDefault();c.promise_.reject()};a.onerror=function(d){d.preventDefault();c.promise_.reject()};a.oncomplete=function(d){c.promise_.resolve()}};
shaka.offline.indexeddb.DBOperation.prototype.abort=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1){try{a.transaction_.abort()}catch(c){}b.setCatchFinallyBlocks(2);return b.yield(a.promise_,4)}if(b.getNextAddressJsc()!=2)return b.leaveTryBlock(0);b.enterCatchBlock();b.jumpToEnd()})};
shaka.offline.indexeddb.DBOperation.prototype.forEachEntry=function(a){var b=this;return new Promise(function(c,d){var e=b.store_.openCursor();e.onerror=d;e.onsuccess=function(f){var g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){if(e.result==null)return c(),h.return();g=e.result;return h.yield(a(g.key,g.value,g),2)}g.continue();h.jumpToEnd()})}})};shaka.offline.indexeddb.DBOperation.prototype.store=function(){return this.store_};
shaka.offline.indexeddb.DBOperation.prototype.promise=function(){return this.promise_};shaka.offline.indexeddb.DBConnection=function(a){this.connection_=a;this.pending_=[]};shaka.offline.indexeddb.DBConnection.prototype.destroy=function(){return Promise.all(this.pending_.map(function(a){return a.abort()}))};shaka.offline.indexeddb.DBConnection.prototype.startReadOnlyOperation=function(a){return this.startOperation_(a,"readonly")};shaka.offline.indexeddb.DBConnection.prototype.startReadWriteOperation=function(a){return this.startOperation_(a,"readwrite")};
shaka.offline.indexeddb.DBConnection.prototype.startOperation_=function(a,b){var c=this;b=this.connection_.transaction([a],b);var d=new shaka.offline.indexeddb.DBOperation(b,a);this.pending_.push(d);d.promise().then(function(){return c.stopTracking_(d)},function(){return c.stopTracking_(d)});return d};shaka.offline.indexeddb.DBConnection.prototype.stopTracking_=function(a){shaka.util.ArrayUtils.remove(this.pending_,a)};shaka.offline.indexeddb.BaseStorageCell=function(a,b,c){this.connection_=new shaka.offline.indexeddb.DBConnection(a);this.segmentStore_=b;this.manifestStore_=c};shaka.offline.indexeddb.BaseStorageCell.prototype.destroy=function(){return this.connection_.destroy()};shaka.offline.indexeddb.BaseStorageCell.prototype.hasFixedKeySpace=function(){return!0};shaka.offline.indexeddb.BaseStorageCell.prototype.addSegments=function(a){return this.rejectAdd(this.segmentStore_)};
shaka.offline.indexeddb.BaseStorageCell.prototype.removeSegments=function(a,b){return this.remove_(this.segmentStore_,a,b)};shaka.offline.indexeddb.BaseStorageCell.prototype.getSegments=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return d.yield(b.get_(b.segmentStore_,a),2);c=d.getYieldResultJsc();return d.return(c.map(function(e){return b.convertSegmentData(e)}))})};
shaka.offline.indexeddb.BaseStorageCell.prototype.addManifests=function(a){return this.rejectAdd(this.manifestStore_)};shaka.offline.indexeddb.BaseStorageCell.prototype.updateManifest=function(a,b){return this.rejectUpdate(this.manifestStore_)};shaka.offline.indexeddb.BaseStorageCell.prototype.updateManifestImplementation=function(a,b){var c=this.connection_.startReadWriteOperation(this.manifestStore_),d=c.store();d.get(a).onsuccess=function(e){d.put(b,a)};return c.promise()};
shaka.offline.indexeddb.BaseStorageCell.prototype.updateManifestExpiration=function(a,b){var c=this.connection_.startReadWriteOperation(this.manifestStore_),d=c.store();d.get(a).onsuccess=function(e){if(e=e.target.result)e.expiration=b,d.put(e,a)};return c.promise()};shaka.offline.indexeddb.BaseStorageCell.prototype.removeManifests=function(a,b){return this.remove_(this.manifestStore_,a,b)};
shaka.offline.indexeddb.BaseStorageCell.prototype.getManifests=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return d.yield(b.get_(b.manifestStore_,a),2);c=d.getYieldResultJsc();return d.return(Promise.all(c.map(function(e){return b.convertManifest(e)})))})};
shaka.offline.indexeddb.BaseStorageCell.prototype.getAllManifests=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(b=a.connection_.startReadOnlyOperation(a.manifestStore_),c=new Map,d.yield(b.forEachEntry(function(e,f){var g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return h.yield(a.convertManifest(f),2);g=h.getYieldResultJsc();c.set(e,g);h.jumpToEnd()})}),2)):d.getNextAddressJsc()!=
3?d.yield(b.promise(),3):d.return(c)})};shaka.offline.indexeddb.BaseStorageCell.prototype.convertSegmentData=function(a){return a};shaka.offline.indexeddb.BaseStorageCell.prototype.convertManifest=function(a){return Promise.resolve(a)};
shaka.offline.indexeddb.BaseStorageCell.prototype.rejectAdd=function(a){return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.NEW_KEY_OPERATION_NOT_SUPPORTED,"Cannot add new value to "+a))};
shaka.offline.indexeddb.BaseStorageCell.prototype.rejectUpdate=function(a){return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MODIFY_OPERATION_NOT_SUPPORTED,"Cannot modify values in "+a))};
shaka.offline.indexeddb.BaseStorageCell.prototype.add=function(a,b){var c=this,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1){d=c.connection_.startReadWriteOperation(a);e=d.store();f=[];g=(0,$jscomp.makeIterator)(b);h=g.next();for(k={};!h.done;k={request$jscomp$63:void 0},h=g.next())l=h.value,k.request$jscomp$63=e.add(l),k.request$jscomp$63.onsuccess=function(n){return function(p){f.push(n.request$jscomp$63.result)}}(k);return m.yield(d.promise(),
2)}return m.return(f)})};shaka.offline.indexeddb.BaseStorageCell.prototype.remove_=function(a,b,c){a=this.connection_.startReadWriteOperation(a);var d=a.store();b=(0,$jscomp.makeIterator)(b);for(var e=b.next(),f={};!e.done;f={key$jscomp$160:void 0},e=b.next())f.key$jscomp$160=e.value,d.delete(f.key$jscomp$160).onsuccess=function(g){return function(){return c(g.key$jscomp$160)}}(f);return a.promise()};
shaka.offline.indexeddb.BaseStorageCell.prototype.get_=function(a,b){var c=this,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1){d=c.connection_.startReadOnlyOperation(a);e=d.store();f={};g=[];h=(0,$jscomp.makeIterator)(b);k=h.next();for(l={};!k.done;l={request$jscomp$64:void 0,key$jscomp$161:void 0},k=h.next())l.key$jscomp$161=k.value,l.request$jscomp$64=e.get(l.key$jscomp$161),l.request$jscomp$64.onsuccess=function(n){return function(){n.request$jscomp$64.result==
void 0&&g.push(n.key$jscomp$161);f[n.key$jscomp$161]=n.request$jscomp$64.result}}(l);return m.yield(d.promise(),2)}if(g.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.KEY_NOT_FOUND,"Could not find values for "+g);return m.return(b.map(function(n){return f[n]}))})};shaka.offline.indexeddb.EmeSessionStorageCell=function(a,b){this.connection_=new shaka.offline.indexeddb.DBConnection(a);this.store_=b};shaka.offline.indexeddb.EmeSessionStorageCell.prototype.destroy=function(){return this.connection_.destroy()};
shaka.offline.indexeddb.EmeSessionStorageCell.prototype.getAll=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(b=a.connection_.startReadOnlyOperation(a.store_),c=[],d.yield(b.forEachEntry(function(e,f){c.push(f)}),2)):d.getNextAddressJsc()!=3?d.yield(b.promise(),3):d.return(c)})};
shaka.offline.indexeddb.EmeSessionStorageCell.prototype.add=function(a){var b=this.connection_.startReadWriteOperation(this.store_),c=b.store();a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())c.add(d.value);return b.promise()};
shaka.offline.indexeddb.EmeSessionStorageCell.prototype.remove=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(c=b.connection_.startReadWriteOperation(b.store_),d.yield(c.forEachEntry(function(e,f,g){a.includes(f.sessionId)&&g.delete()}),2)):d.yield(c.promise(),0)})};shaka.offline.StorageCellHandle={};shaka.offline.StorageCellPath={};shaka.offline.StorageMuxer=function(){this.mechanisms_=new Map};shaka.offline.StorageMuxer.prototype.destroy=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.mechanisms_.values()),c=b.next();!c.done;c=b.next())a.push(c.value.destroy());this.mechanisms_.clear();return Promise.all(a)};
shaka.offline.StorageMuxer.prototype.init=function(){var a=this;shaka.offline.StorageMuxer.getRegistry_().forEach(function(e,f){(e=e())?a.mechanisms_.set(f,e):shaka.log.info("Skipping "+f+" as it is not supported on this platform")});for(var b=[],c=(0,$jscomp.makeIterator)(this.mechanisms_.values()),d=c.next();!d.done;d=c.next())b.push(d.value.init());return Promise.all(b)};
shaka.offline.StorageMuxer.prototype.getActive=function(){var a=null;this.mechanisms_.forEach(function(b,c){b.getCells().forEach(function(d,e){d.hasFixedKeySpace()||a||(a={path:{mechanism:c,cell:e},cell:d})})});if(a)return a;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MISSING_STORAGE_CELL,"Could not find a cell that supports add-operations");};
shaka.offline.StorageMuxer.prototype.forEachCell=function(a){this.mechanisms_.forEach(function(b,c){b.getCells().forEach(function(d,e){a({mechanism:c,cell:e},d)})})};
shaka.offline.StorageMuxer.prototype.getCell=function(a,b){var c=this.mechanisms_.get(a);if(!c)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MISSING_STORAGE_CELL,"Could not find mechanism with name "+a);a=c.getCells().get(b);if(!a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MISSING_STORAGE_CELL,"Could not find cell with name "+b);return a};
shaka.offline.StorageMuxer.prototype.forEachEmeSessionCell=function(a){this.mechanisms_.forEach(function(b,c){a(b.getEmeSessionCell())})};shaka.offline.StorageMuxer.prototype.getEmeSessionCell=function(){var a=Array.from(this.mechanisms_.keys());if(!a.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.STORAGE_NOT_SUPPORTED,"No supported storage mechanisms found");return this.mechanisms_.get(a[0]).getEmeSessionCell()};
shaka.offline.StorageMuxer.prototype.resolvePath=function(a){var b=this.mechanisms_.get(a.mechanism);return b?b.getCells().get(a.cell):null};
shaka.offline.StorageMuxer.prototype.erase=function(){var a=this,b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.getNextAddressJsc()==1?(b=Array.from(a.mechanisms_.values()),c=b.length>0,c||(d=shaka.offline.StorageMuxer.getRegistry_(),d.forEach(function(f,g){(f=f())&&b.push(f)})),e.yield(Promise.all(b.map(function(f){return f.erase()})),2)):c?e.jumpTo(0):e.yield(Promise.all(b.map(function(f){return f.destroy()})),0)})};
shaka.offline.StorageMuxer.register=function(a,b){shaka.offline.StorageMuxer.registry_.set(a,b)};shaka.offline.StorageMuxer.unregister=function(a){shaka.offline.StorageMuxer.registry_.delete(a)};shaka.offline.StorageMuxer.support=function(){var a=shaka.offline.StorageMuxer.getRegistry_();a=(0,$jscomp.makeIterator)(a.values());for(var b=a.next();!b.done;b=a.next())if(b=b.value,b=b())return b.destroy(),!0;return!1};
shaka.offline.StorageMuxer.overrideSupport=function(a){shaka.offline.StorageMuxer.override_=a};shaka.offline.StorageMuxer.clearOverride=function(){shaka.offline.StorageMuxer.override_=null};shaka.offline.StorageMuxer.getRegistry_=function(){var a=shaka.offline.StorageMuxer.override_,b=shaka.offline.StorageMuxer.registry_;return COMPILED?b:a||b};goog.exportSymbol("shaka.offline.StorageMuxer",shaka.offline.StorageMuxer);goog.exportProperty(shaka.offline.StorageMuxer,"unregister",shaka.offline.StorageMuxer.unregister);
goog.exportProperty(shaka.offline.StorageMuxer,"register",shaka.offline.StorageMuxer.register);goog.exportProperty(shaka.offline.StorageMuxer.prototype,"destroy",shaka.offline.StorageMuxer.prototype.destroy);shaka.offline.StorageMuxer.override_=null;shaka.offline.StorageMuxer.registry_=new Map;shaka.offline.indexeddb.V1StorageCell=function(){shaka.offline.indexeddb.BaseStorageCell.apply(this,arguments)};$jscomp.inherits(shaka.offline.indexeddb.V1StorageCell,shaka.offline.indexeddb.BaseStorageCell);
shaka.offline.indexeddb.V1StorageCell.prototype.updateManifestExpiration=function(a,b){var c=this,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){d=c.connection_.startReadWriteOperation(c.manifestStore_);e=d.store();f=new shaka.util.PublicPromise;e.get(a).onsuccess=function(h){(h=h.target.result)?(goog.asserts.assert(h.key==a,"With in-line keys, the keys should match"),h.expiration=b,e.put(h),f.resolve()):f.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,
shaka.util.Error.Code.KEY_NOT_FOUND,"Could not find values for "+a))};return g.yield(Promise.all([d.promise(),f]),0)})};
shaka.offline.indexeddb.V1StorageCell.prototype.convertManifest=function(a){var b,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){b=shaka.offline.indexeddb.V1StorageCell;c=[];for(d=0;d<a.periods.length;++d)e=d==a.periods.length-1?a.duration:a.periods[d+1].startTime,f=e-a.periods[d].startTime,g=b.convertPeriod_(a.periods[d],f),c.push(g);return k.yield(shaka.util.PeriodCombiner.combineDbStreams(c),2)}h=k.getYieldResultJsc();return k.return({creationTime:0,
originalManifestUri:a.originalManifestUri,duration:a.duration,size:a.size,expiration:a.expiration==null?Infinity:a.expiration,streams:h,sessionIds:a.sessionIds,drmInfo:a.drmInfo,appMetadata:a.appMetadata,sequenceMode:!1})})};
shaka.offline.indexeddb.V1StorageCell.convertPeriod_=function(a,b){var c=shaka.offline.indexeddb.V1StorageCell;c.fillMissingVariants_(a);for(var d=(0,$jscomp.makeIterator)(a.streams),e=d.next();!e.done;e=d.next())goog.asserts.assert(e.value.variantIds,"After filling in missing variants, each stream should have variant ids");return a.streams.map(function(f){return c.convertStream_(f,a.startTime,b)})};
shaka.offline.indexeddb.V1StorageCell.convertStream_=function(a,b,c){var d=shaka.offline.indexeddb.V1StorageCell,e=a.initSegmentUri?d.getKeyFromSegmentUri_(a.initSegmentUri):null,f=b+a.presentationTimeOffset,g=b+c;return{id:a.id,originalId:null,groupId:null,primary:a.primary,type:a.contentType,mimeType:a.mimeType,codecs:a.codecs,frameRate:a.frameRate,pixelAspectRatio:void 0,hdr:void 0,colorGamut:void 0,videoLayout:void 0,kind:a.kind,language:a.language,originalLanguage:a.language||null,label:a.label,
width:a.width,height:a.height,initSegmentKey:e,encrypted:a.encrypted,keyIds:new Set([a.keyId]),segments:a.segments.map(function(h){return d.convertSegment_(h,e,b,g,f)}),variantIds:a.variantIds,roles:[],forced:!1,audioSamplingRate:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,tilesLayout:void 0,external:!1,fastSwitching:!1,isAudioMuxedInVideo:!1}};
shaka.offline.indexeddb.V1StorageCell.convertSegment_=function(a,b,c,d,e){var f=shaka.offline.indexeddb.V1StorageCell.getKeyFromSegmentUri_(a.uri);return{startTime:c+a.startTime,endTime:c+a.endTime,dataKey:f,initSegmentKey:b,appendWindowStart:c,appendWindowEnd:d,timestampOffset:e,tilesLayout:"",mimeType:null,codecs:null,thumbnailSprite:null}};shaka.offline.indexeddb.V1StorageCell.prototype.convertSegmentData=function(a){return{data:a.data}};
shaka.offline.indexeddb.V1StorageCell.getKeyFromSegmentUri_=function(a){var b;if((b=/^offline:[0-9]+\/[0-9]+\/([0-9]+)$/.exec(a))||(b=/^offline:segment\/([0-9]+)$/.exec(a)))return Number(b[1]);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MALFORMED_OFFLINE_URI,"Could not parse uri "+a);};
shaka.offline.indexeddb.V1StorageCell.fillMissingVariants_=function(a){var b=shaka.util.ManifestParserUtils.ContentType.AUDIO,c=shaka.util.ManifestParserUtils.ContentType.VIDEO,d=a.streams.filter(function(l){return l.contentType==b});a=a.streams.filter(function(l){return l.contentType==c});if(!d.every(function(l){return l.variantIds})||!a.every(function(l){return l.variantIds})){goog.asserts.assert(d.every(function(l){return!l.variantIds}),"Some audio streams have variant ids and some do not.");goog.asserts.assert(a.every(function(l){return!l.variantIds}),
"Some video streams have variant ids and some do not.");for(var e=(0,$jscomp.makeIterator)(d),f=e.next();!f.done;f=e.next())f.value.variantIds=[];e=(0,$jscomp.makeIterator)(a);for(f=e.next();!f.done;f=e.next())f.value.variantIds=[];e=0;if(a.length&&!d.length){shaka.log.debug("Found video-only content. Creating variants for video.");f=e++;for(var g=(0,$jscomp.makeIterator)(a),h=g.next();!h.done;h=g.next())h.value.variantIds.push(f)}if(!a.length&&d.length)for(shaka.log.debug("Found audio-only content. Creating variants for audio."),
f=e++,g=(0,$jscomp.makeIterator)(d),h=g.next();!h.done;h=g.next())h.value.variantIds.push(f);if(a.length&&d.length)for(shaka.log.debug("Found audio-video content. Creating variants."),d=(0,$jscomp.makeIterator)(d),f=d.next();!f.done;f=d.next())for(f=f.value,g=(0,$jscomp.makeIterator)(a),h=g.next();!h.done;h=g.next()){h=h.value;var k=e++;f.variantIds.push(k);h.variantIds.push(k)}}};shaka.offline.indexeddb.V2StorageCell=function(){shaka.offline.indexeddb.BaseStorageCell.apply(this,arguments)};$jscomp.inherits(shaka.offline.indexeddb.V2StorageCell,shaka.offline.indexeddb.BaseStorageCell);
shaka.offline.indexeddb.V2StorageCell.prototype.convertManifest=function(a){var b=this,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){c=[];for(d=0;d<a.periods.length;++d)e=d==a.periods.length-1?a.duration:a.periods[d+1].startTime,f=e-a.periods[d].startTime,g=b.convertPeriod_(a.periods[d],f),c.push(g);return k.yield(shaka.util.PeriodCombiner.combineDbStreams(c),2)}h=k.getYieldResultJsc();return k.return({appMetadata:a.appMetadata,creationTime:0,
drmInfo:a.drmInfo,duration:a.duration,expiration:a.expiration==null?Infinity:a.expiration,originalManifestUri:a.originalManifestUri,sessionIds:a.sessionIds,size:a.size,streams:h,sequenceMode:!1})})};shaka.offline.indexeddb.V2StorageCell.prototype.convertPeriod_=function(a,b){for(var c=[],d=(0,$jscomp.makeIterator)(a.streams),e=d.next();!e.done;e=d.next())e=e.value,e.variantIds.length!=0&&c.push(this.convertStream_(e,a.startTime,a.startTime+b));return c};
shaka.offline.indexeddb.V2StorageCell.prototype.convertStream_=function(a,b,c){var d=this;return{id:a.id,originalId:a.originalId,groupId:null,primary:a.primary,type:a.contentType,mimeType:a.mimeType,codecs:a.codecs,frameRate:a.frameRate,pixelAspectRatio:a.pixelAspectRatio,hdr:void 0,colorGamut:void 0,videoLayout:void 0,kind:a.kind,language:a.language,originalLanguage:a.language||null,label:a.label,width:a.width,height:a.height,encrypted:a.encrypted,keyIds:new Set([a.keyId]),segments:a.segments.map(function(e){return d.convertSegment_(e,
a.initSegmentKey,b,c,a.presentationTimeOffset)}),variantIds:a.variantIds,roles:[],forced:!1,audioSamplingRate:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,tilesLayout:void 0,external:!1,fastSwitching:!1,isAudioMuxedInVideo:!1}};
shaka.offline.indexeddb.V2StorageCell.prototype.convertSegment_=function(a,b,c,d,e){return{startTime:c+a.startTime,endTime:c+a.endTime,initSegmentKey:b,appendWindowStart:c,appendWindowEnd:d,timestampOffset:c-e,dataKey:a.dataKey,tilesLayout:"",mimeType:null,codecs:null,thumbnailSprite:null}};shaka.offline.indexeddb.V5StorageCell=function(){shaka.offline.indexeddb.BaseStorageCell.apply(this,arguments)};$jscomp.inherits(shaka.offline.indexeddb.V5StorageCell,shaka.offline.indexeddb.BaseStorageCell);shaka.offline.indexeddb.V5StorageCell.prototype.hasFixedKeySpace=function(){return!1};shaka.offline.indexeddb.V5StorageCell.prototype.addSegments=function(a){return this.add(this.segmentStore_,a)};
shaka.offline.indexeddb.V5StorageCell.prototype.addManifests=function(a){return this.add(this.manifestStore_,a)};shaka.offline.indexeddb.V5StorageCell.prototype.updateManifest=function(a,b){return this.updateManifestImplementation(a,b)};shaka.offline.indexeddb.V5StorageCell.prototype.convertManifest=function(a){a.expiration==null&&(a.expiration=Infinity);return Promise.resolve(a)};shaka.offline.indexeddb.StorageMechanism=function(){this.sessions_=this.v5_=this.v3_=this.v2_=this.v1_=this.db_=null};
shaka.offline.indexeddb.StorageMechanism.prototype.init=function(){var a=this,b=shaka.offline.indexeddb.StorageMechanism.DB_NAME,c=shaka.offline.indexeddb.StorageMechanism.VERSION,d=new shaka.util.PublicPromise,e=!1,f=new shaka.util.Timer(function(){e=!0;d.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.INDEXED_DB_INIT_TIMED_OUT))}),g=shaka.offline.indexeddb.StorageMechanismOpenTimeout;typeof g==="number"&&g>0&&f.tickAfter(g);
var h=window.indexedDB.open(b,c);h.onsuccess=function(k){e||(f.stop(),k=h.result,a.db_=k,a.v1_=shaka.offline.indexeddb.StorageMechanism.createV1_(k),a.v2_=shaka.offline.indexeddb.StorageMechanism.createV2_(k),a.v3_=shaka.offline.indexeddb.StorageMechanism.createV3_(k),a.v5_=shaka.offline.indexeddb.StorageMechanism.createV5_(k),a.sessions_=shaka.offline.indexeddb.StorageMechanism.createEmeSessionCell_(k),d.resolve())};h.onupgradeneeded=function(k){a.createStores_(h.result)};h.onerror=function(k){e||
(f.stop(),d.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.INDEXED_DB_ERROR,h.error)),k.preventDefault())};return d};
shaka.offline.indexeddb.StorageMechanism.prototype.destroy=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){switch(b.getNextAddressJsc()){case 1:if(!a.v1_){b.jumpTo(2);break}return b.yield(a.v1_.destroy(),2);case 2:if(!a.v2_){b.jumpTo(4);break}return b.yield(a.v2_.destroy(),4);case 4:if(!a.v3_){b.jumpTo(6);break}return b.yield(a.v3_.destroy(),6);case 6:if(!a.v5_){b.jumpTo(8);break}return b.yield(a.v5_.destroy(),8);case 8:if(!a.sessions_){b.jumpTo(10);break}return b.yield(a.sessions_.destroy(),
10);case 10:a.db_&&a.db_.close(),b.jumpToEnd()}})};shaka.offline.indexeddb.StorageMechanism.prototype.getCells=function(){var a=new Map;this.v1_&&a.set("v1",this.v1_);this.v2_&&a.set("v2",this.v2_);this.v3_&&a.set("v3",this.v3_);this.v5_&&a.set("v5",this.v5_);return a};shaka.offline.indexeddb.StorageMechanism.prototype.getEmeSessionCell=function(){goog.asserts.assert(this.sessions_,"Cannot be destroyed.");return this.sessions_};
shaka.offline.indexeddb.StorageMechanism.prototype.erase=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){switch(b.getNextAddressJsc()){case 1:if(!a.v1_){b.jumpTo(2);break}return b.yield(a.v1_.destroy(),2);case 2:if(!a.v2_){b.jumpTo(4);break}return b.yield(a.v2_.destroy(),4);case 4:if(!a.v3_){b.jumpTo(6);break}return b.yield(a.v3_.destroy(),6);case 6:if(!a.v5_){b.jumpTo(8);break}return b.yield(a.v5_.destroy(),8);case 8:return a.db_&&a.db_.close(),b.yield(shaka.offline.indexeddb.StorageMechanism.deleteAll_(),
10);case 10:return a.db_=null,a.v1_=null,a.v2_=null,a.v3_=null,a.v5_=null,b.yield(a.init(),0)}})};shaka.offline.indexeddb.StorageMechanism.createV1_=function(a){var b=shaka.offline.indexeddb.StorageMechanism,c=b.V1_SEGMENT_STORE;b=b.V1_MANIFEST_STORE;var d=a.objectStoreNames;return d.contains(b)&&d.contains(c)?(shaka.log.debug("Mounting v1 idb storage cell"),new shaka.offline.indexeddb.V1StorageCell(a,c,b)):null};
shaka.offline.indexeddb.StorageMechanism.createV2_=function(a){var b=shaka.offline.indexeddb.StorageMechanism,c=b.V2_SEGMENT_STORE;b=b.V2_MANIFEST_STORE;var d=a.objectStoreNames;return d.contains(b)&&d.contains(c)?(shaka.log.debug("Mounting v2 idb storage cell"),new shaka.offline.indexeddb.V2StorageCell(a,c,b)):null};
shaka.offline.indexeddb.StorageMechanism.createV3_=function(a){var b=shaka.offline.indexeddb.StorageMechanism,c=b.V3_SEGMENT_STORE;b=b.V3_MANIFEST_STORE;var d=a.objectStoreNames;return d.contains(b)&&d.contains(c)?(shaka.log.debug("Mounting v3 idb storage cell"),new shaka.offline.indexeddb.V2StorageCell(a,c,b)):null};
shaka.offline.indexeddb.StorageMechanism.createV5_=function(a){var b=shaka.offline.indexeddb.StorageMechanism,c=b.V5_SEGMENT_STORE;b=b.V5_MANIFEST_STORE;var d=a.objectStoreNames;return d.contains(b)&&d.contains(c)?(shaka.log.debug("Mounting v5 idb storage cell"),new shaka.offline.indexeddb.V5StorageCell(a,c,b)):null};
shaka.offline.indexeddb.StorageMechanism.createEmeSessionCell_=function(a){var b=shaka.offline.indexeddb.StorageMechanism.SESSION_ID_STORE;return a.objectStoreNames.contains(b)?(shaka.log.debug("Mounting session ID idb storage cell"),new shaka.offline.indexeddb.EmeSessionStorageCell(a,b)):null};
shaka.offline.indexeddb.StorageMechanism.prototype.createStores_=function(a){for(var b=(0,$jscomp.makeIterator)([shaka.offline.indexeddb.StorageMechanism.V5_SEGMENT_STORE,shaka.offline.indexeddb.StorageMechanism.V5_MANIFEST_STORE,shaka.offline.indexeddb.StorageMechanism.SESSION_ID_STORE]),c=b.next();!c.done;c=b.next())c=c.value,a.objectStoreNames.contains(c)||a.createObjectStore(c,{autoIncrement:!0})};
shaka.offline.indexeddb.StorageMechanism.deleteAll_=function(){var a=shaka.offline.indexeddb.StorageMechanism.DB_NAME,b=new shaka.util.PublicPromise,c=window.indexedDB.deleteDatabase(a);c.onblocked=function(d){shaka.log.warning("Deleting",a,"is being blocked",d)};c.onsuccess=function(d){b.resolve()};c.onerror=function(d){b.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.INDEXED_DB_ERROR,c.error));d.preventDefault()};return b};
shaka.offline.indexeddb.StorageMechanism.DB_NAME="shaka_offline_db";shaka.offline.indexeddb.StorageMechanism.VERSION=5;shaka.offline.indexeddb.StorageMechanism.V1_SEGMENT_STORE="segment";shaka.offline.indexeddb.StorageMechanism.V2_SEGMENT_STORE="segment-v2";shaka.offline.indexeddb.StorageMechanism.V3_SEGMENT_STORE="segment-v3";shaka.offline.indexeddb.StorageMechanism.V5_SEGMENT_STORE="segment-v5";shaka.offline.indexeddb.StorageMechanism.V1_MANIFEST_STORE="manifest";
shaka.offline.indexeddb.StorageMechanism.V2_MANIFEST_STORE="manifest-v2";shaka.offline.indexeddb.StorageMechanism.V3_MANIFEST_STORE="manifest-v3";shaka.offline.indexeddb.StorageMechanism.V5_MANIFEST_STORE="manifest-v5";shaka.offline.indexeddb.StorageMechanism.SESSION_ID_STORE="session-ids";shaka.offline.indexeddb.StorageMechanismOpenTimeout=5;goog.exportSymbol("shaka.offline.indexeddb.StorageMechanismOpenTimeout",shaka.offline.indexeddb.StorageMechanismOpenTimeout);
shaka.offline.StorageMuxer.register("idb",function(){return shaka.device.DeviceFactory.getDevice().supportsOfflineStorage()?new shaka.offline.indexeddb.StorageMechanism:null});shaka.offline.OfflineUri=function(a,b,c,d){this.type_=a;this.mechanism_=b;this.cell_=c;this.key_=d;this.asString_=["offline:",a,"/",b,"/",c,"/",d].join("")};shaka.offline.OfflineUri.prototype.isManifest=function(){return this.type_=="manifest"};shaka.offline.OfflineUri.prototype.isSegment=function(){return this.type_=="segment"};shaka.offline.OfflineUri.prototype.mechanism=function(){return this.mechanism_};shaka.offline.OfflineUri.prototype.cell=function(){return this.cell_};
shaka.offline.OfflineUri.prototype.key=function(){return this.key_};shaka.offline.OfflineUri.prototype.toString=function(){return this.asString_};shaka.offline.OfflineUri.parse=function(a){a=/^offline:([a-z]+)\/([^/]+)\/([^/]+)\/([0-9]+)$/.exec(a);if(a==null)return null;var b=a[1];if(b!="manifest"&&b!="segment")return null;var c=a[2];if(!c)return null;var d=a[3];return d&&b!=null?new shaka.offline.OfflineUri(b,c,d,Number(a[4])):null};
shaka.offline.OfflineUri.manifest=function(a,b,c){return new shaka.offline.OfflineUri("manifest",a,b,c)};shaka.offline.OfflineUri.segment=function(a,b,c){return new shaka.offline.OfflineUri("segment",a,b,c)};shaka.offline.ManifestConverter=function(a,b){this.mechanism_=a;this.cell_=b};
shaka.offline.ManifestConverter.prototype.fromManifestDB=function(a){var b=this,c=new shaka.media.PresentationTimeline(null,0);c.setDuration(a.duration);var d=a.streams.filter(function(l){return b.isAudio_(l)}),e=a.streams.filter(function(l){return b.isVideo_(l)});d=this.createVariants(d,e,c);e=a.streams.filter(function(l){return b.isText_(l)}).map(function(l){return b.fromStreamDB_(l,c)});var f=a.streams.filter(function(l){return b.isImage_(l)}).map(function(l){return b.fromStreamDB_(l,c)}),g=a.drmInfo?
[a.drmInfo]:[];if(a.drmInfo)for(var h=(0,$jscomp.makeIterator)(d.values()),k=h.next();!k.done;k=h.next())k=k.value,k.audio&&k.audio.encrypted&&(k.audio.drmInfos=g),k.video&&k.video.encrypted&&(k.video.drmInfos=g);return{presentationTimeline:c,offlineSessionIds:a.sessionIds,variants:Array.from(d.values()),textStreams:e,imageStreams:f,sequenceMode:a.sequenceMode||!1,ignoreManifestTimestampsInSegmentsMode:!1,type:a.type||shaka.media.ManifestParser.UNKNOWN,serviceDescription:null,nextUrl:null,periodCount:1,
gapCount:0,isLowLatency:!1,startTime:null}};
shaka.offline.ManifestConverter.prototype.createVariants=function(a,b,c){for(var d=new Set,e=(0,$jscomp.makeIterator)(a),f=e.next();!f.done;f=e.next()){f=(0,$jscomp.makeIterator)(f.value.variantIds);for(var g=f.next();!g.done;g=f.next())d.add(g.value)}e=(0,$jscomp.makeIterator)(b);for(f=e.next();!f.done;f=e.next())for(f=(0,$jscomp.makeIterator)(f.value.variantIds),g=f.next();!g.done;g=f.next())d.add(g.value);e=new Map;d=(0,$jscomp.makeIterator)(d);for(f=d.next();!f.done;f=d.next())f=f.value,e.set(f,
this.createEmptyVariant_(f));a=(0,$jscomp.makeIterator)(a);for(d=a.next();!d.done;d=a.next())for(f=d.value,d=this.fromStreamDB_(f,c),f=(0,$jscomp.makeIterator)(f.variantIds),g=f.next();!g.done;g=f.next())g=e.get(g.value),goog.asserts.assert(!g.audio,"A variant should only have one audio stream"),g.language=d.language,g.primary=g.primary||d.primary,g.audio=d;b=(0,$jscomp.makeIterator)(b);for(a=b.next();!a.done;a=b.next())for(d=a.value,a=this.fromStreamDB_(d,c),d=(0,$jscomp.makeIterator)(d.variantIds),
f=d.next();!f.done;f=d.next())f=e.get(f.value),goog.asserts.assert(!f.video,"A variant should only have one video stream"),f.primary=f.primary||a.primary,f.video=a;return e};
shaka.offline.ManifestConverter.prototype.fromStreamDB_=function(a,b){var c=this,d=a.segments.map(function(e,f){return c.fromSegmentDB_(f,e,a)});b.notifySegments(d);b=new shaka.media.SegmentIndex(d);return{id:a.id,originalId:a.originalId,groupId:a.groupId,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:b,mimeType:a.mimeType,codecs:a.codecs,width:a.width||void 0,height:a.height||void 0,frameRate:a.frameRate,pixelAspectRatio:a.pixelAspectRatio,hdr:a.hdr,colorGamut:a.colorGamut,
videoLayout:a.videoLayout,kind:a.kind,encrypted:a.encrypted,drmInfos:[],keyIds:a.keyIds,language:a.language,originalLanguage:a.originalLanguage||null,label:a.label,type:a.type,primary:a.primary,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:a.roles,forced:a.forced,channelsCount:a.channelsCount,audioSamplingRate:a.audioSamplingRate,spatialAudio:a.spatialAudio,closedCaptions:a.closedCaptions,tilesLayout:a.tilesLayout,mssPrivateData:a.mssPrivateData,accessibilityPurpose:null,external:a.external,
fastSwitching:a.fastSwitching,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs)]),isAudioMuxedInVideo:a.isAudioMuxedInVideo||!1,baseOriginalId:null}};
shaka.offline.ManifestConverter.prototype.fromSegmentDB_=function(a,b,c){var d=shaka.offline.OfflineUri.segment(this.mechanism_,this.cell_,b.dataKey);a=b.initSegmentKey!=null?this.fromInitSegmentDB_(b.initSegmentKey):null;a=new shaka.media.SegmentReference(b.startTime,b.endTime,function(){return[d.toString()]},0,null,a,b.timestampOffset,b.appendWindowStart,b.appendWindowEnd,[],b.tilesLayout||"");a.mimeType=b.mimeType||c.mimeType||"";a.codecs=b.codecs||c.codecs||"";b.thumbnailSprite&&a.setThumbnailSprite(b.thumbnailSprite);
return a};shaka.offline.ManifestConverter.prototype.fromInitSegmentDB_=function(a){var b=shaka.offline.OfflineUri.segment(this.mechanism_,this.cell_,a);return new shaka.media.InitSegmentReference(function(){return[b.toString()]},0,null)};shaka.offline.ManifestConverter.prototype.isAudio_=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO};shaka.offline.ManifestConverter.prototype.isVideo_=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.VIDEO};
shaka.offline.ManifestConverter.prototype.isText_=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.TEXT};shaka.offline.ManifestConverter.prototype.isImage_=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.IMAGE};shaka.offline.ManifestConverter.prototype.createEmptyVariant_=function(a){return{id:a,language:"",disabledUntilTime:0,primary:!1,audio:null,video:null,bandwidth:0,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]}};shaka.offline.OfflineManifestParser=function(){this.uri_=null};shaka.offline.OfflineManifestParser.prototype.configure=function(a){};
shaka.offline.OfflineManifestParser.prototype.start=function(a,b){var c=this,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:d=shaka.offline.OfflineUri.parse(a);c.uri_=d;if(d==null||!d.isManifest())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.MALFORMED_OFFLINE_URI,a);e=new shaka.offline.StorageMuxer;m.setFinallyBlock(2);return m.yield(e.init(),4);case 4:return m.yield(e.getCell(d.mechanism(),
d.cell()),5);case 5:return f=m.getYieldResultJsc(),m.yield(f.getManifests([d.key()]),6);case 6:return g=m.getYieldResultJsc(),h=g[0],k=new shaka.offline.ManifestConverter(d.mechanism(),d.cell()),l=k.fromManifestDB(h),b.makeTextStreamsForClosedCaptions(l),m.return(l);case 2:return m.enterFinallyBlock(),m.yield(e.destroy(),7);case 7:m.leaveFinallyBlock(0)}})};shaka.offline.OfflineManifestParser.prototype.stop=function(){return Promise.resolve()};
shaka.offline.OfflineManifestParser.prototype.update=function(){};
shaka.offline.OfflineManifestParser.prototype.onExpirationUpdated=function(a,b){var c=this,d,e,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){switch(n.getNextAddressJsc()){case 1:return goog.asserts.assert(c.uri_,"Should not get update event before start has been called"),d=c.uri_,e=new shaka.offline.StorageMuxer,n.setCatchFinallyBlocks(2,3),n.yield(e.init(),5);case 5:return n.yield(e.getCell(d.mechanism(),d.cell()),6);case 6:return f=n.getYieldResultJsc(),n.yield(f.getManifests([d.key()]),
7);case 7:g=n.getYieldResultJsc();h=g[0];k=h.sessionIds.includes(a);l=h.expiration==void 0||h.expiration>b;if(!k||!l){n.jumpTo(3);break}shaka.log.debug("Updating expiration for stored content");return n.yield(f.updateManifestExpiration(d.key(),b),3);case 3:return n.enterFinallyBlock(),n.yield(e.destroy(),10);case 10:n.leaveFinallyBlock(0);break;case 2:m=n.enterCatchBlock(),shaka.log.error("There was an error updating",d,m),n.jumpTo(3)}})};
shaka.offline.OfflineManifestParser.prototype.onInitialVariantChosen=function(a){};shaka.offline.OfflineManifestParser.prototype.banLocation=function(a){};shaka.offline.OfflineManifestParser.prototype.setMediaElement=function(a){};shaka.media.ManifestParser.registerParserByMime("application/x-offline-manifest",function(){return new shaka.offline.OfflineManifestParser});shaka.offline.OfflineScheme=function(){};shaka.offline.OfflineScheme.plugin=function(a,b,c,d){return(c=shaka.offline.OfflineUri.parse(a))&&c.isManifest()?shaka.offline.OfflineScheme.getManifest_(a,b):c&&c.isSegment()?shaka.offline.OfflineScheme.getSegment_(c.key(),c,b):shaka.util.AbortableOperation.failed(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.MALFORMED_OFFLINE_URI,a))};
shaka.offline.OfflineScheme.getManifest_=function(a,b){a={uri:a,originalUri:a,data:new ArrayBuffer(0),headers:{"content-type":"application/x-offline-manifest"},originalRequest:b};return shaka.util.AbortableOperation.completed(a)};
shaka.offline.OfflineScheme.getSegment_=function(a,b,c){goog.asserts.assert(b.isSegment(),"Only segment uri's should be given to getSegment");var d=new shaka.offline.StorageMuxer;return shaka.util.AbortableOperation.completed(void 0).chain(function(){return d.init()}).chain(function(){return d.getCell(b.mechanism(),b.cell())}).chain(function(e){return e.getSegments([b.key()])}).chain(function(e){return{uri:b,data:e[0].data,headers:{},originalRequest:c}}).finally(function(){return d.destroy()})};
goog.exportSymbol("shaka.offline.OfflineScheme",shaka.offline.OfflineScheme);goog.exportProperty(shaka.offline.OfflineScheme,"plugin",shaka.offline.OfflineScheme.plugin);shaka.net.NetworkingEngine.registerScheme("offline",shaka.offline.OfflineScheme.plugin);shaka.offline.SessionDeleter=function(){};shaka.offline.SessionDeleter.prototype.delete=function(a,b,c){var d=this,e,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){switch(n.getNextAddressJsc()){case 1:e=shaka.offline.SessionDeleter,f=[],g=(0,$jscomp.makeIterator)(e.createBuckets_(c)),h=g.next();case 2:if(h.done){n.jumpTo(4);break}k=h.value;l=d.doDelete_(a,b,k);return n.yield(l,5);case 5:m=n.getYieldResultJsc();f=f.concat(m);h=g.next();n.jumpTo(2);break;case 4:return n.return(f)}})};
shaka.offline.SessionDeleter.prototype.doDelete_=function(a,b,c){var d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.getNextAddressJsc()){case 1:return d=new shaka.drm.DrmEngine({netEngine:b,onError:function(){},onKeyStatus:function(){},onExpirationUpdated:function(){},onEvent:function(){}}),g.setCatchFinallyBlocks(2),d.configure(a),g.yield(d.initForRemoval(c.info.keySystem,c.info.licenseUri,c.info.serverCertificate,c.info.audioCapabilities,c.info.videoCapabilities),
4);case 4:g.leaveTryBlock(3);break;case 2:return e=g.enterCatchBlock(),shaka.log.warning("Error initializing EME",e),g.yield(d.destroy(),5);case 5:return g.return([]);case 3:return f=[],g.yield(Promise.all(c.sessionIds.map(function(h){var k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1)return l.setCatchFinallyBlocks(2),l.yield(d.removeSession(h),4);if(l.getNextAddressJsc()!=2)return f.push(h),l.leaveTryBlock(0);k=l.enterCatchBlock();shaka.log.warning("Error deleting offline session",
k);l.jumpToEnd()})})),6);case 6:return g.yield(d.destroy(),7);case 7:return g.return(f)}})};shaka.offline.SessionDeleter.createBuckets_=function(a){var b=shaka.offline.SessionDeleter,c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;for(var e=!1,f=(0,$jscomp.makeIterator)(c),g=f.next();!g.done;g=f.next())if(g=g.value,b.isCompatible_(g.info,d)){g.sessionIds.push(d.sessionId);e=!0;break}e||c.push({info:d,sessionIds:[d.sessionId]})}return c};
shaka.offline.SessionDeleter.isCompatible_=function(a,b){var c=shaka.util.ArrayUtils,d=function(e,f){return e.robustness==f.robustness&&e.contentType==f.contentType};return a.keySystem==b.keySystem&&a.licenseUri==b.licenseUri&&c.hasSameElements(a.audioCapabilities,b.audioCapabilities,d)&&c.hasSameElements(a.videoCapabilities,b.videoCapabilities,d)};shaka.offline.StoredContentUtils=function(){};shaka.offline.StoredContentUtils.fromManifest=function(a,b,c,d){goog.asserts.assert(b.variants.length,"Cannot create stored content from manifest with no variants.");var e=b.presentationTimeline.getDuration();b=shaka.offline.StoredContentUtils.getTracks_(b);return{offlineUri:null,originalManifestUri:a,duration:e,size:c,expiration:Infinity,tracks:b,appMetadata:d,isIncomplete:!1}};
shaka.offline.StoredContentUtils.fromManifestDB=function(a,b){goog.asserts.assert(b.streams.length,"Cannot create stored content from manifestDB with no streams.");var c=(new shaka.offline.ManifestConverter(a.mechanism(),a.cell())).fromManifestDB(b),d=b.appMetadata||{};c=shaka.offline.StoredContentUtils.getTracks_(c);goog.asserts.assert(b.expiration!=null,"Manifest expiration must be set by now!");return{offlineUri:a.toString(),originalManifestUri:b.originalManifestUri,duration:b.duration,size:b.size,
expiration:b.expiration,tracks:c,appMetadata:d,isIncomplete:b.isIncomplete||!1}};shaka.offline.StoredContentUtils.getTracks_=function(a){var b=shaka.util.StreamUtils,c=[],d=b.getPlayableVariants(a.variants);d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())c.push(b.variantToTrack(e.value));a=(0,$jscomp.makeIterator)(a.textStreams);for(d=a.next();!d.done;d=a.next())c.push(b.textStreamToTrack(d.value));return c};shaka.offline.StreamBandwidthEstimator=function(){this.estimateByStreamId_=new Map};
shaka.offline.StreamBandwidthEstimator.prototype.addVariant=function(a){var b=a.audio,c=a.video;b&&!c&&this.setBitrate_(b.id,b.bandwidth||a.bandwidth);!b&&c&&this.setBitrate_(c.id,c.bandwidth||a.bandwidth);if(b&&c){var d=b.bandwidth||shaka.offline.StreamBandwidthEstimator.DEFAULT_AUDIO_BITRATE_,e=c.bandwidth||a.bandwidth-d;e<=0&&(shaka.log.warning("Audio bit rate consumes variants bandwidth. Setting video bandwidth to match variant's bandwidth."),e=a.bandwidth);this.setBitrate_(b.id,d);this.setBitrate_(c.id,
e)}};shaka.offline.StreamBandwidthEstimator.prototype.setBitrate_=function(a,b){this.estimateByStreamId_.set(a,b)};shaka.offline.StreamBandwidthEstimator.prototype.addText=function(a){this.estimateByStreamId_.set(a.id,shaka.offline.StreamBandwidthEstimator.DEFAULT_TEXT_BITRATE_)};shaka.offline.StreamBandwidthEstimator.prototype.addImage=function(a){this.estimateByStreamId_.set(a.id,a.bandwidth||shaka.offline.StreamBandwidthEstimator.DEFAULT_IMAGE_BITRATE_)};
shaka.offline.StreamBandwidthEstimator.prototype.getSegmentEstimate=function(a,b){b=b.endTime-b.startTime;return this.getEstimate_(a)*b};shaka.offline.StreamBandwidthEstimator.prototype.getInitSegmentEstimate=function(a){return this.getEstimate_(a)*.5};
shaka.offline.StreamBandwidthEstimator.prototype.getEstimate_=function(a){a=this.estimateByStreamId_.get(a);a==null&&(a=0,shaka.log.error("Asking for bitrate of stream not given to the estimator"));a==0&&shaka.log.warning("Using bitrate of 0, this stream won't affect progress");return a};shaka.offline.StreamBandwidthEstimator.DEFAULT_AUDIO_BITRATE_=393216;shaka.offline.StreamBandwidthEstimator.DEFAULT_TEXT_BITRATE_=52;shaka.offline.StreamBandwidthEstimator.DEFAULT_IMAGE_BITRATE_=2048;shaka.offline.Storage=function(a){var b=this;if(a&&a.constructor!=shaka.Player)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.LOCAL_PLAYER_INSTANCE_REQUIRED);this.networkingEngine_=this.config_=null;a?(this.config_=a.getSharedConfiguration(),this.networkingEngine_=a.getNetworkingEngine(),goog.asserts.assert(this.networkingEngine_,"Storage should not be initialized with a player that had |destroy| called on it.")):(this.config_=
shaka.util.PlayerConfiguration.createDefault(),this.networkingEngine_=new shaka.net.NetworkingEngine,this.networkingEngine_.configure(this.config_.networking));this.openOperations_=[];this.openDownloadManagers_=[];var c=!a;this.destroyer_=new shaka.util.Destroyer(function(){var d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.getNextAddressJsc()){case 1:return k.yield(Promise.all(b.openDownloadManagers_.map(function(l){return l.abortAll()})),2);case 2:d=function(){};
e=[];f=(0,$jscomp.makeIterator)(b.openOperations_);for(g=f.next();!g.done;g=f.next())h=g.value,e.push(h.then(d,d));return k.yield(Promise.all(e),3);case 3:if(!c){k.jumpTo(4);break}return k.yield(b.networkingEngine_.destroy(),4);case 4:b.config_=null,b.networkingEngine_=null,k.jumpToEnd()}})});this.nextExternalStreamId_=1E9};shaka.offline.Storage.support=function(){return shaka.device.DeviceFactory.getDevice().supportsMediaSource()?shaka.offline.StorageMuxer.support():!1};
shaka.offline.Storage.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.offline.Storage.prototype.configure=function(a,b){goog.asserts.assert(typeof a=="object"||arguments.length==2,"String configs should have values!");arguments.length==2&&typeof a=="string"&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));goog.asserts.assert(typeof a=="object","Should be an object!");goog.asserts.assert(this.config_,"Cannot reconfigure storage after calling destroy.");return shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,a)};
shaka.offline.Storage.prototype.getConfiguration=function(){goog.asserts.assert(this.config_,"Config must not be null!");var a=shaka.util.PlayerConfiguration.createDefault();shaka.util.PlayerConfiguration.mergeConfigObjects(a,this.config_,shaka.util.PlayerConfiguration.createDefault());return a};shaka.offline.Storage.prototype.getNetworkingEngine=function(){return this.networkingEngine_};
shaka.offline.Storage.prototype.store=function(a,b,c,d,e){var f=this;goog.asserts.assert(this.networkingEngine_,"Cannot call |store| after calling |destroy|.");var g=this.getConfiguration(),h=new shaka.offline.DownloadManager(this.networkingEngine_);this.openDownloadManagers_.push(h);b=this.store_(a,b||{},d||[],e||[],function(){var k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1)return goog.asserts.assert(f.networkingEngine_,"Should not call |store| after |destroy|"),
c?l.jumpTo(2):l.yield(shaka.net.NetworkingUtils.getMimeType(a,f.networkingEngine_,g.manifest.retryParameters),3);l.getNextAddressJsc()!=2&&(c=l.getYieldResultJsc());k=shaka.media.ManifestParser.getFactory(a,c||null);return l.return(k())})},g,h);b=new shaka.util.AbortableOperation(b,function(){return h.abortAll()});b.finally(function(){shaka.util.ArrayUtils.remove(f.openDownloadManagers_,h)});return this.startAbortableOperation_(b)};
shaka.offline.Storage.prototype.store_=function(a,b,c,d,e,f,g){var h=this,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.getNextAddressJsc()){case 1:return h.requireSupport_(),l=k=null,m=new shaka.offline.StorageMuxer,q=p=n=null,H.setCatchFinallyBlocks(2,3),H.yield(e(),5);case 5:return k=H.getYieldResultJsc(),H.yield(h.parseManifest(a,k,f),6);case 6:r=H.getYieldResultJsc();h.ensureNotDestroyed_();t=!r.presentationTimeline.isLive()&&
!r.presentationTimeline.isInProgress();if(!t)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.CANNOT_STORE_LIVE_OFFLINE,a);u=(0,$jscomp.makeIterator)(c);w=u.next();case 7:if(w.done){H.jumpTo(9);break}v=w.value;return H.yield(h.createExternalImageStream_(v,r),10);case 10:x=H.getYieldResultJsc();r.imageStreams.push(x);h.ensureNotDestroyed_();w=u.next();H.jumpTo(7);break;case 9:y=(0,$jscomp.makeIterator)(d),A=y.next();case 11:if(A.done)return shaka.drm.DrmEngine.configureClearKey(f.drm.clearKeys,
r.variants),z=r.variants.some(function(M){if(M.audio)for(var L=(0,$jscomp.makeIterator)(M.audio.drmInfos),N=L.next();!N.done;N=L.next())if(N.value.licenseServerUri.startsWith("data:"))return!0;if(M.video)for(M=(0,$jscomp.makeIterator)(M.video.drmInfos),L=M.next();!L.done;L=M.next())if(L.value.licenseServerUri.startsWith("data:"))return!0;return!1}),C=f.offline.usePersistentLicense,z&&(C=!1),H.yield(h.createDrmEngine(r,function(M){q=q||M},f,C),15);B=A.value;return H.yield(h.createExternalTextStream_(r,
B.uri,B.language,B.kind,B.mime,B.codecs),14);case 14:D=H.getYieldResultJsc();r.textStreams.push(D);h.ensureNotDestroyed_();A=y.next();H.jumpTo(11);break;case 15:l=H.getYieldResultJsc();h.ensureNotDestroyed_();if(q)throw q;return H.yield(h.filterManifest_(r,l,f,C),16);case 16:return H.yield(m.init(),17);case 17:return h.ensureNotDestroyed_(),H.yield(m.getActive(),18);case 18:return n=H.getYieldResultJsc(),h.ensureNotDestroyed_(),goog.asserts.assert(l,"drmEngine should be non-null here."),E=h.makeManifestDB_(l,
r,a,b,f,g,C),G=E.manifestDB,I=E.toDownload,H.yield(n.cell.addManifests([G]),19);case 19:F=H.getYieldResultJsc();h.ensureNotDestroyed_();p=F[0];goog.asserts.assert(l,"drmEngine should be non-null here.");h.ensureNotDestroyed_();if(q)throw q;return H.yield(h.downloadSegments_(I,p,G,g,f,n.cell,r,l,C),20);case 20:return h.ensureNotDestroyed_(),h.setManifestDrmFields_(r,G,l,C),H.yield(n.cell.updateManifest(p,G),21);case 21:return h.ensureNotDestroyed_(),J=shaka.offline.OfflineUri.manifest(n.path.mechanism,
n.path.cell,p),H.return(shaka.offline.StoredContentUtils.fromManifestDB(J,G));case 3:return H.enterFinallyBlock(),H.yield(m.destroy(),22);case 22:if(!k){H.jumpTo(23);break}return H.yield(k.stop(),23);case 23:if(!l){H.jumpTo(25);break}return H.yield(l.destroy(),25);case 25:H.leaveFinallyBlock(0);break;case 2:K=H.enterCatchBlock();if(p==null){H.jumpTo(27);break}return H.yield(shaka.offline.Storage.cleanStoredManifest(p),27);case 27:throw q||K;}})};
shaka.offline.Storage.prototype.downloadSegments_=function(a,b,c,d,e,f,g,h,k){var l=this,m,n,p,q,r,t,u,w,v,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){case 1:m={};n=0;p=function(){if(l.destroyer_.destroyed()||d.isAborted())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.OPERATION_ABORTED);};q=function(B,D){var z,C,E,G,I,F,J,K,H;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(M){if(M.getNextAddressJsc()==
1){z=(0,$jscomp.makeIterator)(B);C=z.next();for(E={};!C.done;E={download$jscomp$1:void 0},C=z.next())E.download$jscomp$1=C.value,p(),G=E.download$jscomp$1.makeSegmentRequest(e),I=E.download$jscomp$1.estimateId,F=E.download$jscomp$1.isInitSegment,J=function(L){return function(N){var P,Q,O,S;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(V){switch(V.getNextAddressJsc()){case 1:P=L.download$jscomp$1.ref;Q=P.getSegmentData(!1);if(!P.aesKey||Q){V.jumpTo(2);break}return V.yield(shaka.media.SegmentUtils.aesDecrypt(N,
P.aesKey,L.download$jscomp$1.refPosition),3);case 3:N=V.getYieldResultJsc();case 2:return O=shaka.offline.DownloadInfo.idForSegmentRef(P),V.yield(f.addSegments([{data:N}]),4);case 4:S=V.getYieldResultJsc(),p(),m[O]=S[0],n+=N.byteLength,V.jumpToEnd()}})}}(E),K=E.download$jscomp$1.ref,(H=K.getSegmentData(!1))?d.queueData(E.download$jscomp$1.groupId,H,I,F,J):d.queue(E.download$jscomp$1.groupId,G,I,F,J);return M.yield(d.waitToFinish(),2)}p();if(!D||d.isAborted())return M.jumpTo(0);l.setManifestDrmFields_(g,
c,h,k);return M.yield(f.updateManifest(b,c),0)})};r=!1;A.setCatchFinallyBlocks(2);if(!l.getManifestIsEncrypted_(g)||!r||l.getManifestIncludesInitData_(g)){A.jumpTo(4);break}return A.yield(q(a.filter(function(B){return B.isInitSegment}),!0),5);case 5:return p(),a=a.filter(function(B){return!B.isInitSegment}),t=m,u=n,m={},n=0,A.yield(shaka.offline.Storage.assignSegmentsToManifest(f,b,c,t,u,function(){return l.ensureNotDestroyed_()}),6);case 6:p();case 4:if(r){A.jumpTo(7);break}return A.yield(q(a,!1),
8);case 8:return p(),w=m,v=n,m={},n=0,A.yield(shaka.offline.Storage.assignSegmentsToManifest(f,b,c,w,v,function(){return p()}),9);case 9:p(),goog.asserts.assert(!c.isIncomplete,"The manifest should be complete by now");case 7:A.leaveTryBlock(0);break;case 2:return x=A.enterCatchBlock(),y=Object.values(m),A.yield(f.removeSegments(y,function(B){}),10);case 10:throw x;}})};
shaka.offline.Storage.cleanStoredManifest=function(a){var b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){switch(f.getNextAddressJsc()){case 1:return b=new shaka.offline.StorageMuxer,f.yield(b.init(),2);case 2:return f.yield(b.getActive(),3);case 3:return c=f.getYieldResultJsc(),d=shaka.offline.OfflineUri.manifest(c.path.mechanism,c.path.cell,a),f.yield(b.destroy(),4);case 4:return e=new shaka.offline.Storage,f.yield(e.remove(d.toString()),0)}})};
shaka.offline.Storage.assignSegmentsToManifest=function(a,b,c,d,e,f){var g,h,k,l,m,n,p,q,r,t,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(w){switch(w.getNextAddressJsc()){case 1:g=!1;w.setCatchFinallyBlocks(2);h=!0;k=(0,$jscomp.makeIterator)(c.streams);for(l=k.next();!l.done;l=k.next())for(m=l.value,n=(0,$jscomp.makeIterator)(m.segments),p=n.next();!p.done;p=n.next())q=p.value,r=q.pendingSegmentRefId?d[q.pendingSegmentRefId]:null,r!=null&&(q.dataKey=r,q.pendingSegmentRefId=void 0),
r=q.pendingInitSegmentRefId?d[q.pendingInitSegmentRefId]:null,r!=null&&(q.initSegmentKey=r,q.pendingInitSegmentRefId=void 0),q.pendingSegmentRefId&&(h=!1),q.pendingInitSegmentRefId&&(h=!1);c.size+=e;h&&(c.isIncomplete=!1);return w.yield(a.updateManifest(b,c),4);case 4:g=!0;f();w.leaveTryBlock(0);break;case 2:return t=w.enterCatchBlock(),w.yield(shaka.offline.Storage.cleanStoredManifest(b),5);case 5:if(g){w.jumpTo(6);break}u=Object.values(d);return w.yield(a.removeSegments(u,function(v){}),6);case 6:throw t;
}})};
shaka.offline.Storage.prototype.filterManifest_=function(a,b,c,d){var e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D,z,C,E,G,I,F,J,K,H,M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(L){switch(L.getNextAddressJsc()){case 1:return e={width:Infinity,height:Infinity},shaka.util.StreamUtils.filterByRestrictions(a,c.restrictions,e),L.yield(shaka.util.StreamUtils.filterManifestByMediaCapabilities(b,a,d,c.drm.preferredKeySystems,c.drm.keySystemsMapping),2);case 2:f=[];g=c.preferredDecodingAttributes;h=
c.preferredVideoCodecs;k=c.preferredAudioCodecs;l=c.preferredTextFormats;shaka.util.StreamUtils.chooseCodecsAndFilterManifest(a,h,k,g,l);m=(0,$jscomp.makeIterator)(a.variants);for(n=m.next();!n.done;n=m.next())p=n.value,goog.asserts.assert(shaka.util.StreamUtils.isPlayable(p),'We should have already filtered by "is playable"'),f.push(shaka.util.StreamUtils.variantToTrack(p));q=(0,$jscomp.makeIterator)(a.textStreams);for(r=q.next();!r.done;r=q.next())t=r.value,f.push(shaka.util.StreamUtils.textStreamToTrack(t));
u=(0,$jscomp.makeIterator)(a.imageStreams);for(w=u.next();!w.done;w=u.next())v=w.value,f.push(shaka.util.StreamUtils.imageStreamToTrack(v));return L.yield(c.offline.trackSelectionCallback(f),3);case 3:x=L.getYieldResultJsc();y=a.presentationTimeline.getDuration();A=0;B=(0,$jscomp.makeIterator)(x);for(D=B.next();!D.done;D=B.next())z=D.value,C=z.bandwidth*y/8,A+=C;L.setCatchFinallyBlocks(4);return L.yield(c.offline.downloadSizeCallback(A),6);case 6:E=L.getYieldResultJsc();if(!E)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.STORAGE_LIMIT_REACHED);L.leaveTryBlock(5);break;case 4:G=L.enterCatchBlock();if(G instanceof shaka.util.Error)throw G;shaka.log.warning("downloadSizeCallback has produced an unexpected error",G);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.DOWNLOAD_SIZE_CALLBACK_ERROR);case 5:I=new Set;F=new Set;J=new Set;K=(0,$jscomp.makeIterator)(x);for(H=K.next();!H.done;H=K.next())M=
H.value,M.type=="variant"&&I.add(M.id),M.type=="text"&&F.add(M.id),M.type=="image"&&J.add(M.id);a.variants=a.variants.filter(function(N){return I.has(N.id)});a.textStreams=a.textStreams.filter(function(N){return F.has(N.id)});a.imageStreams=a.imageStreams.filter(function(N){return J.has(N.id)});shaka.offline.Storage.validateManifest_(a);L.jumpToEnd()}})};
shaka.offline.Storage.prototype.makeManifestDB_=function(a,b,c,d,e,f,g){var h=shaka.offline.StoredContentUtils.fromManifest(c,b,0,d),k=e.offline.progressCallback;f.setCallbacks(function(r,t){h.size=t;k(h,r)},function(r,t){l&&g&&m==t&&a.newInitData("cenc",r)});var l=this.getManifestIsEncrypted_(b)&&!this.getManifestIncludesInitData_(b),m=null;if(l){var n=a.getDrmInfo();m=shaka.offline.Storage.defaultSystemIds_.get(n.keySystem)}n=new shaka.offline.StreamBandwidthEstimator;for(var p=(0,$jscomp.makeIterator)(b.textStreams),
q=p.next();!q.done;q=p.next())n.addText(q.value);p=(0,$jscomp.makeIterator)(b.imageStreams);for(q=p.next();!q.done;q=p.next())n.addImage(q.value);p=(0,$jscomp.makeIterator)(b.variants);for(q=p.next();!q.done;q=p.next())n.addVariant(q.value);f=this.createStreams_(f,n,a,b,e);e=f.streams;f=f.toDownload;(n=a.getDrmInfo())&&g&&(n.initData=[]);return{manifestDB:{creationTime:Date.now(),originalManifestUri:c,duration:b.presentationTimeline.getDuration(),size:0,expiration:a.getExpiration(),streams:e,sessionIds:g?
a.getSessionIds():[],drmInfo:n,appMetadata:d,isIncomplete:!0,sequenceMode:b.sequenceMode,type:b.type},toDownload:f}};shaka.offline.Storage.prototype.getManifestIsEncrypted_=function(a){return a.variants.some(function(b){var c=b.audio&&b.audio.encrypted;return b.video&&b.video.encrypted||c})};
shaka.offline.Storage.prototype.getManifestIncludesInitData_=function(a){return a.variants.some(function(b){return(b.video?b.video.drmInfos:[]).concat(b.audio?b.audio.drmInfos:[]).some(function(c){return c.initData&&c.initData.length})})};
shaka.offline.Storage.prototype.setManifestDrmFields_=function(a,b,c,d){b.expiration=c.getExpiration();c=c.getSessionIds();b.sessionIds=d?c:[];if(this.getManifestIsEncrypted_(a)&&d&&!c.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.NO_INIT_DATA_FOR_OFFLINE);};shaka.offline.Storage.prototype.remove=function(a){return this.startOperation_(this.remove_(a))};
shaka.offline.Storage.prototype.remove_=function(a){var b=this,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.getNextAddressJsc()){case 1:b.requireSupport_();c=shaka.offline.OfflineUri.parse(a);if(c==null||!c.isManifest())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.MALFORMED_OFFLINE_URI,a);d=c;e=new shaka.offline.StorageMuxer;k.setFinallyBlock(2);return k.yield(e.init(),4);case 4:return k.yield(e.getCell(d.mechanism(),
d.cell()),5);case 5:return f=k.getYieldResultJsc(),k.yield(f.getManifests([d.key()]),6);case 6:return g=k.getYieldResultJsc(),h=g[0],k.yield(Promise.all([b.removeFromDRM_(d,h,e),b.removeFromStorage_(f,d,h)]),2);case 2:return k.enterFinallyBlock(),k.yield(e.destroy(),8);case 8:k.leaveFinallyBlock(0)}})};
shaka.offline.Storage.getCapabilities_=function(a,b){for(var c=shaka.util.MimeUtils,d=[],e=(0,$jscomp.makeIterator)(a.streams),f=e.next();!f.done;f=e.next())f=f.value,b&&f.type=="video"?d.push({contentType:c.getFullType(f.mimeType,f.codecs),robustness:a.drmInfo.videoRobustness}):b||f.type!="audio"||d.push({contentType:c.getFullType(f.mimeType,f.codecs),robustness:a.drmInfo.audioRobustness});return d};
shaka.offline.Storage.prototype.removeFromDRM_=function(a,b,c){var d=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){goog.asserts.assert(d.networkingEngine_,"Cannot be destroyed");return e.yield(shaka.offline.Storage.deleteLicenseFor_(d.networkingEngine_,d.config_.drm,c,b),0)})};
shaka.offline.Storage.prototype.removeFromStorage_=function(a,b,c){var d=this,e=shaka.offline.Storage.getAllSegmentIds_(c),f=e.length+1,g=0,h=shaka.offline.StoredContentUtils.fromManifestDB(b,c);c=function(k){g+=1;d.config_.offline.progressCallback(h,g/f)};return Promise.all([a.removeSegments(e,c),a.removeManifests([b.key()],c)])};shaka.offline.Storage.prototype.removeEmeSessions=function(){return this.startOperation_(this.removeEmeSessions_())};
shaka.offline.Storage.prototype.removeEmeSessions_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){switch(p.getNextAddressJsc()){case 1:return a.requireSupport_(),goog.asserts.assert(a.networkingEngine_,"Cannot be destroyed"),b=a.networkingEngine_,c=a.config_.drm,d=new shaka.offline.StorageMuxer,e=new shaka.offline.SessionDeleter,f=!1,p.setFinallyBlock(2),p.yield(d.init(),4);case 4:g=[],d.forEachEmeSessionCell(function(q){return g.push(q)}),
h=(0,$jscomp.makeIterator)(g),k=h.next();case 5:if(k.done){p.jumpTo(2);break}l=k.value;return p.yield(l.getAll(),8);case 8:return m=p.getYieldResultJsc(),p.yield(e.delete(c,b,m),9);case 9:return n=p.getYieldResultJsc(),p.yield(l.remove(n),10);case 10:n.length!=m.length&&(f=!0);k=h.next();p.jumpTo(5);break;case 2:return p.enterFinallyBlock(),p.yield(d.destroy(),11);case 11:p.leaveFinallyBlock(3);break;case 3:return p.return(!f)}})};shaka.offline.Storage.prototype.list=function(){return this.startOperation_(this.list_())};
shaka.offline.Storage.prototype.list_=function(){var a=this,b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){switch(e.getNextAddressJsc()){case 1:return a.requireSupport_(),b=[],c=new shaka.offline.StorageMuxer,e.setFinallyBlock(2),e.yield(c.init(),4);case 4:return d=Promise.resolve(),c.forEachCell(function(f,g){d=d.then(function(){var h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1)return k.yield(g.getAllManifests(),2);h=k.getYieldResultJsc();
h.forEach(function(l,m){m=shaka.offline.OfflineUri.manifest(f.mechanism,f.cell,m);l=shaka.offline.StoredContentUtils.fromManifestDB(m,l);b.push(l)});k.jumpToEnd()})})}),e.yield(d,2);case 2:return e.enterFinallyBlock(),e.yield(c.destroy(),6);case 6:e.leaveFinallyBlock(3);break;case 3:return e.return(b)}})};
shaka.offline.Storage.prototype.parseManifest=function(a,b,c){var d=this,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1)return e=null,f=d.networkingEngine_,goog.asserts.assert(f,"Should be initialized!"),g={networkingEngine:f,filter:function(){return Promise.resolve()},makeTextStreamsForClosedCaptions:function(m){},onTimelineRegionAdded:function(){},onEvent:function(){},onError:function(m){e=m},isLowLatencyMode:function(){return!1},updateDuration:function(){},
newDrmInfo:function(m){},onManifestUpdated:function(){},getBandwidthEstimate:function(){return c.abr.defaultBandwidthEstimate},onMetadata:function(){},disableStream:function(m){},addFont:function(m,n){}},b.configure(c.manifest),d.ensureNotDestroyed_(),l.yield(b.start(a,g),2);if(l.getNextAddressJsc()!=3)return h=l.getYieldResultJsc(),d.ensureNotDestroyed_(),k=shaka.offline.Storage.getAllStreamsFromManifest_(h),l.yield(Promise.all(shaka.util.Iterables.map(k,function(m){return m.createSegmentIndex()})),
3);d.ensureNotDestroyed_();if(e)throw e;return l.return(h)})};
shaka.offline.Storage.prototype.createExternalImageStream_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(v){switch(v.getNextAddressJsc()){case 1:return v.yield(c.getTextMimetype_(a),2);case 2:d=v.getYieldResultJsc();if(d!="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);goog.asserts.assert(c.networkingEngine_,
"Need networking engine.");return v.yield(c.getTextData_(a,c.networkingEngine_,c.config_.streaming.retryParameters),3);case 3:e=v.getYieldResultJsc();f=shaka.text.TextEngine.findParser(d);if(!f)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,d);g=f();h={periodStart:0,segmentStart:0,segmentEnd:b.presentationTimeline.getDuration(),vttOffset:0};k=shaka.util.BufferUtils.toUint8(e);l=g.parseMedia(k,h,a,[]);m=[];n=(0,$jscomp.makeIterator)(l);
p=n.next();for(q={};!p.done;q={uris$jscomp$26:void 0,cue$jscomp$48:void 0},p=n.next())q.cue$jscomp$48=p.value,q.uris$jscomp$26=null,r=function(x){return function(){x.uris$jscomp$26==null&&(x.uris$jscomp$26=shaka.util.ManifestParserUtils.resolveUris([a],[x.cue$jscomp$48.payload]));return x.uris$jscomp$26||[]}}(q),t=new shaka.media.SegmentReference(q.cue$jscomp$48.startTime,q.cue$jscomp$48.endTime,r,0,null,null,0,0,Infinity),q.cue$jscomp$48.payload.includes("#xywh")&&(u=q.cue$jscomp$48.payload.split("#xywh=")[1].split(","),
u.length===4&&t.setThumbnailSprite({height:parseInt(u[3],10),positionX:parseInt(u[0],10),positionY:parseInt(u[1],10),width:parseInt(u[2],10)})),m.push(t);w=d;if(!m.length){v.jumpTo(4);break}return v.yield(shaka.net.NetworkingUtils.getMimeType(m[0].getUris()[0],c.networkingEngine_,c.config_.manifest.retryParameters),5);case 5:w=v.getYieldResultJsc();case 4:return v.return({id:c.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex(m),
mimeType:w||"",codecs:"",kind:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:"und",originalLanguage:null,label:null,type:shaka.util.ManifestParserUtils.ContentType.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(w||"","")]),isAudioMuxedInVideo:!1,
baseOriginalId:null})}})};
shaka.offline.Storage.prototype.createExternalTextStream_=function(a,b,c,d,e,f){var g=this,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1)return e?m.jumpTo(2):m.yield(g.getTextMimetype_(b),3);m.getNextAddressJsc()!=2&&(e=m.getYieldResultJsc());h={id:g.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:shaka.media.SegmentIndex.forSingleSegment(0,a.presentationTimeline.getDuration(),[b]),
mimeType:e||"",codecs:f||"",kind:d,encrypted:!1,drmInfos:[],keyIds:new Set,language:c,originalLanguage:c,label:null,type:shaka.util.ManifestParserUtils.ContentType.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(e||"",f||"")]),isAudioMuxedInVideo:!1,baseOriginalId:null};
k=shaka.util.MimeUtils.getFullType(h.mimeType,h.codecs);l=shaka.text.TextEngine.isTypeSupported(k);if(!l)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,e);return m.return(h)})};
shaka.offline.Storage.prototype.getTextMimetype_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){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.getYieldResultJsc();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.offline.Storage.prototype.getTextData_=function(a,b,c){var d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return d=shaka.net.NetworkingEngine.RequestType.SEGMENT,e=shaka.net.NetworkingEngine.makeRequest([a],c),e.method="GET",g.yield(b.request(d,e).promise,2);f=g.getYieldResultJsc();return g.return(f.data)})};
shaka.offline.Storage.prototype.createDrmEngine=function(a,b,c,d){var e=this,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){return g.getNextAddressJsc()==1?(goog.asserts.assert(e.networkingEngine_,"Cannot call |createDrmEngine| after |destroy|"),f=new shaka.drm.DrmEngine({netEngine:e.networkingEngine_,onError:b,onKeyStatus:function(){},onExpirationUpdated:function(){},onEvent:function(){}}),f.configure(c.drm),g.yield(f.initForStorage(a.variants,d),2)):g.getNextAddressJsc()!=3?
d?g.yield(f.createOrLoad(),3):g.jumpTo(3):g.return(f)})};
shaka.offline.Storage.prototype.createStreams_=function(a,b,c,d,e){c=new Map;var f=shaka.offline.Storage.getAllStreamsFromManifest_(d),g=new Map;f=(0,$jscomp.makeIterator)(f);for(var h=f.next();!h.done;h=f.next()){h=h.value;var k=this.createStream_(a,b,d,h,e,c);g.set(h.id,k)}a=(0,$jscomp.makeIterator)(d.variants);for(b=a.next();!b.done;b=a.next())b=b.value,b.audio&&g.get(b.audio.id).variantIds.push(b.id),b.video&&g.get(b.video.id).variantIds.push(b.id);return{streams:Array.from(g.values()),toDownload:Array.from(c.values())}};
shaka.offline.Storage.prototype.createStream_=function(a,b,c,d,e,f){var g={id:d.id,originalId:d.originalId,groupId:d.groupId,primary:d.primary,type:d.type,mimeType:d.mimeType,codecs:d.codecs,frameRate:d.frameRate,pixelAspectRatio:d.pixelAspectRatio,hdr:d.hdr,colorGamut:d.colorGamut,videoLayout:d.videoLayout,kind:d.kind,language:d.language,originalLanguage:d.originalLanguage,label:d.label,width:d.width||null,height:d.height||null,encrypted:d.encrypted,keyIds:d.keyIds,segments:[],variantIds:[],roles:d.roles,
forced:d.forced,channelsCount:d.channelsCount,audioSamplingRate:d.audioSamplingRate,spatialAudio:d.spatialAudio,closedCaptions:d.closedCaptions,tilesLayout:d.tilesLayout,mssPrivateData:d.mssPrivateData,external:d.external,fastSwitching:d.fastSwitching,isAudioMuxedInVideo:d.isAudioMuxedInVideo};c=c.presentationTimeline.getSegmentAvailabilityStart();var h=e.offline.numberOfParallelDownloads,k=h===0?d.id:0;shaka.offline.Storage.forEachSegment_(d,c,function(l,m){var n=shaka.offline.DownloadInfo.idForSegmentRef(l),
p=void 0;if(!f.has(n)){var q=a.addDownloadEstimate(b.getSegmentEstimate(d.id,l));q=new shaka.offline.DownloadInfo(l,q,k,!1,m);f.set(n,q)}l.initSegmentReference&&(p=shaka.offline.DownloadInfo.idForSegmentRef(l.initSegmentReference),f.has(p)||(q=a.addDownloadEstimate(b.getInitSegmentEstimate(d.id)),m=new shaka.offline.DownloadInfo(l.initSegmentReference,q,k,!0,m),f.set(p,m)));g.segments.push({pendingInitSegmentRefId:p,initSegmentKey:p?0:null,startTime:l.startTime,endTime:l.endTime,appendWindowStart:l.appendWindowStart,
appendWindowEnd:l.appendWindowEnd,timestampOffset:l.timestampOffset,tilesLayout:l.tilesLayout,pendingSegmentRefId:n,dataKey:0,mimeType:l.mimeType,codecs:l.codecs,thumbnailSprite:l.thumbnailSprite});h!==0&&(k=(k+1)%h)});return g};shaka.offline.Storage.forEachSegment_=function(a,b,c){b=a.segmentIndex.find(b);if(b!=null)for(var d=a.segmentIndex.get(b);d;)c(d,b),d=a.segmentIndex.get(++b)};
shaka.offline.Storage.prototype.ensureNotDestroyed_=function(){if(this.destroyer_.destroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.OPERATION_ABORTED);};shaka.offline.Storage.prototype.requireSupport_=function(){if(!shaka.offline.Storage.support())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STORAGE,shaka.util.Error.Code.STORAGE_NOT_SUPPORTED);};
shaka.offline.Storage.prototype.startOperation_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return b.openOperations_.push(a),c.setFinallyBlock(2),c.yield(a,4);if(c.getNextAddressJsc()!=2)return c.return(c.getYieldResultJsc());c.enterFinallyBlock();shaka.util.ArrayUtils.remove(b.openOperations_,a);return c.leaveFinallyBlock(0)})};
shaka.offline.Storage.prototype.startAbortableOperation_=function(a){var b=this,c=a.promise;this.openOperations_.push(c);return a.finally(function(){shaka.util.ArrayUtils.remove(b.openOperations_,c)})};shaka.offline.Storage.getAllSegmentIds_=function(a){var b=new Set;a=(0,$jscomp.makeIterator)(a.streams);for(var c=a.next();!c.done;c=a.next()){c=(0,$jscomp.makeIterator)(c.value.segments);for(var d=c.next();!d.done;d=c.next())d=d.value,d.initSegmentKey!=null&&b.add(d.initSegmentKey),b.add(d.dataKey)}return Array.from(b)};
shaka.offline.Storage.deleteAll=function(){var a;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.getNextAddressJsc()==1?(a=new shaka.offline.StorageMuxer,b.setFinallyBlock(2),b.yield(a.erase(),2)):b.getNextAddressJsc()!=5?(b.enterFinallyBlock(),b.yield(a.destroy(),5)):b.leaveFinallyBlock(0)})};
shaka.offline.Storage.deleteLicenseFor_=function(a,b,c,d){var e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){if(!d.drmInfo)return k.return();e=c.getEmeSessionCell();f=d.sessionIds.map(function(l){return{sessionId:l,keySystem:d.drmInfo.keySystem,licenseUri:d.drmInfo.licenseServerUri,serverCertificate:d.drmInfo.serverCertificate,audioCapabilities:shaka.offline.Storage.getCapabilities_(d,!1),videoCapabilities:shaka.offline.Storage.getCapabilities_(d,
!0)}});g=new shaka.offline.SessionDeleter;return k.yield(g.delete(b,a,f),2)}return k.getNextAddressJsc()!=3?(h=k.getYieldResultJsc(),k.yield(e.remove(h),3)):k.yield(e.add(f.filter(function(l){return!h.includes(l.sessionId)})),0)})};
shaka.offline.Storage.getAllStreamsFromManifest_=function(a){for(var b=new Set,c=(0,$jscomp.makeIterator)(a.variants),d=c.next();!d.done;d=c.next())d=d.value,d.audio&&b.add(d.audio),d.video&&b.add(d.video);c=(0,$jscomp.makeIterator)(a.textStreams);for(d=c.next();!d.done;d=c.next())b.add(d.value);a=(0,$jscomp.makeIterator)(a.imageStreams);for(c=a.next();!c.done;c=a.next())b.add(c.value);return b};
shaka.offline.Storage.validateManifest_=function(a){var b=new Set(a.variants.map(function(g){return g.video})),c=new Set(a.variants.map(function(g){return g.audio}));a=a.textStreams;b.size>1&&shaka.log.warning("Multiple video tracks selected to be stored");b=(0,$jscomp.makeIterator)(c);for(var d=b.next();!d.done;d=b.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(c),f=e.next();!f.done;f=e.next())f=f.value,d!=f&&d.language==f.language&&shaka.log.warning("Similar audio tracks were selected to be stored",
d.id,f.id)}c=(0,$jscomp.makeIterator)(a);for(b=c.next();!b.done;b=c.next())for(b=b.value,d=(0,$jscomp.makeIterator)(a),e=d.next();!e.done;e=d.next())e=e.value,b!=e&&b.language==e.language&&shaka.log.warning("Similar text tracks were selected to be stored",b.id,e.id)};goog.exportSymbol("shaka.offline.Storage",shaka.offline.Storage);goog.exportProperty(shaka.offline.Storage,"deleteAll",shaka.offline.Storage.deleteAll);goog.exportProperty(shaka.offline.Storage.prototype,"list",shaka.offline.Storage.prototype.list);
goog.exportProperty(shaka.offline.Storage.prototype,"removeEmeSessions",shaka.offline.Storage.prototype.removeEmeSessions);goog.exportProperty(shaka.offline.Storage.prototype,"remove",shaka.offline.Storage.prototype.remove);goog.exportProperty(shaka.offline.Storage.prototype,"store",shaka.offline.Storage.prototype.store);goog.exportProperty(shaka.offline.Storage.prototype,"getNetworkingEngine",shaka.offline.Storage.prototype.getNetworkingEngine);
goog.exportProperty(shaka.offline.Storage.prototype,"getConfiguration",shaka.offline.Storage.prototype.getConfiguration);goog.exportProperty(shaka.offline.Storage.prototype,"configure",shaka.offline.Storage.prototype.configure);goog.exportProperty(shaka.offline.Storage.prototype,"destroy",shaka.offline.Storage.prototype.destroy);goog.exportProperty(shaka.offline.Storage,"support",shaka.offline.Storage.support);
shaka.offline.Storage.defaultSystemIds_=(new Map).set("org.w3.clearkey","1077efecc0b24d02ace33c1e52e2fb4b").set("com.widevine.alpha","edef8ba979d64acea3c827dcd51d21ed").set("com.microsoft.playready","9a04f07998404286ab92e65be0885f95").set("com.microsoft.playready.recommendation","9a04f07998404286ab92e65be0885f95").set("com.microsoft.playready.software","9a04f07998404286ab92e65be0885f95").set("com.microsoft.playready.hardware","9a04f07998404286ab92e65be0885f95").set("com.huawei.wiseplay","3d5e6d359b9a41e8b843dd3c6e72c42c");
shaka.Player.registerSupportPlugin("offline",shaka.offline.Storage.support);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.Aria=function(){};shaka.polyfill.Aria.install=function(){if(Object.getOwnPropertyDescriptor(Element.prototype,"ariaHidden"))shaka.log.info("Using native ARIAMixin interface.");else{shaka.log.info("ARIAMixin interface not detected. Installing polyfill.");for(var a=(0,$jscomp.makeIterator)(["ariaHidden","ariaLabel","ariaPressed","ariaSelected"]),b=a.next();!b.done;b=a.next())shaka.polyfill.Aria.addARIAMixinAttribute_(b.value)}};
shaka.polyfill.Aria.addARIAMixinAttribute_=function(a){var b="aria-"+a.toLowerCase().replace(/^aria/,"");Object.defineProperty(Element.prototype,a,{get:function(){return this.getAttribute(b)},set:function(c){c==null||c==void 0?this.removeAttribute(b):this.setAttribute(b,c)}})};goog.exportProperty(shaka.polyfill,"Aria",shaka.polyfill.Aria);goog.exportProperty(shaka.polyfill.Aria,"install",shaka.polyfill.Aria.install);shaka.polyfill.register(shaka.polyfill.Aria.install);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){var b=shaka.drm.DrmUtils;if(b.isFairPlayKeySystem(a))return"cbcs";if(b.isWidevineKeySystem(a)||b.isPlayReadyKeySystem(a)||b.isClearKeySystem(a)||b.isWisePlayKeySystem(a))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.getNextAddressJsc()==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.getYieldResultJsc();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.getNextAddressJsc()==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.getYieldResultJsc();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.Fullscreen=function(){};
shaka.polyfill.Fullscreen.install=function(){if(window.Document){var a=Element.prototype;a.requestFullscreen=a.requestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullscreen;a=Document.prototype;a.exitFullscreen=a.exitFullscreen||a.mozCancelFullScreen||a.webkitCancelFullScreen;"fullscreenElement"in document||(Object.defineProperty(document,"fullscreenElement",{get:function(){return document.mozFullScreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement}}),Object.defineProperty(document,
"fullscreenEnabled",{get:function(){return document.mozFullScreenEnabled||document.webkitFullscreenEnabled}}));a=shaka.polyfill.Fullscreen.proxyEvent_;document.addEventListener("webkitfullscreenchange",a);document.addEventListener("webkitfullscreenerror",a);document.addEventListener("mozfullscreenchange",a);document.addEventListener("mozfullscreenerror",a)}};
shaka.polyfill.Fullscreen.proxyEvent_=function(a){var b=a.type.replace(/^(webkit|moz)/,"").toLowerCase(),c=document.createEvent("Event");c.initEvent(b,a.bubbles,a.cancelable);a.target.dispatchEvent(c)};goog.exportProperty(shaka.polyfill,"Fullscreen",shaka.polyfill.Fullscreen);goog.exportProperty(shaka.polyfill.Fullscreen,"install",shaka.polyfill.Fullscreen.install);shaka.polyfill.register(shaka.polyfill.Fullscreen.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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc(),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.getNextAddressJsc()){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.getYieldResultJsc();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.getYieldResultJsc();case 3:return l.return(k)}})};
shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_=function(a){var b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return b=shaka.polyfill.MCapEncryptionScheme.convertToMediaKeySystemConfig_(a),d.yield(navigator.requestMediaKeySystemAccess(a.keySystemConfiguration.keySystem,[b]),2);c=d.getYieldResultJsc();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.getNextAddressJsc()){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.getYieldResultJsc(),!l)return q.return(b);case 3:if(!e){q.jumpTo(2);break}return q.yield(shaka.polyfill.MediaCapabilities.checkAudioSupport_(e),6);case 6:if(m=q.getYieldResultJsc(),!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),8);case 8:if(p=q.getYieldResultJsc())b.supported=!0,b.keySystemAccess=p;case 7:return q.return(b)}})};
shaka.polyfill.MediaCapabilities.checkVideoSupport_=function(a){var b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.getNextAddressJsc()==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.getNextAddressJsc()!=2?(d=e.getYieldResultJsc(),e.return(d)):e.return(shaka.media.Capabilities.isTypeSupported(a.contentType))})};
shaka.polyfill.MediaCapabilities.checkAudioSupport_=function(a){var b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.getNextAddressJsc()){case 1:b=shaka.device.DeviceFactory.getDevice();c=b.getDeviceType();d=a.contentType;if(c!==shaka.device.IDevice.DeviceType.CAST||!a.spatialRendering){g.jumpTo(2);break}d+="; spatialRendering=true";if(!(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType)){g.jumpTo(2);break}e=!1;f=shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_;
if(f.has(d)){e=f.get(d);g.jumpTo(4);break}return g.yield(cast.__platform__.canDisplayType(d),5);case 5:e=g.getYieldResultJsc(),f.set(d,e);case 4:return g.return(e);case 2:return g.return(shaka.media.Capabilities.isTypeSupported(d))}})};
shaka.polyfill.MediaCapabilities.checkDrmSupport_=function(a,b,c){var d,e,f,g,h,k,l,m,n,p,q,r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.getNextAddressJsc()){case 1:d=shaka.util.MimeUtils;e=[];f=[];g=[];c.audio&&(h={robustness:c.audio.robustness||"",contentType:b.contentType},shaka.device.DeviceFactory.getDevice().misreportAC3UsingDrm()&&b.contentType.includes('codecs="ac-3"')&&(h.contentType='audio/mp4; codecs="ec-3"'),c.audio.encryptionScheme&&(h.encryptionScheme=
c.audio.encryptionScheme,g.push(c.audio.encryptionScheme)),e.push(h));c.video&&(k={robustness:c.video.robustness||"",contentType:a.contentType},c.video.encryptionScheme&&(k.encryptionScheme=c.video.encryptionScheme,g.push(c.video.encryptionScheme)),f.push(k));l={initDataTypes:[c.initDataType],distinctiveIdentifier:c.distinctiveIdentifier,persistentState:c.persistentState,sessionTypes:c.sessionTypes};e.length&&(l.audioCapabilities=e);f.length&&(l.videoCapabilities=f);m=a?a.contentType:"";n=b?b.contentType:
"";p=d.getBasicType(m)+";"+d.getCodecBase(m);q=d.getBasicType(n)+";"+d.getCodecBase(n);r=c.keySystem;t=null;u.setCatchFinallyBlocks(2);if(shaka.drm.DrmUtils.hasMediaKeySystemAccess(p,q,r,g)){t=shaka.drm.DrmUtils.getMediaKeySystemAccess(p,q,r,g);u.jumpTo(4);break}return u.yield(navigator.requestMediaKeySystemAccess(c.keySystem,[l]),5);case 5:t=u.getYieldResultJsc(),shaka.drm.DrmUtils.setMediaKeySystemAccess(p,q,r,g,t);case 4:u.leaveTryBlock(3);break;case 2:u.enterCatchBlock(),shaka.log.info("navigator.requestMediaKeySystemAccess failed.");
case 3:return u.return(t)}})};
shaka.polyfill.MediaCapabilities.canCastDisplayType_=function(a){var b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==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.getNextAddressJsc()!=2&&(e=
g.getYieldResultJsc(),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.Orientation=function(){};shaka.polyfill.Orientation.install=function(){screen.orientation&&screen.orientation.unlock?shaka.log.info("Using native screen.orientation"):screen.orientation!=void 0?shaka.polyfill.Orientation.installBasedOnScreenMethods_():window.orientation!=void 0&&shaka.polyfill.Orientation.installBasedOnWindowMethods_()};
shaka.polyfill.Orientation.installBasedOnScreenMethods_=function(){screen.orientation.lock===void 0&&(screen.orientation.lock=function(a){shaka.log.info("screen.orientation.lock is a no-op");return Promise.resolve()});screen.orientation.unlock===void 0&&(screen.orientation.unlock=function(){shaka.log.info("screen.orientation.unlock is a no-op")})};
shaka.polyfill.Orientation.installBasedOnWindowMethods_=function(){var a=new shaka.polyfill.Orientation.FakeOrientation;screen.orientation=a;var b=function(){switch(window.orientation){case -90:a.type="landscape-secondary";a.angle=270;break;case 0:a.type="portrait-primary";a.angle=0;break;case 90:a.type="landscape-primary";a.angle=90;break;case 180:a.type="portrait-secondary",a.angle=180}};b();window.addEventListener("orientationchange",function(){b();a.dispatchChangeEvent()})};
goog.exportProperty(shaka.polyfill,"Orientation",shaka.polyfill.Orientation);goog.exportProperty(shaka.polyfill.Orientation,"install",shaka.polyfill.Orientation.install);shaka.polyfill.Orientation.FakeOrientation=function(){shaka.util.FakeEventTarget.call(this);this.type="";this.angle=0};$jscomp.inherits(shaka.polyfill.Orientation.FakeOrientation,shaka.util.FakeEventTarget);
shaka.polyfill.Orientation.FakeOrientation.prototype.dispatchChangeEvent=function(){var a=new shaka.util.FakeEvent("change");this.dispatchEvent(a)};
shaka.polyfill.Orientation.FakeOrientation.prototype.lock=function(a){var b=function(d){return screen.lockOrientation?screen.lockOrientation(d):screen.mozLockOrientation?screen.mozLockOrientation(d):!1},c=!1;switch(a){case "natural":c=b("default");break;case "any":c=!0;this.unlock();break;default:c=b(a)}if(c)return Promise.resolve();a=Error("screen.orientation.lock() is not available on this device");a.name="NotSupportedError";a.code=DOMException.NOT_SUPPORTED_ERR;return Promise.reject(a)};
shaka.polyfill.Orientation.FakeOrientation.prototype.unlock=function(){screen.unlockOrientation?screen.unlockOrientation():screen.mozUnlockOrientation&&screen.mozUnlockOrientation()};shaka.polyfill.register(shaka.polyfill.Orientation.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.PiPWebkit=function(){};
shaka.polyfill.PiPWebkit.install=function(){if(window.HTMLVideoElement){var a=HTMLVideoElement.prototype;if((!a.requestPictureInPicture||!document.exitPictureInPicture)&&a.webkitSupportsPresentationMode){var b=shaka.polyfill.PiPWebkit;shaka.log.debug("PiPWebkit.install");document.pictureInPictureEnabled=!0;document.pictureInPictureElement=null;a.requestPictureInPicture=b.requestPictureInPicture_;Object.defineProperty(a,"disablePictureInPicture",{get:b.getDisablePictureInPicture_,set:b.setDisablePictureInPicture_,
enumerable:!0,configurable:!0});document.exitPictureInPicture=b.exitPictureInPicture_;document.addEventListener("webkitpresentationmodechanged",b.proxyEvent_,!0)}}};
shaka.polyfill.PiPWebkit.proxyEvent_=function(a){a=a.target;if(a.webkitPresentationMode==shaka.polyfill.PiPWebkit.PIP_MODE_){document.pictureInPictureElement=a;var b=new Event("enterpictureinpicture");a.dispatchEvent(b)}else document.pictureInPictureElement==a&&(document.pictureInPictureElement=null),b=new Event("leavepictureinpicture"),a.dispatchEvent(b)};
shaka.polyfill.PiPWebkit.requestPictureInPicture_=function(){var a=shaka.polyfill.PiPWebkit;return this.webkitSupportsPresentationMode(a.PIP_MODE_)?(this.webkitSetPresentationMode(a.PIP_MODE_),document.pictureInPictureElement=this,Promise.resolve()):Promise.reject(Error("PiP not allowed by video element"))};
shaka.polyfill.PiPWebkit.exitPictureInPicture_=function(){var a=shaka.polyfill.PiPWebkit,b=document.pictureInPictureElement;return b?(b.webkitSetPresentationMode(a.INLINE_MODE_),document.pictureInPictureElement=null,Promise.resolve()):Promise.reject(Error("No picture in picture element found"))};shaka.polyfill.PiPWebkit.getDisablePictureInPicture_=function(){return this.hasAttribute("disablePictureInPicture")?!0:!this.webkitSupportsPresentationMode(shaka.polyfill.PiPWebkit.PIP_MODE_)};
shaka.polyfill.PiPWebkit.setDisablePictureInPicture_=function(a){a?this.setAttribute("disablePictureInPicture",""):this.removeAttribute("disablePictureInPicture")};goog.exportProperty(shaka.polyfill,"PiPWebkit",shaka.polyfill.PiPWebkit);goog.exportProperty(shaka.polyfill.PiPWebkit,"install",shaka.polyfill.PiPWebkit.install);shaka.polyfill.PiPWebkit.PIP_MODE_="picture-in-picture";shaka.polyfill.PiPWebkit.INLINE_MODE_="inline";shaka.polyfill.register(shaka.polyfill.PiPWebkit.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;var c=void 0;(c=b.prototype).indexOf!=null||(c.indexOf=Array.prototype.indexOf);c=void 0;(c=b.prototype).lastIndexOf!=null||(c.lastIndexOf=Array.prototype.lastIndexOf);c=void 0;(c=b.prototype).includes!=null||(c.includes=Array.prototype.includes)}};
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.queue={};shaka.queue.QueueManager=function(a){shaka.util.FakeEventTarget.call(this);this.player_=a;this.config_=null;this.items_=[];this.currentItemIndex_=-1;this.preloadPrev_=this.preloadNext_=null;this.eventManager_=new shaka.util.EventManager};$jscomp.inherits(shaka.queue.QueueManager,shaka.util.FakeEventTarget);
shaka.queue.QueueManager.prototype.destroy=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1)return b.yield(a.removeAllItems(),2);a.player_=null;a.eventManager_&&(a.eventManager_.release(),a.eventManager_=null);shaka.util.FakeEventTarget.prototype.release.call(a);b.jumpToEnd()})};shaka.queue.QueueManager.prototype.configure=function(a){this.config_=a};shaka.queue.QueueManager.prototype.getConfiguration=function(){return this.config_};
shaka.queue.QueueManager.prototype.getCurrentItem=function(){return this.items_.length&&this.currentItemIndex_>=0&&this.currentItemIndex_<this.items_.length?this.items_[this.currentItemIndex_]:null};shaka.queue.QueueManager.prototype.getCurrentItemIndex=function(){return this.currentItemIndex_};shaka.queue.QueueManager.prototype.getItems=function(){return this.items_.slice()};
shaka.queue.QueueManager.prototype.insertItems=function(a){this.items_.push.apply(this.items_,(0,$jscomp.arrayFromIterable)(a));this.dispatchEvent(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.ItemsInserted))};
shaka.queue.QueueManager.prototype.removeAllItems=function(){var a=this,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return a.eventManager_.removeAll(),a.items_.length&&a.currentItemIndex_>=0?f.yield(a.player_.unload(),2):f.jumpTo(2);if(f.getNextAddressJsc()!=4){b=[];a.preloadPrev_&&(a.preloadPrev_.preloadManager.isDestroyed()||b.push(a.preloadPrev_.preloadManager.destroy()),a.preloadPrev_=null);a.preloadNext_&&(a.preloadNext_.preloadManager.isDestroyed()||
b.push(a.preloadNext_.preloadManager.destroy()),a.preloadNext_=null);c=(0,$jscomp.makeIterator)(a.items_);for(d=c.next();!d.done;d=c.next())e=d.value,e.preloadManager&&!e.preloadManager.isDestroyed()&&b.push(e.preloadManager.destroy());return b.length?f.yield(Promise.all(b),4):f.jumpTo(4)}a.items_=[];a.currentItemIndex_=-1;a.dispatchEvent(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.ItemsRemoved));f.jumpToEnd()})};
shaka.queue.QueueManager.prototype.playItem=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){case 1:goog.asserts.assert(b.player_,"We should have player");b.eventManager_.removeAll();if(!b.items_.length||a>=b.items_.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.QUEUE_INDEX_OUT_OF_BOUNDS);c=b.getCurrentItem();d=b.items_[a];
b.currentItemIndex_!=a&&(b.currentItemIndex_=a,b.dispatchEvent(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.CurrentItemChanged)));e=b.player_.getMediaElement();f=b.config_?b.config_.preloadNextUrlWindow:0;f>0&&(g=!1,b.eventManager_.listen(e,"timeupdate",function(){var y,A,B,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.getNextAddressJsc()){case 1:if(b.preloadNext_||b.items_.length<=1||g||b.player_.isLive()||!e.duration)return z.return();y=b.player_.seekRange().end-
e.currentTime;if(isNaN(y)){z.jumpTo(0);break}if(!(y<=f)){z.jumpTo(0);break}A=b.config_&&b.config_.repeatMode;B=null;b.currentItemIndex_+1<b.items_.length?B=b.items_[b.currentItemIndex_+1]:A==shaka.config.RepeatMode.ALL&&(B=b.items_[0]);if(!B||B.preloadManager&&!B.preloadManager.isDestroyed()){z.jumpTo(0);break}g=!0;D=null;z.setCatchFinallyBlocks(5);return z.yield(b.player_.preload(B.manifestUri,B.startTime,B.mimeType,B.config),7);case 7:D=z.getYieldResultJsc();z.leaveTryBlock(6);break;case 5:z.enterCatchBlock(),
D=null;case 6:b.preloadNext_={item:B,preloadManager:D},g=!1,z.jumpToEnd()}})}));b.eventManager_.listen(b.player_,"complete",function(){var y=b.config_&&b.config_.repeatMode,A=!1;if(y==shaka.config.RepeatMode.SINGLE)A=!0;else{var B=b.currentItemIndex_+1;B<b.items_.length?b.playItem(B):y==shaka.config.RepeatMode.ALL&&(b.items_.length==1?A=!0:b.playItem(0))}A&&(e.paused?(e.currentTime=b.player_.seekRange().start,e.play()):b.eventManager_.listen(e,"paused",function(){e.currentTime=b.player_.seekRange().start;
e.play()}))});h=d.manifestUri;d.preloadManager&&!d.preloadManager.isDestroyed()&&(h=d.preloadManager);k=!1;b.preloadNext_&&b.preloadNext_.item==d&&b.preloadNext_.preloadManager?h=b.preloadNext_.preloadManager:b.preloadPrev_&&b.preloadPrev_.item==d&&b.preloadPrev_.preloadManager&&(h=b.preloadPrev_.preloadManager,k=!0);if(!b.preloadPrev_){x.jumpTo(2);break}if(k||b.preloadPrev_.preloadManager.isDestroyed()){x.jumpTo(3);break}return x.yield(b.preloadPrev_.preloadManager.destroy(),3);case 3:b.preloadPrev_=
null;case 2:if(!(b.config_&&b.config_.preloadPrevItem&&c&&b.player_.getLoadMode()===shaka.Player.LoadMode.MEDIA_SOURCE)){x.jumpTo(5);break}l=null;x.setCatchFinallyBlocks(6);return x.yield(b.player_.unloadAndSavePreload(),8);case 8:l=x.getYieldResultJsc();x.leaveTryBlock(7);break;case 6:x.enterCatchBlock(),l=null;case 7:b.preloadPrev_={item:c,preloadManager:l};case 5:return d.config&&(b.player_.resetConfiguration(),b.player_.configure(d.config)),x.yield(b.player_.load(h,d.startTime,d.mimeType),9);
case 9:b.preloadNext_=null;if(d.extraText)for(m=(0,$jscomp.makeIterator)(d.extraText),n=m.next();!n.done;n=m.next())p=n.value,p.mime?b.player_.addTextTrackAsync(p.uri,p.language,p.kind,p.mime,p.codecs):b.player_.addTextTrackAsync(p.uri,p.language,p.kind);if(d.extraThumbnail)for(q=(0,$jscomp.makeIterator)(d.extraThumbnail),r=q.next();!r.done;r=q.next())t=r.value,b.player_.addThumbnailsTrack(t);if(d.extraChapter)for(u=(0,$jscomp.makeIterator)(d.extraChapter),w=u.next();!w.done;w=u.next())v=w.value,
b.player_.addChaptersTrack(v.uri,v.language,v.mime);x.jumpToEnd()}})};goog.exportSymbol("shaka.queue.QueueManager",shaka.queue.QueueManager);goog.exportProperty(shaka.queue.QueueManager.prototype,"playItem",shaka.queue.QueueManager.prototype.playItem);goog.exportProperty(shaka.queue.QueueManager.prototype,"removeAllItems",shaka.queue.QueueManager.prototype.removeAllItems);goog.exportProperty(shaka.queue.QueueManager.prototype,"insertItems",shaka.queue.QueueManager.prototype.insertItems);
goog.exportProperty(shaka.queue.QueueManager.prototype,"getItems",shaka.queue.QueueManager.prototype.getItems);goog.exportProperty(shaka.queue.QueueManager.prototype,"getCurrentItemIndex",shaka.queue.QueueManager.prototype.getCurrentItemIndex);goog.exportProperty(shaka.queue.QueueManager.prototype,"getCurrentItem",shaka.queue.QueueManager.prototype.getCurrentItem);goog.exportProperty(shaka.queue.QueueManager.prototype,"getConfiguration",shaka.queue.QueueManager.prototype.getConfiguration);
goog.exportProperty(shaka.queue.QueueManager.prototype,"configure",shaka.queue.QueueManager.prototype.configure);goog.exportProperty(shaka.queue.QueueManager.prototype,"destroy",shaka.queue.QueueManager.prototype.destroy);shaka.Player.setQueueManagerFactory(function(a){return new shaka.queue.QueueManager(a)});shaka.text.LrcTextParser=function(){};shaka.text.LrcTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"LRC does not have init segments")};shaka.text.LrcTextParser.prototype.setSequenceMode=function(a){};shaka.text.LrcTextParser.prototype.setManifestType=function(a){};
shaka.text.LrcTextParser.prototype.parseMedia=function(a,b){var c=shaka.text.LrcTextParser,d=null,e=[];a=shaka.util.StringUtils.fromUTF8(a).split(/\r?\n/);a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next()){var g=f.value;g&&!/^\s+$/.test(g)&&((f=c.lyricLine_.exec(g))?(g=c.parseTime_(f[1]),f=new shaka.text.Cue(g,b.segmentEnd?b.segmentEnd:g+2,f[2]),d&&(d.endTime=g,e.push(d)),d=f):shaka.log.warning("LrcTextParser encountered an unknown line.",g))}d&&e.push(d);return e};
shaka.text.LrcTextParser.parseTime_=function(a){var b=shaka.text.LrcTextParser.timeFormat_.exec(a);a=parseInt(b[1],10);b=parseFloat(b[2].replace(",","."));return a*60+b};goog.exportSymbol("shaka.text.LrcTextParser",shaka.text.LrcTextParser);goog.exportProperty(shaka.text.LrcTextParser.prototype,"parseMedia",shaka.text.LrcTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.LrcTextParser.prototype,"setManifestType",shaka.text.LrcTextParser.prototype.setManifestType);
goog.exportProperty(shaka.text.LrcTextParser.prototype,"setSequenceMode",shaka.text.LrcTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.LrcTextParser.prototype,"parseInit",shaka.text.LrcTextParser.prototype.parseInit);shaka.text.LrcTextParser.lyricLine_=/^\[(\d{1,2}:\d{1,2}(?:[.,]\d{1,3})?)\](.*)/;shaka.text.LrcTextParser.timeFormat_=/^(\d+):(\d{1,2}(?:[.,]\d{1,3})?)$/;shaka.text.TextEngine.registerParser("application/x-subtitle-lrc",function(){return new shaka.text.LrcTextParser});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(u){return u!="\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 u={tagName:"span",children:[q.getTextContents(a)],attributes:{},parent:null}}else u=a;goog.asserts.assert(u,"cueElement should be non-null!");for(var w=null,v=(0,$jscomp.makeIterator)(shaka.text.TtmlTextParser.smpteNsList_),x=v.next();!x.done&&!(w=this.getElementsFromCollection_(u,"backgroundImage",d,"#",x.value)[0]);x=v.next());
v=null;x=q.getAttributeNSList(u,shaka.text.TtmlTextParser.smpteNsList_,"backgroundImage");var y=/^(urn:)(mpeg:[a-z0-9][a-z0-9-]{0,31}:)(subs:)([0-9]+)$/;if(x&&y.test(x)){v=parseInt(x.split(":").pop(),10)-1;if(v>=p.length)return null;v=p[v]}else n&&x&&!x.startsWith("#")&&(y=new goog.Uri(n),x=new goog.Uri(x),(x=y.resolve(x).toString())&&(v=x));if(a.tagName=="p"||w||v)m=!0;a=m;x=(u.attributes["xml:space"]||(h?"default":"preserve"))=="default";y=u.children.every(q.isText);h=[];if(!y)for(var A=(0,$jscomp.makeIterator)(u.children),
B=A.next();!B.done;B=A.next())(B=this.parseCue_(B.value,b,c,d,e,f,g,x,k,u,m,n,p))&&h.push(B);d=l!=null;n=q.getTextContents(u);n=u.children.length&&n&&/\S/.test(n);A=u.attributes.begin||u.attributes.end||u.attributes.dur;if(!(A||n||u.tagName=="br"||h.length!=0||d&&!x))return null;p=this.parseTime_(u,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(!A&&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(u.tagName=="br")return e=new shaka.text.Cue(n,p,""),e.lineBreak=!0,e;b="";y&&(b=r.htmlUnescape(shaka.util.TXml.getTextContents(u)||""),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_(u,"region",f,"")[0];if(u.attributes.region&&k&&k.attributes["xml:id"]){var D=k.attributes["xml:id"];r.region=g.filter(function(z){return z.id==D})[0]}g=k;l&&d&&!u.attributes.region&&!u.attributes.style&&(g=this.getElementsFromCollection_(l,"region",f,"")[0]);this.addStyle_(r,u,g,w,v,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).set("start",shaka.text.Cue.positionAlign.LEFT).set("end",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).boxes(["moov","trak","mdia","minf","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).boxes(["moof","traf"],d.children).fullBox("tfhd",function(w){goog.asserts.assert(w.flags!=null,"A TFHD box should have a valid flags value");f=shaka.util.Mp4BoxParsers.parseTFHD(w.reader,w.flags).defaultSampleSize}).fullBox("trun",function(w){goog.asserts.assert(w.version!=null,"A TRUN box should have a valid version value");goog.asserts.assert(w.flags!=null,"A TRUN box should have a valid flags value");
w=shaka.util.Mp4BoxParsers.parseTRUN(w.reader,w.version,w.flags);w=(0,$jscomp.makeIterator)(w.sampleData);for(var v=w.next();!v.done;v=w.next())k.push(v.value.sampleSize||f||0)}).fullBox("subs",function(w){for(var v=w.reader,x=v.readUint32(),y=-1,A=0;A<x;A++){var B=v.readUint32();y+=B;B=v.readUint16();for(var D=[],z=0;z<B;z++)w.version==1?D.push(v.readUint32()):D.push(v.readUint16()),v.readUint8(),v.readUint8(),v.readUint32();h.set(y,D)}}).box("mdat",d.allData(function(w){g.push(w)},!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);a=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(g));for(var l=d=0;l<k.length;l++){var m=shaka.util.BufferUtils.toUint8(a,d,k[l]);d+=k[l];var n=h.get(l);if(n&&n.length){for(var p=shaka.util.BufferUtils.toUint8(m,0,n[0]),q=[],r=n[0],t=1;t<n.length;t++){var u=shaka.util.BufferUtils.toUint8(m,r,n[t]);
u=shaka.util.Uint8ArrayUtils.toStandardBase64(u);q.push("data:image/png;base64,"+u);r+=n[t]}e=e.concat(this.parser_.parseMedia(p,b,c,q))}else e=e.concat(this.parser_.parseMedia(m,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=[];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])&&!shaka.text.VttTextParser.REGEX_NOTE_.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]||shaka.text.VttTextParser.REGEX_NOTE_.test(a[0])||a[0]=="STYLE"||a[0]=="REGION")return null;var f=null,g=0;a[0].includes("--\x3e")||(f=a[0],g=1);var h=new shaka.util.TextParser(a[g]),k=h.parseTime(),l=h.readRegex(/[ \t]+--\x3e[ \t]+/g),m=h.parseTime();if(k==null||l==null||m==null)return shaka.log.alwaysWarn("Failed to parse VTT time code. Cue skipped:",f,a),null;k+=b;m+=b;k<0&&(k=0);b="";for(l=
g+1;l<a.length;l++)l>g+1&&(b+="\n"),b+=a[l];b=b.trim();d.has("global")?(a=d.get("global").clone(),a.startTime=k,a.endTime=m,a.payload=b):a=new shaka.text.Cue(k,m,b);h.skipWhitespace();for(k=h.readWord();k;)e.parseCueSetting(a,k,c)||shaka.log.warning("VTT parser encountered an invalid VTT setting: ",k," The setting will be ignored."),h.skipWhitespace(),k=h.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=d.REGEX_ALIGN_.exec(b))d.setTextAlign_(a,e[1]);else if(e=d.REGEX_VERTICAL_.exec(b))d.setVerticalWritingMode_(a,e[1]);else if(e=d.REGEX_SIZE_.exec(b))a.size=Number(e[1]);else if(e=d.REGEX_POSITION_.exec(b))a.position=Number(e[1]),e[2]&&d.setPositionAlign_(a,e[2]);else if(e=d.REGEX_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=shaka.text.VttTextParser.REGEX_LINE_PCT_.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=shaka.text.VttTextParser.REGEX_LINE_NUM_.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.VttTextParser.REGEX_NOTE_=/^NOTE($|[ \t])/;shaka.text.VttTextParser.REGEX_ALIGN_=/^align:(start|middle|center|end|left|right)$/;
shaka.text.VttTextParser.REGEX_VERTICAL_=/^vertical:(lr|rl)$/;shaka.text.VttTextParser.REGEX_SIZE_=/^size:([\d.]+)%$/;shaka.text.VttTextParser.REGEX_POSITION_=/^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/;shaka.text.VttTextParser.REGEX_REGION_=/^region:(.*)$/;shaka.text.VttTextParser.REGEX_LINE_PCT_=/^line:([\d.]+)%(?:,(start|end|center))?$/;shaka.text.VttTextParser.REGEX_LINE_NUM_=/^line:(-?\d+)(?:,(start|end|center))?$/;
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).boxes(["moov","trak","mdia","minf","stbl"],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}).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).boxes(["moof","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 u=c.readUint32();t+=u;var w=c.readUint32();w=shaka.util.Mp4Parser.typeToString(w);var v=null;w=="vttc"?u>8&&(v=c.readBytes(u-8,!1)):(w!="vtte"&&shaka.log.error("Unknown box "+w+"! Skipping!"),c.skip(u-8));q?v&&(goog.asserts.assert(this.timescale_!=null,"Timescale should not be null!"),u=shaka.text.Mp4VttParser.parseVTTC_(v,b.periodStart+r/this.timescale_,b.periodStart+a/this.timescale_),g.push(u)):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.text.SbvTextParser=function(){};shaka.text.SbvTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"SubViewer does not have init segments")};shaka.text.SbvTextParser.prototype.setSequenceMode=function(a){};shaka.text.SbvTextParser.prototype.setManifestType=function(a){};
shaka.text.SbvTextParser.prototype.parseMedia=function(a,b){b=shaka.util.StringUtils.fromUTF8(a).replace(/\r+/g,"");b=b.trim();a=[];if(b=="")return a;b=b.split("\n\n");b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next()){var d=c.value.split("\n"),e=new shaka.util.TextParser(d[0]);c=e.parseTime();var f=e.readRegex(/,/g);e=e.parseTime();if(c==null||f==null||e==null)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 SubViewer");d=d.slice(1).join("\n").trim();c=new shaka.text.Cue(c,e,d);a.push(c)}return a};goog.exportSymbol("shaka.text.SbvTextParser",shaka.text.SbvTextParser);goog.exportProperty(shaka.text.SbvTextParser.prototype,"parseMedia",shaka.text.SbvTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.SbvTextParser.prototype,"setManifestType",shaka.text.SbvTextParser.prototype.setManifestType);
goog.exportProperty(shaka.text.SbvTextParser.prototype,"setSequenceMode",shaka.text.SbvTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.SbvTextParser.prototype,"parseInit",shaka.text.SbvTextParser.prototype.parseInit);shaka.text.TextEngine.registerParser("text/x-subviewer",function(){return new shaka.text.SbvTextParser});shaka.text.SrtTextParser=function(){this.parser_=new shaka.text.VttTextParser};shaka.text.SrtTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"SRT does not have init segments")};shaka.text.SrtTextParser.prototype.setSequenceMode=function(a){};shaka.text.SrtTextParser.prototype.setManifestType=function(a){};
shaka.text.SrtTextParser.prototype.parseMedia=function(a,b,c){var d=shaka.util.BufferUtils,e=shaka.util.StringUtils;a=e.fromUTF8(a);a=this.srt2webvtt_(a);d=d.toUint8(e.toUTF8(a));return this.parser_.parseMedia(d,b,c,[])};shaka.text.SrtTextParser.prototype.srt2webvtt_=function(a){var b="WEBVTT\n\n";if(a=="")return b;a=a.replace(/\r+/g,"");a=a.trim();a=a.split("\n\n");a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())b+=this.convertSrtCue_(c.value);return b};
shaka.text.SrtTextParser.prototype.convertSrtCue_=function(a){a=a.split(/\n/);a[0].match(/\d+/)&&a.shift();a[0]=a[0].replace(/,/g,".");return a.join("\n").replace(/{b}/g,"<b>").replace(/{\/b}/g,"</b>").replace(/{i}/g,"<i>").replace(/{\/i}/g,"</i>").replace(/{u}/g,"<u>").replace(/{\/u}/g,"</u>")+"\n\n"};goog.exportSymbol("shaka.text.SrtTextParser",shaka.text.SrtTextParser);goog.exportProperty(shaka.text.SrtTextParser.prototype,"parseMedia",shaka.text.SrtTextParser.prototype.parseMedia);
goog.exportProperty(shaka.text.SrtTextParser.prototype,"setManifestType",shaka.text.SrtTextParser.prototype.setManifestType);goog.exportProperty(shaka.text.SrtTextParser.prototype,"setSequenceMode",shaka.text.SrtTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.SrtTextParser.prototype,"parseInit",shaka.text.SrtTextParser.prototype.parseInit);shaka.text.TextEngine.registerParser("text/srt",function(){return new shaka.text.SrtTextParser});shaka.text.SsaTextParser=function(){};shaka.text.SsaTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"SSA does not have init segments")};shaka.text.SsaTextParser.prototype.setSequenceMode=function(a){};shaka.text.SsaTextParser.prototype.setManifestType=function(a){};
shaka.text.SsaTextParser.prototype.parseMedia=function(a,b){b=shaka.text.SsaTextParser;var c="",d="",e=null,f=null;f=shaka.util.StringUtils.fromUTF8(a).split(/\r?\n\s*\r?\n/);a=(0,$jscomp.makeIterator)(f);for(f=a.next();!f.done;f=a.next()){var g=f.value;f=g;if(g=b.ssaContent_.exec(g))e=g[1],f=g[2];e=="V4 Styles"||e=="V4+ Styles"?(c=f,c=d?c+("\n"+f):f):e=="Events"?d=d?d+("\n"+f):f:e!="Script Info"&&shaka.log.warning("SsaTextParser parser encountered an unknown part.",f)}e=[];f=null;c=c.split(/\r?\n/);
c=(0,$jscomp.makeIterator)(c);for(a=c.next();!a.done;a=c.next())if(a=a.value,!/^\s*;/.test(a)&&(g=b.lineParts_.exec(a)))if(a=g[1].trim(),g=g[2].trim(),a=="Format")f=g.split(b.valuesFormat_);else if(a=="Style"){a=g.split(b.valuesFormat_);g={};for(var h=0;h<f.length&&h<a.length;h++)g[f[h]]=a[h];e.push(g)}f=[];c=null;d=d.split(/\r?\n/);d=(0,$jscomp.makeIterator)(d);g=d.next();for(a={};!g.done;a={styleName:void 0},g=d.next())if(g=g.value,!/^\s*;/.test(g)&&(h=b.lineParts_.exec(g)))if(g=h[1].trim(),h=h[2].trim(),
g=="Format")c=h.split(b.valuesFormat_);else if(g=="Dialogue"){h=h.split(b.valuesFormat_);g={};for(var k=0;k<c.length&&k<h.length;k++)g[c[k]]=h[k];k=b.parseTime_(g.Start);var l=b.parseTime_(g.End);h=h.slice(c.length-1).join(",").replace(/\\N/g,"\n").replace(/\{[^}]+\}/g,"");h=new shaka.text.Cue(k,l,h);a.styleName=g.Style;(a=e.find(function(m){return function(n){return n.Name==m.styleName}}(a)))&&b.addStyle_(h,a);f.push(h)}return f};
shaka.text.SsaTextParser.addStyle_=function(a,b){var c=shaka.text.Cue,d=shaka.text.SsaTextParser,e=b.Fontname;e&&(a.fontFamily=e);if(e=b.Fontsize)a.fontSize=e+"px";if(e=b.PrimaryColour)if(e=d.parseSsaColor_(e))a.color=e;if(e=b.BackColour)if(d=d.parseSsaColor_(e))a.backgroundColor=d;b.Bold&&(a.fontWeight=c.fontWeight.BOLD);b.Italic&&(a.fontStyle=c.fontStyle.ITALIC);b.Underline&&a.textDecoration.push(c.textDecoration.UNDERLINE);if(d=b.Spacing)a.letterSpacing=d+"px";if(d=b.Alignment)switch(parseInt(d,
10)){case 1:a.displayAlign=c.displayAlign.AFTER;a.textAlign=c.textAlign.START;break;case 2:a.displayAlign=c.displayAlign.AFTER;a.textAlign=c.textAlign.CENTER;break;case 3:a.displayAlign=c.displayAlign.AFTER;a.textAlign=c.textAlign.END;break;case 5:a.displayAlign=c.displayAlign.BEFORE;a.textAlign=c.textAlign.START;break;case 6:a.displayAlign=c.displayAlign.BEFORE;a.textAlign=c.textAlign.CENTER;break;case 7:a.displayAlign=c.displayAlign.BEFORE;a.textAlign=c.textAlign.END;break;case 9:a.displayAlign=
c.displayAlign.CENTER;a.textAlign=c.textAlign.START;break;case 10:a.displayAlign=c.displayAlign.CENTER;a.textAlign=c.textAlign.CENTER;break;case 11:a.displayAlign=c.displayAlign.CENTER,a.textAlign=c.textAlign.END}if(b=b.AlphaLevel)a.opacity=parseFloat(b)};shaka.text.SsaTextParser.parseSsaColor_=function(a){a=parseInt(a.replace("&H",""),16);return a>=0?"rgba("+(a&255)+","+(a>>8&255)+","+(a>>16&255)+","+(a>>24&255^255)/255+")":null};
shaka.text.SsaTextParser.parseTime_=function(a){var b=shaka.text.SsaTextParser.timeFormat_.exec(a);a=b[1]?parseInt(b[1].replace(":",""),10):0;var c=parseInt(b[2],10);b=parseFloat(b[3]);return a*3600+c*60+b};goog.exportSymbol("shaka.text.SsaTextParser",shaka.text.SsaTextParser);goog.exportProperty(shaka.text.SsaTextParser.prototype,"parseMedia",shaka.text.SsaTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.SsaTextParser.prototype,"setManifestType",shaka.text.SsaTextParser.prototype.setManifestType);
goog.exportProperty(shaka.text.SsaTextParser.prototype,"setSequenceMode",shaka.text.SsaTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.SsaTextParser.prototype,"parseInit",shaka.text.SsaTextParser.prototype.parseInit);shaka.text.SsaTextParser.ssaContent_=/^\s*\[([^\]]+)\]\r?\n([\s\S]*)/;shaka.text.SsaTextParser.lineParts_=/^\s*([^:]+):\s*(.*)/;shaka.text.SsaTextParser.valuesFormat_=/\s*,\s*/;shaka.text.SsaTextParser.timeFormat_=/^(\d+:)?(\d{1,2}):(\d{1,2}(?:[.]\d{1,3})?)?$/;
shaka.text.TextEngine.registerParser("text/x-ssa",function(){return new shaka.text.SsaTextParser});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.TransmuxerUtils=function(){};shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0});shaka.transmuxer.TransmuxerUtils.VIDEO_KEYFRAME_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0});shaka.transmuxer.TransmuxerUtils.VIDEO_NON_KEYFRAME_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1,isNonSync:1});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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS})}h+=m}e=g.sampleRate;a=Math.floor(a*e/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:g.codec,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,c){if(b+8>a.length||a[b]!==11||a[b+1]!==119)return!1;var d=a[b+4]>>6;if(d>=3)return!1;var e=a[b+4]&63,f=[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][e*3+d]*2;if(b+f>a.length)return!1;var g=a[b+6]>>5,h=0;g===2?h+=2:(g&1&&g!==1&&(h+=2),g&4&&(h+=2));h=(a[b+6]<<8|a[b+7])>>12-h&1;var k=a[b+5]&7;a=new Uint8Array([d<<6|a[b+5]>>3<<1|k>>2,(k&3)<<6|g<<3|h<<2|e>>4,e<<4&224]);c.sampleRate=[48E3,44100,32E3][d];c.channelCount=[2,1,2,3,3,4,4,5][g]+h;c.audioConfig=a;c.frameLength=f;return!0};
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=[],m={sampleRate:0,channelCount:0,audioConfig:new Uint8Array(0),frameLength:0};g<
a.length;){if(!e.parseFrame(a,g,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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});g+=m.frameLength}e=Math.floor(h*
f/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ac-3",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,c){if(b+8>a.length||!shaka.transmuxer.Ec3.probe(a,b))return!1;var d=new shaka.util.ExpGolomb(a.subarray(b+2));d.skipBits(2);d.skipBits(3);var e=d.readBits(11)+1<<1,f=d.readBits(2);if(f==3){f=d.readBits(2);f=[24E3,22060,16E3][f];var g=3}else f=[48E3,44100,32E3][f],g=d.readBits(2);var h=d.readBits(3),k=d.readBits(1);d=d.readBits(5);if(b+e>a.byteLength)return!1;a=Math.floor(e*f/([1,2,3,6][g]*16));a=new Uint8Array([(a&8160)>>5,(a&31)<<3,f<<6|d<<1|0,0|h<<1|
k<<0,0]);c.sampleRate=f;c.channelCount=[2,1,2,3,3,4,4,5][h]+k;c.audioConfig=a;c.frameLength=e;return!0};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=[],m={sampleRate:0,channelCount:0,audioConfig:new Uint8Array(0),frameLength:0};g<
a.length;){if(!e.parseFrame(a,g,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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});g+=m.frameLength}e=Math.floor(h*
f/1E3);d={id:b.id,type:shaka.util.ManifestParserUtils.ContentType.AUDIO,codecs:"ec-3",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(u){return u.type==b.NALU_TYPE_SPS_});a=a.find(function(u){return u.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;c=c.fullData;l=c.byteLength;a=a.fullData;m=a.byteLength;h=0;k=new Uint8Array(11+l+m);k[h++]=1;k[h++]=
c[1];k[h++]=c[2];k[h++]=c[3];k[h++]=255;k[h++]=225;k[h++]=l>>>8&255;k[h++]=l&255;k.set(c,h);h+=l;k[h++]=1;k[h++]=m>>>8&255;k[h++]=m&255;k.set(a,h);return{height:d,width:g,videoConfig:k,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 u=d.nalus.length*4,w=(0,$jscomp.makeIterator)(d.nalus),v=w.next();!v.done;v=w.next())u+=v.value.fullData.byteLength;u=new Uint8Array(u);w=0;v=(0,$jscomp.makeIterator)(d.nalus);for(var x=v.next();!x.done;x=v.next()){x=x.value;var y=x.fullData.byteLength;u[w]=y>>24&255;u[w+1]=y>>16&255;u[w+2]=y>>8&255;u[w+3]=y&255;u.set(x.fullData,w+4);w+=4+y}d.data=
u;c.push(d)}},g=new Uint8Array(0),h=function(u){d={data:g,frame:!1,isKeyframe:!1,pts:u.pts,dts:u.dts,nalus:[]}},k=0;k<a.length;k++){var l=a[k],m=l.nalus,n=!1;d&&m.length&&!e&&(f(),h(l));m=(0,$jscomp.makeIterator)(l.nalus);for(var p=m.next();!p.done;p=m.next()){p=p.value;var q=!1;switch(p.type){case b.NALU_TYPE_NDR_:var r=!1;q=!0;var t=p.data;n&&t.length>4&&(t=(new shaka.util.ExpGolomb(t)).readSliceType(),t===2||t===4||t===7||t===9)&&(r=!0);r&&d&&d.frame&&!d.isKeyframe&&(f(),d=null);d||h(l);d.frame=
!0;d.isKeyframe=r;break;case b.NALU_TYPE_IDR_:q=!0;d&&d.frame&&!d.isKeyframe&&(f(),d=null);d||h(l);d.frame=!0;d.isKeyframe=!0;break;case b.NALU_TYPE_SEI_:q=!0;break;case b.NALU_TYPE_SPS_:n=q=!0;break;case b.NALU_TYPE_PPS_:q=!0;break;case b.NALU_TYPE_AUD_:e=q=!0;d&&d.frame&&(f(),d=null);d||h(l);break;case b.NALU_TYPE_FILLER_DATA_:q=!0;break;default:q=!1}d&&q&&d.nalus.push(p)}}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(),u=a.readUnsignedByte(),w=a.readUnsignedByte(),v=a.readUnsignedByte(),x=a.readUnsignedByte(),y=[],
A=[],B=0;B<f;B++)y.push(a.readBoolean()),A.push(a.readBoolean());if(f>0)for(B=f;B<8;B++)a.readBits(2);for(B=0;B<f;B++)y[B]&&a.readBits(88),A[B]&&a.readUnsignedByte();a.readUnsignedExpGolomb();y=a.readUnsignedExpGolomb();y==3&&a.readBits(1);A=a.readUnsignedExpGolomb();B=a.readUnsignedExpGolomb();a.readBoolean()&&(b+=a.readUnsignedExpGolomb(),c+=a.readUnsignedExpGolomb(),d+=a.readUnsignedExpGolomb(),e+=a.readUnsignedExpGolomb());var D=a.readUnsignedExpGolomb(),z=a.readUnsignedExpGolomb(),C=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 G=0;G<(E===3?2:6);G++)if(a.readBoolean()){var I=Math.min(64,1<<4+(E<<1));E>1&&a.readExpGolomb();
for(var F=0;F<I;F++)a.readExpGolomb()}else a.readUnsignedExpGolomb();a.readBoolean();a.readBoolean();a.readBoolean()&&(a.readUnsignedByte(),a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),a.readBoolean());E=a.readUnsignedExpGolomb();for(I=G=0;I<E;I++)if(F=!1,I!==0&&(F=a.readBoolean()),F){I===E&&a.readUnsignedExpGolomb();a.readBoolean();a.readUnsignedExpGolomb();for(var J=F=0;J<=G;J++){var K=a.readBoolean(),H=!1;K||(H=a.readBoolean());(K||H)&&F++}G=F}else{J=a.readUnsignedExpGolomb();F=a.readUnsignedExpGolomb();
G=J+F;for(K=0;K<J;K++)a.readUnsignedExpGolomb(),a.readBoolean();for(J=0;J<F;J++)a.readUnsignedExpGolomb(),a.readBoolean()}if(a.readBoolean())for(E=a.readUnsignedExpGolomb(),G=0;G<E;G++){for(I=0;I<C+4;I++)a.readBits(1);a.readBits(1)}E=C=1;G=!0;I=1;J=F=0;a.readBoolean();a.readBoolean();if(a.readBoolean()){if(a.readBoolean()){K=a.readUnsignedByte();H=[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];K>0&&K<=16?(C=H[K-1],E=M[K-1]):K===255&&(C=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(K=a.readBoolean())a.skipExpGolomb(),a.skipExpGolomb(),a.skipExpGolomb(),a.skipExpGolomb();if(a.readBoolean()&&(I=a.readBits(32),F=a.readBits(32),a.readBoolean()&&a.readUnsignedExpGolomb(),a.readBoolean())){M=
!1;K=a.readBoolean();H=a.readBoolean();if(K||H){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 L=0;L<=f;L++){G=a.readBoolean();var N=!0,P=1;G||(N=a.readBoolean());var Q=!1;N?a.readUnsignedExpGolomb():Q=a.readBoolean();Q||(P=a.readUnsignedExpGolomb()+1);if(K){for(N=0;N<P;N++)a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb(),M&&(a.readUnsignedExpGolomb(),a.readUnsignedExpGolomb());
a.readBoolean()}if(H){for(N=0;N<P;N++)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:u,generalConstraintIndicatorFlags5:w,generalConstraintIndicatorFlags6:v,minSpatialSegmentationIdc:J,chromaFormatIdc:y,bitDepthLumaMinus8:D,bitDepthChromaMinus8:z,width:A-(b+c)*(y===1||y===2?2:1),height:B-(d+e)*(y===1?2:1),sarWidth:C,sarHeight:E,frameRateFps:F/I,frameRateFixed:G}};
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,a[d].byteLength>>8,a[d].byteLength&255]),b),b+=5,e.set(a[d],b),b+=a[d].byteLength;return e};
shaka.transmuxer.H265.parseFrame=function(a,b){var c=shaka.transmuxer.H265,d=!1,e=[],f=0,g=!1;a=(0,$jscomp.makeIterator)(a);for(var h=a.next();!h.done;h=a.next()){h=h.value;switch(h.type){case c.NALU_TYPE_TRAIL_N_:case c.NALU_TYPE_TRAIL_R_:var k=g=!0;break;case c.NALU_TYPE_IDR_W_RADL_:case c.NALU_TYPE_IDR_N_LP_:case c.NALU_TYPE_CRA_NUT_:d=k=g=!0;break;case c.NALU_TYPE_VPS_:case c.NALU_TYPE_SPS_:case c.NALU_TYPE_PPS_:k=!0;break;case c.NALU_TYPE_AUD_:g=k=!0;break;case c.NALU_TYPE_SEI_PREFIX_:case c.NALU_TYPE_SEI_SUFFIX_:k=
!0;break;default:k=!1}g&&k&&(e.push(h.fullData),f+=h.fullData.byteLength)}if(!e.length)return!1;f+=4*e.length;c=new Uint8Array(f);f=0;e=(0,$jscomp.makeIterator)(e);for(g=e.next();!g.done;g=e.next())g=g.value,a=g.byteLength,c[f]=a>>24&255,c[f+1]=a>>16&255,c[f+2]=a>>8&255,c[f+3]=a&255,c.set(g,f+4),f+=a+4;b.data=c;b.isKeyframe=d;return!0};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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});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",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);/*
 @license
 MSS Transmuxer
 Copyright 2015 Dash Industry Forum
 SPDX-License-Identifier: BSD-3-Clause
*/
shaka.transmuxer.MssTransmuxer=function(a){this.originalMimeType_=a;(this.isoBoxer_=shaka.dependencies.isoBoxer())&&this.addSpecificBoxProcessor_()};
shaka.transmuxer.MssTransmuxer.prototype.addSpecificBoxProcessor_=function(){this.isoBoxer_.addBoxProcessor("saio",function(){this._procFullBox();this.flags&1&&(this._procField("aux_info_type","uint",32),this._procField("aux_info_type_parameter","uint",32));this._procField("entry_count","uint",32);this._procFieldArray("offset",this.entry_count,"uint",this.version===1?64:32)});this.isoBoxer_.addBoxProcessor("saiz",function(){this._procFullBox();this.flags&1&&(this._procField("aux_info_type","uint",
32),this._procField("aux_info_type_parameter","uint",32));this._procField("default_sample_info_size","uint",8);this._procField("sample_count","uint",32);this.default_sample_info_size===0&&this._procFieldArray("sample_info_size",this.sample_count,"uint",8)});var a=function(){this._procFullBox();this.flags&1&&(this._procField("AlgorithmID","uint",24),this._procField("IV_size","uint",8),this._procFieldArray("KID",16,"uint",8));this._procField("sample_count","uint",32);this._procEntries("entry",this.sample_count,
function(b){this._procEntryField(b,"InitializationVector","data",8);this.flags&2&&(this._procEntryField(b,"NumberOfEntries","uint",16),this._procSubEntries(b,"clearAndCryptedData",b.NumberOfEntries,function(c){this._procEntryField(c,"BytesOfClearData","uint",16);this._procEntryField(c,"BytesOfEncryptedData","uint",32)}))})};this.isoBoxer_.addBoxProcessor("senc",a);this.isoBoxer_.addBoxProcessor("uuid",function(){for(var b=shaka.transmuxer.MssTransmuxer,c=!0,d=0;d<16;d++)this.usertype[d]!==b.UUID_SENC_[d]&&
(c=!1);c&&(this._parsing&&(this.type="sepiff"),a.call(this))})};shaka.transmuxer.MssTransmuxer.prototype.destroy=function(){};shaka.transmuxer.MssTransmuxer.prototype.isSupported=function(a,b){var c=shaka.media.Capabilities,d=a.startsWith("mss/");if(!this.isoBoxer_||!d)return!1;if(b)return c.isTypeSupported(this.convertCodecs(b,a));d=shaka.util.ManifestParserUtils.ContentType;b=this.convertCodecs(d.AUDIO,a);a=this.convertCodecs(d.VIDEO,a);return c.isTypeSupported(b)||c.isTypeSupported(a)};
shaka.transmuxer.MssTransmuxer.prototype.convertCodecs=function(a,b){return b.replace("mss/","")};shaka.transmuxer.MssTransmuxer.prototype.getOriginalMimeType=function(){return this.originalMimeType_};
shaka.transmuxer.MssTransmuxer.prototype.transmux=function(a,b,c){if(!c)return Promise.resolve(shaka.util.BufferUtils.toUint8(a));if(!b.mssPrivateData)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MSS_MISSING_DATA_FOR_TRANSMUXING,c?c.getUris()[0]:null));try{var d=this.processMediaSegment_(a,b,c);return Promise.resolve(d)}catch(e){return e instanceof shaka.util.Error?Promise.reject(e):Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MSS_TRANSMUXING_FAILED,c?c.getUris()[0]:null))}};
shaka.transmuxer.MssTransmuxer.prototype.processMediaSegment_=function(a,b,c){a=this.isoBoxer_.parseBuffer(a);var d=a.fetch("tfhd");d.track_ID=b.id+1;var e=a.fetch("tfdt");var f=a.fetch("traf");e===null&&(e=this.isoBoxer_.createFullBox("tfdt",f,d),e.version=1,e.flags=0,e.baseMediaDecodeTime=Math.floor(c.startTime*b.mssPrivateData.timescale));b=a.fetch("trun");(c=a.fetch("tfxd"))&&c._parent.boxes.splice(c._parent.boxes.indexOf(c),1);(c=a.fetch("tfrf"))&&c._parent.boxes.splice(c._parent.boxes.indexOf(c),
1);c=a.fetch("sepiff");if(c!==null&&(c.type="senc",c.usertype=void 0,e=a.fetch("saio"),e===null)){e=this.isoBoxer_.createFullBox("saio",f);e.version=0;e.flags=0;e.entry_count=1;e.offset=[0];var g=this.isoBoxer_.createFullBox("saiz",f);g.version=0;g.flags=0;g.sample_count=c.sample_count;g.default_sample_info_size=0;g.sample_info_size=[];if(c.flags&2)for(e=0;e<c.sample_count;e+=1)g.sample_info_size[e]=10+6*c.entry[e].NumberOfEntries;else g.default_sample_info_size=8}d.flags&=16777214;d.flags|=131072;
b.flags|=1;d=a.fetch("moof");c=d.getLength();b.data_offset=c+8;b=a.fetch("saio");b!==null&&(d=this.getBoxOffset_(d,"traf"),f=this.getBoxOffset_(f,"senc"),b.offset[0]=d+f+16);return shaka.util.BufferUtils.toUint8(a.write())};shaka.transmuxer.MssTransmuxer.prototype.getBoxOffset_=function(a,b){for(var c=8,d=0;d<a.boxes.length&&a.boxes[d].type!==b;d++)c+=a.boxes[d].size;return c};goog.exportSymbol("shaka.transmuxer.MssTransmuxer",shaka.transmuxer.MssTransmuxer);
goog.exportProperty(shaka.transmuxer.MssTransmuxer.prototype,"transmux",shaka.transmuxer.MssTransmuxer.prototype.transmux);goog.exportProperty(shaka.transmuxer.MssTransmuxer.prototype,"getOriginalMimeType",shaka.transmuxer.MssTransmuxer.prototype.getOriginalMimeType);goog.exportProperty(shaka.transmuxer.MssTransmuxer.prototype,"convertCodecs",shaka.transmuxer.MssTransmuxer.prototype.convertCodecs);goog.exportProperty(shaka.transmuxer.MssTransmuxer.prototype,"isSupported",shaka.transmuxer.MssTransmuxer.prototype.isSupported);
goog.exportProperty(shaka.transmuxer.MssTransmuxer.prototype,"destroy",shaka.transmuxer.MssTransmuxer.prototype.destroy);shaka.transmuxer.MssTransmuxer.UUID_SENC_=new Uint8Array([162,57,79,82,90,155,79,20,162,68,108,66,124,100,141,244]);shaka.transmuxer.TransmuxerEngine.registerTransmuxer("mss/audio/mp4",function(){return new shaka.transmuxer.MssTransmuxer("mss/audio/mp4")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);
shaka.transmuxer.TransmuxerEngine.registerTransmuxer("mss/video/mp4",function(){return new shaka.transmuxer.MssTransmuxer("mss/video/mp4")},shaka.transmuxer.TransmuxerEngine.PluginPriority.FALLBACK);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.getPacketSampleCount=function(a){if(a.length<1)return shaka.transmuxer.Opus.OPUS_AUDIO_SAMPLE_PER_FRAME;var b=a[0],c=b&3;b=shaka.transmuxer.Opus.SAMPLES_PER_FRAME_BY_CONFIG_[b>>3&31];if(c===0)a=1;else if(c===1||c===2)a=2;else{if(a.length<2)return b;a=a[1]&63;if(a===0)return b}return b*a};shaka.transmuxer.Opus.SAMPLES_PER_FRAME_BY_CONFIG_=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960];
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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});
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 u=
n.subarray(q+p.headerLength,q+t);h.push({data:u,size:p.frameLength,duration:e.AAC_SAMPLES_PER_FRAME,cts:0,flags:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS})}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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS}),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,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,m={sampleRate:0,channelCount:0,audioConfig:new Uint8Array(0),frameLength:0};a=(0,$jscomp.makeIterator)(a.getAudioData());for(var n=a.next();!n.done;n=a.next()){var p=n.value;n=p.data;l==null&&p.pts!==null&&(l=p.pts);for(p=0;p<n.length;)if(e.parseFrame(n,p,m)){b.audioSamplingRate=m.sampleRate;b.channelsCount=m.channelCount;h=m.sampleRate;
k=m.audioConfig;var q=n.subarray(p,p+m.frameLength);g.push({data:q,size:m.frameLength,duration:e.AC3_SAMPLES_PER_FRAME,cts:0,flags:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});p+=m.frameLength}else p++}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",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,m={sampleRate:0,channelCount:0,audioConfig:new Uint8Array(0),frameLength:0};a=(0,$jscomp.makeIterator)(a.getAudioData());for(var n=a.next();!n.done;n=a.next()){var p=n.value;n=p.data;l==null&&p.pts!==null&&(l=p.pts);for(p=0;p<n.length;)if(e.parseFrame(n,p,m)){b.audioSamplingRate=m.sampleRate;b.channelsCount=m.channelCount;h=m.sampleRate;
k=m.audioConfig;var q=n.subarray(p,p+m.frameLength);g.push({data:q,size:m.frameLength,duration:e.EC3_SAMPLES_PER_FRAME,cts:0,flags:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});p+=m.frameLength}else p++}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",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:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS}),
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",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.getPacketSampleCount(p),cts:0,flags:shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS});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",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:m.isKeyframe?shaka.transmuxer.TransmuxerUtils.VIDEO_KEYFRAME_FLAGS:shaka.transmuxer.TransmuxerUtils.VIDEO_NON_KEYFRAME_FLAGS})}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=b.height||e.height;b.width=b.width||e.width;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.VIDEO,codecs:"avc1",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();var l={data:new Uint8Array(0),isKeyframe:!1};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 m=0;m<a.length;m++){var n=a[m],p=n.nalus;k.push.apply(k,(0,$jscomp.arrayFromIterable)(p));e.parseFrame(p,
l)&&(h==null&&n.dts!=null&&(h=n.dts),g.push({data:l.data,size:l.data.byteLength,duration:m+1<a.length?(a[m+1].dts||0)-(n.dts||0):a.length>1?(n.dts||0)-(a[m-1].dts||0):(d.endTime-d.startTime)*f,cts:Math.round((n.pts||0)-(n.dts||0)),flags:l.isKeyframe?shaka.transmuxer.TransmuxerUtils.VIDEO_KEYFRAME_FLAGS:shaka.transmuxer.TransmuxerUtils.VIDEO_NON_KEYFRAME_FLAGS}))}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=b.height||e.height;b.width=b.width||e.width;return{id:b.id,type:shaka.util.ManifestParserUtils.ContentType.VIDEO,codecs:"hvc1",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.ui.Element=function(a,b){var c=this;this.parent=a;this.controls=b;this.eventManager=new shaka.util.EventManager;this.localization=this.controls.getLocalization();this.player=this.controls.getPlayer();this.video=this.controls.getVideo();this.adManager=this.player.getAdManager();this.ad=b.getAd();this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(d){c.ad=d.ad});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.ad=null})};
shaka.ui.Element.prototype.release=function(){this.eventManager.release();this.ad=this.adManager=this.video=this.player=this.localization=this.eventManager=this.controls=this.parent=null};goog.exportSymbol("shaka.ui.Element",shaka.ui.Element);goog.exportProperty(shaka.ui.Element.prototype,"release",shaka.ui.Element.prototype.release);shaka.ui.Enums={};
shaka.ui.Enums.MaterialDesignSVGIcons={FULLSCREEN:"M200-200h80q17 0 28.5 11.5T320-160q0 17-11.5 28.5T280-120H160q-17 0-28.5-11.5T120-160v-120q0-17 11.5-28.5T160-320q17 0 28.5 11.5T200-280v80Zm560 0v-80q0-17 11.5-28.5T800-320q17 0 28.5 11.5T840-280v120q0 17-11.5 28.5T800-120H680q-17 0-28.5-11.5T640-160q0-17 11.5-28.5T680-200h80ZM200-760v80q0 17-11.5 28.5T160-640q-17 0-28.5-11.5T120-680v-120q0-17 11.5-28.5T160-840h120q17 0 28.5 11.5T320-800q0 17-11.5 28.5T280-760h-80Zm560 0h-80q-17 0-28.5-11.5T640-800q0-17 11.5-28.5T680-840h120q17 0 28.5 11.5T840-800v120q0 17-11.5 28.5T800-640q-17 0-28.5-11.5T760-680v-80Z",EXIT_FULLSCREEN:"M240-240h-80q-17 0-28.5-11.5T120-280q0-17 11.5-28.5T160-320h120q17 0 28.5 11.5T320-280v120q0 17-11.5 28.5T280-120q-17 0-28.5-11.5T240-160v-80Zm480 0v80q0 17-11.5 28.5T680-120q-17 0-28.5-11.5T640-160v-120q0-17 11.5-28.5T680-320h120q17 0 28.5 11.5T840-280q0 17-11.5 28.5T800-240h-80ZM240-720v-80q0-17 11.5-28.5T280-840q17 0 28.5 11.5T320-800v120q0 17-11.5 28.5T280-640H160q-17 0-28.5-11.5T120-680q0-17 11.5-28.5T160-720h80Zm480 0h80q17 0 28.5 11.5T840-680q0 17-11.5 28.5T800-640H680q-17 0-28.5-11.5T640-680v-120q0-17 11.5-28.5T680-840q17 0 28.5 11.5T720-800v80Z",
CLOSE:"M480-424 284-228q-11 11-28 11t-28-11q-11-11-11-28t11-28l196-196-196-196q-11-11-11-28t11-28q11-11 28-11t28 11l196 196 196-196q11-11 28-11t28 11q11 11 11 28t-11 28L536-480l196 196q11 11 11 28t-11 28q-11 11-28 11t-28-11L480-424Z",CLOSED_CAPTIONS:"M200-160q-33 0-56.5-23.5T120-240v-480q0-33 23.5-56.5T200-800h560q33 0 56.5 23.5T840-720v480q0 33-23.5 56.5T760-160H200Zm80-200h120q17 0 28.5-11.5T440-400v-20q0-9-6-15t-15-6h-18q-9 0-15 6t-6 15h-80v-120h80q0 9 6 15t15 6h18q9 0 15-6t6-15v-20q0-17-11.5-28.5T400-600H280q-17 0-28.5 11.5T240-560v160q0 17 11.5 28.5T280-360Zm400-240H560q-17 0-28.5 11.5T520-560v160q0 17 11.5 28.5T560-360h120q17 0 28.5-11.5T720-400v-20q0-9-6-15t-15-6h-18q-9 0-15 6t-6 15h-80v-120h80q0 9 6 15t15 6h18q9 0 15-6t6-15v-20q0-17-11.5-28.5T680-600Z",
CLOSED_CAPTIONS_OFF:"M791-57 687-160H200q-33 0-56.5-23.5T120-240v-487l-65-65q-12-12-12-28.5T55-849q12-12 28.5-12t28.5 12l736 736q12 12 12 28t-12 28q-12 12-28.5 12T791-57ZM280-360h120q17 0 28.5-11.5T440-400v-25q0-8-6-14t-14-6h-20q-8 0-14 6t-6 14v5h-80v-127l-45-45v1q-7 5-11 13t-4 18v160q0 17 11.5 28.5T280-360Zm560-360v388q0 27-24.5 37.5T772-303l-66-66q7-5 10.5-13.5T720-400v-20q0-8-6-14t-14-6h-20q-8 0-14 6t-6 14h-5l-75-75v-45h80v5q0 8 6 14t14 6h20q8 0 14-6t6-14v-25q0-17-11.5-28.5T680-600H560q-17 0-28.5 11.5T520-560v5L343-732q-19-19-8.5-43.5T372-800h388q33 0 56.5 23.5T840-720Z",
CHECKMARK:"m382-354 339-339q12-12 28-12t28 12q12 12 12 28.5T777-636L410-268q-12 12-28 12t-28-12L182-440q-12-12-11.5-28.5T183-497q12-12 28.5-12t28.5 12l142 143Z",LANGUAGE:"M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Zm0-82q26-36 45-75t31-83H404q12 44 31 83t45 75Zm-104-16q-18-33-31.5-68.5T322-320H204q29 50 72.5 87t99.5 55Zm208 0q56-18 99.5-55t72.5-87H638q-9 38-22.5 73.5T584-178ZM170-400h136q-3-20-4.5-39.5T300-480q0-21 1.5-40.5T306-560H170q-5 20-7.5 39.5T160-480q0 21 2.5 40.5T170-400Zm216 0h188q3-20 4.5-39.5T580-480q0-21-1.5-40.5T574-560H386q-3 20-4.5 39.5T380-480q0 21 1.5 40.5T386-400Zm268 0h136q5-20 7.5-39.5T800-480q0-21-2.5-40.5T790-560H654q3 20 4.5 39.5T660-480q0 21-1.5 40.5T654-400Zm-16-240h118q-29-50-72.5-87T584-782q18 33 31.5 68.5T638-640Zm-234 0h152q-12-44-31-83t-45-75q-26 36-45 75t-31 83Zm-200 0h118q9-38 22.5-73.5T376-782q-56 18-99.5 55T204-640Z",
PIP:"M120-520q-17 0-28.5-11.5T80-560q0-17 11.5-28.5T120-600h104L80-743q-12-12-12-28.5T80-800q12-12 28.5-12t28.5 12l143 144v-104q0-17 11.5-28.5T320-800q17 0 28.5 11.5T360-760v200q0 17-11.5 28.5T320-520H120Zm40 360q-33 0-56.5-23.5T80-240v-160q0-17 11.5-28.5T120-440q17 0 28.5 11.5T160-400v160h280q17 0 28.5 11.5T480-200q0 17-11.5 28.5T440-160H160Zm680-280q-17 0-28.5-11.5T800-480v-240H480q-17 0-28.5-11.5T440-760q0-17 11.5-28.5T480-800h320q33 0 56.5 23.5T880-720v240q0 17-11.5 28.5T840-440ZM600-160q-17 0-28.5-11.5T560-200v-120q0-17 11.5-28.5T600-360h240q17 0 28.5 11.5T880-320v120q0 17-11.5 28.5T840-160H600Z",
EXIT_PIP:"M160-160q-33 0-56.5-23.5T80-240v-240q0-17 11.5-28.5T120-520q17 0 28.5 11.5T160-480v240h640v-480H480q-17 0-28.5-11.5T440-760q0-17 11.5-28.5T480-800h320q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm400-263 95 95q12 12 28 12t28-12q12-12 12-28.5T711-385l-95-95h64q17 0 28.5-11.5T720-520q0-17-11.5-28.5T680-560H520q-17 0-28.5 11.5T480-520v160q0 17 11.5 28.5T520-320q17 0 28.5-11.5T560-360v-63ZM120-600q-17 0-28.5-11.5T80-640v-120q0-17 11.5-28.5T120-800h200q17 0 28.5 11.5T360-760v120q0 17-11.5 28.5T320-600H120Zm360 120Z",
BACK:"m432-480 156 156q11 11 11 28t-11 28q-11 11-28 11t-28-11L348-452q-6-6-8.5-13t-2.5-15q0-8 2.5-15t8.5-13l184-184q11-11 28-11t28 11q11 11 11 28t-11 28L432-480Z",RESOLUTION:"M480-120q-17 0-28.5-11.5T440-160v-160q0-17 11.5-28.5T480-360q17 0 28.5 11.5T520-320v40h280q17 0 28.5 11.5T840-240q0 17-11.5 28.5T800-200H520v40q0 17-11.5 28.5T480-120Zm-320-80q-17 0-28.5-11.5T120-240q0-17 11.5-28.5T160-280h160q17 0 28.5 11.5T360-240q0 17-11.5 28.5T320-200H160Zm160-160q-17 0-28.5-11.5T280-400v-40H160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520h120v-40q0-17 11.5-28.5T320-600q17 0 28.5 11.5T360-560v160q0 17-11.5 28.5T320-360Zm160-80q-17 0-28.5-11.5T440-480q0-17 11.5-28.5T480-520h320q17 0 28.5 11.5T840-480q0 17-11.5 28.5T800-440H480Zm160-160q-17 0-28.5-11.5T600-640v-160q0-17 11.5-28.5T640-840q17 0 28.5 11.5T680-800v40h120q17 0 28.5 11.5T840-720q0 17-11.5 28.5T800-680H680v40q0 17-11.5 28.5T640-600Zm-480-80q-17 0-28.5-11.5T120-720q0-17 11.5-28.5T160-760h320q17 0 28.5 11.5T520-720q0 17-11.5 28.5T480-680H160Z",
MUTE:"M760-481q0-83-44-151.5T598-735q-15-7-22-21.5t-2-29.5q6-16 21.5-23t31.5 0q97 43 155 131.5T840-481q0 108-58 196.5T627-153q-16 7-31.5 0T574-176q-5-15 2-29.5t22-21.5q74-34 118-102.5T760-481ZM280-360H160q-17 0-28.5-11.5T120-400v-160q0-17 11.5-28.5T160-600h120l132-132q19-19 43.5-8.5T480-703v446q0 27-24.5 37.5T412-228L280-360Zm380-120q0 42-19 79.5T591-339q-10 6-20.5.5T560-356v-250q0-12 10.5-17.5t20.5.5q31 25 50 63t19 80Z",UNMUTE:"M671-177q-11 7-22 13t-23 11q-15 7-30.5 0T574-176q-6-15 1.5-29.5T598-227q4-2 7.5-4t7.5-4L480-368v111q0 27-24.5 37.5T412-228L280-360H160q-17 0-28.5-11.5T120-400v-160q0-17 11.5-28.5T160-600h88L84-764q-11-11-11-28t11-28q11-11 28-11t28 11l680 680q11 11 11 28t-11 28q-11 11-28 11t-28-11l-93-93Zm89-304q0-83-44-151.5T598-735q-15-7-22-21.5t-2-29.5q6-16 21.5-23t31.5 0q97 43 155 131t58 197q0 33-6 65.5T817-353q-8 22-24.5 27.5t-30.5.5q-14-5-22.5-18t-.5-30q11-26 16-52.5t5-55.5ZM591-623q33 21 51 63t18 80v10q0 5-1 10-2 13-14 17t-22-6l-51-51q-6-6-9-13.5t-3-15.5v-77q0-12 10.5-17.5t20.5.5Zm-201-59q-6-6-6-14t6-14l22-22q19-19 43.5-8.5T480-703v63q0 14-12 19t-22-5l-56-56Z",
CAST:"M480-480Zm320 320H600q0-20-1.5-40t-4.5-40h206v-480H160v46q-20-3-40-4.5T80-680v-40q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160Zm-720 0v-120q50 0 85 35t35 85H80Zm200 0q0-83-58.5-141.5T80-360v-80q117 0 198.5 81.5T360-160h-80Zm160 0q0-75-28.5-140.5t-77-114q-48.5-48.5-114-77T80-520v-80q91 0 171 34.5T391-471q60 60 94.5 140T520-160h-80Z",EXIT_CAST:"M720-600v240q0 17-11.5 28.5T680-320h-87q-8 0-14.5-4.5T569-337q-29-81-81.5-147T364-596q-16-10-11.5-27t21.5-17h306q17 0 28.5 11.5T720-600ZM320-160q-16 0-28-9.5T277-195q-11-63-56.5-107T112-357q-15-2-23.5-14.5T80-400q0-17 11-28.5t26-9.5q94 12 160.5 79T357-198q2 16-9 27t-28 11Zm160 0q-17 0-28.5-11T438-199q-14-128-104.5-217T115-518q-16-2-25.5-14T80-560q0-17 10.5-29t25.5-10q161 13 274 125.5T518-201q2 17-9.5 29T480-160Zm-340 0q-25 0-42.5-17.5T80-220q0-25 17.5-42.5T140-280q25 0 42.5 17.5T200-220q0 25-17.5 42.5T140-160Zm740-560v480q0 33-23.5 56.5T800-160H638q-17 0-28.5-11.5T598-200q0-17 11.5-28.5T638-240h162v-480H160v6q0 17-11.5 28.5T120-674q-17 0-28.5-11.5T80-714v-6q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720Z",
OPEN_OVERFLOW:"M433-80q-27 0-46.5-18T363-142l-9-66q-13-5-24.5-12T307-235l-62 26q-25 11-50 2t-39-32l-47-82q-14-23-8-49t27-43l53-40q-1-7-1-13.5v-27q0-6.5 1-13.5l-53-40q-21-17-27-43t8-49l47-82q14-23 39-32t50 2l62 26q11-8 23-15t24-12l9-66q4-26 23.5-44t46.5-18h94q27 0 46.5 18t23.5 44l9 66q13 5 24.5 12t22.5 15l62-26q25-11 50-2t39 32l47 82q14 23 8 49t-27 43l-53 40q1 7 1 13.5v27q0 6.5-2 13.5l53 40q21 17 27 43t-8 49l-48 82q-14 23-39 32t-50-2l-60-26q-11 8-23 15t-24 12l-9 66q-4 26-23.5 44T527-80h-94Zm49-260q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Z",
REWIND:"M798-281 550-447q-9-6-13.5-14.5T532-480q0-10 4.5-18.5T550-513l248-166q5-4 11-5t11-1q16 0 28 11t12 29v330q0 18-12 29t-28 11q-5 0-11-1t-11-5Zm-400 0L150-447q-9-6-13.5-14.5T132-480q0-10 4.5-18.5T150-513l248-166q5-4 11-5t11-1q16 0 28 11t12 29v330q0 18-12 29t-28 11q-5 0-11-1t-11-5Z",FAST_FORWARD:"M100-315v-330q0-18 12-29t28-11q5 0 11 1t11 5l248 166q9 6 13.5 14.5T428-480q0 10-4.5 18.5T410-447L162-281q-5 4-11 5t-11 1q-16 0-28-11t-12-29Zm400 0v-330q0-18 12-29t28-11q5 0 11 1t11 5l248 166q9 6 13.5 14.5T828-480q0 10-4.5 18.5T810-447L562-281q-5 4-11 5t-11 1q-16 0-28-11t-12-29Z",
PLAY:"M320-273v-414q0-17 12-28.5t28-11.5q5 0 10.5 1.5T381-721l326 207q9 6 13.5 15t4.5 19q0 10-4.5 19T707-446L381-239q-5 3-10.5 4.5T360-233q-16 0-28-11.5T320-273Z",PLAYBACK_RATE:"m426-330 195-125q14-9 14-25t-14-25L426-630q-15-10-30.5-1.5T380-605v250q0 18 15.5 26.5T426-330ZM121-440q17 0 30.5 11t18.5 28q6 23 14.5 43.5T204-317q9 15 7.5 32T198-256q-11 11-27 10t-25-14q-22-31-37-66.5T86-400q-3-16 7.5-28t27.5-12Zm77-264q12 12 13 29t-7 31q-11 20-19.5 41T170-559q-5 17-18.5 28T121-520q-17 0-27.5-12.5T87-561q8-38 23-73.5t36-66.5q9-13 25-13.5t27 10.5Zm56 505q12-13 29.5-14t32.5 8q20 11 40.5 20t42.5 15q17 5 28 18t11 30q0 17-12.5 27T397-88q-38-8-71.5-23T260-146q-14-9-15.5-25t9.5-28Zm186-639q0 17-10.5 30T402-790q-23 6-44 14.5T317-755q-15 9-32.5 7.5T255-761q-12-12-10.5-28.5T260-815q32-20 66.5-34.5T399-872q16-3 28.5 7t12.5 27Zm360 358q0-113-69.5-199.5T553-792q-15-4-24-17t-9-29q0-16 11-26.5t25-7.5q140 28 232 137t92 255q0 146-92 255T556-88q-14 3-25-7.5T520-122q0-16 9-29t24-17q108-26 177.5-112.5T800-480Z",
PAUSE:"M640-200q-33 0-56.5-23.5T560-280v-400q0-33 23.5-56.5T640-760q33 0 56.5 23.5T720-680v400q0 33-23.5 56.5T640-200Zm-320 0q-33 0-56.5-23.5T240-280v-400q0-33 23.5-56.5T320-760q33 0 56.5 23.5T400-680v400q0 33-23.5 56.5T320-200Z",LOOP:"m274-200 34 34q12 12 11.5 28T308-110q-12 12-28.5 12.5T251-109L148-212q-6-6-8.5-13t-2.5-15q0-8 2.5-15t8.5-13l103-103q12-12 28.5-11.5T308-370q11 12 11.5 28T308-314l-34 34h406v-120q0-17 11.5-28.5T720-440q17 0 28.5 11.5T760-400v120q0 33-23.5 56.5T680-200H274Zm412-480H280v120q0 17-11.5 28.5T240-520q-17 0-28.5-11.5T200-560v-120q0-33 23.5-56.5T280-760h406l-34-34q-12-12-11.5-28t11.5-28q12-12 28.5-12.5T709-851l103 103q6 6 8.5 13t2.5 15q0 8-2.5 15t-8.5 13L709-589q-12 12-28.5 11.5T652-590q-11-12-11.5-28t11.5-28l34-34Z",
UNLOOP:"M120-40q-33 0-56.5-23.5T40-120v-720q0-33 23.5-56.5T120-920h720q33 0 56.5 23.5T920-840v720q0 33-23.5 56.5T840-40H120Zm154-160h406q33 0 56.5-23.5T760-280v-120q0-17-11.5-28.5T720-440q-17 0-28.5 11.5T680-400v120H274l34-34q12-12 11.5-28T308-370q-12-12-28.5-12.5T251-371L148-268q-6 6-8.5 13t-2.5 15q0 8 2.5 15t8.5 13l103 103q12 12 28.5 11.5T308-110q11-12 11.5-28T308-166l-34-34Zm412-480-34 34q-12 12-11.5 28t11.5 28q12 12 28.5 12.5T709-589l103-103q6-6 8.5-13t2.5-15q0-8-2.5-15t-8.5-13L709-851q-12-12-28.5-11.5T652-850q-11 12-11.5 28t11.5 28l34 34H280q-33 0-56.5 23.5T200-680v120q0 17 11.5 28.5T240-520q17 0 28.5-11.5T280-560v-120h406Z",
AIRPLAY:"M80-280v-480q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v480q0 33-23.5 56.5T800-200h-80q-17 0-28.5-11.5T680-240q0-17 11.5-28.5T720-280h80v-480H160v480h80q17 0 28.5 11.5T280-240q0 17-11.5 28.5T240-200h-80q-33 0-56.5-23.5T80-280Zm232 160q-14 0-22-9.5t-8-20.5q0-5 2-10.5t7-10.5l161-161q6-6 13-9t15-3q8 0 15 3t13 9l161 161q5 5 7 10.5t2 10.5q0 11-8 20.5t-22 9.5H312Zm168-360Z",REPLAY:"M480-80q-75 0-140.5-28.5t-114-77q-48.5-48.5-77-114T120-440q0-17 11.5-28.5T160-480q17 0 28.5 11.5T200-440q0 117 81.5 198.5T480-160q117 0 198.5-81.5T760-440q0-117-81.5-198.5T480-720h-6l34 34q12 12 11.5 28T508-630q-12 12-28.5 12.5T451-629L348-732q-12-12-12-28t12-28l103-103q12-12 28.5-11.5T508-890q11 12 11.5 28T508-834l-34 34h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-440q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-80Z",
SKIP_NEXT:"M660-280v-400q0-17 11.5-28.5T700-720q17 0 28.5 11.5T740-680v400q0 17-11.5 28.5T700-240q-17 0-28.5-11.5T660-280Zm-440-35v-330q0-18 12-29t28-11q5 0 11 1t11 5l248 166q9 6 13.5 14.5T548-480q0 10-4.5 18.5T530-447L282-281q-5 4-11 5t-11 1q-16 0-28-11t-12-29Z",SKIP_PREVIOUS:"M220-280v-400q0-17 11.5-28.5T260-720q17 0 28.5 11.5T300-680v400q0 17-11.5 28.5T260-240q-17 0-28.5-11.5T220-280Zm458-1L430-447q-9-6-13.5-14.5T412-480q0-10 4.5-18.5T430-513l248-166q5-4 11-5t11-1q16 0 28 11t12 29v330q0 18-12 29t-28 11q-5 0-11-1t-11-5Z",
STATISTICS_ON:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Zm120 200q-17 0-28.5 11.5T280-520v200q0 17 11.5 28.5T320-280q17 0 28.5-11.5T360-320v-200q0-17-11.5-28.5T320-560Zm160-120q-17 0-28.5 11.5T440-640v320q0 17 11.5 28.5T480-280q17 0 28.5-11.5T520-320v-320q0-17-11.5-28.5T480-680Zm160 240q-17 0-28.5 11.5T600-400v80q0 17 11.5 28.5T640-280q17 0 28.5-11.5T680-320v-80q0-17-11.5-28.5T640-440Z",
STATISTICS_OFF:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-440q-17 0-28.5 11.5T280-520v200q0 17 11.5 28.5T320-280q17 0 28.5-11.5T360-320v-200q0-17-11.5-28.5T320-560Zm160-120q-17 0-28.5 11.5T440-640v320q0 17 11.5 28.5T480-280q17 0 28.5-11.5T520-320v-320q0-17-11.5-28.5T480-680Zm160 240q-17 0-28.5 11.5T600-400v80q0 17 11.5 28.5T640-280q17 0 28.5-11.5T680-320v-80q0-17-11.5-28.5T640-440Z",RECENTER_VR:"M479-359q-50 0-85-35t-35-85q0-50 35-85t85-35q50 0 85 35t35 85q0 50-35 85t-85 35Zm-57 222-85-85q-12-12-11.5-28.5T338-279q12-12 28.5-12t28.5 12l85 86 85-85q11-11 28-11t28 11q11 11 11 28t-11 28l-85 85q-12 12-27 18t-30 6q-15 0-30-6t-27-18ZM221-337l-85-85q-12-12-18-27t-6-30q0-15 6-30t18-27l85-85q12-12 28.5-12t28.5 12q12 12 12 28.5T278-564l-86 86 85 85q11 11 11 28t-11 28q-11 11-28 11t-28-11Zm116-401 85-85q12-12 27-18t30-6q15 0 30 6t27 18l85 85q12 12 12 28t-12 28q-12 12-28.5 12T564-682l-86-85-85 85q-11 11-28 11t-28-11q-11-11-11-28t11-28Zm344 343 85-85-85-85q-11-11-11-28t11-28q11-11 28-11t28 11l85 85q12 12 18 27t6 30q0 15-6 30t-18 27l-85 85q-12 12-28 11.5T681-338q-12-12-12-28.5t12-28.5Z",
TOGGLE_STEREOSCOPIC:"M620-360H520q-8 0-14-6t-6-14v-200q0-8 6-14t14-6h100q17 0 28.5 11.5T660-560v160q0 17-11.5 28.5T620-360Zm-200 0h-90q-13 0-21.5-8.5T300-390q0-13 8.5-21.5T330-420h70v-40h-40q-8 0-14-6t-6-14q0-8 6-14t14-6h40v-40h-70q-13 0-21.5-8.5T300-570q0-13 8.5-21.5T330-600h90q17 0 28.5 11.5T460-560v160q0 17-11.5 28.5T420-360Zm140-60h40v-120h-40v120Zm280-20q-17 0-28.5-11.5T800-480q0-115-72.5-203T542-794l30 30q11 11 11 28t-11 28q-11 11-28 11t-28-11L387-837q-8-8-4.5-20t14.5-15q20-5 41-6.5t42-1.5q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 17-11.5 28.5T840-440ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-17 11.5-28.5T120-520q17 0 28.5 11.5T160-480q0 115 72.5 203T418-166l-30-30q-11-11-11-28t11-28q11-11 28-11t28 11l129 129q8 8 4.5 20T563-88q-20 5-41 6.5T480-80Z",
DOWNLOAD:"M480-337q-8 0-15-2.5t-13-8.5L308-492q-12-12-11.5-28t11.5-28q12-12 28.5-12.5T365-549l75 75v-286q0-17 11.5-28.5T480-800q17 0 28.5 11.5T520-760v286l75-75q12-12 28.5-11.5T652-548q11 12 11.5 28T652-492L508-348q-6 6-13 8.5t-15 2.5ZM240-160q-33 0-56.5-23.5T160-240v-80q0-17 11.5-28.5T200-360q17 0 28.5 11.5T240-320v80h480v-80q0-17 11.5-28.5T760-360q17 0 28.5 11.5T800-320v80q0 33-23.5 56.5T720-160H240Z",CHAPTER:"m400-200-182 91q-20 10-39-1.5T160-145v-495q0-33 23.5-56.5T240-720h320q33 0 56.5 23.5T640-640v495q0 23-19 34.5t-39 1.5l-182-91Zm360-40q-17 0-28.5-11.5T720-280v-520H320q-17 0-28.5-11.5T280-840q0-17 11.5-28.5T320-880h400q33 0 56.5 23.5T800-800v520q0 17-11.5 28.5T760-240Z"};shaka.ui.MaterialSVGIcon=function(a,b){this.parent=a;this.svg_=shaka.util.Dom.createSVGElement("svg");this.path_=shaka.util.Dom.createSVGElement("path");this.svg_.classList.add("material-svg-icon");this.svg_.setAttribute("viewBox","0 -960 960 960");b&&this.use(b);this.svg_.appendChild(this.path_);this.parent&&a.appendChild(this.svg_)};shaka.ui.MaterialSVGIcon.prototype.use=function(a){a&&typeof a=="string"&&this.path_.setAttribute("d",a)};shaka.ui.MaterialSVGIcon.prototype.getSvgElement=function(){return this.svg_};
goog.exportSymbol("shaka.ui.MaterialSVGIcon",shaka.ui.MaterialSVGIcon);goog.exportProperty(shaka.ui.MaterialSVGIcon.prototype,"getSvgElement",shaka.ui.MaterialSVGIcon.prototype.getSvgElement);goog.exportProperty(shaka.ui.MaterialSVGIcon.prototype,"use",shaka.ui.MaterialSVGIcon.prototype.use);shaka.ui.Utils=function(){};shaka.ui.Utils.getFirstDescendantWithClassName=function(a,b){a=shaka.ui.Utils.getDescendantIfExists(a,b);goog.asserts.assert(a!=null,"Should not be null!");return a};shaka.ui.Utils.getDescendantIfExists=function(a,b){a=a.getElementsByClassName(b);return a.length?a[0]:null};shaka.ui.Utils.focusOnTheChosenItem=function(a){a&&(a=shaka.ui.Utils.getDescendantIfExists(a,"shaka-chosen-item"))&&a.parentElement.focus()};
shaka.ui.Utils.checkmarkIcon=function(){var a=(new shaka.ui.MaterialSVGIcon(null,shaka.ui.Enums.MaterialDesignSVGIcons.CHECKMARK)).getSvgElement();a.classList.add("shaka-chosen-item");a.ariaHidden="true";return a};shaka.ui.Utils.setDisplay=function(a,b){a&&(b?a.classList.remove("shaka-hidden"):a.classList.add("shaka-hidden"))};
shaka.ui.Utils.buildTimeString=function(a,b){var c=Math.floor(a/86400),d=Math.floor(a%86400/3600),e=Math.floor(a/60%60);a=Math.floor(a%60);a<10&&(a="0"+a);a=e+":"+a;b&&(e<10&&(a="0"+a),a=d+":"+a,c>0&&(d<10&&(a="0"+a),a=c+":"+a));return a};shaka.ui.AdInfo=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.adInfo_=shaka.util.Dom.createButton();this.adInfo_.classList.add("shaka-ad-info");this.adInfo_.disabled=!0;this.parent.appendChild(this.adInfo_);this.timer_=new shaka.util.Timer(function(){c.onTimerTick_()});this.updateAriaLabel_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,
function(){c.updateAriaLabel_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.onAdStarted_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.reset_()});if(this.ad)this.onAdStarted_()};$jscomp.inherits(shaka.ui.AdInfo,shaka.ui.Element);shaka.ui.AdInfo.prototype.updateAriaLabel_=function(){};shaka.ui.AdInfo.prototype.onAdStarted_=function(){this.timer_.tickNow();this.timer_.tickEvery(.5)};
shaka.ui.AdInfo.prototype.onTimerTick_=function(){var a=shaka.ui.Locales.Ids;goog.asserts.assert(this.ad!=null,"this.ad should exist at this point");if(this.ad.isLinear()){var b="",c=this.ad.getSequenceLength();c>1&&(b=this.ad.getPositionInSequence(),b=this.localization.resolve(a.AD_PROGRESS).replace("[AD_ON]",String(b)).replace("[NUM_ADS]",String(c)));var d=Math.round(this.ad.getRemainingTime()),e=this.ad.getDuration();d!=-1&&e!=-1&&isFinite(d)&&isFinite(e)?d>0?(d=shaka.ui.Utils.buildTimeString(e-
d,!1),e=shaka.ui.Utils.buildTimeString(e,!1),e=d+" / "+e,b=c>1?b+("\u00a0\u00a0"+e):this.localization.resolve(a.AD_TIME).replace("[AD_TIME]",e),this.adInfo_.textContent=b,shaka.ui.Utils.setDisplay(this.adInfo_,b!="")):this.reset_():(this.adInfo_.textContent=b,shaka.ui.Utils.setDisplay(this.adInfo_,b!=""))}};shaka.ui.AdInfo.prototype.reset_=function(){this.timer_.stop();this.adInfo_.textContent=""};shaka.ui.AdInfo.prototype.release=function(){this.timer_.stop();this.timer_=null;shaka.ui.Element.prototype.release.call(this)};
goog.exportSymbol("shaka.ui.AdInfo",shaka.ui.AdInfo);shaka.ui.ContextMenu=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.config_=this.controls.getConfig();this.controlsContainer_=this.controls.getControlsContainer();this.children_=[];this.contextMenu_=shaka.util.Dom.createHTMLElement("div");this.contextMenu_.classList.add("shaka-no-propagation");this.contextMenu_.classList.add("shaka-context-menu");this.contextMenu_.classList.add("shaka-hidden");this.controlsContainer_.appendChild(this.contextMenu_);this.eventManager.listen(this.controlsContainer_,
"contextmenu",function(d){if(c.contextMenu_.classList.contains("shaka-hidden")){d.preventDefault();var e=c.controlsContainer_.getBoundingClientRect();c.contextMenu_.style.left=d.clientX-e.left+"px";c.contextMenu_.style.top=d.clientY-e.top+"px";shaka.ui.Utils.setDisplay(c.contextMenu_,!0)}else shaka.ui.Utils.setDisplay(c.contextMenu_,!1)});this.eventManager.listen(window,"click",function(){shaka.ui.Utils.setDisplay(c.contextMenu_,!1)});this.eventManager.listen(this.contextMenu_,"click",function(){shaka.ui.Utils.setDisplay(c.contextMenu_,
!1)});this.eventManager.listen(document,"click",function(d){!c.controlsContainer_||c.contextMenu_.classList.contains("shaka-hidden")||c.controlsContainer_.contains(d.target)||c.closeMenu()});this.createChildren_()};$jscomp.inherits(shaka.ui.ContextMenu,shaka.ui.Element);shaka.ui.ContextMenu.prototype.release=function(){this.controlsContainer_=null;for(var a=(0,$jscomp.makeIterator)(this.children_),b=a.next();!b.done;b=a.next())b.value.release();this.children_=[];shaka.ui.Element.prototype.release.call(this)};
shaka.ui.ContextMenu.prototype.closeMenu=function(){shaka.ui.Utils.setDisplay(this.contextMenu_,!1)};shaka.ui.ContextMenu.registerElement=function(a,b){shaka.ui.ContextMenu.elementNamesToFactories_.set(a,b)};
shaka.ui.ContextMenu.prototype.createChildren_=function(){for(var a=(0,$jscomp.makeIterator)(this.config_.contextMenuElements),b=a.next();!b.done;b=a.next()){b=b.value;var c=shaka.ui.ContextMenu.elementNamesToFactories_.get(b);c?(goog.asserts.assert(this.controls,"Controls should not be null!"),this.children_.push(c.create(this.contextMenu_,this.controls))):shaka.log.alwaysWarn("Unrecognized context menu element:",b)}};goog.exportSymbol("shaka.ui.ContextMenu",shaka.ui.ContextMenu);
goog.exportProperty(shaka.ui.ContextMenu,"registerElement",shaka.ui.ContextMenu.registerElement);goog.exportProperty(shaka.ui.ContextMenu.prototype,"closeMenu",shaka.ui.ContextMenu.prototype.closeMenu);shaka.ui.ContextMenu.elementNamesToFactories_=new Map;shaka.ui.PlayButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.button=shaka.util.Dom.createButton();this.parent.appendChild(this.button);this.icon_=new shaka.ui.MaterialSVGIcon(this.button);this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel()});this.eventManager.listen(this.video,"play",function(){c.updateAriaLabel();
c.updateIcon()});this.eventManager.listen(this.video,"pause",function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.video,"seeking",function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.player,"loaded",function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_PAUSED,function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_RESUMED,function(){c.updateAriaLabel();
c.updateIcon()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.updateAriaLabel();c.updateIcon()});this.eventManager.listen(this.button,"click",function(){c.controls.isOpaque()&&c.controls.playPausePresentation()});this.updateAriaLabel();this.updateIcon()};$jscomp.inherits(shaka.ui.PlayButton,shaka.ui.Element);
shaka.ui.PlayButton.prototype.isPaused=function(){return this.ad&&this.ad.isLinear()?this.ad.isPaused():this.controls.presentationIsPaused()};shaka.ui.PlayButton.prototype.isEnded=function(){return this.ad&&this.ad.isLinear()?!1:this.player?this.player.isEnded():!0};
shaka.ui.PlayButton.prototype.updateAriaLabel=function(){var a=shaka.ui.Locales.Ids;this.isEnded()&&this.video.duration?this.button.ariaLabel=this.localization.resolve(a.REPLAY):(a=this.isPaused()?a.PLAY:a.PAUSE,this.button.ariaLabel=this.localization.resolve(a))};shaka.ui.PlayButton.prototype.updateIcon=function(){var a=shaka.ui.Enums.MaterialDesignSVGIcons;this.isEnded()&&this.video.duration?this.icon_.use(a.REPLAY):this.icon_.use(this.isPaused()?a.PLAY:a.PAUSE)};
goog.exportSymbol("shaka.ui.PlayButton",shaka.ui.PlayButton);shaka.ui.BigPlayButton=function(a,b){shaka.ui.PlayButton.call(this,a,b);this.button.classList.add("shaka-play-button");this.button.classList.add("shaka-no-propagation")};$jscomp.inherits(shaka.ui.BigPlayButton,shaka.ui.PlayButton);shaka.ui.BigPlayButton.prototype.updateIcon=function(){this.isEnded()&&this.video.duration?this.button.setAttribute("icon","replay"):this.isPaused()?this.button.setAttribute("icon","play"):this.button.setAttribute("icon","pause")};
goog.exportSymbol("shaka.ui.BigPlayButton",shaka.ui.BigPlayButton);shaka.ui.HiddenSeekButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.lastTouchEventTimeSet_=null;this.hasMoved_=this.triggeredTouchValid_=!1;this.touchStartY_=this.touchStartX_=null;this.hideSeekButtonContainerTimer_=new shaka.util.Timer(function(){if(parseInt(c.seekValue_.textContent,10)===0)c.controls.onContainerClick(!0);c.hideSeekButtonContainer_()});this.seekContainer=shaka.util.Dom.createHTMLElement("div");this.seekContainer.classList.add("shaka-no-propagation");this.parent.appendChild(this.seekContainer);
this.seekValue_=shaka.util.Dom.createHTMLElement("span");this.seekValue_.textContent="0s";this.seekContainer.appendChild(this.seekValue_);this.seekIcon=new shaka.ui.MaterialSVGIcon(this.seekContainer);this.seekIcon.getSvgElement().classList.add("shaka-forward-rewind-container-icon");this.isRewind=!1;this.eventManager.listen(this.seekContainer,"touchstart",function(d){c.onTouchStart_(d)});this.eventManager.listen(this.seekContainer,"touchmove",function(d){c.onTouchMove_(d)});this.eventManager.listen(this.seekContainer,
"touchend",function(d){c.onTouchEnd_(d)})};$jscomp.inherits(shaka.ui.HiddenSeekButton,shaka.ui.Element);shaka.ui.HiddenSeekButton.prototype.onTouchStart_=function(a){a.touches.length>0&&(this.touchStartX_=a.touches[0].clientX,this.touchStartY_=a.touches[0].clientY);this.hasMoved_=!1};
shaka.ui.HiddenSeekButton.prototype.onTouchMove_=function(a){if(a.touches.length>0&&this.touchStartX_!=null&&this.touchStartY_!=null){var b=a.touches[0].clientX-this.touchStartX_;a=a.touches[0].clientY-this.touchStartY_;Math.sqrt(b*b+a*a)>shaka.ui.HiddenSeekButton.SCROLL_THRESHOLD_&&(this.hasMoved_=!0)}};
shaka.ui.HiddenSeekButton.prototype.onTouchEnd_=function(a){this.hasMoved_||(this.controls.anySettingsMenusAreOpen()?(a.preventDefault(),this.controls.hideSettingsMenus()):!(this.controls.getConfig().tapSeekDistance>0)||this.ad&&this.ad.isLinear()||(a.preventDefault(),this.onSeekButtonClick_()))};
shaka.ui.HiddenSeekButton.prototype.onSeekButtonClick_=function(){var a=this.controls.getConfig().tapSeekDistance,b=shaka.ui.HiddenSeekButton.DOUBLE_TAP_WINDOW_;if(!this.triggeredTouchValid_)this.triggeredTouchValid_=!0,this.lastTouchEventTimeSet_=Date.now(),this.hideSeekButtonContainerTimer_.tickAfter(b);else if(this.lastTouchEventTimeSet_+b*1E3>Date.now()){this.hideSeekButtonContainerTimer_.stop();this.lastTouchEventTimeSet_=Date.now();var c=parseInt(this.seekValue_.textContent,10);c=this.isRewind?
c-a:c+a;this.seekValue_.textContent=c.toString()+"s";this.seekContainer.style.opacity="1";this.hideSeekButtonContainerTimer_.tickAfter(b)}};shaka.ui.HiddenSeekButton.prototype.hideSeekButtonContainer_=function(){var a=parseInt(this.seekValue_.textContent,10);a!==0&&(this.video.currentTime=this.controls.getDisplayTime()+a);this.seekContainer.style.opacity="0";this.triggeredTouchValid_=!1;this.seekValue_.textContent="0s"};goog.exportSymbol("shaka.ui.HiddenSeekButton",shaka.ui.HiddenSeekButton);
shaka.ui.HiddenSeekButton.DOUBLE_TAP_WINDOW_=.5;shaka.ui.HiddenSeekButton.SCROLL_THRESHOLD_=10;shaka.ui.HiddenFastForwardButton=function(a,b){shaka.ui.HiddenSeekButton.call(this,a,b);this.seekContainer.classList.add("shaka-fast-forward-container");this.seekIcon.use(shaka.ui.Enums.MaterialDesignSVGIcons.FAST_FORWARD);this.isRewind=!1};$jscomp.inherits(shaka.ui.HiddenFastForwardButton,shaka.ui.HiddenSeekButton);goog.exportSymbol("shaka.ui.HiddenFastForwardButton",shaka.ui.HiddenFastForwardButton);shaka.ui.HiddenRewindButton=function(a,b){shaka.ui.HiddenSeekButton.call(this,a,b);this.seekContainer.classList.add("shaka-rewind-container");this.seekIcon.use(shaka.ui.Enums.MaterialDesignSVGIcons.REWIND);this.isRewind=!0};$jscomp.inherits(shaka.ui.HiddenRewindButton,shaka.ui.HiddenSeekButton);goog.exportSymbol("shaka.ui.HiddenRewindButton",shaka.ui.HiddenRewindButton);shaka.ui.RangeElement=function(a,b,c,d){shaka.ui.Element.call(this,a,b);var e=this;this.container=shaka.util.Dom.createHTMLElement("div");this.container.classList.add("shaka-range-container");this.container.classList.add.apply(this.container.classList,(0,$jscomp.arrayFromIterable)(c));this.isMouseChanging_=this.isChanging_=!1;this.bar=document.createElement("input");this.endFakeChangeTimer_=new shaka.util.Timer(function(){e.onChangeEnd();e.isChanging_=!1});this.bar.classList.add("shaka-range-element");
this.bar.classList.add.apply(this.bar.classList,(0,$jscomp.arrayFromIterable)(d));this.bar.type="range";this.bar.step="any";this.bar.min="0";this.bar.max="1";this.bar.value="0";this.bar.disabled=!this.controls.isOpaque();this.container.appendChild(this.bar);this.parent.appendChild(this.container);this.showingUITimer_=new shaka.util.Timer(function(){e.bar.disabled=!1});this.eventManager.listen(this.controls,"showingui",function(){e.showingUITimer_.tickAfter(0)});this.eventManager.listen(this.controls,
"hidingui",function(){e.showingUITimer_.stop();e.bar.disabled=!0});this.eventManager.listen(this.bar,"mousedown",function(f){e.bar.disabled||(f.preventDefault(),e.bar.focus(),e.isChanging_=!0,e.isMouseChanging_=!0,e.setBarValueForMouse_(f),e.onChangeStart(),e.onChange(),f.stopPropagation())});this.eventManager.listen(document,"mousemove",function(f){e.isMouseChanging_&&(e.setBarValueForMouse_(f),e.onChange())});this.eventManager.listen(document,"mouseup",function(f){e.isMouseChanging_&&(e.isMouseChanging_=
!1,e.isChanging_&&(e.isChanging_=!1,e.setBarValueForMouse_(f),e.onChangeEnd()))});this.eventManager.listen(this.bar,"touchstart",function(f){e.bar.disabled||(e.isChanging_=!0,e.setBarValueForTouch_(f),e.onChangeStart(),f.stopPropagation())});this.eventManager.listen(this.bar,"input",function(){e.onChange()});this.eventManager.listen(this.bar,"touchmove",function(f){e.isChanging_&&(e.setBarValueForTouch_(f),e.onChange(),f.stopPropagation())});this.eventManager.listen(this.bar,"touchend",function(f){e.isChanging_&&
(e.isChanging_=!1,e.setBarValueForTouch_(f),e.onChangeEnd(),f.stopPropagation())});this.eventManager.listen(this.bar,"touchcancel",function(f){e.isChanging_&&(e.isChanging_=!1,e.setBarValueForTouch_(f),e.onChangeEnd(),f.stopPropagation())});this.eventManager.listen(this.bar,"mouseup",function(f){e.isChanging_&&(e.isChanging_=!1,e.isMouseChanging_=!1,e.setBarValueForMouse_(f),e.onChangeEnd(),f.stopPropagation())});this.eventManager.listen(this.bar,"blur",function(){e.isChanging_&&(e.isChanging_=!1,
e.isMouseChanging_=!1,e.onChangeEnd())});this.eventManager.listen(this.bar,"contextmenu",function(f){f.preventDefault();f.stopPropagation()})};$jscomp.inherits(shaka.ui.RangeElement,shaka.ui.Element);shaka.ui.RangeElement.prototype.release=function(){this.endFakeChangeTimer_&&(this.endFakeChangeTimer_.stop(),this.endFakeChangeTimer_=null);shaka.ui.Element.prototype.release.call(this)};shaka.ui.RangeElement.prototype.setRange=function(a,b){this.bar.min=a;this.bar.max=b};
shaka.ui.RangeElement.prototype.onChangeStart=function(){};shaka.ui.RangeElement.prototype.onChange=function(){};shaka.ui.RangeElement.prototype.onChangeEnd=function(){};shaka.ui.RangeElement.prototype.changeTo=function(a){this.isChanging_||(this.isChanging_=!0,this.onChangeStart());var b=parseFloat(this.bar.min),c=parseFloat(this.bar.max);this.bar.value=a>c?c:a<b?b:a;this.onChange();this.endFakeChangeTimer_.tickAfter(.5)};shaka.ui.RangeElement.prototype.getValue=function(){return parseFloat(this.bar.value)};
shaka.ui.RangeElement.prototype.setValue=function(a){this.isChanging_||(this.bar.value=a)};shaka.ui.RangeElement.prototype.getValueFromPosition=function(a){var b=this.bar.getBoundingClientRect(),c=parseFloat(this.bar.min),d=parseFloat(this.bar.max),e=parseFloat(this.bar.step)||1,f=b.left+6;b=b.right-6;a=c+(Math.max(f,Math.min(b,a))-f)/(b-f)*(d-c);a=Math.round((a-c)/e)*e+c;return a=Math.min(d,Math.max(c,a))};shaka.ui.RangeElement.prototype.setBarValueForMouse_=function(a){this.bar.value=this.getValueFromPosition(a.clientX)};
shaka.ui.RangeElement.prototype.setBarValueForTouch_=function(a){a.preventDefault();this.bar.value=this.getValueFromPosition(a.changedTouches[0].clientX)};goog.exportSymbol("shaka.ui.RangeElement",shaka.ui.RangeElement);goog.exportProperty(shaka.ui.RangeElement.prototype,"setValue",shaka.ui.RangeElement.prototype.setValue);goog.exportProperty(shaka.ui.RangeElement.prototype,"getValue",shaka.ui.RangeElement.prototype.getValue);goog.exportProperty(shaka.ui.RangeElement.prototype,"changeTo",shaka.ui.RangeElement.prototype.changeTo);
goog.exportProperty(shaka.ui.RangeElement.prototype,"onChangeEnd",shaka.ui.RangeElement.prototype.onChangeEnd);goog.exportProperty(shaka.ui.RangeElement.prototype,"onChange",shaka.ui.RangeElement.prototype.onChange);goog.exportProperty(shaka.ui.RangeElement.prototype,"onChangeStart",shaka.ui.RangeElement.prototype.onChangeStart);goog.exportProperty(shaka.ui.RangeElement.prototype,"setRange",shaka.ui.RangeElement.prototype.setRange);shaka.ui.SeekBar=function(a,b){shaka.ui.RangeElement.call(this,a,b,["shaka-seek-bar-container"],["shaka-seek-bar","shaka-no-propagation","shaka-show-controls-on-mouse-over"]);var c=this;this.adMarkerContainer_=shaka.util.Dom.createHTMLElement("div");this.adMarkerContainer_.classList.add("shaka-ad-markers");this.container.insertBefore(this.adMarkerContainer_,this.container.childNodes[0]);this.config_=this.controls.getConfig();this.seekTimer_=new shaka.util.Timer(function(){var d=c.getValue();c.player.isLive()||
d==c.video.duration&&(d-=.001);c.video.currentTime=d});this.adBreaksTimer_=new shaka.util.Timer(function(){c.markAdBreaks_()});this.wasPlaying_=!1;this.thumbnailContainer_=shaka.util.Dom.createHTMLElement("div");this.thumbnailContainer_.id="shaka-player-ui-thumbnail-container";this.thumbnailImage_=shaka.util.Dom.createHTMLElement("img");this.thumbnailImage_.id="shaka-player-ui-thumbnail-image";this.thumbnailImage_.draggable=!1;this.thumbnailTimeContainer_=shaka.util.Dom.createHTMLElement("div");this.thumbnailTimeContainer_.id=
"shaka-player-ui-thumbnail-time-container";this.thumbnailTime_=shaka.util.Dom.createHTMLElement("div");this.thumbnailTime_.id="shaka-player-ui-thumbnail-time";this.thumbnailTimeContainer_.appendChild(this.thumbnailTime_);this.thumbnailContainer_.appendChild(this.thumbnailImage_);this.thumbnailContainer_.appendChild(this.thumbnailTimeContainer_);this.container.appendChild(this.thumbnailContainer_);this.timeContainer_=shaka.util.Dom.createHTMLElement("div");this.timeContainer_.id="shaka-player-ui-time-container";
this.container.appendChild(this.timeContainer_);this.lastThumbnailPendingRequest_=this.lastThumbnail_=null;this.isMoving_=!1;this.hideThumbnailTimer_=new shaka.util.Timer(function(){c.hideThumbnail_()});this.adCuePoints_=[];this.eventManager.listen(this.bar,"input",function(){c.controls.hideSettingsMenus()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){return c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,
function(){return c.updateAriaLabel_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.shouldBeDisplayed_()||shaka.ui.Utils.setDisplay(c.container,!1)});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.shouldBeDisplayed_()&&shaka.ui.Utils.setDisplay(c.container,!0)});this.eventManager.listen(this.adManager,shaka.ads.Utils.CUEPOINTS_CHANGED,function(d){c.adCuePoints_=d.cuepoints;c.onAdCuePointsChanged_()});this.eventManager.listen(this.player,
"unloading",function(){c.adCuePoints_=[];c.onAdCuePointsChanged_();c.lastThumbnailPendingRequest_&&(c.lastThumbnailPendingRequest_.abort(),c.lastThumbnailPendingRequest_=null);c.lastThumbnail_=null;c.hideThumbnail_();c.hideTime_()});this.eventManager.listen(this.bar,"mousemove",function(d){if(c.controls.anySettingsMenusAreOpen())c.hideTime_(),c.hideThumbnail_();else{var e=c.getValueFromPosition(d.clientX),f=c.bar.getBoundingClientRect();d=Math.max(0,d.clientX-f.left);c.player.getImageTracks().length?
(c.hideTime_(),c.showThumbnail_(d,e)):(c.hideThumbnail_(),c.showTime_(d,e))}});this.eventManager.listen(this.container,"mouseleave",function(){c.hideTime_();c.hideThumbnailTimer_.stop();c.hideThumbnailTimer_.tickAfter(.25)});this.setValue(this.video.currentTime);this.update();this.updateAriaLabel_();this.ad&&shaka.ui.Utils.setDisplay(this.container,!1)};$jscomp.inherits(shaka.ui.SeekBar,shaka.ui.RangeElement);
shaka.ui.SeekBar.prototype.release=function(){this.seekTimer_&&(this.seekTimer_.stop(),this.seekTimer_=null,this.adBreaksTimer_.stop(),this.adBreaksTimer_=null);shaka.ui.RangeElement.prototype.release.call(this)};shaka.ui.SeekBar.prototype.onChangeStart=function(){this.wasPlaying_=!this.video.paused;this.controls.setSeeking(!0);this.video.pause();this.hideThumbnailTimer_.stop();this.isMoving_=!0};
shaka.ui.SeekBar.prototype.onChange=function(){if(this.video.duration)if(this.update(),this.seekTimer_.tickAfter(.125),this.player.getImageTracks().length&&!this.controls.anySettingsMenusAreOpen()){var a=parseFloat(this.bar.min),b=parseFloat(this.bar.max),c=this.bar.getBoundingClientRect(),d=Math.round(this.getValue());this.showThumbnail_((d-a)/((b-a)/c.width),d)}else this.hideThumbnail_()};
shaka.ui.SeekBar.prototype.onChangeEnd=function(){this.seekTimer_.tickNow();this.controls.setSeeking(!1);this.wasPlaying_&&this.video.play();this.isMoving_&&(this.isMoving_=!1,this.hideThumbnailTimer_.stop(),this.hideThumbnailTimer_.tickAfter(.25))};shaka.ui.SeekBar.prototype.isShowing=function(){return!this.container.classList.contains("shaka-hidden")};
shaka.ui.SeekBar.prototype.update=function(){var a=this.config_.seekBarColors,b=this.getValue(),c=this.video.buffered.length,d=c?this.video.buffered.start(0):0,e=c?this.video.buffered.end(c-1):0;c=this.player.seekRange();var f=c.end-c.start;this.setRange(c.start,c.end);this.shouldBeDisplayed_()?(shaka.ui.Utils.setDisplay(this.container,!0),d=(Math.max(d,c.start)-c.start)/f||0,e=(Math.min(e,c.end)-c.start)/f||0,b=(Math.min(Math.max(b,c.start),c.end)-c.start)/f||0,a=["to right",this.makeColor_(this.config_.showUnbufferedStart?
a.base:a.played,d),this.makeColor_(a.played,d),this.makeColor_(a.played,b),this.makeColor_(a.buffered,b),this.makeColor_(a.buffered,e),this.makeColor_(a.base,e)],this.container.style.background="linear-gradient("+a.join(",")+")"):shaka.ui.Utils.setDisplay(this.container,!1)};
shaka.ui.SeekBar.prototype.markAdBreaks_=function(){if(this.adCuePoints_.length){for(var a=this.player.seekRange(),b=a.end-a.start,c=["to right"],d=[],e=this.config_.seekBarColors.adBreaks,f=!1,g=(0,$jscomp.makeIterator)(this.adCuePoints_),h=g.next();!h.done;h=g.next())if(h=h.value,h.start==-1&&!h.end)f=!0;else if(!h.end&&h.start>=a.start||typeof h.end=="number"&&h.end>a.start){var k=(Math.max(h.start,a.start)-a.start)/b||0,l=k+.01;h.end&&(l=(h.end-a.start)/b||0);d.push({start:k,end:l})}d=d.sort(function(m,
n){return m.start-n.start});a=(0,$jscomp.makeIterator)(d);for(b=a.next();!b.done;b=a.next())b=b.value,c.push(this.makeColor_("transparent",b.start)),c.push(this.makeColor_(e,b.start)),c.push(this.makeColor_(e,b.end)),c.push(this.makeColor_("transparent",b.end));f&&(c.push(this.makeColor_("transparent",.99)),c.push(this.makeColor_(e,.99)));this.adMarkerContainer_.style.background="linear-gradient("+c.join(",")+")"}else this.adMarkerContainer_.style.background="transparent",this.adBreaksTimer_.stop()};
shaka.ui.SeekBar.prototype.makeColor_=function(a,b){return a+" "+b*100+"%"};shaka.ui.SeekBar.prototype.onAdCuePointsChanged_=function(){var a=this,b=function(){a.markAdBreaks_();var c=a.player.seekRange();c=c.end-c.start;var d=shaka.ui.SeekBar.MIN_SEEK_WINDOW_TO_SHOW_SEEKBAR_;a.player.isLive()&&c>d&&a.adBreaksTimer_.tickEvery(.25)};b();this.player.isFullyLoaded()||this.eventManager.listenOnce(this.player,"loaded",b)};
shaka.ui.SeekBar.prototype.shouldBeDisplayed_=function(){var a=this.player.seekRange();a=a.end-a.start;return this.player.isLive()&&(a<shaka.ui.SeekBar.MIN_SEEK_WINDOW_TO_SHOW_SEEKBAR_||!isFinite(a))?!1:this.ad==null||!this.ad.isLinear()};shaka.ui.SeekBar.prototype.updateAriaLabel_=function(){this.bar.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.SEEK)};
shaka.ui.SeekBar.prototype.showTime_=function(a,b){var c=this.timeContainer_.clientWidth;this.timeContainer_.style.width="auto";this.timeContainer_.style.height="20px";this.timeContainer_.style.top="-30px";this.timeContainer_.style.left=Math.min(this.bar.offsetWidth-c,Math.max(0,a-c/2))+"px";this.timeContainer_.style.right="";this.timeContainer_.style.visibility="visible";a=this.player.seekRange();this.player.isLive()?(b=a.end-b,b<1?(this.timeContainer_.textContent=this.localization.resolve(shaka.ui.Locales.Ids.LIVE),
this.timeContainer_.style.left="",this.timeContainer_.style.right="0px"):this.timeContainer_.textContent="-"+this.timeFormatter_(b)):this.timeContainer_.textContent=this.timeFormatter_(b-a.start)};
shaka.ui.SeekBar.prototype.showThumbnail_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(B){switch(B.getNextAddressJsc()){case 1:b<0&&(b=0);d=!1;c.adCuePoints_.length&&(d=c.adCuePoints_.some(function(D){return D.end?b>=D.start&&b<=D.end:!1}));if(d)return c.hideThumbnail_(),c.showTime_(a,b),B.return();e=c.player.seekRange();f=Math.max(Math.ceil(e.start),Math.min(Math.floor(e.end),b));c.player.isLive()?(g=e.end-b,c.thumbnailTime_.textContent=
g<1?c.localization.resolve(shaka.ui.Locales.Ids.LIVE):"-"+c.timeFormatter_(g)):c.thumbnailTime_.textContent=c.timeFormatter_(b);h=-10;k=c.thumbnailContainer_.clientWidth;l=Math.floor(k*9/16);c.thumbnailContainer_.style.height=l+"px";c.thumbnailContainer_.style.top=-(l-h)+"px";m=Math.min(c.bar.offsetWidth-k,Math.max(0,a-k/2));c.thumbnailContainer_.style.left=m+"px";return B.yield(c.player.getThumbnails(null,f),2);case 2:n=B.getYieldResultJsc();if(!n||!n.uris||!n.uris.length)return c.hideThumbnail_(),
c.showTime_(a,b),B.return();n.width<n.height?c.thumbnailContainer_.classList.add("portrait-thumbnail"):c.thumbnailContainer_.classList.remove("portrait-thumbnail");c.thumbnailContainer_.style.visibility="visible";p=n.uris[0].split("#xywh=")[0];if(c.lastThumbnail_&&p===c.lastThumbnail_.uris[0].split("#xywh=")[0]&&n.startByte==c.lastThumbnail_.startByte&&n.endByte==c.lastThumbnail_.endByte){B.jumpTo(3);break}c.lastThumbnail_=n;c.lastThumbnailPendingRequest_&&(c.lastThumbnailPendingRequest_.abort(),
c.lastThumbnailPendingRequest_=null);if(n.codecs!="mjpg"&&!p.startsWith("offline:")){B.jumpTo(4);break}c.thumbnailImage_.src=shaka.ui.SeekBar.Transparent_Image_;B.setCatchFinallyBlocks(5);q=shaka.net.NetworkingEngine.RequestType.SEGMENT;r=shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT;t=shaka.net.NetworkingUtils.createSegmentRequest(n.uris,n.startByte,n.endByte,c.player.getConfiguration().streaming.retryParameters);c.lastThumbnailPendingRequest_=c.player.getNetworkingEngine().request(q,
t,{type:r});return B.yield(c.lastThumbnailPendingRequest_.promise,7);case 7:u=B.getYieldResultJsc();c.lastThumbnailPendingRequest_=null;n.codecs=="mjpg"?(w=(new shaka.util.Mp4Parser).box("mdat",shaka.util.Mp4Parser.allData(function(D){D=new Blob([D],{type:"image/jpeg"});p=URL.createObjectURL(D)},!0)),w.parse(u.data,!1)):(v=n.mimeType||"image/jpeg",x=new Blob([u.data],{type:v}),p=URL.createObjectURL(x));B.leaveTryBlock(4);break;case 5:y=B.enterCatchBlock();if(y.code==shaka.util.Error.Code.OPERATION_ABORTED)return B.return();
throw y;case 4:try{c.thumbnailContainer_.removeChild(c.thumbnailImage_)}catch(D){}c.thumbnailImage_=shaka.util.Dom.createHTMLElement("img");c.thumbnailImage_.id="shaka-player-ui-thumbnail-image";c.thumbnailImage_.draggable=!1;c.thumbnailImage_.src=p;c.thumbnailImage_.onload=function(){p.startsWith("blob:")&&URL.revokeObjectURL(p)};c.thumbnailContainer_.insertBefore(c.thumbnailImage_,c.thumbnailContainer_.firstChild);case 3:A=k/n.width,n.imageHeight?c.thumbnailImage_.height=n.imageHeight:n.sprite||
(c.thumbnailImage_.style.height="100%",c.thumbnailImage_.style.objectFit="contain"),n.imageWidth?c.thumbnailImage_.width=n.imageWidth:n.sprite||(c.thumbnailImage_.style.width="100%",c.thumbnailImage_.style.objectFit="contain"),c.thumbnailImage_.style.left="-"+A*n.positionX+"px",c.thumbnailImage_.style.top="-"+A*n.positionY+"px",c.thumbnailImage_.style.transform="scale("+A+")",c.thumbnailImage_.style.transformOrigin="left top",l=Math.floor(k*n.height/n.width),c.thumbnailContainer_.style.height=l+"px",
c.thumbnailContainer_.style.top=-(l-h)+"px",B.jumpToEnd()}})};shaka.ui.SeekBar.prototype.hideThumbnail_=function(){this.thumbnailContainer_.style.visibility="hidden"};shaka.ui.SeekBar.prototype.hideTime_=function(){this.timeContainer_.style.visibility="hidden"};shaka.ui.SeekBar.prototype.timeFormatter_=function(a){return shaka.ui.Utils.buildTimeString(a,a>=3600)};goog.exportSymbol("shaka.ui.SeekBar",shaka.ui.SeekBar);shaka.ui.SeekBar.Transparent_Image_='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>';
shaka.ui.SeekBar.MIN_SEEK_WINDOW_TO_SHOW_SEEKBAR_=5;shaka.ui.SeekBar.Factory=function(){};shaka.ui.SeekBar.Factory.prototype.create=function(a,b){return new shaka.ui.SeekBar(a,b)};goog.exportProperty(shaka.ui.SeekBar,"Factory",shaka.ui.SeekBar.Factory);shaka.ui.SkipAdButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.container_=shaka.util.Dom.createHTMLElement("div");this.container_.classList.add("shaka-skip-ad-container");this.parent.appendChild(this.container_);this.counter_=shaka.util.Dom.createHTMLElement("div");this.counter_.classList.add("shaka-skip-ad-counter");shaka.ui.Utils.setDisplay(this.counter_,!1);this.container_.appendChild(this.counter_);this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-skip-ad-button");
this.button_.disabled=!0;shaka.ui.Utils.setDisplay(this.button_,!1);this.button_.classList.add("shaka-no-propagation");this.container_.appendChild(this.button_);this.updateAriaLabel_();this.updateLocalizedStrings_();this.timer_=new shaka.util.Timer(function(){c.onTimerTick_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_();c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,
function(){c.updateAriaLabel_();c.updateLocalizedStrings_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.onAdStarted_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_SKIP_STATE_CHANGED,function(){c.onSkipStateChanged_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.reset_()});this.eventManager.listen(this.button_,"click",function(){c.ad.skip()});if(this.ad)this.onAdStarted_()};
$jscomp.inherits(shaka.ui.SkipAdButton,shaka.ui.Element);shaka.ui.SkipAdButton.prototype.release=function(){this.timer_.stop();this.timer_=null;shaka.ui.Element.prototype.release.call(this)};shaka.ui.SkipAdButton.prototype.updateLocalizedStrings_=function(){this.button_.textContent=this.localization.resolve(shaka.ui.Locales.Ids.SKIP_AD)};shaka.ui.SkipAdButton.prototype.updateAriaLabel_=function(){};
shaka.ui.SkipAdButton.prototype.onAdStarted_=function(){this.ad.isSkippable()&&this.ad.needsSkipUI()&&(shaka.ui.Utils.setDisplay(this.button_,!0),shaka.ui.Utils.setDisplay(this.counter_,!0),this.counter_.textContent="",this.timer_.tickNow(),this.timer_.tickEvery(.5))};
shaka.ui.SkipAdButton.prototype.onTimerTick_=function(){goog.asserts.assert(this.ad!=null,"this.ad should exist at this point");if(this.ad.isSkippable()){var a=Math.round(this.ad.getTimeUntilSkippable());a>0?this.counter_.textContent=a:(this.timer_.stop(),shaka.ui.Utils.setDisplay(this.counter_,!1))}else this.reset_()};
shaka.ui.SkipAdButton.prototype.onSkipStateChanged_=function(){this.ad.isSkippable()?this.ad.canSkipNow()&&(this.button_.disabled=!1,this.timer_.stop(),shaka.ui.Utils.setDisplay(this.counter_,!1)):this.reset_()};shaka.ui.SkipAdButton.prototype.reset_=function(){this.timer_.stop();this.button_.disabled=!0;shaka.ui.Utils.setDisplay(this.button_,!1);shaka.ui.Utils.setDisplay(this.counter_,!1)};goog.exportSymbol("shaka.ui.SkipAdButton",shaka.ui.SkipAdButton);/*
 @license
 glMatrix: https://github.com/toji/gl-matrix/
 Copyright 2015-2021, Brandon Jones, Colin MacKenzie IV
 SPDX-License-Identifier: MIT
*/
shaka.ui.Matrix4x4=function(){};shaka.ui.Matrix4x4.create=function(){var a=new Float32Array(16);a[0]=1;a[5]=1;a[10]=1;a[15]=1;return a};
shaka.ui.Matrix4x4.lookAt=function(a,b,c,d){var e=b[0],f=b[1];b=b[2];var g=d[0];var h=d[1];var k=d[2];var l=c[0];d=c[1];var m=c[2];if(Math.abs(e-l)<shaka.ui.Matrix4x4.EPSILON_&&Math.abs(f-d)<shaka.ui.Matrix4x4.EPSILON_&&Math.abs(b-m)<shaka.ui.Matrix4x4.EPSILON_)return shaka.ui.Matrix4x4.identity_(a);c=e-l;d=f-d;l=b-m;var n=1/Math.sqrt(c*c+d*d+l*l);c*=n;d*=n;l*=n;m=h*l-k*d;k=k*c-g*l;g=g*d-h*c;(n=Math.sqrt(m*m+k*k+g*g))?(n=1/n,m*=n,k*=n,g*=n):g=k=m=0;h=d*g-l*k;var p=l*m-c*g;var q=c*k-d*m;(n=Math.sqrt(h*
h+p*p+q*q))?(n=1/n,h*=n,p*=n,q*=n):q=p=h=0;a[0]=m;a[1]=h;a[2]=c;a[3]=0;a[4]=k;a[5]=p;a[6]=d;a[7]=0;a[8]=g;a[9]=q;a[10]=l;a[11]=0;a[12]=-(m*e+k*f+g*b);a[13]=-(h*e+p*f+q*b);a[14]=-(c*e+d*f+l*b);a[15]=1;return a};shaka.ui.Matrix4x4.scale=function(a,b,c){var d=c[0],e=c[1];c=c[2];a[0]=b[0]*d;a[1]=b[1]*d;a[2]=b[2]*d;a[3]=b[3]*d;a[4]=b[4]*e;a[5]=b[5]*e;a[6]=b[6]*e;a[7]=b[7]*e;a[8]=b[8]*c;a[9]=b[9]*c;a[10]=b[10]*c;a[11]=b[11]*c;a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15]};
shaka.ui.Matrix4x4.perspective=function(a,b,c,d,e){b=1/Math.tan(b/2);a[0]=b/c;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[11]=-1;a[12]=0;a[13]=0;a[15]=0;e!=null&&e!==Infinity?(c=1/(d-e),a[10]=(e+d)*c,a[14]=2*e*d*c):(a[10]=-1,a[14]=-2*d);return a};
shaka.ui.Matrix4x4.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],k=b[5],l=b[6],m=b[7],n=b[8],p=b[9],q=b[10],r=b[11],t=b[12],u=b[13],w=b[14];b=b[15];var v=c[0],x=c[1],y=c[2],A=c[3];a[0]=v*d+x*h+y*n+A*t;a[1]=v*e+x*k+y*p+A*u;a[2]=v*f+x*l+y*q+A*w;a[3]=v*g+x*m+y*r+A*b;v=c[4];x=c[5];y=c[6];A=c[7];a[4]=v*d+x*h+y*n+A*t;a[5]=v*e+x*k+y*p+A*u;a[6]=v*f+x*l+y*q+A*w;a[7]=v*g+x*m+y*r+A*b;v=c[8];x=c[9];y=c[10];A=c[11];a[8]=v*d+x*h+y*n+A*t;a[9]=v*e+x*k+y*p+A*u;a[10]=v*f+x*l+y*q+A*w;a[11]=v*g+x*m+
y*r+A*b;v=c[12];x=c[13];y=c[14];A=c[15];a[12]=v*d+x*h+y*n+A*t;a[13]=v*e+x*k+y*p+A*u;a[14]=v*f+x*l+y*q+A*w;a[15]=v*g+x*m+y*r+A*b};shaka.ui.Matrix4x4.frustum=function(a,b,c,d,e,f,g){var h=1/(c-b),k=1/(e-d),l=1/(f-g);a[0]=f*2*h;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=f*2*k;a[6]=0;a[7]=0;a[8]=(c+b)*h;a[9]=(e+d)*k;a[10]=(g+f)*l;a[11]=-1;a[12]=0;a[13]=0;a[14]=g*f*2*l;a[15]=0;return a};
shaka.ui.Matrix4x4.rotateX=function(a,b,c){var d=Math.sin(c);c=Math.cos(c);var e=b[4],f=b[5],g=b[6],h=b[7],k=b[8],l=b[9],m=b[10],n=b[11];b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[4]=e*c+k*d;a[5]=f*c+l*d;a[6]=g*c+m*d;a[7]=h*c+n*d;a[8]=k*c-e*d;a[9]=l*c-f*d;a[10]=m*c-g*d;a[11]=n*c-h*d};
shaka.ui.Matrix4x4.rotateY=function(a,b,c){var d=Math.sin(c);c=Math.cos(c);var e=b[0],f=b[1],g=b[2],h=b[3],k=b[8],l=b[9],m=b[10],n=b[11];b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=e*c-k*d;a[1]=f*c-l*d;a[2]=g*c-m*d;a[3]=h*c-n*d;a[8]=e*d+k*c;a[9]=f*d+l*c;a[10]=g*d+m*c;a[11]=h*d+n*c};
shaka.ui.Matrix4x4.rotateZ=function(a,b,c){var d=Math.sin(c);c=Math.cos(c);var e=b[0],f=b[1],g=b[2],h=b[3],k=b[4],l=b[5],m=b[6],n=b[7];b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=e*c+k*d;a[1]=f*c+l*d;a[2]=g*c+m*d;a[3]=h*c+n*d;a[4]=k*c-e*d;a[5]=l*c-f*d;a[6]=m*c-g*d;a[7]=n*c-h*d};
shaka.ui.Matrix4x4.getRotation=function(a,b){var c=new Float32Array(3);shaka.ui.Matrix4x4.getScaling_(c,b);var d=1/c[0],e=1/c[1],f=1/c[2],g=b[0]*d;c=b[1]*e;var h=b[2]*f,k=b[4]*d,l=b[5]*e,m=b[6]*f;d*=b[8];e*=b[9];b=b[10]*f;f=g+l+b;f>0?(g=Math.sqrt(f+1)*2,a[3]=.25*g,a[0]=(m-e)/g,a[1]=(d-h)/g,a[2]=(c-k)/g):g>l&&g>b?(g=Math.sqrt(1+g-l-b)*2,a[3]=(m-e)/g,a[0]=.25*g,a[1]=(c+k)/g,a[2]=(d+h)/g):l>b?(g=Math.sqrt(1+l-g-b)*2,a[3]=(d-h)/g,a[0]=(c+k)/g,a[1]=.25*g,a[2]=(m+e)/g):(g=Math.sqrt(1+b-g-l)*2,a[3]=(c-k)/
g,a[0]=(d+h)/g,a[1]=(m+e)/g,a[2]=.25*g);return a};shaka.ui.Matrix4x4.fromQuat=function(a,b){var c=b[0],d=b[1],e=b[2];b=b[3];var f=c+c,g=d+d,h=e+e;c*=f;var k=d*f;d*=g;var l=e*f,m=e*g;e*=h;f*=b;g*=b;b*=h;a[0]=1-d-e;a[1]=k+b;a[2]=l-g;a[3]=0;a[4]=k-b;a[5]=1-c-e;a[6]=m+f;a[7]=0;a[8]=l+g;a[9]=m-f;a[10]=1-c-d;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1};shaka.ui.Matrix4x4.identity_=function(a){for(var b=0;b<16;b++)a[b]=b%5==0?1:0;return a};
shaka.ui.Matrix4x4.getScaling_=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[4],g=b[5],h=b[6],k=b[8],l=b[9];b=b[10];a[0]=Math.sqrt(c*c+d*d+e*e);a[1]=Math.sqrt(f*f+g*g+h*h);a[2]=Math.sqrt(k*k+l*l+b*b)};shaka.ui.Matrix4x4.EPSILON_=1E-6;shaka.ui.MatrixQuaternion=function(){};shaka.ui.MatrixQuaternion.create=function(){var a=new Float32Array(4);a[3]=1;return a};shaka.ui.MatrixQuaternion.normalize=function(a,b){var c=b[0],d=b[1],e=b[2];b=b[3];var f=c*c+d*d+e*e+b*b;f>0&&(f=1/Math.sqrt(f));a[0]=c*f;a[1]=d*f;a[2]=e*f;a[3]=b*f};shaka.ui.VRUtils=function(){};shaka.ui.VRUtils.generateSphere=function(a,b){var c=[],d=[],e=[],f=Math.PI;b=(b===void 0?0:b)?f/2:f;for(var g=0;g<=a;g++){var h=g*f/a,k=Math.sin(h);h=Math.cos(h);for(var l=0;l<=a;l++){var m=l*2*b/a;c.push(Math.sin(m)*k,h,Math.cos(m)*k);d.push(l/a,g/a)}}for(f=0;f<a;f++)for(b=0;b<a;b++)g=f*(a+1)+b,k=g+a+1,e.push(g,k,g+1),e.push(k,k+1,g+1);return{vertices:c,textureCoords:d,indices:e}};
shaka.ui.VRUtils.generateCube=function(){return{vertices:[-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1],textureCoords:[2/3,.5,1/3,.5,1/3,0,2/3,0,2/3,.5,2/3,0,1,0,1,.5,1,1,2/3,1,2/3,.5,1,.5,0,.5,0,0,1/3,0,1/3,.5,0,.5,1/3,.5,1/3,1,0,1,1/3,1,1/3,.5,2/3,.5,2/3,1],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}};
shaka.ui.VRUtils.VERTEX_SPHERE_SHADER="attribute vec4 a_vPosition;\n// Per-vertex texture coordinate info\nattribute vec2 a_TexCoordinate;\nuniform mat4 u_VPMatrix;\n// Passed into the fragment shader.\nvarying vec2 v_TexCoordinate;\nvarying vec3 pass_position;\nvoid main()\n{\n gl_Position = u_VPMatrix * a_vPosition;\n // Pass through texture coord\n v_TexCoordinate = a_TexCoordinate;\n pass_position = a_vPosition.xyz;\n}";shaka.ui.VRUtils.FRAGMENT_SPHERE_SHADER="precision highp float;\n#define PI 3.141592653589793238462643383279\nvarying vec2 v_TexCoordinate;\nvarying vec3 pass_position;\nuniform sampler2D uSampler;\nvoid main(void) {\nhighp float xValue =\n      (PI + atan(pass_position.z, pass_position.x)) / (2.0 * PI);\n vec2 tc = vec2(xValue, v_TexCoordinate.t);\n tc = vec2(tc.x , tc.y);\nhighp vec4 texelColor =\n      texture2D(uSampler, tc);\n  gl_FragColor = vec4(texelColor.rgb, texelColor.a);\n}";
shaka.ui.VRUtils.VERTEX_CUBE_SHADER="attribute vec4 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nvarying highp vec2 vTextureCoord;\nvarying highp vec3 vLighting;\nvoid main(void) {\n  gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;\n  vTextureCoord = aTextureCoord;\n}";shaka.ui.VRUtils.FRAGMENT_CUBE_SHADER="varying highp vec2 vTextureCoord;\nuniform sampler2D uSampler;\nvoid main(void) {\n  highp vec4 texelColor = texture2D(uSampler, vTextureCoord);\n  gl_FragColor = vec4(texelColor.rgb , texelColor.a);\n}";shaka.ui.VRWebgl=function(a,b,c,d,e){this.video_=a;this.player_=b;this.canvas_=c;this.gl_=d;this.eventManager_=new shaka.util.EventManager;this.originalQuaternion_=shaka.ui.MatrixQuaternion.create();this.currentQuaternion_=shaka.ui.MatrixQuaternion.create();this.verticesIndexBuffer_=this.verticesTextureCoordBuffer_=this.verticesBuffer_=this.shaderProgram_=null;this.viewMatrix_=shaka.ui.Matrix4x4.create();this.projectionMatrix_=shaka.ui.Matrix4x4.create();this.viewProjectionMatrix_=shaka.ui.Matrix4x4.create();
this.identityMatrix_=shaka.ui.Matrix4x4.create();this.diff_=null;this.stereoscopicMode_=!1;this.resetTimer_=this.activeTimer_=null;this.previousCanvasHeight_=this.previousCanvasWidth_=0;this.texture_=this.textureCoordAttribute_=this.vertexPositionAttribute_=this.geometry_=null;this.positionY_=this.positionX_=0;this.fieldOfView_=75;this.cont_=0;this.projectionMode_=e;this.videoCallbackId_=-1;this.init_()};
shaka.ui.VRWebgl.prototype.release=function(){this.videoCallbackId_!=-1&&(this.video_.cancelVideoFrameCallback(this.videoCallbackId_),this.videoCallbackId_=-1);this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.activeTimer_&&(this.activeTimer_.stop(),this.activeTimer_=null);this.resetTimer_&&(this.resetTimer_.stop(),this.resetTimer_=null)};shaka.ui.VRWebgl.prototype.getProjectionMode=function(){return this.projectionMode_};
shaka.ui.VRWebgl.prototype.toEulerAngles_=function(a){var b={pitch:0,yaw:0,roll:0},c=a[0],d=a[1],e=a[2];a=a[3];var f=d*d,g=e*e,h=a*a,k=c*c+f+g+h,l=c*a-d*e;l>.499995*k?(b.pitch=Math.PI/2,b.yaw=2*Math.atan2(d,c),b.roll=0):l<-.499995*k?(b.pitch=-Math.PI/2,b.yaw=2*Math.atan2(d,c),b.roll=0):(b.pitch=Math.asin(2*(c*e-a*d)),b.yaw=Math.atan2(2*(c*a+d*e),1-2*(g+h)),b.roll=Math.atan2(2*(c*d+e*a),1-2*(f+g)));return b};
shaka.ui.VRWebgl.prototype.toggleStereoscopicMode=function(){(this.stereoscopicMode_=!this.stereoscopicMode_)||this.gl_.viewport(0,0,this.canvas_.width,this.canvas_.height);this.renderGL_(!1)};shaka.ui.VRWebgl.prototype.isStereoscopicModeEnabled=function(){return this.stereoscopicMode_};
shaka.ui.VRWebgl.prototype.init_=function(){var a=this;this.initMatrices_();this.initGL_();this.initGLShaders_();this.initGLBuffers_();this.initGLTexture_();shaka.util.MediaReadyState.waitForReadyState(this.video_,HTMLMediaElement.HAVE_CURRENT_DATA,this.eventManager_,function(){a.video_.readyState>=HTMLMediaElement.HAVE_ENOUGH_DATA&&a.renderGL_();if("requestVideoFrameCallback"in a.video_){var b=function(d,e){a.videoCallbackId_!=-1&&(a.renderGL_(),a.videoCallbackId_!=-1&&(a.videoCallbackId_=a.video_.requestVideoFrameCallback(b)))};
a.videoCallbackId_=a.video_.requestVideoFrameCallback(b)}else{var c;a.eventManager_.listen(a.video_,"canplaythrough",function(){a.renderGL_()});a.eventManager_.listen(a.video_,"playing",function(){a.activeTimer_&&a.activeTimer_.stop();if(!c){var d=a.player_.getVariantTracks();d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())(e=e.value.frameRate)&&(!c||c<e)&&(c=e)}c||(c=60);a.renderGL_();a.activeTimer_=(new shaka.util.Timer(function(){a.renderGL_()})).tickNow().tickEvery(1/c)});
a.eventManager_.listen(a.video_,"pause",function(){a.activeTimer_&&a.activeTimer_.stop();a.activeTimer_=null;a.renderGL_()});a.eventManager_.listen(a.video_,"seeked",function(){a.renderGL_()});a.eventManager_.listen(document,"visibilitychange",function(){a.renderGL_()})}})};
shaka.ui.VRWebgl.prototype.initMatrices_=function(){shaka.ui.Matrix4x4.lookAt(this.viewMatrix_,[0,0,0],[1,0,0],[0,1,0]);shaka.ui.Matrix4x4.getRotation(this.originalQuaternion_,this.viewMatrix_);shaka.ui.Matrix4x4.scale(this.identityMatrix_,this.identityMatrix_,[4,4,4])};
shaka.ui.VRWebgl.prototype.initGL_=function(){this.updateViewPort_();this.gl_.viewport(0,0,this.gl_.drawingBufferWidth,this.gl_.drawingBufferHeight);this.gl_.clearColor(0,0,0,1);this.gl_.enable(this.gl_.CULL_FACE);this.gl_.cullFace(this.gl_.FRONT);this.gl_.clear(this.gl_.COLOR_BUFFER_BIT)};
shaka.ui.VRWebgl.prototype.initGLShaders_=function(){var a=this.getGLShader_(this.gl_.VERTEX_SHADER),b=this.getGLShader_(this.gl_.FRAGMENT_SHADER);this.shaderProgram_=this.gl_.createProgram();this.gl_.attachShader(this.shaderProgram_,a);this.gl_.attachShader(this.shaderProgram_,b);this.gl_.linkProgram(this.shaderProgram_);this.gl_.getProgramParameter(this.shaderProgram_,this.gl_.LINK_STATUS)||shaka.log.error("Unable to initialize the shader program: ",this.gl_.getProgramInfoLog(this.shaderProgram_));
this.projectionMode_=="cubemap"?(this.vertexPositionAttribute_=this.gl_.getAttribLocation(this.shaderProgram_,"aVertexPosition"),this.textureCoordAttribute_=this.gl_.getAttribLocation(this.shaderProgram_,"aTextureCoord")):(this.vertexPositionAttribute_=this.gl_.getAttribLocation(this.shaderProgram_,"a_vPosition"),this.gl_.enableVertexAttribArray(this.vertexPositionAttribute_),this.textureCoordAttribute_=this.gl_.getAttribLocation(this.shaderProgram_,"a_TexCoordinate"),this.gl_.enableVertexAttribArray(this.textureCoordAttribute_))};
shaka.ui.VRWebgl.prototype.getGLShader_=function(a){switch(a){case this.gl_.VERTEX_SHADER:var b=this.projectionMode_=="cubemap"?shaka.ui.VRUtils.VERTEX_CUBE_SHADER:shaka.ui.VRUtils.VERTEX_SPHERE_SHADER;break;case this.gl_.FRAGMENT_SHADER:b=this.projectionMode_=="cubemap"?shaka.ui.VRUtils.FRAGMENT_CUBE_SHADER:shaka.ui.VRUtils.FRAGMENT_SPHERE_SHADER;break;default:return null}var c=this.gl_.createShader(a);this.gl_.shaderSource(c,b);this.gl_.compileShader(c);this.gl_.getShaderParameter(c,this.gl_.COMPILE_STATUS)||
shaka.log.warning("Error in "+a+" shader: "+this.gl_.getShaderInfoLog(c));goog.asserts.assert(c,"Should have a shader!");return c};
shaka.ui.VRWebgl.prototype.initGLBuffers_=function(){this.geometry_=this.projectionMode_=="cubemap"?shaka.ui.VRUtils.generateCube():this.projectionMode_=="halfequirectangular"?shaka.ui.VRUtils.generateSphere(100,!0):shaka.ui.VRUtils.generateSphere(100);this.verticesBuffer_=this.gl_.createBuffer();this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER,this.verticesBuffer_);this.gl_.bufferData(this.gl_.ARRAY_BUFFER,new Float32Array(this.geometry_.vertices),this.gl_.STATIC_DRAW);this.verticesTextureCoordBuffer_=
this.gl_.createBuffer();this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER,this.verticesTextureCoordBuffer_);this.gl_.bufferData(this.gl_.ARRAY_BUFFER,new Float32Array(this.geometry_.textureCoords),this.gl_.STATIC_DRAW);this.verticesIndexBuffer_=this.gl_.createBuffer();this.gl_.bindBuffer(this.gl_.ELEMENT_ARRAY_BUFFER,this.verticesIndexBuffer_);this.gl_.bufferData(this.gl_.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.geometry_.indices),this.gl_.STATIC_DRAW)};
shaka.ui.VRWebgl.prototype.initGLTexture_=function(){this.texture_=this.gl_.createTexture();this.gl_.bindTexture(this.gl_.TEXTURE_2D,this.texture_);this.gl_.texParameteri(this.gl_.TEXTURE_2D,this.gl_.TEXTURE_WRAP_S,this.gl_.CLAMP_TO_EDGE);this.gl_.texParameteri(this.gl_.TEXTURE_2D,this.gl_.TEXTURE_WRAP_T,this.gl_.CLAMP_TO_EDGE);this.gl_.texParameteri(this.gl_.TEXTURE_2D,this.gl_.TEXTURE_MIN_FILTER,this.gl_.NEAREST);this.gl_.texParameteri(this.gl_.TEXTURE_2D,this.gl_.TEXTURE_MAG_FILTER,this.gl_.NEAREST)};
shaka.ui.VRWebgl.prototype.renderGL_=function(a){a=a===void 0?!0:a;var b=this.player_.getLoadMode()==shaka.Player.LoadMode.MEDIA_SOURCE;if(!(!this.video_||this.video_.readyState<2||!b&&this.video_.playbackRate==0)){shaka.ui.Matrix4x4.perspective(this.projectionMatrix_,this.fieldOfView_*Math.PI/180,1.5625,.1,100);this.projectionMode_=="cubemap"?shaka.ui.Matrix4x4.perspective(this.projectionMatrix_,this.fieldOfView_*Math.PI/180,2.5,.1,100):shaka.ui.Matrix4x4.perspective(this.projectionMatrix_,this.fieldOfView_*
Math.PI/180,1.5625,.1,100);this.gl_.useProgram(this.shaderProgram_);this.gl_.clear(this.gl_.COLOR_BUFFER_BIT);this.updateViewPort_();a&&(this.gl_.activeTexture(this.gl_.TEXTURE0),this.gl_.bindTexture(this.gl_.TEXTURE_2D,this.texture_),this.gl_.pixelStorei(this.gl_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.gl_.texImage2D(this.gl_.TEXTURE_2D,0,this.gl_.RGBA,this.gl_.RGBA,this.gl_.UNSIGNED_BYTE,this.video_));if(this.projectionMode_=="equirectangular"||this.projectionMode_=="halfequirectangular")shaka.ui.Matrix4x4.multiply(this.viewProjectionMatrix_,
this.viewMatrix_,this.identityMatrix_),shaka.ui.Matrix4x4.multiply(this.viewProjectionMatrix_,this.projectionMatrix_,this.viewProjectionMatrix_);this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER,this.verticesBuffer_);goog.asserts.assert(this.vertexPositionAttribute_!=null,"Should have a texture attribute!");this.gl_.vertexAttribPointer(this.vertexPositionAttribute_,3,this.gl_.FLOAT,!1,0,0);this.gl_.enableVertexAttribArray(this.vertexPositionAttribute_);this.gl_.bindBuffer(this.gl_.ARRAY_BUFFER,this.verticesTextureCoordBuffer_);
goog.asserts.assert(this.textureCoordAttribute_!=null,"Should have a texture attribute!");this.gl_.vertexAttribPointer(this.textureCoordAttribute_,2,this.gl_.FLOAT,!1,0,0);this.gl_.enableVertexAttribArray(this.textureCoordAttribute_);this.gl_.bindBuffer(this.gl_.ELEMENT_ARRAY_BUFFER,this.verticesIndexBuffer_);this.setMatrixUniforms_();this.gl_.uniform1i(this.gl_.getUniformLocation(this.shaderProgram_,"uSampler"),0);this.stereoscopicMode_&&this.gl_.viewport(0,0,this.canvas_.width/2,this.canvas_.height);
this.gl_.drawElements(this.gl_.TRIANGLES,this.geometry_.indices.length,this.gl_.UNSIGNED_SHORT,0);this.stereoscopicMode_&&(this.gl_.viewport(this.canvas_.width/2,0,this.canvas_.width/2,this.canvas_.height),this.gl_.drawElements(this.gl_.TRIANGLES,this.geometry_.indices.length,this.gl_.UNSIGNED_SHORT,0))}};
shaka.ui.VRWebgl.prototype.setMatrixUniforms_=function(){this.projectionMode_=="cubemap"?(this.gl_.uniformMatrix4fv(this.gl_.getUniformLocation(this.shaderProgram_,"uProjectionMatrix"),!1,this.projectionMatrix_),this.gl_.uniformMatrix4fv(this.gl_.getUniformLocation(this.shaderProgram_,"uModelViewMatrix"),!1,this.viewProjectionMatrix_)):this.gl_.uniformMatrix4fv(this.gl_.getUniformLocation(this.shaderProgram_,"u_VPMatrix"),!1,this.viewProjectionMatrix_)};
shaka.ui.VRWebgl.prototype.updateViewPort_=function(){var a=this.video_.videoWidth;a||(a=this.canvas_.scrollWidth);var b=this.video_.videoHeight;b||(b=this.canvas_.scrollHeight);if(this.previousCanvasWidth_!==a||this.previousCanvasHeight_!==b){this.canvas_.width=a;this.canvas_.height=b;this.previousCanvasWidth_=a;this.previousCanvasHeight_=b;var c=a/b;this.projectionMatrix_=shaka.ui.Matrix4x4.frustum(this.projectionMatrix_,-c,c,-1,1,0,1);this.gl_.viewport(0,0,a,b)}};
shaka.ui.VRWebgl.prototype.rotateViewGlobal=function(a,b,c){var d=Infinity,e=90*Math.PI/180;this.projectionMode_=="halfequirectangular"&&(d=90*Math.PI/180,e/=2);var f=this.projectionMode_=="cubemap"?this.viewProjectionMatrix_:this.viewMatrix_;this.positionX_+=a;this.positionY_+=b;this.positionX_<d&&this.positionX_>-d?shaka.ui.Matrix4x4.rotateY(f,f,a):this.positionX_-=a;this.positionY_<e&&this.positionY_>-e?(a=shaka.ui.Matrix4x4.create(),shaka.ui.Matrix4x4.rotateX(a,shaka.ui.Matrix4x4.create(),-1*
b),shaka.ui.Matrix4x4.multiply(f,a,f)):this.positionY_-=b;b=shaka.ui.Matrix4x4.create();shaka.ui.Matrix4x4.rotateZ(b,shaka.ui.Matrix4x4.create(),c);shaka.ui.Matrix4x4.multiply(f,b,f);this.renderGL_(!1)};shaka.ui.VRWebgl.prototype.zoom=function(a){a/=50;this.fieldOfView_>=20&&this.fieldOfView_<=100&&(this.fieldOfView_+=a);this.fieldOfView_<20?this.fieldOfView_=20:this.fieldOfView_>100&&(this.fieldOfView_=100);this.renderGL_(!1)};shaka.ui.VRWebgl.prototype.getFieldOfView=function(){return this.fieldOfView_};
shaka.ui.VRWebgl.prototype.setFieldOfView=function(a){this.fieldOfView_=a;this.renderGL_(!1)};shaka.ui.VRWebgl.prototype.getNorth=function(){shaka.ui.Matrix4x4.getRotation(this.currentQuaternion_,this.viewMatrix_);var a=this.toEulerAngles_(this.currentQuaternion_);return Math.acos(Math.cos(a.yaw)*Math.cos(a.pitch))*180/Math.PI};
shaka.ui.VRWebgl.prototype.reset=function(a){var b=this;if(a===void 0||a)shaka.ui.Matrix4x4.getRotation(this.currentQuaternion_,this.viewMatrix_),this.cont_=0,this.diff_=shaka.ui.MatrixQuaternion.create(),this.diff_[0]=(this.currentQuaternion_[0]-this.originalQuaternion_[0])/20,this.diff_[1]=(this.currentQuaternion_[1]-this.originalQuaternion_[1])/20,this.diff_[2]=(this.currentQuaternion_[2]-this.originalQuaternion_[2])/20,this.diff_[3]=(this.currentQuaternion_[3]-this.originalQuaternion_[3])/20;
this.currentQuaternion_[0]-=this.diff_[0];this.currentQuaternion_[1]-=this.diff_[1];this.currentQuaternion_[2]-=this.diff_[2];this.currentQuaternion_[3]-=this.diff_[3];a=shaka.ui.Matrix4x4.create();shaka.ui.MatrixQuaternion.normalize(this.currentQuaternion_,this.currentQuaternion_);shaka.ui.Matrix4x4.fromQuat(a,this.currentQuaternion_);this.viewMatrix_=a;this.resetTimer_&&(this.resetTimer_.stop(),this.resetTimer_=null);this.cont_<20?this.resetTimer_=(new shaka.util.Timer(function(){b.reset(!1);b.positionX_=
0;b.positionY_=0;b.cont_++;b.renderGL_(!1)})).tickAfter(shaka.ui.VRWebgl.ANIMATION_DURATION_/20):(shaka.ui.Matrix4x4.fromQuat(a,this.originalQuaternion_),this.viewMatrix_=a)};shaka.ui.VRWebgl.ANIMATION_DURATION_=.5;shaka.ui.VRManager=function(a,b,c,d,e,f){shaka.util.FakeEventTarget.call(this);var g=this;this.container_=a;this.canvas_=b;this.video_=c;this.player_=d;this.config_=e;this.controls_=f;this.loadEventManager_=new shaka.util.EventManager;this.eventManager_=new shaka.util.EventManager;this.gl_=this.getGL_(this.canvas_);this.vrWebgl_=null;this.onGesture_=!1;this.prevGamma_=this.prevBeta_=this.prevAlpha_=this.prevY_=this.prevX_=0;this.vrAsset_=null;this.loadEventManager_.listen(d,"loading",function(){g.vrWebgl_&&
g.vrWebgl_.reset();g.checkVrStatus_()});this.loadEventManager_.listen(d,"spatialvideoinfo",function(h){h=h.detail;var k=!1;switch(h.projection){case "rect":g.vrAsset_=null;break;case "equi":g.vrAsset_="equirectangular";break;case "hequ":switch(h.hfov){case 360:g.vrAsset_="equirectangular";break;case 180:g.vrAsset_="halfequirectangular";break;default:h.hfov==null?g.vrAsset_="halfequirectangular":(g.vrAsset_=null,k=!0)}break;case "fish":g.vrAsset_="halfequirectangular";break;default:g.vrAsset_=null,
k=!0}k&&shaka.log.warning("Unsupported VR projection or hfov",h);g.checkVrStatus_()});this.loadEventManager_.listen(d,"nospatialvideoinfo",function(){g.vrAsset_=null;g.checkVrStatus_()});this.loadEventManager_.listen(d,"unloading",function(){g.vrAsset_=null;g.checkVrStatus_()});this.loadEventManager_.listen(this.controls_,"caststatuschanged",function(){g.checkVrStatus_()});this.checkVrStatus_()};$jscomp.inherits(shaka.ui.VRManager,shaka.util.FakeEventTarget);
shaka.ui.VRManager.prototype.release=function(){this.loadEventManager_&&(this.loadEventManager_.release(),this.loadEventManager_=null);this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.vrWebgl_&&(this.vrWebgl_.release(),this.vrWebgl_=null);shaka.util.FakeEventTarget.prototype.release.call(this)};shaka.ui.VRManager.prototype.configure=function(a){this.config_=a;this.checkVrStatus_()};
shaka.ui.VRManager.prototype.canPlayVR=function(){if(this.canvas_)return!!this.gl_;var a=shaka.util.Dom.asHTMLCanvasElement(document.createElement("canvas"));return!!this.getGL_(a)};shaka.ui.VRManager.prototype.isPlayingVR=function(){return!!this.vrWebgl_};shaka.ui.VRManager.prototype.reset=function(){this.vrWebgl_?this.vrWebgl_.reset():shaka.log.alwaysWarn("Not playing VR content")};
shaka.ui.VRManager.prototype.getNorth=function(){return this.vrWebgl_?this.vrWebgl_.getNorth():(shaka.log.alwaysWarn("Not playing VR content"),null)};shaka.ui.VRManager.prototype.getFieldOfView=function(){return this.vrWebgl_?this.vrWebgl_.getFieldOfView():(shaka.log.alwaysWarn("Not playing VR content"),null)};
shaka.ui.VRManager.prototype.setFieldOfView=function(a){this.vrWebgl_?(a<0?(shaka.log.alwaysWarn("Field of view should be greater than 0"),a=0):a>100&&(shaka.log.alwaysWarn("Field of view should be less than 100"),a=100),this.vrWebgl_.setFieldOfView(a)):shaka.log.alwaysWarn("Not playing VR content")};shaka.ui.VRManager.prototype.toggleStereoscopicMode=function(){this.vrWebgl_?this.vrWebgl_.toggleStereoscopicMode():shaka.log.alwaysWarn("Not playing VR content")};
shaka.ui.VRManager.prototype.isStereoscopicModeEnabled=function(){return this.vrWebgl_?this.vrWebgl_.isStereoscopicModeEnabled():(shaka.log.alwaysWarn("Not playing VR content"),!1)};shaka.ui.VRManager.prototype.incrementYaw=function(a){this.vrWebgl_?this.vrWebgl_.rotateViewGlobal(a*shaka.ui.VRManager.TO_RADIANS_,0,0):shaka.log.alwaysWarn("Not playing VR content")};
shaka.ui.VRManager.prototype.incrementPitch=function(a){this.vrWebgl_?this.vrWebgl_.rotateViewGlobal(0,a*shaka.ui.VRManager.TO_RADIANS_,0):shaka.log.alwaysWarn("Not playing VR content")};shaka.ui.VRManager.prototype.incrementRoll=function(a){this.vrWebgl_?this.vrWebgl_.rotateViewGlobal(0,0,a*shaka.ui.VRManager.TO_RADIANS_):shaka.log.alwaysWarn("Not playing VR content")};
shaka.ui.VRManager.prototype.checkVrStatus_=function(){var a=this.controls_.getCastProxy().isCasting();!this.config_.displayInVrMode&&!this.vrAsset_||a?this.canvas_&&this.vrWebgl_&&(this.canvas_.style.display="none",this.eventManager_.removeAll(),this.vrWebgl_.release(),this.vrWebgl_=null,this.dispatchEvent(new shaka.util.FakeEvent("vrstatuschanged",(new Map).set("newStatus",this.isPlayingVR())))):(this.canvas_||(this.canvas_=shaka.util.Dom.asHTMLCanvasElement(document.createElement("canvas")),this.canvas_.classList.add("shaka-vr-canvas-container"),
this.video_.parentElement.insertBefore(this.canvas_,this.video_.nextElementSibling),this.gl_=this.getGL_(this.canvas_)),a=this.vrAsset_||this.config_.defaultVrProjectionMode,this.vrWebgl_)?this.vrWebgl_.getProjectionMode()!=a&&(this.eventManager_.removeAll(),this.vrWebgl_.release(),this.init_(a)):(this.canvas_.style.display="",this.init_(a),this.dispatchEvent(new shaka.util.FakeEvent("vrstatuschanged",(new Map).set("newStatus",this.isPlayingVR()))))};
shaka.ui.VRManager.prototype.init_=function(a){this.gl_&&this.canvas_&&(this.vrWebgl_=new shaka.ui.VRWebgl(this.video_,this.player_,this.canvas_,this.gl_,a),this.setupVRListeners_())};shaka.ui.VRManager.prototype.getGL_=function(a){if(!a||!window.WebGLRenderingContext)return null;for(var b=(0,$jscomp.makeIterator)(["webgl2","webgl"]),c=b.next();!c.done;c=b.next())if(c=a.getContext(c.value))return c;return null};
shaka.ui.VRManager.prototype.setupVRListeners_=function(){var a=this;this.eventManager_.listen(this.container_,"mousedown",function(d){a.onGesture_||a.gestureStart_(d.clientX,d.clientY)});navigator.maxTouchPoints>0&&this.eventManager_.listen(this.container_,"touchstart",function(d){a.onGesture_||a.gestureStart_(d.touches[0].clientX,d.touches[0].clientY)});this.eventManager_.listen(this.container_,"wheel",function(d){a.onGesture_||(a.vrWebgl_.zoom(d.deltaY),d.preventDefault(),d.stopPropagation())});
this.eventManager_.listen(this.container_,"mousemove",function(d){a.onGesture_&&a.gestureMove_(d.clientX,d.clientY)});navigator.maxTouchPoints>0&&this.eventManager_.listen(this.container_,"touchmove",function(d){a.onGesture_&&a.gestureMove_(d.touches[0].clientX,d.touches[0].clientY);d.preventDefault()});this.eventManager_.listen(this.container_,"mouseleave",function(){a.onGesture_=!1});this.eventManager_.listen(this.container_,"mouseup",function(){a.onGesture_=!1});navigator.maxTouchPoints>0&&this.eventManager_.listen(this.container_,
"touchend",function(){a.onGesture_=!1});var b=!1;if(window.DeviceOrientationEvent)if(typeof DeviceMotionEvent.requestPermission=="function"){var c=function(){DeviceMotionEvent.requestPermission().then(function(d){d!=="granted"||b||(b=!0,a.setupDeviceOrientationListener_())})};DeviceMotionEvent.requestPermission().then(function(d){a.eventManager_.unlisten(a.container_,"click",c);a.eventManager_.unlisten(a.container_,"mouseup",c);navigator.maxTouchPoints>0&&a.eventManager_.unlisten(a.container_,"touchend",
c);d!=="granted"?(a.eventManager_.listenOnce(a.container_,"click",c),a.eventManager_.listenOnce(a.container_,"mouseup",c),navigator.maxTouchPoints>0&&a.eventManager_.listenOnce(a.container_,"touchend",c)):(b=!0,a.setupDeviceOrientationListener_())}).catch(function(){a.eventManager_.unlisten(a.container_,"click",c);a.eventManager_.unlisten(a.container_,"mouseup",c);navigator.maxTouchPoints>0&&a.eventManager_.unlisten(a.container_,"touchend",c);a.eventManager_.listenOnce(a.container_,"click",c);a.eventManager_.listenOnce(a.container_,
"mouseup",c);navigator.maxTouchPoints>0&&a.eventManager_.listenOnce(a.container_,"touchend",c)})}else b=!0,this.setupDeviceOrientationListener_()};
shaka.ui.VRManager.prototype.setupDeviceOrientationListener_=function(){var a=this;this.eventManager_.listen(window,"deviceorientation",function(b){if(a.vrWebgl_){var c=(b.alpha||0)-a.prevAlpha_,d=(b.beta||0)-a.prevBeta_,e=(b.gamma||0)-a.prevGamma_;if(Math.abs(c)>10||Math.abs(d)>10||Math.abs(e)>5)d=e=c=0;a.prevAlpha_=b.alpha||0;a.prevBeta_=b.beta||0;a.prevGamma_=b.gamma||0;b=shaka.ui.VRManager.TO_RADIANS_;var f=screen.orientation.angle;f==90||f==-90?a.vrWebgl_.rotateViewGlobal(c*b*-1,e*b*-1,0):a.vrWebgl_.rotateViewGlobal(c*
b*-1,d*b,0)}})};shaka.ui.VRManager.prototype.gestureStart_=function(a,b){this.onGesture_=!0;this.prevX_=a;this.prevY_=b};shaka.ui.VRManager.prototype.gestureMove_=function(a,b){var c=-.6*Math.PI/180;this.vrWebgl_.rotateViewGlobal((a-this.prevX_)*c,(b-this.prevY_)*-1*c,0);this.prevX_=a;this.prevY_=b};shaka.ui.VRManager.TO_RADIANS_=Math.PI/180;shaka.ui.ControlsPanel={};
shaka.ui.Controls=function(a,b,c,d,e){shaka.util.FakeEventTarget.call(this);var f=this;this.enabled_=!0;this.config_=e;this.castProxy_=new shaka.cast.CastProxy(c,a,this.config_.castReceiverAppId,this.config_.castAndroidReceiverCompatible);this.castAllowed_=!0;this.video_=this.castProxy_.getVideo();this.localVideo_=c;this.player_=this.castProxy_.getPlayer();this.localPlayer_=a;this.videoContainer_=b;this.vrCanvas_=d;this.adManager_=this.player_.getAdManager();this.seekBar_=this.ad_=null;this.isSeeking_=
!1;this.menus_=[];this.showOnHoverControls_=[];this.recentMouseMovement_=!1;this.mouseStillTimer_=new shaka.util.Timer(function(){f.onMouseStill_()});this.fadeControlsTimer_=new shaka.util.Timer(function(){f.controlsContainer_.removeAttribute("shown");f.dispatchVisibilityEvent_();f.computeShakaTextContainerSize_();f.contextMenu_&&f.contextMenu_.closeMenu();f.hideSettingsMenusTimer_.tickAfter(f.config_.closeMenusDelay)});this.hideSettingsMenusTimer_=new shaka.util.Timer(function(){for(var g=(0,$jscomp.makeIterator)(f.menus_),
h=g.next();!h.done;h=g.next())shaka.ui.Utils.setDisplay(h.value,!1);f.config_.enableTooltips&&f.controlsButtonPanel_.classList.add("shaka-tooltips-on")});this.timeAndSeekRangeTimer_=new shaka.util.Timer(function(){f.isOpaque()&&f.updateTimeAndSeekRange_()});this.lastTouchEventTime_=null;this.elements_=[];this.localization_=shaka.ui.Controls.createLocalization_();this.eventManager_=new shaka.util.EventManager;this.vr_=null;this.configure(this.config_);this.addEventListeners_();this.setupMediaSession_();
this.pressedKeys_=new Set;this.onCastStatusChange_();this.timeAndSeekRangeTimer_.tickEvery(this.config_.refreshTickInSeconds);this.eventManager_.listen(this.localization_,shaka.ui.Localization.LOCALE_CHANGED,function(g){g=g.locales[0];f.adManager_.setLocale(g);f.videoContainer_.setAttribute("lang",g)});this.adManager_.initInterstitial(this.getClientSideAdContainer(),this.localPlayer_,this.localVideo_);this.eventManager_.listen(this.player_,"texttrackvisibility",function(){f.computeShakaTextContainerSize_()});
this.eventManager_.listen(this.player_,"unloading",function(){f.ad_||(f.isFullScreenEnabled()&&f.exitFullScreen_(),f.isPiPEnabled()&&f.togglePiP())})};$jscomp.inherits(shaka.ui.Controls,shaka.util.FakeEventTarget);
shaka.ui.Controls.prototype.destroy=function(a){a=a===void 0?!1:a;var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:if(document.pictureInPictureElement!=b.localVideo_){c.jumpTo(2);break}return c.yield(document.exitPictureInPicture(),2);case 2:b.eventManager_&&(b.eventManager_.release(),b.eventManager_=null);b.mouseStillTimer_&&(b.mouseStillTimer_.stop(),b.mouseStillTimer_=null);b.fadeControlsTimer_&&(b.fadeControlsTimer_.stop(),b.fadeControlsTimer_=
null);b.hideSettingsMenusTimer_&&(b.hideSettingsMenusTimer_.stop(),b.hideSettingsMenusTimer_=null);b.timeAndSeekRangeTimer_&&(b.timeAndSeekRangeTimer_.stop(),b.timeAndSeekRangeTimer_=null);b.vr_&&(b.vr_.release(),b.vr_=null);b.releaseChildElements_();b.controlsContainer_&&(b.videoContainer_.removeChild(b.controlsContainer_),b.controlsContainer_=null);if(!b.castProxy_){c.jumpTo(4);break}return c.yield(b.castProxy_.destroy(a),5);case 5:b.castProxy_=null;case 4:b.spinnerContainer_&&(b.videoContainer_.removeChild(b.spinnerContainer_),
b.spinnerContainer_=null);b.clientSideAdContainer_&&(b.videoContainer_.removeChild(b.clientSideAdContainer_),b.clientSideAdContainer_=null);b.serverSideAdContainer_&&(b.videoContainer_.removeChild(b.serverSideAdContainer_),b.serverSideAdContainer_=null);if(!b.localPlayer_){c.jumpTo(6);break}return c.yield(b.localPlayer_.destroy(),7);case 7:b.localPlayer_=null;case 6:b.player_=null,b.localVideo_=null,b.video_=null,b.localization_=null,b.pressedKeys_.clear(),b.removeMediaSession_(),shaka.util.FakeEventTarget.prototype.release.call(b),
c.jumpToEnd()}})};shaka.ui.Controls.prototype.releaseChildElements_=function(){for(var a=(0,$jscomp.makeIterator)(this.elements_),b=a.next();!b.done;b=a.next())b.value.release();this.elements_=[]};shaka.ui.Controls.registerElement=function(a,b){shaka.ui.ControlsPanel.elementNamesToFactories_.set(a,b)};shaka.ui.Controls.registerSeekBar=function(a){shaka.ui.ControlsPanel.seekBarFactory_=a};shaka.ui.Controls.prototype.allowCast=function(a){this.castAllowed_=a;this.onCastStatusChange_()};
shaka.ui.Controls.prototype.loadComplete=function(){this.onPlayStateChange_()};
shaka.ui.Controls.prototype.configure=function(a){var b=this;this.config_=a;this.castProxy_.changeReceiverId(a.castReceiverAppId,a.castAndroidReceiverCompatible);this.seekBar_&&(this.seekBar_=null);this.playButton_&&(this.playButton_=null);this.contextMenu_&&(this.contextMenu_=null);this.vr_&&this.vr_.configure(a);this.controlsContainer_?(shaka.util.Dom.removeAllChildren(this.controlsContainer_),this.releaseChildElements_()):(this.addControlsContainer_(),this.addAdContainers_(),goog.asserts.assert(this.controlsContainer_,
"Should have a controlsContainer_!"),goog.asserts.assert(this.localVideo_,"Should have a localVideo_!"),goog.asserts.assert(this.player_,"Should have a player_!"),this.vr_=new shaka.ui.VRManager(this.controlsContainer_,this.vrCanvas_,this.localVideo_,this.player_,this.config_,this));this.createDOM_();this.onPlayStateChange_();a=this.videoContainer_.getElementsByClassName("shaka-no-propagation");a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=function(e){return e.stopPropagation()};
this.eventManager_.listen(c,"click",d);this.eventManager_.listen(c,"dblclick",d);navigator.maxTouchPoints>0&&this.eventManager_.listen(c,"touchend",function(e){b.isOpaque()&&e.stopPropagation()})}};shaka.ui.Controls.prototype.setEnabledShakaControls=function(a){(this.enabled_=a)?(this.videoContainer_.setAttribute("shaka-controls","true"),this.localVideo_.tabIndex=-1,this.localVideo_.controls=!1):this.videoContainer_.removeAttribute("shaka-controls");this.onPlayStateChange_()};
shaka.ui.Controls.prototype.setEnabledNativeControls=function(a){this.localVideo_.controls=a;this.localVideo_.tabIndex=a?0:-1;a&&this.setEnabledShakaControls(!1)};shaka.ui.Controls.prototype.getAd=function(){return this.ad_};shaka.ui.Controls.prototype.getCastProxy=function(){return this.castProxy_};shaka.ui.Controls.prototype.getLocalization=function(){return this.localization_};shaka.ui.Controls.prototype.getVideoContainer=function(){return this.videoContainer_};
shaka.ui.Controls.prototype.getVideo=function(){return this.video_};shaka.ui.Controls.prototype.getLocalVideo=function(){return this.localVideo_};shaka.ui.Controls.prototype.getPlayer=function(){return this.player_};shaka.ui.Controls.prototype.getLocalPlayer=function(){return this.localPlayer_};shaka.ui.Controls.prototype.getControlsContainer=function(){goog.asserts.assert(this.controlsContainer_,"No controls container after destruction!");return this.controlsContainer_};
shaka.ui.Controls.prototype.getServerSideAdContainer=function(){goog.asserts.assert(this.serverSideAdContainer_,"No server side ad container after destruction!");return this.serverSideAdContainer_};shaka.ui.Controls.prototype.getClientSideAdContainer=function(){goog.asserts.assert(this.clientSideAdContainer_,"No client side ad container after destruction!");return this.clientSideAdContainer_};shaka.ui.Controls.prototype.getConfig=function(){return this.config_};
shaka.ui.Controls.prototype.isSeeking=function(){return this.isSeeking_};shaka.ui.Controls.prototype.setSeeking=function(a){(this.isSeeking_=a)?this.mouseStillTimer_.stop():this.mouseStillTimer_.tickAfter(3)};shaka.ui.Controls.prototype.isCastAllowed=function(){return this.castAllowed_};shaka.ui.Controls.prototype.getDisplayTime=function(){return this.seekBar_?this.seekBar_.getValue():this.video_.currentTime};shaka.ui.Controls.prototype.setLastTouchEventTime=function(a){this.lastTouchEventTime_=a};
shaka.ui.Controls.prototype.anySettingsMenusAreOpen=function(){return this.menus_.some(function(a){return!a.classList.contains("shaka-hidden")})};shaka.ui.Controls.prototype.hideSettingsMenus=function(){this.hideSettingsMenusTimer_.tickNow()};
shaka.ui.Controls.prototype.shouldUseDocumentFullscreen_=function(){return!document.fullscreenEnabled||this.localVideo_.webkitSupportsFullscreen&&this.config_.preferVideoFullScreenInVisionOS&&shaka.device.DeviceFactory.getDevice().getDeviceType()==shaka.device.IDevice.DeviceType.APPLE_VR?!1:!0};shaka.ui.Controls.prototype.shouldUseDocumentPictureInPicture_=function(){return"documentPictureInPicture"in window&&this.config_.preferDocumentPictureInPicture};
shaka.ui.Controls.prototype.isFullScreenSupported=function(){return this.castProxy_.isCasting()?!1:this.shouldUseDocumentFullscreen_()||(!this.ad_||!this.ad_.isUsingAnotherMediaElement())&&this.localVideo_.webkitSupportsFullscreen?!0:!1};shaka.ui.Controls.prototype.isFullScreenEnabled=function(){if(this.shouldUseDocumentFullscreen_())return!!document.fullscreenElement;var a=this.localVideo_;return a.webkitSupportsFullscreen?a.webkitDisplayingFullscreen:!1};
shaka.ui.Controls.prototype.enterFullScreen_=function(){var a=this,b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){switch(e.getNextAddressJsc()){case 1:e.setCatchFinallyBlocks(2);if(!a.shouldUseDocumentFullscreen_()){b=a.localVideo_;b.webkitSupportsFullscreen&&b.webkitEnterFullscreen();e.jumpTo(4);break}if(!a.isPiPEnabled()){e.jumpTo(5);break}return e.yield(a.togglePiP(),6);case 6:if(!a.shouldUseDocumentPictureInPicture_()){e.jumpTo(5);break}return e.yield(new Promise(function(f){(new shaka.util.Timer(f)).tickAfter(.05)}),
5);case 5:return c=a.config_.fullScreenElement,e.yield(c.requestFullscreen({navigationUI:"hide"}),9);case 9:if(!a.config_.forceLandscapeOnFullscreen||!screen.orientation){e.jumpTo(4);break}e.setCatchFinallyBlocks(11);return e.yield(screen.orientation.lock("landscape"),13);case 13:e.leaveTryBlock(4,2);break;case 11:e.enterCatchBlock(2);case 4:e.leaveTryBlock(0);break;case 2:d=e.enterCatchBlock(),a.dispatchEvent(new shaka.util.FakeEvent("error",(new Map).set("detail",d))),e.jumpToEnd()}})};
shaka.ui.Controls.prototype.exitFullScreen_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(!a.shouldUseDocumentFullscreen_())return b=a.localVideo_,b.webkitSupportsFullscreen&&b.webkitExitFullscreen(),c.jumpTo(0);screen.orientation&&screen.orientation.unlock();return c.yield(document.exitFullscreen(),0)})};
shaka.ui.Controls.prototype.toggleFullScreen=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return a.isFullScreenEnabled()?b.yield(a.exitFullScreen_(),0):b.yield(a.enterFullScreen_(),0)})};shaka.ui.Controls.prototype.isPiPAllowed=function(){return this.castProxy_.isCasting()?!1:document.pictureInPictureEnabled||this.shouldUseDocumentPictureInPicture_()?!this.localVideo_.disablePictureInPicture:!1};
shaka.ui.Controls.prototype.isPiPEnabled=function(){return!!(window.documentPictureInPicture&&window.documentPictureInPicture.window||document.pictureInPictureElement)};
shaka.ui.Controls.prototype.togglePiP=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){case 1:d.setCatchFinallyBlocks(2);if(a.shouldUseDocumentPictureInPicture_()){if(!a.isFullScreenEnabled()){d.jumpTo(10);break}return d.yield(a.exitFullScreen_(),10)}return document.pictureInPictureElement?d.yield(document.exitPictureInPicture(),5):(a.isFullScreenEnabled()&&a.exitFullScreen_(),b=a.localVideo_,d.yield(b.requestPictureInPicture(),
5));case 10:return d.yield(a.toggleDocumentPictureInPicture_(),5);case 5:d.leaveTryBlock(0);break;case 2:c=d.enterCatchBlock(),a.dispatchEvent(new shaka.util.FakeEvent("error",(new Map).set("detail",c))),d.jumpToEnd()}})};
shaka.ui.Controls.prototype.toggleDocumentPictureInPicture_=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){if(window.documentPictureInPicture.window)return window.documentPictureInPicture.window.close(),h.return();b=a.videoContainer_;c=b.getBoundingClientRect();return h.yield(window.documentPictureInPicture.requestWindow({width:c.width,height:c.height}),2)}d=h.getYieldResultJsc();a.copyStyleSheetsToWindow_(d);e=b.parentNode||
document.body;f=a.videoContainer_.cloneNode(!0);f.style.visibility="hidden";f.style.height=getComputedStyle(b).height;e.appendChild(f);g=document.createElement("style");g.append("[data-shaka-player-container] {\n      width: 100% !important; max-height: 100%}");d.document.head.append(g);d.document.body.append(b);a.eventManager_.listenOnce(d,"pagehide",function(){f.replaceWith(b)});h.jumpToEnd()})};
shaka.ui.Controls.prototype.copyStyleSheetsToWindow_=function(a){var b=[].concat((0,$jscomp.arrayFromIterable)(document.styleSheets)).map(function(d){try{return[].concat((0,$jscomp.arrayFromIterable)(d.cssRules)).map(function(f){return f.cssText}).join("")}catch(f){var e=document.createElement("link");e.rel="stylesheet";e.type=d.type;e.media=d.media;e.href=d.href;a.document.head.appendChild(e)}return""}).filter(Boolean).join("\n"),c=document.createElement("style");c.textContent=b;a.document.head.appendChild(c)};
shaka.ui.Controls.prototype.showAdUI=function(){shaka.ui.Utils.setDisplay(this.adPanel_,!0);this.clientSideAdContainer_&&this.clientSideAdContainer_.hasChildNodes()&&shaka.ui.Utils.setDisplay(this.clientSideAdContainer_,!0);this.serverSideAdContainer_&&this.serverSideAdContainer_.hasChildNodes()&&shaka.ui.Utils.setDisplay(this.serverSideAdContainer_,!0);this.ad_.hasCustomClick()?this.controlsContainer_.setAttribute("ad-active","true"):this.controlsContainer_.removeAttribute("ad-active")};
shaka.ui.Controls.prototype.hideAdUI=function(){shaka.ui.Utils.setDisplay(this.adPanel_,!1);shaka.ui.Utils.setDisplay(this.clientSideAdContainer_,!1);shaka.ui.Utils.setDisplay(this.serverSideAdContainer_,!1);this.controlsContainer_.removeAttribute("ad-active")};
shaka.ui.Controls.prototype.playPausePresentation=function(){if(this.enabled_){if(this.ad_&&(this.playPauseAd(),this.ad_.isLinear()))return;this.video_.duration&&(this.presentationIsPaused()?(this.player_.isEnded()&&(this.video_.currentTime=this.player_.seekRange().start),this.video_.play()):this.video_.pause())}};shaka.ui.Controls.prototype.playPauseAd=function(){this.ad_&&this.ad_.isPaused()?this.ad_.play():this.ad_&&this.ad_.pause()};
shaka.ui.Controls.prototype.presentationIsPaused=function(){return this.video_.paused&&!this.isSeeking()};
shaka.ui.Controls.prototype.createDOM_=function(){this.videoContainer_.classList.add("shaka-video-container");this.localVideo_.classList.add("shaka-video");this.addScrimContainer_();this.config_.addBigPlayButton&&this.addPlayButton_();this.config_.customContextMenu&&this.addContextMenu_();this.spinnerContainer_||this.addBufferingSpinner_();this.config_.seekOnTaps&&(this.addFastForwardButtonOnControlsContainer_(),this.addRewindButtonOnControlsContainer_());this.addControlsButtonPanel_();this.menus_=
Array.from(this.videoContainer_.getElementsByClassName("shaka-settings-menu"));this.menus_.push.apply(this.menus_,(0,$jscomp.arrayFromIterable)(Array.from(this.videoContainer_.getElementsByClassName("shaka-overflow-menu"))));this.showOnHoverControls_=Array.from(this.videoContainer_.getElementsByClassName("shaka-show-controls-on-mouse-over"))};
shaka.ui.Controls.prototype.addControlsContainer_=function(){var a=this;this.controlsContainer_=shaka.util.Dom.createHTMLElement("div");this.controlsContainer_.classList.add("shaka-controls-container");this.videoContainer_.appendChild(this.controlsContainer_);this.videoContainer_.setAttribute("shaka-controls","true");this.eventManager_.listen(this.controlsContainer_,"touchend",function(b){a.onContainerTouch_(b)});this.eventManager_.listen(this.controlsContainer_,"click",function(){a.onContainerClick()});
this.eventManager_.listen(this.controlsContainer_,"dblclick",function(){a.config_.doubleClickForFullscreen&&a.isFullScreenSupported()&&a.toggleFullScreen()})};shaka.ui.Controls.prototype.addPlayButton_=function(){var a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-play-button-container");this.controlsContainer_.appendChild(a);this.playButton_=new shaka.ui.BigPlayButton(a,this);this.elements_.push(this.playButton_)};
shaka.ui.Controls.prototype.addContextMenu_=function(){this.contextMenu_=new shaka.ui.ContextMenu(this.controlsButtonPanel_,this);this.elements_.push(this.contextMenu_)};shaka.ui.Controls.prototype.addScrimContainer_=function(){var a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-scrim-container");this.controlsContainer_.appendChild(a)};
shaka.ui.Controls.prototype.addAdControls_=function(){this.adPanel_=shaka.util.Dom.createHTMLElement("div");this.adPanel_.classList.add("shaka-ad-controls");var a=this.ad_!=null&&this.ad_.isLinear();shaka.ui.Utils.setDisplay(this.adPanel_,a);this.bottomControls_.appendChild(this.adPanel_);a=new shaka.ui.SkipAdButton(this.adPanel_,this);this.elements_.push(a)};
shaka.ui.Controls.prototype.addBufferingSpinner_=function(){this.spinnerContainer_=shaka.util.Dom.createHTMLElement("div");this.spinnerContainer_.classList.add("shaka-spinner-container");this.videoContainer_.appendChild(this.spinnerContainer_);var a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-spinner");this.spinnerContainer_.appendChild(a);a.insertAdjacentHTML("beforeend",'<svg focusable="false" stroke="currentColor"\n         viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg"\n         width="50px" height="50px" class="q-spinner text-grey-9">\n      <g transform="translate(1 1)" stroke-width="6" fill="none"\n        fill-rule="evenodd">\n        <circle stroke-opacity=".5" cx="18" cy="18" r="16"></circle>\n        <path d="M34 18c0-9.94-8.06-16-16-16">\n          <animateTransform attributeName="transform" type="rotate"\n            from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite">\n          </animateTransform>\n        </path>\n      </g>\n    </svg>')};
shaka.ui.Controls.prototype.addFastForwardButtonOnControlsContainer_=function(){var a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-hidden-fast-forward-container");this.controlsContainer_.appendChild(a);this.hiddenFastForwardButton_=new shaka.ui.HiddenFastForwardButton(a,this);this.elements_.push(this.hiddenFastForwardButton_)};
shaka.ui.Controls.prototype.addRewindButtonOnControlsContainer_=function(){var a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-hidden-rewind-container");this.controlsContainer_.appendChild(a);this.hiddenRewindButton_=new shaka.ui.HiddenRewindButton(a,this);this.elements_.push(this.hiddenRewindButton_)};
shaka.ui.Controls.prototype.addControlsButtonPanel_=function(){var a=this;this.bottomControls_=shaka.util.Dom.createHTMLElement("div");this.bottomControls_.classList.add("shaka-bottom-controls");this.bottomControls_.classList.add("shaka-no-propagation");this.controlsContainer_.appendChild(this.bottomControls_);this.eventManager_.listen(this.bottomControls_,"click",function(e){e.target.closest(".shaka-overflow-button")||a.hideSettingsMenus()});this.addAdControls_();this.addSeekBar_();this.controlsButtonPanel_=
shaka.util.Dom.createHTMLElement("div");this.controlsButtonPanel_.classList.add("shaka-controls-button-panel");this.controlsButtonPanel_.classList.add("shaka-show-controls-on-mouse-over");this.config_.enableTooltips&&this.controlsButtonPanel_.classList.add("shaka-tooltips-on");this.bottomControls_.appendChild(this.controlsButtonPanel_);for(var b=(0,$jscomp.makeIterator)(this.config_.controlPanelElements),c=b.next();!c.done;c=b.next())if(c=c.value,shaka.ui.ControlsPanel.elementNamesToFactories_.get(c)){var d=
shaka.ui.ControlsPanel.elementNamesToFactories_.get(c).create(this.controlsButtonPanel_,this);this.elements_.push(d);c=="time_and_duration"&&(c=new shaka.ui.AdInfo(this.controlsButtonPanel_,this),this.elements_.push(c))}else shaka.log.alwaysWarn("Unrecognized control panel element requested:",c)};
shaka.ui.Controls.prototype.addSeekBar_=function(){if(this.config_.addSeekBar)this.seekBar_=shaka.ui.ControlsPanel.seekBarFactory_.create(this.bottomControls_,this),this.elements_.push(this.seekBar_);else{for(var a=(0,$jscomp.makeIterator)(this.menus_),b=a.next();!b.done;b=a.next())b.value.classList.add("shaka-low-position");a=this.controlsButtonPanel_;a.classList.contains("shaka-tooltips-on")&&a.classList.add("shaka-tooltips-low-position")}};
shaka.ui.Controls.prototype.addAdContainers_=function(){var a=this;this.clientSideAdContainer_=shaka.util.Dom.createHTMLElement("div");this.clientSideAdContainer_.classList.add("shaka-client-side-ad-container");shaka.ui.Utils.setDisplay(this.clientSideAdContainer_,!1);this.eventManager_.listen(this.clientSideAdContainer_,"click",function(){a.onContainerClick()});this.videoContainer_.appendChild(this.clientSideAdContainer_);this.serverSideAdContainer_=shaka.util.Dom.createHTMLElement("div");this.serverSideAdContainer_.classList.add("shaka-server-side-ad-container");
shaka.ui.Utils.setDisplay(this.serverSideAdContainer_,!1);this.eventManager_.listen(this.serverSideAdContainer_,"click",function(){a.onContainerClick()});this.videoContainer_.appendChild(this.serverSideAdContainer_)};
shaka.ui.Controls.prototype.addEventListeners_=function(){var a=this;this.eventManager_.listen(this.player_,"buffering",function(){a.onBufferingStateChange_()});this.onBufferingStateChange_();this.eventManager_.listen(window,"keydown",function(b){a.onWindowKeyDown_(b)});this.eventManager_.listen(window,"click",function(){return a.hideSettingsMenus()});this.eventManager_.listen(this,"submenuopen",function(){a.hideSettingsMenus()});this.eventManager_.listen(this.video_,"play",function(){a.onPlayStateChange_()});
this.eventManager_.listen(this.video_,"pause",function(){a.onPlayStateChange_()});this.eventManager_.listen(this.videoContainer_,"mousemove",function(b){a.onMouseMove_(b)});this.eventManager_.listen(this.videoContainer_,"touchmove",function(b){a.onMouseMove_(b)},{passive:!0});this.eventManager_.listen(this.videoContainer_,"touchend",function(b){a.onMouseMove_(b)},{passive:!0});this.eventManager_.listen(this.videoContainer_,"mouseleave",function(){a.onMouseLeave_()});this.eventManager_.listen(this.videoContainer_,
"wheel",function(b){a.onMouseMove_(b)},{passive:!0});this.eventManager_.listen(this.castProxy_,"caststatuschanged",function(){a.onCastStatusChange_()});this.eventManager_.listen(this.vr_,"vrstatuschanged",function(){a.dispatchEvent(new shaka.util.FakeEvent("vrstatuschanged"))});this.eventManager_.listen(this.videoContainer_,"keydown",function(b){if(!a.config_.enableKeyboardPlaybackControlsInWindow&&!a.isFullScreenEnabled())a.onControlsKeyDown_(b)});this.eventManager_.listen(this.videoContainer_,"keyup",
function(b){if(!a.config_.enableKeyboardPlaybackControlsInWindow&&!a.isFullScreenEnabled())a.onControlsKeyUp_(b)});this.eventManager_.listen(window,"keydown",function(b){if(a.config_.enableKeyboardPlaybackControlsInWindow||a.isFullScreenEnabled())a.onControlsKeyDown_(b)});this.eventManager_.listen(window,"keyup",function(b){if(a.config_.enableKeyboardPlaybackControlsInWindow||a.isFullScreenEnabled())a.onControlsKeyUp_(b)});this.eventManager_.listen(this.adManager_,shaka.ads.Utils.AD_STARTED,function(b){a.ad_=
b.ad;a.showAdUI();a.onBufferingStateChange_()});this.eventManager_.listen(this.adManager_,shaka.ads.Utils.AD_STOPPED,function(){a.ad_=null;a.hideAdUI();a.onBufferingStateChange_()});screen.orientation&&this.eventManager_.listen(screen.orientation,"change",function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.yield(a.onScreenRotation_(),0)})})};
shaka.ui.Controls.prototype.setupMediaSession_=function(){var a=this;if(this.config_.setupMediaSession&&navigator.mediaSession){var b=function(f,g){try{navigator.mediaSession.setActionHandler(f,function(h){g(h)})}catch(h){shaka.log.debug('The "'+f+'" media session action is not supported.')}},c=function(){if(a.ad_&&a.ad_.isLinear())d();else{var f=a.player_.seekRange(),g=f.end-f.start;f=parseFloat((a.video_.currentTime-f.start).toFixed(2));a.player_.isLive()&&Math.abs(g-f)<1&&(g=Infinity);try{navigator.mediaSession.setPositionState({duration:Math.max(0,
g),playbackRate:a.video_.playbackRate,position:Math.max(0,f)})}catch(h){shaka.log.v2("setPositionState in media session is not supported.")}}},d=function(){try{navigator.mediaSession.setPositionState()}catch(f){shaka.log.v2("setPositionState in media session is not supported.")}},e=function(f){var g=a.config_.keyboardSeekDistance;switch(f.action){case "pause":a.playPausePresentation();break;case "play":a.playPausePresentation();break;case "seekbackward":if(f.seekOffset&&!isFinite(f.seekOffset))break;
a.ad_&&a.ad_.isLinear()||a.seek_(a.seekBar_.getValue()-(f.seekOffset||g));break;case "seekforward":if(f.seekOffset&&!isFinite(f.seekOffset))break;a.ad_&&a.ad_.isLinear()||a.seek_(a.seekBar_.getValue()+(f.seekOffset||g));break;case "seekto":if(f.seekTime&&!isFinite(f.seekTime))break;a.ad_&&a.ad_.isLinear()||a.seek_(a.player_.seekRange().start+f.seekTime);break;case "stop":a.player_.unload();break;case "enterpictureinpicture":a.ad_&&a.ad_.isLinear()||a.togglePiP()}};b("pause",e);b("play",e);b("seekbackward",
e);b("seekforward",e);b("seekto",e);b("stop",e);("documentPictureInPicture"in window||document.pictureInPictureEnabled)&&b("enterpictureinpicture",e);b=function(){a.player_.isLive()||a.player_.seekRange().start!=0?(c(),a.eventManager_.listen(a.video_,"timeupdate",c)):d()};this.player_.isFullyLoaded()&&b();this.eventManager_.listen(this.player_,"loaded",b);this.eventManager_.listen(this.player_,"unloading",function(){a.eventManager_.unlisten(a.video_,"timeupdate",c)});this.eventManager_.listen(this.player_,
"metadata",function(f){if(f=f.payload){var g;f.key=="TIT2"&&f.data&&(g=f.data);var h;f.key=="APIC"&&f.mimeType=="--\x3e"&&(h=f.data);g&&(f={title:g,artwork:[]},navigator.mediaSession.metadata&&(f=navigator.mediaSession.metadata,f.title=g),navigator.mediaSession.metadata=new MediaMetadata(f));h&&(g=a.localVideo_,h!=g.poster&&(g.poster=h),g={title:"",artwork:[{src:h}]},navigator.mediaSession.metadata&&(g=navigator.mediaSession.metadata,g.artwork=[{src:h}]),navigator.mediaSession.metadata=new MediaMetadata(g))}})}};
shaka.ui.Controls.prototype.removeMediaSession_=function(){if(this.config_.setupMediaSession&&navigator.mediaSession){try{navigator.mediaSession.setPositionState()}catch(b){}var a=function(b){try{navigator.mediaSession.setActionHandler(b,null)}catch(c){}};a("pause");a("play");a("seekbackward");a("seekforward");a("seekto");a("stop");a("enterpictureinpicture")}};
shaka.ui.Controls.prototype.onScreenRotation_=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return a.video_&&a.video_.readyState!=0&&!a.castProxy_.isCasting()&&a.config_.enableFullscreenOnRotation&&a.isFullScreenSupported()?screen.orientation.type.includes("landscape")&&!a.isFullScreenEnabled()?b.yield(a.enterFullScreen_(),0):screen.orientation.type.includes("portrait")&&a.isFullScreenEnabled()?b.yield(a.exitFullScreen_(),0):b.jumpTo(0):b.return()})};
shaka.ui.Controls.prototype.onMouseMove_=function(a){a.type=="mousemove"&&(this.controlsContainer_.classList.remove("shaka-keyboard-navigation"),this.computeOpacity());a.type=="touchstart"||a.type=="touchmove"||a.type=="touchend"||a.type=="keyup"?this.lastTouchEventTime_=Date.now():this.lastTouchEventTime_+1E3<Date.now()&&(this.lastTouchEventTime_=null);this.lastTouchEventTime_&&a.type=="mousemove"||(this.videoContainer_.classList.remove("no-cursor"),this.recentMouseMovement_=!0,this.hideSettingsMenusTimer_.stop(),
this.isOpaque()||(this.updateTimeAndSeekRange_(),this.computeOpacity()),this.mouseStillTimer_.stop(),a.type!="touchend"&&a.type!="wheel"&&a.type!="keyup"&&this.lastTouchEventTime_||this.mouseStillTimer_.tickAfter(3))};shaka.ui.Controls.prototype.onMouseLeave_=function(){this.lastTouchEventTime_||this.mouseStillTimer_.tickNow()};shaka.ui.Controls.prototype.onMouseStill_=function(){this.videoContainer_.classList.add("no-cursor");this.recentMouseMovement_=!1;this.computeOpacity()};
shaka.ui.Controls.prototype.isHovered_=function(){return window.matchMedia("hover: hover").matches?this.showOnHoverControls_.some(function(a){return a.matches(":hover")}):!1};shaka.ui.Controls.prototype.computeShakaTextContainerSize_=function(){var a=this.videoContainer_.getElementsByClassName("shaka-text-container")[0];a&&(this.isOpaque()?a.style.bottom=this.bottomControls_.clientHeight+"px":a.style.bottom="0px")};
shaka.ui.Controls.prototype.computeOpacity=function(){var a=this.ad_?this.ad_.isPaused():!1,b=this.video_.paused&&!this.isSeeking_,c=this.controlsContainer_.classList.contains("shaka-keyboard-navigation");a||(!this.ad_||!this.ad_.isLinear())&&b||this.recentMouseMovement_||c||this.isHovered_()?(this.updateTimeAndSeekRange_(),this.controlsContainer_.getAttribute("shown")==null&&(this.controlsContainer_.setAttribute("shown","true"),this.dispatchVisibilityEvent_()),this.computeShakaTextContainerSize_(),
this.fadeControlsTimer_.stop()):this.fadeControlsTimer_.tickAfter(this.config_.fadeDelay);this.anySettingsMenusAreOpen()&&this.controlsButtonPanel_.classList.remove("shaka-tooltips-on")};shaka.ui.Controls.prototype.onContainerTouch_=function(a){if(this.video_.duration){if(this.isOpaque())this.lastTouchEventTime_=Date.now(),this.onContainerClick(!0);else this.onMouseMove_(a);a.cancelable&&a.preventDefault()}};
shaka.ui.Controls.prototype.onContainerClick=function(a){a=a===void 0?!1:a;this.enabled_&&!this.isPlayingVR()&&(this.anySettingsMenusAreOpen()?this.hideSettingsMenusTimer_.tickNow():this.config_.singleClickForPlayAndPause?this.playPausePresentation():a&&this.isOpaque()&&this.hideUI())};
shaka.ui.Controls.prototype.onCastStatusChange_=function(){var a=this.castProxy_.isCasting();this.dispatchEvent(new shaka.util.FakeEvent("caststatuschanged",(new Map).set("newStatus",a)));a?this.controlsContainer_.getAttribute("casting")==null&&(this.controlsContainer_.setAttribute("casting","true"),this.dispatchVisibilityEvent_()):this.controlsContainer_.getAttribute("casting")!=null&&(this.controlsContainer_.removeAttribute("casting"),this.dispatchVisibilityEvent_())};
shaka.ui.Controls.prototype.onPlayStateChange_=function(){this.computeOpacity()};
shaka.ui.Controls.prototype.onControlsKeyDown_=function(a){var b=document.activeElement,c=b&&b.classList?b.classList.contains("shaka-volume-bar"):!1,d=b&&b.classList&&b.classList.contains("shaka-seek-bar"),e=this.isFullScreenEnabled();b=this.controlsContainer_.contains(b);e=e||this.config_.enableKeyboardPlaybackControlsInWindow;if(b)this.onMouseMove_(a);if(this.config_.enableKeyboardPlaybackControls&&this.player_.getAssetUri()){var f=this.config_.keyboardSeekDistance,g=this.config_.keyboardLargeSeekDistance;
switch(a.key){case "ArrowLeft":this.seekBar_&&f>0&&(d||e)&&!c&&(a.preventDefault(),this.seek_(this.seekBar_.getValue()-f));break;case "ArrowRight":this.seekBar_&&f>0&&(d||e)&&!c&&(a.preventDefault(),this.seek_(this.seekBar_.getValue()+f));break;case "PageDown":this.seekBar_&&g>0&&(d||e)&&(a.preventDefault(),this.seek_(this.seekBar_.getValue()-g));break;case "PageUp":this.seekBar_&&g>0&&(d||e)&&(a.preventDefault(),this.seek_(this.seekBar_.getValue()+g));break;case "Home":this.seekBar_&&this.seek_(this.player_.seekRange().start);
break;case "End":this.seekBar_&&this.seek_(this.player_.seekRange().end);break;case "c":this.player_.setTextTrackVisibility(!this.player_.isTextTrackVisible());break;case "f":this.isFullScreenSupported()&&this.toggleFullScreen();break;case "m":this.ad_&&this.ad_.isLinear()?this.ad_.setMuted(!this.ad_.isMuted()):this.localVideo_.muted=!this.localVideo_.muted;break;case "p":this.isPiPAllowed()&&this.togglePiP();break;case ">":a=this.config_.playbackRates.indexOf(this.player_.getPlaybackRate());a>-1&&
a+1<this.config_.playbackRates.length&&this.player_.trickPlay(this.config_.playbackRates[a+1],!1);break;case "<":a=this.config_.playbackRates.indexOf(this.player_.getPlaybackRate());a>-1&&a-1>=0&&this.player_.trickPlay(this.config_.playbackRates[a-1],!1);break;case " ":(d||e&&!b)&&this.playPausePresentation()}}};shaka.ui.Controls.prototype.onControlsKeyUp_=function(a){this.pressedKeys_.delete(a.key)};
shaka.ui.Controls.prototype.onBufferingStateChange_=function(){this.enabled_&&(this.ad_&&this.ad_.isClientRendering()&&this.ad_.isLinear()?shaka.ui.Utils.setDisplay(this.spinnerContainer_,!1):shaka.ui.Utils.setDisplay(this.spinnerContainer_,this.player_.isBuffering()))};shaka.ui.Controls.prototype.isOpaque=function(){return this.enabled_?this.controlsContainer_.getAttribute("shown")!=null||this.controlsContainer_.getAttribute("casting")!=null:!1};
shaka.ui.Controls.prototype.dispatchVisibilityEvent_=function(){this.isOpaque()?this.dispatchEvent(new shaka.util.FakeEvent("showingui")):this.dispatchEvent(new shaka.util.FakeEvent("hidingui"))};shaka.ui.Controls.prototype.seek_=function(a){goog.asserts.assert(this.seekBar_,"Caller of seek_ must check for seekBar_ first!");this.video_.currentTime=a;this.updateTimeAndSeekRange_()};
shaka.ui.Controls.prototype.updateTimeAndSeekRange_=function(){if(this.seekBar_)if(this.seekBar_.setValue(this.video_.currentTime),this.seekBar_.update(),this.seekBar_.isShowing()){for(var a=(0,$jscomp.makeIterator)(this.menus_),b=a.next();!b.done;b=a.next())b.value.classList.remove("shaka-low-position");a=this.controlsButtonPanel_;a.classList.contains("shaka-tooltips-on")&&a.classList.remove("shaka-tooltips-low-position")}else{a=(0,$jscomp.makeIterator)(this.menus_);for(b=a.next();!b.done;b=a.next())b.value.classList.add("shaka-low-position");
a=this.controlsButtonPanel_;a.classList.contains("shaka-tooltips-on")&&a.classList.add("shaka-tooltips-low-position")}this.dispatchEvent(new shaka.util.FakeEvent("timeandseekrangeupdated"))};
shaka.ui.Controls.prototype.onWindowKeyDown_=function(a){var b=this;this.pressedKeys_.add(a.key);var c=this.anySettingsMenusAreOpen();a.key=="Tab"&&(this.controlsContainer_.classList.add("shaka-keyboard-navigation"),this.computeOpacity(),this.eventManager_.listen(window,"mousedown",function(){return b.onMouseDown_()}));a.key=="Escape"&&this.hideSettingsMenusTimer_.tickNow();c&&this.pressedKeys_.has("Tab")&&this.keepFocusInMenu_(a)};
shaka.ui.Controls.prototype.keepFocusInMenu_=function(a){var b=this.menus_.filter(function(e){return!e.classList.contains("shaka-hidden")});if(b.length){var c=b[0];if(c.childNodes.length){for(b=c.firstElementChild;b&&b.classList.contains("shaka-hidden");)b=b.nextElementSibling;for(c=c.lastElementChild;c&&c.classList.contains("shaka-hidden");)c=c.previousElementSibling;var d=document.activeElement;this.pressedKeys_.has("Shift")?d==b&&(a.preventDefault(),c.focus()):d==c&&(a.preventDefault(),b.focus())}}};
shaka.ui.Controls.prototype.onMouseDown_=function(){this.eventManager_.unlisten(window,"mousedown")};shaka.ui.Controls.prototype.showUI=function(){var a=new Event("mousemove",{bubbles:!1,cancelable:!1});this.onMouseMove_(a)};shaka.ui.Controls.prototype.hideUI=function(){this.mouseStillTimer_.tickNow()};shaka.ui.Controls.prototype.getVR=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_};
shaka.ui.Controls.prototype.canPlayVR=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_.canPlayVR()};shaka.ui.Controls.prototype.isPlayingVR=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_.isPlayingVR()};shaka.ui.Controls.prototype.resetVR=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.reset()};
shaka.ui.Controls.prototype.getVRNorth=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_.getNorth()};shaka.ui.Controls.prototype.getVRFieldOfView=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_.getFieldOfView()};shaka.ui.Controls.prototype.setVRFieldOfView=function(a){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.setFieldOfView(a)};
shaka.ui.Controls.prototype.toggleStereoscopicMode=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.toggleStereoscopicMode()};shaka.ui.Controls.prototype.isStereoscopicModeEnabled=function(){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");return this.vr_.isStereoscopicModeEnabled()};shaka.ui.Controls.prototype.incrementYaw=function(a){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.incrementYaw(a)};
shaka.ui.Controls.prototype.incrementPitch=function(a){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.incrementPitch(a)};shaka.ui.Controls.prototype.incrementRoll=function(a){goog.asserts.assert(this.vr_!=null,"Should have a VR manager!");this.vr_.incrementRoll(a)};shaka.ui.Controls.createLocalization_=function(){var a=new shaka.ui.Localization("en");shaka.ui.Locales.addTo(a);a.changeLocale(navigator.languages||[]);return a};goog.exportSymbol("shaka.ui.Controls",shaka.ui.Controls);
goog.exportProperty(shaka.ui.Controls.prototype,"incrementRoll",shaka.ui.Controls.prototype.incrementRoll);goog.exportProperty(shaka.ui.Controls.prototype,"incrementPitch",shaka.ui.Controls.prototype.incrementPitch);goog.exportProperty(shaka.ui.Controls.prototype,"incrementYaw",shaka.ui.Controls.prototype.incrementYaw);goog.exportProperty(shaka.ui.Controls.prototype,"toggleStereoscopicMode",shaka.ui.Controls.prototype.toggleStereoscopicMode);
goog.exportProperty(shaka.ui.Controls.prototype,"setVRFieldOfView",shaka.ui.Controls.prototype.setVRFieldOfView);goog.exportProperty(shaka.ui.Controls.prototype,"getVRFieldOfView",shaka.ui.Controls.prototype.getVRFieldOfView);goog.exportProperty(shaka.ui.Controls.prototype,"getVRNorth",shaka.ui.Controls.prototype.getVRNorth);goog.exportProperty(shaka.ui.Controls.prototype,"isPlayingVR",shaka.ui.Controls.prototype.isPlayingVR);goog.exportProperty(shaka.ui.Controls.prototype,"canPlayVR",shaka.ui.Controls.prototype.canPlayVR);
goog.exportProperty(shaka.ui.Controls.prototype,"hideUI",shaka.ui.Controls.prototype.hideUI);goog.exportProperty(shaka.ui.Controls.prototype,"showUI",shaka.ui.Controls.prototype.showUI);goog.exportProperty(shaka.ui.Controls.prototype,"isOpaque",shaka.ui.Controls.prototype.isOpaque);goog.exportProperty(shaka.ui.Controls.prototype,"hideAdUI",shaka.ui.Controls.prototype.hideAdUI);goog.exportProperty(shaka.ui.Controls.prototype,"showAdUI",shaka.ui.Controls.prototype.showAdUI);
goog.exportProperty(shaka.ui.Controls.prototype,"togglePiP",shaka.ui.Controls.prototype.togglePiP);goog.exportProperty(shaka.ui.Controls.prototype,"isPiPEnabled",shaka.ui.Controls.prototype.isPiPEnabled);goog.exportProperty(shaka.ui.Controls.prototype,"isPiPAllowed",shaka.ui.Controls.prototype.isPiPAllowed);goog.exportProperty(shaka.ui.Controls.prototype,"toggleFullScreen",shaka.ui.Controls.prototype.toggleFullScreen);goog.exportProperty(shaka.ui.Controls.prototype,"isFullScreenEnabled",shaka.ui.Controls.prototype.isFullScreenEnabled);
goog.exportProperty(shaka.ui.Controls.prototype,"isFullScreenSupported",shaka.ui.Controls.prototype.isFullScreenSupported);goog.exportProperty(shaka.ui.Controls.prototype,"hideSettingsMenus",shaka.ui.Controls.prototype.hideSettingsMenus);goog.exportProperty(shaka.ui.Controls.prototype,"anySettingsMenusAreOpen",shaka.ui.Controls.prototype.anySettingsMenusAreOpen);goog.exportProperty(shaka.ui.Controls.prototype,"setLastTouchEventTime",shaka.ui.Controls.prototype.setLastTouchEventTime);
goog.exportProperty(shaka.ui.Controls.prototype,"getDisplayTime",shaka.ui.Controls.prototype.getDisplayTime);goog.exportProperty(shaka.ui.Controls.prototype,"isCastAllowed",shaka.ui.Controls.prototype.isCastAllowed);goog.exportProperty(shaka.ui.Controls.prototype,"setSeeking",shaka.ui.Controls.prototype.setSeeking);goog.exportProperty(shaka.ui.Controls.prototype,"isSeeking",shaka.ui.Controls.prototype.isSeeking);goog.exportProperty(shaka.ui.Controls.prototype,"getConfig",shaka.ui.Controls.prototype.getConfig);
goog.exportProperty(shaka.ui.Controls.prototype,"getClientSideAdContainer",shaka.ui.Controls.prototype.getClientSideAdContainer);goog.exportProperty(shaka.ui.Controls.prototype,"getServerSideAdContainer",shaka.ui.Controls.prototype.getServerSideAdContainer);goog.exportProperty(shaka.ui.Controls.prototype,"getControlsContainer",shaka.ui.Controls.prototype.getControlsContainer);goog.exportProperty(shaka.ui.Controls.prototype,"getLocalPlayer",shaka.ui.Controls.prototype.getLocalPlayer);
goog.exportProperty(shaka.ui.Controls.prototype,"getPlayer",shaka.ui.Controls.prototype.getPlayer);goog.exportProperty(shaka.ui.Controls.prototype,"getLocalVideo",shaka.ui.Controls.prototype.getLocalVideo);goog.exportProperty(shaka.ui.Controls.prototype,"getVideo",shaka.ui.Controls.prototype.getVideo);goog.exportProperty(shaka.ui.Controls.prototype,"getVideoContainer",shaka.ui.Controls.prototype.getVideoContainer);goog.exportProperty(shaka.ui.Controls.prototype,"getLocalization",shaka.ui.Controls.prototype.getLocalization);
goog.exportProperty(shaka.ui.Controls.prototype,"getCastProxy",shaka.ui.Controls.prototype.getCastProxy);goog.exportProperty(shaka.ui.Controls.prototype,"getAd",shaka.ui.Controls.prototype.getAd);goog.exportProperty(shaka.ui.Controls.prototype,"setEnabledNativeControls",shaka.ui.Controls.prototype.setEnabledNativeControls);goog.exportProperty(shaka.ui.Controls.prototype,"setEnabledShakaControls",shaka.ui.Controls.prototype.setEnabledShakaControls);
goog.exportProperty(shaka.ui.Controls.prototype,"configure",shaka.ui.Controls.prototype.configure);goog.exportProperty(shaka.ui.Controls.prototype,"loadComplete",shaka.ui.Controls.prototype.loadComplete);goog.exportProperty(shaka.ui.Controls.prototype,"allowCast",shaka.ui.Controls.prototype.allowCast);goog.exportProperty(shaka.ui.Controls,"registerSeekBar",shaka.ui.Controls.registerSeekBar);goog.exportProperty(shaka.ui.Controls,"registerElement",shaka.ui.Controls.registerElement);
goog.exportProperty(shaka.ui.Controls.prototype,"destroy",shaka.ui.Controls.prototype.destroy);shaka.ui.ControlsPanel.elementNamesToFactories_=new Map;shaka.ui.ControlsPanel.seekBarFactory_=new shaka.ui.SeekBar.Factory;shaka.ui.OverflowMenu=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.config_=this.controls.getConfig();this.controlsContainer_=this.controls.getControlsContainer();this.videoContainer_=this.controls.getVideoContainer();this.children_=[];this.addOverflowMenuButton_();this.addOverflowMenu_();this.createChildren_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,
function(){c.updateAriaLabel_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.ad&&c.ad.isLinear()&&shaka.ui.Utils.setDisplay(c.overflowMenuButton_,!1)});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){shaka.ui.Utils.setDisplay(c.overflowMenuButton_,!0)});this.eventManager.listen(this.controls,"submenuopen",function(){shaka.ui.Utils.setDisplay(c.overflowMenu_,!1)});this.eventManager.listen(this.overflowMenu_,"touchstart",function(d){c.controls.setLastTouchEventTime(Date.now());
d.stopPropagation()});this.eventManager.listen(this.overflowMenuButton_,"click",function(){if(c.controls.isOpaque())c.onOverflowMenuButtonClick_()});this.updateAriaLabel_();this.ad&&this.ad.isLinear()&&shaka.ui.Utils.setDisplay(this.overflowMenuButton_,!1);this.resizeObserver_=null;a=function(){return c.computeMaxHeight_()};window.ResizeObserver?(this.resizeObserver_=new ResizeObserver(a),this.resizeObserver_.observe(this.controls.getVideoContainer())):this.eventManager.listen(window,"resize",a)};
$jscomp.inherits(shaka.ui.OverflowMenu,shaka.ui.Element);shaka.ui.OverflowMenu.prototype.release=function(){this.controlsContainer_=null;for(var a=(0,$jscomp.makeIterator)(this.children_),b=a.next();!b.done;b=a.next())b.value.release();this.children_=[];this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);shaka.ui.Element.prototype.release.call(this)};shaka.ui.OverflowMenu.registerElement=function(a,b){shaka.ui.OverflowMenu.elementNamesToFactories_.set(a,b)};
shaka.ui.OverflowMenu.prototype.addOverflowMenu_=function(){this.overflowMenu_=shaka.util.Dom.createHTMLElement("div");this.overflowMenu_.classList.add("shaka-overflow-menu");this.overflowMenu_.classList.add("shaka-no-propagation");this.overflowMenu_.classList.add("shaka-show-controls-on-mouse-over");this.overflowMenu_.classList.add("shaka-hidden");this.controlsContainer_.appendChild(this.overflowMenu_)};
shaka.ui.OverflowMenu.prototype.addOverflowMenuButton_=function(){this.overflowMenuButton_=shaka.util.Dom.createButton();this.overflowMenuButton_.classList.add("shaka-overflow-menu-button");this.overflowMenuButton_.classList.add("shaka-no-propagation");this.overflowMenuButton_.classList.add("shaka-tooltip");(new shaka.ui.MaterialSVGIcon(this.overflowMenuButton_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.OPEN_OVERFLOW);var a=shaka.util.Dom.createHTMLElement("span");a.classList.add("shaka-overflow-quality-mark");
a.style.display="none";this.overflowMenuButton_.appendChild(a);this.parent.appendChild(this.overflowMenuButton_)};
shaka.ui.OverflowMenu.prototype.createChildren_=function(){for(var a=(0,$jscomp.makeIterator)(this.config_.overflowMenuButtons),b=a.next();!b.done;b=a.next())b=b.value,shaka.ui.OverflowMenu.elementNamesToFactories_.get(b)?(b=shaka.ui.OverflowMenu.elementNamesToFactories_.get(b),goog.asserts.assert(this.controls,"Controls should not be null!"),this.children_.push(b.create(this.overflowMenu_,this.controls))):shaka.log.alwaysWarn("Unrecognized overflow menu element requested:",b)};
shaka.ui.OverflowMenu.prototype.onOverflowMenuButtonClick_=function(){if(this.controls.anySettingsMenusAreOpen())this.controls.hideSettingsMenus();else{shaka.ui.Utils.setDisplay(this.overflowMenu_,!0);this.controls.computeOpacity();var a=function(c){return c.classList.contains("shaka-hidden")==0},b=shaka.util.Iterables;b.some(this.overflowMenu_.childNodes,a)&&b.filter(this.overflowMenu_.childNodes,a)[0].focus();this.computeMaxHeight_()}};
shaka.ui.OverflowMenu.prototype.updateAriaLabel_=function(){this.overflowMenuButton_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.MORE_SETTINGS)};shaka.ui.OverflowMenu.prototype.computeMaxHeight_=function(){var a=this.overflowMenu_.getBoundingClientRect(),b=window.getComputedStyle(this.overflowMenu_),c=parseFloat(b.paddingTop);b=parseFloat(b.paddingBottom);var d=this.videoContainer_.getBoundingClientRect();this.overflowMenu_.style.maxHeight=a.bottom-d.top-c-b-5+"px"};
goog.exportSymbol("shaka.ui.OverflowMenu",shaka.ui.OverflowMenu);goog.exportProperty(shaka.ui.OverflowMenu,"registerElement",shaka.ui.OverflowMenu.registerElement);shaka.ui.OverflowMenu.Factory=function(){};shaka.ui.OverflowMenu.Factory.prototype.create=function(a,b){return new shaka.ui.OverflowMenu(a,b)};shaka.ui.Controls.registerElement("overflow_menu",new shaka.ui.OverflowMenu.Factory);shaka.ui.OverflowMenu.elementNamesToFactories_=new Map;shaka.ui.AdStatisticsButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-ad-statistics-button");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_ON);a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-simple-overflow-button-label-inline");this.nameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.nameSpan_);
this.stateSpan_=shaka.util.Dom.createHTMLElement("span");this.stateSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.stateSpan_);this.button_.appendChild(a);this.parent.appendChild(this.button_);this.container_=shaka.util.Dom.createHTMLElement("div");this.container_.classList.add("shaka-no-propagation");this.container_.classList.add("shaka-show-controls-on-mouse-over");this.container_.classList.add("shaka-ad-statistics-container");this.container_.classList.add("shaka-hidden");
this.controls.getControlsContainer().appendChild(this.container_);this.statisticsList_=[];this.currentStats_=this.adManager.getStats();shaka.ui.Utils.setDisplay(this.button_,this.currentStats_.started>0);this.displayedElements_=new Map;a=function(d){return c.currentStats_[d]};this.parseFrom_=(new Map).set("loadTimes",function(d){var e=0;d=(0,$jscomp.makeIterator)(c.currentStats_[d]);for(var f=d.next();!f.done;f=d.next())e+=parseFloat(f.value);return e}).set("averageLoadTime",a).set("started",a).set("overlayAds",
a).set("playedCompletely",a).set("skipped",a).set("errors",a);this.timer_=new shaka.util.Timer(function(){c.onTimerTick_()});this.updateLocalizedStrings_();this.loadContainer_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&(c.onClick_(),
c.updateLocalizedStrings_())});this.eventManager.listen(this.player,"loading",function(){shaka.ui.Utils.setDisplay(c.button_,!1)});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){shaka.ui.Utils.setDisplay(c.button_,!0)})};$jscomp.inherits(shaka.ui.AdStatisticsButton,shaka.ui.Element);
shaka.ui.AdStatisticsButton.prototype.onClick_=function(){this.container_.classList.contains("shaka-hidden")?(this.icon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_OFF),this.timer_.tickEvery(.1),shaka.ui.Utils.setDisplay(this.container_,!0)):(this.icon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_ON),this.timer_.stop(),shaka.ui.Utils.setDisplay(this.container_,!1))};
shaka.ui.AdStatisticsButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.nameSpan_.textContent=this.localization.resolve(a.AD_STATISTICS);this.button_.ariaLabel=this.localization.resolve(a.AD_STATISTICS);a=this.container_.classList.contains("shaka-hidden")?a.OFF:a.ON;this.stateSpan_.textContent=this.localization.resolve(a)};
shaka.ui.AdStatisticsButton.prototype.generateComponent_=function(a){var b=shaka.util.Dom.createHTMLElement("div"),c=shaka.util.Dom.createHTMLElement("label");c.textContent=a+":";b.appendChild(c);c=shaka.util.Dom.createHTMLElement("span");c.textContent=this.parseFrom_.get(a)(a);b.appendChild(c);this.displayedElements_.set(a,c);return b};
shaka.ui.AdStatisticsButton.prototype.loadContainer_=function(){var a=this,b=shaka.util.Dom.createHTMLElement("div");b.classList.add("shaka-no-propagation");b.classList.add("shaka-statistics-close");var c=(new shaka.ui.MaterialSVGIcon(b,shaka.ui.Enums.MaterialDesignSVGIcons.CLOSE)).getSvgElement();c.classList.add("material-icons","notranslate");this.container_.appendChild(b);this.eventManager.listen(c,"click",function(){a.onClick_()});b=(0,$jscomp.makeIterator)(this.controls.getConfig().adStatisticsList);
for(c=b.next();!c.done;c=b.next())c=c.value,c in this.currentStats_?(this.container_.appendChild(this.generateComponent_(c)),this.statisticsList_.push(c)):shaka.log.alwaysWarn("Unrecognized ad statistic element:",c)};shaka.ui.AdStatisticsButton.prototype.onTimerTick_=function(){this.currentStats_=this.adManager.getStats();for(var a=(0,$jscomp.makeIterator)(this.statisticsList_),b=a.next();!b.done;b=a.next())b=b.value,this.displayedElements_.get(b).textContent=this.parseFrom_.get(b)(b)};
shaka.ui.AdStatisticsButton.prototype.release=function(){this.timer_.stop();this.timer_=null;shaka.ui.Element.prototype.release.call(this)};goog.exportSymbol("shaka.ui.AdStatisticsButton",shaka.ui.AdStatisticsButton);shaka.ui.AdStatisticsButton.Factory=function(){};shaka.ui.AdStatisticsButton.Factory.prototype.create=function(a,b){return new shaka.ui.AdStatisticsButton(a,b)};shaka.ui.OverflowMenu.registerElement("ad_statistics",new shaka.ui.AdStatisticsButton.Factory);
shaka.ui.ContextMenu.registerElement("ad_statistics",new shaka.ui.AdStatisticsButton.Factory);shaka.ui.AirPlayButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.airplayButton_=shaka.util.Dom.createButton();this.airplayButton_.classList.add("shaka-airplay-button");this.airplayButton_.classList.add("shaka-tooltip");this.airplayButton_.ariaPressed="false";(new shaka.ui.MaterialSVGIcon(this.airplayButton_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.AIRPLAY);window.WebKitPlaybackTargetAvailabilityEvent||this.airplayButton_.classList.add("shaka-hidden");a=shaka.util.Dom.createHTMLElement("label");
a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-overflow-menu-only");this.airplayNameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.airplayNameSpan_);this.airplayCurrentSelectionSpan_=shaka.util.Dom.createHTMLElement("span");this.airplayCurrentSelectionSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.airplayCurrentSelectionSpan_);this.airplayButton_.appendChild(a);this.parent.appendChild(this.airplayButton_);this.updateLocalizedStrings_();
this.onAirPlayStatusChange_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.airplayButton_,"click",function(){if(c.controls.isOpaque())c.onAirPlayClick_()});a=this.controls.getVideo();goog.asserts.assert(a!=null,"Should have a video!");this.eventManager.listen(a,"webkitplaybacktargetavailabilitychanged",
function(d){c.onAirPlayAvailabilityChange_(d)});this.eventManager.listen(a,"webkitcurrentplaybacktargetiswirelesschanged",function(){c.onAirPlayStatusChange_()})};$jscomp.inherits(shaka.ui.AirPlayButton,shaka.ui.Element);shaka.ui.AirPlayButton.prototype.onAirPlayClick_=function(){var a=this.controls.getVideo();goog.asserts.assert(a!=null,"Should have a video!");a.webkitShowPlaybackTargetPicker()};
shaka.ui.AirPlayButton.prototype.onAirPlayAvailabilityChange_=function(a){a=a.availability=="available";var b=this.player.getLoadMode()==shaka.Player.LoadMode.SRC_EQUALS;shaka.ui.Utils.setDisplay(this.airplayButton_,a&&b)};shaka.ui.AirPlayButton.prototype.onAirPlayStatusChange_=function(){var a=this.controls.getVideo();goog.asserts.assert(a!=null,"Should have a video!");this.airplayButton_.ariaPressed=a&&a.webkitCurrentPlaybackTargetIsWireless?"true":"false"};
shaka.ui.AirPlayButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.airplayButton_.ariaLabel=this.localization.resolve(a.AIRPLAY);this.airplayNameSpan_.textContent=this.localization.resolve(a.AIRPLAY)};goog.exportSymbol("shaka.ui.AirPlayButton",shaka.ui.AirPlayButton);shaka.ui.AirPlayButton.Factory=function(){};shaka.ui.AirPlayButton.Factory.prototype.create=function(a,b){return new shaka.ui.AirPlayButton(a,b)};shaka.ui.OverflowMenu.registerElement("airplay",new shaka.ui.AirPlayButton.Factory);
shaka.ui.Controls.registerElement("airplay",new shaka.ui.AirPlayButton.Factory);shaka.ui.Watermark=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.canvas_=document.createElement("canvas");this.canvas_.style.position="absolute";this.canvas_.style.top="0";this.canvas_.style.left="0";this.canvas_.style.pointerEvents="none";this.parent.appendChild(this.canvas_);this.resizeCanvas_();this.resizeObserver_=this.animationId_=null;window.ResizeObserver?(this.resizeObserver_=new ResizeObserver(function(){return c.resizeCanvas_()}),this.resizeObserver_.observe(this.parent)):
window.addEventListener("resize",function(){return c.resizeCanvas_()})};$jscomp.inherits(shaka.ui.Watermark,shaka.ui.Element);shaka.ui.Watermark.prototype.getContext2D_=function(){var a=this.canvas_.getContext("2d");return a?a:(shaka.log.error("2D context is not available"),null)};shaka.ui.Watermark.prototype.resizeCanvas_=function(){this.canvas_.width=this.parent.offsetWidth;this.canvas_.height=this.parent.offsetHeight};
shaka.ui.Watermark.prototype.setTextWatermark=function(a,b){a={type:"static",text:a,position:"top-right",color:"rgba(255, 255, 255, 0.7)",size:20,alpha:.7,interval:2E3,skip:500,displayDuration:2E3,transitionDuration:.5};b=Object.assign({},a,b||a);b.type==="static"?this.drawStaticWatermark_(b):b.type==="dynamic"&&this.startDynamicWatermark_(b)};
shaka.ui.Watermark.prototype.drawStaticWatermark_=function(a){var b=this.getContext2D_();if(b){b.clearRect(0,0,this.canvas_.width,this.canvas_.height);b.globalAlpha=a.alpha;b.fillStyle=a.color;b.font=a.size+"px Arial";var c=b.measureText(a.text);switch(a.position){case "top-left":c=20;var d=a.size+20;break;case "top-right":c=this.canvas_.width-c.width-20;d=a.size+20;break;case "bottom-left":c=20;d=this.canvas_.height-20;break;case "bottom-right":c=this.canvas_.width-c.width-20;d=this.canvas_.height-
20;break;default:c=(this.canvas_.width-c.width)/2,d=(this.canvas_.height+a.size)/2}b.fillText(a.text,c,d)}};
shaka.ui.Watermark.prototype.startDynamicWatermark_=function(a){var b=this,c=this.canvas_.getContext("2d"),d={left:0,top:0},e=0,f="fadeIn",g=Math.round(a.displayDuration*60),h=1/(Math.round(a.transitionDuration*60)/2),k=0,l=function(){c.font=a.size+"px Arial";var n=c.measureText(a.text).width,p=a.size;n=[{left:20,top:p+20},{left:b.canvas_.width-n-20,top:p+20},{left:20,top:b.canvas_.height-20},{left:b.canvas_.width-n-20,top:b.canvas_.height-20},{left:(b.canvas_.width-n)/2,top:(b.canvas_.height+p)/
2}];p=n[k];k=(k+1)%n.length;return p};d=l();var m=function(){if(b.animationId_){c.clearRect(0,0,b.canvas_.width,b.canvas_.height);switch(f){case "fadeIn":e=Math.min(a.alpha,e+h);e>=a.alpha&&(f="display");break;case "display":--g<=0&&(f="fadeOut");break;case "fadeOut":e=Math.max(0,e-h),e<=0&&(f="transition",d=l(),g=Math.round(a.displayDuration*60),f="fadeIn")}e>0&&(c.globalAlpha=e,c.fillStyle=a.color,c.font=a.size+"px Arial",c.fillText(a.text,d.left,d.top));b.animationId_&&(b.animationId_=requestAnimationFrame(m))}};
this.animationId_=requestAnimationFrame(m)};shaka.ui.Watermark.prototype.removeWatermark=function(){this.animationId_&&(cancelAnimationFrame(this.animationId_),this.animationId_=null);var a=this.getContext2D_();a&&a.clearRect(0,0,this.canvas_.width,this.canvas_.height)};
shaka.ui.Watermark.prototype.release=function(){var a=this;this.canvas_&&this.canvas_.parentNode&&this.canvas_.parentNode.removeChild(this.canvas_);this.resizeObserver_?(this.resizeObserver_.disconnect(),this.resizeObserver_=null):window.removeEventListener("resize",function(){return a.resizeCanvas_()});shaka.ui.Element.prototype.release.call(this)};goog.exportSymbol("shaka.ui.Watermark",shaka.ui.Watermark);goog.exportProperty(shaka.ui.Watermark.prototype,"removeWatermark",shaka.ui.Watermark.prototype.removeWatermark);
goog.exportProperty(shaka.ui.Watermark.prototype,"setTextWatermark",shaka.ui.Watermark.prototype.setTextWatermark);shaka.ui.Overlay=function(a,b,c,d){d=d===void 0?null:d;this.player_=a;this.videoContainer_=b;this.config_=this.defaultConfig_();var e="",f=!1;b.dataset&&b.dataset.shakaPlayerCastReceiverId?(f=b.dataset,e=f.shakaPlayerCastReceiverId,f=f.shakaPlayerCastAndroidReceiverCompatible==="true"):c.dataset&&c.dataset.shakaPlayerCastReceiverId&&(f=c.dataset,e=f.shakaPlayerCastReceiverId,f=f.shakaPlayerCastAndroidReceiverCompatible==="true");e.length&&(this.config_.castReceiverAppId=e,this.config_.castAndroidReceiverCompatible=
f);b.dataset.shakaPlayerContainer="";b.ui=this;this.isMobile()&&b.classList.add("shaka-mobile");this.controls_=new shaka.ui.Controls(a,b,c,d,this.config_);c.controls||a.setVideoContainer(b);b.ui=this;c.ui=this;this.watermark_=null};
shaka.ui.Overlay.prototype.destroy=function(a){a=a===void 0?!1:a;var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return b.controls_?c.yield(b.controls_.destroy(a),2):c.jumpTo(2);if(c.getNextAddressJsc()!=4)return b.controls_=null,b.player_?c.yield(b.player_.destroy(),4):c.jumpTo(4);b.player_=null;b.watermark_=null;c.jumpToEnd()})};shaka.ui.Overlay.prototype.isMobile=function(){return shaka.device.DeviceFactory.getDevice().getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE};
shaka.ui.Overlay.prototype.isSmartTV=function(){return shaka.device.DeviceFactory.getDevice().getDeviceType()==shaka.device.IDevice.DeviceType.TV};shaka.ui.Overlay.prototype.getConfiguration=function(){var a=this.defaultConfig_();shaka.util.ConfigUtils.mergeConfigObjects(a,this.config_,this.defaultConfig_(),{},"");return a};
shaka.ui.Overlay.prototype.configure=function(a,b){goog.asserts.assert(typeof a=="object"||arguments.length==2,"String configs should have values!");arguments.length==2&&typeof a=="string"&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));goog.asserts.assert(typeof a=="object","Should be an object!");var c=Object.assign({},this.config_);shaka.util.ConfigUtils.mergeConfigObjects(c,a,this.defaultConfig_(),{},"");goog.asserts.assert(this.player_!=null,"Should have a player!");var d=shaka.util.ConfigUtils.getDifferenceFromConfigObjects(c,
this.config_);Object.keys(d).length&&(this.config_=c,this.controls_.configure(this.config_),this.controls_.dispatchEvent(new shaka.util.FakeEvent("uiupdated")),this.setupCastSenderUrl_())};shaka.ui.Overlay.prototype.getControls=function(){return this.controls_};shaka.ui.Overlay.prototype.setEnabled=function(a){this.controls_.setEnabledShakaControls(a)};
shaka.ui.Overlay.prototype.setTextWatermark=function(a,b){a&&!this.watermark_&&this.videoContainer_&&this.controls_&&(this.watermark_=new shaka.ui.Watermark(this.videoContainer_,this.controls_));this.watermark_&&this.watermark_.setTextWatermark(a,b)};shaka.ui.Overlay.prototype.removeWatermark=function(){this.watermark_&&this.watermark_.removeWatermark()};
shaka.ui.Overlay.prototype.defaultConfig_=function(){var a="play_pause skip_previous skip_next mute volume time_and_duration spacer overflow_menu".split(" ");window.chrome&&a.push("cast");"remote"in HTMLMediaElement.prototype?a.push("remote"):window.WebKitPlaybackTargetAvailabilityEvent&&a.push("airplay");a.push("fullscreen");a={controlPanelElements:a,overflowMenuButtons:"captions quality language chapter picture_in_picture playback_rate recenter_vr toggle_stereoscopic".split(" "),statisticsList:"width height currentCodecs corruptedFrames decodedFrames droppedFrames drmTimeSeconds licenseTime liveLatency loadLatency bufferingTime manifestTimeSeconds estimatedBandwidth streamBandwidth maxSegmentDuration pauseTime playTime completionPercent manifestSizeBytes bytesDownloaded nonFatalErrorCount manifestPeriodCount manifestGapCount".split(" "),
adStatisticsList:"loadTimes averageLoadTime started overlayAds playedCompletely skipped errors".split(" "),contextMenuElements:["loop","picture_in_picture","save_video_frame","statistics","ad_statistics"],playbackRates:[.5,.75,1,1.25,1.5,1.75,2],fastForwardRates:[2,4,8,1],rewindRates:[-1,-2,-4,-8],addSeekBar:!0,addBigPlayButton:!1,customContextMenu:!1,castReceiverAppId:"",castAndroidReceiverCompatible:!1,clearBufferOnQualityChange:!0,showUnbufferedStart:!1,seekBarColors:{base:"rgba(255, 255, 255, 0.3)",
buffered:"rgba(255, 255, 255, 0.54)",played:"rgb(255, 255, 255)",adBreaks:"rgb(255, 204, 0)"},volumeBarColors:{base:"rgba(255, 255, 255, 0.54)",level:"rgb(255, 255, 255)"},qualityMarks:{720:"",1080:"HD",1440:"2K",2160:"4K",4320:"8K"},trackLabelFormat:shaka.ui.Overlay.TrackLabelFormat.LANGUAGE,textTrackLabelFormat:shaka.ui.Overlay.TrackLabelFormat.LANGUAGE,fadeDelay:0,closeMenusDelay:2,doubleClickForFullscreen:!0,singleClickForPlayAndPause:!0,enableKeyboardPlaybackControls:!0,enableFullscreenOnRotation:!1,
forceLandscapeOnFullscreen:!1,enableTooltips:!0,keyboardSeekDistance:5,keyboardLargeSeekDistance:60,fullScreenElement:this.videoContainer_,preferDocumentPictureInPicture:!0,showAudioChannelCountVariants:!0,seekOnTaps:!1,tapSeekDistance:10,refreshTickInSeconds:.125,displayInVrMode:!1,defaultVrProjectionMode:"equirectangular",setupMediaSession:!0,preferVideoFullScreenInVisionOS:!0,showAudioCodec:!0,showVideoCodec:!0,castSenderUrl:"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js",enableKeyboardPlaybackControlsInWindow:!1,
alwaysShowVolumeBar:!1};if(this.isMobile()){a.addBigPlayButton=!0;a.singleClickForPlayAndPause=!1;a.seekOnTaps=!0;a.enableTooltips=!1;a.doubleClickForFullscreen=!1;var b=shaka.device.DeviceFactory.getDevice();a.enableFullscreenOnRotation=b.getBrowserEngine()!==shaka.device.IDevice.BrowserEngine.WEBKIT;a.forceLandscapeOnFullscreen=!0;var c=["play_pause","skip_previous","skip_next","volume"];a.controlPanelElements=a.controlPanelElements.filter(function(e){return!c.includes(e)});a.overflowMenuButtons=
a.overflowMenuButtons.filter(function(e){return!c.includes(e)});a.contextMenuElements=a.contextMenuElements.filter(function(e){return!c.includes(e)})}else if(this.isSmartTV()){a.addBigPlayButton=!0;a.singleClickForPlayAndPause=!1;a.enableTooltips=!1;a.doubleClickForFullscreen=!1;var d="play_pause cast remote airplay volume save_video_frame".split(" ");a.controlPanelElements=a.controlPanelElements.filter(function(e){return!d.includes(e)});a.overflowMenuButtons=a.overflowMenuButtons.filter(function(e){return!d.includes(e)});
a.contextMenuElements=a.contextMenuElements.filter(function(e){return!d.includes(e)})}return a};shaka.ui.Overlay.prototype.setupCastSenderUrl_=function(){var a=this.config_.castSenderUrl;if(a&&this.config_.castReceiverAppId&&window.chrome&&!chrome.cast&&!this.isSmartTV()){for(var b=!1,c=(0,$jscomp.makeIterator)(document.getElementsByTagName("script")),d=c.next();!d.done;d=c.next())if(d.value.src===a){b=!0;break}b||(b=document.createElement("script"),b.src=a,b.defer=!0,document.head.appendChild(b))}};
shaka.ui.Overlay.scanPageForShakaElements_=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,w,v,x,y,A,B,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.getNextAddressJsc()){case 1:shaka.polyfill.installAll();if(!shaka.Player.isBrowserSupported())return shaka.log.error("Shaka Player does not support this browser. Please see https://tinyurl.com/y7s4j9tr for the list of supported browsers."),shaka.ui.Overlay.dispatchLoadedEvent_("shaka-ui-load-failed",shaka.ui.Overlay.FailReasonCode.NO_BROWSER_SUPPORT),
z.return();a=document.querySelectorAll("[data-shaka-player-container]");b=document.querySelectorAll("[data-shaka-player]");c=document.querySelectorAll("[data-shaka-player-canvas]");d=document.querySelectorAll("[data-shaka-player-vr-canvas]");if(!b.length&&!a.length){z.jumpTo(2);break}if(b.length&&!a.length){z.jumpTo(3);break}e=(0,$jscomp.makeIterator)(a);f=e.next();case 5:if(f.done){z.jumpTo(2);break}g=f.value;if(g.ui){z.jumpTo(6);break}goog.asserts.assert(g.tagName.toLowerCase()=="div","Container should be a div!");
h=null;k=(0,$jscomp.makeIterator)(b);for(l=k.next();!l.done;l=k.next())if(m=l.value,goog.asserts.assert(m.tagName.toLowerCase()=="video","Should be a video element!"),m.parentElement==g){h=m;break}h||(h=document.createElement("video"),h.setAttribute("playsinline",""),g.appendChild(h));n=shaka.ui.Overlay.findOrMakeSpecialCanvases_(g,c,d);p=n.lcevcCanvas;q=n.vrCanvas;z.setCatchFinallyBlocks(8);return z.yield(shaka.ui.Overlay.setupUIandAutoLoad_(g,h,p,q),10);case 10:z.leaveTryBlock(6);break;case 8:return r=
z.enterCatchBlock(),shaka.log.error("Error setting up Shaka Player",r),shaka.ui.Overlay.dispatchLoadedEvent_("shaka-ui-load-failed",shaka.ui.Overlay.FailReasonCode.PLAYER_FAILED_TO_LOAD),z.return();case 6:f=e.next();z.jumpTo(5);break;case 3:t=(0,$jscomp.makeIterator)(b),u=t.next();case 11:if(u.done){z.jumpTo(2);break}w=u.value;if(w.ui){z.jumpTo(12);break}goog.asserts.assert(w.tagName.toLowerCase()=="video","Should be a video element!");v=document.createElement("div");x=w.parentElement;x.replaceChild(v,
w);v.appendChild(w);y=shaka.ui.Overlay.findOrMakeSpecialCanvases_(v,c,d);A=y.lcevcCanvas;B=y.vrCanvas;z.setCatchFinallyBlocks(14);return z.yield(shaka.ui.Overlay.setupUIandAutoLoad_(v,w,A,B),16);case 16:z.leaveTryBlock(12);break;case 14:return D=z.enterCatchBlock(),shaka.log.error("Error setting up Shaka Player",D),shaka.ui.Overlay.dispatchLoadedEvent_("shaka-ui-load-failed",shaka.ui.Overlay.FailReasonCode.PLAYER_FAILED_TO_LOAD),z.return();case 12:u=t.next();z.jumpTo(11);break;case 2:shaka.ui.Overlay.dispatchLoadedEvent_("shaka-ui-loaded"),
z.jumpToEnd()}})};shaka.ui.Overlay.dispatchLoadedEvent_=function(a,b){var c=null;b!=void 0&&(c={reasonCode:b});a=new CustomEvent(a,{detail:c});document.dispatchEvent(a)};
shaka.ui.Overlay.setupUIandAutoLoad_=function(a,b,c,d){var e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.getNextAddressJsc()){case 1:e=new shaka.Player;f=[];if(g=b.getAttribute("src"))f.push(g),b.removeAttribute("src");h=(0,$jscomp.makeIterator)(b.getElementsByTagName("source"));for(k=h.next();!k.done;k=h.next())l=k.value,f.push(l.src),b.removeChild(l);return t.yield(e.attach(shaka.util.Dom.asHTMLMediaElement(b)),2);case 2:e.attachCanvas(c),m=new shaka.ui.Overlay(e,
shaka.util.Dom.asHTMLElement(a),shaka.util.Dom.asHTMLMediaElement(b),d?shaka.util.Dom.asHTMLCanvasElement(d):null),shaka.util.Dom.asHTMLMediaElement(b).controls&&m.getControls().setEnabledNativeControls(!0),n=(0,$jscomp.makeIterator)(f),p=n.next();case 3:if(p.done){t.jumpTo(0);break}q=p.value;t.setCatchFinallyBlocks(6);return t.yield(m.getControls().getPlayer().load(q),8);case 8:t.jumpTo(0);break;case 6:r=t.enterCatchBlock(),shaka.log.error("Error auto-loading asset",r);case 4:p=n.next(),t.jumpTo(3)}})};
shaka.ui.Overlay.findOrMakeSpecialCanvases_=function(a,b,c){var d=null;b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next())if(e=e.value,goog.asserts.assert(e.tagName.toLowerCase()=="canvas","Should be a canvas element!"),e.parentElement==a){d=e;break}d||(d=document.createElement("canvas"),d.classList.add("shaka-canvas-container"),a.appendChild(d));b=null;c=(0,$jscomp.makeIterator)(c);for(e=c.next();!e.done;e=c.next())if(e=e.value,goog.asserts.assert(e.tagName.toLowerCase()=="canvas",
"Should be a canvas element!"),e.parentElement==a){b=e;break}return{lcevcCanvas:d,vrCanvas:b}};goog.exportSymbol("shaka.ui.Overlay",shaka.ui.Overlay);goog.exportProperty(shaka.ui.Overlay.prototype,"removeWatermark",shaka.ui.Overlay.prototype.removeWatermark);goog.exportProperty(shaka.ui.Overlay.prototype,"setTextWatermark",shaka.ui.Overlay.prototype.setTextWatermark);goog.exportProperty(shaka.ui.Overlay.prototype,"setEnabled",shaka.ui.Overlay.prototype.setEnabled);
goog.exportProperty(shaka.ui.Overlay.prototype,"getControls",shaka.ui.Overlay.prototype.getControls);goog.exportProperty(shaka.ui.Overlay.prototype,"configure",shaka.ui.Overlay.prototype.configure);goog.exportProperty(shaka.ui.Overlay.prototype,"getConfiguration",shaka.ui.Overlay.prototype.getConfiguration);goog.exportProperty(shaka.ui.Overlay.prototype,"isSmartTV",shaka.ui.Overlay.prototype.isSmartTV);goog.exportProperty(shaka.ui.Overlay.prototype,"isMobile",shaka.ui.Overlay.prototype.isMobile);
goog.exportProperty(shaka.ui.Overlay.prototype,"destroy",shaka.ui.Overlay.prototype.destroy);shaka.ui.Overlay.TrackLabelFormat={LANGUAGE:0,ROLE:1,LANGUAGE_ROLE:2,LABEL:3};goog.exportProperty(shaka.ui.Overlay,"TrackLabelFormat",shaka.ui.Overlay.TrackLabelFormat);shaka.ui.Overlay.FailReasonCode={NO_BROWSER_SUPPORT:0,PLAYER_FAILED_TO_LOAD:1};goog.exportProperty(shaka.ui.Overlay,"FailReasonCode",shaka.ui.Overlay.FailReasonCode);
document.readyState=="complete"?function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(a){if(a.getNextAddressJsc()==1)return a.yield(Promise.resolve(),2);shaka.ui.Overlay.scanPageForShakaElements_();a.jumpToEnd()})}():window.addEventListener("load",shaka.ui.Overlay.scanPageForShakaElements_);shaka.ui.LanguageUtils=function(){};shaka.ui.LanguageUtils.areAudioTracksEqualExceptLabel_=function(a){var b=function(d){return{codecs:d.codecs,channelCount:d.channelCount,language:d.language,roles:d.roles,spatialAudio:d.spatialAudio}},c=b(a[0]);return a.every(function(d){return JSON.stringify(b(d))===JSON.stringify(c)})};
shaka.ui.LanguageUtils.updateAudioTracks=function(a,b,c,d,e,f,g,h,k){var l=shaka.ui.Locales.Ids,m=a.find(function(I){return I.active==1});a.length>1&&a[0].label&&g!=shaka.ui.Overlay.TrackLabelFormat.LABEL&&shaka.ui.LanguageUtils.areAudioTracksEqualExceptLabel_(a)&&(g=shaka.ui.Overlay.TrackLabelFormat.LABEL);for(var n=new Map,p=(0,$jscomp.makeIterator)(a),q=p.next();!q.done;q=p.next())q=q.value,q.codecs&&(n.has(q.language)||n.set(q.language,new Set),n.get(q.language).add(shaka.util.MimeUtils.getNormalizedCodec(q.codecs)));
var r=function(I){return n.has(I)&&n.get(I).size>1};p=shaka.ui.Utils.getFirstDescendantWithClassName(b,"shaka-back-to-overflow-button");shaka.util.Dom.removeAllChildren(b);b.appendChild(p);p=function(I,F,J,K,H,M){F=[I,F,M];h&&K!=null&&F.push(K);k&&r(I)&&H&&F.push(H);J&&g==shaka.ui.Overlay.TrackLabelFormat.LABEL&&F.push(J);return F.join(": ")};q=function(I){var F="";I>=5&&(F=" "+f.resolve(l.SURROUND));return F};var t=function(I){var F="";I=="aac"?F="AAC":I==="ac-3"?F="Dolby":I==="ec-3"?F="DD+":I===
"ac-4"?F="Dolby AC-4":I==="opus"?F="Opus":I==="flac"&&(F="fLaC");return F?" "+F:F},u=new Set;m=m?p(m.language,m.roles.join(", "),m.label,m.channelsCount,m.codecs&&shaka.util.MimeUtils.getNormalizedCodec(m.codecs),m.spatialAudio):"";a=(0,$jscomp.makeIterator)(a);for(var w=a.next(),v={};!w.done;v={track$jscomp$50:void 0},w=a.next()){v.track$jscomp$50=w.value;w=v.track$jscomp$50.language;var x=v.track$jscomp$50.roles.join(", "),y=v.track$jscomp$50.label,A=v.track$jscomp$50.channelsCount,B=v.track$jscomp$50.codecs&&
shaka.util.MimeUtils.getNormalizedCodec(v.track$jscomp$50.codecs),D=v.track$jscomp$50.spatialAudio,z=p(w,x,y,A,B,D);if(!u.has(z)){u.add(z);var C=shaka.util.Dom.createButton();C.addEventListener("click",function(I){return function(){c(I.track$jscomp$50)}}(v));var E=shaka.util.Dom.createHTMLElement("span");C.appendChild(E);E.textContent=shaka.ui.LanguageUtils.getLanguageName(w,f);var G="";k&&h&&D&&(B=="ec-3"||B=="ac-4")?G+=" Dolby Atmos":(k&&r(w)&&(G+=t(B)),h&&(G+=q(A)));switch(g){case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE:E.textContent+=
G;break;case shaka.ui.Overlay.TrackLabelFormat.ROLE:E.textContent+=G;x?E.textContent=x:(shaka.log.alwaysWarn("Track #"+JSON.stringify(v.track$jscomp$50)+" does not have a role, but the UI is configured to only show role."),E.textContent="?");break;case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE_ROLE:E.textContent+=G;x&&(E.textContent+=": "+x);break;case shaka.ui.Overlay.TrackLabelFormat.LABEL:y?E.textContent=y:(shaka.log.alwaysWarn("Track #"+JSON.stringify(v.track$jscomp$50)+" does not have a label, but the UI is configured to only show labels."),
E.textContent="?")}d&&z==m&&(C.appendChild(shaka.ui.Utils.checkmarkIcon()),E.classList.add("shaka-chosen-item"),C.ariaSelected="true",e.textContent=E.textContent);b.appendChild(C)}}};
shaka.ui.LanguageUtils.updateTextTracks=function(a,b,c,d,e,f,g){var h=shaka.ui.Locales.Ids,k=a.find(function(y){return y.active==1}),l=shaka.ui.Utils.getFirstDescendantWithClassName(b,"shaka-back-to-overflow-button");shaka.util.Dom.removeAllChildren(b);b.appendChild(l);l=function(y,A,B,D){y=[y,A,D];B&&g==shaka.ui.Overlay.TrackLabelFormat.LABEL&&y.push(B);return y.join(": ")};var m=new Set;k=k?l(k.language,k.roles.join(", "),k.label,k.forced):"";a=(0,$jscomp.makeIterator)(a);for(var n=a.next(),p={};!n.done;p=
{track$jscomp$53:void 0},n=a.next()){p.track$jscomp$53=n.value;n=p.track$jscomp$53.language;var q=p.track$jscomp$53.forced,r=f.resolve(h.SUBTITLE_FORCED),t=p.track$jscomp$53.roles.join(", "),u=p.track$jscomp$53.label,w=l(n,t,u,q);if(!m.has(w)){m.add(w);var v=shaka.util.Dom.createButton();v.addEventListener("click",function(y){return function(){c(y.track$jscomp$53)}}(p));var x=shaka.util.Dom.createHTMLElement("span");v.appendChild(x);x.textContent=shaka.ui.LanguageUtils.getLanguageName(n,f);switch(g){case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE:q&&
(x.textContent+=" ("+r+")");break;case shaka.ui.Overlay.TrackLabelFormat.ROLE:t?x.textContent=t:(shaka.log.alwaysWarn("Track #"+p.track$jscomp$53.id+" does not have a role, but the UI is configured to only show role."),x.textContent="?");q&&(x.textContent+=" ("+r+")");break;case shaka.ui.Overlay.TrackLabelFormat.LANGUAGE_ROLE:t&&(x.textContent+=": "+t);q&&(x.textContent+=" ("+r+")");break;case shaka.ui.Overlay.TrackLabelFormat.LABEL:u?x.textContent=u:(shaka.log.alwaysWarn("Track #"+p.track$jscomp$53.id+
" does not have a label, but the UI is configured to only show labels."),x.textContent="?")}d&&w==k&&(v.appendChild(shaka.ui.Utils.checkmarkIcon()),x.classList.add("shaka-chosen-item"),v.ariaSelected="true",e.textContent=x.textContent);b.appendChild(v)}}};
shaka.ui.LanguageUtils.getLanguageName=function(a,b){if(!a&&!b)return"";switch(a){case "mul":return b.resolve(shaka.ui.Locales.Ids.MULTIPLE_LANGUAGES);case "und":return b.resolve(shaka.ui.Locales.Ids.UNDETERMINED_LANGUAGE);case "zxx":return b.resolve(shaka.ui.Locales.Ids.NOT_APPLICABLE)}var c=shaka.util.LanguageUtils.getBase(a);return a in mozilla.LanguageMapping?mozilla.LanguageMapping[a]:c in mozilla.LanguageMapping?mozilla.LanguageMapping[c]+" ("+a+")":b.resolve(shaka.ui.Locales.Ids.UNRECOGNIZED_LANGUAGE)+
" ("+a+")"};shaka.ui.SettingsMenu=function(a,b,c){shaka.ui.Element.call(this,a,b);var d=this;this.videoContainer_=this.controls.getVideoContainer();this.addButton_(c);this.addMenu_();this.inOverflowMenu_();this.eventManager.listen(this.button,"click",function(){if(d.controls.isOpaque())d.onButtonClick_()});this.resizeObserver_=null;a=function(){return d.computeMaxHeight_()};window.ResizeObserver?(this.resizeObserver_=new ResizeObserver(a),this.resizeObserver_.observe(this.controls.getVideoContainer())):this.eventManager.listen(window,
"resize",a)};$jscomp.inherits(shaka.ui.SettingsMenu,shaka.ui.Element);shaka.ui.SettingsMenu.prototype.release=function(){this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);shaka.ui.Element.prototype.release.call(this)};
shaka.ui.SettingsMenu.prototype.addButton_=function(a){this.button=shaka.util.Dom.createButton();this.button.classList.add("shaka-overflow-button");this.icon=new shaka.ui.MaterialSVGIcon(this.button,a);a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-overflow-menu-only");a.classList.add("shaka-overflow-button-label-inline");this.nameSpan=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.nameSpan);this.currentSelection=shaka.util.Dom.createHTMLElement("span");
this.currentSelection.classList.add("shaka-current-selection-span");a.appendChild(this.currentSelection);this.button.appendChild(a);this.parent.appendChild(this.button)};
shaka.ui.SettingsMenu.prototype.addMenu_=function(){var a=this;this.menu=shaka.util.Dom.createHTMLElement("div");this.menu.classList.add("shaka-no-propagation");this.menu.classList.add("shaka-show-controls-on-mouse-over");this.menu.classList.add("shaka-settings-menu");this.menu.classList.add("shaka-hidden");this.backButton=shaka.util.Dom.createButton();this.backButton.classList.add("shaka-back-to-overflow-button");this.menu.appendChild(this.backButton);this.eventManager.listen(this.backButton,"click",
function(){a.controls.hideSettingsMenus()});this.backIcon_=new shaka.ui.MaterialSVGIcon(this.backButton,shaka.ui.Enums.MaterialDesignSVGIcons.CLOSE);this.backSpan=shaka.util.Dom.createHTMLElement("span");this.backButton.appendChild(this.backSpan);this.controls.getControlsContainer().appendChild(this.menu)};
shaka.ui.SettingsMenu.prototype.inOverflowMenu_=function(){var a=this;this.parent.classList.contains("shaka-overflow-menu")&&(this.backIcon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.BACK),this.eventManager.listen(this.menu,"click",function(){shaka.ui.Utils.setDisplay(a.menu,!1);shaka.ui.Utils.setDisplay(a.parent,!0);var b=function(d){return d.classList.contains("shaka-hidden")==0},c=shaka.util.Iterables;c.some(a.parent.childNodes,b)&&c.filter(a.parent.childNodes,b)[0].focus();a.controls.computeOpacity();
a.computeMaxHeight_()}))};shaka.ui.SettingsMenu.prototype.onButtonClick_=function(){this.menu.classList.contains("shaka-hidden")?(this.controls.dispatchEvent(new shaka.util.FakeEvent("submenuopen")),shaka.ui.Utils.setDisplay(this.menu,!0),shaka.ui.Utils.focusOnTheChosenItem(this.menu),this.computeMaxHeight_()):shaka.ui.Utils.setDisplay(this.menu,!1)};
shaka.ui.SettingsMenu.prototype.computeMaxHeight_=function(){var a=this.menu.getBoundingClientRect(),b=window.getComputedStyle(this.menu),c=parseFloat(b.paddingTop);b=parseFloat(b.paddingBottom);var d=this.videoContainer_.getBoundingClientRect();this.menu.style.maxHeight=a.bottom-d.top-c-b-5+"px"};goog.exportSymbol("shaka.ui.SettingsMenu",shaka.ui.SettingsMenu);shaka.ui.AudioLanguageSelection=function(a,b){shaka.ui.SettingsMenu.call(this,a,b,shaka.ui.Enums.MaterialDesignSVGIcons.LANGUAGE);var c=this;this.button.classList.add("shaka-language-button");this.button.classList.add("shaka-tooltip-status");this.menu.classList.add("shaka-audio-languages");this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});
this.eventManager.listen(this.player,"loading",function(){c.onAudioTracksChanged_()});this.eventManager.listen(this.player,"loaded",function(){c.onAudioTracksChanged_()});this.eventManager.listen(this.player,"unloading",function(){c.onAudioTracksChanged_()});this.eventManager.listen(this.player,"audiotrackschanged",function(){c.onAudioTracksChanged_()});this.updateLocalizedStrings_();this.onAudioTracksChanged_()};$jscomp.inherits(shaka.ui.AudioLanguageSelection,shaka.ui.SettingsMenu);
shaka.ui.AudioLanguageSelection.prototype.onAudioTracksChanged_=function(){var a=this,b=this.player.getAudioTracks()||[];shaka.ui.LanguageUtils.updateAudioTracks(b,this.menu,function(c){return a.onAudioTrackSelected_(c)},!0,this.currentSelection,this.localization,this.controls.getConfig().trackLabelFormat,this.controls.getConfig().showAudioChannelCountVariants,this.controls.getConfig().showAudioCodec);shaka.ui.Utils.focusOnTheChosenItem(this.menu);this.controls.dispatchEvent(new shaka.util.FakeEvent("languageselectionupdated"));
this.button.setAttribute("shaka-status",this.currentSelection.innerText);b=this.menu.getElementsByTagName("button").length;shaka.ui.Utils.setDisplay(this.button,b>2)};shaka.ui.AudioLanguageSelection.prototype.onAudioTrackSelected_=function(a){this.player.selectAudioTrack(a);var b={preferredAudioLanguage:a.language,preferSpatialAudio:a.spatialAudio};a.label&&(b.preferredAudioLabel=a.label);a.channelsCount&&(b.preferredAudioChannelCount=a.channelsCount);this.player.configure(b)};
shaka.ui.AudioLanguageSelection.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.backButton.ariaLabel=this.localization.resolve(a.BACK);this.button.ariaLabel=this.localization.resolve(a.LANGUAGE);this.nameSpan.textContent=this.localization.resolve(a.LANGUAGE);this.backSpan.textContent=this.localization.resolve(a.LANGUAGE)};goog.exportSymbol("shaka.ui.AudioLanguageSelection",shaka.ui.AudioLanguageSelection);shaka.ui.AudioLanguageSelection.Factory=function(){};
shaka.ui.AudioLanguageSelection.Factory.prototype.create=function(a,b){return new shaka.ui.AudioLanguageSelection(a,b)};shaka.ui.OverflowMenu.registerElement("language",new shaka.ui.AudioLanguageSelection.Factory);shaka.ui.Controls.registerElement("language",new shaka.ui.AudioLanguageSelection.Factory);shaka.ui.CastButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.castProxy_=this.controls.getCastProxy();this.castButton_=shaka.util.Dom.createButton();this.castButton_.classList.add("shaka-cast-button");this.castButton_.classList.add("shaka-tooltip");this.castButton_.ariaPressed="false";this.castIcon_=new shaka.ui.MaterialSVGIcon(this.castButton_,shaka.ui.Enums.MaterialDesignSVGIcons.CAST);a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");
a.classList.add("shaka-overflow-menu-only");a.classList.add("shaka-simple-overflow-button-label-inline");this.castNameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.castNameSpan_);this.castCurrentSelectionSpan_=shaka.util.Dom.createHTMLElement("span");this.castCurrentSelectionSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.castCurrentSelectionSpan_);this.castButton_.appendChild(a);this.parent.appendChild(this.castButton_);this.updateLocalizedStrings_();this.onCastStatusChange_();
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.castButton_,"click",function(){if(c.controls.isOpaque())c.onCastClick_()});this.eventManager.listen(this.controls,"caststatuschanged",function(){c.onCastStatusChange_()})};$jscomp.inherits(shaka.ui.CastButton,shaka.ui.Element);
shaka.ui.CastButton.prototype.onCastClick_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1){if(a.castProxy_.isCasting())return a.castProxy_.suggestDisconnect(),c.jumpTo(0);c.setCatchFinallyBlocks(3);a.castButton_.disabled=!0;return c.yield(a.castProxy_.cast(),5)}if(c.getNextAddressJsc()!=3)return a.castButton_.disabled=!1,c.leaveTryBlock(0);b=c.enterCatchBlock();a.castButton_.disabled=!1;b.code!=shaka.util.Error.Code.CAST_CANCELED_BY_USER&&
a.controls.dispatchEvent(new shaka.util.FakeEvent("error",(new Map).set("detail",b)));c.jumpToEnd()})};shaka.ui.CastButton.prototype.onCastStatusChange_=function(){var a=this.castProxy_.canCast()&&this.controls.isCastAllowed(),b=this.castProxy_.isCasting(),c=shaka.ui.Enums.MaterialDesignSVGIcons;shaka.ui.Utils.setDisplay(this.castButton_,a);this.castIcon_.use(b?c.EXIT_CAST:c.CAST);a&&(this.castButton_.ariaPressed=b?"true":"false");this.setCurrentCastSelection_()};
shaka.ui.CastButton.prototype.setCurrentCastSelection_=function(){this.castProxy_.isCasting()?this.castCurrentSelectionSpan_.textContent=this.castProxy_.receiverName():this.castCurrentSelectionSpan_.textContent=this.localization.resolve(shaka.ui.Locales.Ids.OFF)};shaka.ui.CastButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.castButton_.ariaLabel=this.localization.resolve(a.CAST);this.castNameSpan_.textContent=this.localization.resolve(a.CAST);this.setCurrentCastSelection_()};
goog.exportSymbol("shaka.ui.CastButton",shaka.ui.CastButton);shaka.ui.CastButton.Factory=function(){};shaka.ui.CastButton.Factory.prototype.create=function(a,b){return new shaka.ui.CastButton(a,b)};shaka.ui.OverflowMenu.registerElement("cast",new shaka.ui.CastButton.Factory);shaka.ui.Controls.registerElement("cast",new shaka.ui.CastButton.Factory);shaka.ui.ChapterSelection=function(a,b){shaka.ui.SettingsMenu.call(this,a,b,shaka.ui.Enums.MaterialDesignSVGIcons.CHAPTER);var c=this;this.button.classList.add("shaka-chapter-button");this.menu.classList.add("shaka-chapters");this.button.classList.add("shaka-tooltip-status");this.chapters_=[];this.chaptersLanguage_="und";this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_();c.updateChapters_()});this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_();c.updateChapters_()});this.eventManager.listen(this.player,"unloading",function(){c.deletePreviousChapters_();c.chaptersLanguage_="und";c.chapters_=[]});this.eventManager.listen(this.player,"trackschanged",function(){c.updateChapters_()});this.updateLocalizedStrings_();this.updateChapters_()};$jscomp.inherits(shaka.ui.ChapterSelection,shaka.ui.SettingsMenu);
shaka.ui.ChapterSelection.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.backButton.ariaLabel=this.localization.resolve(a.BACK);this.button.ariaLabel=this.localization.resolve(a.CHAPTERS);this.nameSpan.textContent=this.localization.resolve(a.CHAPTERS);this.backSpan.textContent=this.localization.resolve(a.CHAPTERS)};
shaka.ui.ChapterSelection.prototype.deletePreviousChapters_=function(){var a=shaka.ui.Utils.getFirstDescendantWithClassName(this.menu,"shaka-back-to-overflow-button");shaka.util.Dom.removeAllChildren(this.menu);this.menu.appendChild(a);shaka.ui.Utils.setDisplay(this.button,!1)};
shaka.ui.ChapterSelection.prototype.updateChapters_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.getNextAddressJsc()){case 1:b=function(u,w){return!u&&!w||u.id===w.id&&u.title===w.title&&u.startTime===w.startTime&&u.endTime===w.endTime},c="und",d=[],e=a.localization.getCurrentLocales(),f=(0,$jscomp.makeIterator)(Array.from(e)),g=f.next();case 2:if(g.done){t.jumpTo(4);break}c=h=g.value;if(!a.player){t.jumpTo(5);break}return t.yield(a.player.getChaptersAsync(c),
6);case 6:d=t.getYieldResultJsc()||[];case 5:if(d.length){t.jumpTo(4);break}g=f.next();t.jumpTo(2);break;case 4:if(d.length){t.jumpTo(7);break}c="und";if(!a.player){t.jumpTo(7);break}return t.yield(a.player.getChaptersAsync(c),9);case 9:d=t.getYieldResultJsc()||[];case 7:k=c!==a.chaptersLanguage_;l=a.chapters_.length!==d.length||!a.chapters_.some(function(u,w){w=d.at(w);return b(u,w)||d.some(function(v){return b(u,v)})});a.chaptersLanguage_=c;a.chapters_=d;if(!d.length)a.deletePreviousChapters_();
else if(k||l){m=(0,$jscomp.makeIterator)(a.chapters_);n=m.next();for(p={};!n.done;p={chapter$jscomp$2:void 0},n=m.next())p.chapter$jscomp$2=n.value,q=shaka.util.Dom.createButton(),r=shaka.util.Dom.createHTMLElement("span"),r.classList.add("shaka-chapter"),r.textContent=p.chapter$jscomp$2.title,q.appendChild(r),a.eventManager.listen(q,"click",function(u){return function(){a.controls.isOpaque()&&(a.video.currentTime=u.chapter$jscomp$2.startTime)}}(p)),a.menu.appendChild(q);shaka.ui.Utils.setDisplay(a.button,
!0);shaka.ui.Utils.focusOnTheChosenItem(a.menu)}t.jumpToEnd()}})};goog.exportSymbol("shaka.ui.ChapterSelection",shaka.ui.ChapterSelection);shaka.ui.ChapterSelection.Factory=function(){};shaka.ui.ChapterSelection.Factory.prototype.create=function(a,b){return new shaka.ui.ChapterSelection(a,b)};shaka.ui.OverflowMenu.registerElement("chapter",new shaka.ui.ChapterSelection.Factory);shaka.ui.Controls.registerElement("chapter",new shaka.ui.ChapterSelection.Factory);shaka.ui.FastForwardButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-fast-forward-button");this.button_.classList.add("shaka-tooltip-status");this.button_.setAttribute("shaka-status","1x");(new shaka.ui.MaterialSVGIcon(this.button_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.FAST_FORWARD);this.parent.appendChild(this.button_);this.updateAriaLabel_();this.fastForwardRates_=this.controls.getConfig().fastForwardRates;
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&c.fastForward_()});this.eventManager.listen(this.player,"ratechange",function(){c.button_.setAttribute("shaka-status",c.player.getPlaybackRate()+"x")})};
$jscomp.inherits(shaka.ui.FastForwardButton,shaka.ui.Element);shaka.ui.FastForwardButton.prototype.updateAriaLabel_=function(){this.button_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.FAST_FORWARD)};
shaka.ui.FastForwardButton.prototype.fastForward_=function(){if(this.video.duration){var a=this.player.getPlaybackRate();a=this.fastForwardRates_.indexOf(a)+1;a=a!=this.fastForwardRates_.length?this.fastForwardRates_[a]:this.fastForwardRates_[0];this.video.paused&&this.video.play();this.player.trickPlay(a);this.button_.setAttribute("shaka-status",a+"x")}};goog.exportSymbol("shaka.ui.FastForwardButton",shaka.ui.FastForwardButton);shaka.ui.FastForwardButton.Factory=function(){};
shaka.ui.FastForwardButton.Factory.prototype.create=function(a,b){return new shaka.ui.FastForwardButton(a,b)};shaka.ui.Controls.registerElement("fast_forward",new shaka.ui.FastForwardButton.Factory);shaka.ui.FullscreenButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.localVideo_=this.controls.getLocalVideo();this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-fullscreen-button");this.button_.classList.add("shaka-tooltip");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.FULLSCREEN);this.checkSupport_();this.parent.appendChild(this.button_);this.updateAriaLabel_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,
function(){c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.button_,"click",function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return c.controls.isOpaque()?d.yield(c.controls.toggleFullScreen(),0):d.return()})});this.eventManager.listen(document,"fullscreenchange",function(){c.updateIcon_();c.updateAriaLabel_()});this.eventManager.listen(this.localVideo_,
"loadedmetadata",function(){c.checkSupport_()});this.eventManager.listen(this.localVideo_,"loadeddata",function(){c.checkSupport_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.checkSupport_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.checkSupport_()})};$jscomp.inherits(shaka.ui.FullscreenButton,shaka.ui.Element);
shaka.ui.FullscreenButton.prototype.checkSupport_=function(){this.controls.isFullScreenSupported()?this.button_.classList.remove("shaka-hidden"):this.button_.classList.add("shaka-hidden")};shaka.ui.FullscreenButton.prototype.updateAriaLabel_=function(){var a=shaka.ui.Locales.Ids;a=this.controls.isFullScreenEnabled()?a.EXIT_FULL_SCREEN:a.FULL_SCREEN;this.button_.ariaLabel=this.localization.resolve(a)};
shaka.ui.FullscreenButton.prototype.updateIcon_=function(){this.icon_.use(this.controls.isFullScreenEnabled()?shaka.ui.Enums.MaterialDesignSVGIcons.EXIT_FULLSCREEN:shaka.ui.Enums.MaterialDesignSVGIcons.FULLSCREEN)};goog.exportSymbol("shaka.ui.FullscreenButton",shaka.ui.FullscreenButton);shaka.ui.FullscreenButton.Factory=function(){};shaka.ui.FullscreenButton.Factory.prototype.create=function(a,b){return new shaka.ui.FullscreenButton(a,b)};shaka.ui.Controls.registerElement("fullscreen",new shaka.ui.FullscreenButton.Factory);shaka.ui.LoopButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;a=shaka.ui.Locales.Ids;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-loop-button");this.button_.classList.add("shaka-tooltip");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.LOOP);b=shaka.util.Dom.createHTMLElement("label");b.classList.add("shaka-overflow-button-label");b.classList.add("shaka-overflow-menu-only");b.classList.add("shaka-simple-overflow-button-label-inline");
this.nameSpan_=shaka.util.Dom.createHTMLElement("span");this.nameSpan_.textContent=this.localization.resolve(a.LOOP);b.appendChild(this.nameSpan_);this.currentState_=shaka.util.Dom.createHTMLElement("span");this.currentState_.classList.add("shaka-current-selection-span");b.appendChild(this.currentState_);this.button_.appendChild(b);this.updateLocalizedStrings_();this.parent.appendChild(this.button_);this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.button_,"click",function(){if(c.controls.isOpaque())c.onClick_()});this.loopEnabled_=this.video.loop;this.timer_=new shaka.util.Timer(function(){c.onTimerTick_()});this.timer_.tickEvery(1);this.eventManager.listen(this.player,"unloading",function(){c.checkAvailability_()});this.eventManager.listen(this.player,"loaded",function(){c.checkAvailability_()});
this.eventManager.listen(this.player,"manifestupdated",function(){c.checkAvailability_()});this.eventManager.listen(this.video,"durationchange",function(){c.checkAvailability_()})};$jscomp.inherits(shaka.ui.LoopButton,shaka.ui.Element);shaka.ui.LoopButton.prototype.release=function(){this.timer_.stop();this.timer_=null;shaka.ui.Element.prototype.release.call(this)};shaka.ui.LoopButton.prototype.onClick_=function(){this.video.loop=!this.video.loop;this.timer_.tickNow();this.timer_.tickEvery(1)};
shaka.ui.LoopButton.prototype.onTimerTick_=function(){this.loopEnabled_!=this.video.loop&&(this.updateLocalizedStrings_(),this.loopEnabled_=this.video.loop)};
shaka.ui.LoopButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids,b=shaka.ui.Enums.MaterialDesignSVGIcons;this.nameSpan_.textContent=this.localization.resolve(a.LOOP);this.currentState_.textContent=this.localization.resolve(this.video.loop?a.ON:a.OFF);this.icon_.use(this.video.loop?b.UNLOOP:b.LOOP);this.button_.ariaLabel=this.localization.resolve(this.video.loop?a.EXIT_LOOP_MODE:a.ENTER_LOOP_MODE)};
shaka.ui.LoopButton.prototype.checkAvailability_=function(){shaka.ui.Utils.setDisplay(this.button_,!this.player.isLive())};goog.exportSymbol("shaka.ui.LoopButton",shaka.ui.LoopButton);shaka.ui.LoopButton.Factory=function(){};shaka.ui.LoopButton.Factory.prototype.create=function(a,b){return new shaka.ui.LoopButton(a,b)};shaka.ui.OverflowMenu.registerElement("loop",new shaka.ui.LoopButton.Factory);shaka.ui.Controls.registerElement("loop",new shaka.ui.LoopButton.Factory);
shaka.ui.ContextMenu.registerElement("loop",new shaka.ui.LoopButton.Factory);shaka.ui.MuteButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;a=shaka.ui.Locales.Ids;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-mute-button");this.button_.classList.add("shaka-tooltip");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.MUTE);b=shaka.util.Dom.createHTMLElement("label");b.classList.add("shaka-overflow-button-label");b.classList.add("shaka-overflow-menu-only");this.nameSpan_=shaka.util.Dom.createHTMLElement("span");
this.nameSpan_.textContent=this.localization.resolve(a.MUTE);b.appendChild(this.nameSpan_);this.currentState_=shaka.util.Dom.createHTMLElement("span");this.currentState_.classList.add("shaka-current-selection-span");b.appendChild(this.currentState_);this.button_.appendChild(b);this.parent.appendChild(this.button_);this.updateLocalizedStrings_();this.updateIcon_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&(c.ad&&c.ad.isLinear()?c.ad.setMuted(!c.ad.isMuted()):c.video.muted||c.video.volume!=0?c.video.muted=!c.video.muted:c.video.volume=1)});this.eventManager.listen(this.video,"volumechange",function(){c.updateLocalizedStrings_();c.updateIcon_()});this.eventManager.listen(this.player,"loading",function(){c.updateLocalizedStrings_();c.updateIcon_()});
this.eventManager.listen(this.player,"loaded",function(){c.checkAvailability_()});this.eventManager.listen(this.player,"unloading",function(){c.checkAvailability_()});this.eventManager.listen(this.player,"trackschanged",function(){c.checkAvailability_()});this.eventManager.listen(this.controls,"caststatuschanged",function(){c.updateLocalizedStrings_();c.updateIcon_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_VOLUME_CHANGED,function(){c.updateLocalizedStrings_();c.updateIcon_()});
this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_MUTED,function(){c.updateLocalizedStrings_();c.updateIcon_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.checkAvailability_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.ad=null;c.updateLocalizedStrings_();c.updateIcon_();c.checkAvailability_()});this.checkAvailability_()};$jscomp.inherits(shaka.ui.MuteButton,shaka.ui.Element);
shaka.ui.MuteButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;a=this.ad?this.ad.isMuted()?a.UNMUTE:a.MUTE:this.video.muted||this.video.volume==0?a.UNMUTE:a.MUTE;this.button_.ariaLabel=this.localization.resolve(a);this.nameSpan_.textContent=this.localization.resolve(a)};shaka.ui.MuteButton.prototype.updateIcon_=function(){var a=shaka.ui.Enums.MaterialDesignSVGIcons;a=this.ad?this.ad.isMuted()?a.UNMUTE:a.MUTE:this.video.muted||this.video.volume==0?a.UNMUTE:a.MUTE;this.icon_.use(a)};
shaka.ui.MuteButton.prototype.checkAvailability_=function(){var a=!0;this.ad&&this.ad.isLinear()?a=!0:this.player.isVideoOnly()&&(a=!1);shaka.ui.Utils.setDisplay(this.button_,a)};goog.exportSymbol("shaka.ui.MuteButton",shaka.ui.MuteButton);shaka.ui.MuteButton.Factory=function(){};shaka.ui.MuteButton.Factory.prototype.create=function(a,b){return new shaka.ui.MuteButton(a,b)};shaka.ui.OverflowMenu.registerElement("mute",new shaka.ui.MuteButton.Factory);shaka.ui.Controls.registerElement("mute",new shaka.ui.MuteButton.Factory);
shaka.ui.ContextMenu.registerElement("mute",new shaka.ui.MuteButton.Factory);shaka.ui.PipButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.localVideo_=this.controls.getLocalVideo();this.videoContainer_=this.controls.getVideoContainer();a=shaka.ui.Locales.Ids;this.pipButton_=shaka.util.Dom.createButton();this.pipButton_.classList.add("shaka-pip-button");this.pipButton_.classList.add("shaka-tooltip");this.pipIcon_=new shaka.ui.MaterialSVGIcon(this.pipButton_,shaka.ui.Enums.MaterialDesignSVGIcons.PIP);b=shaka.util.Dom.createHTMLElement("label");b.classList.add("shaka-overflow-button-label");
b.classList.add("shaka-overflow-menu-only");b.classList.add("shaka-simple-overflow-button-label-inline");this.pipNameSpan_=shaka.util.Dom.createHTMLElement("span");this.pipNameSpan_.textContent=this.localization.resolve(a.PICTURE_IN_PICTURE);b.appendChild(this.pipNameSpan_);this.currentPipState_=shaka.util.Dom.createHTMLElement("span");this.currentPipState_.classList.add("shaka-current-selection-span");b.appendChild(this.currentPipState_);this.pipButton_.appendChild(b);this.updateLocalizedStrings_();
this.parent.appendChild(this.pipButton_);this.controls.isPiPAllowed()||shaka.ui.Utils.setDisplay(this.pipButton_,!1);this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.pipButton_,"click",function(){c.controls.isOpaque()&&c.controls.togglePiP()});this.eventManager.listen(this.localVideo_,
"enterpictureinpicture",function(){c.onEnterPictureInPicture_()});this.eventManager.listen(this.localVideo_,"leavepictureinpicture",function(){c.onLeavePictureInPicture_()});this.eventManager.listen(this.controls,"caststatuschanged",function(){c.onTracksChanged_()});this.eventManager.listen(this.player,"trackschanged",function(){c.onTracksChanged_()});"documentPictureInPicture"in window&&this.eventManager.listen(window.documentPictureInPicture,"enter",function(d){c.onEnterPictureInPicture_();c.eventManager.listenOnce(d.window,
"pagehide",function(){c.onLeavePictureInPicture_()})})};$jscomp.inherits(shaka.ui.PipButton,shaka.ui.Element);shaka.ui.PipButton.prototype.onEnterPictureInPicture_=function(){var a=shaka.ui.Locales.Ids;this.pipIcon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.EXIT_PIP);this.pipButton_.ariaLabel=this.localization.resolve(a.EXIT_PICTURE_IN_PICTURE);this.currentPipState_.textContent=this.localization.resolve(a.ON)};
shaka.ui.PipButton.prototype.onLeavePictureInPicture_=function(){var a=shaka.ui.Locales.Ids;this.pipIcon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.PIP);this.pipButton_.ariaLabel=this.localization.resolve(a.ENTER_PICTURE_IN_PICTURE);this.currentPipState_.textContent=this.localization.resolve(a.OFF)};
shaka.ui.PipButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.pipNameSpan_.textContent=this.localization.resolve(a.PICTURE_IN_PICTURE);var b=this.controls.isPiPEnabled();this.pipButton_.ariaLabel=this.localization.resolve(b?a.EXIT_PICTURE_IN_PICTURE:a.ENTER_PICTURE_IN_PICTURE);this.currentPipState_.textContent=this.localization.resolve(b?a.ON:a.OFF)};
shaka.ui.PipButton.prototype.onTracksChanged_=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(!a.controls.isPiPAllowed())return shaka.ui.Utils.setDisplay(a.pipButton_,!1),a.controls.isPiPEnabled()?b.yield(a.controls.togglePiP(),0):b.jumpTo(0);if(!a.player||!a.player.isAudioOnly())return shaka.ui.Utils.setDisplay(a.pipButton_,!0),b.jumpTo(0);shaka.ui.Utils.setDisplay(a.pipButton_,!1);return a.controls.isPiPEnabled()?b.yield(a.controls.togglePiP(),0):b.jumpTo(0)})};
goog.exportSymbol("shaka.ui.PipButton",shaka.ui.PipButton);shaka.ui.PipButton.Factory=function(){};shaka.ui.PipButton.Factory.prototype.create=function(a,b){return new shaka.ui.PipButton(a,b)};shaka.ui.OverflowMenu.registerElement("picture_in_picture",new shaka.ui.PipButton.Factory);shaka.ui.Controls.registerElement("picture_in_picture",new shaka.ui.PipButton.Factory);shaka.ui.ContextMenu.registerElement("picture_in_picture",new shaka.ui.PipButton.Factory);shaka.ui.PlaybackRateSelection=function(a,b){shaka.ui.SettingsMenu.call(this,a,b,shaka.ui.Enums.MaterialDesignSVGIcons.PLAYBACK_RATE);var c=this;this.button.classList.add("shaka-playbackrate-button");this.menu.classList.add("shaka-playback-rates");this.button.classList.add("shaka-tooltip-status");Array.from(a.classList).includes("shaka-overflow-menu")||(this.playbackRateMark=shaka.util.Dom.createHTMLElement("span"),this.playbackRateMark.classList.add("shaka-overflow-playback-rate-mark"),this.button.appendChild(this.playbackRateMark));
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.player,"loaded",function(){c.updatePlaybackRateSelection_()});this.eventManager.listen(this.player,"ratechange",function(){c.updatePlaybackRateSelection_()});this.updateLocalizedStrings_();this.addPlaybackRates_();this.updatePlaybackRateSelection_()};
$jscomp.inherits(shaka.ui.PlaybackRateSelection,shaka.ui.SettingsMenu);shaka.ui.PlaybackRateSelection.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.backButton.ariaLabel=this.localization.resolve(a.BACK);this.button.ariaLabel=this.localization.resolve(a.PLAYBACK_RATE);this.nameSpan.textContent=this.localization.resolve(a.PLAYBACK_RATE);this.backSpan.textContent=this.localization.resolve(a.PLAYBACK_RATE)};
shaka.ui.PlaybackRateSelection.prototype.updatePlaybackRateSelection_=function(){var a=this.player.getPlaybackRate(),b=shaka.ui.Utils.getDescendantIfExists(this.menu,"material-svg-icon shaka-chosen-item");if(b){var c=b.parentElement;c.removeAttribute("aria-selected");var d=c.getElementsByTagName("span")[0];d&&d.classList.remove("shaka-chosen-item");c.removeChild(b)}if(b=Array.from(this.menu.querySelectorAll("span")).find(function(e){return e.textContent==a+"x"}))c=b.parentElement,c.appendChild(shaka.ui.Utils.checkmarkIcon()),
c.ariaSelected="true",b.classList.add("shaka-chosen-item");this.currentSelection.textContent=a+"x";this.button.setAttribute("shaka-status",a+"x");this.playbackRateMark&&(this.playbackRateMark.textContent=a+"x")};
shaka.ui.PlaybackRateSelection.prototype.addPlaybackRates_=function(){for(var a=this,b=(0,$jscomp.makeIterator)(this.controls.getConfig().playbackRates),c=b.next(),d={};!c.done;d={rate$jscomp$10:void 0},c=b.next()){d.rate$jscomp$10=c.value;c=shaka.util.Dom.createButton();var e=shaka.util.Dom.createHTMLElement("span");e.textContent=d.rate$jscomp$10+"x";c.appendChild(e);this.eventManager.listen(c,"click",function(f){return function(){f.rate$jscomp$10==a.video.defaultPlaybackRate?a.player.cancelTrickPlay():
a.player.trickPlay(f.rate$jscomp$10,!1)}}(d));this.menu.appendChild(c)}shaka.ui.Utils.focusOnTheChosenItem(this.menu)};goog.exportSymbol("shaka.ui.PlaybackRateSelection",shaka.ui.PlaybackRateSelection);shaka.ui.PlaybackRateSelection.Factory=function(){};shaka.ui.PlaybackRateSelection.Factory.prototype.create=function(a,b){return new shaka.ui.PlaybackRateSelection(a,b)};shaka.ui.OverflowMenu.registerElement("playback_rate",new shaka.ui.PlaybackRateSelection.Factory);
shaka.ui.Controls.registerElement("playback_rate",new shaka.ui.PlaybackRateSelection.Factory);shaka.ui.PresentationTimeTracker=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.currentTime_=shaka.util.Dom.createButton();this.currentTime_.classList.add("shaka-current-time");this.setValue_("0:00");this.parent.appendChild(this.currentTime_);this.eventManager.listen(this.currentTime_,"click",function(){c.controls.isOpaque()&&c.player.isLive()&&(c.video.currentTime=c.player.seekRange().end)});this.eventManager.listen(this.player,"loading",function(){shaka.ui.Utils.setDisplay(c.currentTime_,
!0)});this.eventManager.listen(this.controls,"timeandseekrangeupdated",function(){c.updateTime_()});this.eventManager.listen(this.player,"trackschanged",function(){c.onTracksChanged_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){shaka.ui.Utils.setDisplay(c.currentTime_,!c.ad.isLinear())});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){shaka.ui.Utils.setDisplay(c.currentTime_,!0)})};
$jscomp.inherits(shaka.ui.PresentationTimeTracker,shaka.ui.Element);shaka.ui.PresentationTimeTracker.prototype.setValue_=function(a){a!=this.currentTime_.textContent&&(this.currentTime_.textContent=a)};
shaka.ui.PresentationTimeTracker.prototype.updateTime_=function(){var a=this.controls.isSeeking(),b=this.controls.getDisplayTime(),c=this.player.seekRange(),d=c.end-c.start,e=shaka.ui.Utils;isFinite(d)?this.player.isLive()?(b=Math.max(0,Math.floor(c.end-b)),d=d>=3600,b>=1||a?(this.setValue_("- "+e.buildTimeString(b,d)),this.currentTime_.disabled=!1):(this.setValue_(this.localization.resolve(shaka.ui.Locales.Ids.LIVE)),this.currentTime_.disabled=!0)):(a=d>=3600,b=Math.max(0,b-c.start),d&&(b=Math.min(b,
d)),b=e.buildTimeString(b,a),d&&(b+=" / "+e.buildTimeString(d,a)),this.setValue_(b),this.currentTime_.disabled=!0):(this.setValue_(this.localization.resolve(shaka.ui.Locales.Ids.LIVE)),this.currentTime_.disabled=!0)};shaka.ui.PresentationTimeTracker.prototype.onTracksChanged_=function(){this.player.isLive()&&(this.currentTime_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.SKIP_TO_LIVE))};goog.exportSymbol("shaka.ui.PresentationTimeTracker",shaka.ui.PresentationTimeTracker);
shaka.ui.PresentationTimeTracker.Factory=function(){};shaka.ui.PresentationTimeTracker.Factory.prototype.create=function(a,b){return new shaka.ui.PresentationTimeTracker(a,b)};shaka.ui.Controls.registerElement("time_and_duration",new shaka.ui.PresentationTimeTracker.Factory);shaka.ui.RecenterVRButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.recenterVRButton_=shaka.util.Dom.createButton();this.recenterVRButton_.classList.add("shaka-recenter-vr-button");this.recenterVRButton_.classList.add("shaka-tooltip");this.recenterVRButton_.ariaPressed="false";this.recenterVRIcon_=new shaka.ui.MaterialSVGIcon(this.recenterVRButton_,shaka.ui.Enums.MaterialDesignSVGIcons.RECENTER_VR);a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");
a.classList.add("shaka-overflow-menu-only");this.recenterVRNameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.recenterVRNameSpan_);this.recenterVRCurrentSelectionSpan_=shaka.util.Dom.createHTMLElement("span");this.recenterVRCurrentSelectionSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.recenterVRCurrentSelectionSpan_);this.recenterVRButton_.appendChild(a);this.parent.appendChild(this.recenterVRButton_);this.updateLocalizedStrings_();this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});var d=this.controls.getVR();this.eventManager.listen(this.recenterVRButton_,"click",function(){c.controls.isOpaque()&&d.reset()});this.eventManager.listen(d,"vrstatuschanged",function(){c.checkAvailability_()});this.checkAvailability_()};$jscomp.inherits(shaka.ui.RecenterVRButton,shaka.ui.Element);
shaka.ui.RecenterVRButton.prototype.checkAvailability_=function(){shaka.ui.Utils.setDisplay(this.recenterVRButton_,this.controls.isPlayingVR())};shaka.ui.RecenterVRButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.recenterVRButton_.ariaLabel=this.localization.resolve(a.RECENTER_VR);this.recenterVRNameSpan_.textContent=this.localization.resolve(a.RECENTER_VR)};goog.exportSymbol("shaka.ui.RecenterVRButton",shaka.ui.RecenterVRButton);
shaka.ui.RecenterVRButton.Factory=function(){};shaka.ui.RecenterVRButton.Factory.prototype.create=function(a,b){return new shaka.ui.RecenterVRButton(a,b)};shaka.ui.OverflowMenu.registerElement("recenter_vr",new shaka.ui.RecenterVRButton.Factory);shaka.ui.Controls.registerElement("recenter_vr",new shaka.ui.RecenterVRButton.Factory);shaka.ui.RemoteButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.isAirPlay_=shaka.device.DeviceFactory.getDevice().supportsAirPlay();this.remoteButton_=shaka.util.Dom.createButton();this.remoteButton_.classList.add("shaka-remote-button");this.remoteButton_.classList.add("shaka-tooltip");this.remoteButton_.ariaPressed="false";this.remoteIcon_=new shaka.ui.MaterialSVGIcon(this.remoteButton_,this.isAirPlay_?shaka.ui.Enums.MaterialDesignSVGIcons.AIRPLAY:shaka.ui.Enums.MaterialDesignSVGIcons.CAST);
a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-overflow-menu-only");this.remoteNameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.remoteNameSpan_);this.remoteCurrentSelectionSpan_=shaka.util.Dom.createHTMLElement("span");this.remoteCurrentSelectionSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.remoteCurrentSelectionSpan_);this.remoteButton_.appendChild(a);this.parent.appendChild(this.remoteButton_);
this.callbackId_=-1;this.updateLocalizedStrings_();shaka.ui.Utils.setDisplay(this.remoteButton_,!1);this.video.remote?(this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()}),this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()}),this.eventManager.listen(this.controls,"caststatuschanged",function(){c.updateRemoteState_()}),this.eventManager.listen(this.remoteButton_,"click",
function(){c.controls.isOpaque()&&c.video.remote.prompt().catch(function(){})}),this.eventManager.listen(this.video.remote,"connect",function(){c.updateRemoteState_();c.updateIcon_()}),this.eventManager.listen(this.video.remote,"connecting",function(){c.updateRemoteState_();c.updateIcon_()}),this.eventManager.listen(this.video.remote,"disconnect",function(){c.updateRemoteState_();c.updateIcon_()}),this.eventManager.listen(this.player,"loaded",function(){c.updateRemoteState_()}),this.updateRemoteState_(!0),
this.updateIcon_()):this.remoteButton_.classList.add("shaka-hidden")};$jscomp.inherits(shaka.ui.RemoteButton,shaka.ui.Element);shaka.ui.RemoteButton.prototype.release=function(){this.video.remote&&this.callbackId_!=-1&&this.video.remote.cancelWatchAvailability(this.callbackId_).catch(function(){});shaka.ui.Element.prototype.release.call(this)};
shaka.ui.RemoteButton.prototype.updateRemoteState_=function(a){a=a===void 0?!1:a;var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){switch(e.getNextAddressJsc()){case 1:if(b.controls.getCastProxy().canCast()&&b.controls.isCastAllowed()||!b.video.remote){shaka.ui.Utils.setDisplay(b.remoteButton_,!1);b.callbackId_!=-1&&(b.video.remote.cancelWatchAvailability(b.callbackId_),b.callbackId_=-1);e.jumpTo(0);break}if(b.video.remote.state=="disconnected"||a){c=function(f){if(b.player){var g=
b.video.disableRemotePlayback,h=!0;shaka.device.DeviceFactory.getDevice().supportsAirPlay()&&b.player.getLoadMode()==shaka.Player.LoadMode.MEDIA_SOURCE&&b.player.getManifestType()!="HLS"&&(h=!1);shaka.ui.Utils.setDisplay(b.remoteButton_,h&&f&&!g)}else shaka.ui.Utils.setDisplay(b.remoteButton_,!1)};e.setCatchFinallyBlocks(7);if(b.callbackId_==-1){e.jumpTo(9);break}return e.yield(b.video.remote.cancelWatchAvailability(b.callbackId_),10)}shaka.ui.Utils.setDisplay(b.remoteButton_,!0);if(b.callbackId_==
-1){e.jumpTo(0);break}return e.yield(b.video.remote.cancelWatchAvailability(b.callbackId_),6);case 6:b.callbackId_=-1;e.jumpTo(0);break;case 10:b.callbackId_=-1;case 9:e.leaveTryBlock(8);break;case 7:e.enterCatchBlock();case 8:return e.setCatchFinallyBlocks(11),e.yield(b.video.remote.watchAvailability(c),13);case 13:d=e.getYieldResultJsc();b.callbackId_=d;e.leaveTryBlock(0);break;case 11:e.enterCatchBlock(),c(!0),e.jumpToEnd()}})};
shaka.ui.RemoteButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;a=this.isAirPlay_?this.localization.resolve(a.AIRPLAY):this.localization.resolve(a.CAST);this.remoteButton_.ariaLabel=a;this.remoteNameSpan_.textContent=a};shaka.ui.RemoteButton.prototype.updateIcon_=function(){this.isAirPlay_||(this.video.remote.state=="disconnected"?this.remoteIcon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.CAST):this.remoteIcon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.EXIT_CAST))};
goog.exportSymbol("shaka.ui.RemoteButton",shaka.ui.RemoteButton);shaka.ui.RemoteButton.Factory=function(){};shaka.ui.RemoteButton.Factory.prototype.create=function(a,b){return new shaka.ui.RemoteButton(a,b)};shaka.ui.OverflowMenu.registerElement("remote",new shaka.ui.RemoteButton.Factory);shaka.ui.Controls.registerElement("remote",new shaka.ui.RemoteButton.Factory);shaka.ui.ResolutionSelection=function(a,b){shaka.ui.SettingsMenu.call(this,a,b,shaka.ui.Enums.MaterialDesignSVGIcons.RESOLUTION);var c=this;this.button.classList.add("shaka-resolution-button");this.button.classList.add("shaka-tooltip-status");this.menu.classList.add("shaka-resolutions");this.autoQuality=shaka.util.Dom.createHTMLElement("span");this.autoQuality.classList.add("shaka-current-auto-quality");this.autoQuality.style.display="none";this.qualityMark=shaka.util.Dom.createHTMLElement("sup");
this.qualityMark.classList.add("shaka-current-quality-mark");this.qualityMark.style.display="none";Array.from(a.classList).includes("shaka-overflow-menu")?this.parent.parentElement&&(a=shaka.util.Dom.asHTMLElement(this.parent.parentElement),this.overflowQualityMark=shaka.util.Dom.getElementByClassNameIfItExists("shaka-overflow-quality-mark",a)):(this.overflowQualityMark=shaka.util.Dom.createHTMLElement("span"),this.overflowQualityMark.classList.add("shaka-overflow-playback-rate-mark"),this.button.appendChild(this.overflowQualityMark));
a=shaka.util.Dom.createHTMLElement("span");this.button.childNodes[1].appendChild(a);a.appendChild(this.currentSelection);a.appendChild(this.autoQuality);a.appendChild(this.qualityMark);this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.player,"loading",function(){c.updateSelection_();
c.updateLabels_()});this.eventManager.listen(this.player,"loaded",function(){c.updateSelection_();c.updateLabels_()});this.eventManager.listen(this.player,"unloading",function(){c.updateSelection_();c.updateLabels_()});this.eventManager.listen(this.player,"variantchanged",function(){c.updateSelection_();c.updateLabels_()});this.eventManager.listen(this.player,"trackschanged",function(){c.updateSelection_();c.updateLabels_()});this.eventManager.listen(this.player,"abrstatuschanged",function(){c.updateSelection_();
c.updateLabels_()});this.eventManager.listen(this.player,"adaptation",function(){c.updateSelection_();c.updateLabels_()});this.updateSelection_()};$jscomp.inherits(shaka.ui.ResolutionSelection,shaka.ui.SettingsMenu);
shaka.ui.ResolutionSelection.prototype.updateLabels_=function(){var a=this.player.getConfiguration().abr.enabled;if(this.player.isAudioOnly()){this.qualityMark.textContent="";this.qualityMark.style.display="none";this.overflowQualityMark&&(this.overflowQualityMark.textContent="",this.overflowQualityMark.style.display="none");var b=this.player.getVariantTracks()||[],c=b.find(function(d){return d.active});c&&(a?(this.autoQuality.textContent=c.bandwidth?this.getQualityLabel_(c,b):"Unknown",this.autoQuality.style.display=
""):this.autoQuality.style.display="none")}else b=this.player.getVideoTracks()||[],(c=b.find(function(d){return d.active}))?(a?(this.autoQuality.textContent=c.height&&c.width?this.getResolutionLabel_(c,b):c.bandwidth?this.getTextFromBandwidth_(c.bandwidth):"Unknown",this.autoQuality.style.display=""):this.autoQuality.style.display="none",a=this.getQualityMark_(c.width,c.height),this.qualityMark.textContent=a,this.qualityMark.style.display=a!==""?"":"none",this.overflowQualityMark&&(this.overflowQualityMark.textContent=
a,this.overflowQualityMark.style.display=a!==""?"":"none")):this.overflowQualityMark&&(a=this.player.getStats(),a=this.getQualityMark_(a.width,a.height),this.overflowQualityMark.textContent=a,this.overflowQualityMark.style.display=a!==""?"":"none")};
shaka.ui.ResolutionSelection.prototype.getQualityMark_=function(a,b){if(!a||!b)return"";b>a&&(b=(0,$jscomp.makeIterator)([b,a]),a=b.next().value,b=b.next().value);a/b>16/9&&(b=Math.round(a*9/16));a=this.controls.getConfig().qualityMarks;return b>=8640?b+"p":b>=4320?a["4320"]:b>=2160?a["2160"]:b>=1440?a["1440"]:b>=1080?a["1080"]:b>=720?a["720"]:""};
shaka.ui.ResolutionSelection.prototype.updateSelection_=function(){var a=this,b=shaka.ui.Utils.getFirstDescendantWithClassName(this.menu,"shaka-back-to-overflow-button");shaka.util.Dom.removeAllChildren(this.menu);this.menu.appendChild(b);b=0;b=this.player.isAudioOnly()?this.updateAudioOnlySelection_():this.updateResolutionSelection_();var c=shaka.util.Dom.createButton();c.classList.add("shaka-enable-abr-button");this.eventManager.listen(c,"click",function(){a.player.configure({abr:{enabled:!0}});
a.updateSelection_()});this.abrOnSpan_=shaka.util.Dom.createHTMLElement("span");this.abrOnSpan_.textContent=this.localization.resolve(shaka.ui.Locales.Ids.AUTO_QUALITY);c.appendChild(this.abrOnSpan_);this.player.getConfiguration().abr.enabled&&(c.ariaSelected="true",c.appendChild(shaka.ui.Utils.checkmarkIcon()),this.abrOnSpan_.classList.add("shaka-chosen-item"),this.currentSelection.textContent=this.localization.resolve(shaka.ui.Locales.Ids.AUTO_QUALITY));this.button.setAttribute("shaka-status",this.currentSelection.textContent);
this.menu.appendChild(c);shaka.ui.Utils.focusOnTheChosenItem(this.menu);this.controls.dispatchEvent(new shaka.util.FakeEvent("resolutionselectionupdated"));this.updateLocalizedStrings_();shaka.ui.Utils.setDisplay(this.button,b>0)};
shaka.ui.ResolutionSelection.prototype.updateAudioOnlySelection_=function(){var a=this,b=shaka.ui.Overlay.TrackLabelFormat,c=[];this.player.getLoadMode()==shaka.Player.LoadMode.SRC_EQUALS||this.player.isRemotePlayback()||(c=this.player.getVariantTracks()||[]);var d=c.find(function(l){return l.active});d&&(c=c.filter(function(l){if(l.language!=d.language||a.controls.getConfig().showAudioChannelCountVariants&&l.channelsCount&&d.channelsCount&&l.channelsCount!=d.channelsCount)return!1;var m=a.controls.getConfig().trackLabelFormat;
return(m==b.ROLE||m==b.LANGUAGE_ROLE)&&JSON.stringify(l.audioRoles)!=JSON.stringify(d.audioRoles)||m==b.LABEL&&l.label!=d.label||!l.bandwidth?!1:!0}));c=c.filter(function(l,m){return c.findIndex(function(n){return n.bandwidth==l.bandwidth})==m});c.sort(function(l,m){goog.asserts.assert(l.bandwidth!=null,"Null bandwidth");goog.asserts.assert(m.bandwidth!=null,"Null bandwidth");return m.bandwidth-l.bandwidth});for(var e=this.player.getConfiguration().abr.enabled,f=(0,$jscomp.makeIterator)(c),g=f.next(),
h={};!g.done;h={track$jscomp$61:void 0},g=f.next()){h.track$jscomp$61=g.value;g=shaka.util.Dom.createButton();g.classList.add("explicit-resolution");this.eventManager.listen(g,"click",function(l){return function(){return a.onTrackSelected_(l.track$jscomp$61)}}(h));var k=shaka.util.Dom.createHTMLElement("span");k.textContent=h.track$jscomp$61.bandwidth?this.getQualityLabel_(h.track$jscomp$61,c):"Unknown";g.appendChild(k);e||h.track$jscomp$61!=d||(g.ariaSelected="true",g.appendChild(shaka.ui.Utils.checkmarkIcon()),
k.classList.add("shaka-chosen-item"),this.currentSelection.textContent=k.textContent);this.menu.appendChild(g)}return c.length};
shaka.ui.ResolutionSelection.prototype.updateResolutionSelection_=function(){var a=this,b=this.player.getVideoTracks()||[],c=b.find(function(m){return m.active});b=b.filter(function(m,n){return b.findIndex(function(p){var q=p.height==m.height&&p.bandwidth==m.bandwidth&&p.frameRate==m.frameRate&&p.hdr==m.hdr&&p.videoLayout==m.videoLayout&&shaka.util.ArrayUtils.equal(p.roles,m.roles);q&&a.controls.getConfig().showVideoCodec&&p.codecs&&m.codecs&&(q=shaka.util.MimeUtils.getNormalizedCodec(p.codecs)==
shaka.util.MimeUtils.getNormalizedCodec(m.codecs));return q})==n});b.sort(function(m,n){return n.height==m.height||m.height==null||n.height==null?n.bandwidth-m.bandwidth:n.height-m.height});for(var d=this.player.getConfiguration().abr.enabled,e=(0,$jscomp.makeIterator)(b),f=e.next(),g={};!f.done;g={track$jscomp$64:void 0},f=e.next()){g.track$jscomp$64=f.value;f=shaka.util.Dom.createButton();f.classList.add("explicit-resolution");this.eventManager.listen(f,"click",function(m){return function(){return a.onVideoTrackSelected_(m.track$jscomp$64)}}(g));
var h=shaka.util.Dom.createHTMLElement("span");h.textContent=g.track$jscomp$64.height&&g.track$jscomp$64.width?this.getResolutionLabel_(g.track$jscomp$64,b):g.track$jscomp$64.bandwidth?this.getTextFromBandwidth_(g.track$jscomp$64.bandwidth):"Unknown";f.appendChild(h);var k=this.getQualityMark_(g.track$jscomp$64.width,g.track$jscomp$64.height);if(k!==""){var l=shaka.util.Dom.createHTMLElement("sup");l.classList.add("shaka-quality-mark");l.textContent=k;f.appendChild(l)}d||g.track$jscomp$64!=c||(f.ariaSelected=
"true",f.appendChild(shaka.ui.Utils.checkmarkIcon()),h.classList.add("shaka-chosen-item"),this.currentSelection.textContent=h.textContent);this.menu.appendChild(f)}return b.length};
shaka.ui.ResolutionSelection.prototype.getResolutionLabel_=function(a,b){var c=a.height||0,d=a.width||0,e=!0;if(a.pixelAspectRatio){var f=a.pixelAspectRatio.split(":").map(function(m){return Number(m)});f.length===2?e=f[0]===f[1]:f.length===1&&(e=f[0]===1)}c>d&&e&&(c=(0,$jscomp.makeIterator)([c,d]),d=c.next().value,c=c.next().value);e=c;d/c>16/9&&(e=Math.round(d*9/16));d=e+"p";c=new Set;e=(0,$jscomp.makeIterator)(b);for(f=e.next();!f.done;f=e.next())f=f.value,f.frameRate&&c.add(Math.round(f.frameRate));
c.size>1&&(c=a.frameRate)&&(c>=50||c<=20)&&(d+=Math.round(a.frameRate));var g=function(m){return m.codecs?shaka.util.MimeUtils.getNormalizedCodec(m.codecs).startsWith("dovi-"):!1},h=function(m){return m.codecs?shaka.util.MimeUtils.getNormalizedCodec(m.codecs).startsWith("lcevc"):!1};if(g(a))d+=" Dolby Vision";else if(a.hdr=="PQ"||a.hdr=="HLG")d+=" HDR";h(a)&&(d+=" LCEVC");(a.videoLayout||"").includes("CH-STEREO")&&(d+=" 3D");var k=function(m,n){return m!=n&&m.height==n.height&&m.hdr==n.hdr&&g(m)==
g(n)&&h(m)==h(n)&&Math.round(m.frameRate||0)==Math.round(n.frameRate||0)};if(b.some(function(m){return k(a,m)})&&(b.some(function(m){return k(a,m)&&m.bandwidth==a.bandwidth})||(d+=" ("+this.getTextFromBandwidth_(a.bandwidth)+")"),this.controls.getConfig().showVideoCodec)){var l=function(m){var n="";m&&(n=shaka.util.MimeUtils.getNormalizedCodec(m).toUpperCase());return n?" "+n:n};b.some(function(m){return k(a,m)&&l(m.codecs)!=l(a.codecs)})&&(d+=l(a.codecs))}return d};
shaka.ui.ResolutionSelection.prototype.getQualityLabel_=function(a,b){var c=this.getTextFromBandwidth_(a.bandwidth);if(this.controls.getConfig().showAudioCodec){var d=function(e){var f="";e&&(f=shaka.util.MimeUtils.getNormalizedCodec(e).toUpperCase());return f?" "+f:f};b.some(function(e){return d(e.codecs)!=d(a.codecs)})&&(c+=d(a.codecs))}return c};shaka.ui.ResolutionSelection.prototype.getTextFromBandwidth_=function(a){return a>=1E6?(a/1E6).toFixed(1).replace(".0","")+" Mbps":Math.floor(a/1E3)+" Kbps"};
shaka.ui.ResolutionSelection.prototype.onVideoTrackSelected_=function(a){this.player.configure({abr:{enabled:!1}});var b=this.controls.getConfig().clearBufferOnQualityChange;this.player.selectVideoTrack(a,b)};shaka.ui.ResolutionSelection.prototype.onTrackSelected_=function(a){this.player.configure({abr:{enabled:!1}});var b=this.controls.getConfig().clearBufferOnQualityChange;this.player.selectVariantTrack(a,b)};
shaka.ui.ResolutionSelection.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids,b=this.player.isAudioOnly()?a.QUALITY:a.RESOLUTION;this.button.ariaLabel=this.localization.resolve(b);this.backButton.ariaLabel=this.localization.resolve(b);this.backSpan.textContent=this.localization.resolve(b);this.nameSpan.textContent=this.localization.resolve(b);this.abrOnSpan_.textContent=this.localization.resolve(a.AUTO_QUALITY);this.player.getConfiguration().abr.enabled&&(this.currentSelection.textContent=
this.localization.resolve(shaka.ui.Locales.Ids.AUTO_QUALITY))};goog.exportSymbol("shaka.ui.ResolutionSelection",shaka.ui.ResolutionSelection);shaka.ui.ResolutionSelection.Factory=function(){};shaka.ui.ResolutionSelection.Factory.prototype.create=function(a,b){return new shaka.ui.ResolutionSelection(a,b)};shaka.ui.OverflowMenu.registerElement("quality",new shaka.ui.ResolutionSelection.Factory);shaka.ui.Controls.registerElement("quality",new shaka.ui.ResolutionSelection.Factory);shaka.ui.RewindButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-rewind-button");this.button_.classList.add("shaka-tooltip-status");this.button_.setAttribute("shaka-status",this.localization.resolve(shaka.ui.Locales.Ids.OFF));(new shaka.ui.MaterialSVGIcon(this.button_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.REWIND);this.parent.appendChild(this.button_);this.updateAriaLabel_();this.rewindRates_=this.controls.getConfig().rewindRates;
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel_()});this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&c.rewind_()});this.eventManager.listen(this.player,"ratechange",function(){c.button_.setAttribute("shaka-status",c.player.getPlaybackRate()+"x")})};$jscomp.inherits(shaka.ui.RewindButton,shaka.ui.Element);
shaka.ui.RewindButton.prototype.updateAriaLabel_=function(){this.button_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.REWIND)};shaka.ui.RewindButton.prototype.rewind_=function(){if(this.video.duration){var a=this.player.getPlaybackRate();a=this.rewindRates_.indexOf(a)+1;a=a!=this.rewindRates_.length?this.rewindRates_[a]:this.rewindRates_[0];this.video.paused&&this.video.play();this.player.trickPlay(a);this.button_.setAttribute("shaka-status",a+"x")}};
goog.exportSymbol("shaka.ui.RewindButton",shaka.ui.RewindButton);shaka.ui.RewindButton.Factory=function(){};shaka.ui.RewindButton.Factory.prototype.create=function(a,b){return new shaka.ui.RewindButton(a,b)};shaka.ui.Controls.registerElement("rewind",new shaka.ui.RewindButton.Factory);shaka.ui.SaveVideoFrameButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.castProxy_=this.controls.getCastProxy();a=shaka.ui.Locales.Ids;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-save.video-frame-button");this.button_.classList.add("shaka-tooltip");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.DOWNLOAD);b=shaka.util.Dom.createHTMLElement("label");b.classList.add("shaka-overflow-button-label");b.classList.add("shaka-overflow-menu-only");
this.nameSpan_=shaka.util.Dom.createHTMLElement("span");this.nameSpan_.textContent=this.localization.resolve(a.DOWNLOAD_VIDEO_FRAME);b.appendChild(this.nameSpan_);this.currentState_=shaka.util.Dom.createHTMLElement("span");this.currentState_.classList.add("shaka-current-selection-span");b.appendChild(this.currentState_);this.button_.appendChild(b);this.updateLocalizedStrings_();this.parent.appendChild(this.button_);this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});
this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.button_,"click",function(){c.onClick_()});a=this.controls.getVR();this.eventManager.listen(a,"vrstatuschanged",function(){c.checkAvailability_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){c.checkAvailability_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.checkAvailability_()});
this.eventManager.listen(this.player,"unloading",function(){c.checkAvailability_()});this.eventManager.listen(this.player,"loaded",function(){c.checkAvailability_()});this.eventManager.listen(this.video,"play",function(){c.checkAvailability_()});this.eventManager.listen(this.video,"pause",function(){c.checkAvailability_()});this.eventManager.listen(this.video,"seeking",function(){c.checkAvailability_()});this.eventManager.listen(this.controls,"caststatuschanged",function(){c.checkAvailability_()});
this.checkAvailability_()};$jscomp.inherits(shaka.ui.SaveVideoFrameButton,shaka.ui.Element);shaka.ui.SaveVideoFrameButton.prototype.onClick_=function(){var a=document.createElement("canvas"),b=a.getContext("2d"),c=this.controls.getLocalVideo();a.width=c.videoWidth;a.height=c.videoHeight;b.drawImage(c,0,0,a.width,a.height);a=a.toDataURL("image/png");b=document.createElement("a");b.href=a;b.download="videoframe_"+c.currentTime.toFixed(3)+".png";b.click()};
shaka.ui.SaveVideoFrameButton.prototype.checkAvailability_=function(){var a=!0;this.controls.isPlayingVR()&&(a=!1);a&&this.castProxy_.isCasting()&&(a=!1);a&&(this.player.drmInfo()||this.player.isAudioOnly())&&(a=!1);a&&this.ad&&(a=!1);a&&this.video.remote&&this.video.remote.state!="disconnected"&&(a=!1);shaka.ui.Utils.setDisplay(this.button_,a)};
shaka.ui.SaveVideoFrameButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.button_.ariaLabel=this.localization.resolve(a.DOWNLOAD_VIDEO_FRAME);this.nameSpan_.textContent=this.localization.resolve(a.DOWNLOAD_VIDEO_FRAME)};goog.exportSymbol("shaka.ui.SaveVideoFrameButton",shaka.ui.SaveVideoFrameButton);shaka.ui.SaveVideoFrameButton.Factory=function(){};shaka.ui.SaveVideoFrameButton.Factory.prototype.create=function(a,b){return new shaka.ui.SaveVideoFrameButton(a,b)};
shaka.ui.OverflowMenu.registerElement("save_video_frame",new shaka.ui.SaveVideoFrameButton.Factory);shaka.ui.ContextMenu.registerElement("save_video_frame",new shaka.ui.SaveVideoFrameButton.Factory);shaka.ui.SkipNextButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;if(this.queueManager_=this.player.getQueueManager())this.button_=shaka.util.Dom.createButton(),this.button_.classList.add("shaka-skip-next-button"),this.button_.classList.add("shaka-tooltip"),(new shaka.ui.MaterialSVGIcon(this.button_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.SKIP_NEXT),this.parent.appendChild(this.button_),this.updateAriaLabel_(),this.checkAvailability_(),this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()}),this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel_()}),this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&c.queueManager_.playItem(c.queueManager_.getCurrentItemIndex()+1)}),this.eventManager.listen(this.queueManager_,"currentitemchanged",function(){c.checkAvailability_()}),this.eventManager.listen(this.queueManager_,"itemsinserted",function(){c.checkAvailability_()}),
this.eventManager.listen(this.queueManager_,"itemsremoved",function(){c.checkAvailability_()}),this.eventManager.listen(this.player,"loading",function(){c.checkAvailability_()})};$jscomp.inherits(shaka.ui.SkipNextButton,shaka.ui.Element);shaka.ui.SkipNextButton.prototype.updateAriaLabel_=function(){this.button_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.SKIP_NEXT)};
shaka.ui.SkipNextButton.prototype.checkAvailability_=function(){var a=this.queueManager_.getItems().length;a=a>1&&this.queueManager_.getCurrentItemIndex()+1<a;shaka.ui.Utils.setDisplay(this.button_,a)};goog.exportSymbol("shaka.ui.SkipNextButton",shaka.ui.SkipNextButton);shaka.ui.SkipNextButton.Factory=function(){};shaka.ui.SkipNextButton.Factory.prototype.create=function(a,b){return new shaka.ui.SkipNextButton(a,b)};shaka.ui.Controls.registerElement("skip_next",new shaka.ui.SkipNextButton.Factory);shaka.ui.SkipPreviousButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;if(this.queueManager_=this.player.getQueueManager())this.button_=shaka.util.Dom.createButton(),this.button_.classList.add("shaka-skip-previous-button"),this.button_.classList.add("shaka-tooltip"),(new shaka.ui.MaterialSVGIcon(this.button_)).use(shaka.ui.Enums.MaterialDesignSVGIcons.SKIP_PREVIOUS),this.parent.appendChild(this.button_),this.updateAriaLabel_(),this.checkAvailability_(),this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateAriaLabel_()}),this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateAriaLabel_()}),this.eventManager.listen(this.button_,"click",function(){c.controls.isOpaque()&&c.queueManager_.playItem(c.queueManager_.getCurrentItemIndex()-1)}),this.eventManager.listen(this.queueManager_,"currentitemchanged",function(){c.checkAvailability_()}),this.eventManager.listen(this.queueManager_,"itemsinserted",function(){c.checkAvailability_()}),
this.eventManager.listen(this.queueManager_,"itemsremoved",function(){c.checkAvailability_()}),this.eventManager.listen(this.player,"loading",function(){c.checkAvailability_()})};$jscomp.inherits(shaka.ui.SkipPreviousButton,shaka.ui.Element);shaka.ui.SkipPreviousButton.prototype.updateAriaLabel_=function(){this.button_.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.SKIP_PREVIOUS)};
shaka.ui.SkipPreviousButton.prototype.checkAvailability_=function(){var a=this.queueManager_.getItems().length>1&&this.queueManager_.getCurrentItemIndex()>0;shaka.ui.Utils.setDisplay(this.button_,a)};goog.exportSymbol("shaka.ui.SkipPreviousButton",shaka.ui.SkipPreviousButton);shaka.ui.SkipPreviousButton.Factory=function(){};shaka.ui.SkipPreviousButton.Factory.prototype.create=function(a,b){return new shaka.ui.SkipPreviousButton(a,b)};shaka.ui.Controls.registerElement("skip_previous",new shaka.ui.SkipPreviousButton.Factory);shaka.ui.SmallPlayButton=function(a,b){shaka.ui.PlayButton.call(this,a,b);this.button.classList.add("shaka-small-play-button");this.button.classList.add("shaka-tooltip")};$jscomp.inherits(shaka.ui.SmallPlayButton,shaka.ui.PlayButton);goog.exportSymbol("shaka.ui.SmallPlayButton",shaka.ui.SmallPlayButton);shaka.ui.SmallPlayButton.Factory=function(){};shaka.ui.SmallPlayButton.Factory.prototype.create=function(a,b){return new shaka.ui.SmallPlayButton(a,b)};
shaka.ui.Controls.registerElement("play_pause",new shaka.ui.SmallPlayButton.Factory);shaka.ui.Spacer=function(a,b){shaka.ui.Element.call(this,a,b);a=shaka.util.Dom.createHTMLElement("div");a.classList.add("shaka-spacer");a.ariaHidden="true";this.parent.appendChild(a)};$jscomp.inherits(shaka.ui.Spacer,shaka.ui.Element);goog.exportSymbol("shaka.ui.Spacer",shaka.ui.Spacer);shaka.ui.Spacer.Factory=function(){};shaka.ui.Spacer.Factory.prototype.create=function(a,b){return new shaka.ui.Spacer(a,b)};shaka.ui.Controls.registerElement("spacer",new shaka.ui.Spacer.Factory);shaka.ui.StatisticsButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.button_=shaka.util.Dom.createButton();this.button_.classList.add("shaka-statistics-button");this.icon_=new shaka.ui.MaterialSVGIcon(this.button_,shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_ON);a=shaka.util.Dom.createHTMLElement("label");a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-simple-overflow-button-label-inline");this.nameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.nameSpan_);
this.stateSpan_=shaka.util.Dom.createHTMLElement("span");this.stateSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.stateSpan_);this.button_.appendChild(a);this.parent.appendChild(this.button_);this.container_=shaka.util.Dom.createHTMLElement("div");this.container_.classList.add("shaka-no-propagation");this.container_.classList.add("shaka-show-controls-on-mouse-over");this.container_.classList.add("shaka-statistics-container");this.container_.classList.add("shaka-hidden");this.controls.getControlsContainer().appendChild(this.container_);
this.statisticsList_=[];this.skippedStats_=["stateHistory","switchHistory"];this.currentStats_=this.player.getStats();this.displayedElements_=new Map;a=function(k){return c.currentStats_[k]+" (px)"};b=function(k){return c.currentStats_[k]+" (frames)"};var d=function(k){return c.currentStats_[k].toFixed(2)+" (s)"},e=function(k){return Math.round(c.currentStats_[k]/1E3)+" (kbits/s)"},f=function(k){k=c.currentStats_[k];return shaka.ui.Utils.buildTimeString(k,k>3600)},g=function(k){return c.currentStats_[k]+
" (gaps)"},h=function(k){k=parseInt(c.currentStats_[k],10);return k>2E9?(k/1E9).toFixed(2)+"GB":k>1E6?(k/1E6).toFixed(2)+"MB":k>1E3?(k/1E3).toFixed(2)+"KB":k+"B"};this.parseFrom_=(new Map).set("width",a).set("height",a).set("currentCodecs",function(k){return c.currentStats_[k]}).set("completionPercent",function(k){return c.currentStats_[k]+" (%)"}).set("bufferingTime",d).set("drmTimeSeconds",d).set("licenseTime",d).set("liveLatency",d).set("loadLatency",d).set("manifestTimeSeconds",d).set("estimatedBandwidth",
e).set("streamBandwidth",e).set("maxSegmentDuration",d).set("pauseTime",f).set("playTime",f).set("corruptedFrames",b).set("decodedFrames",b).set("droppedFrames",b).set("stallsDetected",function(k){return c.currentStats_[k]+" (stalls)"}).set("gapsJumped",g).set("manifestSizeBytes",h).set("bytesDownloaded",h).set("nonFatalErrorCount",function(k){return c.currentStats_[k]+" (errors)"}).set("manifestPeriodCount",function(k){return c.currentStats_[k]+" (periods)"}).set("manifestGapCount",g);this.timer_=
new shaka.util.Timer(function(){c.onTimerTick_()});this.updateLocalizedStrings_();this.loadContainer_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.button_,"click",function(){c.onClick_();c.updateLocalizedStrings_()})};$jscomp.inherits(shaka.ui.StatisticsButton,shaka.ui.Element);
shaka.ui.StatisticsButton.prototype.onClick_=function(){this.container_.classList.contains("shaka-hidden")?(this.icon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_OFF),this.timer_.tickEvery(.1),shaka.ui.Utils.setDisplay(this.container_,!0)):(this.icon_.use(shaka.ui.Enums.MaterialDesignSVGIcons.STATISTICS_ON),this.timer_.stop(),shaka.ui.Utils.setDisplay(this.container_,!1))};
shaka.ui.StatisticsButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.nameSpan_.textContent=this.localization.resolve(a.STATISTICS);this.button_.ariaLabel=this.localization.resolve(a.STATISTICS);a=this.container_.classList.contains("shaka-hidden")?a.OFF:a.ON;this.stateSpan_.textContent=this.localization.resolve(a)};
shaka.ui.StatisticsButton.prototype.generateComponent_=function(a){var b=shaka.util.Dom.createHTMLElement("div"),c=shaka.util.Dom.createHTMLElement("label");c.textContent=a+":";b.appendChild(c);c=shaka.util.Dom.createHTMLElement("span");c.textContent=this.parseFrom_.get(a)(a);b.appendChild(c);this.displayedElements_.set(a,c);return b};
shaka.ui.StatisticsButton.prototype.loadContainer_=function(){var a=this,b=shaka.util.Dom.createHTMLElement("div");b.classList.add("shaka-no-propagation");b.classList.add("shaka-statistics-close");var c=(new shaka.ui.MaterialSVGIcon(b,shaka.ui.Enums.MaterialDesignSVGIcons.CLOSE)).getSvgElement();c.classList.add("material-icons","notranslate");this.container_.appendChild(b);this.eventManager.listen(c,"click",function(){a.onClick_()});b=(0,$jscomp.makeIterator)(this.controls.getConfig().statisticsList);
for(c=b.next();!c.done;c=b.next())if(c=c.value,c in this.currentStats_&&!this.skippedStats_.includes(c)){var d=this.generateComponent_(c);this.container_.appendChild(d);this.statisticsList_.push(c)}else shaka.log.alwaysWarn("Unrecognized statistic element:",c)};
shaka.ui.StatisticsButton.prototype.onTimerTick_=function(){this.currentStats_=this.player.getStats();for(var a=(0,$jscomp.makeIterator)(this.statisticsList_),b=a.next();!b.done;b=a.next()){var c=b.value;b=this.displayedElements_.get(c);b.textContent=this.parseFrom_.get(c)(c);b&&b.parentElement&&(c=this.currentStats_[c],typeof c=="string"?shaka.ui.Utils.setDisplay(b.parentElement,c!=""):shaka.ui.Utils.setDisplay(b.parentElement,!isNaN(c)))}};
shaka.ui.StatisticsButton.prototype.release=function(){this.timer_.stop();this.timer_=null;shaka.ui.Element.prototype.release.call(this)};goog.exportSymbol("shaka.ui.StatisticsButton",shaka.ui.StatisticsButton);shaka.ui.StatisticsButton.Factory=function(){};shaka.ui.StatisticsButton.Factory.prototype.create=function(a,b){return new shaka.ui.StatisticsButton(a,b)};shaka.ui.OverflowMenu.registerElement("statistics",new shaka.ui.StatisticsButton.Factory);
shaka.ui.ContextMenu.registerElement("statistics",new shaka.ui.StatisticsButton.Factory);shaka.ui.TextSelection=function(a,b){shaka.ui.SettingsMenu.call(this,a,b,shaka.ui.Enums.MaterialDesignSVGIcons.CLOSED_CAPTIONS);var c=this;this.button.classList.add("shaka-caption-button");this.button.classList.add("shaka-tooltip-status");this.menu.classList.add("shaka-text-languages");this.player&&this.player.isTextTrackVisible()?this.button.ariaPressed="true":this.button.ariaPressed="false";this.addOffOption_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_();
c.updateTextLanguages_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_();c.updateTextLanguages_()});this.eventManager.listen(this.player,"loading",function(){c.onCaptionStateChange_();c.updateTextLanguages_()});this.eventManager.listen(this.player,"loaded",function(){c.onCaptionStateChange_();c.updateTextLanguages_()});this.eventManager.listen(this.player,"unloading",function(){c.onCaptionStateChange_();c.updateTextLanguages_()});
this.eventManager.listen(this.player,"texttrackvisibility",function(){c.onCaptionStateChange_();c.updateTextLanguages_()});this.eventManager.listen(this.player,"textchanged",function(){c.updateTextLanguages_()});this.eventManager.listen(this.player,"trackschanged",function(){c.updateTextLanguages_()});this.onCaptionStateChange_();this.updateLocalizedStrings_();this.updateTextLanguages_()};$jscomp.inherits(shaka.ui.TextSelection,shaka.ui.SettingsMenu);
shaka.ui.TextSelection.prototype.addOffOption_=function(){var a=shaka.util.Dom.createButton();a.ariaSelected="true";this.menu.appendChild(a);a.appendChild(shaka.ui.Utils.checkmarkIcon());this.captionsOffSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.captionsOffSpan_)};
shaka.ui.TextSelection.prototype.onCaptionStateChange_=function(){this.player.isTextTrackVisible()?(this.icon.use(shaka.ui.Enums.MaterialDesignSVGIcons.CLOSED_CAPTIONS),this.button.ariaPressed="true"):(this.icon.use(shaka.ui.Enums.MaterialDesignSVGIcons.CLOSED_CAPTIONS_OFF),this.button.ariaPressed="false");this.controls.dispatchEvent(new shaka.util.FakeEvent("captionselectionupdated"))};
shaka.ui.TextSelection.prototype.updateTextLanguages_=function(){var a=this,b=this.player.getTextTracks()||[];shaka.ui.LanguageUtils.updateTextTracks(b,this.menu,function(d){return a.onTextTrackSelected_(d)},this.player.isTextTrackVisible(),this.currentSelection,this.localization,this.controls.getConfig().textTrackLabelFormat);var c=shaka.util.Dom.createButton();c.classList.add("shaka-turn-captions-off-button");this.eventManager.listen(c,"click",function(){a.player.setTextTrackVisibility(!1);a.updateTextLanguages_()});
c.appendChild(this.captionsOffSpan_);this.menu.appendChild(c);this.player.isTextTrackVisible()?this.captionsOffSpan_.classList.remove("shaka-chosen-item"):(c.ariaSelected="true",c.appendChild(shaka.ui.Utils.checkmarkIcon()),this.captionsOffSpan_.classList.add("shaka-chosen-item"),this.currentSelection.textContent=this.localization.resolve(shaka.ui.Locales.Ids.OFF));this.button.setAttribute("shaka-status",this.currentSelection.textContent);shaka.ui.Utils.focusOnTheChosenItem(this.menu);this.controls.dispatchEvent(new shaka.util.FakeEvent("captionselectionupdated"));
shaka.ui.Utils.setDisplay(this.button,b.length>0)};shaka.ui.TextSelection.prototype.onTextTrackSelected_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return b.player.selectTextTrack(a),c.yield(b.player.setTextTrackVisibility(!0),2);b.player.configure({preferredTextLanguage:a.language,preferForcedSubs:a.forced});c.jumpToEnd()})};
shaka.ui.TextSelection.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.button.ariaLabel=this.localization.resolve(a.CAPTIONS);this.backButton.ariaLabel=this.localization.resolve(a.BACK);this.nameSpan.textContent=this.localization.resolve(a.CAPTIONS);this.backSpan.textContent=this.localization.resolve(a.CAPTIONS);this.captionsOffSpan_.textContent=this.localization.resolve(a.OFF)};goog.exportSymbol("shaka.ui.TextSelection",shaka.ui.TextSelection);
shaka.ui.TextSelection.Factory=function(){};shaka.ui.TextSelection.Factory.prototype.create=function(a,b){return new shaka.ui.TextSelection(a,b)};shaka.ui.OverflowMenu.registerElement("captions",new shaka.ui.TextSelection.Factory);shaka.ui.Controls.registerElement("captions",new shaka.ui.TextSelection.Factory);shaka.ui.ToggleStereoscopicButton=function(a,b){shaka.ui.Element.call(this,a,b);var c=this;this.toggleStereoscopicButton_=shaka.util.Dom.createButton();this.toggleStereoscopicButton_.classList.add("shaka-toggle-stereoscopic-button");this.toggleStereoscopicButton_.classList.add("shaka-tooltip");this.toggleStereoscopicButton_.ariaPressed="false";this.toggleStereoscopicIcon_=new shaka.ui.MaterialSVGIcon(this.toggleStereoscopicButton_,shaka.ui.Enums.MaterialDesignSVGIcons.TOGGLE_STEREOSCOPIC);a=shaka.util.Dom.createHTMLElement("label");
a.classList.add("shaka-overflow-button-label");a.classList.add("shaka-overflow-menu-only");this.toggleStereoscopicNameSpan_=shaka.util.Dom.createHTMLElement("span");a.appendChild(this.toggleStereoscopicNameSpan_);this.toggleStereoscopicCurrentSelectionSpan_=shaka.util.Dom.createHTMLElement("span");this.toggleStereoscopicCurrentSelectionSpan_.classList.add("shaka-current-selection-span");a.appendChild(this.toggleStereoscopicCurrentSelectionSpan_);this.toggleStereoscopicButton_.appendChild(a);this.parent.appendChild(this.toggleStereoscopicButton_);
this.updateLocalizedStrings_();this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){c.updateLocalizedStrings_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_CHANGED,function(){c.updateLocalizedStrings_()});var d=this.controls.getVR();this.eventManager.listen(this.toggleStereoscopicButton_,"click",function(){c.controls.isOpaque()&&d.toggleStereoscopicMode()});this.eventManager.listen(d,"vrstatuschanged",function(){c.checkAvailability_()});
this.checkAvailability_()};$jscomp.inherits(shaka.ui.ToggleStereoscopicButton,shaka.ui.Element);shaka.ui.ToggleStereoscopicButton.prototype.checkAvailability_=function(){shaka.ui.Utils.setDisplay(this.toggleStereoscopicButton_,this.controls.isPlayingVR())};shaka.ui.ToggleStereoscopicButton.prototype.updateLocalizedStrings_=function(){var a=shaka.ui.Locales.Ids;this.toggleStereoscopicButton_.ariaLabel=this.localization.resolve(a.TOGGLE_STEREOSCOPIC);this.toggleStereoscopicNameSpan_.textContent=this.localization.resolve(a.TOGGLE_STEREOSCOPIC)};
goog.exportSymbol("shaka.ui.ToggleStereoscopicButton",shaka.ui.ToggleStereoscopicButton);shaka.ui.ToggleStereoscopicButton.Factory=function(){};shaka.ui.ToggleStereoscopicButton.Factory.prototype.create=function(a,b){return new shaka.ui.ToggleStereoscopicButton(a,b)};shaka.ui.OverflowMenu.registerElement("toggle_stereoscopic",new shaka.ui.ToggleStereoscopicButton.Factory);shaka.ui.Controls.registerElement("toggle_stereoscopic",new shaka.ui.ToggleStereoscopicButton.Factory);shaka.ui.VolumeBar=function(a,b){shaka.ui.RangeElement.call(this,a,b,["shaka-volume-bar-container"],["shaka-volume-bar"]);var c=this;this.config_=this.controls.getConfig();this.config_.alwaysShowVolumeBar||this.container.classList.add("shaka-volume-bar-container-allow-hiding");this.setRange(0,100);this.eventManager.listen(this.video,"volumechange",function(){return c.onPresentationVolumeChange_()});this.eventManager.listen(this.player,"loading",function(){return c.onPresentationVolumeChange_()});
this.eventManager.listen(this.player,"loaded",function(){return c.checkAvailability_()});this.eventManager.listen(this.player,"unloading",function(){return c.checkAvailability_()});this.eventManager.listen(this.player,"trackschanged",function(){return c.checkAvailability_()});this.eventManager.listen(this.controls,"caststatuschanged",function(){return c.onPresentationVolumeChange_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_VOLUME_CHANGED,function(){return c.onAdVolumeChange_()});
this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_MUTED,function(){return c.onAdVolumeChange_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STARTED,function(){return c.checkAvailability_()});this.eventManager.listen(this.adManager,shaka.ads.Utils.AD_STOPPED,function(){c.checkAvailability_();c.onPresentationVolumeChange_()});this.eventManager.listen(this.localization,shaka.ui.Localization.LOCALE_UPDATED,function(){return c.updateAriaLabel_()});this.eventManager.listen(this.localization,
shaka.ui.Localization.LOCALE_CHANGED,function(){return c.updateAriaLabel_()});this.onPresentationVolumeChange_();this.updateAriaLabel_();if(this.ad)this.onChange();this.checkAvailability_()};$jscomp.inherits(shaka.ui.VolumeBar,shaka.ui.RangeElement);shaka.ui.VolumeBar.prototype.onChange=function(){this.ad&&this.ad.isLinear()?this.ad.setVolume(this.getValue()/100):(this.video.volume=this.getValue()/100,this.video.volume>0&&(this.video.muted=!1))};
shaka.ui.VolumeBar.prototype.onPresentationVolumeChange_=function(){this.video.muted?this.setValue(0):this.setValue(this.video.volume*100);this.updateColors_()};shaka.ui.VolumeBar.prototype.onAdVolumeChange_=function(){goog.asserts.assert(this.ad!=null,"This.ad should exist at this point!");var a=this.ad.getVolume();this.setValue(a*100);this.updateColors_()};
shaka.ui.VolumeBar.prototype.updateColors_=function(){var a=this.config_.volumeBarColors,b=["to right"];b.push(a.level+this.getValue()+"%");b.push(a.base+this.getValue()+"%");b.push(a.base+"100%");this.container.style.background="linear-gradient("+b.join(",")+")"};shaka.ui.VolumeBar.prototype.updateAriaLabel_=function(){this.bar.ariaLabel=this.localization.resolve(shaka.ui.Locales.Ids.VOLUME)};
shaka.ui.VolumeBar.prototype.checkAvailability_=function(){var a=!0;this.ad&&this.ad.isLinear()?a=!0:this.player.isVideoOnly()&&(a=!1);shaka.ui.Utils.setDisplay(this.container,a)};goog.exportSymbol("shaka.ui.VolumeBar",shaka.ui.VolumeBar);shaka.ui.VolumeBar.Factory=function(){};shaka.ui.VolumeBar.Factory.prototype.create=function(a,b){return new shaka.ui.VolumeBar(a,b)};shaka.ui.Controls.registerElement("volume",new shaka.ui.VolumeBar.Factory);}).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.ui.debug.map