(function(){var g={}; var _ = _ || {}
var f=function(window){var TV=function(){this.B=[0,1,2,4,8,16,32,64,128,27,54];this.C=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.l=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.A=new Uint32Array(256);this.o=new Uint32Array(256);this.w=new Uint32Array(0);this.h=this.a=this.j=this.f=null;var a=this.A,b=this.o,c=this.C,d=c[0],e=c[1],f=c[2];c=c[3];var g=this.l,h=g[0],l=g[1],m=g[2];g=g[3];var n=new Uint32Array(256),p=0,q=0,t;for(t=0;256>
t;t++)n[t]=128>t?t<<1:t<<1^283;for(t=0;256>t;t++){var v=q^q<<1^q<<2^q<<3^q<<4;v=v>>>8^v&255^99;a[p]=v;b[v]=p;var z=n[p],A=n[z],D=n[A],G=257*n[v]^16843008*v;d[p]=G<<24|G>>>8;e[p]=G<<16|G>>>16;f[p]=G<<8|G>>>24;c[p]=G;G=16843009*D^65537*A^257*z^16843008*p;h[v]=G<<24|G>>>8;l[v]=G<<16|G>>>16;m[v]=G<<8|G>>>24;g[v]=G;p?(p=z^n[n[n[D^z]]],q^=n[n[q]]):p=q=1}},UV=function(a){a=_.Vj(a);for(var b=new Uint32Array(4),c=0;4>c;c++)b[c]=a.getUint32(4*c);return b},VV=function(){this.a=null},WV=function(){this.j={};
this.l=!1;this.g=new _.J("clpp.crypto")},YV=function(a,b){return function(c){var d,e,f;return _.H(function(g){if(1==g.a){d=c.request||null;if(!(d&&2===d.type&&d.keyInfo&&c.data))return g.D(2);e=d.uris[0];a.g.debug("Decrypting AES-128-encrypted video segment",e);f=c;return _.x(g,XV(a,b,c.data,d.keyInfo,e),3)}2!=g.a&&(f.data=g.f);return g["return"](c)})}},ZV=function(a,b,c){var d,e,f,g,h,l;return _.H(function(m){if(1==m.a){d=_.ck(c);if(e=(new _.dj(c)).ab.endsWith(".drmtoday.com"))f=b.getConfiguration(),
_.Rn(d,f);g=c+JSON.stringify(d.headers);if(a.j[g])return m["return"](a.j[g]);_.C(m,2);return _.x(m,b.getNetworkEngine().fetch(d).S,4)}if(2!=m.a)return h=m.f,a.j[g]=h.data,m["return"](h.data);l=_.E(m);e&&1001===l.code&&412===l.data.status&&a.g.warn("Wrong DRMtoday credentials, server responded with 412.");throw l;})},XV=function(a,b,c,d,e){var f,g,h,l,m;return _.H(function(n){switch(n.a){case 1:return f=new ArrayBuffer(0),_.C(n,2),_.x(n,ZV(a,b,d.url),4);case 4:f=n.f;_.uh(n,3);break;case 2:return g=
_.E(n),a.g.warn("Could not fetch AES key",g),b.onError(new _.N(1,7,7104,null,g)),n["return"](c);case 3:return _.C(n,5),h=a.l?new VV:new TV,_.x(n,h.importKey(f),7);case 7:return _.x(n,h.decrypt(c,d.iv),8);case 8:return l=n.f,n["return"](l);case 5:return m=_.E(n),a.g.warn("Could not decrypt segment data!",e,m),b.onError(new _.N(1,3,3103,null,m)),n["return"](c)}})};
TV.prototype.importKey=function(a){a=UV(a);for(var b=!0,c=0;c<a.length&&b;)b=a[c]===this.w[c],c++;if(b)return new Promise(function(n){return n()});this.w=a;this.a=a.length;if(4!==this.a&&6!==this.a&&8!==this.a)throw Error("Invalid aes key size\x3d"+this.a);this.h=4*(this.a+7);this.f=new Uint32Array(this.h);this.j=new Uint32Array(this.h);b=this.A;var d=this.B;var e=this.l;c=e[0];var f=e[1],g=e[2],h=e[3],l=0,m=0;for(e=0;e<this.h;e++)e<this.a?l=this.f[e]=a[e]:(m=l,0===e%this.a?(m=m<<8|m>>>24,m=b[m>>>
24]<<24|b[m>>>16&255]<<16|b[m>>>8&255]<<8|b[m&255],m^=d[e/this.a|0]<<24):6<this.a&&4===e%this.a&&(m=b[m>>>24]<<24|b[m>>>16&255]<<16|b[m>>>8&255]<<8|b[m&255]),l=(this.f[e-this.a]^m)>>>0,this.f[e]=l);for(a=0;a<this.h;a++)e=this.h-a,m=a&3?this.f[e]:this.f[e-4],this.j[a]=4>a||4>=e?m:c[b[m>>>24]]^f[b[m>>>16&255]]^g[b[m>>>8&255]]^h[b[m&255]],this.j[a]>>>=0;return new Promise(function(n){return n()})};
TV.prototype.decrypt=function(a,b){var c=0,d=this.a+6,e=this.j,f=this.o,g=this.l,h=g[0],l=g[1],m=g[2];g=g[3];var n=UV(b),p=n[0],q=n[1],t=n[2];n=n[3];for(var v=_.Uj(a),z=new Int32Array(v.length),A,D,G,B,F,M,R,ka,U,qa,Ba,Ca,Da,Na=this.G.bind(this);c<v.length;){ka=Na(v[c]);U=Na(v[c+1]);qa=Na(v[c+2]);Ba=Na(v[c+3]);F=ka^e[0];M=Ba^e[1];R=qa^e[2];B=U^e[3];Ca=4;for(Da=1;Da<d;Da++)A=h[F>>>24]^l[M>>16&255]^m[R>>8&255]^g[B&255]^e[Ca],D=h[M>>>24]^l[R>>16&255]^m[B>>8&255]^g[F&255]^e[Ca+1],G=h[R>>>24]^l[B>>16&
255]^m[F>>8&255]^g[M&255]^e[Ca+2],B=h[B>>>24]^l[F>>16&255]^m[M>>8&255]^g[R&255]^e[Ca+3],F=A,M=D,R=G,Ca+=4;A=f[F>>>24]<<24^f[M>>16&255]<<16^f[R>>8&255]<<8^f[B&255]^e[Ca];D=f[M>>>24]<<24^f[R>>16&255]<<16^f[B>>8&255]<<8^f[F&255]^e[Ca+1];G=f[R>>>24]<<24^f[B>>16&255]<<16^f[F>>8&255]<<8^f[M&255]^e[Ca+2];B=f[B>>>24]<<24^f[F>>16&255]<<16^f[M>>8&255]<<8^f[R&255]^e[Ca+3];Ca+=3;z[c]=Na(A^p);z[c+1]=Na(B^q);z[c+2]=Na(G^t);z[c+3]=Na(D^n);p=ka;q=U;t=qa;n=Ba;c+=4}return new Promise(function(zb){var me=z.buffer;var Cf=
me.byteLength,Fg=Cf&&(new DataView(me)).getUint8(Cf-1);me=Fg?me.slice(0,Cf-Fg):me;zb(me)})};TV.prototype.destroy=function(){this.B=this.j=this.f=this.l=this.C=this.o=this.A=this.h=this.a=this.w=null;return new Promise(function(a){return a()})};TV.prototype.G=function(a){return a<<24|(a&65280)<<8|(a&16711680)>>8|a>>>24};VV.prototype.importKey=function(a){var b=this,c;return _.H(function(d){if(1==d.a)return c=b,_.x(d,crypto.subtle.importKey("raw",a,{name:"AES-CBC"},!1,["decrypt"]),2);c.a=d.f;_.y(d)})};VV.prototype.decrypt=function(a,b){var c=this,d;return _.H(function(e){if(1==e.a)return _.x(e,crypto.subtle.decrypt({name:"AES-CBC",iv:b},c.a,a),2);d=e.f;return e["return"](d)})};VV.prototype.destroy=function(){this.a=null;return new Promise(function(a){return a()})};_.w(WV,_.Bu);WV.prototype.f=function(){if(window.crypto&&crypto.subtle){var a=crypto.subtle.decrypt;a=typeof crypto.subtle.importKey===_.oe&&typeof a===_.oe}else a=!1;(this.l=a)||this.g.warn("No WebCrypto APIs found. Will fallback to software AES")};WV.prototype.o=function(a){var b=YV(this,a);a.getNetworkEngine().fd(b)};WV.prototype.a=function(){this.j={}};WV.prototype.id=function(){return"crypto"};_.I("clpp.crypto.CryptoComponent",WV);};
if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
else{_=this.clpp._;(f.call(g,this));}
})();