function X2JS(n,t,i){function h(n){var t=n.localName;return t==null&&(t=n.baseName),(t==null||t=="")&&(t=n.nodeName),t}function w(n){return n.prefix}function c(n){return typeof n=="string"?n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;"):n}function b(n){return n.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/")}function f(u){var l,it,o,g,v,c,s,rt,y,p,a,nt,k,ut,tt,d;if(u.nodeType==r.DOCUMENT_NODE){for(c=u.firstChild,l=0,it=u.childNodes.length;l<it;l+=1)if(u.childNodes[l].nodeType!==r.COMMENT_NODE){c=u.childNodes[l];break}return i?o=f(c):(o={},s=h(c),o[s]=f(c)),o}if(u.nodeType==r.ELEMENT_NODE){for(o={},o.__cnt=0,g=u.childNodes,v=0;v<g.length;v++)if(c=g.item(v),s=h(c),o.__cnt++,o[s]==null)o[s]=f(c),o[s+"_asArray"]=new Array(1),o[s+"_asArray"][0]=o[s];else{for(o[s]!=null&&(o[s]instanceof Array||(rt=o[s],o[s]=[],o[s][0]=rt,o[s+"_asArray"]=o[s])),y=0;o[s][y]!=null;)y++;o[s][y]=f(c)}for(p=0;p<u.attributes.length;p++){for(a=u.attributes.item(p),o.__cnt++,nt=a.value,k=0,ut=n.length;k<ut;k++)tt=n[k],tt.test.call(this,a.value)&&(nt=tt.converter.call(this,a.value));o[t+a.name]=nt}return d=w(u),d!=null&&d!=""&&(o.__cnt++,o.__prefix=d),o.__cnt==1&&o["#text"]!=null&&(o=o["#text"]),o["#text"]!=null&&(o.__text=o["#text"],e&&(o.__text=b(o.__text)),delete o["#text"],delete o["#text_asArray"]),o["#cdata-section"]!=null&&(o.__cdata=o["#cdata-section"],delete o["#cdata-section"],delete o["#cdata-section_asArray"]),(o.__text!=null||o.__cdata!=null)&&(o.toString=function(){return(this.__text!=null?this.__text:"")+(this.__cdata!=null?this.__cdata:"")}),o}return u.nodeType==r.TEXT_NODE||u.nodeType==r.CDATA_SECTION_NODE?u.nodeValue:u.nodeType==r.COMMENT_NODE?null:void 0}function u(n,t,i,r){var e="<"+(n!=null&&n.__prefix!=null?n.__prefix+":":"")+t,u,f,o;if(i!=null)for(u=0;u<i.length;u++)f=i[u],o=n[f],e+=" "+f.substr(1)+"='"+o+"'";return e+(r?"/>":">")}function o(n,t){return"<\/"+(n.__prefix!=null?n.__prefix+":":"")+t+">"}function k(n,t){return n.indexOf(t,n.length-t.length)!==-1}function l(n,t){return k(t.toString(),"_asArray")||t.toString().indexOf("_")==0||n[t]instanceof Function?!0:!1}function a(n){var t=0,i;if(n instanceof Object)for(i in n)l(n,i)||t++;return t}function v(n){var i=[],t;if(n instanceof Object)for(t in n)t.toString().indexOf("__")==-1&&t.toString().indexOf("_")==0&&i.push(t);return i}function d(n){var t="";return n.__cdata!=null&&(t+="<![CDATA["+n.__cdata+"]\]>"),n.__text!=null&&(t+=e?c(n.__text):n.__text),t}function y(n){var t="";return n instanceof Object?t+=d(n):n!=null&&(t+=e?c(n):n),t}function g(n,t,i){var f="",r;if(n.length==0)f+=u(n,t,i,!0);else for(r=0;r<n.length;r++)f+=u(n[r],t,v(n[r]),!1),f+=s(n[r]),f+=o(n[r],t);return f}function s(n){var i="",h=a(n),r,t,f,e;if(h>0)for(r in n)l(n,r)||(t=n[r],f=v(t),t==null||t==undefined?i+=u(t,r,f,!0):t instanceof Object?t instanceof Array?i+=g(t,r,f):(e=a(t),e>0||t.__text!=null||t.__cdata!=null?(i+=u(t,r,f,!1),i+=s(t),i+=o(t,r)):i+=u(t,r,f,!0)):(i+=u(t,r,f,!1),i+=y(t),i+=o(t,r)));return i+y(n)}(t===null||t===undefined)&&(t="_");(i===null||i===undefined)&&(i=!1);var p="1.0.11",e=!1,r={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};this.parseXmlString=function(n){var t,i;return window.DOMParser?(i=new window.DOMParser,t=i.parseFromString(n,"text/xml")):(n.indexOf("<?")==0&&(n=n.substr(n.indexOf("?>")+2)),t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(n)),t};this.xml2json=function(n){return f(n)};this.xml_str2json=function(n){var t=this.parseXmlString(n);return this.xml2json(t)};this.json2xml_str=function(n){return s(n)};this.json2xml=function(n){var t=this.json2xml_str(n);return this.parseXmlString(t)};this.getVersion=function(){return p};this.escapeMode=function(n){e=n}}function ObjectIron(n){var t;for(t=[],i=0,len=n.length;i<len;i+=1)n[i].isRoot?t.push("root"):t.push(n[i].name);var e=function(n,t){var i;if(n!==null&&t!==null)for(i in n)n.hasOwnProperty(i)&&(t.hasOwnProperty(i)||(t[i]=n[i]))},u=function(n,t,i){var o,s,r,u,f;if(n!==null&&n.length!==0)for(o=0,s=n.length;o<s;o+=1)r=n[o],t.hasOwnProperty(r.name)&&(i.hasOwnProperty(r.name)?r.merge&&(u=t[r.name],f=i[r.name],typeof u=="object"&&typeof f=="object"?e(u,f):i[r.name]=r.mergeFunction!=null?r.mergeFunction(u,f):u+f):i[r.name]=t[r.name])},r=function(n,t){var f=n,o,c,s,l,h,i,e;if(f.children!==null&&f.children.length!==0)for(o=0,c=f.children.length;o<c;o+=1)if(i=f.children[o],t.hasOwnProperty(i.name))if(i.isArray)for(h=t[i.name+"_asArray"],s=0,l=h.length;s<l;s+=1)e=h[s],u(f.properties,t,e),r(i,e);else e=t[i.name],u(f.properties,t,e),r(i,e)},f=function(i){var u,h,c,e,o,s,l;if(i===null||typeof i!="object")return i;for(u=0,h=t.length;u<h;u+=1)t[u]==="root"&&(o=n[u],s=i,r(o,s));for(e in i)if(i.hasOwnProperty(e)){if(c=t.indexOf(e),c!==-1)if(o=n[c],o.isArray)for(l=i[e+"_asArray"],u=0,h=l.length;u<h;u+=1)s=l[u],r(o,s);else s=i[e],r(o,s);f(i[e])}return i};return{run:f}}var utils,UTF8,BASE64,btoa,atob;(function(n){"use strict";var t={VERSION:"0.5.3"};t.System=function(){this._mappings={};this._outlets={};this._handlers={};this.strictInjections=!0;this.autoMapOutlets=!1;this.postInjectionHook="setup"};t.System.prototype={_createAndSetupInstance:function(n,t){var i=new t;return this.injectInto(i,n),i},_retrieveFromCacheOrCreate:function(n,t){var r,i;if(typeof t=="undefined"&&(t=!1),this._mappings.hasOwnProperty(n))i=this._mappings[n],!t&&i.isSingleton?(i.object==null&&(i.object=this._createAndSetupInstance(n,i.clazz)),r=i.object):r=i.clazz?this._createAndSetupInstance(n,i.clazz):i.object;else throw new Error(1e3);return r},mapOutlet:function(n,t,i){if(typeof n=="undefined")throw new Error(1010);return t=t||"global",i=i||n,this._outlets.hasOwnProperty(t)||(this._outlets[t]={}),this._outlets[t][i]=n,this},getObject:function(n){if(typeof n=="undefined")throw new Error(1020);return this._retrieveFromCacheOrCreate(n)},mapValue:function(n,t){if(typeof n=="undefined")throw new Error(1030);return this._mappings[n]={clazz:null,object:t,isSingleton:!0},this.autoMapOutlets&&this.mapOutlet(n),this.hasMapping(n)&&this.injectInto(t,n),this},hasMapping:function(n){if(typeof n=="undefined")throw new Error(1040);return this._mappings.hasOwnProperty(n)},mapClass:function(n,t){if(typeof n=="undefined")throw new Error(1050);if(typeof t=="undefined")throw new Error(1051);return this._mappings[n]={clazz:t,object:null,isSingleton:!1},this.autoMapOutlets&&this.mapOutlet(n),this},mapSingleton:function(n,t){if(typeof n=="undefined")throw new Error(1060);if(typeof t=="undefined")throw new Error(1061);return this._mappings[n]={clazz:t,object:null,isSingleton:!0},this.autoMapOutlets&&this.mapOutlet(n),this},instantiate:function(n){if(typeof n=="undefined")throw new Error(1070);return this._retrieveFromCacheOrCreate(n,!0)},injectInto:function(n,t){var i,f,u,r,e;if(typeof n=="undefined")throw new Error(1080);if(typeof n=="object"){i=[];this._outlets.hasOwnProperty("global")&&i.push(this._outlets.global);typeof t!="undefined"&&this._outlets.hasOwnProperty(t)&&i.push(this._outlets[t]);for(f in i){u=i[f];for(r in u)e=u[r],(!this.strictInjections||r in n)&&(n[r]=this.getObject(e))}"setup"in n&&n.setup.call(n)}return this},unmap:function(n){if(typeof n=="undefined")throw new Error(1090);return delete this._mappings[n],this},unmapOutlet:function(n,t){if(typeof n=="undefined")throw new Error(1100);if(typeof t=="undefined")throw new Error(1101);return delete this._outlets[n][t],this},mapHandler:function(n,t,i,r,u){if(typeof n=="undefined")throw new Error(1110);return t=t||"global",i=i||n,typeof r=="undefined"&&(r=!1),typeof u=="undefined"&&(u=!1),this._handlers.hasOwnProperty(n)||(this._handlers[n]={}),this._handlers[n].hasOwnProperty(t)||(this._handlers[n][t]=[]),this._handlers[n][t].push({handler:i,oneShot:r,passEvent:u}),this},unmapHandler:function(n,t,i){var r,u,f;if(typeof n=="undefined")throw new Error(1120);if(t=t||"global",i=i||n,this._handlers.hasOwnProperty(n)&&this._handlers[n].hasOwnProperty(t)){r=this._handlers[n][t];for(u in r)if(f=r[u],f.handler===i){r.splice(u,1);break}}return this},notify:function(n){var s,l,h,u,f,r,e,t,o,c,i;if(typeof n=="undefined")throw new Error(1130);if(s=Array.prototype.slice.call(arguments),l=s.slice(1),this._handlers.hasOwnProperty(n)){h=this._handlers[n];for(u in h){for(f=h[u],u!=="global"&&(r=this.getObject(u)),e=[],t=0,o=f.length;t<o;t++)i=f[t],c=r&&typeof i.handler=="string"?r[i.handler]:i.handler,i.oneShot&&e.unshift(t),i.passEvent?c.apply(r,s):c.apply(r,l);for(t=0,o=e.length;t<o;t++)f.splice(e[t],1)}}return this}};n.dijon=t})(this);typeof utils=="undefined"&&(utils={});typeof utils.Math=="undefined"&&(utils.Math={});utils.Math.to64BitNumber=function(n,t){var i,r,u;return i=new goog.math.Long(0,t),r=new goog.math.Long(n,0),u=i.add(r),u.toNumber()};goog={};goog.math={};goog.math.Long=function(n,t){this.low_=n|0;this.high_=t|0};goog.math.Long.IntCache_={};goog.math.Long.fromInt=function(n){var t,i;return-128<=n&&n<128&&(t=goog.math.Long.IntCache_[n],t)?t:(i=new goog.math.Long(n|0,n<0?-1:0),-128<=n&&n<128&&(goog.math.Long.IntCache_[n]=i),i)};goog.math.Long.fromNumber=function(n){return isNaN(n)||!isFinite(n)?goog.math.Long.ZERO:n<=-goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MIN_VALUE:n+1>=goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MAX_VALUE:n<0?goog.math.Long.fromNumber(-n).negate():new goog.math.Long(n%goog.math.Long.TWO_PWR_32_DBL_|0,n/goog.math.Long.TWO_PWR_32_DBL_|0)};goog.math.Long.fromBits=function(n,t){return new goog.math.Long(n,t)};goog.math.Long.fromString=function(n,t){var i,o,r,u,f,e,s;if(n.length==0)throw Error("number format error: empty string");if(i=t||10,i<2||36<i)throw Error("radix out of range: "+i);if(n.charAt(0)=="-")return goog.math.Long.fromString(n.substring(1),i).negate();if(n.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+n);for(o=goog.math.Long.fromNumber(Math.pow(i,8)),r=goog.math.Long.ZERO,u=0;u<n.length;u+=8)f=Math.min(8,n.length-u),e=parseInt(n.substring(u,u+f),i),f<8?(s=goog.math.Long.fromNumber(Math.pow(i,f)),r=r.multiply(s).add(goog.math.Long.fromNumber(e))):(r=r.multiply(o),r=r.add(goog.math.Long.fromNumber(e)));return r};goog.math.Long.TWO_PWR_16_DBL_=65536;goog.math.Long.TWO_PWR_24_DBL_=16777216;goog.math.Long.TWO_PWR_32_DBL_=goog.math.Long.TWO_PWR_16_DBL_*goog.math.Long.TWO_PWR_16_DBL_;goog.math.Long.TWO_PWR_31_DBL_=goog.math.Long.TWO_PWR_32_DBL_/2;goog.math.Long.TWO_PWR_48_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_16_DBL_;goog.math.Long.TWO_PWR_64_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_32_DBL_;goog.math.Long.TWO_PWR_63_DBL_=goog.math.Long.TWO_PWR_64_DBL_/2;goog.math.Long.ZERO=goog.math.Long.fromInt(0);goog.math.Long.ONE=goog.math.Long.fromInt(1);goog.math.Long.NEG_ONE=goog.math.Long.fromInt(-1);goog.math.Long.MAX_VALUE=goog.math.Long.fromBits(4294967295|0,2147483647);goog.math.Long.MIN_VALUE=goog.math.Long.fromBits(0,2147483648|0);goog.math.Long.TWO_PWR_24_=goog.math.Long.fromInt(16777216);goog.math.Long.prototype.toInt=function(){return this.low_};goog.math.Long.prototype.toNumber=function(){return this.high_*goog.math.Long.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()};goog.math.Long.prototype.toString=function(n){var t=n||10;if(t<2||36<t)throw Error("radix out of range: "+t);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(goog.math.Long.MIN_VALUE)){var f=goog.math.Long.fromNumber(t),e=this.div(f),i=e.multiply(f).subtract(this);return e.toString(t)+i.toInt().toString(t)}return"-"+this.negate().toString(t)}for(var o=goog.math.Long.fromNumber(Math.pow(t,6)),i=this,u="";;){var s=i.div(o),h=i.subtract(s.multiply(o)).toInt(),r=h.toString(t);if(i=s,i.isZero())return r+u;while(r.length<6)r="0"+r;u=""+r+u}};goog.math.Long.prototype.getHighBits=function(){return this.high_};goog.math.Long.prototype.getLowBits=function(){return this.low_};goog.math.Long.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:goog.math.Long.TWO_PWR_32_DBL_+this.low_};goog.math.Long.prototype.getNumBitsAbs=function(){var t,n;if(this.isNegative())return this.equals(goog.math.Long.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(t=this.high_!=0?this.high_:this.low_,n=31;n>0;n--)if((t&1<<n)!=0)break;return this.high_!=0?n+33:n+1};goog.math.Long.prototype.isZero=function(){return this.high_==0&&this.low_==0};goog.math.Long.prototype.isNegative=function(){return this.high_<0};goog.math.Long.prototype.isOdd=function(){return(this.low_&1)==1};goog.math.Long.prototype.equals=function(n){return this.high_==n.high_&&this.low_==n.low_};goog.math.Long.prototype.notEquals=function(n){return this.high_!=n.high_||this.low_!=n.low_};goog.math.Long.prototype.lessThan=function(n){return this.compare(n)<0};goog.math.Long.prototype.lessThanOrEqual=function(n){return this.compare(n)<=0};goog.math.Long.prototype.greaterThan=function(n){return this.compare(n)>0};goog.math.Long.prototype.greaterThanOrEqual=function(n){return this.compare(n)>=0};goog.math.Long.prototype.compare=function(n){if(this.equals(n))return 0;var t=this.isNegative(),i=n.isNegative();return t&&!i?-1:!t&&i?1:this.subtract(n).isNegative()?-1:1};goog.math.Long.prototype.negate=function(){return this.equals(goog.math.Long.MIN_VALUE)?goog.math.Long.MIN_VALUE:this.not().add(goog.math.Long.ONE)};goog.math.Long.prototype.add=function(n){var f=this.high_>>>16,e=this.high_&65535,o=this.low_>>>16,s=this.low_&65535,h=n.high_>>>16,c=n.high_&65535,l=n.low_>>>16,a=n.low_&65535,r=0,t=0,i=0,u=0;return u+=s+a,i+=u>>>16,u&=65535,i+=o+l,t+=i>>>16,i&=65535,t+=e+c,r+=t>>>16,t&=65535,r+=f+h,r&=65535,goog.math.Long.fromBits(i<<16|u,r<<16|t)};goog.math.Long.prototype.subtract=function(n){return this.add(n.negate())};goog.math.Long.prototype.multiply=function(n){if(this.isZero()||n.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE))return n.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(n.equals(goog.math.Long.MIN_VALUE))return this.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(this.isNegative())return n.isNegative()?this.negate().multiply(n.negate()):this.negate().multiply(n).negate();if(n.isNegative())return this.multiply(n.negate()).negate();if(this.lessThan(goog.math.Long.TWO_PWR_24_)&&n.lessThan(goog.math.Long.TWO_PWR_24_))return goog.math.Long.fromNumber(this.toNumber()*n.toNumber());var l=this.high_>>>16,h=this.high_&65535,o=this.low_>>>16,u=this.low_&65535,a=n.high_>>>16,c=n.high_&65535,s=n.low_>>>16,f=n.low_&65535,r=0,t=0,i=0,e=0;return e+=u*f,i+=e>>>16,e&=65535,i+=o*f,t+=i>>>16,i&=65535,i+=u*s,t+=i>>>16,i&=65535,t+=h*f,r+=t>>>16,t&=65535,t+=o*s,r+=t>>>16,t&=65535,t+=u*c,r+=t>>>16,t&=65535,r+=l*f+h*s+o*c+u*a,r&=65535,goog.math.Long.fromBits(i<<16|e,r<<16|t)};goog.math.Long.prototype.div=function(n){var e,t,o,u,i;if(n.isZero())throw Error("division by zero");else if(this.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE))return n.equals(goog.math.Long.ONE)||n.equals(goog.math.Long.NEG_ONE)?goog.math.Long.MIN_VALUE:n.equals(goog.math.Long.MIN_VALUE)?goog.math.Long.ONE:(e=this.shiftRight(1),t=e.div(n).shiftLeft(1),t.equals(goog.math.Long.ZERO)?n.isNegative()?goog.math.Long.ONE:goog.math.Long.NEG_ONE:(i=this.subtract(n.multiply(t)),o=t.add(i.div(n)),o));if(n.equals(goog.math.Long.MIN_VALUE))return goog.math.Long.ZERO;if(this.isNegative())return n.isNegative()?this.negate().div(n.negate()):this.negate().div(n).negate();if(n.isNegative())return this.div(n.negate()).negate();for(u=goog.math.Long.ZERO,i=this;i.greaterThanOrEqual(n);){for(var t=Math.max(1,Math.floor(i.toNumber()/n.toNumber())),s=Math.ceil(Math.log(t)/Math.LN2),h=s<=48?1:Math.pow(2,s-48),r=goog.math.Long.fromNumber(t),f=r.multiply(n);f.isNegative()||f.greaterThan(i);)t-=h,r=goog.math.Long.fromNumber(t),f=r.multiply(n);r.isZero()&&(r=goog.math.Long.ONE);u=u.add(r);i=i.subtract(f)}return u};goog.math.Long.prototype.modulo=function(n){return this.subtract(this.div(n).multiply(n))};goog.math.Long.prototype.not=function(){return goog.math.Long.fromBits(~this.low_,~this.high_)};goog.math.Long.prototype.and=function(n){return goog.math.Long.fromBits(this.low_&n.low_,this.high_&n.high_)};goog.math.Long.prototype.or=function(n){return goog.math.Long.fromBits(this.low_|n.low_,this.high_|n.high_)};goog.math.Long.prototype.xor=function(n){return goog.math.Long.fromBits(this.low_^n.low_,this.high_^n.high_)};goog.math.Long.prototype.shiftLeft=function(n){var t,i;return n&=63,n==0?this:(t=this.low_,n<32?(i=this.high_,goog.math.Long.fromBits(t<<n,i<<n|t>>>32-n)):goog.math.Long.fromBits(0,t<<n-32))};goog.math.Long.prototype.shiftRight=function(n){var t,i;return n&=63,n==0?this:(t=this.high_,n<32?(i=this.low_,goog.math.Long.fromBits(i>>>n|t<<32-n,t>>n)):goog.math.Long.fromBits(t>>n-32,t>=0?0:-1))};goog.math.Long.prototype.shiftRightUnsigned=function(n){var t,i;return n&=63,n==0?this:(t=this.high_,n<32?(i=this.low_,goog.math.Long.fromBits(i>>>n|t<<32-n,t>>>n)):n==32?goog.math.Long.fromBits(t,0):goog.math.Long.fromBits(t>>>n-32,0))};UTF8={};UTF8.encode=function(n){for(var t,i=[],r=0;r<n.length;++r)t=n.charCodeAt(r),t<128?i.push(t):t<2048?(i.push(192|t>>6),i.push(128|63&t)):t<65536?(i.push(224|t>>12),i.push(128|63&t>>6),i.push(128|63&t)):(i.push(240|t>>18),i.push(128|63&t>>12),i.push(128|63&t>>6),i.push(128|63&t));return i};UTF8.decode=function(n){for(var r=[],i=0,t;i<n.length;)t=n[i++],t<128||(t<224?t=(31&t)<<6|63&n[i++]:t<240?(t=(15&t)<<12,t|=(63&n[i++])<<6,t|=63&n[i++]):(t=(7&t)<<18,t|=(63&n[i++])<<12,t|=(63&n[i++])<<6,t|=63&n[i++])),r.push(String.fromCharCode(t));return r.join("")};BASE64={},function(n){var u=function(t){for(var u=0,i=[],f=0|t.length/3,r;0<f--;)r=(t[u]<<16)+(t[u+1]<<8)+t[u+2],u+=3,i.push(n.charAt(63&r>>18)),i.push(n.charAt(63&r>>12)),i.push(n.charAt(63&r>>6)),i.push(n.charAt(63&r));return 2==t.length-u?(r=(t[u]<<16)+(t[u+1]<<8),i.push(n.charAt(63&r>>18)),i.push(n.charAt(63&r>>12)),i.push(n.charAt(63&r>>6)),i.push("=")):1==t.length-u&&(r=t[u]<<16,i.push(n.charAt(63&r>>18)),i.push(n.charAt(63&r>>12)),i.push("==")),i.join("")},t=function(){for(var i=[],t=0;t<n.length;++t)i[n.charCodeAt(t)]=t;return i["=".charCodeAt(0)]=0,i}(),r=function(n){for(var r=0,i=[],f=0|n.length/4,u;0<f--;)u=(t[n.charCodeAt(r)]<<18)+(t[n.charCodeAt(r+1)]<<12)+(t[n.charCodeAt(r+2)]<<6)+t[n.charCodeAt(r+3)],i.push(255&u>>16),i.push(255&u>>8),i.push(255&u),r+=4;return i&&("="==n.charAt(r-2)?(i.pop(),i.pop()):"="==n.charAt(r-1)&&i.pop()),i},i={};i.encode=function(n){for(var i=[],t=0;t<n.length;++t)i.push(n.charCodeAt(t));return i};i.decode=function(){for(var n=0;n<s.length;++n)a[n]=String.fromCharCode(a[n]);return a.join("")};BASE64.decodeArray=function(n){var t=r(n);return new Uint8Array(t)};BASE64.encodeASCII=function(n){var t=i.encode(n);return u(t)};BASE64.decodeASCII=function(n){var t=r(n);return i.decode(t)};BASE64.encode=function(n){var t=UTF8.encode(n);return u(t)};BASE64.decode=function(n){var t=r(n);return UTF8.decode(t)}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");undefined===btoa&&(btoa=BASE64.encode);undefined===atob&&(atob=BASE64.decode);MediaPlayer=function(n){"use strict";var it="1.2.0",rt=n,t,u,r,s,h,a,i,f,c,d,e,l=!1,p=!1,w=!0,b=!1,k=MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_REQUIRED,v=function(){return!!h&&!!a},g=function(){if(!l)throw"MediaPlayer not initialized!";if(!this.capabilities.supportsMediaSource()){this.errHandler.capabilityError("mediasource");return}if(!h||!a)throw"Missing view or source.";p=!0;i=t.getObject("streamController");i.subscribe(i.eventList.ENAME_STREAMS_COMPOSED,c);u.subscribe(u.eventList.ENAME_MANIFEST_LOADED,i);u.subscribe(u.eventList.ENAME_MANIFEST_LOADED,c);r.subscribe(r.eventList.ENAME_TOP_QUALITY_INDEX_CHANGED,s);i.setVideoModel(e);i.setAutoPlay(w);i.load(a);t.mapValue("scheduleWhilePaused",b);t.mapOutlet("scheduleWhilePaused","stream");t.mapOutlet("scheduleWhilePaused","scheduleController");t.mapValue("bufferMax",k);t.injectInto(s,"bufferMax");f.initialize()},nt=function(){v()&&g.call(this)},o=function(){var n=this.metricsModel.getReadOnlyMetricsFor("video")||this.metricsModel.getReadOnlyMetricsFor("audio");return this.metricsExt.getCurrentDVRInfo(n)},ut=function(){return o.call(this).mpd.timeShiftBufferDepth},ft=function(n){var t=o.call(this),i=t.range.start+parseInt(n);return i>t.range.end&&(i=t.range.end),i},et=function(n){e.getElement().currentTime=this.getDVRSeekOffset(n)},ot=function(){var n=o.call(this);return n===null?0:Math.round(this.duration()-(n.range.end-n.time))},st=function(){var n=o.call(this),t;return n===null?0:(t=n.range.end-n.range.start,Math.round(t<n.mpd.timeShiftBufferDepth?t:n.mpd.timeShiftBufferDepth))},ht=function(){var n=o.call(this),t,i;return n===null?0:(t=n.mpd.availabilityStartTime.getTime()/1e3,i=this.time()+(t+n.range.start),Math.round(i))},ct=function(){var n=o.call(this),t,i;return n===null?0:(t=n.mpd.availabilityStartTime.getTime()/1e3,i=t+n.range.start+this.duration(),Math.round(i))},lt=function(n,t,i){var r=new Date(n*1e3),u=r.toLocaleDateString(t),f=r.toLocaleTimeString(t,{hour12:i});return f+" "+u},at=function(n){n=Math.max(n,0);var t=Math.floor(n/3600),i=Math.floor(n%3600/60),r=Math.floor(n%3600%60);return(t===0?"":t<10?"0"+t.toString()+":":t.toString()+":")+(i<10?"0"+i.toString():i.toString())+":"+(r<10?"0"+r.toString():r.toString())},y=function(n,t,i){t&&n!==undefined&&n!==null&&(i?f.setRules(n,t):f.addRules(n,t))},tt=function(){p&&i&&(i.unsubscribe(i.eventList.ENAME_STREAMS_COMPOSED,c),u.unsubscribe(u.eventList.ENAME_MANIFEST_LOADED,i),u.unsubscribe(u.eventList.ENAME_MANIFEST_LOADED,c),r.unsubscribe(r.eventList.ENAME_TOP_QUALITY_INDEX_CHANGED,s),i.reset(),r.reset(),s.reset(),f.reset(),i=null,p=!1)};return t=new dijon.System,t.mapValue("system",t),t.mapOutlet("system"),t.injectInto(rt),{notifier:undefined,debug:undefined,eventBus:undefined,capabilities:undefined,metricsModel:undefined,errHandler:undefined,tokenAuthentication:undefined,uriQueryFragModel:undefined,videoElementExt:undefined,abrRulesCollection:undefined,scheduleRulesCollection:undefined,setup:function(){d=t.getObject("metricsExt");u=t.getObject("manifestLoader");c=t.getObject("manifestUpdater");s=t.getObject("bufferExt");r=t.getObject("abrController");f=t.getObject("rulesController")},addEventListener:function(n,t,i){this.eventBus.addEventListener(n,t,i)},removeEventListener:function(n,t,i){this.eventBus.removeEventListener(n,t,i)},getVersion:function(){return it},startup:function(){l||(t.injectInto(this),l=!0)},getDebug:function(){return this.debug},getVideoModel:function(){return e},setAutoPlay:function(n){w=n},getAutoPlay:function(){return w},setScheduleWhilePaused:function(n){b=n},getScheduleWhilePaused:function(){return b},setTokenAuthentication:function(n,t){this.tokenAuthentication.setTokenAuthentication({name:n,type:t})},setBufferMax:function(n){k=n},getBufferMax:function(){return k},getMetricsExt:function(){return d},getMetricsFor:function(n){return this.metricsModel.getReadOnlyMetricsFor(n)},getQualityFor:function(n){return r.getQualityFor(n)},setQualityFor:function(n,t){r.setPlaybackQuality(n,t)},getAutoSwitchQuality:function(){return r.getAutoSwitchBitrate()},setAutoSwitchQuality:function(n){r.setAutoSwitchBitrate(n)},setSchedulingRules:function(n){y.call(this,f.SCHEDULING_RULE,n,!0)},addSchedulingRules:function(n){y.call(this,f.SCHEDULING_RULE,n,!1)},setABRRules:function(n){y.call(this,f.ABR_RULE,n,!0)},addABRRules:function(n){y.call(this,f.ABR_RULE,n,!1)},attachView:function(n){if(!l)throw"MediaPlayer not initialized!";h=n;e=null;h&&(e=t.getObject("videoModel"),e.setElement(h));tt.call(this);v.call(this)&&nt.call(this)},attachSource:function(n){if(!l)throw"MediaPlayer not initialized!";this.uriQueryFragModel.reset();a=this.uriQueryFragModel.parseURI(n);tt.call(this);v.call(this)&&nt.call(this)},reset:function(){this.attachSource(null);this.attachView(null)},play:g,isReady:v,seek:et,time:ot,duration:st,timeAsUTC:ht,durationAsUTC:ct,getDVRWindowSize:ut,getDVRSeekOffset:ft,formatUTC:lt,convertToTimeCode:at}};MediaPlayer.prototype={constructor:MediaPlayer};MediaPlayer.dependencies={};MediaPlayer.utils={};MediaPlayer.models={};MediaPlayer.vo={};MediaPlayer.vo.metrics={};MediaPlayer.rules={};MediaPlayer.di={};MediaPlayer.di.Context=function(){"use strict";return{system:undefined,setup:function(){this.system.autoMapOutlets=!0;this.system.mapSingleton("debug",MediaPlayer.utils.Debug);this.system.mapSingleton("tokenAuthentication",MediaPlayer.utils.TokenAuthentication);this.system.mapSingleton("eventBus",MediaPlayer.utils.EventBus);this.system.mapSingleton("capabilities",MediaPlayer.utils.Capabilities);this.system.mapSingleton("textTrackExtensions",MediaPlayer.utils.TextTrackExtensions);this.system.mapSingleton("vttParser",MediaPlayer.utils.VTTParser);this.system.mapSingleton("ttmlParser",MediaPlayer.utils.TTMLParser);this.system.mapClass("videoModel",MediaPlayer.models.VideoModel);this.system.mapSingleton("manifestModel",MediaPlayer.models.ManifestModel);this.system.mapSingleton("metricsModel",MediaPlayer.models.MetricsModel);this.system.mapSingleton("uriQueryFragModel",MediaPlayer.models.URIQueryAndFragmentModel);this.system.mapClass("protectionModel",MediaPlayer.models.ProtectionModel);this.system.mapSingleton("textSourceBuffer",MediaPlayer.dependencies.TextSourceBuffer);this.system.mapSingleton("mediaSourceExt",MediaPlayer.dependencies.MediaSourceExtensions);this.system.mapSingleton("sourceBufferExt",MediaPlayer.dependencies.SourceBufferExtensions);this.system.mapSingleton("bufferExt",MediaPlayer.dependencies.BufferExtensions);this.system.mapSingleton("abrController",MediaPlayer.dependencies.AbrController);this.system.mapSingleton("errHandler",MediaPlayer.dependencies.ErrorHandler);this.system.mapSingleton("protectionExt",MediaPlayer.dependencies.ProtectionExtensions);this.system.mapSingleton("videoExt",MediaPlayer.dependencies.VideoModelExtensions);this.system.mapClass("protectionController",MediaPlayer.dependencies.ProtectionController);this.system.mapClass("playbackController",MediaPlayer.dependencies.PlaybackController);this.system.mapSingleton("liveEdgeFinder",MediaPlayer.dependencies.LiveEdgeFinder);this.system.mapClass("metrics",MediaPlayer.models.MetricsList);this.system.mapClass("downloadRatioRule",MediaPlayer.rules.DownloadRatioRule);this.system.mapClass("insufficientBufferRule",MediaPlayer.rules.InsufficientBufferRule);this.system.mapClass("limitSwitchesRule",MediaPlayer.rules.LimitSwitchesRule);this.system.mapSingleton("abrRulesCollection",MediaPlayer.rules.ABRRulesCollection);this.system.mapSingleton("rulesController",MediaPlayer.rules.RulesController);this.system.mapClass("liveEdgeBinarySearchRule",MediaPlayer.rules.LiveEdgeBinarySearchRule);this.system.mapClass("bufferLevelRule",MediaPlayer.rules.BufferLevelRule);this.system.mapClass("pendingRequestsRule",MediaPlayer.rules.PendingRequestsRule);this.system.mapClass("playbackTimeRule",MediaPlayer.rules.PlaybackTimeRule);this.system.mapClass("sameTimeRequestRule",MediaPlayer.rules.SameTimeRequestRule);this.system.mapSingleton("scheduleRulesCollection",MediaPlayer.rules.ScheduleRulesCollection);this.system.mapClass("streamProcessor",MediaPlayer.dependencies.StreamProcessor);this.system.mapClass("eventController",MediaPlayer.dependencies.EventController);this.system.mapClass("textController",MediaPlayer.dependencies.TextController);this.system.mapClass("bufferController",MediaPlayer.dependencies.BufferController);this.system.mapSingleton("manifestLoader",MediaPlayer.dependencies.ManifestLoader);this.system.mapSingleton("manifestUpdater",MediaPlayer.dependencies.ManifestUpdater);this.system.mapClass("fragmentController",MediaPlayer.dependencies.FragmentController);this.system.mapClass("fragmentLoader",MediaPlayer.dependencies.FragmentLoader);this.system.mapClass("fragmentModel",MediaPlayer.dependencies.FragmentModel);this.system.mapSingleton("streamController",MediaPlayer.dependencies.StreamController);this.system.mapClass("stream",MediaPlayer.dependencies.Stream);this.system.mapClass("scheduleController",MediaPlayer.dependencies.ScheduleController);this.system.mapSingleton("notifier",MediaPlayer.dependencies.Notifier)}}};Dash=function(){"use strict";return{modules:{},dependencies:{},vo:{},di:{}}}();Dash.di.DashContext=function(){"use strict";return{system:undefined,setup:function(){Dash.di.DashContext.prototype.setup.call(this);this.system.mapClass("parser",Dash.dependencies.DashParser);this.system.mapClass("indexHandler",Dash.dependencies.DashHandler);this.system.mapSingleton("baseURLExt",Dash.dependencies.BaseURLExtensions);this.system.mapClass("fragmentExt",Dash.dependencies.FragmentExtensions);this.system.mapClass("representationController",Dash.dependencies.RepresentationController);this.system.mapSingleton("manifestExt",Dash.dependencies.DashManifestExtensions);this.system.mapSingleton("metricsExt",Dash.dependencies.DashMetricsExtensions);this.system.mapSingleton("timelineConverter",Dash.dependencies.TimelineConverter)}}};Dash.di.DashContext.prototype=new MediaPlayer.di.Context;Dash.di.DashContext.prototype.constructor=Dash.di.DashContext;MediaPlayer.dependencies.AbrController=function(){"use strict";var r=!0,n={},t={},i={},u=function(n){return t.hasOwnProperty(n)||(t[n]=0),t[n]},f=function(n,i){t[n]=i},e=function(n){return i.hasOwnProperty(n)||(i[n]=0),i[n]},s=function(n,t){i[n]=t},h=function(t,i){n[t]=i},o=function(t){return n.hasOwnProperty(t)||(n[t]=0),n[t]},c=function(n,t){var r=this,u=n.streamProcessor.getType(),i;(i=r.manifestExt.getRepresentationCount(t)-1,o(u)!==i)&&(h(u,i),r.notify(r.eventList.ENAME_TOP_QUALITY_INDEX_CHANGED,u,i))};return{debug:undefined,abrRulesCollection:undefined,manifestExt:undefined,rulesController:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_QUALITY_CHANGED:"qualityChanged",ENAME_TOP_QUALITY_INDEX_CHANGED:"topQualityIndexChanged"},setup:function(){this.dataUpdateCompleted=c},getAutoSwitchBitrate:function(){return r},setAutoSwitchBitrate:function(n){r=n},getPlaybackQuality:function(n,t,i){var c=this,h,l,v,a,y=function(t){var i=o(n);(h=t.value,a=t.confidence,h<0&&(h=0),h>i&&(h=i),l=u(n),h!==l)&&(f(n,h),s(n,a),c.notify(c.eventList.ENAME_QUALITY_CHANGED,n,l,h))};(h=u(n),a=e(n),r)&&(c.abrRulesCollection.downloadRatioRule&&c.abrRulesCollection.downloadRatioRule.setData(i,t.adaptation.period.id),v=c.abrRulesCollection.getRules(MediaPlayer.rules.ABRRulesCollection.prototype.QUALITY_SWITCH_RULES),c.rulesController.applyRules(v,n,t,y.bind(c),h,function(n,t){return Math.min(n,t)}))},setPlaybackQuality:function(t,i){var r=u(t),e=i!==null&&!isNaN(i)&&i%1==0;if(!e)throw"argument is not an integer";i!==r&&i>=0&&n.hasOwnProperty(t)&&i<=n[t]&&(f(t,i),this.notify(this.eventList.ENAME_QUALITY_CHANGED,t,r,i))},getQualityFor:function(n){return u(n)},getConfidenceFor:function(n){return e(n)},reset:function(){var e=this.abrRulesCollection.getRules(MediaPlayer.rules.ABRRulesCollection.prototype.QUALITY_SWITCH_RULES),f,o=e.length,u=0;for(u;u<o;u+=1)f=e[u],typeof f.reset=="function"&&f.reset();r=!0;n={};t={};i={}}}};MediaPlayer.dependencies.AbrController.prototype={constructor:MediaPlayer.dependencies.AbrController};MediaPlayer.dependencies.BufferController=function(){"use strict";var vt=.5,yt=22,a=[],t=0,u=-1,v=!1,s=0,f=Number.POSITIVE_INFINITY,y,g=-1,et=-1,h,n=null,i,p=null,r,c=!1,e=!1,o=[],nt=!1,w=function(){var n=this.streamProcessor.getFragmentModel().getLoadingRequests();return u>t&&(ot(o,u)||ot(n,u))?!1:u!==t},ot=function(n,t){var i=0,r=n.length;for(i;i<r;i+=1)if(n[i].quality===t)return!0;return!1},pt=function(n,t){var i=function(n,i){return n[t]<i[t]?-1:n[t]>i[t]?1:0};n.sort(i)},wt=function(n,i,r,u){var f=this;i===f.streamProcessor.getFragmentModel()&&(f.debug.log("Initialization finished loading: "+h),a[u]=r,u===t&&w.call(f))&&ft.call(f)},bt=function(n,t,i,r,u){if(t===this.streamProcessor.getFragmentModel()){var f,h=this.streamProcessor.getFragmentModel().getExecutedRequestForQualityAndIndex(r,u),c=this.representationController.getRepresentationForQuality(r),e=this.manifestExt.getEventStreamForAdaptationSet(this.streamProcessor.getData()),s=this.manifestExt.getEventStreamForRepresentation(this.streamProcessor.getData(),c);(e.length>0||s.length>0)&&(f=kt.call(this,i,h,e,s),this.streamProcessor.getEventController().addInbandEvents(f));i=dt.call(this,i);o.push({bytes:i,quality:r,index:u});pt(o,"index");l.call(this)}},st=function(i,f,o){e=!0;r={quality:f,index:o};var s=this,h=isNaN(o);if(f!==t&&h||f!==u&&!h){ti.call(s,f,o);return}s.sourceBufferExt.append(n,i)},b=function(t,i,u,s){var c,l,a,v;if(n===i){if(c=this,s){s.code===yt&&(o.unshift({bytes:u,quality:r.quality,index:r.index}),f=ht.call(c)*.8,c.bufferExt.setCriticalBufferLevel(f),c.notify(c.eventList.ENAME_QUOTA_EXCEEDED,f),it.call(c));e=!1;return}if(tt.call(c),k.call(c)||(c.notify(c.eventList.ENAME_QUOTA_EXCEEDED,f),it.call(c)),l=c.sourceBufferExt.getAllRanges(n),l&&l.length>0)for(a=0,v=l.length;a<v;a+=1)c.debug.log("Buffered "+h+" Range: "+l.start(a)+" - "+l.end(a));ni.call(c,r.quality,r.index);c.notify(c.eventList.ENAME_BYTES_APPENDED,r.quality,r.index)}},tt=function(){var t=this,i=t.playbackController.getTime();return s=t.sourceBufferExt.getBufferLength(n,i),t.notify(t.eventList.ENAME_BUFFER_LEVEL_UPDATED,s),gt.call(t),lt.call(t),s<vt&&rt.call(t,!1),!0},kt=function(n,t,i,r){var y=[],u=0,c,a,p=Math.pow(256,2),w=Math.pow(256,3),g=Math.max(isNaN(t.startTime)?0:t.startTime,0),v=[],l,h,f;for(nt=!1,l=i.concat(r),h=0;h<l.length;h++)v[l[h].schemeIdUri]=l[h];while(u<n.length){if(c=String.fromCharCode(n[u+4],n[u+5],n[u+6],n[u+7]),a=n[u]*w+n[u+1]*p+n[u+2]*256+n[u+3]*1,c=="moov"||c=="moof")break;else if(c=="emsg"){nt=!0;for(var e=["","",0,0,0,0,""],s=0,o=u+12;o<a+u;)s===0||s==1||s==6?(n[o]!==0?e[s]+=String.fromCharCode(n[o]):s+=1,o+=1):(e[s]=n[o]*w+n[o+1]*p+n[o+2]*256+n[o+3]*1,o+=4,s+=1);var b=e[0],tt=e[1],k=e[2],d=e[3],it=e[4],rt=e[5],ut=e[6],ft=g*k+d;v[b]&&(f=new Dash.vo.Event,f.eventStream=v[b],f.eventStream.value=tt,f.eventStream.timescale=k,f.duration=it,f.id=rt,f.presentationTime=ft,f.messageData=ut,f.presentationTimeDelta=d,y.push(f))}u+=a}return y},dt=function(n){var i;if(!nt)return n;for(var o=n.length,t=0,r=0,f,u,s=Math.pow(256,2),h=Math.pow(256,3),e=new Uint8Array(n.length);t<o;){if(f=String.fromCharCode(n[t+4],n[t+5],n[t+6],n[t+7]),u=n[t]*h+n[t+1]*s+n[t+2]*256+n[t+3]*1,f!="emsg")for(i=t;i<t+u;i++)e[r]=n[i],r+=1;t+=u}return e.subarray(0,r)},gt=function(){var r=this.bufferExt.getLeastBufferLevel(),n=i*2,t=s-r;t>=n&&!c?(c=!0,this.notify(this.eventList.ENAME_BUFFER_LEVEL_OUTRUN)):t<n/2&&c&&(this.notify(this.eventList.ENAME_BUFFER_LEVEL_BALANCED),c=!1,l.call(this))},k=function(){var n=this,t=ht.call(n);return t<f},it=function(){var t=this,r=t.playbackController.getTime(),f,u,e,i;n&&(i=t.fragmentController.getExecutedRequestForTime(t.streamProcessor.getFragmentModel(),r),u=i&&!isNaN(i.startTime)?i.startTime:Math.floor(r),e=t.sourceBufferExt.getBufferRange(n,r),e===null&&n.buffered.length>0&&(u=n.buffered.end(n.buffered.length-1)),f=n.buffered.start(0),t.sourceBufferExt.remove(n,f,u,y))},d=function(t,r,u,f){n===r&&((tt.call(this),this.notify(this.eventList.ENAME_BUFFER_CLEARED,u,f,k.call(this)),k.call(this))||setTimeout(it.bind(this),i*1e3))},ht=function(){var f=this,i=f.sourceBufferExt.getAllRanges(n),r=0,u,t;if(!i)return r;for(t=0,u=i.length;t<u;t+=1)r+=i.end(t)-i.start(t);return r},ct=function(){var n=g===et-1;n&&!v&&(v=!0,this.notify(this.eventList.ENAME_BUFFERING_COMPLETED))},lt=function(){var n=this.playbackController.getTimeToPeriodEnd();s<i&&(i<n||i>=n&&!v)?rt.call(this,!1):rt.call(this,!0)},rt=function(n){p!==n&&(p=n,this.debug.log(p?"Got enough "+h+" buffer to start.":"Waiting for more "+h+" buffer before starting playback."),this.notify(this.eventList.ENAME_BUFFER_LEVEL_STATE_CHANGED,n))},at=function(t){n.timestampOffset!==t&&(n.timestampOffset=t)},ut=function(){var n=this;tt.call(n);l.call(n)},l=function(){w.call(this)?ft.call(this):ui.call(this)},ni=function(n,t){e=!1;isNaN(t)?ii.call(this,n):ri.call(this,t);l.call(this)},ti=function(n,t){e=!1;this.notify(this.eventList.ENAME_BYTES_REJECTED,n,t);l.call(this)},ii=function(n){u=n},ri=function(n){g=Math.max(n,g);ct.call(this)},ui=function(){var n;o.length===0||c||e||w.call(this)||!k.call(this)||(n=o.shift(),st.call(this,n.bytes,n.quality,n.index))},fi=function(n,t,r){var u=this,f;at.call(u,r.MSETimeOffset);f=u.bufferExt.decideBufferLength(u.manifestModel.getValue().minBufferTime,u.playbackController.getPeriodDuration(),u.streamProcessor.isDynamic());i!==f&&(u.setMinBufferTime(f),u.notify(u.eventList.ENAME_MIN_BUFFER_TIME_UPDATED,f))},ei=function(n,t,i){var r=this;t===r.streamProcessor.getFragmentModel()&&(et=i.index,ct.call(r))},oi=function(n,i,r,u){if(h===i){var f=this;t!==u&&(at.call(f,f.representationController.getRepresentationForQuality(u).MSETimeOffset),t=u,w.call(f))&&ft.call(f)}},ft=function(){var n=this;if(a[t]){if(e)return;st.call(n,a[t],t)}else n.notify(n.eventList.ENAME_INIT_REQUESTED,t)},si=function(){l.call(this)},hi=function(){lt.call(this)};return{manifestExt:undefined,manifestModel:undefined,bufferExt:undefined,sourceBufferExt:undefined,debug:undefined,system:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_CLOSED_CAPTIONING_REQUESTED:"closedCaptioningRequested",ENAME_BUFFER_LEVEL_STATE_CHANGED:"bufferLevelStateChanged",ENAME_BUFFER_LEVEL_UPDATED:"bufferLevelUpdated",ENAME_QUOTA_EXCEEDED:"quotaExceeded",ENAME_BYTES_APPENDED:"bytesAppended",ENAME_BYTES_REJECTED:"bytesRejected",ENAME_BUFFERING_COMPLETED:"bufferingCompleted",ENAME_BUFFER_CLEARED:"bufferCleared",ENAME_INIT_REQUESTED:"initRequested",ENAME_BUFFER_LEVEL_OUTRUN:"bufferLevelOutrun",ENAME_BUFFER_LEVEL_BALANCED:"bufferLevelBalanced",ENAME_MIN_BUFFER_TIME_UPDATED:"minBufferTimeUpdated"},setup:function(){this.dataUpdateCompleted=fi;this.initSegmentLoaded=wt;this.mediaSegmentLoaded=bt;this.streamCompleted=ei;this.qualityChanged=oi;this.playbackProgress=ut;this.playbackSeeking=ut;this.playbackTimeUpdated=ut;this.playbackRateChanged=hi;this.wallclockTimeUpdated=si;b=b.bind(this);d=d.bind(this);this.sourceBufferExt.subscribe(this.sourceBufferExt.eventList.ENAME_SOURCEBUFFER_APPEND_COMPLETED,this,b);this.sourceBufferExt.subscribe(this.sourceBufferExt.eventList.ENAME_SOURCEBUFFER_REMOVE_COMPLETED,this,d)},initialize:function(n,t,i,r){var u=this;h=n;u.setMediaSource(i);u.setBuffer(t);u.streamProcessor=r;u.fragmentController=r.fragmentController;u.scheduleController=r.scheduleController;u.representationController=r.representationController;u.playbackController=r.playbackController},getStreamProcessor:function(){return this.streamProcessor},setStreamProcessor:function(n){this.streamProcessor=n},getBuffer:function(){return n},setBuffer:function(t){n=t},getBufferLevel:function(){return s},getMinBufferTime:function(){return i},setMinBufferTime:function(n){i=n},setMediaSource:function(n){y=n},isBufferingCompleted:function(){return v},reset:function(i){var s=this;a=[];f=Number.POSITIVE_INFINITY;s.bufferExt.setCriticalBufferLevel(f);p=null;u=-1;t=0;s.sourceBufferExt.unsubscribe(s.sourceBufferExt.eventList.ENAME_SOURCEBUFFER_APPEND_COMPLETED,s,b);s.sourceBufferExt.unsubscribe(s.sourceBufferExt.eventList.ENAME_SOURCEBUFFER_REMOVE_COMPLETED,s,d);r=null;c=!1;e=!1;o=[];i||(s.sourceBufferExt.abort(y,n),s.sourceBufferExt.removeSourceBuffer(y,n));n=null}}};MediaPlayer.dependencies.BufferController.prototype={constructor:MediaPlayer.dependencies.BufferController};MediaPlayer.dependencies.BufferExtensions=function(){"use strict";var n=null,t=null,i=0,r=0,u=Number.POSITIVE_INFINITY,f=function(n){var t=this.metricsExt.getCurrentHttpRequest(n);return t!==null?(t.tresponse.getTime()-t.trequest.getTime())/1e3:0},e=function(){var n=this,t,u=n.abrController.getQualityFor("audio"),f=n.abrController.getConfidenceFor("audio"),e=n.abrController.getQualityFor("video"),o=n.abrController.getConfidenceFor("video");return t=u===i&&e===r,t||f===MediaPlayer.rules.SwitchRequest.prototype.STRONG&&o===MediaPlayer.rules.SwitchRequest.prototype.STRONG},o=function(n,t,u){t==="audio"?i=u:t==="video"&&(r=u)};return{system:undefined,manifestExt:undefined,metricsExt:undefined,metricsModel:undefined,abrController:undefined,bufferMax:undefined,setup:function(){this.topQualityIndexChanged=o},setCriticalBufferLevel:function(n){u=n},getTopQualityIndex:function(n){var t=null;return n==="audio"?t=i:n==="video"&&(t=r),t},decideBufferLength:function(t,i,r){return n=isNaN(i)||MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME<i&&t<i?Math.max(MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME,t):t>=i?Math.min(i,MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME):Math.min(i,t),r?n/2:n},getLeastBufferLevel:function(){var i=this.metricsModel.getReadOnlyMetricsFor("video"),n=this.metricsExt.getCurrentBufferLevel(i),r=this.metricsModel.getReadOnlyMetricsFor("audio"),t=this.metricsExt.getCurrentBufferLevel(r);return n===null||t===null?t!==null?t.level:n!==null?n.level:null:Math.min(t.level,n.level)},getRequiredBufferLength:function(i,r){var o=this,c=o.metricsModel.getReadOnlyMetricsFor("video"),l=o.metricsModel.getReadOnlyMetricsFor("audio"),a=r>=MediaPlayer.dependencies.BufferExtensions.LONG_FORM_CONTENT_DURATION_THRESHOLD,h=!1,s=0;return o.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_MIN?s=n:o.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_INFINITY?s=r:o.bufferMax===MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_REQUIRED&&(t=n,i||(h=e.call(o)),h&&(t=a?MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY_LONG_FORM:MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY),s=t+Math.max(f.call(o,c),f.call(o,l))),Math.min(s,u)},getBufferTarget:function(){return t===null?n:t},reset:function(){n=null;t=null;i=0;r=0;u=Number.POSITIVE_INFINITY}}};MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_REQUIRED="required";MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_MIN="min";MediaPlayer.dependencies.BufferExtensions.BUFFER_SIZE_INFINITY="infinity";MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_STARTUP=1;MediaPlayer.dependencies.BufferExtensions.DEFAULT_MIN_BUFFER_TIME=8;MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY=30;MediaPlayer.dependencies.BufferExtensions.BUFFER_TIME_AT_TOP_QUALITY_LONG_FORM=300;MediaPlayer.dependencies.BufferExtensions.LONG_FORM_CONTENT_DURATION_THRESHOLD=600;MediaPlayer.dependencies.BufferExtensions.prototype.constructor=MediaPlayer.dependencies.BufferExtensions;MediaPlayer.utils.Capabilities=function(){"use strict"};MediaPlayer.utils.Capabilities.prototype={constructor:MediaPlayer.utils.Capabilities,supportsMediaSource:function(){"use strict";var n="WebKitMediaSource"in window,t="MediaSource"in window;return n||t},supportsMediaKeys:function(){"use strict";var n="WebKitMediaKeys"in window,t="MSMediaKeys"in window,i="MediaKeys"in window;return n||t||i},supportsCodec:function(n,t){"use strict";if(!(n instanceof HTMLMediaElement))throw"element must be of type HTMLMediaElement.";var i=n.canPlayType(t);return i==="probably"}};MediaPlayer.utils.Debug=function(){"use strict";var n=!0;return{eventBus:undefined,setLogToBrowserConsole:function(t){n=t},getLogToBrowserConsole:function(){return n},log:function(t){n&&console.log(t);this.eventBus.dispatchEvent({type:"log",message:t})}}};MediaPlayer.dependencies.ErrorHandler=function(){"use strict";return{eventBus:undefined,capabilityError:function(n){this.eventBus.dispatchEvent({type:"error",error:"capability",event:n})},downloadError:function(n,t,i){this.eventBus.dispatchEvent({type:"error",error:"download",event:{id:n,url:t,request:i}})},manifestError:function(n,t,i){this.eventBus.dispatchEvent({type:"error",error:"manifestError",event:{message:n,id:t,manifest:i}})},closedCaptionsError:function(n,t,i){this.eventBus.dispatchEvent({type:"error",error:"cc",event:{message:n,id:t,cc:i}})},mediaSourceError:function(n){this.eventBus.dispatchEvent({type:"error",error:"mediasource",event:n})},mediaKeySessionError:function(n){this.eventBus.dispatchEvent({type:"error",error:"key_session",event:n})},mediaKeyMessageError:function(n){this.eventBus.dispatchEvent({type:"error",error:"key_message",event:n})},mediaKeySystemSelectionError:function(n){this.eventBus.dispatchEvent({type:"error",error:"key_system_selection",event:n})}}};MediaPlayer.dependencies.ErrorHandler.prototype={constructor:MediaPlayer.dependencies.ErrorHandler};MediaPlayer.utils.EventBus=function(){"use strict";var n,t=function(t,i){var r=(i?"1":"0")+t;return r in n||(n[r]=[]),n[r]},i=function(){n={}};return i(),{addEventListener:function(n,i,r){var u=t(n,r),f=u.indexOf(i);f===-1&&u.push(i)},removeEventListener:function(n,i,r){var u=t(n,r),f=u.indexOf(i);f!==-1&&u.splice(f,1)},dispatchEvent:function(n){for(var r=t(n.type,!1).slice(),i=0;i<r.length;i++)r[i].call(this,n);return!n.defaultPrevented}}};MediaPlayer.dependencies.EventController=function(){"use strict";var i=[],r=[],t=[],n=null,u=100,e=u/1e3,o="urn:mpeg:dash:event:2012",s=1,h=function(){n!==null&&(clearInterval(n),n=null);i=null;r=null;t=null},c=function(){n!==null&&(clearInterval(n),n=null)},l=function(){var t=this;t.debug.log("Start Event Controller");isNaN(u)||(n=setInterval(y.bind(this),u))},a=function(n){var t=this;i=[];n&&n.length>0&&(i=n);t.debug.log("Added "+n.length+" inline events")},v=function(n){for(var t,u=this,i=0;i<n.length;i++)t=n[i],r[t.id]=t,u.debug.log("Add inband event with id "+t.id)},y=function(){f.call(this,r);f.call(this,i);p.call(this)},f=function(n){var h=this,f=this.videoModel.getCurrentTime(),u,r,i;if(n)for(r=0;r<n.length;r++)i=n[r],i!==undefined&&(u=i.presentationTime/i.eventStream.timescale,(u===0||u<=f&&u+e>f)&&(h.debug.log("Start Event at "+f),i.duration>0&&t.push(i),i.eventStream.schemeIdUri==o&&i.eventStream.value==s&&w.call(this),n.splice(r,1)))},p=function(){var u=this,r,i,n;if(t)for(r=this.videoModel.getCurrentTime(),i=0;i<t.length;i++)n=t[i],n!==null&&(n.duration+n.presentationTime)/n.eventStream.timescale<r&&(u.debug.log("Remove Event at time "+r),n=null,t.splice(i,1))},w=function(){var n=this,t=n.manifestModel.getValue(),i=t.mpdUrl;t.hasOwnProperty("Location")&&(i=t.Location);n.debug.log("Refresh manifest @ "+i);n.manifestLoader.load(i)};return{manifestModel:undefined,manifestExt:undefined,manifestLoader:undefined,debug:undefined,system:undefined,errHandler:undefined,videoModel:undefined,addInlineEvents:a,addInbandEvents:v,reset:h,clear:c,start:l,getVideoModel:function(){return this.videoModel},setVideoModel:function(n){this.videoModel=n},initialize:function(n){this.setVideoModel(n)}}};MediaPlayer.dependencies.EventController.prototype={constructor:MediaPlayer.dependencies.EventController};MediaPlayer.dependencies.FragmentController=function(){"use strict";var n=[],r=!1,t=function(t){for(var r=n.length,i=0;i<r;i++)if(n[i].getContext()==t)return n[i];return null},u=function(t,i){var u=this,r=n[0].getContext().streamProcessor,e=r.getPeriodInfo().id,o=r.getType(),f=u.scheduleRulesCollection.getRules(MediaPlayer.rules.ScheduleRulesCollection.prototype.SEGMENTS_TO_EXECUTE_RULES);f.indexOf(this.scheduleRulesCollection.sameTimeRequestRule)!==-1&&this.scheduleRulesCollection.sameTimeRequestRule.setFragmentModels(n,e);u.rulesController.applyRules(f,o,r.getCurrentRepresentation(),i,t,function(n,t){return t})},f=function(n,t){var i=this;i.isInitializationRequest(t)?i.notify(i.eventList.ENAME_INIT_SEGMENT_LOADING_START,n,t):i.notify(i.eventList.ENAME_MEDIA_SEGMENT_LOADING_START,n,t)},e=function(n,t,r){var u=this,f=u.process(r);if(f===null){u.debug.log("No "+t.streamType+" bytes to push.");return}u.isInitializationRequest(t)?u.notify(u.eventList.ENAME_INIT_SEGMENT_LOADED,n,f,t.quality):u.notify(u.eventList.ENAME_MEDIA_SEGMENT_LOADED,n,f,t.quality,t.index);i.call(this)},o=function(n,t){this.notify(this.eventList.ENAME_STREAM_COMPLETED,n,t)},s=function(){i.call(this)},h=function(t){for(var o=t.value,s,i,u,e,f=0;f<o.length;f+=1)if(i=o[f],i)for(e=0;e<n.length;e+=1)(u=n[e],s=u.getContext().streamProcessor.getType(),i.streamType===s)&&(i instanceof MediaPlayer.vo.SegmentRequest||(i=u.getPendingRequestForTime(i.startTime)),u.executeRequest(i));r=!1},i=function(n){r||(r=!0,u.call(this,n,h.bind(this)))};return{system:undefined,debug:undefined,scheduleRulesCollection:undefined,rulesController:undefined,fragmentLoader:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_STREAM_COMPLETED:"streamCompleted",ENAME_INIT_SEGMENT_LOADING_START:"initSegmentLoadingStart",ENAME_MEDIA_SEGMENT_LOADING_START:"mediaSegmentLoadingStart",ENAME_INIT_SEGMENT_LOADED:"initSegmentLoaded",ENAME_MEDIA_SEGMENT_LOADED:"mediaSegmentLoaded"},setup:function(){this.fragmentLoadingStarted=f;this.fragmentLoadingCompleted=e;this.streamCompleted=o;this.bufferLevelBalanced=s},process:function(n){var t=null;return n!==null&&n!==undefined&&n.byteLength>0&&(t=new Uint8Array(n)),t},getModel:function(i){if(!i)return null;var r=t(i);return r||(r=this.system.getObject("fragmentModel"),r.setContext(i),n.push(r)),r},detachModel:function(t){var i=n.indexOf(t);i>-1&&n.splice(i,1)},isFragmentLoadedOrPending:function(n,i){var r=t(n);return r?r.isFragmentLoadedOrPending(i):!1},getPendingRequests:function(n){var i=t(n);return i?i.getPendingRequests():null},getLoadingRequests:function(n){var i=t(n);return i?i.getLoadingRequests():null},isInitializationRequest:function(n){return n&&n.type&&n.type.toLowerCase()==="initialization segment"},getLoadingTime:function(n){var i=t(n);return i?i.getLoadingTime():null},getExecutedRequestForTime:function(n,t){return n?n.getExecutedRequestForTime(t):null},removeExecutedRequest:function(n,t){n&&n.removeExecutedRequest(t)},removeExecutedRequestsBeforeTime:function(n,t){n&&n.removeExecutedRequestsBeforeTime(t)},cancelPendingRequestsForModel:function(n){n&&n.cancelPendingRequests()},abortRequestsForModel:function(n){n&&n.abortRequests();i.call(this)},prepareFragmentForLoading:function(n,r){var u=t(n);u&&r&&u.addRequest(r)&&i.call(this,r)},executePendingRequests:function(){i.call(this)},resetModel:function(n){this.abortRequestsForModel(n);this.cancelPendingRequestsForModel(n)}}};MediaPlayer.dependencies.FragmentController.prototype={constructor:MediaPlayer.dependencies.FragmentController};MediaPlayer.dependencies.FragmentLoader=function(){"use strict";var r=3,t=500,n=[],i=function(r,u){var f=new XMLHttpRequest,o=null,c=!0,h=!0,s=null,e=this;n.push(f);r.requestStartDate=new Date;o=e.metricsModel.addHttpRequest(r.streamType,null,r.type,r.url,null,r.range,r.requestStartDate,null,null,null,null,r.duration);e.metricsModel.appendHttpTrace(o,r.requestStartDate,r.requestStartDate.getTime()-r.requestStartDate.getTime(),[0]);s=r.requestStartDate;f.open("GET",e.tokenAuthentication.addTokenAsQueryArg(r.url),!0);f.responseType="arraybuffer";f=e.tokenAuthentication.setTokenInRequestHeader(f);r.range&&f.setRequestHeader("Range","bytes="+r.range);f.onprogress=function(n){var t=new Date;c&&(c=!1,(!n.lengthComputable||n.lengthComputable&&n.total!=n.loaded)&&(r.firstByteDate=t,o.tresponse=t));e.metricsModel.appendHttpTrace(o,t,t.getTime()-s.getTime(),[f.response?f.response.byteLength:0]);s=t};f.onload=function(){if(!(f.status<200)&&!(f.status>299)){h=!1;var n=new Date,t=f.response,i,u;r.firstByteDate||(r.firstByteDate=r.requestStartDate);r.requestEndDate=n;i=r.firstByteDate.getTime()-r.requestStartDate.getTime();u=r.requestEndDate.getTime()-r.firstByteDate.getTime();e.debug.log("loaded "+r.streamType+":"+r.type+":"+r.startTime+" ("+f.status+", "+i+"ms, "+u+"ms)");o.tresponse=r.firstByteDate;o.tfinish=r.requestEndDate;o.responsecode=f.status;e.metricsModel.appendHttpTrace(o,n,n.getTime()-s.getTime(),[t?t.byteLength:0]);s=n;e.notify(e.eventList.ENAME_LOADING_COMPLETED,r,t)}};f.onloadend=f.onerror=function(){if(n.indexOf(f)!==-1&&(n.splice(n.indexOf(f),1),h)){h=!1;var c=new Date,l=f.response,a,v;r.firstByteDate||(r.firstByteDate=r.requestStartDate);r.requestEndDate=c;a=r.firstByteDate.getTime()-r.requestStartDate.getTime();v=r.requestEndDate.getTime()-r.firstByteDate.getTime();e.debug.log("failed "+r.streamType+":"+r.type+":"+r.startTime+" ("+f.status+", "+a+"ms, "+v+"ms)");o.tresponse=r.firstByteDate;o.tfinish=r.requestEndDate;o.responsecode=f.status;e.metricsModel.appendHttpTrace(o,c,c.getTime()-s.getTime(),[l?l.byteLength:0]);s=c;u>0?(e.debug.log("Failed loading segment: "+r.streamType+":"+r.type+":"+r.startTime+", retry in "+t+"ms attempts: "+u),u--,setTimeout(function(){i.call(e,r,u)},t)):(e.debug.log("Failed loading segment: "+r.streamType+":"+r.type+":"+r.startTime+" no retry attempts left"),e.errHandler.downloadError("content",r.url,f),e.notify(e.eventList.ENAME_LOADING_COMPLETED,r,null,new Error("failed loading segment")))}};f.send()},u=function(n){var i=this,t=new XMLHttpRequest,r=!1;t.open("HEAD",n.url,!0);t.onload=function(){t.status<200||t.status>299||(r=!0,i.notify(i.eventList.ENAME_CHECK_FOR_EXISTENCE_COMPLETED,!0,n))};t.onloadend=t.onerror=function(){r||i.notify(i.eventList.ENAME_CHECK_FOR_EXISTENCE_COMPLETED,!1,n)};t.send()};return{metricsModel:undefined,errHandler:undefined,debug:undefined,tokenAuthentication:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_LOADING_COMPLETED:"loadingCompleted",ENAME_CHECK_FOR_EXISTENCE_COMPLETED:"checkForExistenceCompleted"},load:function(n){n?i.call(this,n,r):this.notify(this.eventList.ENAME_LOADING_COMPLETED,n,null,new Error("request is null"))},checkForExistence:function(n){if(!n){this.notify(this.eventList.ENAME_CHECK_FOR_EXISTENCE_COMPLETED,!1,n);return}u.call(this,n)},abort:function(){for(var i,r=n.length,t=0;t<r;t+=1)i=n[t],n[t]=null,i.abort(),i=null;n=[]}}};MediaPlayer.dependencies.FragmentLoader.prototype={constructor:MediaPlayer.dependencies.FragmentLoader};MediaPlayer.dependencies.FragmentModel=function(){"use strict";var e,n=[],i=[],t=[],o=[],u=!1,h=function(n){var t=this;t.notify(t.eventList.ENAME_FRAGMENT_LOADING_STARTED,n);t.fragmentLoader.load(n)},s=function(t){var i=n.indexOf(t);i!==-1&&n.splice(i,1)},f=function(n,t){for(var e=n.length-1,i=NaN,f=NaN,r=null,u=e;u>=0;u-=1)if(r=n[u],i=r.startTime,f=i+r.duration,!isNaN(i)&&!isNaN(f)&&t>=i&&t<f||isNaN(i)&&isNaN(t))return r;return null},r=function(n,t){if(n){var i=n.streamType,r=new Date,u=n.type,f=n.startTime,e=n.availabilityStartTime,o=n.duration,s=n.quality,h=n.range;this.metricsModel.addSchedulingInfo(i,r,u,f,e,o,s,h,t)}},c=function(i,u,f,e){t.splice(t.indexOf(u),1);f&&!e?(n.push(u),r.call(this,u,MediaPlayer.vo.metrics.SchedulingInfo.EXECUTED_STATE),this.notify(this.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,u,f)):(r.call(this,u,MediaPlayer.vo.metrics.SchedulingInfo.FAILED_STATE),this.notify(this.eventList.ENAME_FRAGMENT_LOADING_FAILED,u))},l=function(n,t,i){var u=this.getExecutedRequestForQualityAndIndex(t,i);u&&(this.removeExecutedRequest(u),isNaN(i)||(o.push(u),r.call(this,u,MediaPlayer.vo.metrics.SchedulingInfo.REJECTED_STATE)))},a=function(){u=!0},v=function(){u=!1};return{system:undefined,debug:undefined,metricsModel:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_STREAM_COMPLETED:"streamCompleted",ENAME_FRAGMENT_LOADING_STARTED:"fragmentLoadingStarted",ENAME_FRAGMENT_LOADING_COMPLETED:"fragmentLoadingCompleted",ENAME_FRAGMENT_LOADING_FAILED:"segmentLoadingFailed"},setup:function(){this.bufferLevelOutrun=a;this.bufferLevelBalanced=v;this.bytesRejected=l;this.loadingCompleted=c},setLoader:function(n){this.fragmentLoader=n},setContext:function(n){e=n},getContext:function(){return e},getIsPostponed:function(){return u},addRequest:function(n){return!n||this.isFragmentLoadedOrPending(n)?!1:(i.push(n),r.call(this,n,MediaPlayer.vo.metrics.SchedulingInfo.PENDING_STATE),!0)},isFragmentLoadedOrPending:function(r){var f=function(n,t){return n.action==="complete"&&n.action===t.action},e=function(n,t){return n.url===t.url&&n.startTime===t.startTime},o=function(n,t){return isNaN(n.index)&&isNaN(t.index)&&n.quality===t.quality},u=function(n){for(var t,u=!1,s=n.length,i=0;i<s;i+=1)if(t=n[i],e(r,t)||o(r,t)||f(r,t)){u=!0;break}return u};return u(i)||u(t)||u(n)},getPendingRequests:function(){return i},getLoadingRequests:function(){return t},getExecutedRequests:function(){return n},getRejectedRequests:function(){return o},getLoadingTime:function(){for(var r=0,t,i=n.length-1;i>=0;i-=1)if(t=n[i],t.requestEndDate instanceof Date&&t.firstByteDate instanceof Date){r=t.requestEndDate.getTime()-t.firstByteDate.getTime();break}return r},getExecutedRequestForTime:function(t){return f(n,t)},getPendingRequestForTime:function(n){return f(i,n)},getLoadingRequestForTime:function(n){return f(t,n)},getExecutedRequestForQualityAndIndex:function(t,i){for(var f=n.length-1,r=null,u=f;u>=0;u-=1)if(r=n[u],r.quality===t&&r.index===i)return r;return null},removeExecutedRequest:function(n){s.call(this,n)},removeExecutedRequestsBeforeTime:function(t){for(var f=n.length-1,r=NaN,u=null,i=f;i>=0;i-=1)u=n[i],r=u.startTime,!isNaN(r)&&r<t&&s.call(this,u)},cancelPendingRequests:function(){var n=this,t=i;i=[];t.forEach(function(t){r.call(n,t,MediaPlayer.vo.metrics.SchedulingInfo.CANCELED_STATE)})},abortRequests:function(){this.fragmentLoader.abort();for(var n=0,i=t.length;n<i;n+=1)this.removeExecutedRequest(t[n]);t=[]},executeRequest:function(u){var f=this,e=i.indexOf(u);if(u&&e!==-1){i.splice(e,1);switch(u.action){case"complete":n.push(u);r.call(f,u,MediaPlayer.vo.metrics.SchedulingInfo.EXECUTED_STATE);f.notify(f.eventList.ENAME_STREAM_COMPLETED,u);break;case"download":t.push(u);r.call(f,u,MediaPlayer.vo.metrics.SchedulingInfo.LOADING_STATE);h.call(f,u);break;default:this.debug.log("Unknown request action.")}}}}};MediaPlayer.dependencies.FragmentModel.prototype={constructor:MediaPlayer.dependencies.FragmentModel};MediaPlayer.dependencies.LiveEdgeFinder=function(){"use strict";var t=!1,n,i=function(n){var t=n.value;t!==null?this.notify(this.eventList.ENAME_LIVE_EDGE_FOUND,t):this.notify(this.eventList.ENAME_LIVE_EDGE_SEARCH_ERROR)},r=function(){if(this.streamProcessor.isDynamic()&&!t){var r=this,u=this.streamProcessor.getType();n=r.scheduleRulesCollection.getRules(MediaPlayer.rules.ScheduleRulesCollection.prototype.LIVE_EDGE_RULES);t=!0;this.rulesController.applyRules(n,u,this.streamProcessor.getCurrentRepresentation(),i.bind(r),null,function(n,t){return t})}};return{system:undefined,scheduleRulesCollection:undefined,rulesController:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_LIVE_EDGE_FOUND:"liveEdgeFound",ENAME_LIVE_EDGE_SEARCH_ERROR:"liveEdgeSearchError"},setup:function(){this.streamUpdated=r},initialize:function(n){this.streamProcessor=n;this.indexHandler=n.indexHandler;this.fragmentLoader=n.fragmentLoader;this.scheduleRulesCollection.liveEdgeBinarySearchRule&&this.scheduleRulesCollection.liveEdgeBinarySearchRule.setFinder(this)},abortSearch:function(){if(t=!1,n)for(var i=0,r=n.length;i<r;i+=1)n[i].reset()}}};MediaPlayer.dependencies.LiveEdgeFinder.prototype={constructor:MediaPlayer.dependencies.LiveEdgeFinder};MediaPlayer.dependencies.ManifestLoader=function(){"use strict";var i=3,n=500,r=function(n){var t=null;return n.indexOf("/")!==-1&&(n.indexOf("?")!==-1&&(n=n.substring(0,n.indexOf("?"))),t=n.substring(0,n.lastIndexOf("/")+1)),t},t=function(i,u){var v=r(i),e=new XMLHttpRequest,h=new Date,s=null,c=!0,o,a=null,l=null,f=this;a=function(){e.status<200||e.status>299||(c=!1,s=new Date,f.tokenAuthentication.checkRequestHeaderForToken(e),f.metricsModel.addHttpRequest("stream",null,"MPD",i,null,null,h,s,e.status,null,null),o=f.parser.parse(e.responseText,v),o?(o.mpdUrl=i,o.mpdLoadedTime=s,f.metricsModel.addManifestUpdate("stream",o.type,h,s,o.availabilityStartTime),f.notify(f.eventList.ENAME_MANIFEST_LOADED,o)):f.notify(f.eventList.ENAME_MANIFEST_LOADED,null,new Error("Failed loading manifest: "+i)))};l=function(){c&&(c=!1,f.metricsModel.addHttpRequest("stream",null,"MPD",i,null,null,h,new Date,e.status,null,null),u>0?(f.debug.log("Failed loading manifest: "+i+", retry in "+n+"ms attempts: "+u),u--,setTimeout(function(){t.call(f,i,u)},n)):(f.debug.log("Failed loading manifest: "+i+" no retry attempts left"),f.errHandler.downloadError("manifest",i,e),f.notify(f.eventList.ENAME_MANIFEST_LOADED,null,new Error("Failed loading manifest: "+i+" no retry attempts left"))))};try{e.onload=a;e.onloadend=l;e.onerror=l;e.open("GET",i,!0);e.send()}catch(y){e.onerror()}};return{debug:undefined,parser:undefined,errHandler:undefined,metricsModel:undefined,tokenAuthentication:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_MANIFEST_LOADED:"manifestLoaded"},load:function(n){t.call(this,n,i)}}};MediaPlayer.dependencies.ManifestLoader.prototype={constructor:MediaPlayer.dependencies.ManifestLoader};MediaPlayer.models.ManifestModel=function(){"use strict";var n;return{system:undefined,eventBus:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_MANIFEST_UPDATED:"manifestUpdated"},getValue:function(){return n},setValue:function(t){n=t;this.eventBus.dispatchEvent({type:"manifestLoaded",data:t});this.notify(this.eventList.ENAME_MANIFEST_UPDATED,t)}}};MediaPlayer.models.ManifestModel.prototype={constructor:MediaPlayer.models.ManifestModel};MediaPlayer.dependencies.ManifestUpdater=function(){"use strict";var n=NaN,t=null,i=!1,r=!1,f=function(){t!==null&&(clearInterval(t),t=null)},e=function(){f.call(this);isNaN(n)||(this.debug.log("Refresh manifest in "+n+" seconds."),t=setTimeout(o.bind(this),Math.min(n*1e3,Math.pow(2,31)-1),this))},u=function(){var i=this,t=i.manifestModel.getValue(),r,u;t!==undefined&&t!==null&&(r=i.manifestExt.getRefreshDelay(t),u=((new Date).getTime()-t.mpdLoadedTime.getTime())/1e3,n=Math.max(r-u,0),e.call(i))},o=function(){var i=this,n,t;r||(r=!0,n=i.manifestModel.getValue(),t=n.mpdUrl,n.hasOwnProperty("Location")&&(t=n.Location),i.manifestLoader.load(t))},s=function(n,t,r){r||(this.manifestModel.setValue(t),this.debug.log("Manifest has been refreshed."),i)||u.call(this)},h=function(){this.start()},c=function(){this.stop()},l=function(){r=!1};return{debug:undefined,system:undefined,manifestModel:undefined,manifestExt:undefined,manifestLoader:undefined,setup:function(){u.call(this);this.streamsComposed=l;this.manifestLoaded=s;this.playbackStarted=h;this.playbackPaused=c},start:function(){i=!1;u.call(this)},stop:function(){i=!0;f.call(this)}}};MediaPlayer.dependencies.ManifestUpdater.prototype={constructor:MediaPlayer.dependencies.ManifestUpdater};MediaPlayer.dependencies.MediaSourceExtensions=function(){"use strict"};MediaPlayer.dependencies.MediaSourceExtensions.prototype={constructor:MediaPlayer.dependencies.MediaSourceExtensions,createMediaSource:function(){"use strict";var n="WebKitMediaSource"in window,t="MediaSource"in window;return t?new MediaSource:n?new WebKitMediaSource:null},attachMediaSource:function(n,t){"use strict";t.setSource(window.URL.createObjectURL(n))},detachMediaSource:function(n){"use strict";n.setSource("")},setDuration:function(n,t){"use strict";return n.duration=t,n.duration},signalEndOfStream:function(n){"use strict";n.readyState==="open"&&n.endOfStream()}};MediaPlayer.models.MetricsModel=function(){"use strict";return{system:undefined,eventBus:undefined,streamMetrics:{},metricsChanged:function(){this.eventBus.dispatchEvent({type:"metricsChanged",data:{}})},metricChanged:function(n){this.eventBus.dispatchEvent({type:"metricChanged",data:{stream:n}});this.metricsChanged()},metricUpdated:function(n,t,i){this.eventBus.dispatchEvent({type:"metricUpdated",data:{stream:n,metric:t,value:i}});this.metricChanged(n)},metricAdded:function(n,t,i){this.eventBus.dispatchEvent({type:"metricAdded",data:{stream:n,metric:t,value:i}});this.metricChanged(n)},clearCurrentMetricsForType:function(n){delete this.streamMetrics[n];this.metricChanged(n)},clearAllCurrentMetrics:function(){var n=this;this.streamMetrics={};this.metricsChanged.call(n)},getReadOnlyMetricsFor:function(n){return this.streamMetrics.hasOwnProperty(n)?this.streamMetrics[n]:null},getMetricsFor:function(n){var t;return this.streamMetrics.hasOwnProperty(n)?t=this.streamMetrics[n]:(t=this.system.getObject("metrics"),this.streamMetrics[n]=t),t},addTcpConnection:function(n,t,i,r,u,f){var e=new MediaPlayer.vo.metrics.TCPConnection;return e.tcpid=t,e.dest=i,e.topen=r,e.tclose=u,e.tconnect=f,this.getMetricsFor(n).TcpList.push(e),this.metricAdded(n,"TcpConnection",e),e},addHttpRequest:function(n,t,i,r,u,f,e,o,s,h,c,l){var a=new MediaPlayer.vo.metrics.HTTPRequest;return a.stream=n,a.tcpid=t,a.type=i,a.url=r,a.actualurl=u,a.range=f,a.trequest=e,a.tresponse=o,a.tfinish=s,a.responsecode=h,a.interval=c,a.mediaduration=l,this.getMetricsFor(n).HttpList.push(a),this.metricAdded(n,"HttpRequest",a),a},appendHttpTrace:function(n,t,i,r){var u=new MediaPlayer.vo.metrics.HTTPRequest.Trace;return u.s=t,u.d=i,u.b=r,n.trace.push(u),this.metricUpdated(n.stream,"HttpRequestTrace",n),u},addRepresentationSwitch:function(n,t,i,r,u){var f=new MediaPlayer.vo.metrics.RepresentationSwitch;return f.t=t,f.mt=i,f.to=r,f.lto=u,this.getMetricsFor(n).RepSwitchList.push(f),this.metricAdded(n,"RepresentationSwitch",f),f},addBufferLevel:function(n,t,i){var r=new MediaPlayer.vo.metrics.BufferLevel;return r.t=t,r.level=i,this.getMetricsFor(n).BufferLevel.push(r),this.metricAdded(n,"BufferLevel",r),r},addDVRInfo:function(n,t,i,r){var u=new MediaPlayer.vo.metrics.DVRInfo;return u.time=t,u.range=r,u.mpd=i,this.getMetricsFor(n).DVRInfo.push(u),this.metricAdded(n,"DVRInfo",u),u},addDroppedFrames:function(n,t){var i=new MediaPlayer.vo.metrics.DroppedFrames,r=this.getMetricsFor(n).DroppedFrames;return(i.time=t.creationTime,i.droppedFrames=t.droppedVideoFrames,r.length>0&&r[r.length-1]==i)?r[r.length-1]:(r.push(i),this.metricAdded(n,"DroppedFrames",i),i)},addSchedulingInfo:function(n,t,i,r,u,f,e,o,s){var h=new MediaPlayer.vo.metrics.SchedulingInfo;return h.streamType=n,h.t=t,h.type=i,h.startTime=r,h.availabilityStartTime=u,h.duration=f,h.quality=e,h.range=o,h.state=s,this.getMetricsFor(n).SchedulingInfo.push(h),this.metricAdded(n,"SchedulingInfo",h),h},addManifestUpdate:function(n,t,i,r,u,f,e,o,s,h){var c=new MediaPlayer.vo.metrics.ManifestUpdate,l=this.getMetricsFor("stream");return c.streamType=n,c.type=t,c.requestTime=i,c.fetchTime=r,c.availabilityStartTime=u,c.presentationStartTime=f,c.clientTimeOffset=e,c.currentTime=o,c.buffered=s,c.latency=h,l.ManifestUpdate.push(c),this.metricAdded(n,"ManifestUpdate",c),c},updateManifestUpdateInfo:function(n,t){for(var i in t)n[i]=t[i];this.metricUpdated(n.streamType,"ManifestUpdate",n)},addManifestUpdatePeriodInfo:function(n,t,i,r,u){var f=new MediaPlayer.vo.metrics.ManifestUpdate.PeriodInfo;return f.id=t,f.index=i,f.start=r,f.duration=u,n.periodInfo.push(f),this.metricUpdated(n.streamType,"ManifestUpdatePeriodInfo",n),f},addManifestUpdateRepresentationInfo:function(n,t,i,r,u,f,e,o){var s=new MediaPlayer.vo.metrics.ManifestUpdate.RepresentationInfo;return s.id=t,s.index=i,s.periodIndex=r,s.streamType=u,s.startNumber=e,s.segmentInfoType=o,s.presentationTimeOffset=f,n.representationInfo.push(s),this.metricUpdated(n.streamType,"ManifestUpdateRepresentationInfo",n),s},addPlayList:function(n,t,i,r){var u=new MediaPlayer.vo.metrics.PlayList;return u.stream=n,u.start=t,u.mstart=i,u.starttype=r,this.getMetricsFor(n).PlayList.push(u),this.metricAdded(n,"PlayList",u),u},appendPlayListTrace:function(n,t,i,r,u,f,e,o){var s=new MediaPlayer.vo.metrics.PlayList.Trace;return s.representationid=t,s.subreplevel=i,s.start=r,s.mstart=u,s.duration=f,s.playbackspeed=e,s.stopreason=o,n.trace.push(s),this.metricUpdated(n.stream,"PlayListTrace",n),s}}};MediaPlayer.models.MetricsModel.prototype={constructor:MediaPlayer.models.MetricsModel};MediaPlayer.dependencies.Notifier=function(){"use strict";var n,i=0,t=function(){return this.id||(i+=1,this.id="_id_"+i),this.id},r=function(n){var t,i=this.eventList;for(t in i)if(i[t]===n)return!0;return!1};return{system:undefined,setup:function(){n=this.system;n.mapValue("notify",this.notify);n.mapValue("subscribe",this.subscribe);n.mapValue("unsubscribe",this.unsubscribe)},notify:function(){var i=[].slice.call(arguments);i.splice(1,0,this);i[0]+=t.call(this);n.notify.apply(n,i)},subscribe:function(i,u,f,e){if(!f&&u[i]&&(f=u[i]=u[i].bind(u)),!r.call(this,i))throw"object does not support given event "+i;if(!u)throw"observer object cannot be null or undefined";if(!f)throw"event handler cannot be null or undefined";i+=t.call(this);n.mapHandler(i,undefined,f,e)},unsubscribe:function(i,r,u){u=u||r[i];i+=t.call(this);n.unmapHandler(i,undefined,u)}}};MediaPlayer.dependencies.Notifier.prototype={constructor:MediaPlayer.dependencies.Notifier};MediaPlayer.dependencies.PlaybackController=function(){"use strict";var d=1e3,v=0,i,t,n,y,r,g=function(){var n=this,t=function(){it.call(n)};i!==null&&p.call(this);i=setInterval(t,d)},p=function(){clearInterval(i);i=null},w=function(){var n=this.timelineConverter.calcPresentationStartTime(t);this.debug.log("Starting playback at offset: "+n);this.seek(n)},b=function(){if(!this.isPaused()){var t=this.getTime(),n=this.timelineConverter.calcActualPresentationTime(y,t,r),i=!isNaN(n)&&n!==t;i&&this.seek(n)}},nt=function(n,i,u){y=u;t=y.adaptation.period;r=n.streamProcessor.isDynamic();b.call(this)},tt=function(){n.getElement().readyState!==0&&w.call(this)},k=function(){n&&(n.unlisten("play",u),n.unlisten("pause",f),n.unlisten("error",a),n.unlisten("seeking",e),n.unlisten("seeked",o),n.unlisten("timeupdate",s),n.unlisten("progress",h),n.unlisten("ratechange",c),n.unlisten("loadedmetadata",l))},u=function(){b.call(this);this.notify(this.eventList.ENAME_PLAYBACK_STARTED,this.getTime())},f=function(){this.notify(this.eventList.ENAME_PLAYBACK_PAUSED)},e=function(){this.notify(this.eventList.ENAME_PLAYBACK_SEEKING,this.getTime(),!1)},o=function(){this.notify(this.eventList.ENAME_PLAYBACK_SEEKED)},s=function(){var n=this.getTime();n!==v&&(v=n,this.notify(this.eventList.ENAME_PLAYBACK_TIME_UPDATED,this.getTimeToPeriodEnd()))},h=function(){var i=n.getElement().buffered,r,u,f;i.length&&(r=i.length-1,u=i.end(r),f=this.timelineConverter.calcPresentationStartTime(t)+t.duration-u);this.notify(this.eventList.ENAME_PLAYBACK_PROGRESS,n.getElement().buffered,f)},c=function(){this.notify(this.eventList.ENAME_PLAYBACK_RATE_CHANGED)},l=function(){this.debug.log("Got loadmetadata event.");(!r||t.mpd.isClientServerTimeSyncCompleted)&&w.call(this);this.notify(this.eventList.ENAME_PLAYBACK_METADATA_LOADED);g.call(this)},a=function(n){this.notify(this.eventList.ENAME_PLAYBACK_ERROR,n.srcElement.error)},it=function(){this.notify(this.eventList.ENAME_WALLCLOCK_TIME_UPDATED,r,new Date)},rt=function(t){n=t;n.listen("play",u);n.listen("pause",f);n.listen("error",a);n.listen("seeking",e);n.listen("seeked",o);n.listen("timeupdate",s);n.listen("progress",h);n.listen("ratechange",c);n.listen("loadedmetadata",l)};return{debug:undefined,timelineConverter:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_PLAYBACK_STARTED:"playbackStarted",ENAME_PLAYBACK_STOPPED:"playbackStopped",ENAME_PLAYBACK_PAUSED:"playbackPaused",ENAME_PLAYBACK_SEEKING:"playbackSeeking",ENAME_PLAYBACK_SEEKED:"playbackSeeked",ENAME_PLAYBACK_TIME_UPDATED:"playbackTimeUpdated",ENAME_PLAYBACK_PROGRESS:"playbackProgress",ENAME_PLAYBACK_RATE_CHANGED:"playbackRateChanged",ENAME_PLAYBACK_METADATA_LOADED:"playbackMetaDataLoaded",ENAME_PLAYBACK_ERROR:"playbackError",ENAME_WALLCLOCK_TIME_UPDATED:"wallclockTimeUpdated"},setup:function(){this.dataUpdateCompleted=nt;this.liveEdgeFound=tt;u=u.bind(this);f=f.bind(this);a=a.bind(this);e=e.bind(this);o=o.bind(this);s=s.bind(this);h=h.bind(this);c=c.bind(this);l=l.bind(this)},initialize:function(i,r){(t=i,n!==r)&&(k.call(this),rt.call(this,r))},getTimeToPeriodEnd:function(){var i=n.getCurrentTime();return this.timelineConverter.calcPresentationStartTime(t)+t.duration-i},getPeriodId:function(){return t.id},getPeriodDuration:function(){return t.duration},getTime:function(){return n.getCurrentTime()},getPlaybackRate:function(){return n.getPlaybackRate()},start:function(){n.play()},isPaused:function(){return n.isPaused()},pause:function(){n&&n.pause()},isSeeking:function(){return n.getElement().seeking},seek:function(t){t!==this.getTime()&&(n.setCurrentTime(t),this.notify(this.eventList.ENAME_PLAYBACK_SEEKING,t,!0))},reset:function(){p.call(this);k.call(this);n=null;t=null;v=0}}};MediaPlayer.dependencies.PlaybackController.prototype={constructor:MediaPlayer.dependencies.PlaybackController};MediaPlayer.dependencies.ProtectionController=function(){"use strict";var t=null,n=null,i=function(n){var t=this;t.protectionModel.removeKeySystem(n)},r=function(t,i){for(var u,f,e=this,r=0;r<n.length;++r)for(u=0;u<i.length;++u)if(n[r].isSupported(i[u])&&e.protectionExt.supportsCodec(n[r].keysTypeString,t))return f=e.manifestExt.getKID(i[u]),f||(f="unknown"),e.protectionModel.addKeySystem(f,i[u],n[r]),e.debug.log("DRM: Selected Key System: "+n[r].keysTypeString+" For KID: "+f),f;throw new Error("DRM: The protection system for this content is not supported.");},u=function(n,t,i){var u=this,f=null,r=null;u.protectionModel.needToAddKeySession(n)&&(r=u.protectionModel.getInitData(n),r||!i?!r||u.debug.log("DRM: Using initdata from prheader in mpd. length: "+r.length):(r=i,u.debug.log("DRM: Using initdata from needskey event. length: "+r.length)),r?(f=u.protectionModel.addKeySession(n,t,r),u.debug.log("DRM: Added Key Session ["+f.sessionId+"] for KID: "+n+" type: "+t+" initData length: "+r.length)):u.debug.log("DRM: initdata is null."))},f=function(n,t,i,r){this.protectionModel.updateFromMessage(n,t,i,r)};return{system:undefined,debug:undefined,manifestExt:undefined,capabilities:undefined,protectionModel:undefined,protectionExt:undefined,setup:function(){n=this.protectionExt.getKeySystems()},init:function(n,i){this.videoModel=n;this.protectionModel=i;t=this.videoModel.getElement()},selectKeySystem:r,ensureKeySession:u,updateFromMessage:f,teardownKeySystem:i}};MediaPlayer.dependencies.ProtectionController.prototype={constructor:MediaPlayer.dependencies.ProtectionController};MediaPlayer.dependencies.ProtectionExtensions=function(){"use strict"};MediaPlayer.dependencies.ProtectionExtensions.prototype={constructor:MediaPlayer.dependencies.ProtectionExtensions,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_KEY_SYSTEM_UPDATE_COMPLETED:"keySystemUpdateCompleted"},supportsCodec:function(n,t){"use strict";var i="WebKitMediaKeys"in window,r="MSMediaKeys"in window,u="MediaKeys"in window;return u?MediaKeys.isTypeSupported(n,t):i?WebKitMediaKeys.isTypeSupported(n,t):r?MSMediaKeys.isTypeSupported(n,t):!1},createMediaKeys:function(n){"use strict";var t="WebKitMediaKeys"in window,i="MSMediaKeys"in window,r="MediaKeys"in window;return r?new MediaKeys(n):t?new WebKitMediaKeys(n):i?new MSMediaKeys(n):null},setMediaKey:function(n,t){var i="WebKitSetMediaKeys"in n,r="msSetMediaKeys"in n,u="SetMediaKeys"in n;if(u)return n.SetMediaKeys(t);if(i)return n.WebKitSetMediaKeys(t);if(r)return n.msSetMediaKeys(t);this.debug.log("no setmediakeys function in element")},createSession:function(n,t,i){return n.createSession(t,i)},getKeySystems:function(){var n=this,t=function(t,i){var c=null,o=[],l=new DOMParser,f=l.parseFromString(t,"application/xml"),s,e,h,u,r;for(f.getElementsByTagName("Challenge")[0]?(s=f.getElementsByTagName("Challenge")[0].childNodes[0].nodeValue,s&&(c=BASE64.decode(s))):n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,null,new Error("DRM: playready update, can not find Challenge in keyMessage")),e=f.getElementsByTagName("name"),h=f.getElementsByTagName("value"),e.length!=h.length&&n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,null,new Error("DRM: playready update, invalid header name/value pair in keyMessage")),u=0;u<e.length;u++)o[u]={name:e[u].childNodes[0].nodeValue,value:h[u].childNodes[0].nodeValue};r=new XMLHttpRequest;r.onload=function(){r.status==200?n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,new Uint8Array(r.response)):n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,null,new Error('DRM: playready update, XHR status is "'+r.statusText+'" ('+r.status+"), expected to be 200. readyState is "+r.readyState))};r.onabort=function(){n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,null,new Error('DRM: playready update, XHR aborted. status is "'+r.statusText+'" ('+r.status+"), readyState is "+r.readyState))};r.onerror=function(){n.notify(n.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,null,new Error('DRM: playready update, XHR error. status is "'+r.statusText+'" ('+r.status+"), readyState is "+r.readyState))};r.open("POST",i);r.responseType="arraybuffer";o&&o.forEach(function(n){r.setRequestHeader(n.name,n.value)});r.send(c)},i=function(n,t){return n===null&&t.length===0},r=function(n){var t=0,r=0,f=0,e=new Uint8Array([112,115,115,104,0,0,0,0]),o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]),u=null,s=null,i=null,h=null;if("pro"in n)u=BASE64.decodeArray(n.pro.__text);else if("prheader"in n)u=BASE64.decodeArray(n.prheader.__text);else return null;return r=u.length,f=4+e.length+o.length+4+r,s=new ArrayBuffer(f),i=new Uint8Array(s),h=new DataView(s),h.setUint32(t,f),t+=4,i.set(e,t),t+=e.length,i.set(o,t),t+=o.length,h.setUint32(t,r),t+=4,i.set(u,t),t+=r,i};return[{schemeIdUri:"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95",keysTypeString:"com.microsoft.playready",isSupported:function(n){return this.schemeIdUri===n.schemeIdUri.toLowerCase()},needToAddKeySession:i,getInitData:r,getUpdate:t},{schemeIdUri:"urn:mpeg:dash:mp4protection:2011",keysTypeString:"com.microsoft.playready",isSupported:function(n){return this.schemeIdUri===n.schemeIdUri.toLowerCase()&&n.value.toLowerCase()==="cenc"},needToAddKeySession:i,getInitData:function(){return null},getUpdate:t},{schemeIdUri:"urn:uuid:00000000-0000-0000-0000-000000000000",keysTypeString:"webkit-org.w3.clearkey",isSupported:function(n){return this.schemeIdUri===n.schemeIdUri.toLowerCase()},needToAddKeySession:function(){return!0},getInitData:function(){return null},getUpdate:function(n){return n}}]},addKey:function(n,t,i,r,u){n.webkitAddKey(t,i,r,u)},generateKeyRequest:function(n,t,i){n.webkitGenerateKeyRequest(t,i)},listenToNeedKey:function(n,t){n.listen("webkitneedkey",t);n.listen("msneedkey",t);n.listen("needKey",t)},listenToKeyError:function(n,t){n.addEventListener("webkitkeyerror",t,!1);n.addEventListener("mskeyerror",t,!1);n.addEventListener("keyerror",t,!1)},listenToKeyMessage:function(n,t){n.addEventListener("webkitkeymessage",t,!1);n.addEventListener("mskeymessage",t,!1);n.addEventListener("keymessage",t,!1)},listenToKeyAdded:function(n,t){n.addEventListener("webkitkeyadded",t,!1);n.addEventListener("mskeyadded",t,!1);n.addEventListener("keyadded",t,!1)},unlistenToKeyError:function(n,t){n.removeEventListener("webkitkeyerror",t);n.removeEventListener("mskeyerror",t);n.removeEventListener("keyerror",t)},unlistenToKeyMessage:function(n,t){n.removeEventListener("webkitkeymessage",t);n.removeEventListener("mskeymessage",t);n.removeEventListener("keymessage",t)},unlistenToKeyAdded:function(n,t){n.removeEventListener("webkitkeyadded",t);n.removeEventListener("mskeyadded",t);n.removeEventListener("keyadded",t)}};MediaPlayer.models.ProtectionModel=function(){"use strict";var u=null,t=null,i=null,r=null,f,n=[],e=function(n,t,i){i||f.update(t)};return{system:undefined,protectionExt:undefined,setup:function(){this.keySystemUpdateCompleted=e},init:function(n){this.videoModel=n;u=this.videoModel.getElement()},addKeySession:function(u,f,e){var o=null;return o=this.protectionExt.createSession(n[u].keys,f,e),this.protectionExt.listenToKeyAdded(o,t),this.protectionExt.listenToKeyError(o,i),this.protectionExt.listenToKeyMessage(o,r),n[u].initData=e,n[u].keySessions.push(o),o},addKeySystem:function(t,i,r){var f=null;f=this.protectionExt.createMediaKeys(r.keysTypeString);this.protectionExt.setMediaKey(u,f);n[t]={kID:t,contentProtection:i,keySystem:r,keys:f,initData:null,keySessions:[]}},removeKeySystem:function(u){var e,f;if(u!==null&&n[u]!==undefined&&n[u].keySessions.length!==0){for(e=n[u].keySessions,f=0;f<e.length;++f)this.protectionExt.unlistenToKeyError(e[f],i),this.protectionExt.unlistenToKeyAdded(e[f],t),this.protectionExt.unlistenToKeyMessage(e[f],r),e[f].close();n[u]=undefined}},needToAddKeySession:function(t){var i=null;return i=n[t],i.keySystem.needToAddKeySession(i.initData,i.keySessions)},getInitData:function(t){var i=null;return i=n[t],i.keySystem.getInitData(i.contentProtection)},updateFromMessage:function(t,i,r,u){f=i;n[t].keySystem.getUpdate(r,u)},listenToNeedKey:function(n){this.protectionExt.listenToNeedKey(this.videoModel,n)},listenToKeyError:function(t){var r,f,u;for(i=t,r=0;r<n.length;++r)for(f=n[r].keySessions,u=0;u<f.length;++u)this.protectionExt.listenToKeyError(f[u],t)},listenToKeyMessage:function(t){var i,f,u;for(r=t,i=0;i<n.length;++i)for(f=n[i].keySessions,u=0;u<f.length;++u)this.protectionExt.listenToKeyMessage(f[u],t)},listenToKeyAdded:function(i){var r,f,u;for(t=i,r=0;r<n.length;++r)for(f=n[r].keySessions,u=0;u<f.length;++u)this.protectionExt.listenToKeyAdded(f[u],i)}}};MediaPlayer.models.ProtectionModel.prototype={constructor:MediaPlayer.models.ProtectionModel};MediaPlayer.dependencies.ScheduleController=function(){"use strict";var u=0,t,o,i,s,n,h=!0,p=null,c=!1,l=null,a=null,v=!0,r=function(n,t){var i=0,r=null;v===!1&&(r=a.start,i=n.getTime()-r.getTime(),a.duration=i,a.stopreason=t,v=!0)},f=function(){if(o){c=!1;var n=new Date;r(n,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON);l=this.metricsModel.addPlayList(t,n,0,MediaPlayer.vo.metrics.PlayList.INITIAL_PLAY_START_REASON);h&&(h=!1);this.debug.log("ScheduleController "+t+" start.");y.call(this)}},b=function(){h&&w.call(this,n.index);f.call(this)},e=function(n){c||(c=!0,this.debug.log("ScheduleController "+t+" stop."),n&&this.fragmentController.cancelPendingRequestsForModel(i),r(new Date,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON))},g=function(i){var r=this,u=r.scheduleRulesCollection.getRules(MediaPlayer.rules.ScheduleRulesCollection.prototype.NEXT_SEGMENT_RULES);r.rulesController.applyRules(u,t,n,i,null,function(n,t){return t})},w=function(n){var t=this,i;return i=t.indexHandler.getInitRequest(t.representationController.getRepresentationForQuality(n)),i!==null&&t.fragmentController.prepareFragmentForLoading(t,i),i},nt=function(i){var r=this,f=r.scheduleRulesCollection.getRules(MediaPlayer.rules.ScheduleRulesCollection.prototype.SEGMENTS_TO_SCHEDULE_RULES);r.rulesController.applyRules(f,t,n,i,u,function(n,t){return Math.min(n,t)})},tt=function(i){var r=this;if(u=i.value,u<=0){r.fragmentController.executePendingRequests();return}r.abrController.getPlaybackQuality(t,n,r.streamProcessor.getData());g.call(r,it.bind(r))},it=function(t){var i=t.value;i===null||i instanceof MediaPlayer.vo.SegmentRequest||(i=this.indexHandler.getSegmentRequestForTime(n,i.startTime));i&&(u--,this.fragmentController.prepareFragmentForLoading(this,i))},y=function(){var n=(new Date).getTime(),t=p?n-p>this.fragmentController.getLoadingTime(this):!0;!t||c||this.playbackController.isPaused()&&(!this.scheduleWhilePaused||s)||(p=n,nt.call(this,tt.bind(this)))},rt=function(){var n=this;t!==null&&t!==""&&n.metricsModel.clearCurrentMetricsForType(t)},ut=function(t,i,r){var u=this,f;f=u.indexHandler.getCurrentTime(n||r);n=r;k.call(u);s||(o=!0);o&&b.call(u,f)},ft=function(n,i){i===this.streamProcessor.getFragmentModel()&&(this.debug.log(t+" Stream is complete."),r(new Date,MediaPlayer.vo.metrics.PlayList.Trace.END_OF_CONTENT_STOP_REASON))},et=function(n,t){var i=this;t===i.streamProcessor.getFragmentModel()&&y.call(i)},ot=function(){e.call(this)},st=function(){d.call(this)},ht=function(){e.call(this,!1)},ct=function(n,t){w.call(this,t)},lt=function(n,t,r,u){this.fragmentController.removeExecutedRequestsBeforeTime(i,r);u&&f.call(this)},at=function(n,i){var u=this;i||u.playbackController.isSeeking()||(u.debug.log("Stalling "+t+" Buffer: "+t),r(new Date,MediaPlayer.vo.metrics.PlayList.Trace.REBUFFERING_REASON))},vt=function(i,r){var u=this,f=u.timelineConverter.calcSegmentAvailabilityRange(n,s);u.metricsModel.addBufferLevel(t,new Date,r);u.metricsModel.addDVRInfo(t,u.playbackController.getTime(),n.adaptation.period.mpd,f);y.call(this)},yt=function(){e.call(this,!1)},pt=function(i,u,f,e){if(t===u){var o=this;if(n=o.representationController.getRepresentationForQuality(e),n===null||n===undefined)throw"Unexpected error!";r(new Date,MediaPlayer.vo.metrics.PlayList.Trace.REPRESENTATION_SWITCH_STOP_REASON);k.call(o)}},k=function(){var i=new Date,r=this.playbackController.getTime();this.metricsModel.addRepresentationSwitch(t,i,r,n.id)},d=function(){var t=this,i=t.playbackController.getTime(),r=t.playbackController.getPlaybackRate(),u=new Date;v===!0&&n&&l&&(v=!1,a=t.metricsModel.appendPlayListTrace(l,n.id,null,u,i,null,r,null))},wt=function(n,t){var r=this,u=w.call(r,t);i.executeRequest(u)},bt=function(){f.call(this)},kt=function(u,e){h||this.fragmentController.cancelPendingRequestsForModel(i);var o,s=this.metricsModel.getMetricsFor("stream"),c=this.metricsExt.getCurrentManifestUpdate(s);this.debug.log("ScheduleController "+t+" seek: "+e);o=new Date;r(o,MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON);l=this.metricsModel.addPlayList(t,o,e,MediaPlayer.vo.metrics.PlayList.SEEK_START_REASON);f.call(this);this.metricsModel.updateManifestUpdateInfo(c,{latency:n.segmentAvailabilityRange.end-this.playbackController.getTime()})},dt=function(){d.call(this)},gt=function(){y.call(this)},ni=function(t,i){var r=this,s=Math.max(i-r.bufferController.getMinBufferTime()*2,n.segmentAvailabilityRange.start),f,h=r.metricsModel.getMetricsFor("stream"),c=r.metricsExt.getCurrentManifestUpdate(h),u,e;f=r.indexHandler.getSegmentRequestForTime(n,s);e=f.startTime;u=e+f.duration/2;n.adaptation.period.liveEdge=u;r.metricsModel.updateManifestUpdateInfo(c,{currentTime:u,presentationStartTime:i,latency:i-u,clientTimeOffset:n.adaptation.period.mpd.clientServerTimeShift});o=!0;b.call(r)};return{debug:undefined,system:undefined,metricsModel:undefined,metricsExt:undefined,bufferExt:undefined,scheduleWhilePaused:undefined,timelineConverter:undefined,sourceBufferExt:undefined,abrController:undefined,scheduleRulesCollection:undefined,rulesController:undefined,eventList:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,setup:function(){this.liveEdgeFound=ni;this.qualityChanged=pt;this.dataUpdateStarted=ht;this.dataUpdateCompleted=ut;this.mediaSegmentLoadingStart=et;this.segmentLoadingFailed=ot;this.streamCompleted=ft;this.bufferCleared=lt;this.bytesAppended=st;this.bufferLevelStateChanged=at;this.bufferLevelUpdated=vt;this.initRequested=ct;this.quotaExceeded=yt;this.closedCaptioningRequested=wt;this.playbackStarted=bt;this.playbackSeeking=kt;this.playbackRateChanged=dt;this.wallclockTimeUpdated=gt},initialize:function(n,r){var u=this;t=n;u.streamProcessor=r;u.playbackController=r.playbackController;u.fragmentController=r.fragmentController;u.representationController=r.representationController;u.liveEdgeFinder=r.liveEdgeFinder;u.bufferController=r.bufferController;u.indexHandler=r.indexHandler;s=r.isDynamic();i=this.fragmentController.getModel(this);u.scheduleRulesCollection.bufferLevelRule&&u.scheduleRulesCollection.bufferLevelRule.setScheduleController(u);u.scheduleRulesCollection.pendingRequestsRule&&u.scheduleRulesCollection.pendingRequestsRule.setScheduleController(u);u.scheduleRulesCollection.playbackTimeRule&&u.scheduleRulesCollection.playbackTimeRule.setScheduleController(u)},getFragmentModel:function(){return i},reset:function(){var n=this;e.call(n,!0);n.bufferController.unsubscribe(n.bufferController.eventList.ENAME_BUFFER_LEVEL_OUTRUN,n.scheduleRulesCollection.bufferLevelRule);n.bufferController.unsubscribe(n.bufferController.eventList.ENAME_BUFFER_LEVEL_BALANCED,n.scheduleRulesCollection.bufferLevelRule);n.fragmentController.abortRequestsForModel(i);n.fragmentController.detachModel(i);rt.call(n);u=0},start:f,stop:e}};MediaPlayer.dependencies.ScheduleController.prototype={constructor:MediaPlayer.dependencies.ScheduleController};MediaPlayer.dependencies.SourceBufferExtensions=function(){"use strict";this.system=undefined;this.manifestExt=undefined;this.errHandler=undefined;this.notify=undefined;this.subscribe=undefined;this.unsubscribe=undefined;this.eventList={ENAME_SOURCEBUFFER_REMOVE_COMPLETED:"sourceBufferRemoveCompleted",ENAME_SOURCEBUFFER_APPEND_COMPLETED:"sourceBufferAppendCompleted"}};MediaPlayer.dependencies.SourceBufferExtensions.prototype={constructor:MediaPlayer.dependencies.SourceBufferExtensions,createSourceBuffer:function(n,t){"use strict";var r=this,i=null;try{i=n.addSourceBuffer(t)}catch(u){if(r.manifestExt.getIsTextTrack(t))i=r.system.getObject("textSourceBuffer");else throw u;}return i},removeSourceBuffer:function(n,t){"use strict";try{n.removeSourceBuffer(t)}catch(i){}},getBufferRange:function(n,t,i){"use strict";var u=null,r=0,f=0,e=null,o=null,h=0,c=i||.15,l,s;try{u=n.buffered}catch(a){return null}if(u!==null){for(s=0,l=u.length;s<l;s+=1)if(r=u.start(s),f=u.end(s),e===null)h=Math.abs(r-t),t>=r&&t<f?(e=r,o=f):h<=c&&(e=r,o=f);else if(h=r-o,h<=c)o=f;else break;if(e!==null)return{start:e,end:o}}return null},getAllRanges:function(n){try{return n.buffered}catch(t){return null}},getBufferLength:function(n,t,i){"use strict";var u=this,r;return r=u.getBufferRange(n,t,i),r===null?0:r.end-t},waitForUpdateEnd:function(n,t){"use strict";var i,r=50,u=function(){n.updating||(clearInterval(i),t(!0))},f=function(){n.updating||(n.removeEventListener("updateend",f,!1),t(!0))};if(!n.updating){t(!0);return}if(typeof n.addEventListener=="function")try{n.addEventListener("updateend",f,!1)}catch(e){i=setInterval(u,r)}else i=setInterval(u,r)},append:function(n,t){var i=this,r="append"in n?"append":"appendBuffer"in n?"appendBuffer":null;if(r)try{i.waitForUpdateEnd(n,function(){n[r](t);i.waitForUpdateEnd(n,function(){i.notify(i.eventList.ENAME_SOURCEBUFFER_APPEND_COMPLETED,n,t)})})}catch(u){i.notify(i.eventList.ENAME_SOURCEBUFFER_APPEND_COMPLETED,n,t,u)}},remove:function(n,t,i,r){var u=this;try{t>=0&&i>t&&r.readyState!=="ended"&&n.remove(t,i);this.waitForUpdateEnd(n,function(){u.notify(u.eventList.ENAME_SOURCEBUFFER_REMOVE_COMPLETED,n,t,i)})}catch(f){u.notify(u.eventList.ENAME_SOURCEBUFFER_REMOVE_COMPLETED,n,t,i,f)}},abort:function(n,t){"use strict";try{n.readyState==="open"&&t.abort()}catch(i){}}};MediaPlayer.dependencies.Stream=function(){"use strict";var i,u,h={},o=null,t=[],c=!0,e=!1,l=!1,y=!1,f=null,p=[],a=!0,n=null,w,b,k,d,r=null,g=function(){e&&this.playbackController.start()},s=function(){this.playbackController.pause()},it=function(n){e&&(this.debug.log("Do seek: "+n),this.playbackController.seek(n))},rt=function(n){var t=this,r=h.video,i;if(i=n.type!=="msneedkey"?n.type:r,p.push({type:i,initData:n.initData}),this.debug.log("DRM: Key required for - "+i),!!o&&!!r&&!f)try{f=t.protectionController.selectKeySystem(r,o)}catch(u){s.call(t);t.debug.log(u);t.errHandler.mediaKeySystemSelectionError(u)}!f||t.protectionController.ensureKeySession(f,i,n.initData)},ut=function(n){var e=this,t=null,i=null,r=null,u=null;this.debug.log("DRM: Got a key message...");t=n.target;i=new Uint16Array(n.message.buffer);r=String.fromCharCode.apply(null,i);u=n.destinationURL;e.protectionController.updateFromMessage(f,t,r,u)},ft=function(){this.debug.log("DRM: Key added.")},et=function(){var t=event.target,n="DRM: MediaKeyError - sessionId: "+t.sessionId+" errorCode: "+t.error.code+" systemErrorCode: "+t.error.systemCode+" [";switch(t.error.code){case 1:n+="MEDIA_KEYERR_UNKNOWN - An unspecified error occurred. This value is used for errors that don't match any of the other codes.";break;case 2:n+="MEDIA_KEYERR_CLIENT - The Key System could not be installed or updated.";break;case 3:n+="MEDIA_KEYERR_SERVICE - The message passed into update indicated an error from the license service.";break;case 4:n+="MEDIA_KEYERR_OUTPUT - There is no available output device with the required characteristics for the content protection system.";break;case 5:n+="MEDIA_KEYERR_HARDWARECHANGE - A hardware configuration change caused a content protection error.";break;case 6:n+="MEDIA_KEYERR_DOMAIN - An error occurred in a multi-device domain licensing configuration. The most common error is a failure to join the domain."}n+="]";this.debug.log(n);this.errHandler.mediaKeySessionError(n)},ot=function(n,t){var i=this,r=function(u){i.debug.log("MediaSource is open!");i.debug.log(u);n.removeEventListener("sourceopen",r);n.removeEventListener("webkitsourceopen",r);t(n)};n.addEventListener("sourceopen",r,!1);n.addEventListener("webkitsourceopen",r,!1);i.mediaSourceExt.attachMediaSource(n,i.videoModel)},st=function(){var c=this,l=t.length,n=0,s;for(n;n<l;n+=1)s=t[n],s.reset(y),s=null;!r||r.reset();t=[];!u||c.mediaSourceExt.detachMediaSource(c.videoModel);e=!1;f=null;p=[];o=null;h={};u=null;i=null},v=function(i,f,e){var s=this,l,c,k=function(n){return s.manifestExt.getCodec(n)},y,a,p,w,v,b;if(i==="text"&&(k=function(n){return l=s.manifestExt.getMimeType(n)}),a=s.manifestExt.getDataForType(f,e,i),a!==null){if(p=k.call(s,a),v=null,p===l)try{v=s.sourceBufferExt.createSourceBuffer(u,l)}catch(d){s.errHandler.mediaSourceError("Error creating "+i+" source buffer.")}else if(c=p,s.debug.log(i+" codec: "+c),h[i]=c,w=s.manifestExt.getContentProtectionData(a),!w||s.capabilities.supportsMediaKeys())if(o=w,s.capabilities.supportsCodec(s.videoModel.getElement(),c))try{v=s.sourceBufferExt.createSourceBuffer(u,c)}catch(d){s.errHandler.mediaSourceError("Error creating "+i+" source buffer.")}else b=i+"Codec ("+c+") is not supported.",s.errHandler.manifestError(b,"codec",f),s.debug.log(b);else s.errHandler.capabilityError("mediakeys");v===null?s.debug.log("No buffer was created, skipping "+i+" data."):(y=s.system.getObject("streamProcessor"),t.push(y),y.initialize(l||i,v,s.videoModel,s.fragmentController,s.playbackController,u,a,n,s,r))}else s.debug.log("No "+i+" data.")},ht=function(){var u=this,e,f;r=u.system.getObject("eventController");r.initialize(u.videoModel);e=u.manifestExt.getEventsForPeriod(i,n);r.addInlineEvents(e);v.call(u,"video",i,n.index);v.call(u,"audio",i,n.index);v.call(u,"text",i,n.index);t.length===0?(f="No streams to play.",this.errHandler.manifestError(f,"nostreams",i),this.debug.log(f)):(u.liveEdgeFinder.initialize(t[0]),u.liveEdgeFinder.subscribe(u.liveEdgeFinder.eventList.ENAME_LIVE_EDGE_FOUND,u.playbackController))},ct=function(){var t=this,i,r;i=t.manifestExt.getDuration(t.manifestModel.getValue(),n);r=t.mediaSourceExt.setDuration(u,i);t.debug.log("Duration successfully set to: "+r);e=!0;tt.call(t)},lt=function(){this.debug.log("element loaded!");l=!0;nt.call(this)},nt=function(){e&&l&&n.index===0&&(r.start(),c&&g.call(this))},tt=function(){var i=this,r=t.length,n=0;if(e){for(n;n<r;n+=1)if(t[n].isUpdating())return;a=!1;i.notify(i.eventList.ENAME_STREAM_UPDATED)}},at=function(n,t){var r=t.code,i="";if(r!==-1){switch(r){case 1:i="MEDIA_ERR_ABORTED";break;case 2:i="MEDIA_ERR_NETWORK";break;case 3:i="MEDIA_ERR_DECODE";break;case 4:i="MEDIA_ERR_SRC_NOT_SUPPORTED";break;case 5:i="MEDIA_ERR_ENCRYPTED"}y=!0;this.debug.log("Video Element Error: "+i);this.debug.log(t);this.errHandler.mediaSourceError(i);this.reset()}},vt=function(n){var t=this,f=function(n){u=n;ht.call(t);ct.call(t);nt.call(t)},r;i=n;r=t.mediaSourceExt.createMediaSource();ot.call(t,r,f)},yt=function(){var t=bt(),i=t.length,n=0;for(n;n<i;n+=1)if(!t[n].isBufferingCompleted())return;u&&this.mediaSourceExt.signalEndOfStream(u)},pt=function(){tt.call(this)},wt=function(n,t,i){i&&(s.call(this),this.debug.log(i),this.errHandler.mediaKeyMessageError(i))},bt=function(){var u=[],n=0,f=t.length,i,r;for(n;n<f;n+=1)r=t[n],i=r.getType(),(i==="audio"||i==="video")&&u.push(r);return u},kt=function(u){var f=this,v=t.length,e=0,h,o,c,l,s;for(a=!0,i=f.manifestModel.getValue(),n=u,f.debug.log("Manifest updated... set new data on buffers."),r&&(l=f.manifestExt.getEventsForPeriod(i,n),r.addInlineEvents(l)),e;e<v;e+=1)s=t[e],o=s.getData(),h=s.getDataIndex(),c=!!o&&o.hasOwnProperty("id")?f.manifestExt.getDataForId(o.id,i,n.index):f.manifestExt.getDataForIndex(h,i,n.index),s.updateData(c,n)};return{system:undefined,manifestModel:undefined,mediaSourceExt:undefined,sourceBufferExt:undefined,manifestExt:undefined,fragmentController:undefined,playbackController:undefined,protectionModel:undefined,protectionController:undefined,protectionExt:undefined,capabilities:undefined,debug:undefined,errHandler:undefined,timelineConverter:undefined,liveEdgeFinder:undefined,abrController:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_STREAM_UPDATED:"streamUpdated"},setup:function(){this.bufferingCompleted=yt;this.dataUpdateCompleted=pt;this.playbackError=at;this.playbackMetaDataLoaded=lt;this.keySystemUpdateCompleted=wt},load:function(n){vt.call(this,n)},setVideoModel:function(n){this.videoModel=n},initProtection:function(){w=rt.bind(this);b=ut.bind(this);k=ft.bind(this);d=et.bind(this);this.protectionModel=this.system.getObject("protectionModel");this.protectionModel.init(this.getVideoModel());this.protectionController=this.system.getObject("protectionController");this.protectionController.init(this.videoModel,this.protectionModel);this.protectionModel.listenToNeedKey(w);this.protectionModel.listenToKeyMessage(b);this.protectionModel.listenToKeyError(d);this.protectionModel.listenToKeyAdded(k);this.protectionExt.subscribe(this.protectionExt.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,this.protectionModel);this.protectionExt.subscribe(this.protectionExt.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,this)},getVideoModel:function(){return this.videoModel},getManifestExt:function(){var n=this;return n.manifestExt},setAutoPlay:function(n){c=n},getAutoPlay:function(){return c},reset:function(){s.call(this);st.call(this);!this.protectionController||this.protectionController.teardownKeySystem(f);this.protectionModel&&this.protectionExt.unsubscribe(this.protectionExt.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,this.protectionModel);this.protectionExt.unsubscribe(this.protectionExt.eventList.ENAME_KEY_SYSTEM_UPDATE_COMPLETED,this);this.protectionController=undefined;this.protectionModel=undefined;this.fragmentController=undefined;this.playbackController.unsubscribe(this.playbackController.eventList.ENAME_PLAYBACK_ERROR,this);this.playbackController.unsubscribe(this.playbackController.eventList.ENAME_PLAYBACK_METADATA_LOADED,this);this.playbackController.reset();this.liveEdgeFinder.abortSearch();this.liveEdgeFinder.unsubscribe(this.liveEdgeFinder.eventList.ENAME_LIVE_EDGE_FOUND,this.playbackController);l=!1},getDuration:function(){return n.duration},getStartTime:function(){return n.start},getPeriodIndex:function(){return n.index},getId:function(){return n.id},setPeriodInfo:function(t){n=t},getPeriodInfo:function(){return n},startEventController:function(){r.start()},resetEventController:function(){r.reset()},setPlaybackController:function(t){this.playbackController=t;t.initialize(n,this.videoModel)},getPlaybackController:function(){return this.playbackController},isUpdating:function(){return a},updateData:kt,play:g,seek:it,pause:s}};MediaPlayer.dependencies.Stream.prototype={constructor:MediaPlayer.dependencies.Stream};MediaPlayer.dependencies.StreamController=function(){"use strict";var t=[],n,c=6,l=.2,r=!0,i=!1,e=function(){n.play()},a=function(){n.pause()},u=function(t){n.seek(t)},v=function(n,t){var i=n.getVideoModel().getElement(),r=t.getVideoModel().getElement();r.parentNode||i.parentNode.insertBefore(r,i);i.style.width="0px";r.style.width="100%";y(i,r);s.call(this,n);o.call(this,t)},o=function(n){var t=n.getPlaybackController();t.subscribe(t.eventList.ENAME_PLAYBACK_STARTED,this.manifestUpdater);t.subscribe(t.eventList.ENAME_PLAYBACK_PAUSED,this.manifestUpdater);t.subscribe(t.eventList.ENAME_PLAYBACK_SEEKING,this);t.subscribe(t.eventList.ENAME_PLAYBACK_TIME_UPDATED,this);t.subscribe(t.eventList.ENAME_PLAYBACK_PROGRESS,this)},s=function(n){var i=this,t=n.getPlaybackController();setTimeout(function(){t.unsubscribe(t.eventList.ENAME_PLAYBACK_STARTED,i.manifestUpdater);t.unsubscribe(t.eventList.ENAME_PLAYBACK_PAUSED,i.manifestUpdater);t.unsubscribe(t.eventList.ENAME_PLAYBACK_SEEKING,i);t.unsubscribe(t.eventList.ENAME_PLAYBACK_TIME_UPDATED,i);t.unsubscribe(t.eventList.ENAME_PLAYBACK_PROGRESS,i)},1)},y=function(n,t){["controls","loop","muted","volume"].forEach(function(i){t[i]=n[i]})},p=function(n,t,i){!i||i>=c||k()},w=function(t,i){var r=this;(r.metricsModel.addDroppedFrames("video",r.videoExt.getPlaybackQuality(n.getVideoModel().getElement())),f())&&(n.getVideoModel().getElement().seeking||i<l&&h.call(this,n,f()))},b=function(t,i){var r=d(i);r&&r!==n&&h.call(this,n,r,i)},k=function(){var n=f();n&&n.seek(n.getStartTime())},f=function(){var i=n.getPeriodIndex()+1;return i<t.length?t[i]:null},d=function(n){var r=0,u=null,f=t.length,i;for(f>0&&(r+=t[0].getStartTime()),i=0;i<f;i++)if(u=t[i],r+=u.getDuration(),n<r)return u;return null},g=function(){var n=this.system.getObject("videoModel"),t=document.createElement("video");return n.setElement(t),n},nt=function(n){n.parentNode&&n.parentNode.removeChild(n)},h=function(t,r,f){!i&&t&&r&&t!==r&&(i=!0,t.pause(),n=r,v.call(this,t,r),f?u(t.getPlaybackController().getTime()):u(r.getStartTime()),e(),t.resetEventController(),n.startEventController(),i=!1)},tt=function(){var i=this,a=i.manifestModel.getValue(),b=i.metricsModel.getMetricsFor("stream"),y=i.metricsExt.getCurrentManifestUpdate(b),e,v,p,w,s,h,f,c,l,u;if(a){l=i.manifestExt.getMpd(a);n&&(v=n.getPeriodInfo(),l.isClientServerTimeSyncCompleted=v.mpd.isClientServerTimeSyncCompleted,l.clientServerTimeShift=v.mpd.clientServerTimeShift);c=i.manifestExt.getRegularPeriods(a,l);try{if(c.length===0)throw new Error("There are no regular periods");for(i.metricsModel.updateManifestUpdateInfo(y,{currentTime:i.videoModel.getCurrentTime(),buffered:i.videoModel.getElement().buffered,presentationStartTime:c[0].start,clientTimeOffset:l.clientServerTimeShift}),s=0,p=c.length;s<p;s+=1){for(f=c[s],h=0,w=t.length;h<w;h+=1)t[h].getId()===f.id&&(u=t[h],u.updateData(f));u||(u=i.system.getObject("stream"),e=i.system.getObject("playbackController"),u.setPeriodInfo(f),u.setVideoModel(s===0?i.videoModel:g.call(i)),u.setPlaybackController(e),e.subscribe(e.eventList.ENAME_PLAYBACK_ERROR,u),e.subscribe(e.eventList.ENAME_PLAYBACK_METADATA_LOADED,u),u.initProtection(),u.setAutoPlay(r),u.load(a),u.subscribe(u.eventList.ENAME_STREAM_UPDATED,i),t.push(u));i.metricsModel.addManifestUpdatePeriodInfo(y,f.id,f.index,f.start,f.duration);u=null}n||(n=t[0],o.call(i,n),n.subscribe(n.eventList.ENAME_STREAM_UPDATED,this.liveEdgeFinder))}catch(k){i.errHandler.manifestError(k.message,"nostreamscomposed",i.manifestModel.getValue());i.reset()}}},it=function(){var i=this,r=t.length,n=0;for(n;n<r;n+=1)if(t[n].isUpdating())return;i.notify(i.eventList.ENAME_STREAMS_COMPOSED)},rt=function(n,t,i){i?this.reset():(this.manifestModel.setValue(t),this.debug.log("Manifest has loaded."),tt.call(this))};return{system:undefined,videoModel:undefined,manifestLoader:undefined,manifestUpdater:undefined,manifestModel:undefined,manifestExt:undefined,debug:undefined,metricsModel:undefined,metricsExt:undefined,videoExt:undefined,liveEdgeFinder:undefined,timelineConverter:undefined,errHandler:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_STREAMS_COMPOSED:"streamsComposed"},setup:function(){this.manifestLoaded=rt;this.streamUpdated=it;this.playbackSeeking=b;this.playbackProgress=p;this.playbackTimeUpdated=w},getManifestExt:function(){return n.getManifestExt()},setAutoPlay:function(n){r=n},getAutoPlay:function(){return r},getVideoModel:function(){return this.videoModel},setVideoModel:function(n){this.videoModel=n},load:function(n){this.manifestLoader.load(n)},reset:function(){var u,f,r;for(!n||s.call(this,n),u=0,f=t.length;u<f;u++)r=t[u],r.unsubscribe(r.eventList.ENAME_STREAM_UPDATED,this),r.reset(),r!==n&&nt(r.getVideoModel().getElement());t=[];this.manifestUpdater.stop();this.metricsModel.clearAllCurrentMetrics();this.manifestModel.setValue(null);this.timelineConverter.reset();i=!1;n=null},play:e,seek:u,pause:a}};MediaPlayer.dependencies.StreamController.prototype={constructor:MediaPlayer.dependencies.StreamController};MediaPlayer.dependencies.StreamProcessor=function(){"use strict";var i,t,n,r,u=function(n){var t=this,i=n==="video"||n==="audio"?"bufferController":"textController";return t.system.getObject(i)};return{system:undefined,manifestModel:undefined,manifestExt:undefined,indexHandler:undefined,liveEdgeFinder:undefined,eventList:undefined,timelineConverter:undefined,abrController:undefined,baseURLExt:undefined,initialize:function(f,e,o,s,h,c,l,a,v,y){var k=this,ut=k.manifestModel.getValue(),b=k.system.getObject("representationController"),w=k.system.getObject("scheduleController"),nt=k.liveEdgeFinder,g=k.abrController,tt=k.indexHandler,it=k.baseURLExt,d,rt=this.system.getObject("fragmentLoader"),p=u.call(k,f);t=v;n=f;r=y;i=k.manifestExt.getIsDynamic(ut);tt.setType(n);tt.setIsDynamic(i);k.bufferController=p;k.playbackController=h;k.scheduleController=w;k.representationController=b;k.videoModel=o;k.fragmentController=s;k.fragmentLoader=rt;b.subscribe(b.eventList.ENAME_DATA_UPDATE_COMPLETED,p);s.subscribe(s.eventList.ENAME_INIT_SEGMENT_LOADED,p);p.subscribe(p.eventList.ENAME_CLOSED_CAPTIONING_REQUESTED,w);(n==="video"||n==="audio")&&(g.subscribe(g.eventList.ENAME_QUALITY_CHANGED,p),g.subscribe(g.eventList.ENAME_QUALITY_CHANGED,b),g.subscribe(g.eventList.ENAME_QUALITY_CHANGED,w),nt.subscribe(nt.eventList.ENAME_LIVE_EDGE_FOUND,k.timelineConverter),nt.subscribe(nt.eventList.ENAME_LIVE_EDGE_FOUND,w),nt.subscribe(nt.eventList.ENAME_LIVE_EDGE_FOUND,b),b.subscribe(b.eventList.ENAME_DATA_UPDATE_STARTED,w),b.subscribe(b.eventList.ENAME_DATA_UPDATE_COMPLETED,w),b.subscribe(b.eventList.ENAME_DATA_UPDATE_COMPLETED,g),b.subscribe(b.eventList.ENAME_DATA_UPDATE_COMPLETED,t),b.subscribe(b.eventList.ENAME_DATA_UPDATE_COMPLETED,h),s.subscribe(s.eventList.ENAME_MEDIA_SEGMENT_LOADED,p),s.subscribe(s.eventList.ENAME_MEDIA_SEGMENT_LOADING_START,w),s.subscribe(s.eventList.ENAME_STREAM_COMPLETED,w),s.subscribe(s.eventList.ENAME_STREAM_COMPLETED,p),s.subscribe(s.eventList.ENAME_STREAM_COMPLETED,w.scheduleRulesCollection.bufferLevelRule),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_STATE_CHANGED,o),p.subscribe(p.eventList.ENAME_BUFFER_CLEARED,w),p.subscribe(p.eventList.ENAME_BYTES_APPENDED,w),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_UPDATED,w),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_STATE_CHANGED,w),p.subscribe(p.eventList.ENAME_INIT_REQUESTED,w),p.subscribe(p.eventList.ENAME_BUFFERING_COMPLETED,t),p.subscribe(p.eventList.ENAME_QUOTA_EXCEEDED,w),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_OUTRUN,w.scheduleRulesCollection.bufferLevelRule),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_BALANCED,w.scheduleRulesCollection.bufferLevelRule),h.subscribe(h.eventList.ENAME_PLAYBACK_PROGRESS,p),h.subscribe(h.eventList.ENAME_PLAYBACK_TIME_UPDATED,p),h.subscribe(h.eventList.ENAME_PLAYBACK_RATE_CHANGED,p),h.subscribe(h.eventList.ENAME_PLAYBACK_RATE_CHANGED,w),h.subscribe(h.eventList.ENAME_PLAYBACK_SEEKING,p),h.subscribe(h.eventList.ENAME_PLAYBACK_SEEKING,w),h.subscribe(h.eventList.ENAME_PLAYBACK_STARTED,w),h.subscribe(h.eventList.ENAME_PLAYBACK_SEEKING,w.scheduleRulesCollection.playbackTimeRule),i&&h.subscribe(h.eventList.ENAME_WALLCLOCK_TIME_UPDATED,b),h.subscribe(h.eventList.ENAME_WALLCLOCK_TIME_UPDATED,p),h.subscribe(h.eventList.ENAME_WALLCLOCK_TIME_UPDATED,w),tt.subscribe(tt.eventList.ENAME_REPRESENTATION_UPDATED,b),it.subscribe(it.eventList.ENAME_INITIALIZATION_LOADED,tt),it.subscribe(it.eventList.ENAME_SEGMENTS_LOADED,tt));p.initialize(n,e,c,k);w.initialize(n,this);d=this.getFragmentModel();d.setLoader(rt);d.subscribe(d.eventList.ENAME_FRAGMENT_LOADING_STARTED,s);d.subscribe(d.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,s);d.subscribe(d.eventList.ENAME_STREAM_COMPLETED,s);d.subscribe(d.eventList.ENAME_FRAGMENT_LOADING_FAILED,w);rt.subscribe(rt.eventList.ENAME_LOADING_COMPLETED,d);(n==="video"||n==="audio")&&(p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_OUTRUN,d),p.subscribe(p.eventList.ENAME_BUFFER_LEVEL_BALANCED,d),p.subscribe(p.eventList.ENAME_BYTES_REJECTED,d));b.initialize(this);b.updateData(l,a,n)},getData:function(){return this.representationController.getData()},getDataIndex:function(){return this.representationController.getDataIndex()},isUpdating:function(){return this.representationController.isUpdating()},getType:function(){return n},getFragmentModel:function(){return this.scheduleController.getFragmentModel()},getPeriodInfo:function(){return t.getPeriodInfo()},getEventController:function(){return r},updateData:function(t,i){return this.representationController.updateData(t,i,n)},start:function(){this.scheduleController.start()},stop:function(){this.scheduleController.stop()},getCurrentRepresentation:function(){return this.representationController.getCurrentRepresentation()},isBufferingCompleted:function(){return this.bufferController.isBufferingCompleted()},isDynamic:function(){return i},reset:function(n){var s=this,i=s.bufferController,f=s.representationController,u=s.scheduleController,c=s.liveEdgeFinder,e=s.fragmentController,h=s.abrController,r=s.playbackController,l=this.indexHandler,a=this.baseURLExt,o=this.getFragmentModel(),v=this.fragmentLoader,y=s.videoModel;h.unsubscribe(h.eventList.ENAME_QUALITY_CHANGED,i);h.unsubscribe(h.eventList.ENAME_QUALITY_CHANGED,f);h.unsubscribe(h.eventList.ENAME_QUALITY_CHANGED,u);c.unsubscribe(c.eventList.ENAME_LIVE_EDGE_FOUND,s.timelineConverter);c.unsubscribe(c.eventList.ENAME_LIVE_EDGE_FOUND,u);c.unsubscribe(c.eventList.ENAME_LIVE_EDGE_FOUND,f);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_STARTED,u);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_COMPLETED,i);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_COMPLETED,u);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_COMPLETED,h);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_COMPLETED,t);f.unsubscribe(f.eventList.ENAME_DATA_UPDATE_COMPLETED,r);e.unsubscribe(e.eventList.ENAME_INIT_SEGMENT_LOADED,i);e.unsubscribe(e.eventList.ENAME_MEDIA_SEGMENT_LOADED,i);e.unsubscribe(e.eventList.ENAME_MEDIA_SEGMENT_LOADING_START,u);e.unsubscribe(e.eventList.ENAME_STREAM_COMPLETED,u);e.unsubscribe(e.eventList.ENAME_STREAM_COMPLETED,i);e.unsubscribe(e.eventList.ENAME_STREAM_COMPLETED,u.scheduleRulesCollection.bufferLevelRule);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_STATE_CHANGED,y);i.unsubscribe(i.eventList.ENAME_BUFFER_CLEARED,u);i.unsubscribe(i.eventList.ENAME_BYTES_APPENDED,u);i.unsubscribe(i.eventList.ENAME_BYTES_REJECTED,u);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_UPDATED,u);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_STATE_CHANGED,u);i.unsubscribe(i.eventList.ENAME_INIT_REQUESTED,u);i.unsubscribe(i.eventList.ENAME_BUFFERING_COMPLETED,t);i.unsubscribe(i.eventList.ENAME_CLOSED_CAPTIONING_REQUESTED,u);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_OUTRUN,u.scheduleRulesCollection.bufferLevelRule);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_BALANCED,u.scheduleRulesCollection.bufferLevelRule);r.unsubscribe(r.eventList.ENAME_PLAYBACK_PROGRESS,i);r.unsubscribe(r.eventList.ENAME_PLAYBACK_TIME_UPDATED,i);r.unsubscribe(r.eventList.ENAME_PLAYBACK_RATE_CHANGED,i);r.unsubscribe(r.eventList.ENAME_PLAYBACK_RATE_CHANGED,u);r.unsubscribe(r.eventList.ENAME_PLAYBACK_SEEKING,i);r.unsubscribe(r.eventList.ENAME_PLAYBACK_SEEKING,u);r.unsubscribe(r.eventList.ENAME_PLAYBACK_STARTED,u);r.unsubscribe(r.eventList.ENAME_WALLCLOCK_TIME_UPDATED,f);r.unsubscribe(r.eventList.ENAME_WALLCLOCK_TIME_UPDATED,i);r.unsubscribe(r.eventList.ENAME_WALLCLOCK_TIME_UPDATED,u);r.unsubscribe(r.eventList.ENAME_PLAYBACK_SEEKING,u.scheduleRulesCollection.playbackTimeRule);l.unsubscribe(l.eventList.ENAME_REPRESENTATION_UPDATED,f);a.unsubscribe(a.eventList.ENAME_INITIALIZATION_LOADED,l);a.unsubscribe(a.eventList.ENAME_SEGMENTS_LOADED,l);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_OUTRUN,o);i.unsubscribe(i.eventList.ENAME_BUFFER_LEVEL_BALANCED,o);i.unsubscribe(i.eventList.ENAME_BYTES_REJECTED,o);o.unsubscribe(o.eventList.ENAME_FRAGMENT_LOADING_STARTED,e);o.unsubscribe(o.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,e);o.unsubscribe(o.eventList.ENAME_STREAM_COMPLETED,e);o.unsubscribe(o.eventList.ENAME_FRAGMENT_LOADING_FAILED,u);v.unsubscribe(v.eventList.ENAME_LOADING_COMPLETED,o);e.resetModel(o);this.bufferController.reset(n);this.scheduleController.reset();this.bufferController=null;this.scheduleController=null;this.representationController=null;this.videoModel=null;this.fragmentController=null}}};MediaPlayer.dependencies.StreamProcessor.prototype={constructor:MediaPlayer.dependencies.StreamProcessor};MediaPlayer.utils.TokenAuthentication=function(){"use strict";var n={type:MediaPlayer.utils.TokenAuthentication.TYPE_QUERY};return{debug:undefined,getTokenAuthentication:function(){return n},setTokenAuthentication:function(t){n=t},checkRequestHeaderForToken:function(t){n.name!==undefined&&t.getResponseHeader(n.name)!==null&&(n.token=t.getResponseHeader(n.name),this.debug.log(n.name+" received: "+n.token))},addTokenAsQueryArg:function(t){if(n.name!==undefined&&n.token!==undefined&&n.type===MediaPlayer.utils.TokenAuthentication.TYPE_QUERY){var i=t.indexOf("?")===-1?"?":"&";t+=i+n.name+"="+n.token;this.debug.log(n.name+" is being appended on the request url with a value of : "+n.token)}return t},setTokenInRequestHeader:function(t){return n.type===MediaPlayer.utils.TokenAuthentication.TYPE_HEADER&&(t.setRequestHeader(n.name,n.token),this.debug.log(n.name+" is being set in the request header with a value of : "+n.token)),t}}};MediaPlayer.utils.TokenAuthentication.TYPE_QUERY="query";MediaPlayer.utils.TokenAuthentication.TYPE_HEADER="header";MediaPlayer.models.URIQueryAndFragmentModel=function(){"use strict";var t=new MediaPlayer.vo.URIFragmentData,n=[],i=function(i){function u(n,t,i,r){var u=r[0].split(/[=]/);return r.push({key:u[0],value:u[1]}),r.shift(),r}function c(t,i,u){return i>0&&(o&&n.length===0?n=u[i].split(/[&]/):s&&(r=u[i].split(/[&]/))),u}if(!i)return null;var r=[],f=new RegExp(/[?]/),e=new RegExp(/[#]/),o=f.test(i),s=e.test(i),h;return h=i.split(/[?#]/).map(c),n.length>0&&(n=n.reduce(u,null)),r.length>0&&(r=r.reduce(u,null),r.forEach(function(n){t[n.key]=n.value})),i};return{parseURI:i,getURIFragmentData:t,getURIQueryData:n,reset:function(){t=new MediaPlayer.vo.URIFragmentData;n=[]}}};MediaPlayer.models.URIQueryAndFragmentModel.prototype={constructor:MediaPlayer.models.URIQueryAndFragmentModel};MediaPlayer.models.VideoModel=function(){"use strict";var n,t=[],i=function(){return t.length>0},r=function(i){i!==null&&(n.playbackRate=0,t[i]!==!0)&&(t.push(i),t[i]=!0)},u=function(r){if(r!==null){t[r]=!1;var u=t.indexOf(r);u!==-1&&t.splice(u,1);i()===!1&&(n.playbackRate=1)}},f=function(n,t){t?r(n):u(n)},e=function(n,t){var i=n.streamProcessor.getType();f.call(this,i,!t)};return{system:undefined,setup:function(){this.bufferLevelStateChanged=e},play:function(){n.play()},pause:function(){n.pause()},isPaused:function(){return n.paused},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(t){n.playbackRate=t},getCurrentTime:function(){return n.currentTime},setCurrentTime:function(t){n.currentTime!=t&&(n.currentTime=t)},listen:function(t,i){n.addEventListener(t,i,!1)},unlisten:function(t,i){n.removeEventListener(t,i,!1)},getElement:function(){return n},setElement:function(t){n=t},setSource:function(t){n.src=t}}};MediaPlayer.models.VideoModel.prototype={constructor:MediaPlayer.models.VideoModel};MediaPlayer.dependencies.VideoModelExtensions=function(){"use strict";return{getPlaybackQuality:function(n){var i="webkitDroppedFrameCount"in n,r="getVideoPlaybackQuality"in n,t=null;return r?t=n.getVideoPlaybackQuality():i&&(t={droppedVideoFrames:n.webkitDroppedFrameCount,creationTime:new Date}),t}}};MediaPlayer.dependencies.VideoModelExtensions.prototype={constructor:MediaPlayer.dependencies.VideoModelExtensions};MediaPlayer.dependencies.TextController=function(){var i=!1,t,n,r,u=function(){i||(n.hasOwnProperty("initialize")&&n.initialize(r,this),i=!0);this.notify(this.eventList.ENAME_CLOSED_CAPTIONING_REQUESTED,0)},f=function(t,i,r){var u=this;i===u.streamProcessor.getFragmentModel()&&r!==null&&u.sourceBufferExt.append(n,r,u.videoModel)};return{sourceBufferExt:undefined,debug:undefined,system:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_CLOSED_CAPTIONING_REQUESTED:"closedCaptioningRequested"},setup:function(){this.dataUpdateCompleted=u;this.initSegmentLoaded=f},initialize:function(n,t,i,u){var f=this;r=n;f.setBuffer(t);f.setMediaSource(i);f.videoModel=u.videoModel;f.representationController=u.representationController;f.streamProcessor=u},getBuffer:function(){return n},setBuffer:function(t){n=t},setMediaSource:function(n){t=n},reset:function(i){i||(this.sourceBufferExt.abort(t,n),this.sourceBufferExt.removeSourceBuffer(t,n))}}};MediaPlayer.dependencies.TextController.prototype={constructor:MediaPlayer.dependencies.TextController};MediaPlayer.dependencies.TextSourceBuffer=function(){var n,t;return{system:undefined,eventBus:undefined,errHandler:undefined,initialize:function(i,r){t=i;this.videoModel=r.videoModel;n=r.streamProcessor.getData()},append:function(t){var i=this,r,u,f,e=String.fromCharCode.apply(null,new Uint16Array(t));try{r=i.getParser().parse(e);u=n.Representation_asArray[0].id;f=n.lang;i.getTextTrackExtensions().addTextTrack(i.videoModel.getElement(),r,u,f,!0);i.eventBus.dispatchEvent({type:"updateend"})}catch(o){i.errHandler.closedCaptionsError(o,"parse",e)}},abort:function(){this.getTextTrackExtensions().deleteCues(this.videoModel.getElement())},getParser:function(){var n;return t==="text/vtt"?n=this.system.getObject("vttParser"):t==="application/ttml+xml"&&(n=this.system.getObject("ttmlParser")),n},getTextTrackExtensions:function(){return this.system.getObject("textTrackExtensions")},addEventListener:function(n,t,i){this.eventBus.addEventListener(n,t,i)},removeEventListener:function(n,t,i){this.eventBus.removeEventListener(n,t,i)}}};MediaPlayer.dependencies.TextSourceBuffer.prototype={constructor:MediaPlayer.dependencies.TextSourceBuffer};MediaPlayer.utils.TextTrackExtensions=function(){"use strict";var n;return{setup:function(){n=window.VTTCue||window.TextTrackCue},addTextTrack:function(t,i,r,u,f){var e=t.addTextTrack("captions",r,u),s,o;e.default=f;e.mode="showing";for(s in i)o=i[s],e.addCue(new n(o.start,o.end,o.data));return e},deleteCues:function(n){for(var t=n.textTracks[0],r=t.cues,u=r.length-1,i=u;i>=0;i-=1)t.removeCue(r[i]);t.mode="disabled"}}};MediaPlayer.utils.TTMLParser=function(){"use strict";var i=3600,r=60,u=/^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])((\.[0-9][0-9][0-9])|(:[0-9][0-9]))$/,n,t=function(t){var s=u.test(t),f,o,e;if(!s)return NaN;if(f=t.split(":"),o=parseFloat(f[0])*i+parseFloat(f[1])*r+parseFloat(f[2]),f[3])if(e=n.tt.frameRate,e&&!isNaN(e))o+=parseFloat(f[3])/e;else return NaN;return o},f=function(){var t=!1,r=n.hasOwnProperty("tt"),i=r?n.tt.hasOwnProperty("head"):!1,u=i?n.tt.head.hasOwnProperty("layout"):!1,f=i?n.tt.head.hasOwnProperty("styling"):!1,e=r?n.tt.hasOwnProperty("body"):!1,o=i?n.tt.head.hasOwnProperty("profile"):!1;return r&&i&&u&&f&&e&&(t=!0),t&&(t=o&&n.tt.head.profile.use==="http://www.w3.org/ns/ttml/profile/sdp-us"),t},e=function(n,t){var i=Object.keys(n).filter(function(i){return i.split(":")[0]==="xmlns"&&n[i]===t}).map(function(n){return n.split(":")[1]});return i.length!=1?null:i[0]},o=function(i){var a=[],v=new X2JS([],"",!1),r,u,o,h,c,l,s;if(n=v.xml_str2json(i),!f()){r="TTML document has incorrect structure";throw r;}if(l=e(n.tt,"http://www.w3.org/ns/ttml#parameter"),n.tt.hasOwnProperty(l+":frameRate")&&(n.tt.frameRate=parseInt(n.tt[l+":frameRate"],10)),u=n.tt.body.div_asArray[0].p_asArray,!u||u.length===0){r="TTML document does not contain any cues";throw r;}for(s=0;s<u.length;s+=1){if(o=u[s],h=t(o.begin),c=t(o.end),isNaN(h)||isNaN(c)){r="TTML document has incorrect timing value";throw r;}a.push({start:h,end:c,data:o.__text})}return a};return{parse:o}};MediaPlayer.utils.VTTParser=function(){"use strict";var n=function(n){var t=n.split(":"),i=t.length-1;return n=parseInt(t[i-1],10)*60+parseFloat(t[i],10),i===2&&(n+=parseInt(t[0],10)*3600),n};return{parse:function(t){var f=/-->/,e=/(^[\s]+|[\s]+$)/g,o=[],s,i,r,u,h;for(t=t.split(/(?:\r\n|\r|\n)/gm),s=t.length,i=0;i<s;i++)r=t[i],r.length>0&&r!=="WEBVTT"&&r.match(f)&&(u=r.split(f),h=t[i+1],o.push({start:n(u[0].replace(e,"")),end:n(u[1].replace(e,"")),data:h}));return o}}};MediaPlayer.rules.RulesContext=function(n,t,i){"use strict";var u=n,r=t,f=i;return{getPeriodInfo:function(){return r.adaptation.period},getAdaptationInfo:function(){return r.adaptation},getRepresentationInfo:function(){return r},getStreamType:function(){return u},getCurrentValue:function(){return f}}};MediaPlayer.rules.RulesContext.prototype={constructor:MediaPlayer.rules.RulesContext};MediaPlayer.rules.SwitchRequest=function(n,t){"use strict";this.value=n;this.priority=t;this.value===undefined&&(this.value=999);this.priority===undefined&&(this.priority=.5)};MediaPlayer.rules.SwitchRequest.prototype={constructor:MediaPlayer.rules.SwitchRequest,NO_CHANGE:999,DEFAULT:.5,STRONG:1,WEAK:0};MediaPlayer.rules.ABRRulesCollection=function(){"use strict";var n=[];return{downloadRatioRule:undefined,insufficientBufferRule:undefined,limitSwitchesRule:undefined,getRules:function(t){switch(t){case MediaPlayer.rules.ABRRulesCollection.prototype.QUALITY_SWITCH_RULES:return n;default:return null}},setup:function(){n.push(this.downloadRatioRule);n.push(this.insufficientBufferRule);n.push(this.limitSwitchesRule)}}};MediaPlayer.rules.ABRRulesCollection.prototype={constructor:MediaPlayer.rules.ABRRulesCollection,QUALITY_SWITCH_RULES:"qualitySwitchRules"};MediaPlayer.rules.DownloadRatioRule=function(){"use strict";var n={},t=function(n,t,i){var r=this,u,f;return f=r.manifestExt.getRepresentationFor(n,i),u=r.manifestExt.getBandwidth(f),u/t};return{debug:undefined,manifestExt:undefined,metricsExt:undefined,metricsModel:undefined,setData:function(t,i){n[i]=n[i]||{};this.manifestExt.getIsAudio(t)&&(n[i].audio=t);this.manifestExt.getIsVideo(t)&&(n[i].video=t)},execute:function(i,r){var u=this,it=i.getPeriodInfo().id,b=i.getStreamType(),o=i.getCurrentValue,h=n[it][b],k=u.metricsModel.getReadOnlyMetricsFor(b),f=u.metricsExt.getCurrentHttpRequest(k),d,w,s,g,v,nt,tt,c,y,p,l,a,e;if(!k){r(new MediaPlayer.rules.SwitchRequest);return}if(f===null){r(new MediaPlayer.rules.SwitchRequest);return}if(w=(f.tfinish.getTime()-f.trequest.getTime())/1e3,d=(f.tfinish.getTime()-f.tresponse.getTime())/1e3,w<=0){r(new MediaPlayer.rules.SwitchRequest);return}if(f.mediaduration===null||f.mediaduration===undefined||f.mediaduration<=0||isNaN(f.mediaduration)){r(new MediaPlayer.rules.SwitchRequest);return}if(g=f.mediaduration/w,s=f.mediaduration/d*.75,isNaN(s)||isNaN(g)){u.debug.log("The ratios are NaN, bailing.");r(new MediaPlayer.rules.SwitchRequest);return}if(isNaN(s))e=new MediaPlayer.rules.SwitchRequest;else if(s<4)o>0?(u.debug.log("We are not at the lowest bitrate, so switch down."),y=u.manifestExt.getRepresentationFor(o-1,h),nt=u.manifestExt.getBandwidth(y),p=u.manifestExt.getRepresentationFor(o,h),c=u.manifestExt.getBandwidth(p),v=nt/c,s<v?(u.debug.log("Things must be going pretty bad, switch all the way down."),e=new MediaPlayer.rules.SwitchRequest(0)):(u.debug.log("Things could be better, so just switch down one index."),e=new MediaPlayer.rules.SwitchRequest(o-1))):e=new MediaPlayer.rules.SwitchRequest(o);else if(a=u.manifestExt.getRepresentationCount(h)-1,o<a)if(y=u.manifestExt.getRepresentationFor(o+1,h),tt=u.manifestExt.getBandwidth(y),p=u.manifestExt.getRepresentationFor(o,h),c=u.manifestExt.getBandwidth(p),v=tt/c,s>=v)if(s>100)u.debug.log("Tons of bandwidth available, go all the way up."),e=new MediaPlayer.rules.SwitchRequest(a-1);else if(s>10)u.debug.log("Just enough bandwidth available, switch up one."),e=new MediaPlayer.rules.SwitchRequest(o+1);else{for(l=-1;(l+=1)<a;)if(s<t.call(u,l,c,h))break;u.debug.log("Calculated ideal new quality index is: "+l);e=new MediaPlayer.rules.SwitchRequest(l)}else e=new MediaPlayer.rules.SwitchRequest;else e=new MediaPlayer.rules.SwitchRequest(a);r(e)},reset:function(){n={}}}};MediaPlayer.rules.DownloadRatioRule.prototype={constructor:MediaPlayer.rules.DownloadRatioRule};MediaPlayer.rules.InsufficientBufferRule=function(){"use strict";var n=0,t=3;return{debug:undefined,metricsModel:undefined,execute:function(i,r){var e=this,l=i.getStreamType(),h=i.getCurrentValue(),o=e.metricsModel.getReadOnlyMetricsFor(l),u,f,c=!1,s=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT;if(o.PlayList===null||o.PlayList===undefined||o.PlayList.length===0){r(new MediaPlayer.rules.SwitchRequest);return}if(u=o.PlayList[o.PlayList.length-1],u===null||u===undefined||u.trace.length===0){r(new MediaPlayer.rules.SwitchRequest);return}if(f=u.trace[u.trace.length-2],f===null||f===undefined||f.stopreason===null||f.stopreason===undefined){r(new MediaPlayer.rules.SwitchRequest);return}f.stopreason===MediaPlayer.vo.metrics.PlayList.Trace.REBUFFERING_REASON&&(c=!0,n+=1,e.debug.log("Number of times the buffer has run dry: "+n));n>t&&(s=MediaPlayer.rules.SwitchRequest.prototype.STRONG,e.debug.log("Apply STRONG to buffer rule."));c?(e.debug.log("The buffer ran dry recently, switch down."),r(new MediaPlayer.rules.SwitchRequest(h-1,s))):n>t?(e.debug.log("Too many dry buffer hits, quit switching bitrates."),r(new MediaPlayer.rules.SwitchRequest(h,s))):r(new MediaPlayer.rules.SwitchRequest(MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,s))}}};MediaPlayer.rules.InsufficientBufferRule.prototype={constructor:MediaPlayer.rules.InsufficientBufferRule};MediaPlayer.rules.LimitSwitchesRule=function(){"use strict";var t=0,n=2e3;return{debug:undefined,manifestModel:undefined,metricsModel:undefined,execute:function(i,r){var e=this,l=i.getStreamType(),a=i.getCurrentValue(),o=this.metricsModel.getReadOnlyMetricsFor(l),u=e.manifestModel.getValue(),s,h=Number.POSITIVE_INFINITY,v=o.RepSwitchList.length-1,y=o.RepSwitchList[v],f=(new Date).getTime(),c;if(u&&(s=u.minBufferTime,u.hasOwnProperty("maxSegmentDuration")&&(h=u.maxSegmentDuration),n=Math.min(s,h)*1e3),c=f-t,c<n&&f-y.t.getTime()<n){e.debug.log("Wait some time before allowing another switch.");r(new MediaPlayer.rules.SwitchRequest(a,MediaPlayer.rules.SwitchRequest.prototype.STRONG));return}t=f;r(new MediaPlayer.rules.SwitchRequest(MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,MediaPlayer.rules.SwitchRequest.prototype.STRONG))}}};MediaPlayer.rules.LimitSwitchesRule.prototype={constructor:MediaPlayer.rules.LimitSwitchesRule};MediaPlayer.rules.BufferLevelRule=function(){"use strict";var n={},t={},i={},r=function(n,i){return t[n]&&t[n][i]},u=function(t,i){return n[t]&&n[t][i]},f=function(n,i,r){var u=i.getContext().streamProcessor.getPeriodInfo().id;t[u]=t[u]||{};t[u][r.streamType]=!0},e=function(t){var i=t.streamProcessor.getPeriodInfo().id;n[i]=n[i]||{};n[i][t.streamProcessor.getType()]=!0},o=function(t){var i=t.streamProcessor.getPeriodInfo().id;n[i]=n[i]||{};n[i][t.streamProcessor.getType()]=!1};return{metricsExt:undefined,manifestExt:undefined,bufferExt:undefined,metricsModel:undefined,setup:function(){this.bufferLevelOutrun=e;this.bufferLevelBalanced=o;this.streamCompleted=f},setScheduleController:function(n){var t=n.streamProcessor.getPeriodInfo().id;i[t]=i[t]||{};i[t][n.streamProcessor.getType()]=n},execute:function(n,t){var e=n.getPeriodInfo().id,f=n.getStreamType();if(u(e,f)){t(new MediaPlayer.rules.SwitchRequest(0,MediaPlayer.rules.SwitchRequest.prototype.STRONG));return}var s=this.metricsModel.getReadOnlyMetricsFor(f),y=this.metricsExt.getCurrentBufferLevel(s)?this.metricsExt.getCurrentBufferLevel(s).level:0,h=i[e][f].streamProcessor.getCurrentRepresentation(),c=this.manifestExt.getIsDynamic(h.adaptation.period.mpd.manifest),p=this.metricsExt.getCurrentPlaybackRate(s),l=h.adaptation.period.duration,a=y/Math.max(p,1),w=h.segments[0].duration,b=i[e][f].playbackController.getTime(),v=c?Number.POSITIVE_INFINITY:l-b,k=Math.min(this.bufferExt.getRequiredBufferLength(c,l),v),d=Math.max(k-a,0),o;o=Math.ceil(d/w);a>=v&&!r(e,f)&&(o=o||1);t(new MediaPlayer.rules.SwitchRequest(o,MediaPlayer.rules.SwitchRequest.prototype.DEFAULT))},reset:function(){n={};t={};i={}}}};MediaPlayer.rules.BufferLevelRule.prototype={constructor:MediaPlayer.rules.BufferLevelRule};MediaPlayer.rules.LiveEdgeBinarySearchRule=function(){"use strict";var v=43200,i=NaN,r=null,u=NaN,n=null,h=!1,e=NaN,o=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT,t,f,s=function(i,r,f,e){var o=this,c,h;e===null?(n.segments=null,n.segmentAvailabilityRange={start:i-u,end:i+u},c=t.indexHandler.getSegmentRequestForTime(n,i),s.call(o,i,r,f,c)):(h=function(n,u,e){t.fragmentLoader.unsubscribe(t.fragmentLoader.eventList.ENAME_CHECK_FOR_EXISTENCE_COMPLETED,o,h);u?r.call(o,e,i):f.call(o,e,i)},t.fragmentLoader.subscribe(t.fragmentLoader.eventList.ENAME_CHECK_FOR_EXISTENCE_COMPLETED,o,h),t.fragmentLoader.checkForExistence(e))},c=function(e,v){var y,w,p;if(h){a.call(this,!1,v);return}p=v-i;y=p>0?i-p:i+Math.abs(p)+u;y<r.start&&y>r.end?f(new MediaPlayer.rules.SwitchRequest(null,o)):(w=t.indexHandler.getSegmentRequestForTime(n,y),s.call(this,y,l,c,w))},l=function(c,l){var y=c.startTime,p=this,w,v;if(!h){if(!n.segmentDuration){f(new MediaPlayer.rules.SwitchRequest(y,o));return}if(h=!0,r.end=y+2*u,l===i){v=l+e;w=t.indexHandler.getSegmentRequestForTime(n,v);s.call(p,v,function(){a.call(p,!0,v)},function(){f(new MediaPlayer.rules.SwitchRequest(v,o))},w);return}}a.call(this,!0,l)},a=function(i,u){var a,v,h;i?r.start=u:r.end=u;a=Math.floor(r.end-r.start)<=e;a?f(new MediaPlayer.rules.SwitchRequest(i?u:u-e,o)):(h=(r.start+r.end)/2,v=t.indexHandler.getSegmentRequestForTime(n,h),s.call(this,h,l,c,v))};return{metricsExt:undefined,manifestExt:undefined,setFinder:function(n){t=n},execute:function(h,a){var w=this,p,y;if(f=a,n=t.streamProcessor.getCurrentRepresentation(),e=n.segmentDuration,y=n.segmentAvailabilityRange,i=y.end,n.useCalculatedLiveEdgeTime){f(new MediaPlayer.rules.SwitchRequest(i,o));return}r={start:Math.max(0,i-v),end:i+v};u=Math.floor((y.end-y.start)/2);p=t.indexHandler.getSegmentRequestForTime(n,i);s.call(w,i,l,c,p)},reset:function(){i=NaN;r=null;u=NaN;n=null;h=!1;e=NaN;t=null}}};MediaPlayer.rules.LiveEdgeBinarySearchRule.prototype={constructor:MediaPlayer.rules.LiveEdgeBinarySearchRule};MediaPlayer.rules.PendingRequestsRule=function(){"use strict";var t=3,n={};return{metricsExt:undefined,manifestExt:undefined,bufferExt:undefined,setScheduleController:function(t){var i=t.streamProcessor.getPeriodInfo().id;n[i]=n[i]||{};n[i][t.streamProcessor.getType()]=t},execute:function(i,r){var s=i.getStreamType(),h=i.getPeriodInfo().id,f=i.getCurrentValue(),u=n[h][s],c=u.fragmentController.getPendingRequests(u),l=u.fragmentController.getLoadingRequests(u),e=c.length+l.length,o=Math.max(f-e,0);if(e>t){r(new MediaPlayer.rules.SwitchRequest(0,MediaPlayer.rules.SwitchRequest.prototype.DEFAULT));return}if(f===0){r(new MediaPlayer.rules.SwitchRequest(o,MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE));return}r(new MediaPlayer.rules.SwitchRequest(o,MediaPlayer.rules.SwitchRequest.prototype.DEFAULT))},reset:function(){n={}}}};MediaPlayer.rules.PendingRequestsRule.prototype={constructor:MediaPlayer.rules.PendingRequestsRule};MediaPlayer.rules.PlaybackTimeRule=function(){"use strict";var n={},t={},i=function(t,i){var r=t.getPeriodId();n[r]=n[r]||{};n[r].audio=i;n[r].video=i};return{setup:function(){this.playbackSeeking=i},setScheduleController:function(n){var i=n.streamProcessor.getPeriodInfo().id;t[i]=t[i]||{};t[i][n.streamProcessor.getType()]=n},execute:function(i,r){var h=i.getStreamType(),o=i.getPeriodInfo().id,u=t[o][h],c=u.streamProcessor.getCurrentRepresentation(),l=n[o]?n[o][h]:null,y=l?MediaPlayer.rules.SwitchRequest.prototype.STRONG:MediaPlayer.rules.SwitchRequest.prototype.DEFAULT,e=u.getFragmentModel().getRejectedRequests().shift(),w=!!e&&!l,a=u.indexHandler.getCurrentTime(c),b=u.playbackController.getTime(),k=e?e.startTime+e.duration:null,p=e&&(k>b&&e.startTime<=a||isNaN(a)),v,s,f;if(s=l||(p?e.startTime:a),isNaN(s)){r(new MediaPlayer.rules.SwitchRequest(null,y));return}for(n[o]&&(n[o][h]=null),v=u.sourceBufferExt.getBufferRange(u.bufferController.getBuffer(),s),v!==null&&(s=v.end),f=u.indexHandler.getSegmentRequestForTime(c,s,w);f&&u.fragmentController.isFragmentLoadedOrPending(u,f);){if(f.action==="complete"){f=null;u.indexHandler.setCurrentTime(NaN);break}f=u.indexHandler.getNextSegmentRequest(c)}f&&!p&&u.indexHandler.setCurrentTime(f.startTime+f.duration);r(new MediaPlayer.rules.SwitchRequest(f,y))},reset:function(){n={};t={}}}};MediaPlayer.rules.PlaybackTimeRule.prototype={constructor:MediaPlayer.rules.PlaybackTimeRule};MediaPlayer.rules.RulesController=function(){"use strict";var n={},t=["execute"],i=function(n){return n===this.SCHEDULING_RULE||n===this.ABR_RULE},r=function(n){var r=t.length,i=0;for(i;i<r;i+=1)if(!n.hasOwnProperty(t[i]))return!1;return!0},f=function(n,t,i){return new MediaPlayer.rules.RulesContext(n,t,i)},e=function(n){var t=n.execute.bind(n);return n.execute=function(i,r,u){var f=function(t){r.call(n,new MediaPlayer.rules.SwitchRequest(t.value,t.priority))};t(i,f,u)},typeof n.reset!="function"&&(n.reset=function(){}),n},u=function(n,t,i){var u,o,s,h,c,f;for(o in t)if(h=t[o],c=h.length,c)for(f=0;f<c;f+=1)(u=h[f],r.call(this,u))&&(u=e.call(this,u),s=n.getRules(o),i&&(s.length=0),s.push(u))};return{system:undefined,debug:undefined,SCHEDULING_RULE:0,ABR_RULE:1,initialize:function(){n[this.ABR_RULE]=this.system.getObject("abrRulesCollection");n[this.SCHEDULING_RULE]=this.system.getObject("scheduleRulesCollection")},setRules:function(t,r){i.call(this,t)&&r&&u.call(this,n[t],r,!0)},addRules:function(t,r){i.call(this,t)&&r&&u.call(this,n[t],r,!1)},applyRules:function(n,t,i,u,e,o){var c=n.length,a=c,s={},v=f.call(this,t,i,e),l,h,y=function(n){var i,t;(n.value!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(s[n.priority]=o(s[n.priority],n.value)),--c)||(s[MediaPlayer.rules.SwitchRequest.prototype.WEAK]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(t=MediaPlayer.rules.SwitchRequest.prototype.WEAK,i=s[MediaPlayer.rules.SwitchRequest.prototype.WEAK]),s[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(t=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT,i=s[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]),s[MediaPlayer.rules.SwitchRequest.prototype.STRONG]!==MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE&&(t=MediaPlayer.rules.SwitchRequest.prototype.STRONG,i=s[MediaPlayer.rules.SwitchRequest.prototype.STRONG]),t!=MediaPlayer.rules.SwitchRequest.prototype.STRONG&&t!=MediaPlayer.rules.SwitchRequest.prototype.WEAK&&(t=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT),u({value:i||e,confidence:t}))};for(s[MediaPlayer.rules.SwitchRequest.prototype.STRONG]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,s[MediaPlayer.rules.SwitchRequest.prototype.WEAK]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,s[MediaPlayer.rules.SwitchRequest.prototype.DEFAULT]=MediaPlayer.rules.SwitchRequest.prototype.NO_CHANGE,h=0;h<a;h+=1){if(l=n[h],!r.call(this,l)){c--;continue}l.execute(v,y)}},reset:function(){n={}}}};MediaPlayer.rules.RulesController.prototype={constructor:MediaPlayer.rules.RulesController};MediaPlayer.rules.SameTimeRequestRule=function(){"use strict";var n=4,t=function(n,t){var i,u,f,e=0,o,s,h=n.length;for(e;e<h;e+=1)for(f=n[e].getPendingRequests(),r.call(this,f,"index"),o=0,s=f.length;o<s;o++){if(i=f[o],isNaN(i.startTime)&&i.action!=="complete"){u=i;break}i.startTime>t&&(!u||i.startTime<u.startTime)&&(u=i)}return u||i},i=function(n,t){for(var f=n.length,i,r=null,u=0;u<f;u+=1)i=n[u].getPendingRequestForTime(t),i&&(!r||i.startTime>r.startTime)&&(r=i);return r},r=function(n,t){var i=function(n,i){return n[t]<i[t]||isNaN(n[t])&&n.action!=="complete"?-1:n[t]>i[t]?1:0};n.sort(i)};return{setFragmentModels:function(n,t){this.fragmentModels=this.fragmentModels||{};this.fragmentModels[t]=n},execute:function(r,u){var g=r.getPeriodInfo().id,nt=r.getCurrentValue(),s=MediaPlayer.rules.SwitchRequest.prototype.DEFAULT,e=this.fragmentModels[g],y,f,h,a,o,v,tt=new Date,c=null,p,w=e?e.length:null,b=!1,l=[],k,d;if(!e||!w){u(new MediaPlayer.rules.SwitchRequest([],s));return}if(v=Math.round(e[0].getContext().playbackController.getTime()*100)/100,p=i(e,v),o=p||t(e,v)||nt,!o){u(new MediaPlayer.rules.SwitchRequest([],s));return}for(a=0;a<w;a+=1)if((f=e[a],y=f.getContext().streamProcessor.getType(),y==="video"||y==="audio")&&(k=f.getPendingRequests(),d=f.getLoadingRequests().length,!f.getIsPostponed()||isNaN(o.startTime))){if(d>n){u(new MediaPlayer.rules.SwitchRequest([],s));return}if(c=c||(o===p?v:o.startTime),k.indexOf(o)!==-1){l.push(o);continue}if(h=f.getPendingRequestForTime(c),h){l.push(h);continue}if(h=f.getLoadingRequestForTime(c)||f.getExecutedRequestForTime(c),!h){b=!0;break}}if(l=l.filter(function(n){return n.action==="complete"||tt.getTime()>=n.availabilityStartTime.getTime()}),b){u(new MediaPlayer.rules.SwitchRequest([],s));return}u(new MediaPlayer.rules.SwitchRequest(l,s))}}};MediaPlayer.rules.SameTimeRequestRule.prototype={constructor:MediaPlayer.rules.SameTimeRequestRule};MediaPlayer.rules.ScheduleRulesCollection=function(){"use strict";var n=[],t=[],i=[],r=[];return{bufferLevelRule:undefined,pendingRequestsRule:undefined,playbackTimeRule:undefined,sameTimeRequestRule:undefined,liveEdgeBinarySearchRule:undefined,getRules:function(u){switch(u){case MediaPlayer.rules.ScheduleRulesCollection.prototype.SEGMENTS_TO_SCHEDULE_RULES:return n;case MediaPlayer.rules.ScheduleRulesCollection.prototype.NEXT_SEGMENT_RULES:return r;case MediaPlayer.rules.ScheduleRulesCollection.prototype.SEGMENTS_TO_EXECUTE_RULES:return t;case MediaPlayer.rules.ScheduleRulesCollection.prototype.LIVE_EDGE_RULES:return i;default:return null}},setup:function(){n.push(this.bufferLevelRule);n.push(this.pendingRequestsRule);r.push(this.playbackTimeRule);t.push(this.sameTimeRequestRule);i.push(this.liveEdgeBinarySearchRule)}}};MediaPlayer.rules.ScheduleRulesCollection.prototype={constructor:MediaPlayer.rules.ScheduleRulesCollection,SEGMENTS_TO_SCHEDULE_RULES:"segmentsToScheduleRules",NEXT_SEGMENT_RULES:"nextSegmentRules",SEGMENTS_TO_EXECUTE_RULES:"segmentsToExecuteRules",LIVE_EDGE_RULES:"liveEdgeRules"};MediaPlayer.models.MetricsList=function(){"use strict";return{TcpList:[],HttpList:[],RepSwitchList:[],BufferLevel:[],PlayList:[],DroppedFrames:[],SchedulingInfo:[],DVRInfo:[],ManifestUpdate:[]}};MediaPlayer.models.MetricsList.prototype={constructor:MediaPlayer.models.MetricsList};MediaPlayer.vo.SegmentRequest=function(){"use strict";this.action="download";this.startTime=NaN;this.streamType=null;this.type=null;this.duration=NaN;this.timescale=NaN;this.range=null;this.url=null;this.requestStartDate=null;this.firstByteDate=null;this.requestEndDate=null;this.quality=NaN;this.index=NaN;this.availabilityStartTime=null;this.availabilityEndTime=null;this.wallStartTime=null};MediaPlayer.vo.SegmentRequest.prototype={constructor:MediaPlayer.vo.SegmentRequest,ACTION_DOWNLOAD:"download",ACTION_COMPLETE:"complete"};MediaPlayer.vo.URIFragmentData=function(){"use strict";this.t=null;this.xywh=null;this.track=null;this.id=null;this.s=null};MediaPlayer.vo.URIFragmentData.prototype={constructor:MediaPlayer.vo.URIFragmentData};MediaPlayer.vo.metrics.BufferLevel=function(){"use strict";this.t=null;this.level=null};MediaPlayer.vo.metrics.BufferLevel.prototype={constructor:MediaPlayer.vo.metrics.BufferLevel};MediaPlayer.vo.metrics.DroppedFrames=function(){"use strict";this.time=null;this.droppedFrames=null};MediaPlayer.vo.metrics.DroppedFrames.prototype={constructor:MediaPlayer.vo.metrics.DroppedFrames};MediaPlayer.vo.metrics.DVRInfo=function(){"use strict";this.time=null;this.range=null;this.mpd=null};MediaPlayer.vo.metrics.DVRInfo.prototype={constructor:MediaPlayer.vo.metrics.DVRInfo};MediaPlayer.vo.metrics.HTTPRequest=function(){"use strict";this.stream=null;this.tcpid=null;this.type=null;this.url=null;this.actualurl=null;this.range=null;this.trequest=null;this.tresponse=null;this.tfinish=null;this.responsecode=null;this.interval=null;this.mediaduration=null;this.trace=[]};MediaPlayer.vo.metrics.HTTPRequest.prototype={constructor:MediaPlayer.vo.metrics.HTTPRequest};MediaPlayer.vo.metrics.HTTPRequest.Trace=function(){"use strict";this.s=null;this.d=null;this.b=[]};MediaPlayer.vo.metrics.HTTPRequest.Trace.prototype={constructor:MediaPlayer.vo.metrics.HTTPRequest.Trace};MediaPlayer.vo.metrics.ManifestUpdate=function(){"use strict";this.streamType=null;this.type=null;this.requestTime=null;this.fetchTime=null;this.availabilityStartTime=null;this.presentationStartTime=0;this.clientTimeOffset=0;this.currentTime=null;this.buffered=null;this.latency=0;this.periodInfo=[];this.representationInfo=[]};MediaPlayer.vo.metrics.ManifestUpdate.PeriodInfo=function(){"use strict";this.id=null;this.index=null;this.start=null;this.duration=null};MediaPlayer.vo.metrics.ManifestUpdate.RepresentationInfo=function(){"use strict";this.id=null;this.index=null;this.streamType=null;this.periodIndex=null;this.presentationTimeOffset=null;this.startNumber=null;this.segmentInfoType=null};MediaPlayer.vo.metrics.ManifestUpdate.prototype={constructor:MediaPlayer.vo.metrics.ManifestUpdate};MediaPlayer.vo.metrics.ManifestUpdate.PeriodInfo.prototype={constructor:MediaPlayer.vo.metrics.ManifestUpdate.PeriodInfo};MediaPlayer.vo.metrics.ManifestUpdate.RepresentationInfo.prototype={constructor:MediaPlayer.vo.metrics.ManifestUpdate.RepresentationInfo};MediaPlayer.vo.metrics.PlayList=function(){"use strict";this.stream=null;this.start=null;this.mstart=null;this.starttype=null;this.trace=[]};MediaPlayer.vo.metrics.PlayList.Trace=function(){"use strict";this.representationid=null;this.subreplevel=null;this.start=null;this.mstart=null;this.duration=null;this.playbackspeed=null;this.stopreason=null};MediaPlayer.vo.metrics.PlayList.prototype={constructor:MediaPlayer.vo.metrics.PlayList};MediaPlayer.vo.metrics.PlayList.INITIAL_PLAY_START_REASON="initial_start";MediaPlayer.vo.metrics.PlayList.SEEK_START_REASON="seek";MediaPlayer.vo.metrics.PlayList.Trace.prototype={constructor:MediaPlayer.vo.metrics.PlayList.Trace()};MediaPlayer.vo.metrics.PlayList.Trace.USER_REQUEST_STOP_REASON="user_request";MediaPlayer.vo.metrics.PlayList.Trace.REPRESENTATION_SWITCH_STOP_REASON="representation_switch";MediaPlayer.vo.metrics.PlayList.Trace.END_OF_CONTENT_STOP_REASON="end_of_content";MediaPlayer.vo.metrics.PlayList.Trace.REBUFFERING_REASON="rebuffering";MediaPlayer.vo.metrics.RepresentationSwitch=function(){"use strict";this.t=null;this.mt=null;this.to=null;this.lto=null};MediaPlayer.vo.metrics.RepresentationSwitch.prototype={constructor:MediaPlayer.vo.metrics.RepresentationSwitch};MediaPlayer.vo.metrics.SchedulingInfo=function(){"use strict";this.streamType=null;this.t=null;this.type=null;this.startTime=null;this.availabilityStartTime=null;this.duration=null;this.quality=null;this.range=null;this.state=null};MediaPlayer.vo.metrics.SchedulingInfo.prototype={constructor:MediaPlayer.vo.metrics.SchedulingInfo};MediaPlayer.vo.metrics.SchedulingInfo.PENDING_STATE="pending";MediaPlayer.vo.metrics.SchedulingInfo.LOADING_STATE="loading";MediaPlayer.vo.metrics.SchedulingInfo.EXECUTED_STATE="executed";MediaPlayer.vo.metrics.SchedulingInfo.REJECTED_STATE="rejected";MediaPlayer.vo.metrics.SchedulingInfo.CANCELED_STATE="canceled";MediaPlayer.vo.metrics.SchedulingInfo.FAILED_STATE="failed";MediaPlayer.vo.metrics.TCPConnection=function(){"use strict";this.tcpid=null;this.dest=null;this.topen=null;this.tclose=null;this.tconnect=null};MediaPlayer.vo.metrics.TCPConnection.prototype={constructor:MediaPlayer.vo.metrics.TCPConnection};Dash.dependencies.BaseURLExtensions=function(){"use strict";var i=function(n,t){for(var u=new DataView(n),r={},i=0,h,c,s,e,a,o,l,f,v,y;f!=="sidx"&&i<u.byteLength;){for(v=u.getUint32(i),i+=4,f="",e=0;e<4;e+=1)y=u.getInt8(i),f+=String.fromCharCode(y),i+=1;f!=="moof"&&f!=="traf"&&f!=="sidx"?i+=v-8:f==="sidx"&&(i-=8)}if(s=u.getUint32(i,!1)+i,s>n.byteLength)throw"sidx terminates after array buffer";for(r.version=u.getUint8(i+8),i+=12,r.timescale=u.getUint32(i+4,!1),i+=8,r.version===0?(r.earliest_presentation_time=u.getUint32(i,!1),r.first_offset=u.getUint32(i+4,!1),i+=8):(r.earliest_presentation_time=utils.Math.to64BitNumber(u.getUint32(i+4,!1),u.getUint32(i,!1)),r.first_offset=(u.getUint32(i+8,!1)<<32)+u.getUint32(i+12,!1),i+=16),r.first_offset+=s+(t||0),r.reference_count=u.getUint16(i+2,!1),i+=4,r.references=[],h=r.first_offset,c=r.earliest_presentation_time,e=0;e<r.reference_count;e+=1)o=u.getUint32(i,!1),a=o>>>31,o=o&2147483647,l=u.getUint32(i+4,!1),i+=12,r.references.push({size:o,type:a,offset:h,duration:l,time:c,timescale:r.timescale}),h+=o,c+=l;if(i!==s)throw"Error: final pos "+i+" differs from SIDX end "+s;return r},n=function(n,t,r){var s,f,o,e,u,h,c,l;for(s=i.call(this,n,r),f=s.references,o=[],u=0,h=f.length;u<h;u+=1)e=new Dash.vo.Segment,e.duration=f[u].duration,e.media=t,e.startTime=f[u].time,e.timescale=f[u].timescale,c=f[u].offset,l=f[u].offset+f[u].size-1,e.mediaRange=c+"-"+l,o.push(e);return this.debug.log("Parsed SIDX box: "+o.length+" segments."),o},r=function(n,t,i){var h,c,y,p,s=new DataView(n),e=0,o="",l=0,k,a,w,u,b=!1,v,f=this;for(f.debug.log("Searching for initialization.");o!=="moov"&&e<s.byteLength;){for(l=s.getUint32(e),e+=4,o="",a=0;a<4;a+=1)w=s.getInt8(e),o+=String.fromCharCode(w),e+=1;o==="ftyp"&&(h=e-8);o==="moov"&&(c=e-8);o!=="moov"&&(e+=l-8)}k=s.byteLength-e;o!=="moov"?(f.debug.log("Loading more bytes to find initialization."),t.range.start=0,t.range.end=t.bytesLoaded+t.bytesToLoad,u=new XMLHttpRequest,u.onloadend=function(){b||i.call(f,null,new Error("Error loading initialization."))},u.onload=function(){b=!0;t.bytesLoaded=t.range.end;r.call(f,u.response,function(n){i.call(f,n)})},u.onerror=function(){i.call(f,null,new Error("Error loading initialization."))},u.open("GET",f.tokenAuthentication.addTokenAsQueryArg(t.url)),u.responseType="arraybuffer",u.setRequestHeader("Range","bytes="+t.range.start+"-"+t.range.end),u=f.tokenAuthentication.setTokenInRequestHeader(u),u.send(null)):(y=h===undefined?c:h,p=c+l-1,v=y+"-"+p,f.debug.log("Found the initialization.  Range: "+v),i.call(f,v))},f=function(n){var t=new XMLHttpRequest,f=!0,u=this,e=n.adaptation.period.mpd.manifest.Period_asArray[n.adaptation.period.index].AdaptationSet_asArray[n.adaptation.index].Representation_asArray[n.index].BaseURL,i={url:e,range:{},searching:!1,bytesLoaded:0,bytesToLoad:1500,request:t};u.debug.log("Start searching for initialization.");i.range.start=0;i.range.end=i.bytesToLoad;t.onload=function(){t.status<200||t.status>299||(f=!1,i.bytesLoaded=i.range.end,r.call(u,t.response,i,function(t){n.range=t;n.initialization=e;u.notify(u.eventList.ENAME_INITIALIZATION_LOADED,n)}))};t.onloadend=t.onerror=function(){f&&(f=!1,u.errHandler.downloadError("initialization",i.url,t),u.notify(u.eventList.ENAME_INITIALIZATION_LOADED,n))};t.open("GET",u.tokenAuthentication.addTokenAsQueryArg(i.url));t.responseType="arraybuffer";t.setRequestHeader("Range","bytes="+i.range.start+"-"+i.range.end);t=u.tokenAuthentication.setTokenInRequestHeader(t);t.send(null);u.debug.log("Perform init search: "+i.url)},t=function(i,r,f,e){var nt,y=new DataView(i),s=new XMLHttpRequest,c=0,a="",v=0,w,p,tt,it,b,rt,k=!0,ut,h,ft=!1,o=this;for(o.debug.log("Searching for SIDX box."),o.debug.log(r.bytesLoaded+" bytes loaded.");a!=="sidx"&&c<y.byteLength;){for(v=y.getUint32(c),c+=4,a="",b=0;b<4;b+=1)rt=y.getInt8(c),a+=String.fromCharCode(rt),c+=1;a!=="sidx"&&(c+=v-8)}if(w=y.byteLength-c,a!=="sidx")e.call(o);else if(w<v-8)o.debug.log("Found SIDX but we don't have all of it."),r.range.start=0,r.range.end=r.bytesLoaded+(v-w),s.onload=function(){s.status<200||s.status>299||(k=!1,r.bytesLoaded=r.range.end,t.call(o,s.response,r,f,e))},s.onloadend=s.onerror=function(){k&&(k=!1,o.errHandler.downloadError("SIDX",r.url,s),e.call(o))},s.open("GET",o.tokenAuthentication.addTokenAsQueryArg(r.url)),s.responseType="arraybuffer",s.setRequestHeader("Range","bytes="+r.range.start+"-"+r.range.end),s=o.tokenAuthentication.setTokenInRequestHeader(s),s.send(null);else if(r.range.start=c-8,r.range.end=r.range.start+v,o.debug.log("Found the SIDX box.  Start: "+r.range.start+" | End: "+r.range.end),p=new ArrayBuffer(r.range.end-r.range.start),it=new Uint8Array(p),tt=new Uint8Array(i,r.range.start,r.range.end-r.range.start),it.set(tt),ut=this.parseSIDX.call(this,p,r.range.start),h=ut.references,h!==null&&h!==undefined&&h.length>0&&(ft=h[0].type===1),ft){o.debug.log("Initiate multiple SIDX load.");for(var et,ot,st,g=[],ht=0,ct=function(n){n?(g=g.concat(n),ht+=1,ht>=d&&e.call(o,g)):e.call(o)},l=0,d=h.length;l<d;l+=1)et=h[l].offset,ot=h[l].offset+h[l].size-1,st=et+"-"+ot,u.call(o,f,null,st,ct)}else o.debug.log("Parsing segments from SIDX."),nt=n.call(o,p,r.url,r.range.start),e.call(o,nt)},u=function(i,r,u,f){var o=new XMLHttpRequest,l,h,a=i.adaptation.period.mpd.manifest.Period_asArray[i.adaptation.period.index].AdaptationSet_asArray[i.adaptation.index].Representation_asArray[i.index].BaseURL,c=!0,s=this,e={url:a,range:{},searching:!1,bytesLoaded:0,bytesToLoad:1500,request:o};u===null?(s.debug.log("No known range for SIDX request."),e.searching=!0,e.range.start=0,e.range.end=e.bytesToLoad):(h=u.split("-"),e.range.start=parseFloat(h[0]),e.range.end=parseFloat(h[1]));o.onload=function(){o.status<200||o.status>299||(c=!1,e.searching?(e.bytesLoaded=e.range.end,t.call(s,o.response,e,i,function(n){n&&f.call(s,n,i,r)})):(l=n.call(s,o.response,e.url,e.range.start),f.call(s,l,i,r)))};o.onloadend=o.onerror=function(){c&&(c=!1,s.errHandler.downloadError("SIDX",e.url,o),f.call(s,null,i,r))};o.open("GET",s.tokenAuthentication.addTokenAsQueryArg(e.url));o.responseType="arraybuffer";o.setRequestHeader("Range","bytes="+e.range.start+"-"+e.range.end);o=s.tokenAuthentication.setTokenInRequestHeader(o);o.send(null);s.debug.log("Perform SIDX load: "+e.url)},e=function(n,t,i){var r=this;n?r.notify(r.eventList.ENAME_SEGMENTS_LOADED,n,t,i):r.notify(r.eventList.ENAME_SEGMENTS_LOADED,null,t,i,new Error("error loading segments"))};return{debug:undefined,errHandler:undefined,tokenAuthentication:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_INITIALIZATION_LOADED:"initializationLoaded",ENAME_SEGMENTS_LOADED:"segmentsLoaded"},loadSegments:function(n,t,i){u.call(this,n,t,i,e.bind(this))},loadInitialization:f,parseSegments:n,parseSIDX:i,findSIDX:t}};Dash.dependencies.BaseURLExtensions.prototype={constructor:Dash.dependencies.BaseURLExtensions};Dash.dependencies.DashHandler=function(){"use strict";var n=-1,u,t,i,s=0,f=function(n,t){while(n.length<t)n="0"+n;return n},r=function(n,t,i){for(var r=0,u=0,h=t.length,c="%0",a=c.length,s,l,o,e;;){if((r=n.indexOf("$"+t),r<0)||(u=n.indexOf("$",r+h),u<0))return n;if(s=n.indexOf(c,r+h),s>r&&s<u){l=n.charAt(u-1);o=parseInt(n.substring(s+a,u-1),10);switch(l){case"d":case"i":case"u":e=f(i.toString(),o);break;case"x":e=f(i.toString(16),o);break;case"X":e=f(i.toString(16),o).toUpperCase();break;case"o":e=f(i.toString(8),o);break;default:return this.debug.log("Unsupported/invalid IEEE 1003.1 format identifier string in URL"),n}}else e=i;n=n.substring(0,r)+e+n.substring(u+1)}},k=function(n){return n.split("$$").join("$")},d=function(n,t){if(t===null||n.indexOf("$RepresentationID$")===-1)return n;var i=t.toString();return n.split("$RepresentationID$").join(i)},h=function(n,t){return n.representation.startNumber+t},c=function(n,t){var i=t.adaptation.period.mpd.manifest.Period_asArray[t.adaptation.period.index].AdaptationSet_asArray[t.adaptation.index].Representation_asArray[t.index].BaseURL;return n===i?n:n.indexOf("http://")!==-1?n:i+n},g=function(n,i){var e=this,u,r=new MediaPlayer.vo.SegmentRequest,f;return u=n.adaptation.period,r.streamType=i,r.type="Initialization Segment",r.url=c(n.initialization,n),r.range=n.range,f=u.start,r.availabilityStartTime=e.timelineConverter.calcAvailabilityStartTimeFromPresentationTime(f,n.adaptation.period.mpd,t),r.availabilityEndTime=e.timelineConverter.calcAvailabilityEndTimeFromPresentationTime(f+u.duration,u.mpd,t),r.quality=n.index,r},nt=function(n){var t=this;return n?g.call(t,n,i):null},l=function(i){var u,s=i.adaptation.period,r=!1,f,e;return t?r=!1:n<0?r=!1:n<i.availableSegmentsNumber?(f=o(n,i),f&&(e=f.presentationStartTime-s.start,u=i.adaptation.period.duration,this.debug.log(i.segmentInfoType+": "+e+" / "+u),r=e>=u)):r=!0,r},a=function(n,i){var u=this,r,f,e,o;return f=n.segmentDuration,e=n.adaptation.period.start+i*f,o=e+f,r=new Dash.vo.Segment,r.representation=n,r.duration=f,r.presentationStartTime=e,r.mediaStartTime=u.timelineConverter.calcMediaTimeFromPresentationTime(r.presentationStartTime,n),r.availabilityStartTime=u.timelineConverter.calcAvailabilityStartTimeFromPresentationTime(r.presentationStartTime,n.adaptation.period.mpd,t),r.availabilityEndTime=u.timelineConverter.calcAvailabilityEndTimeFromPresentationTime(o,n.adaptation.period.mpd,t),r.wallStartTime=u.timelineConverter.calcWallTimeForSegment(r,t),r.replacementNumber=h(r,i),r.availabilityIdx=i,r},tt=function(n){var r=this,g=n.adaptation.period.mpd.manifest.Period_asArray[n.adaptation.period.index].AdaptationSet_asArray[n.adaptation.index].Representation_asArray[n.index].SegmentTemplate,st=g.SegmentTimeline,l=n.availableSegmentsNumber>0,a=[],s,t,h,nt,w,f,b,v,e=0,p=0,o=-1,c,k,tt,it,ut,i,ft=function(t){return y.call(r,n,e,t.d,i,g.media,t.mediaRange,o)},et,ot,d;for(i=n.timescale,s=st.S_asArray,c=rt.call(r,n),c?(it=c.start,ut=c.end):tt=r.timelineConverter.calcMediaTimeFromPresentationTime(u||0,n),h=0,nt=s.length;h<nt;h+=1){if(t=s[h],f=0,t.hasOwnProperty("r")&&(f=t.r),t.hasOwnProperty("t")&&(e=t.t,p=e/i),f<0&&(v=s[h+1],v&&v.hasOwnProperty("t")?b=v.t/i:(b=r.timelineConverter.calcMediaTimeFromPresentationTime(n.segmentAvailabilityRange.end,n),n.segmentDuration=t.d/i),f=Math.ceil((b-p)/(t.d/i))-1),k){if(l)break;o+=f+1;continue}for(w=0;w<=f;w+=1){if(o+=1,c){if(o>ut){if(k=!0,l)break;continue}o>=it&&a.push(ft.call(r,t))}else{if(a.length>10){if(k=!0,l)break;continue}p>=tt-t.d/i&&a.push(ft.call(r,t))}e+=t.d;p=e/i}}return l||(d=s[0],et=d.t===undefined?0:r.timelineConverter.calcPresentationTimeFromMediaTime(d.t/i,n),ot=r.timelineConverter.calcPresentationTimeFromMediaTime((e-t.d)/i,n),n.segmentAvailabilityRange={start:et,end:ot},n.availableSegmentsNumber=o+1),a},it=function(n){var e=[],o=this,y=n.adaptation.period.mpd.manifest.Period_asArray[n.adaptation.period.index].AdaptationSet_asArray[n.adaptation.index].Representation_asArray[n.index].SegmentTemplate,p=n.segmentDuration,s=n.segmentAvailabilityRange,f,u,h,c,t=null,l,i=null;for(l=n.startNumber,f=v.call(o,n),h=f.start,c=f.end,u=h;u<=c;u+=1)t=a.call(o,n,u),t.replacementTime=(l+u-1)*n.segmentDuration,i=y.media,i=r(i,"Number",t.replacementNumber),i=r(i,"Time",t.replacementTime),t.media=i,e.push(t),t=null;return n.availableSegmentsNumber=Math.ceil((s.end-s.start)/p),e},v=function(i){var e=this,r=i.segmentDuration,y=i.adaptation.period.mpd.manifest.minBufferTime,a=i.segmentAvailabilityRange,f={start:e.timelineConverter.calcPeriodRelativeTimeFromMpdRelativeTime(i,a.start),end:e.timelineConverter.calcPeriodRelativeTimeFromMpdRelativeTime(i,a.end)},c=NaN,l=null,v=i.segments,p=2*r,w=Math.max(2*y,10*r),s,h;return(f||(f=e.timelineConverter.calcSegmentAvailabilityRange(i,t)),t&&!i.adaptation.period.mpd.isClientServerTimeSyncCompleted)?(s=Math.floor(f.start/r),h=Math.floor(f.end/r),{start:s,end:h}):(v?(l=o(n,i),c=l?e.timelineConverter.calcPeriodRelativeTimeFromMpdRelativeTime(i,l.presentationStartTime):n>0?n*r:e.timelineConverter.calcPeriodRelativeTimeFromMpdRelativeTime(i,u||v[0].presentationStartTime)):c=n>0?n*r:t?f.end:f.start,s=Math.floor(Math.max(c-p,f.start)/r),h=Math.floor(Math.min(s+w/r,f.end/r)),{start:s,end:h})},rt=function(i){var r=0,f=Number.POSITIVE_INFINITY,e,o;return t&&!i.adaptation.period.mpd.isClientServerTimeSyncCompleted?{start:r,end:f}:!t&&u||n<0?null:(e=Math.max(n-2,r),o=Math.min(n+10,f),{start:e,end:o})},y=function(n,i,u,f,e,o,s){var l=this,v=i/f,y=Math.min(u/f,n.adaptation.period.mpd.maxSegmentDuration),a,p,c;return a=l.timelineConverter.calcPresentationTimeFromMediaTime(v,n),p=a+y,c=new Dash.vo.Segment,c.representation=n,c.duration=y,c.mediaStartTime=v,c.presentationStartTime=a,c.availabilityStartTime=n.adaptation.period.mpd.manifest.mpdLoadedTime,c.availabilityEndTime=l.timelineConverter.calcAvailabilityEndTimeFromPresentationTime(p,n.adaptation.period.mpd,t),c.wallStartTime=l.timelineConverter.calcWallTimeForSegment(c,t),c.replacementTime=i,c.replacementNumber=h(c,s),e=r(e,"Number",c.replacementNumber),e=r(e,"Time",c.replacementTime),c.media=e,c.mediaRange=o,c.availabilityIdx=s,c},ut=function(n){var e=this,o=[],u=n.adaptation.period.mpd.manifest.Period_asArray[n.adaptation.period.index].AdaptationSet_asArray[n.adaptation.index].Representation_asArray[n.index].SegmentList,l=u.SegmentURL_asArray.length,i,t,r,f,s,h,c;for(c=n.startNumber,f=v.call(e,n),s=Math.max(f.start,0),h=Math.min(f.end,u.SegmentURL_asArray.length-1),i=s;i<=h;i+=1)r=u.SegmentURL_asArray[i],t=a.call(e,n,i),t.replacementTime=(c+i-1)*n.segmentDuration,t.media=r.media,t.mediaRange=r.mediaRange,t.index=r.index,t.indexRange=r.indexRange,o.push(t),t=null;return n.availableSegmentsNumber=l,o},e=function(n){var t,i=this,r=n.segmentInfoType;return r!=="SegmentBase"&&r!=="BaseURL"&&ot.call(i,n)?(r==="SegmentTimeline"?t=tt.call(i,n):r==="SegmentTemplate"?t=it.call(i,n):r==="SegmentList"&&(t=ut.call(i,n)),p.call(i,n,t)):t=n.segments,t},p=function(n,i){var u,r,f;n.segments=i;u=i.length-1;t&&isNaN(n.adaptation.period.liveEdge)&&(r=i[u].presentationStartTime,f=this.metricsModel.getMetricsFor("stream"),n.adaptation.period.liveEdge=r,this.metricsModel.updateManifestUpdateInfo(this.metricsExt.getCurrentManifestUpdate(f),{presentationStartTime:r}))},ft=function(n){var t=this;if(!n)throw new Error("no representation");return n.segments=null,e.call(t,n),n},et=function(r,u){var f=this,e=r.initialization,o=r.segmentInfoType!=="BaseURL"&&r.segmentInfoType!=="SegmentBase";r.segmentAvailabilityRange=f.timelineConverter.calcSegmentAvailabilityRange(r,t);u||(n=-1);ft.call(f,r);e||f.baseURLExt.loadInitialization(r);o||f.baseURLExt.loadSegments(r,i,r.indexRange);e&&o&&f.notify(f.eventList.ENAME_REPRESENTATION_UPDATED,r)},w=function(n,t){var i=t.segments,s=i?i.length-1:null,e=-1,r,f,o,u;if(i&&i.length>0)for(u=s;u>=0;u--)if(r=i[u],f=r.presentationStartTime,o=r.duration,n+Dash.dependencies.DashHandler.EPSILON>=f&&n-Dash.dependencies.DashHandler.EPSILON<=f+o){e=r.availabilityIdx;break}return e},o=function(n,t){if(!t||!t.segments)return null;for(var u=t.segments.length,r,i=0;i<u;i+=1)if(r=t.segments[i],r.availabilityIdx===n)return r;return null},ot=function(t){var r=!1,i=t.segments,u,f;return i?(f=i[0].availabilityIdx,u=i[i.length-1].availabilityIdx,r=n<f||n>u):r=!0,r},b=function(n){if(n===null||n===undefined)return null;var t=new MediaPlayer.vo.SegmentRequest,f=n.representation,e=f.adaptation.period.mpd.manifest.Period_asArray[f.adaptation.period.index].AdaptationSet_asArray[f.adaptation.index].Representation_asArray[f.index].bandwidth,u;return u=c(n.media,f),u=r(u,"Number",n.replacementNumber),u=r(u,"Time",n.replacementTime),u=r(u,"Bandwidth",e),u=d(u,f.id),u=k(u),t.streamType=i,t.type="Media Segment",t.url=u,t.range=n.mediaRange,t.startTime=n.presentationStartTime,t.duration=n.duration,t.timescale=f.timescale,t.availabilityStartTime=n.availabilityStartTime,t.availabilityEndTime=n.availabilityEndTime,t.wallStartTime=n.wallStartTime,t.quality=f.index,t.index=n.availabilityIdx,t},st=function(t,r,f){var h,c,a,v=n,s=this;return t?(u=r,s.debug.log("Getting the request for time: "+r),n=w.call(s,r,t),e.call(s,t),n<0&&(n=w.call(s,r,t)),s.debug.log("Index for time "+r+" is "+n),a=l.call(s,t),a?(h=new MediaPlayer.vo.SegmentRequest,h.action=h.ACTION_COMPLETE,h.index=n,h.streamType=i,s.debug.log("Signal complete."),s.debug.log(h)):(c=o(n,t),h=b.call(s,c)),f&&(n=v),h):null},ht=function(t){var r,h,c,s,f=this;if(!t)return null;if(n===-1)throw"You must call getSegmentRequestForTime first.";return u=null,n+=1,s=n,c=l.call(f,t),c?(r=new MediaPlayer.vo.SegmentRequest,r.action=r.ACTION_COMPLETE,r.index=s,r.streamType=i,f.debug.log("Signal complete.")):(e.call(f,t),h=o(s,t),r=b.call(f,h)),r},ct=function(n,t,i){var f=this,o=Math.max(t-i,0),r,u;if(!n)throw new Error("no represenation");return u=e.call(f,n),r=u[0].duration,Math.ceil(o/r)},lt=function(n,t){t.segments&&this.notify(this.eventList.ENAME_REPRESENTATION_UPDATED,t)},at=function(n,t,r,u,f){if(!f&&i===u){for(var l=this,e,h=[],a=0,c,o=0,s=t.length;o<s;o+=1)e=t[o],c=y.call(l,r,e.startTime,e.duration,e.timescale,e.media,e.mediaRange,a),h.push(c),c=null,a+=1;(r.segmentAvailabilityRange={start:h[0].presentationStartTime,end:h[s-1].presentationStartTime},r.availableSegmentsNumber=s,p.call(l,r,h),r.initialization)&&this.notify(this.eventList.ENAME_REPRESENTATION_UPDATED,r)}};return{debug:undefined,baseURLExt:undefined,timelineConverter:undefined,metricsModel:undefined,metricsExt:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_REPRESENTATION_UPDATED:"representationUpdated"},setup:function(){this.initializationLoaded=lt;this.segmentsLoaded=at},getType:function(){return i},setType:function(n){i=n},getIsDynamic:function(){return t},setIsDynamic:function(n){t=n},setCurrentTime:function(n){s=n},getCurrentTime:function(){return s},getInitRequest:nt,getSegmentRequestForTime:st,getNextSegmentRequest:ht,getSegmentCountForDuration:ct,updateRepresentation:et}};Dash.dependencies.DashHandler.EPSILON=.003;Dash.dependencies.DashHandler.prototype={constructor:Dash.dependencies.DashHandler};Dash.dependencies.DashManifestExtensions=function(){"use strict";this.timelineConverter=undefined};Dash.dependencies.DashManifestExtensions.prototype={constructor:Dash.dependencies.DashManifestExtensions,getIsTypeOf:function(n,t){"use strict";var i,u,e=n.ContentComponent_asArray,s=t!=="text"?new RegExp(t):new RegExp("(vtt|ttml)"),o,f=!1,r=!1;if(e)for(i=0,u=e.length;i<u;i+=1)e[i].contentType===t&&(f=!0,r=!0);if(n.hasOwnProperty("mimeType")&&(f=s.test(n.mimeType),r=!0),!r)for(i=0,u=n.Representation_asArray.length;!r&&i<u;)o=n.Representation_asArray[i],o.hasOwnProperty("mimeType")&&(f=s.test(o.mimeType),r=!0),i+=1;return f},getIsAudio:function(n){"use strict";return this.getIsTypeOf(n,"audio")},getIsVideo:function(n){"use strict";return this.getIsTypeOf(n,"video")},getIsText:function(n){"use strict";return this.getIsTypeOf(n,"text")},getIsTextTrack:function(n){return n==="text/vtt"||n==="application/ttml+xml"},getIsMain:function(){"use strict";return!1},processAdaptation:function(n){"use strict";return n.Representation_asArray!==undefined&&n.Representation_asArray!==null&&n.Representation_asArray.sort(function(n,t){return n.bandwidth-t.bandwidth}),n},getDataForId:function(n,t,i){"use strict";for(var u=t.Period_asArray[i].AdaptationSet_asArray,r=0,f=u.length;r<f;r+=1)if(u[r].hasOwnProperty("id")&&u[r].id===n)return u[r];return null},getDataForIndex:function(n,t,i){"use strict";var r=t.Period_asArray[i].AdaptationSet_asArray;return r[n]},getDataIndex:function(n,t,i){"use strict";for(var u=t.Period_asArray[i].AdaptationSet_asArray,r=0,f=u.length;r<f;r+=1)if(u[r]===n)return r;return-1},getDatasForType:function(n,t,i){"use strict";for(var o=this,u=n.Period_asArray[t].AdaptationSet_asArray,e=[],r=0,f=u.length;r<f;r+=1)this.getIsTypeOf(u[r],i)&&e.push(o.processAdaptation(u[r]));return e},getDataForType:function(n,t,i){"use strict";var u,f,r,e=this;if(r=this.getDatasForType(n,t,i),!r||r.length===0)return null;for(u=0,f=r.length;u<f;u+=1)if(e.getIsMain(r[u]))return r[u];return r[0]},getCodec:function(n){"use strict";var t=n.Representation_asArray[0];return t.mimeType+';codecs="'+t.codecs+'"'},getMimeType:function(n){"use strict";return n.Representation_asArray[0].mimeType},getKID:function(n){"use strict";return!n||!n.hasOwnProperty("cenc:default_KID")?null:n["cenc:default_KID"]},getContentProtectionData:function(n){"use strict";return!n||!n.hasOwnProperty("ContentProtection_asArray")||n.ContentProtection_asArray.length===0?null:n.ContentProtection_asArray},getIsDynamic:function(n){"use strict";var t=!1;return n.hasOwnProperty("type")&&(t=n.type==="dynamic"),t},getIsDVR:function(n){"use strict";var i=this.getIsDynamic(n),t;return t=!isNaN(n.timeShiftBufferDepth),i&&t},getIsOnDemand:function(n){"use strict";var t=!1;return n.profiles&&n.profiles.length>0&&(t=n.profiles.indexOf("urn:mpeg:dash:profile:isoff-on-demand:2011")!==-1),t},getDuration:function(n){return n.hasOwnProperty("mediaPresentationDuration")?n.mediaPresentationDuration:Number.POSITIVE_INFINITY},getBandwidth:function(n){"use strict";return n.bandwidth},getRefreshDelay:function(n){"use strict";var t=NaN;return n.hasOwnProperty("minimumUpdatePeriod")&&(t=Math.max(parseFloat(n.minimumUpdatePeriod),2)),t},getRepresentationCount:function(n){"use strict";return n.Representation_asArray.length},getRepresentationFor:function(n,t){"use strict";return t.Representation_asArray[n]},getRepresentationsForAdaptation:function(n,t){for(var o=this,s=o.processAdaptation(n.Period_asArray[t.period.index].AdaptationSet_asArray[t.index]),h=[],i,f,r,u,e=0;e<s.Representation_asArray.length;e+=1)u=s.Representation_asArray[e],i=new Dash.vo.Representation,i.index=e,i.adaptation=t,u.hasOwnProperty("id")&&(i.id=u.id),u.hasOwnProperty("SegmentBase")?(r=u.SegmentBase,i.segmentInfoType="SegmentBase"):u.hasOwnProperty("SegmentList")?(r=u.SegmentList,i.segmentInfoType="SegmentList",i.useCalculatedLiveEdgeTime=!0):u.hasOwnProperty("SegmentTemplate")?(r=u.SegmentTemplate,i.segmentInfoType=r.hasOwnProperty("SegmentTimeline")?"SegmentTimeline":"SegmentTemplate",r.hasOwnProperty("initialization")&&(i.initialization=r.initialization.split("$Bandwidth$").join(u.bandwidth).split("$RepresentationID$").join(u.id))):(r=u.BaseURL,i.segmentInfoType="BaseURL"),r.hasOwnProperty("Initialization")?(f=r.Initialization,f.hasOwnProperty("sourceURL")?i.initialization=f.sourceURL:f.hasOwnProperty("range")&&(i.initialization=u.BaseURL,i.range=f.range)):u.hasOwnProperty("mimeType")&&o.getIsTextTrack(u.mimeType)&&(i.initialization=u.BaseURL,i.range=0),r.hasOwnProperty("timescale")&&(i.timescale=r.timescale),r.hasOwnProperty("duration")&&(i.segmentDuration=r.duration/i.timescale),r.hasOwnProperty("startNumber")&&(i.startNumber=r.startNumber),r.hasOwnProperty("indexRange")&&(i.indexRange=r.indexRange),r.hasOwnProperty("presentationTimeOffset")&&(i.presentationTimeOffset=r.presentationTimeOffset/i.timescale),i.MSETimeOffset=o.timelineConverter.calcMSETimeOffset(i),h.push(i);return h},getAdaptationsForPeriod:function(n,t){for(var f=n.Period_asArray[t.index],u=[],i,r=0;r<f.AdaptationSet_asArray.length;r+=1)i=new Dash.vo.AdaptationSet,i.index=r,i.period=t,u.push(i);return u},getRegularPeriods:function(n,t){for(var o=this,e=[],c=o.getIsDynamic(n),h=null,r=null,u=null,i=null,f=0,s=n.Period_asArray.length;f<s;f+=1)r=n.Period_asArray[f],r.hasOwnProperty("start")?(i=new Dash.vo.Period,i.start=r.start):h!==null&&r.hasOwnProperty("duration")?(i=new Dash.vo.Period,i.start=u.start+u.duration,i.duration=r.duration):f!==0||c||(i=new Dash.vo.Period,i.start=0),u!==null&&isNaN(u.duration)&&(u.duration=i.start-u.start),i!==null&&r.hasOwnProperty("id")&&(i.id=r.id),i!==null&&r.hasOwnProperty("duration")&&(i.duration=r.duration),i!==null&&(i.index=f,i.mpd=t,e.push(i)),h=r,r=null,u=i,i=null;return e.length===0?e:(t.checkTime=o.getCheckTime(n,e[0]),u!==null&&isNaN(u.duration)&&(u.duration=o.getEndTimeForLastPeriod(t)-u.start),e)},getMpd:function(n){var t=new Dash.vo.Mpd;return t.manifest=n,t.availabilityStartTime=n.hasOwnProperty("availabilityStartTime")?new Date(n.availabilityStartTime.getTime()):new Date(n.mpdLoadedTime.getTime()),n.hasOwnProperty("availabilityEndTime")&&(t.availabilityEndTime=new Date(n.availabilityEndTime.getTime())),n.hasOwnProperty("suggestedPresentationDelay")&&(t.suggestedPresentationDelay=n.suggestedPresentationDelay),n.hasOwnProperty("timeShiftBufferDepth")&&(t.timeShiftBufferDepth=n.timeShiftBufferDepth),n.hasOwnProperty("maxSegmentDuration")&&(t.maxSegmentDuration=n.maxSegmentDuration),t},getFetchTime:function(n,t){return this.timelineConverter.calcPresentationTimeFromWallTime(n.mpdLoadedTime,t)},getCheckTime:function(n,t){var u=this,i=NaN,r;return n.hasOwnProperty("minimumUpdatePeriod")&&(r=u.getFetchTime(n,t),i=r+n.minimumUpdatePeriod),i},getEndTimeForLastPeriod:function(n){var t;if(n.manifest.mediaPresentationDuration)t=n.manifest.mediaPresentationDuration;else if(isNaN(n.checkTime))throw new Error("Must have @mediaPresentationDuration or @minimumUpdatePeriod on MPD or an explicit @duration on the last period.");else t=n.checkTime;return t},getEventsForPeriod:function(n,t){var s=n.Period_asArray,r=s[t.index].EventStream_asArray,o=[],i,f,u,e;if(r)for(i=0;i<r.length;i+=1){if(f=new Dash.vo.EventStream,f.period=t,f.timescale=1,r[i].hasOwnProperty("schemeIdUri"))f.schemeIdUri=r[i].schemeIdUri;else throw"Invalid EventStream. SchemeIdUri has to be set";for(r[i].hasOwnProperty("timescale")&&(f.timescale=r[i].timescale),r[i].hasOwnProperty("value")&&(f.value=r[i].value),u=0;u<r[i].Event_asArray.length;u+=1)e=new Dash.vo.Event,e.presentationTime=0,e.eventStream=f,r[i].Event_asArray[u].hasOwnProperty("presentationTime")&&(e.presentationTime=r[i].Event_asArray[u].presentationTime),r[i].Event_asArray[u].hasOwnProperty("duration")&&(e.duration=r[i].Event_asArray[u].duration),r[i].Event_asArray[u].hasOwnProperty("id")&&(e.id=r[i].Event_asArray[u].id),o.push(e)}return o},getEventStreamForAdaptationSet:function(n){var u=[],i=n.InbandEventStream_asArray,t,r;if(i)for(t=0;t<i.length;t+=1){if(r=new Dash.vo.EventStream,r.timescale=1,i[t].hasOwnProperty("schemeIdUri"))r.schemeIdUri=i[t].schemeIdUri;else throw"Invalid EventStream. SchemeIdUri has to be set";i[t].hasOwnProperty("timescale")&&(r.timescale=i[t].timescale);i[t].hasOwnProperty("value")&&(r.value=i[t].value);u.push(r)}return u},getEventStreamForRepresentation:function(n,t){var f=[],r=n.Representation_asArray[t.index].InbandEventStream_asArray,i,u;if(r)for(i=0;i<r.length;i++){if(u=new Dash.vo.EventStream,u.timescale=1,u.representation=t,r[i].hasOwnProperty("schemeIdUri"))u.schemeIdUri=r[i].schemeIdUri;else throw"Invalid EventStream. SchemeIdUri has to be set";r[i].hasOwnProperty("timescale")&&(u.timescale=r[i].timescale);r[i].hasOwnProperty("value")&&(u.value=r[i].value);f.push(u)}return f}};Dash.dependencies.DashMetricsExtensions=function(){"use strict";var n=function(n,t){for(var o,s,f,h,e,u,i,r=0;r<n.length;r=r+1)for(o=n[r],f=o.AdaptationSet_asArray,u=0;u<f.length;u=u+1)for(s=f[u],e=s.Representation_asArray,i=0;i<e.length;i=i+1)if(h=e[i],t===h.id)return i;return-1},t=function(n,t){for(var s,h,f,e,o,r,u,i=0;i<n.length;i=i+1)for(s=n[i],f=s.AdaptationSet_asArray,r=0;r<f.length;r=r+1)for(h=f[r],o=h.Representation_asArray,u=0;u<o.length;u=u+1)if(e=o[u],t===e.id)return e;return null},i=function(n,t){return this.manifestExt.getIsTypeOf(n,t)},r=function(n,t){for(var o,f,e,s,u,r=0;r<n.length;r=r+1)for(o=n[r],e=o.AdaptationSet_asArray,u=0;u<e.length;u=u+1)if(f=e[u],s=f.Representation_asArray,i.call(this,f,t))return s.length;return-1},u=function(n){var r=this,u=r.manifestModel.getValue(),i,f=u.Period_asArray;return(i=t.call(r,f,n),i===null)?null:i.bandwidth},f=function(t){var i=this,r=i.manifestModel.getValue(),u=r.Period_asArray;return n.call(i,u,t)},e=function(n){var t=this,i=t.manifestModel.getValue(),u=i.Period_asArray;return r.call(this,u,n)},o=function(n){if(n===null)return null;var t=n.RepSwitchList,i,r;return t===null||t.length<=0?null:(i=t.length,r=i-1,t[r])},s=function(n){if(n===null)return null;var t=n.BufferLevel,i,r;return t===null||t.length<=0?null:(i=t.length,r=i-1,t[r])},h=function(n){if(n===null)return null;var i=n.PlayList,t;return i===null||i.length<=0?null:(t=i[i.length-1].trace,t===null||t.length<=0)?null:t[t.length-1].playbackspeed},c=function(n){if(n===null)return null;var t=n.HttpList,r,i,u=null;if(t===null||t.length<=0)return null;for(r=t.length,i=r-1;i>0;){if(t[i].responsecode){u=t[i];break}i-=1}return u},l=function(n){return n===null?[]:!n.HttpList?[]:n.HttpList},a=function(n){if(n===null)return null;var t=n.DroppedFrames,i,r;return t===null||t.length<=0?null:(i=t.length,r=i-1,t[r])},v=function(n){if(n===null)return null;var t=n.SchedulingInfo,i,r;return t===null||t.length<=0?null:(i=t.length,r=i-1,t[r])},y=function(n){if(n===null)return null;var t=n.ManifestUpdate,i,r;return t===null||t.length<=0?null:(i=t.length,r=i-1,t[r])},p=function(n){if(n===null)return null;var t=n.DVRInfo,i;return t===null||t.length<=0?null:(i=t.length-1,t[i])};return{manifestModel:undefined,manifestExt:undefined,getBandwidthForRepresentation:u,getIndexForRepresentation:f,getMaxIndexForBufferType:e,getCurrentRepresentationSwitch:o,getCurrentBufferLevel:s,getCurrentPlaybackRate:h,getCurrentHttpRequest:c,getHttpRequests:l,getCurrentDroppedFrames:a,getCurrentSchedulingInfo:v,getCurrentDVRInfo:p,getCurrentManifestUpdate:y}};Dash.dependencies.DashMetricsExtensions.prototype={constructor:Dash.dependencies.DashMetricsExtensions};Dash.dependencies.DashParser=function(){"use strict";var u=31536e3,f=2592e3,e=86400,o=3600,n=60,s=60,t=1e3,i=/^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/,r=/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2})(?::([0-9]*)(\.[0-9]*)?)?(?:([+-])([0-9]{2})([0-9]{2}))?/,h=/^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$/,c=[{type:"duration",test:function(n){return i.test(n)},converter:function(t){var r=i.exec(t);return parseFloat(r[2]||0)*u+parseFloat(r[4]||0)*f+parseFloat(r[6]||0)*e+parseFloat(r[8]||0)*o+parseFloat(r[10]||0)*n+parseFloat(r[12]||0)}},{type:"datetime",test:function(n){return r.test(n)},converter:function(i){var u=r.exec(i),f,e;return f=Date.UTC(parseInt(u[1],10),parseInt(u[2],10)-1,parseInt(u[3],10),parseInt(u[4],10),parseInt(u[5],10),u[6]&&parseInt(u[6],10)||0,u[7]&&parseFloat(u[7])*t||0),u[9]&&u[10]&&(e=parseInt(u[9],10)*s+parseInt(u[10],10),f+=(u[8]==="+"?-1:1)*e*n*t),new Date(f)}},{type:"numeric",test:function(n){return h.test(n)},converter:function(n){return parseFloat(n)}}],l=function(){var n,t,i,r;return r=[{name:"profiles",merge:!1},{name:"width",merge:!1},{name:"height",merge:!1},{name:"sar",merge:!1},{name:"frameRate",merge:!1},{name:"audioSamplingRate",merge:!1},{name:"mimeType",merge:!1},{name:"segmentProfiles",merge:!1},{name:"codecs",merge:!1},{name:"maximumSAPPeriod",merge:!1},{name:"startsWithSap",merge:!1},{name:"maxPlayoutRate",merge:!1},{name:"codingDependency",merge:!1},{name:"scanType",merge:!1},{name:"FramePacking",merge:!0},{name:"AudioChannelConfiguration",merge:!0},{name:"ContentProtection",merge:!0}],n={},n.name="AdaptationSet",n.isRoot=!1,n.isArray=!0,n.parent=null,n.children=[],n.properties=r,t={},t.name="Representation",t.isRoot=!1,t.isArray=!0,t.parent=n,t.children=[],t.properties=r,n.children.push(t),i={},i.name="SubRepresentation",i.isRoot=!1,i.isArray=!0,i.parent=t,i.children=[],i.properties=r,t.children.push(i),n},a=function(){var n,t,i,r;return r=[{name:"SegmentBase",merge:!0},{name:"SegmentTemplate",merge:!0},{name:"SegmentList",merge:!0}],n={},n.name="Period",n.isRoot=!1,n.isArray=!0,n.parent=null,n.children=[],n.properties=r,t={},t.name="AdaptationSet",t.isRoot=!1,t.isArray=!0,t.parent=n,t.children=[],t.properties=r,n.children.push(t),i={},i.name="Representation",i.isRoot=!1,i.isArray=!0,i.parent=t,i.children=[],i.properties=r,t.children.push(i),n},v=function(){var i,n,t,r,u;return u=[{name:"BaseURL",merge:!0,mergeFunction:function(n,t){return t.indexOf("http://")===0?t:n+t}}],i={},i.name="mpd",i.isRoot=!0,i.isArray=!0,i.parent=null,i.children=[],i.properties=u,n={},n.name="Period",n.isRoot=!1,n.isArray=!0,n.parent=null,n.children=[],n.properties=u,i.children.push(n),t={},t.name="AdaptationSet",t.isRoot=!1,t.isArray=!0,t.parent=n,t.children=[],t.properties=u,n.children.push(t),r={},r.name="Representation",r.isRoot=!1,r.isArray=!0,r.parent=t,r.children=[],r.properties=u,t.children.push(r),i},y=function(){var n=[];return n.push(l()),n.push(a()),n.push(v()),n},p=function(n,t){var i,e=new X2JS(c,"",!0),o=new ObjectIron(y()),f=new Date,r=null,u=null;try{i=e.xml_str2json(n);r=new Date;i.hasOwnProperty("BaseURL")?(i.BaseURL=i.BaseURL_asArray[0],i.BaseURL.toString().indexOf("http")!==0&&(i.BaseURL=t+i.BaseURL)):i.BaseURL=t;o.run(i);u=new Date;this.debug.log("Parsing complete: ( xml2json: "+(r.getTime()-f.getTime())+"ms, objectiron: "+(u.getTime()-r.getTime())+"ms, total: "+(u.getTime()-f.getTime())/1e3+"s)")}catch(s){return this.errHandler.manifestError("parsing the manifest failed","parse",n),null}return i};return{debug:undefined,errHandler:undefined,parse:p}};Dash.dependencies.DashParser.prototype={constructor:Dash.dependencies.DashParser};Dash.dependencies.FragmentExtensions=function(){"use strict";var n=function(n){for(var i=new DataView(n),t=0,u,f,e,r,o,s;r!=="tfdt"&&t<i.byteLength;){for(e=i.getUint32(t),t+=4,r="",o=0;o<4;o+=1)s=i.getInt8(t),r+=String.fromCharCode(s),t+=1;r!=="moof"&&r!=="traf"&&r!=="tfdt"&&(t+=e-8)}if(t===i.byteLength)throw"Error finding live offset.";return f=i.getUint8(t),this.debug.log("position: "+t),f===0?(t+=4,u=i.getUint32(t,!1)):(t+=e-16,u=utils.Math.to64BitNumber(i.getUint32(t+4,!1),i.getUint32(t,!1))),{version:f,base_media_decode_time:u}},t=function(n){for(var i=new DataView(n),t=0,f,e,o,u,r,s,h;r!=="sidx"&&t<i.byteLength;){for(s=i.getUint32(t),t+=4,r="",u=0;u<4;u+=1)h=i.getInt8(t),r+=String.fromCharCode(h),t+=1;r!=="moof"&&r!=="traf"&&r!=="sidx"?t+=s-8:r==="sidx"&&(t-=8)}return f=i.getUint8(t+8),t+=12,e=i.getUint32(t+4,!1),t+=8,o=f===0?i.getUint32(t,!1):utils.Math.to64BitNumber(i.getUint32(t+4,!1),i.getUint32(t,!1)),{earliestPresentationTime:o,timescale:e}},i=function(t){var r=this,i=new XMLHttpRequest,u,e=!1,f,o;u=t;i.onloadend=function(){e||(f="Error loading fragment: "+u,r.notify(r.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,null,new Error(f)))};i.onload=function(){e=!0;o=n(i.response);r.notify(r.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,o)};i.onerror=function(){f="Error loading fragment: "+u;r.notify(r.eventList.ENAME_FRAGMENT_LOADING_COMPLETED,null,new Error(f))};i.responseType="arraybuffer";i.open("GET",u);i.send(null)};return{debug:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_FRAGMENT_LOADING_COMPLETED:"fragmentLoadingCompleted"},loadFragment:i,parseTFDT:n,parseSIDX:t}};Dash.dependencies.FragmentExtensions.prototype={constructor:Dash.dependencies.FragmentExtensions};Dash.dependencies.RepresentationController=function(){"use strict";var i=null,r=-1,u=!0,n=[],t,o=function(r,e,o){var s=this,c;if(u=!0,s.notify(s.eventList.ENAME_DATA_UPDATE_STARTED),n=h.call(s,r,e),t=f.call(s,s.abrController.getQualityFor(o)),i=r,o!=="video"&&o!=="audio"){s.notify(s.eventList.ENAME_DATA_UPDATE_COMPLETED,i,t);return}for(c=0;c<n.length;c+=1)s.indexHandler.updateRepresentation(n[c],!0)},f=function(t){return n[t]},s=function(){for(var t=0,i=n.length;t<i;t+=1)if(n[t].segmentAvailabilityRange===null||n[t].initialization===null)return!1;return!0},h=function(n,t){var i=this,f,u=i.manifestModel.getValue();return r=i.manifestExt.getDataIndex(n,u,t.index),f=i.manifestExt.getAdaptationsForPeriod(u,t),i.manifestExt.getRepresentationsForAdaptation(u,f[r])},e=function(t){for(var u=this,i,r=0,f=n.length;r<f;r+=1)i=n[r],i.segmentAvailabilityRange=u.timelineConverter.calcSegmentAvailabilityRange(i,t)},c=function(n,r){for(var f=this,e=r,a=f.metricsModel.getMetricsFor("stream"),o=f.metricsExt.getCurrentManifestUpdate(a),h,l=!1,c=0;c<o.representationInfo.length;c+=1)if(h=o.representationInfo[c],h.index===e.index&&h.streamType===f.streamProcessor.getType()){l=!0;break}l||f.metricsModel.addManifestUpdateRepresentationInfo(o,e.id,e.index,e.adaptation.period.index,f.streamProcessor.getType(),e.presentationTimeOffset,e.startNumber,e.segmentInfoType);s()&&(u=!1,f.metricsModel.updateManifestUpdateInfo(o,{latency:t.segmentAvailabilityRange.end-f.streamProcessor.playbackController.getTime()}),this.notify(this.eventList.ENAME_DATA_UPDATE_COMPLETED,i,t))},l=function(n,t){e.call(this,t)},a=function(){e.call(this,!0);this.indexHandler.updateRepresentation(t,!1)},v=function(n,i,r,u){var f=this;i===f.streamProcessor.getType()&&(t=f.getRepresentationForQuality(u))};return{system:undefined,debug:undefined,manifestExt:undefined,manifestModel:undefined,metricsModel:undefined,metricsExt:undefined,bufferExt:undefined,abrController:undefined,timelineConverter:undefined,notify:undefined,subscribe:undefined,unsubscribe:undefined,eventList:{ENAME_DATA_UPDATE_COMPLETED:"dataUpdateCompleted",ENAME_DATA_UPDATE_STARTED:"dataUpdateStarted"},setup:function(){this.qualityChanged=v;this.representationUpdated=c;this.wallclockTimeUpdated=l;this.liveEdgeFound=a},initialize:function(n){this.streamProcessor=n;this.indexHandler=n.indexHandler},getData:function(){return i},getDataIndex:function(){return r},isUpdating:function(){return u},updateData:o,getRepresentationForQuality:f,getCurrentRepresentation:function(){return t}}};Dash.dependencies.RepresentationController.prototype={constructor:Dash.dependencies.RepresentationController};Dash.dependencies.TimelineConverter=function(){"use strict";var n=0,t=!1,i=function(t,i,r,u){return u?r&&i.timeShiftBufferDepth!=Number.POSITIVE_INFINITY?new Date(i.availabilityStartTime.getTime()+(t+i.timeShiftBufferDepth)*1e3):i.availabilityEndTime:r?new Date(i.availabilityStartTime.getTime()+t*1e3-n):i.availabilityStartTime},u=function(n,t,r){return i.call(this,n,t,r)},f=function(n,t,r){return i.call(this,n,t,r,!0)},e=function(n){var t,r=n.mpd.manifest.type==="dynamic",i=parseInt(this.uriQueryFragModel.getURIFragmentData.s);return r?(!isNaN(i)&&i>1262304e3&&(t=i-n.mpd.availabilityStartTime.getTime()/1e3,(t>n.liveEdge||t<n.liveEdge-n.mpd.timeShiftBufferDepth)&&(t=null)),t=t||n.liveEdge):t=!isNaN(i)&&i<n.duration&&i>=0?i:n.start,t},r=function(n,t){return(n.getTime()-t.mpd.availabilityStartTime.getTime())/1e3},o=function(n,t){var i=t.presentationTimeOffset;return n-i},s=function(n,t){var i=t.presentationTimeOffset;return i+n},h=function(n,t){var i,r,u;return t&&(i=n.representation.adaptation.period.mpd.suggestedPresentationDelay,r=n.presentationStartTime+i,u=new Date(n.availabilityStartTime.getTime()+r*1e3)),u},c=function(n,t,i){var u=this,r=u.calcSegmentAvailabilityRange(n,i);return t>=r.start&&t<=r.end?t:Math.max(r.end-n.adaptation.period.mpd.manifest.minBufferTime*2,r.start)},l=function(n,i){var s=n.segmentDuration,u=n.adaptation.period.start,e=u+n.adaptation.period.duration,h={start:u,end:e},o,f;return i?(!t||isNaN(s))&&n.segmentAvailabilityRange?n.segmentAvailabilityRange:(o=n.adaptation.period.mpd.checkTime,f=r(new Date((new Date).getTime()),n.adaptation.period),u=Math.max(f-n.adaptation.period.mpd.timeShiftBufferDepth,0),e=isNaN(o)?f:Math.min(o,f),{start:u,end:e}):h},a=function(n,t){var i=n.adaptation.period.start;return t-i},v=function(n,t){var i=n.adaptation.period.start;return t+i},y=function(i,r){var u=i.streamProcessor.getCurrentRepresentation().adaptation.period,f;u.mpd.isClientServerTimeSyncCompleted||(f=((new Date).getTime()-u.mpd.manifest.mpdLoadedTime.getTime())/1e3,u.mpd.clientServerTimeShift=r-(u.liveEdge+f),u.mpd.isClientServerTimeSyncCompleted=!0,n=u.mpd.clientServerTimeShift*1e3,t=!0)},p=function(n){var t=n.presentationTimeOffset;return-t},w=function(){n=0;t=!1};return{notifier:undefined,uriQueryFragModel:undefined,setup:function(){this.liveEdgeFound=y},calcAvailabilityStartTimeFromPresentationTime:u,calcAvailabilityEndTimeFromPresentationTime:f,calcPresentationTimeFromWallTime:r,calcPresentationTimeFromMediaTime:o,calcPresentationStartTime:e,calcActualPresentationTime:c,calcPeriodRelativeTimeFromMpdRelativeTime:a,calcMpdRelativeTimeFromPeriodRelativeTime:v,calcMediaTimeFromPresentationTime:s,calcSegmentAvailabilityRange:l,calcWallTimeForSegment:h,calcMSETimeOffset:p,reset:w}};Dash.dependencies.TimelineConverter.prototype={constructor:Dash.dependencies.TimelineConverter};Dash.vo.AdaptationSet=function(){"use strict";this.period=null;this.index=-1};Dash.vo.AdaptationSet.prototype={constructor:Dash.vo.AdaptationSet};Dash.vo.Event=function(){"use strict";this.duration=NaN;this.presentationTime=NaN;this.id=NaN;this.messageData="";this.eventStream=null;this.presentationTimeDelta=NaN};Dash.vo.Event.prototype={constructor:Dash.vo.Event};Dash.vo.EventStream=function(){"use strict";this.adaptionSet=null;this.representation=null;this.period=null;this.timescale=1;this.value="";this.schemeIdUri=""};Dash.vo.EventStream.prototype={constructor:Dash.vo.EventStream};Dash.vo.Mpd=function(){"use strict";this.manifest=null;this.suggestedPresentationDelay=0;this.availabilityStartTime=null;this.availabilityEndTime=Number.POSITIVE_INFINITY;this.timeShiftBufferDepth=Number.POSITIVE_INFINITY;this.maxSegmentDuration=Number.POSITIVE_INFINITY;this.checkTime=NaN;this.clientServerTimeShift=0;this.isClientServerTimeSyncCompleted=!1};Dash.vo.Mpd.prototype={constructor:Dash.vo.Mpd};Dash.vo.Period=function(){"use strict";this.id=null;this.index=-1;this.duration=NaN;this.start=NaN;this.mpd=null;this.liveEdge=NaN};Dash.vo.Period.prototype={constructor:Dash.vo.Period};Dash.vo.Representation=function(){"use strict";this.id=null;this.index=-1;this.adaptation=null;this.segmentInfoType=null;this.initialization=null;this.segmentDuration=NaN;this.timescale=1;this.startNumber=1;this.indexRange=null;this.range=null;this.presentationTimeOffset=0;this.MSETimeOffset=NaN;this.segmentAvailabilityRange=null;this.availableSegmentsNumber=0};Dash.vo.Representation.prototype={constructor:Dash.vo.Representation};Dash.vo.Segment=function(){"use strict";this.indexRange=null;this.index=null;this.mediaRange=null;this.media=null;this.duration=NaN;this.replacementTime=null;this.replacementNumber=NaN;this.mediaStartTime=NaN;this.presentationStartTime=NaN;this.availabilityStartTime=NaN;this.availabilityEndTime=NaN;this.availabilityIdx=NaN;this.wallStartTime=NaN;this.representation=null};Dash.vo.Segment.prototype={constructor:Dash.vo.Segment}