import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var pB,qB,sB,tB,uB,vB,wB,xB,zB,AB,BB,CB,EB,FB,GB,HB,IB,KB,LB,PB,QB,SB,TB,UB,VB,WB,ZB,$B,aC,fC,gC,hC,iC,jC,kC,lC,mC,oC,rC,sC,xC,yC,zC,AC,BC,DC,EC,FC,HC,JC,KC,LC,MC,NC,OC,PC,QC,RC,SC,TC,VC,aD,dD,iD,kD,$C,lD,mD,nD,oD,pD,qD,wD,xD,yD,zD,AD,CD,DD,ED,FD,BD,ID,LD,KD,MD,JD,ND,OD,PD,QD,UD,ZD,$D,WD,XD,YD,fE,gE,iE,jE,kE,lE,mE,nE,oE,pE,rE,sE,tE,vE,uE,wE,xE,yE,zE,AE,BE,GE,KE,LE,PE,HE,DE,CE,NE,OE,SE,TE,UE,WE,YE,$E,aF,ZE,bF,dF,eF,fF,gF,hF,iF,jF,kF,lF,mF,nF,pF,qF,oF,cF,wF,rF,sF,tF,uF,vF,xF,yF,zF,CF,AF,
BF,DF,EF,LF,MF,OF,PF,QF,RE,SF,VF,TF,UF,WF,XF,YF,ZF,$F,aG,dG,bG,cG,fG,eG,hG,iG,jG,kG,lG,mG,sG,tG,uG,wG,xG,pG,nG,qG,rG,yG,zG,AG,JG,CG,KG,LG,oG,MG,NG,OG,PG,QG,HG,RG,SG,DG,EG,FG,GG,TG,WG,XG,$G,aH,bH,YG,ZG,BG,UG,VG,cH,dH,eH,fH,gH,hH,iH,jH,kH,lH,mH,oH,nH,pH,qH,EE,FE,CH,IE,JE,ME,FH,HH,IH,NH,OH,LH,JH,QH,RH,VH,YH,bI,oI,pI,rI,sI,tI,uI,vI,KH,MH,CI,EI,qI,SH,UH,WH,XH,xI,aI,cI,dI,uH,QE,AH,fI,gI,jI,kI,lI,mI,nI,$H,zH,LI,II,ZI,rH,sH,tH,aJ,EH,vH,wH,xH,BH,cJ,FI,eJ,bJ,JI,$I,HI,WI,XI,dJ,fJ,NI,OI,MI,gJ,GI,hJ,iJ,jJ,kJ,
lJ,mJ,bC,qJ,TH,TI,vD,GD,HD,tJ,uJ,vJ,PI,QI,SI,aE,DI,BI,XE;pB=" buffer";qB="\x3c/DATA\x3e\x3c/WRMHEADER\x3e";_.rB="AUDIO";sB="Cannot get segment, period ID unknown";tB="Choosing new streams after key status change";uB="IterateSegmentReference";vB="Jumping forward";wB="MediaSource threw QuotaExceededError:";xB="Period not found.";_.yB="Player is in ERROR state and can not switch to ";zB="PrestoPlay TextTrack";AB="Removing audio from variant - audio not compatible with platform";BB="Setting playback rate to\x3d";
CB="URI-REPLACEMENT";_.DB="Updating manifest...";EB="X-Playback-Session-Id";FB="bufferBehind\x3d";GB="bufferedBehind\x3d";HB="calling onCanSwitch()...";IB="cannot find segment";_.JB="caption";KB="clpp.mse.Player";LB="currentPeriod.startTime\x3d";_.MB="dashif:Laurl";_.NB="getSegmentNextReference";_.OB="iterateSegmentReference";PB="key-restriction";QB="manifest.start";_.RB="onChooseStreams_";SB="presentationTime:";TB="presentationTime\x3d";UB="reference.endTime\x3d";VB="reference.position\x3d";WB="reference.startTime\x3d";
_.XB="subtitle";_.YB="subtitles";ZB="switch: Stream ";$B=function(a,b,c=0){if(!a.length||1===a.length&&1E-6>a.end(0)-a.start(0))return null;for(let d=0;d<a.length;d++)if(a.start(d)>b&&(0===d||a.end(d-1)-b<=c))return d;return null};aC=function(a){const b=a.a+a.f.byteOffset;let c=void 0;for(;_.Yl(a);)if(0===_.$l(a)){c=a.a+a.f.byteOffset-1;break}a=a.f.buffer.slice(b,c);return _.Ui(a)};
_.cC=function(a){const b=new Uint8Array(bC),c=4+b.byteLength+a.j.byteLength+4+a.f.byteLength,d=new _.qm(c,!1);_.O(d,c);_.Xl(d,b);_.Xl(d,a.j);_.O(d,a.f.byteLength);_.Xl(d,a.f);return _.K(d.buffer)};
_.dC=function(a,b,c,d){var e=_.Kl(b);if(8!==e.byteLength)e="";else{var f=_.nn(e);e=_.Hl(f);b:switch(f=f.byteLength,_.qh("Trying to create PlayReady header in version",a),a){case "4.0.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,"\x3cDATA\x3e\x3cPROTECTINFO\x3e",`<KEYLEN>${f}</KEYLEN>`,"\x3cALGID\x3eAESCTR\x3c/ALGID\x3e\x3c/PROTECTINFO\x3e",`<KID>${e}</KID>`,c?`<CHECKSUM>${c}</CHECKSUM>`:"",d?`<LA_URL>${d}</LA_URL>`:"",qB].join("");break b;
case "4.1.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,'\x3cDATA\x3e\x3cPROTECTINFO\x3e\x3cKID ALGID\x3d"AESCTR" ',c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:"",qB].join("");break b;case "4.2.0.0":case "4.3.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,'\x3cDATA\x3e\x3cPROTECTINFO\x3e\x3cKIDS\x3e\x3cKID ALGID\x3d"AESCTR" ',
c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/KIDS\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:"",qB].join("");break b;default:_.C("Cannot create PlayReady header in version",a),e=""}}if(!e)return null;_.qh("New payload",e);e=_.K(_.Zi(e,!0));return new _.rn(_.sn,b,d||null,e,a,c)};_.eC=function(a,b){return b===a.version?a:_.dC(b,a.a,a.l||void 0,a.h||void 0)};
fC=function(a,b){a:{if(b)for(const c of a.h.keys()){const d=a.h.get(c);for(let e=0;e<d.lb.length;e++)if(d.lb[e]===b){a=d;break a}}a=null}return a?a.hb:null};gC=function(a,b){if(_.uk("Edge/"))return!0;b=b.toLowerCase();if(_.vk()&&b.includes('codecs\x3d"ac-3"')){const c=b.replace("ac-3",_.Pd);return a.J.has(b)||a.J.has(c)}return a.J.has(b)};hC=function(a,b){a=a.o.get(b);return!(!a||a!==_.Me&&a!==_.ce)};
iC=function(a,b){var c=b.audio,d=b.video;if(c&&c.encrypted&&(c=_.Dn(c),!gC(a,c))||d&&d.encrypted&&(d=_.Dn(d),!gC(a,d)))return!1;const e=a.keySystem();return 0===b.drmInfos.length||b.drmInfos.some(f=>f.keySystem===e)};jC=function(a,b,c){a.f!==b&&(a.f=b,a.a.push({timestamp:Date.now()/1E3,id:b.id,trackId:b.track.id,type:b.track.type,fromAdaptation:c,width:null,height:null,bandwidth:b.bandwidth}))};kC=function(a,b){return null==a.a?null:(a=a.a[a.a.length-1])?a[b]:null};
lC=function(a){a=kC(a,_.sv);return null==a?null:a};mC=function(a,b){if(a.a.length)if(0>b)a.f=0;else{for(var c=0,d=a.a[c]||null;d&&b>d.Rb()+d.getDuration();)c+=1,d=a.a[c]||null;a.f=d?c:a.a.length-1}else a.f=-1};_.nC=function(a,b){return a.concat(b)};oC=function(){};_.pC=function(a,b){if(0===b.length)return a;const c=b.map(d=>new _.mi(d));return a.map(d=>new _.mi(d)).map(d=>c.map(d.resolve.bind(d))).reduce(_.nC,[]).map(d=>d.toString())};
_.qC=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[],keyIds:[],periodId:c?c:null}};rC=function(a,b){a=_.Bi(a);b=_.Bi(b);a=a.split("-");b=b.split("-");return a[0]===b[0]&&1===a.length&&2===b.length};sC=function(a){return a.language?_.Bi(a.language):a.audio&&a.audio.language?_.Bi(a.audio.language):a.video&&a.video.language?_.Bi(a.video.language):_.dg};
_.tC=function(a,b){a=_.Bi(a);const c=new Set;for(var d of b)c.add(_.Bi(d));for(const e of c)if(e===a)return e;for(const e of c)if(rC(e,a))return e;for(const e of c)if(d=e,b=a,d=_.Bi(d),b=_.Bi(b),d=d.split("-"),b=b.split("-"),b=2===d.length&&2===b.length&&d[0]===b[0])return e;for(const e of c)if(rC(a,e))return e;return null};
_.uC=function(a){if(typeof a!==_.Nf)return null;var b=a.trim().match(/^(\d+)x(\d+)$/);if(!b)return null;a=parseInt(b[1],10);b=parseInt(b[2],10);return 0>=a||0>=b?null:{ld:a,Fd:b,Gi:a*b}};
_.vC=function(a,b){if(!a.length)return b;if(!b.length)return a;const c=[];for(let e=0;e<a.length;e++)for(var d=0;d<b.length;d++)if(a[e].keySystem===b[d].keySystem&&a[e].periodId===b[d].periodId){const f=a[e];d=b[d];let g=[];g=g.concat(f.initData||[]);g=g.concat(d.initData||[]);const h=[...f.keyIds||[]];d.keyIds&&d.keyIds.length&&d.keyIds.forEach(k=>{h.includes(k)||h.push(k)});c.push({keySystem:f.keySystem,licenseServerUri:f.licenseServerUri||d.licenseServerUri,licenseServerUriOrigin:f.licenseServerUriOrigin||
d.licenseServerUriOrigin,distinctiveIdentifierRequired:f.distinctiveIdentifierRequired||d.distinctiveIdentifierRequired,persistentStateRequired:f.persistentStateRequired||d.persistentStateRequired,videoRobustness:f.videoRobustness||d.videoRobustness,audioRobustness:f.audioRobustness||d.audioRobustness,serverCertificate:f.serverCertificate||d.serverCertificate,initData:g,keyIds:h,periodId:f.periodId});break}return c};_.wC=function(a,b){return a.length&&b.length?0<_.vC(a,b).length:!0};
xC=function(a,b){for(const c in b)if(b[c]===a)return c;return""};yC=function(a,b){let c=0;for(const d of a)c+=b(d)?1:0;return c};zC=function(a,b){var c=_.lk(b,a);if(!c)return!1;c=c();a=c.isMuxed(a,b);c.destroy();return a};AC=function(a){const b=[a.mimeType];for(const c of _.pu){const [d,e]=c;{const f=a[d];null!=f&&b.push(e.trim()+'\x3d"'+String(f).trim()+'"')}}return b.join(";").replace(/\s/g,"")};BC=function(a){return a.split(",").map(b=>b.trim()).filter(b=>0<b.length)};
_.CC=function(a){const b=[];for(const c of a.split(/\s*,\s*/)){{a=c.split(".");const d=a[0];a.shift();a=[d,a.join(".")]}b.push(a[0])}return b.sort().join(",")};DC=function(a,b){const c=_.CC(_.ok(a));a=_.nk(a);const d=_.CC(_.ok(b));return a===_.nk(b)&&c===d};EC=function(a,b="total"){b=new _.ru(void 0,b);for(const c of a)b.a.push(c);b.length=a.length;return b};
FC=function(a){return-1===a.indexOf("\x26")?a:a.replace(/&(?:amp|lt|gt|quot|apos|nbsp|lrm|rlm|#[xX]?[0-9a-fA-F]+);/g,b=>{switch(b){case "\x26amp;":return"\x26";case "\x26lt;":return"\x3c";case "\x26gt;":return"\x3e";case "\x26quot;":return'"';case "\x26apos;":return"'";case "\x26nbsp;":return"\u00a0";case "\x26lrm;":return"\u200e";case "\x26rlm;":return"\u200f";default:return"#"===b[1]?(b="x"===b[2]||"X"===b[2]?parseInt(b.slice(3),16):parseInt(b.slice(2),10),String.fromCodePoint(b)):b}})};
HC=function(a){function b(h,k){return new _.GC(void 0===k?_.da:k,h,{},[],null,null,g)}function c(h){h=void 0===h?"":h;const k=[];for(;a[e];)if(60==a.charCodeAt(e)){if(47===a.charCodeAt(e+1)){var l=e+2;e=a.indexOf("\x3e",e);if(!a.startsWith(h,l))throw h=a.substring(0,e).split("\n"),Error("Unexpected close tag\nLine: "+(h.length-1)+"\nColumn: "+(h[h.length-1].length+1)+"\nChar: "+a[e]);e+1&&(e+=1);break}else if(63===a.charCodeAt(e+1)){e=a.indexOf("\x3e",e);e++;continue}else if(33===a.charCodeAt(e+1)){if(45==
a.charCodeAt(e+2)){for(;-1!==e&&(62!==a.charCodeAt(e)||45!=a.charCodeAt(e-1)||45!=a.charCodeAt(e-2)||-1==e);)e=a.indexOf("\x3e",e+1);-1===e&&(e=f)}else if(91===a.charCodeAt(e+2)&&91===a.charCodeAt(e+8)&&a.startsWith("CDATA",e+3)){l=a.indexOf("]]\x3e",e);-1==l?(k.push(b(a.substr(e+9),"#cdata")),e=f):(k.push(b(a.substring(e+9,l),"#cdata")),e=l+3);continue}else{l=e+1;e+=2;for(var m=!1;(62!==a.charCodeAt(e)||!0===m)&&a[e];)91===a.charCodeAt(e)?m=!0:!0===m&&93===a.charCodeAt(e)&&(m=!1),e++;k.push(b(a.substring(l,
e),"#doctype"))}e++;continue}{e++;m=l=d();let v=null;var n=l.indexOf(":");-1!==n&&(v=l.slice(0,n),m=l.slice(n+1));for(n={};62!==a.charCodeAt(e)&&a[e];){var r=a.charCodeAt(e);if(64<r&&91>r||96<r&&123>r){r=d();var u="";let y=a.charCodeAt(e);for(;39!==y&&34!==y;)e++,y=a.charCodeAt(e);if(39===y||34===y){if(u=e+1,e=a.indexOf(a[e],u),u=a.slice(u,e),-1===e)throw Error("Missing closing quote");}else e--;n[r]=u;r=r.split(":");"xmlns"===r[0]&&r[1]&&g.set(u,r[1])}e++}r=[];u=a.charCodeAt(e-1);e++;47!==u&&(r=
c(l));l=new _.GC(l,null,n,r,v,m,g)}k.push(l)}else l=e,e=a.indexOf("\x3c",e)-1,-2===e&&(e=f),l=FC(a.slice(l,e+1)),l=l.trim(),0<l.length&&k.push(b(l)),e++;return k}function d(){const h=e;for(;-1==="\r\n\t\x3e/\x3d ".indexOf(a[e])&&a[e];)e++;return a.slice(h,e)}let e=0;const f=a.length,g=new Map;return new _.GC("#document",null,{},c(""),null,null,g)};
JC=function(a){switch(a){case _.ql:_.bv.info("Select DOM parser for XML");_.on=new _.av;break;case "txml":_.bv.info("Select TXML parser for XML");_.on=new _.IC;break;default:_.bv.warn("XML parser option unknown, using default "+`DOM parser. Option: ${a}`),_.on=new _.av}};KC=function(){return!!window.SourceBuffer&&!!SourceBuffer.prototype&&!!SourceBuffer.prototype.changeType};LC=function(a,b){return a.start-b.start};
MC=function(a){return a.U.map(b=>({start:b.start,end:b.end,width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b.rendition}))};NC=function(a){a.player&&(a.player.off(_.vf,a.a),a.f&&a.player.off(_.Zf,a.a));a.player=null};OC=function(a){a.player&&a.player.trigger(new _.F(_.Hc))};
PC=function(a){if(a.player){var b=!1,c={};for(let d=0;d<a.U.length;d++){const e=a.U[d],f=e.width+"x"+e.height,g=c[f];if(g&&g!==e.bandwidth){b=!0;break}c[f]=e.bandwidth}b&&!a.f?(a.log.debug("Tracking timeupdates"),a.player.on(_.Zf,a.a,a),a.f=!0):!b&&a.f&&(a.log.debug("Stop tracking timeupdates"),a.player.off(_.Zf,a.a),a.f=!1)}};QC=function(a,b,c){a.U=a.U.filter(d=>{if(d.end<=b||d.start>=c)return!1;d.start=Math.max(d.start,b);d.end=Math.min(d.end,c);return!0});a.player&&a.player.trigger(new _.F(_.qg))};
RC=function(a,b){let c=null;for(const d of a)b>=d.startTime&&(c=d);return c};SC=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&(b.add(c.video),c.video.trickModeVideo&&b.add(c.video.trickModeVideo))});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return b};TC=function(a,b){for(let c=0;c<a.length;c++)if(SC(a[c]).has(b))return c;return-1};VC=function(a,b){Array.from(SC(a)).forEach(c=>{c.segmentIndex&&_.UC(c.segmentIndex,b)})};
_.WC=function(a,b,c){const d=Math.pow(a.h,b);c=c*(1-d)+d*a.a;isNaN(c)||(a.a=c,a.f+=b)};_.XC=function(a){return a.a/(1-Math.pow(a.h,a.f))};_.YC=function(a,b,c,d,e,f,g,h){a=_.mj(a);a.timeout=d.timeout;a.maxAttempts=d.maxAttempts;a.baseDelay=d.baseDelay;a.fuzzFactor=d.fuzzFactor;a.backoffFactor=d.backoffFactor;if(0!==b||null!=c)a.headers.Range=c?"bytes\x3d"+b+"-"+c:"bytes\x3d"+b+"-";e&&(a.startTime=e);f&&(a.endTime=f);g&&(a.contentType=g);h&&(a.timescale=h);return a};_.ZC=function(a,b,c){a.h=b;a.a=c};
aD=function(a){return 2===a.j.version?a.a.Rb():$C(a,0)};_.bD=function(a,b){a.K={offsetDateTime:b-aD(a),seekRangeStartDateTime:b}};_.cD=function(a,b){a.l=b;a.C=b;a.a.f=b};dD=function(a){return 2===a.j.version?a.a.f?a.a.a:null:a.l?a.f:a.C?a.o:null};_.eD=function(a,b){a.w=null==a.w?b:Math.min(a.w,b)};_.fD=function(a,b){a.o=Math.max(a.o||0,b)};
_.gD=function(a,b,c){if(0!==b.length){var d=b[b.length-1].endTime+c;_.eD(a,b[0].startTime+c);a.h=b.reduce((e,f)=>Math.max(e,f.endTime-f.startTime),a.h);_.fD(a,d);null!=a.F&&a.L&&(a.F=(Date.now()+a.H)/1E3-(a.o||0)-a.h);a.g.debug("notifySegments: maxSegmentDuration\x3d"+a.h)}};_.hD=function(a,b){a.h=Math.max(a.h,b);a.g.debug("notifyNewSegmentDuration: maxSegmentDuration\x3d"+a.h)};
iD=function(a){if(2===a.j.version)a=a.a.a;else if(a.l)a=a.f;else if(a.C)a=a.o||0;else{if("startover"===a.B)var b=a.I||0;else b=(Date.now()+a.H)/1E3,b=a.M?Math.max(0,b-(a.h-a.G)-a.F):Math.max(0,b-a.h-a.F);a=Math.min(b,a.f)}return a};_.jD=function(a){return 2===a.j.version?a.a.Rb():Infinity===a.A?0:Math.max(0,iD(a)-a.A)};kD=function(a){const b=a.qd()&&!a.C?a.J:0;return 2===a.j.version?a.a.a-b:Math.max(0,iD(a)-b)};
$C=function(a,b){if(2===a.j.version)return a.a.Rb();const c=Math.max(a.w,0);return Infinity===a.A?Math.ceil(1E3*c)/1E3:Math.max(c,Math.min(iD(a)-a.A+b,kD(a)))};lD=function(a,b=!1){b=b?a.offset:0;return{schemeIdUri:a.schemeIdUri,configurationId:a.configurationId,value:a.value,startTime:a.startTime+b,endTime:a.endTime+b,id:a.id,eventElement:a.eventElement,type:a.type,customAttributes:a.customAttributes}};mD=function(a,b,c){a.f=b;a.h=c};
nD=function(a,b){const c=[];let d=!1;for(const f of b)if(!a.a.has(f)){c.push(f);var e=Array.from(a.a.values()).some(g=>g.id===f.id);f.id&&e&&(d=!0)}e=a.a.size;a.a.clear();b.forEach(f=>a.a.add(f));b=a.a.size;c.forEach(f=>a.f(f));(d||0<c.length||e!==b)&&a.h()};oD=function(a,b=!1){return Array.from(a.a.values()).map(c=>lD(c,b)).sort((c,d)=>c.startTime-d.startTime)};
pD=function(a){const b=a.a.Xf(),c=a.h,d=b?b.id:null;(c?c.id:null)!==d&&b&&a.f(new _.F(_.yf,{id:d}));a.h=b;"basic"===a.o.timeline&&(a.j.a=b)};qD=function(a){let b=a.h.get(a.a);if(!b)return null;0<b.a.length&&b.Ya().length&&a.f>=b.a.length&&(a.a+=1,a.f=0,b=a.h.get(a.a));return b&&0<b.a.length?b.a[a.f]||null:b};_.UC=function(a,b){for(;a.a.length;)if(0>=a.a[0].endTime)a.a.shift();else break;0===a.a.length||a.a[a.a.length-1].startTime>=b||(a.a[a.a.length-1].endTime=b)};
_.rD=function(a){return a.a.length?a.a[a.a.length-1].endTime:0};
_.tD=function(a,b){let c=[];const d=[];for(var e=0,f=0;e<a.a.length&&f<b.length;){var g=a.a[e];const h=b[f];g.startTime<h.startTime?(c.push(g),e++):(g.startTime>h.startTime?0===e?d.push(h):a.g.info("Refusing to rewrite original references on update!"):(.1<Math.abs(g.endTime-h.endTime)?c.push(new _.sD(g.position,h.startTime,h.endTime,h.Ya,h.ya,h.pa,h.Ca,h.keyInfo,h.Mc,h.timescale,h.horizontalTiles,h.verticalTiles,h.durationPerTile,null,null,h.wd,h.Ka)):c.push(g),e++),f++)}for(;e<a.a.length;)c.push(a.a[e++]);
if(c.length)for(e=c[c.length-1].position+1;f<b.length;)g=b[f++],g=new _.sD(e++,g.startTime,g.endTime,g.Ya,g.ya,g.pa,g.Ca,g.keyInfo,g.Mc,g.timescale,g.horizontalTiles,g.verticalTiles,g.durationPerTile,null,null,g.wd,g.Ka),c.push(g);else c=b;b=c;if(d.length&&c.length){b=[];f=c[0].position;e=d.length;for(const h of d)b.push(new _.sD(f-e--,h.startTime,h.endTime,h.Ya,h.ya,h.pa,h.Ca,h.keyInfo,h.Mc,h.timescale,h.horizontalTiles,h.verticalTiles,h.durationPerTile,null,null,h.wd,h.Ka));for(const h of c)b.push(h)}a.a=
b};_.uD=function(a,b){for(let c=0;c<a.a.length;++c)if(a.a[c].endTime>b)return a.a.splice(0,c);b=a.a;a.a=[];return b};wD=function(a,b){let c=a.f(b);c=null===c?-1:c-1;const d=a.get(c+1);let e=-1;if(d&&0<d.a.length)for(let f=d.a.length-1;0<=f;--f){let g=d.a[f];if(b>=g.startTime&&b<g.endTime){for(;f&&!g.h;)--f,g=d.a[f];if(!g.h)break;c+=1;e=f-1;break}}return new vD(a,c,e)};xD=function(a,b){a.f=b};
yD=function(a){if(a.a.paused||0===a.a.playbackRate||0===a.a.buffered.length)var b=!1;else a:{b=a.a.buffered;a=a.a.currentTime;for(let c=0;c<b.length;c++){const d=b.start(c),e=b.end(c);if(!(a<d-.1||a>e-(c+1===b.length?.5:.1))){b=!0;break a}}b=!1}return b};
zD=function(a){if(0!==a.a.readyState){if(a.a.seeking){if(!a.C)return}else a.C=!1;if(!a.a.paused&&!a.o){a.a.readyState!==a.I&&(a.l=!1,a.I=a.a.readyState);var b=a.h.smallGapLimit,c=a.a.currentTime,d=a.a.buffered,e=a.h.gapTolerance,f=$B(new _.ru(d),c,a.h.gapDetectionThreshold);if(null==f){if(a.f){a=a.f;d=a.h;c=yD(d);d=d.a.currentTime;f=Date.now()/1E3;if(a.a!==d||a.l!==c)a.j=f,a.a=d,a.l=c;d=f-a.j;d>=a.o&&c&&a.f(a.a,d)}}else if((0!==f||a.A)&&a.H){var g=d.start(f);if(!(g>=kD(a.G))){var h=g-c;b=h<=b;var k=
!1;h<e||(b||a.l||(a.l=!0,e=new _.F("largegap",{detail:{currentTime:c,gapSize:h}}),e.cancelable=!0,a.F(e),a.h.jumpLargeGaps&&!e.defaultPrevented?k=!0:_.ph("Ignoring large gap at",c,"size",h)),!b&&!k)||(0===f?_.ph(vB,h,"seconds because of gap before start time of",g):_.ph(vB,h,"seconds because of gap starting at",d.end(f-1),"and ending at",g),a.B=!0,a.a.currentTime=g)}}}}};AD=function(a,b){a.h=a.f.currentTime;a.l=b;a.j=a.o;a.f.currentTime=b;a.a.Bb(.1)};
CD=function(a,b){a.w||(a.w=!0,a.o&&a.o());.001>Math.abs(a.a.currentTime-b)?BD(a):(a.f.one(a.a,_.Cf,()=>{BD(a)}),AD(a.h,0===a.a.currentTime?b:a.a.currentTime))};DD=function(a,b){a.A=b;a.f.off(a.a,_.me);a.f.one(a.a,_.me,()=>{CD(a,b)})};ED=function(a){return a.l?a.a.currentTime:a.A};FD=function(a,b){0<a.a.readyState?AD(a.h,b):DD(a,b)};BD=function(a){_.Ak()&&!a.l&&a.j();a.l=!0;a.f.on(a.a,_.Cf,()=>a.j())};
ID=function(a,b,c){if(!c.stallEnabled)return null;const d=c.gapDetectionThreshold;let e=c.stallSkip;c=new GD(new HD(b),c.stallThreshold);xD(c,(f,g)=>{a.g.warn(`Stall detected at ${f} for ${g} seconds.`);if(e){g=new _.ru(b.buffered);var h;if(h=_.uk("Edge/")||_.uk("Trident/")||_.vk()||_.Ak())a:{h=g;if(h.length&&!(1>=h.length))for(let k=0;k<h.length-1;k++)if(f>h.start(k)&&f<h.end(k)){h=h.start(k+1)-h.end(k)>=d;break a}h=!1}if(h){a:{if(g.length&&!(1>=g.length))for(h=0;h<g.length-1;h++)if(f>g.start(h)&&
f<g.end(h)){f=g.start(h+1)-f;break a}f=null}f&&(e=Math.min(f+.1,e))}a.g.warn(`Seeking forward ${e} seconds to break stall.`);b.currentTime+=e}else a.g.warn("Pausing and unpausing to break stall."),b.pause(),b.play()});return c};LD=function(a,b,c){null==b?b=Infinity>a.a.getDuration()||c?aD(a.a):kD(a.a):0>b&&(b=kD(a.a)+b);return JD(a,KD(a,b))};KD=function(a,b){const c=aD(a.a);if(b<c)return c;a=kD(a.a);return b>a?a:b};MD=function(a){const b=ED(a.f);return 0<a.h.readyState&&!a.h.paused?KD(a,b):b};
JD=function(a,b){const c=a.a.getDuration();return b>=c?c-a.l.durationBackoff:b};
ND=function(a,b){if("startover"===a.a.B)return b;var c=new _.ru(a.h.buffered);c=c.yc.bind(c);var d=Math.max(a.B,a.l.rebufferingGoal);const e=a.l.safeSeekOffset;let f=aD(a.a);const g=kD(a.a),h=a.a.getDuration();3>g-f&&(f=g-3);const k=$C(a.a,d),l=$C(a.a,e);d=$C(a.a,d+e);if(b>=h)return a.g.debug("Playhead past duration."),JD(a,b);if(b>g)return a.g.debug("Playhead past end."),g;if(b<f){if(c(l))return a.g.debug("Playhead before start \x26 start is buffered"),l;a.g.debug("Playhead before start \x26 start is unbuffered");
return d}if(b>=k||c(b))return a.g.debug("Playhead in safe region or in buffered region."),b;a.g.debug("Playhead outside safe region \x26 in unbuffered region.");return d};OD=function(a,b,c=0){for(const d of a.a)d.l(a.f.currentTime,b,c)};PD=function(a,b){const c=a.offset||0;return b<a.startTime+c?1:b>a.endTime+c?3:2};QD=function(a,b,c,d){a.a=b;a.f=c;a.h=d};_.RD=function(a){_.$s[a]&&delete _.$s[a]};_.SD=function(a){_.Ys[a]&&delete _.Ys[a]};
_.TD=function(a,b,c){if(!(16E3>c)){var d=8E3*c/b;b/=1E3;a.a+=c;_.WC(a.f,b,d);_.WC(a.h,b,d)}};UD=function(a,b){if(typeof a!==typeof b||a.length!==b.length)return!1;for(let c=0;c<a.length;c++)if(a[c].serviceLocationId!==b[c].serviceLocationId||a[c].uri!==b[c].uri||a[c].params!==b[c].params)return!1;return!0};_.VD=function(a,b){return a.la.map(c=>{const d=new URL(c.uri+b);if(c.params)for(const [e,f]of Object.entries(c.params))d.searchParams.set(e,f);return d.toString()})};
ZD=function(a,b){return _.x(function*(){b=b||a.h.contentSteeringServerUri;var c=WD(a,b);a.g.info("Sending request to content steering server, "+`URI: ${c}`);c=_.mj(c,a.A.attemptParameters);c.type=7;c=a.B.fetch(c);_.vj(a.C,c);c=yield c.T;if(410===c.status)a.g.info(" Content steering server not available(HTTP response 410), stopping updates."),null!=a.a&&(a.a.stop(),a.a=null);else if(429===c.status){a.g.info("Content steering server overloaded (HTTP response 429).");var d=parseInt(c.headers["retry-after"],
10);d&&(a.g.info(`Will retry after ${d} s `+"based on Retry-After header."),a.f=d);XD(a,a.f)}else try{d=_.Ui(c.data);const e=JSON.parse(d);1===e.VERSION?YD(a,e,c.uri):a.g.warn(`Received unsupported steering manifest version: ${e.VERSION}, ignoring it and stop requesting.`)}catch(e){a.g.error("requestInfo_: error parsing received steering manifest:",e),e&&7001===e.code||(null!=a.a&&(a.a.stop(),a.a=null),a.a=new _.rk(()=>{ZD(a)}),XD(a,a.f))}})};
$D=function(a,b){return _.x(function*(){null!=a.a&&(a.a.stop(),a.a=null);a.o.clear();a.l.clear();a.j.clear();a.w.clear();a.g.debug(`contentSteeringServerUri: ${b.contentSteeringServerUri}`);a.g.info(`queryBeforeStart: ${b.queryBeforeStart}`);a.h={manifestType:b.manifestType,contentSteeringServerUri:b.contentSteeringServerUri,queryBeforeStart:b.queryBeforeStart,Pf:b.defaultServiceLocation?b.defaultServiceLocation.split(","):[]};b.baseUriCollections.forEach(c=>{const d=[];if(a.h.Pf.length)for(const e of a.h.Pf){const f=
c.la.find(g=>g.serviceLocationId===e);f?d.push(f):a.g.warn("setManifestConfig: could not get default location:",`pathwayId: ${e} processedLocations:`,d)}d.length?a.l.set(c.id,d):a.l.set(c.id,c.la);a.o.set(c.id,c.la)});if(b.contentSteeringServerUri){if(a.h.queryBeforeStart)return ZD(a);a.g.info(`defaultServiceLocations: ${b.defaultServiceLocation}`);ZD(a)}})};_.bE=function(a,b){let c=a.j.get(b);c||(c={$c:0,ue:new aE,yd:!1},a.j.set(b,c));return c};
_.dE=function(a,b){var c=a.l.get(b);if(!c)return a.g.warn(`getBaseUriCollectionById: invalid baseUriSetId:${b}.`),null;const d=Date.now();a.j.forEach((f,g)=>{f.$c&&d>f.$c&&(f.$c=0,a.trigger(new _.F(_.wd,{detail:{serviceLocationId:g,banned:!1,bannedSeconds:0}})))});let e=c.filter(f=>0===_.bE(a,f.serviceLocationId).$c);e.length||(e=c);e.length&&(c=a.w.get(b),UD(e,c)||(c={baseUriCollectionId:b,from:c||[],to:e},a.g.info(`Steering server update baseUriCollectionId: ${c.baseUriCollectionId} from: ${JSON.stringify(c.from)} to: ${JSON.stringify(c.to)}`),
a.trigger(new _.F(_.vd,{detail:c})),a.w.set(b,e)));return new _.cE(b,e)};_.eE=function(a,b){const c=_.bE(a,b);c.$c=Date.now()+1E3*a.f;c.yd=!1;a.g.info(`service location ${b} banned during ${a.f} seconds`);a.trigger(new _.F(_.wd,{detail:{serviceLocationId:b,banned:!0,bannedSeconds:a.f}}))};
WD=function(a,b){b=new URL(b);const c=[],d=[];a.j.forEach((e,f)=>{e.yd&&(c.push(f),d.push(parseInt(e.ue.getBandwidthEstimate(1E4),10)));e.yd=!1});c.length?a.h.manifestType===_.tc?(b.searchParams.set("_DASH_pathway",`"${c.toString()}"`),b.searchParams.set("_DASH_throughput",d.toString())):a.h.manifestType===_.kl&&(b.searchParams.set("_HLS_pathway",`"${c.toString()}"`),b.searchParams.set("_HLS_throughput",d.toString())):a.g.debug("addQueryParams_: serviceLocations EMPTY");return b.toString()};
XD=function(a,b){a.g.info(`Scheduling next steering manifest update in ${b} s.`);a.a.ka(b)};YD=function(a,b,c){null!=a.a&&(a.a.stop(),a.a=null);const d=b["RELOAD-URI"]||c;a.a=new _.rk(()=>{ZD(a,d)});if(c=b.TTL)a.f=c;XD(a,a.f);const e=b["PATHWAY-PRIORITY"]||[],f=b["PATHWAY-CLONES"]||[];a.j.forEach((g,h)=>{e.includes(h)||a.j.delete(h)});a.o.forEach((g,h)=>{g=fE(a,h,e,f);a.l.set(h,g)})};
fE=function(a,b,c,d){const e=[],f=a.o.get(b)||[];if(!c.length)return a.l.get(b);for(const g of c)if(a=f.find(h=>h.serviceLocationId===g))e.push(a);else{const h=d.find(k=>k.ID===g);if(h&&(a=f.find(k=>k.serviceLocationId===h["BASE-ID"]))){const k={serviceLocationId:g,uri:a.uri,params:{}};h[CB]&&(h[CB].HOST&&(a=new URL(a.uri),a.hostname=h[CB].HOST,k.uri=a.toString()),h[CB].PARAMS&&Object.entries(h[CB].PARAMS).forEach(l=>{var [m,n]=l;k.params[m]=n}));e.push(k)}}return e};
gE=function(a){return b=>{if(!a.a||!a.a.enabled)return Promise.resolve(b);b.headers=Object.assign({},b.headers||{});return Promise.resolve(b)}};_.hE=function(a){a=a.toLowerCase();return _.xt[a]||window.muxjs&&a===_.sc?!0:!1};
iE=function(a,b,c,d){return Promise.resolve().then(()=>{if(a.w&&a.h)if(null==c||null==d)a.w.parseInit(_.K(b));else{var e={periodStart:a.A,segmentStart:c,segmentEnd:d};e=a.w.parseMedia(_.K(b),e);var f=e.cues.filter(g=>g.startTime>=a.j&&g.startTime<a.l);a.h.append(f,e.styles);null==a.a&&(a.a=Math.max(c,a.j));a.f=Math.min(d,a.l)}})};jE=function(a,b,c){a.B=b;if(b=a.o.get(b))for(const d of b.keys()){let e=b.get(d);e&&(e=e.filter(f=>f.endTime<=c),a.h.append(e,[]))}};
kE=function(a,b,c,d,e){const f=c+" "+d,g=new Map;for(const h of b){b=h.stream;g.has(b)||g.set(b,new Map);g.get(b).has(f)||g.get(b).set(f,[]);h.startTime+=e;h.endTime+=e;if(!(h.startTime>=a.j&&h.startTime<a.l))continue;const k=new _.Vt(h.startTime,h.endTime,h.text);g.get(b).get(f).push(k);b===a.B&&a.h.append([k],[])}for(const h of g.keys()){a.o.has(h)||a.o.set(h,new Map);for(const k of g.get(h).keys())e=g.get(h).get(k),a.o.get(h).set(k,e)}a.a=null==a.a?Math.max(c,a.j):Math.min(a.a,Math.max(c,a.j));
a.f=Math.max(a.f,Math.min(d,a.l))};
lE=function(a,b){var c=String(_.Hj++);c=new _.Ij(c,a);c.mimeType=_.Cj(b.mimeType);if(a===_.L||a===_.M)c.label=_.Cj(b.label),c.language=_.Cj(b.language),c.originalLanguage=_.Cj(b.originalLanguage);a===_.N?(c.frameRate=b.frameRate,c.roles=b.roles,c.trickPlay=b.trickPlay):a===_.M?(c.channelsCount=b.channelsCount,c.roles=b.audioRoles||[],c.mimeType=_.Cj(b.audioMimeType)):(c.kind=_.Cj(b.kind),c.roles=b.roles);c.accessibility=a===_.N||a===_.M?(b.accessibility||[]).filter(d=>d.type===a):b.accessibility||
[];return c};
mE=function(a,b,c){const d=new _.Qj(a===_.N?`${b.videoId}`:a===_.M?`${b.audioId}`:`${b.id}`,c);switch(a){case _.N:d.codec=_.Cj(b.videoCodec);d.bandwidth=b.videoBandwidth||b.bandwidth;d.width=b.width;d.height=b.height;d.originalId=b.originalVideoId;break;case _.M:d.codec=_.Cj(b.audioCodec);d.bandwidth=b.audioBandwidth||b.bandwidth;d.originalId=b.originalAudioId;break;default:d.codec=_.Cj(b.codecs),d.originalId=b.originalTextId}(a=c.renditions.find(e=>_.eh(e,d,null,["id","track"])))||c.renditions.push(d);return a||
d};nE=function(a,b){a=a.reduce((c,d)=>{b===_.N?null===d.videoId||c[d.videoId]&&!d.activeVideo||(c[d.videoId]=d):b===_.M&&(null===d.audioId||c[d.audioId]&&!d.activeAudio||(c[d.audioId]=d));return c},{});return Object.values(a)};oE=function(a,b){if(void 0!==b&&null!==b){const c=a.filter(d=>d.audio&&d.audio.id===b);if(0<c.length)return c}return a};pE=function(a,b,c){function d(e,f){return null==e?null==f:f.id===e}for(let e=0;e<c.length;e++)if(d(a,c[e].audio)&&d(b,c[e].video))return c[e];return null};
_.qE=function(a,b){a.forEach(c=>{c.startTime+=b;c.endTime+=b})};rE=function(a){const b=a.periods[0].startTime;a=a.periods[a.periods.length-1].endTime;if(null==a)throw Error("Period end time must be known");return{start:b,end:a}};sE=function(a){return Object.assign({},a,{periods:a.periods.map(b=>Object.assign({},b))})};
tE=function(a,b){if(0===a.length)throw Error("Cannot concatenate 0 manifests");if(1===a.length)return a[0];a[0].cues.forEach(e=>{e.offset=0});var c=[...a[0].periods];for(var d=1;d<a.length;d++){const e=rE(a[d-1]).end;_.qE(a[d].periods,e);c.push(...a[d].periods);a[d].cues.forEach(f=>{f.offset=e})}d=a.flatMap(e=>e.cues);c={periods:c,presentationTimeline:b,minBufferTime:0,cues:d,alternativeVariants:a[0].alternativeVariants};d=rE(c).end;_.ZC(b.a,0,d);(a=a[0].presentationTimeline.vc())&&_.bD(b,a.seekRangeStartDateTime);
return c};vE=function(a,b){try{if(1===a.length)return a[0];if(!a.every(uE))throw new _.ji("Period durations must be finite");return tE(a,b)}catch(c){throw new _.I(_.G,7,7003,"Failed to join manifests into a continuous playlist!",c);}};uE=function(a){return a.periods.every(b=>null!=b.endTime&&0<=b.endTime&&isFinite(b.endTime))};
wE=function(a,b){const c=b.periods[0].configurationId;var d=[...a.periods].filter(e=>e.configurationId!==c);a=a.presentationTimeline;d={periods:d,presentationTimeline:a,minBufferTime:0};_.cD(a,b.presentationTimeline.l);return vE([d,b],a)};xE=function(a){return{id:a.id,bandwidth:a.bandwidth,trickPlay:a.video?a.video.trickPlay:!1,width:a.video?a.video.width:void 0,height:a.video?a.video.height:void 0}};yE=function(a,b){return b.find(c=>c.id===a.id)||null};
zE=function(a,b){return a.h.filter(c=>c.type===b)};AE=function(a,b){return(a=a.a.get(b)||null)&&a.track};BE=function(a,b,c){if(!c||AE(a,c.type)!==c||a.m.ta())switch(c=c?c.renditions[0]||null:null,b){case _.N:a.jb(c);break;case _.M:a.yb(c);break;case _.L:a.zb(c);break;default:throw Error(`Unknown track type ${b}`);}};
GE=function(a,b,c){CE(a,b,_.N);if(DE(a,b,_.N)){var d=a.m;a.g.info(`Set video rendition with ID: ${b.id}`);var e=a.a.get(_.M)||null,f=null;if(e&&!e.a){const g=EE(d).filter(h=>h.videoId===parseInt(b.id,10));f=g.find(h=>h.audioId===parseInt(e.id,10))||null;if(!f){a.g.debug("Unable to find exact variant. Searching for equivalent");const h=e.track.renditions.map(k=>k.id).filter(k=>k!==e.id);f=g.find(k=>h.find(l=>l===k.audioId))||null}}else f=EE(d).find(g=>g.videoId===parseInt(b.id,10))||null;f?(a.f.set(_.N,
b),FE(d,f,c)):a.g.warn("Cannot find matching variant")}};KE=function(a,b){_.x(function*(){CE(a,b,_.L);if(DE(a,b,_.L)){var c=a.m.ma().find(d=>d.id===parseInt(b.id,10));if(c){a.g.info(`Set text rendition with ID: ${b.id}`);a.f.set(_.L,b);try{HE(a,b),yield IE(a.m,!0),yield JE(a.m,c),a.m.trigger(new _.F(_.Uf))}catch(d){a.g.warn("Failed to set text rendition",d)}}else a.g.warn(`Text rendition with ID: ${b.id} not found.`)}})};
LE=function(a){_.x(function*(){if(AE(a,_.L)){a.g.info("Unset text rendition.");try{yield IE(a.m,!1),a.a.set(_.L,null),a.m.trigger(new _.F(_.Uf))}catch(b){a.g.warn("Failed to unset text rendition",b)}}})};
PE=function(a){if(a.m){a.g.debug("Track list change detected, updating track list");var b=[];for(var c of Object.values(_.nu))a.a.set(c,null),a.f.set(c,null);for(var d of a.m.ma()){let e=lE(_.L,d);e=(c=b.find(g=>e.Oc(g)))||e;const f=mE(_.L,d,e);d.activeText&&a.a.set(_.L,f);c||b.push(e)}ME(a.m)||a.a.set(_.L,null);d=EE(a.m);NE(a,b,d,_.N);NE(a,b,d,_.M);OE(a,b);a.h=b}};HE=function(a,b){a.a.set(b.track.type,b);b===(a.f.get(b.track.type)||null)&&a.f.set(b.track.type,null)};
DE=function(a,b,c){return a.m.ta()?!0:(a.a.get(c)||null)===b?!1:!0};CE=function(a,b,c){if(0>a.h.indexOf(b.track))throw Error(`Unknown rendition with ID ${b.id}`);if(c!==b.track.type)throw Error("Types mismatch");};NE=function(a,b,c,d){c=nE(c,d);for(const e of c){let f=lE(d,e);f=(c=b.find(h=>f.Oc(h)))||f;const g=mE(d,e,f);(d===_.N&&e.activeVideo||d===_.M&&e.activeAudio)&&a.a.set(d,g);c||b.push(f)}};
OE=function(a,b){var c=a.m;if(c.f){var d=(d=QE(c))?RE(c.o,d).Za:null;c=c.f.muxedAudioTracks||[];if(d)for(e of c)e.active=d.id===e.id;var e=c}else e=[];for(const f of e)e=f,c=String(_.Hj++),c=new _.Ij(c,_.M),c.mimeType="",c.label=e.label,c.language=e.language,c.originalLanguage=e.language,c.channelsCount=e.channelsCount,c.roles=[],c.accessibility=[],d=new _.Qj(`${e.id}`,c),d.codec="",d.bandwidth=0,d.originalId=e.label,d.a=!0,c.renditions.push(d),e=c,b.push(e),f.active&&a.a.set(_.M,e.renditions[0])};
SE=function(a,b,c){return zE(a,c).flatMap(d=>d.renditions).find(d=>parseInt(d.id,10)===b)||null};TE=function(a,b,c,d){a.h.length||PE(a);const e=a.a.get(c)||null;(b=SE(a,b,c))&&e!==b&&(HE(a,b),c===_.M?a.m.trigger(new _.F(_.Ic)):c===_.N&&a.m.trigger(new _.F(_.rg,{details:{width:b.width||0,height:b.height||0,bandwidth:b.bandwidth,track:b.track,abrSelection:d}})))};UE=function(a){const b=_.mk(a.mimeType,a.codecs),c=AC(a);return _.hE(b)||_.Ds(c)||(_.lk(b,a.type)?!0:!1)};
WE=function(a,b){if(window.ManagedMediaSource){a.j.disableRemotePlayback=!0;var c=new ManagedMediaSource;a.l.one(c,"sourceopen",()=>{URL.revokeObjectURL(a.B);b.resolve()});a.l.on(c,"startstreaming",()=>{a.R=!0});a.l.on(c,"endstreaming",()=>{a.R=!1});a.B=VE(c);a.j.src=a.B;return c}c=new MediaSource;a.B=VE(c);a.l.one(c,"sourceopen",()=>{URL.revokeObjectURL(a.B);b.resolve()});a.j.src=a.B;return c};
YE=function(a,b){a.f||(a.f=new XE(a.I,a.C));a=a.f;if(b!==_.sc){var c=_.xt[b];if(!c)throw new _.I(_.G,2,2012,"Text parser is unavailable for "+b);a.w=new c(a.C)}};$E=function(a,b){return _.x(function*(){for(const d of b){const [e,f]=d;{const g=e;var c=a.a[g];c?yield ZE(a,g,c):(c=a.o.addSourceBuffer(f),a.l.on(c,_.q,a.da.bind(a,g)),a.l.on(c,"updateend",a.A.bind(a,g)),a.a[g]=c);a.J[g]=f;a.h[g]=[];a.G[g]=!1}}})};aF=function(a){a.g.debug("Reset transmuxers.");Object.values(a.w).forEach(b=>b.reset())};
ZE=function(a,b,c){return _.x(function*(){yield bF(a,b,()=>{c.remove(0,Infinity)})})};bF=function(a,b,c){if(a.K)return Promise.reject();c={start:c,p:new _.bn};a.h[b].push(c);1===a.h[b].length&&cF(a,b);return c.p};dF=function(a){return a.I.streaming.ignoreManagedMediaSourceStreamingHints?!0:a.R};eF=function(a){return a.o?a.o.readyState===_.Sd:!0};fF=function(a,b){try{return new _.ru(a.a[b].buffered,b)}catch(c){return b in a.a&&a.g.error("failed to get buffered range for "+b,c),null}};
gF=function(a){const b={};b.total=new _.ru(a.j.buffered,"total");b.audio=fF(a,_.p);b.video=fF(a,_.w);let c=[];a.f&&(c=[{start:a.f.Ob(),end:a.f.La()}]);b.text=EC(c,_.H);return b};hF=function(a,b){return a.a[b]?(a=fF(a,b))?a.toString():"":""};
iF=function(a,b,c,d,e,f,g,h,k){h=void 0===h?!1:h;k=void 0===k?!1:k;const l=a.a[b];let m=-1,n=0;l&&l.buffered&&(n=l.buffered.length);b===_.w&&null!==d&&null!==e&&h&&(m=0<n?l.buffered.end(n-1):-1);b===_.H?k=iE(a.f,c,d,e):a.w[b]?(c=a.w[b].transmux(c),c.captions&&0<c.captions.length&&(a.f||YE(a,_.Sf),kE(a.f,c.captions,d,e,a.a.video.timestampOffset)),f=[],0<c.audio.byteLength&&a.a.audio&&!k&&f.push(bF(a,_.p,a.L.bind(a,_.p,c.audio.buffer))),0<c.video.byteLength&&a.a.video&&f.push(bF(a,_.w,a.L.bind(a,_.w,
c.video.buffer))),k=Promise.all(f)):(f&&window.muxjs&&(a.f||YE(a,_.Sf),null==d&&null==e?a.H.init(c):a.H.h(c,r=>{r.length&&kE(a.f,r,d,e,a.a.video.timestampOffset)})),k=bF(a,b,a.L.bind(a,b,c)));return k.then(()=>{if(b===_.w&&null!==d&&null!==e&&!h)a.F.append(d,e,g),null!==d&&null!==e&&a.g.debug("Appended video segment ",d,e,"Buffer:",hF(a,b));else if(b===_.p&&null!==d&&null!==e)OC(a.F),null!==d&&null!==e&&a.g.debug("Appended audio segment ",d,e,"Buffer:",hF(a,b));else if(b===_.w&&null!==d&&null!==e&&
h){var r=l.buffered.length,u=0<r?l.buffered.end(r-1):-1;0>m&&0<r&&(m=l.buffered.start(0));0<=m&&0<u&&a.F.append(m,u,g)}if(!a.G[b]&&l&&1===l.buffered.length){r=l.buffered.start(0);const v=d-r;if(Math.abs(v)>a.fa&&0===l.timestampOffset)return a.g.warn(`Detected a delta of ${v} between `+`media times and segment times for ${b}. `+`The segment start time is ${d} and the media start time `+`is ${r}. Adjusting timestampOffset.`),r=bF(a,b,()=>{a.X(b,v)}),u=bF(a,b,a.S.bind(a,b,!1)),Promise.all([r,u])}null!==
d&&null!==e&&(a.G[b]=!0)}).catch(r=>{throw r;})};jF=function(a,b){const c=a.La(_.w)||0;jE(a.f,b,c)};kF=function(a){a.f&&jE(a.f,"",0)};lF=function(a,b,c,d){return _.x(function*(){if(b!==_.H&&KC()&&a.I.mediaSource.codecSwitchingStrategy===_.Hf){var e=_.mk(c,d);DC(a.J[b],e)||(yield bF(a,b,()=>{a.g.info(`Change MIME type of ${b} to ${e}`);a.a[b].changeType(e);a.J[b]=e;a.A(b)}))}})};mF=function(a,b,c,d,e){return[bF(a,b,a.ba.bind(a,b)),bF(a,b,a.X.bind(a,b,c)),bF(a,b,a.ia.bind(a,b,d,e))]};
nF=function(a,b,c,d,e,f,g){return _.x(function*(){if(b===_.H){a.f.A=c;var h=a.f;h.j=d;h.l=e}else yield lF(a,b,f,g),h=mF(a,b,c,d,e),a.P&&(h=h.concat(mF(a,_.p,c,d,e))),yield Promise.all(h)})};
pF=function(a,b){return _.x(function*(){if(a.K)return Promise.reject();const c=[];for(const d in a.a){const e=new _.bn,f={start:function(g){g.resolve()}.bind(null,e),p:e};a.h[d].push(f);c.push(e);1===a.h[d].length&&f.start()}try{yield Promise.all(c)}catch(d){for(const e in a.a)a.h[e].length&&a.h[e].shift();return Promise.reject(d)}for(const d in a.a);try{yield b()}catch(d){return Promise.reject(new _.I(_.G,3,3015,{mediaError:d}))}finally{for(const d in a.a)oF(a,d)}})};
qF=function(a,b){pF(a,()=>{a.o.duration=b})};oF=function(a,b){a.h[b].shift();cF(a,b)};cF=function(a,b){const c=a.h[b][0];if(c)try{a.g.debug("Starting next operation for "+b),c.start()}catch(d){"QuotaExceededError"===d.name?c.p.reject(new _.I(_.G,3,3017,{type:b})):c.p.reject(new _.I(_.G,3,3015,{mediaError:d})),oF(a,b)}else a.g.debug("No more scheduled operations for "+b)};
wF=function(a,b,c,d){const e=a.periods.flatMap(k=>k.variants);var f=e;if(b.length||c.length)f=rF(f,b,c);f=sF(f,d);if(1<a.periods.length&&e.some(k=>null!=k.audio)){const k=m=>{m=m.split(".");let n=m[0];1<m.length&&(n+="."+m[1]);return n.toLowerCase()};b=[];for(var g of a.periods){c=new Set;for(const m of g.variants)null!==m.audio&&c.add(k(m.audio.codecs));b.push(c)}let l=b[0];for(g=1;g<b.length;g++){const m=b[g];l=new Set([...l].filter(n=>m.has(n)))}f=f.filter(m=>0===l.size&&null===m.audio?!0:0<l.size&&
null===m.audio?!1:l.has(k(m.audio.codecs)))}f=tF(f);const h=uF(f);for(const k of a.periods)k.variants=k.variants.filter(l=>{if(vF(l)===h)return!0;_.qh("Dropping Variant (better codec available)",l);return!1})};
rF=function(a,b,c){if(!b.length&&!c.length)return a;const d=a.filter(g=>(g=g.audio)&&c.length&&(g=_.CC(g.codecs),c.includes(g))?!0:!1),e=a.filter(g=>(g=g.video)&&b.length&&(g=_.CC(g.codecs),b.includes(g))?!0:!1),f=a.filter(g=>d.length&&!e.length?d.includes(g):!d.length&&e.length?e.includes(g):d.includes(g)&&e.includes(g));return f.length?f:a};
sF=function(a,b){var c=a.filter(f=>f.audio&&f.audio.channelsCount);const d=new Map;for(var e of c)c=e.audio.channelsCount,d.has(c)||d.set(c,[]),d.get(c).push(e);e=Array.from(d.keys());if(0===e.length)return a;a=e.filter(f=>f<=b);return a.length?d.get(Math.max.apply(null,a)):d.get(Math.min.apply(null,e))};tF=function(a){const b=new _.Jt;for(const c of a)a=vF(c),b.push(a,c);return b};
uF=function(a){let b="",c=Infinity;a.forEach((d,e)=>{e=e.reduce((f,g)=>f+g.bandwidth||0,0)/e.length;_.qh(_.md,d,"avg bandwidth",e);e<c&&(b=d,c=e)});return b};vF=function(a){let b="";a.video&&(b=_.CC(a.video.codecs));let c="";a.audio&&(c=_.CC(a.audio.codecs));return b+"-"+c};xF=function(a,b,c,d){let e=a.periods.flatMap(f=>f.variants);if(b.length||c.length)e=rF(e,b,c);e=sF(e,d);for(const f of a.periods)f.variants=f.variants.filter(g=>e.includes(g))};
yF=function(a,b){var c;if(!(c=!a.width||!a.height)){c=a.width;if(c=c>=b.minWidth&&c<=b.maxWidth)c=a.height,c=c>=b.minHeight&&c<=b.maxHeight;c&&(c=a.width*a.height,c=c>=b.minPixels&&c<=b.maxPixels)}c&&(a=a.bandwidth,c=a>=b.minBandwidth&&a<=b.maxBandwidth);return c?!0:!1};zF=function(a,b){let c=!1;for(const d of a)a=d.allowedByApplication,d.allowedByApplication=yF(d,b),a!==d.allowedByApplication&&(c=!0);return c};
CF=function(a,b,c,d,e){e=void 0===e?!0:e;let f=!1;d.variants=d.variants.filter(g=>{if(a&&a.S&&!iC(a,g))return _.qh("Dropping variant - not compatible with key system",g),!1;let h=g.audio;const k=g.video;if(h&&!UE(h)){const l=h.codecs;0<=h.codecs.indexOf(_.Pd)?(_.qh("Trying to use AC-3 for EC-3"),h.codecs=h.codecs.replace(_.Pd,"ac-3"),UE(h)?_.ph("Using AC-3 instead of EC-3 for",AF(h)):(h.codecs=l,_.ph(AB,AF(h)),g.audio=null,f=!0,h=null)):(_.ph(AB,AF(h)),g.audio=null,f=!0,h=null)}return k&&!UE(k)?(_.ph("Dropping variant - video not compatible with platform",
AF(k)),!1):h&&b&&!BF(h,b,e)?(_.ph("Dropping variant - not compatible with active audio","active audio",AF(b),"variant.audio",AF(h)),!1):k&&c&&!BF(k,c,e)?(_.ph("Dropping variant - not compatible with active video","active video",AF(c),"variant.video",AF(k)),!1):!0});if(f){let g=!1,h=!1;for(const k of d.variants)!g&&k.video&&k.audio&&(g=!0),h||k.audio||!k.video||(h=!0);g&&h&&(d.variants=d.variants.filter(k=>k.video&&!k.audio?(_.ph("Dropping variant - not compatible with video + audio","variant.video",
AF(k.video)),!1):!0))}d.textStreams=d.textStreams.filter(g=>{const h=_.hE(_.mk(g.mimeType,g.codecs));h||_.qh("Dropping text stream. Is not supported by the platform.",g);return h})};
AF=function(a){const b=AC(a);return a.type===_.p?"type\x3daudio mimeType\x3d"+a.mimeType+" codecs\x3d"+a.codecs+" codecInfo\x3d"+b+" bandwidth\x3d"+a.bandwidth+" channelsCount\x3d"+a.channelsCount:a.type===_.w?"type\x3dvideo mimeType\x3d"+a.mimeType+" codecs\x3d"+a.codecs+" codecInfo\x3d"+b+" bandwidth\x3d"+a.bandwidth+" frameRate\x3d"+a.frameRate+" width\x3d"+a.width+" height\x3d"+a.height:"unexpected stream type"};
BF=function(a,b,c){return a.mimeType!==b.mimeType||(void 0===c||c)&&a.codecs.split(".")[0]!==b.codecs.split(".")[0]?!1:!0};
DF=function(a){const b=a.audio,c=a.video,d=b?b.codecs:null,e=c?c.codecs:null,f=[];e&&f.push(e);d&&f.push(d);const g=c&&c.mimeType||null,h=b&&b.mimeType||null;var k=[];b&&k.push(b.kind);c&&k.push(c.kind);k=k[0]||null;const l=new Set,m=new Set;if(b)for(var n of b.roles)m.add(n);if(c)for(const r of c.roles)l.add(r);n=[c,b].map(r=>r?r.accessibility||[]:[]).reduce((r,u)=>r.concat(u),[]);a={id:a.id,activeVideo:!1,activeAudio:!1,activeText:!1,type:"variant",bandwidth:a.bandwidth,language:a.language,originalLanguage:a.language,
label:null,kind:k,width:null,height:null,frameRate:null,trickPlay:!1,mimeType:g,audioMimeType:h,codecs:f.join(", "),audioCodec:d,videoCodec:e,primary:a.primary,roles:Array.from(l),audioRoles:Array.from(m),videoId:null,audioId:null,channelsCount:null,spatialAudio:!1,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:null,accessibility:n};c&&(a.videoId=c.id,a.originalVideoId=c.originalId,a.width=c.width||null,a.height=c.height||null,a.frameRate=c.frameRate||
null,a.trickPlay=!!c.trickPlay,a.videoBandwidth=c.bandwidth||null);b&&(a.audioId=b.id,a.originalAudioId=b.originalId,a.originalLanguage=b.originalLanguage,a.channelsCount=b.channelsCount,a.audioBandwidth=b.bandwidth||null,a.label=b.label,a.audioRoles=b.roles);return a};
EF=function(a){return{id:a.id,activeVideo:!1,activeAudio:!1,activeText:!1,type:_.H,bandwidth:0,language:a.language,originalLanguage:a.originalLanguage,label:a.label,kind:a.kind||null,width:null,height:null,frameRate:null,trickPlay:!1,mimeType:a.mimeType,audioMimeType:null,codecs:a.codecs||null,audioCodec:null,videoCodec:null,primary:a.primary,roles:a.roles,audioRoles:null,videoId:null,audioId:null,channelsCount:null,spatialAudio:!1,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,
originalTextId:a.originalId,accessibility:a.accessibility,keyId:null}};LF=function(a){return a.allowedByApplication&&a.allowedByKeySystem};
_.NF=function(a,b,c,d){b=_.$h(b);let e=a;const f=a.filter(h=>h.primary);f.length&&(e=f);const g=e.length?e[0].language:"";e=e.filter(h=>h.language===g);b.some(h=>{const k=_.tC(_.Bi(h),a.map(l=>l.language));return k?(e=a.filter(l=>_.Bi(l.language)===k),!0):!1});d&&e.some(h=>h.kind===_.Ud)&&(e=e.filter(h=>h.kind===_.Ud));if(c){b=MF(e,c);if(b.length)return b;_.C("No exact match for the text role could be found.")}else if(b=e.filter(h=>0===h.roles.length),b.length)return b;b=e.map(h=>h.roles).reduce(_.nC,
[]);return b.length?MF(e,b[0]):e};MF=function(a,b){return a.filter(c=>c.roles.includes(b))};OF=function(a,b,c){if(a.j&&a.a.useCmsd){const d=lC(a.j);null!==d&&(a.g.debug("Using CMSD maxSuggestedBitrateKbps:",d),c=c.filter(e=>e.bandwidth<=1E3*d))}a=c.filter(d=>!d.trickPlay);b&&(a=a.filter(d=>yF(d,b)));return a.sort((d,e)=>d.bandwidth-e.bandwidth)};PF=function(a){return new _.I(_.G,7,7E3,a.a?"Another load operation was started while a load operation was in progress.":"Player was released while a load operation was in progress.")};
QF=function(a,b){if(b&&(null==a.a||a.a!==b))throw PF(a);};RE=function(a,b){a.a.has(b)||a.a.set(b,new RF);return a.a.get(b)};SF=function(a,b,c){RE(a,b).text=c};
VF=function(a,b,c){c=void 0===c?!0:c;var d;if(!(d=!!a.audio!==!!b.audio||!!a.video!==!!b.video||a.language!==b.language)&&(d=a.audio&&b.audio)){d=a.audio;var e=b.audio;d=!(d.channelsCount===e.channelsCount&&(!c||TF(d,e))&&UF(d.roles,e.roles))}!d&&(d=a.video&&b.video)&&(a=a.video,b=b.video,d=!((!c||TF(a,b))&&UF(a.roles,b.roles)));return d?!1:!0};
TF=function(a,b){if(a.mimeType!==b.mimeType)return!1;a=BC(a.codecs).map(c=>_.CC(c));b=BC(b.codecs).map(c=>_.CC(c));if(a.length!==b.length)return!1;a.sort();b.sort();for(let c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0};UF=function(a,b){a=new Set(a);b=new Set(b);a.delete(_.oe);b.delete(_.oe);if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0};WF=function(a,b){let c=null;b.some(d=>{c=_.tC(_.Bi(d),a.map(e=>sC(e)));return!!c});return c?a.filter(d=>c===sC(d)):[]};
XF=function(a,b){return a.filter(c=>{const d=c.audio;c=c.video;return d&&0<=d.roles.indexOf(b)||c&&0<=c.roles.indexOf(b)})};YF=function(a,b){return a.filter(c=>c.audio&&c.audio.spatialAudio!==b?!1:!0)};
ZF=function(a){return 1>=a.a.chasingRate?(a.g.warn("chasingRate must be greater than 1."),!1):a.a.chaseJumpDistance<=a.a.startChasingAt?(a.g.warn("chaseJumpDistance must be greater than startChasingAt."),!1):a.a.startChasingAt<=a.a.stopChasingAt?(a.g.warn("startChasingAt must be greater than stopChasingAt."),!1):0>a.a.stopChasingAt?(a.g.warn("stopChasingAt must be greater than or equal to 0."),!1):!0};$F=function(a,b){a.f=b};aG=function(a,b){a.j=b;a.j.speedUpMode&&(a.w=a.j.speedUpMode)};
dG=function(a,b){a.a.stop();a.l||(a.o=!1);const c=a.l?0:a.h;if((b?b:a.w)===_.zd||0===c||1===c)try{bG(a,c)}catch(d){a.g.warn('Set playbackRate using "decoder" mode fails, due to unsupported range by platform. Fallback to "seek" mode.',d),cG(a)}else cG(a)};bG=function(a,b){if(a.f.ag()!==b){a.g.debug(BB,b,' using native playbackRate "decoder" mode.');try{a.f.Ai(b)}catch(c){throw c;}}};cG=function(a){a.g.debug(BB,a.h,' using "seek" mode.');bG(a,0);a.o=!0;a.a.Bb(.25)};
fG=function(a){a=_.K(a);let b=!1,c;const d=[],e=h=>{d.push(h);_.hm(h)},f=()=>{b=!0},g=[];(new _.om).N(_.ye,e).N(_.ag,e).N(_.qe,e).N(_.xe,e).N(_.Mf,e).ea(_.Of,h=>{c=h;d.push(h);_.im(h)}).ea("encv",f).ea("enca",f).ea("avc1",h=>{g.push({N:h,Vc:1701733238})}).ea("avc3",h=>{g.push({N:h,Vc:1701733238})}).ea("ac-3",h=>{g.push({N:h,Vc:1701733217})}).ea(_.Pd,h=>{g.push({N:h,Vc:1701733217})}).ea("mp4a",h=>{g.push({N:h,Vc:1701733217})}).parse(a);if(b)return _.ph("Init segment already indicates encryption."),
a;if(0===g.length||!c)throw _.rh("Failed to find boxes needed to fake encryption!"),_.rh("Failed init segment (hex):",_.Ll(a)),new _.I(_.G,3,14E3);g.reverse();for(const h of g)_.ph(`Inserting "${_.gm(h.Vc)}" box into init segment.`),a=eG(a,c,h.N,d,h.Vc);return a};
eG=function(a,b,c,d,e){{var f=gG.value(),g=a.subarray(c.start,c.start+c.size);const k=_.Ri(g);var h=new Uint8Array(c.size+f.byteLength);h.set(g,0);g=_.Ri(h);g.setUint32(4,e);h.set(f,c.size);e=k.getUint32(4);g.setUint32(c.size+16,e);hG(h,0,h.byteLength);e=h}h=new Uint8Array(a.byteLength+e.byteLength);c=_.uk("Xbox One")||_.tk()?c.start:c.start+c.size;f=a.subarray(c);h.set(a.subarray(0,c));h.set(e,c);h.set(f,c+e.byteLength);for(const k of d)hG(h,k.start,k.size+e.byteLength);a=_.Ri(h,b.start);b=_.km(b);
d=a.getUint32(b);a.setUint32(b,d+1);return h};hG=function(a,b,c){a=_.Ri(a,b);b=a.getUint32(0);0!==b&&(1===b?(a.setUint32(8,c>>32),a.setUint32(12,c&4294967295)):a.setUint32(0,c))};iG=function(a){return"("+a.type+":"+a.stream.id+")"};jG=function(a){return!a.wb&&null==a.kb&&!a.$b&&!a.nc};kG=function(a){a.periods.every(b=>typeof b.id===_.Nf)};lG=function(a){null!=a.kb&&(a.kb.stop(),a.kb=null)};mG=function(a){return _.x(function*(){a.Wb&&(yield a.Wb.abort())})};
sG=function(a,b,c,d,e){return _.x(function*(){var f=a.D.Ib();const g=nG(a,f);if(null==g)a.g.warn("Cannot initialize streams, period not found at",f);else{f=new Map;var h=new Set;b&&(f.set(_.p,b),h.add(b));c&&(f.set(_.w,c),h.add(c));d&&(f.set(_.H,d),h.add(d));yield a.D.aa.init(f,a.h.forceNativeTS,a.h.disableAudioTracks);a.f||(oG(a),yield pG(a,h),a.f||f.forEach((k,l)=>{a.a.has(l)||(k=qG(k,g,e),a.a.set(l,k),rG(a,k,0))}))}})};
tG=function(a,b){a=a.j.periods.find(c=>c.id===b)||null;if(!a)throw new _.I(_.G,5,5006,`Period ${b} not found`);return a};uG=function(a){var b=a.a.get(_.w);return b?tG(a,b.Ub):(b=a.a.get(_.p))?tG(a,b.Ub):null};_.vG=function(a,b){return(a=a.a.get(b))?a.ec||a.stream:null};wG=function(a){return _.vG(a,_.p)};xG=function(a){return _.vG(a,_.w)};
pG=function(a,b){return _.x(function*(){const c=[];for(const f of b){const g=a.w.get(f.id);g?(a.g.debug("(all) Stream "+f.id+" is being or has been set up"),c.push(g)):(a.g.debug("(all) setting up Stream "+f.id),a.w.set(f.id,new _.bn),c.push(f.createSegmentIndex(a.D.vb)))}try{if(yield Promise.all(c),a.f)return}catch(f){if(a.f)return;for(var d of b){var e=a.w.get(d.id);e&&(e.catch(()=>{}),e.reject(),a.w.delete(d.id))}throw f;}for(e of b)(d=a.w.get(e.id))&&!d.done&&(d.resolve(),a.g.debug("(all) setup Stream "+
e.id))})};nG=function(a,b){return(a=RC(a.j.periods,b+_.fu))?a.id:null};qG=function(a,b,c){return{stream:a,type:a.type,bc:null,segmentIterator:null,ra:null,ec:null,ce:!0,Ub:b,endOfStream:!1,wb:!1,kb:null,$b:!1,Md:0,qe:!1,nc:!1,Ze:!1,Rc:!1,Ag:c||0,Wb:null,Od:!1,kg:0}};rG=function(a,b,c){a.g.debug(iG(b),"updating in "+c+" seconds");b.kb=(new _.Ht(()=>_.x(function*(){try{yield a.Vb(b)}catch(d){if(a.D)a.D.onError(d)}}))).ka(c)};
yG=function(a,b){return _.x(function*(){yield a.D.aa.clear(_.H);a.H++;a.I=!1;var c=a.H,d=a.D.aa;const e=new Map,f=new Set;e.set(_.H,b);f.add(b);yield d.init(e,!1,a.h.disableAudioTracks);a.f||(yield pG(a,f),a.f||(d=d.getTextDisplayer().isTextVisible()||a.h.alwaysStreamText,a.H!==c||a.a.has(_.H)||a.I||!d||(c=a.D.Ib(),d=nG(a,c),null==d?a.g.warn("Cannot set up text media state, period not found at",c):(c=qG(b,d,0),a.a.set(_.H,c),rG(a,c,0)))))})};
zG=function(a){a.I=!0;const b=a.a.get(_.H);b&&(a.g.info("Unload text stream"),lG(b),mG(b).catch(()=>{}),a.a.delete(_.H))};AG=function(a){return _.x(function*(){const b=a.a.get(_.p);b&&(a.g.info("Unload audio stream"),lG(b),yield mG(b).catch(()=>{}),a.a.delete(_.p))})};
_.IG=function(a,b,c,d){const e=a.a.get(b.type);if(!e&&b.type===_.H&&a.h.ignoreTextStreamFailures)yG(a,b);else if(e){var f=BG(a,b).id;if(c&&f!==e.Ub){a.g.debug("switch: switching to stream in another Period; clearing buffer and changing Periods");for(var g of a.a.values())CG(a,g)}else if(e.ec&&(a.g.debug("switch during trick play mode",b),b.trickModeVideo?(e.ec=b,b=b.trickModeVideo,a.g.debug("switch found trick play stream",b)):(e.ec=null,a.g.debug("switch found no special trick play stream"))),DG(a,
f))if(EG(a,b.id)||pG(a,new Set([b])),e.stream!==b){g=a.j.presentationTimeline.getDuration();var h=a.D.Ib();h=FG(a,e,h);!c&&(e.endOfStream||h>=g)?a.g.debug(ZB+iG(e)+" already buffered to the end. Not switching."):(b.type===_.H&&YE(a.D.aa,_.mk(b.mimeType,b.codecs)),e.stream=b,e.stream.segmentIterator=null,e.ce=!0,a.g.debug("switch: switching to Stream "+iG(e)),GG(a,e,f)&&(a.g.info("Aborting current segment request to switch."),e.Wb.abort()),c&&(e.nc?e.qe=!0:e.wb?(e.$b=!0,e.Md=d,e.qe=!0):(lG(e),HG(a,
e,!0,d).catch(k=>{if(a.D)a.D.onError(k)}))))}else a.g.debug(ZB+iG(e)+" already active")}};JG=function(a,b,c,d){b.video&&_.IG(a,b.video,c,d);b.audio&&_.IG(a,b.audio,c,d)};
CG=function(a,b){return _.x(function*(){const c=iG(b);b.nc?a.g.debug(c,"clear: already clearing the buffer"):b.$b?a.g.debug(c,"clear: already waiting"):b.wb?(a.g.debug(c,"clear: currently updating"),b.$b=!0,b.Md=0):null==a.D.aa.Ob(b.type)?(a.g.debug(c,"clear: nothing buffered"),null==b.kb&&rG(a,b,0)):(a.g.debug(c,"clear: handling right now"),lG(b),yield HG(a,b,!1,0).catch(d=>{if(a.D)a.D.onError(d)}))})};KG=function(a){_.x(function*(){if(!a.A){a.A=!0;yield AG(a);var b=a.a.get(_.w);yield CG(a,b)}})};
LG=function(a,b){_.x(function*(){if(a.A){a.A=!1;const c=a.D.Ib();yield sG(a,b,null,null,c)}_.IG(a,b,!0,0)})};oG=function(a){const b=a.j.presentationTimeline.getDuration();Infinity>b?qF(a.D.aa,b):qF(a.D.aa,Math.pow(2,32))};MG=function(a,b){const c=a.j.periods.map(d=>d.id);a.g.debug(`Manifest updated, periods (${c.length}): `+`${c.join(", ")}`);a.j.periods=b.periods;kG(a.j);oG(a)};
NG=function(a){const b=a.D.Ib(),c=g=>a.D.aa.yc(g,b,0);let d=!1;const e=nG(a,b);if(_.Ji(a.a.values(),g=>g.Ub===e))for(const g of a.a.keys()){var f=a.a.get(g);f.stream.segmentIterator=null;c(g)||(CG(a,f),d=!0)}else if(!_.Ji(a.a.keys(),c)){a.g.debug("(all): seeked: unbuffered seek: clearing all buffers");for(f of a.a.values())CG(a,f);d=!0}d||a.g.debug("(all): seeked: buffered seek: presentationTime\x3d"+b)};
OG=function(a,b){b=void 0===b?!1:b;if(a.f)a.g.error("Unable to retry after StreamingEngine is destroyed!");else if(a.o)a.g.error("Unable to retry after StreamingEngine encountered a fatal error!");else for(const c of a.a.values()){const d=iG(c);if(c.Rc||b&&jG(c))a.g.info(d,"Retrying after failure..."),c.Rc=!1,rG(a,c,.1)}};PG=function(a){return Array.from(a.a.values()).some(b=>null!==b.kb)};QG=function(a){const b=Array.from(a.a.values());return a.C&&b.every(c=>c.endOfStream)};
HG=function(a,b,c,d){return _.x(function*(){const e=iG(b);b.$b=!1;b.qe=!1;b.Md=0;b.nc=!0;b.stream.segmentIterator=null;a.g.debug(e,"clearing buffer");if(d){var f=a.D.Ib();const g=a.D.aa.getDuration();f=a.D.aa.remove(b.type,f+d,g)}else f=a.D.aa.clear(b.type).then(()=>!a.f&&c?a.D.aa.flush(b.type):null);yield f;a.f||(a.g.debug(e,"cleared buffer"),b.bc=null,b.ra=null,b.nc=!1,b.endOfStream=!1,b.Od=!1,rG(a,b,0))})};
RG=function(a){return _.x(function*(){const b=[];for(const c of a.a.values())lG(c),c.wb&&c.Wb&&(c.wb=!1,b.push(c.Wb.abort())),c.$b&&b.push(HG(a,c,!0,0));yield Promise.all(b)})};SG=function(a,b,c){(a=a.a.get(b))&&c&&(lG(a),a.stream=c,a.bc=c,a.ra&&(a.ra=c.getSegmentReference(a.ra.position)),a.ra||(a.bc=null))};DG=function(a,b){a=a.B.get(b);return!(!a||!a.ne)};EG=function(a,b){a=a.w.get(b);return!(!a||!a.ne)};FG=function(a,b,c){return b.bc&&b.ra?BG(a,b.bc).startTime+b.ra.endTime:Math.max(c,b.Ag)};
GG=function(a,b,c){if(!b.Wb)return!1;const d=a.D.Ib(),e=a.D.aa.La(b.type);c=(c=TG(a,b,d,e,c))?c.kd():null;if(null==c)return!1;var f=b.stream.initSegmentReference;f&&(c+=f.kd()||0);f=a.D.gd().getBandwidthEstimate();if(8*c/f<(null===e?0:e-d)-Math.max(a.j.minBufferTime||0,a.h.rebufferingGoal))return!0;a=b.Wb;a=a.j?a.j.bytesRemaining:-1;return 0>a||a>c?!0:!1};
TG=function(a,b,c,d,e){if(null==e)return a.g.warn(sB),null;if(b.stream.segmentLookupStrategy===_.OB)b.stream.segmentIterator?a=qD(b.stream.segmentIterator):b.ra||d?(c=b.ra?b.ra.endTime:d,a.g.info(uB,"looking up segment from new stream endTime:",c),b.stream.segmentIterator=wD(b.stream.segmentIndex,c),e=b.stream.segmentIterator.next().value,null===e&&(b.stream.segmentIterator=null,a.g.warn(uB,IB,"endTime:",c,b.ra)),a=e):(e=tG(a,e),e=Math.max(0,c-e.startTime),a.g.info(uB,"looking up segment","lookupTime:",
e,SB,c),d=null,d||(b.stream.segmentIterator=wD(b.stream.segmentIndex,e),d=b.stream.segmentIterator.next().value),null===d&&a.g.warn(uB,IB,"lookupTime:",e,SB,c),a=d);else{var f=iG(b);if(b.ra&&b.stream===b.bc)c=b.ra.position+1,a.g.debug(f,"next position known:","position\x3d"+c),a=UG(a,b,e,c);else{if(b.ra){a.g.debug(f,"next position unknown: another Stream buffered");f=BG(a,b.bc);var g=VG(a,b,f.startTime+b.ra.endTime,e)}else a.g.debug(f,"next position unknown: nothing buffered"),g=VG(a,b,d||c,e);if(null==
g)a=null;else if(f=UG(a,b,e,g),null==f)a=null;else{var h=null==a.h?!1:a.h.ignoreDrift;null==d&&!h&&f.Ca+f.startTime+2>c&&(a=UG(a,b,e,Math.max(0,g-1)))&&(f=a);a=f}}}return a};
WG=function(a,b){var c=a.B.get(b);if(c)return a.g.debug(`(all) Period ${b} is being or has been set up`),c;a.g.debug(`(all) setting up Period ${b}`);const d=new _.bn;a.B.set(b,d);const e=new Set;c=tG(a,b);for(const f of c.variants)f.video&&e.add(f.video),f.video&&f.video.trickModeVideo&&e.add(f.video.trickModeVideo),f.audio&&e.add(f.audio);for(const f of c.textStreams)e.add(f);a.G=a.G.then(()=>a.f?null:pG(a,e)).then(()=>{a.f||(d.resolve(),a.g.debug(`(all) setup Period ${b}`))}).catch(f=>{a.f||(d.catch(()=>
{}),d.reject(),a.B.delete(b),a.g.warn(`(all) failed to setup Period ${b}`),a.D.onError(f))});return d};XG=function(a){a.g.debug("(all) setupAllPeriods_");a.j.periods.map(b=>b.id).forEach(b=>{WG(a,b).catch(oC)})};
$G=function(a,b){if(b.type===_.H&&b.stream.mimeType===_.sc)return jF(a.D.aa,b.stream.originalId||""),null;b.type===_.H&&kF(a.D.aa);if(!dF(a.D.aa)&&b.type!==_.H)return a.h.bufferLimitUpdateInterval?a.h.bufferLimitUpdateInterval/2:.5;var c=iG(b);const d=a.D.Ib(),e=FG(a,b,d);a.g.debug(c,"timeNeeded\x3d"+e);var f=a.D.aa.Wa(b.type,d);a.g.debug(c,"update_:",TB+d,"bufferedAhead\x3d"+f);var g=Math.max(a.j.minBufferTime||0,a.h.rebufferingGoal,a.h.bufferingGoal)*a.l,h=dD(a.j.presentationTimeline);if(null!=
h&&e>=h&&!b.Od)return YG(a,b),null;b.endOfStream=!1;h=BG(a,b.stream).id;const k=nG(a,e);null!=k&&(b.Ub=k);if(k!==h)return a.g.debug(c,"need Period "+k,TB+d,"timeNeeded\x3d"+e,"currentPeriodId\x3d"+h),null;if(f>=g)return a.g.debug(c,"buffering goal met"),a.h.bufferLimitUpdateInterval||.5;f=a.D.aa.La(b.type);f=TG(a,b,d,f,h);if(!f)return a.j.presentationTimeline.isLive()||b.type===_.H?a.h.bufferLimitUpdateInterval||1:(a.g.debug("Media state "+c+": no next segment found. Assuming EOS."),YG(a,b),null);
c=Infinity;for(const l of a.a.values())if(l.type!==_.H||l.stream.mimeType!==_.sc)g=FG(a,l,d),c=Math.min(c,g);if(e>=c+a.j.presentationTimeline.h)return a.h.bufferLimitUpdateInterval||1;b.Ag=0;ZG(a,b,d,h,f).catch(()=>{});return null};aH=function(a,b){return _.x(function*(){if(!a.f){if(a.D.Eg)try{yield a.D.Eg(b)}catch(c){c.cause=b,b=c}if(!b.f)a.D.onError(b)}})};
bH=function(a,b){const c=iG(b),d=BG(a,b.stream).id;if(b.Ub!==d){var e=b.Ub,f=Array.from(a.a.values());f.every(g=>g.Ub===e)?f.every(jG)?(a.g.debug(c,"all need Period "+e),WG(a,e).then(()=>{if(!a.f)if(aF(a.D.aa),f.every(l=>{const m=jG(l),n=BG(a,l.stream).id;return m&&l.Ub===e&&n!==e})){var g=tG(a,e);a.g.debug(c,"Streaming period",e,g);a.g.debug(c,"calling onChooseStreams()...");var h=a.D.Pe(g);a.F=!h.audio&&!h.video&&!!h.text;var k=new Map;h.video&&k.set(_.w,h.video);h.audio&&k.set(_.p,h.audio);h.text&&
k.set(_.H,h.text);for(const l of a.a.keys())if(!k.has(l)&&l!==_.H){a.g.error(c,"invalid Streams chosen: missing "+l+" Stream");a.D.onError(new _.I(_.G,5,5005));return}for(const l of Array.from(k.keys()))if(!a.a.has(l))if(l===_.H)sG(a,null,null,k.get(_.H),g.startTime),k.delete(l);else{a.g.error(c,"invalid Streams chosen: unusable "+l+" Stream");a.D.onError(new _.I(_.G,5,5005));return}for(const l of Array.from(a.a.keys()))(g=k.get(l))?(_.IG(a,g,!1,0),rG(a,a.a.get(l),0)):a.a.delete(l);a.g.debug(c,HB);
a.D.Oe()}else a.g.debug(c,"ignoring transition to Period",e,"since another is happening")}).catch(oC)):a.g.debug(c,"all MediaStates need Period "+e+", but not all MediaStates are idle"):a.g.debug(c,"not all MediaStates need Period "+e)}};YG=function(a,b){a.g.debug(iG(b),"buffered to end of presentation");b.endOfStream=!0;b.type===_.w&&(a=a.a.get(_.H))&&a.stream.mimeType===_.sc&&(a.endOfStream=!0)};
ZG=function(a,b,c,d,e){return _.x(function*(){const f=iG(b),g=tG(a,d);a.g.debug(f,"fetchAndAppend_:",TB+c,LB+g.startTime,VB+e.position,WB+e.startTime,UB+e.endTime);const h=b.stream,k=b.stream.segmentIterator;var l=a.j.presentationTimeline.getDuration();const m=cH(a,d);l=dH(a,b,g,Math.max(0,g.startTime-.1),m?m.startTime+.01:l,e);b.wb=!0;b.ce=!1;a.g.debug(f,"fetching segment");let n=!1;const r=(v,y)=>{if(a.f||a.o)return null;n=!0;return eH(a,b,c,g,h,e,v,y)},u=a.D.aa.La(b.type)||0;l.then(()=>a.f||a.o?
null:fH(a,b,e,!1,v=>r(v.data,!0))).then(v=>a.f||a.o?null:n||null===v?(gH(a,b,u,e,h),null):r(v,!1)).then(()=>{if(!a.f&&!a.o){gH(a,b,u,e,h);b.wb=!1;b.Ze=!1;b.$b||a.D.ge();if(k){const v=k.next().value;v&&a.g.debug("New iterated segment",v)}rG(a,b,0);hH(a,b,h);a.g.debug(f,"finished fetch and append")}}).catch(v=>_.x(function*(){a.f||a.o||(b.wb=!1,b.type===_.H&&a.h.ignoreTextStreamFailures?(1001===v.code?a.g.warn(f,"Text stream failed to download. Proceeding without it."):a.g.warn(f,"Text stream failed to parse. Proceeding without it."),
a.a.delete(_.H)):7001===v.code?(b.wb=!1,b.kb=null,rG(a,b,0)):3017===v.code?iH(a,b,v):1001===v.code&&v.data&&404===v.data[1]?(a.g.warn(f,"request for segment failed","segment not available on server",VB+e.position,WB+e.startTime,UB+e.endTime,"error\x3d"+v),b.wb=!1,b.kb=null,rG(a,b,1)):b.type===_.H?(v instanceof _.I&&v.a(1),lG(b),a.D.onError(new _.I(1,2,2010,v))):1001<=v.code&&1003>=v.code?yield jH(a,b,g,v):(a.g.error(f,"failed fetch and append: code\x3d"+v.code),b.Rc=!0,v instanceof _.I&&v.a(_.G),
yield aH(a,v)))}))})};BG=function(a,b){a=a.j.periods;const c=TC(a,b);a=a[c];if(!a)throw new _.I(_.G,5,5006,`No period found for stream with ID ${b.id}.`);return a};
UG=function(a,b,c,d){const e=iG(b);if(null==c)return a.g.warn(e,sB),null;c=tG(a,c);const f=b.stream.getSegmentReference(d);if(!f)return a.g.debug(e,"segment does not exist:",LB+c.startTime,"position\x3d"+d),null;var g=a.j.presentationTimeline;d=_.jD(g);g=iD(g);return!b.Od&&(c.startTime+f.endTime<d||c.startTime+f.startTime>g)?(a.g.debug(e,"segment is not available:",LB+c.startTime,WB+f.startTime,UB+f.endTime,"availabilityStart\x3d"+d,"availabilityEnd\x3d"+g),null):f};
VG=function(a,b,c,d){const e=iG(b);d=tG(a,d);const f=Math.max(0,c-d.startTime);b=b.stream.findSegmentPosition(f);a.g.debug(e,"Looked up segment:",TB+c,"lookupTime\x3d"+f,LB+d.startTime,"Result: segment position\x3d"+b);null==b&&a.g.warn(e,"cannot find segment:",LB+d.startTime,"lookupTime\x3d"+f);return b};cH=function(a,b){const c=a.j.periods.findIndex(d=>d.id===b);return 0>c?null:a.j.periods[c+1]||null};
dH=function(a,b,c,d,e,f){return _.x(function*(){var g=c.startTime-f.Ca,h=b.ce||f.initSegment!==(b.ra&&b.ra.initSegment);if(!h&&g===b.kg)return Promise.resolve();b.kg=g;const k=iG(b);a.g.debug(k,"setting timestamp offset to "+g);a.g.debug(k,"setting append window start to "+d);a.g.debug(k,"setting append window end to "+e);g=nF(a.D.aa,b.type,g,d,e,b.stream.mimeType,b.stream.codecs);if(!b.stream.initSegmentReference||!h)return g;a.g.debug(k,"fetching init segment");h=fH(a,b,f&&f.initSegment||b.stream.initSegmentReference,
!0).then(l=>{if(a.f)return null;a.g.debug(k,"appending init segment");return kH(a,l,b).then(()=>iF(a.D.aa,b.type,l,null,null,!!b.stream.closedCaptions&&0<b.stream.closedCaptions.size))}).catch(l=>{b.ce=!0;return Promise.reject(l)});return Promise.all([g,h])})};
eH=function(a,b,c,d,e,f,g,h){h=void 0===h?!1:h;return _.x(function*(){const k=iG(b);if(e&&e.keyId&&a.D.ed){var l=fC(a.D.ed,e.keyId);if(l)try{yield l}catch(n){a.g.warn("DRM session load failed, cannot append segment!")}else a.g.warn(`Unable to find DRM session for ${e.keyId}`)}if(e.encrypted&&e.keyId&&a.D.ed&&hC(a.D.ed,e.keyId))return lG(b),l=BG(a,e).id,(l=lH(a,l))&&(yield l),l=a.D.ve(e,d,PB),a.g.warn(k,`Blocked append for ${f.startTime+d.startTime} - ${f.endTime+d.startTime}: ${l}. `+`Stream with Key ID ${e.keyId} has restrictions.`),
Promise.resolve();const m=e.closedCaptions&&0<e.closedCaptions.size;null!=e.emsgSchemeIdUris&&0<e.emsgSchemeIdUris.length&&(new _.om).ea("emsg",a.J.bind(a,d,f,e.emsgSchemeIdUris)).parse(g);return mH(a,b,c).then(()=>{if(a.f)return null;const n=f.startTime+d.startTime,r=f.endTime+d.startTime;a.g.debug(k,"Appending segment "+`with ${n.toFixed(3)} - ${r.toFixed(3)} `+`KeyID: ${e.keyId} `+`Width: ${e.width} Height: ${e.height} `+`Bitrate: ${_.ej(e.bandwidth)} `+`Fragment: ${h}`);return iF(a.D.aa,b.type,
g,n,r,m,e.id,h,e.type===_.w&&null!=e.muxedAudioId&&!a.A)}).then(()=>{a.f||(a.g.debug(k,"appended media segment"),b.bc=e,b.ra=f)})})};
fH=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?null:e;var f=[];const g=nH(a,c);g&&(f=_.VD(g,c.wd));f.length||(f=c.Ya());f=_.YC(f,c.ya,c.pa,a.h.attemptParameters,c.startTime,c.endTime,b.type,c.timescale);f.type=2;f.onFragment=c.Mc?null:e;f.disableFragmentSupport=c.Mc||a.h.disableFragmentSupport;f.disableMergedFragments=a.h.disableMergedFragments;if(e=c.f())f.keyInfo=e,f.onFragment=null;d&&(f.responseModifiers.push(h=>{oH(a,b,h.data)}),b.type===_.w&&a.h.overridePasp&&f.responseModifiers.push(a.K.bind(a)));
a.g.debug("fetching: reference\x3d",c);c=a.D.vb.fetch(f);b.Wb=c;return c.T.then(h=>{const k=a.D.gd(),l=h.timeMs,m=h.data.byteLength;l&&m&&!d&&k.segmentDownloaded(l,m);pH(a,g,h);b.Wb=null;return h.data}).catch(h=>{pH(a,g);throw h;})};
gH=function(a,b,c,d,e){if(!a.j.presentationTimeline.isLive()&&b.type!==_.H){var f=iG(b);const g=(a.D.aa.La(b.type)||0)-c,h=d.endTime-d.startTime;c=g-h;if(Math.abs(c)>=Math.min(.01,h)&&Math.abs(c)<=Math.min(1,h))for(a.g.debug(f,"Adjusted segment",d.position,"with real duration",g,"and accounted for",c,"delta between segment duration and real duration"),b.Od=!0,a=a.j.periods,b=c,e.adjustSegmentDurations(d.position,b),d=TC(a,e),f=a[d],e=e.getDuration(),VC(f,e),e=d+1;e<a.length;e++)a[e].startTime+=b}};
hH=function(a,b,c){if(!a.C){b=iG(b);var d=Array.from(a.a.values());1!==d.length||d[0].type!==_.H?a.C=d.every(e=>e.type===_.H||a.F?!0:!e.$b&&!e.nc&&e.ra):a.F&&(a.C=!0);a.C&&(a.g.debug(b,"startup complete"),c=BG(a,c).id,cH(a,c),lH(a,c))}};
iH=function(a,b,c){const d=iG(b);if(Array.from(a.a.values()).some(e=>e!==b&&e.Ze))a.g.debug(d,wB,"waiting for another stream to recover...");else{const e=Math.round(100*a.l);if(20<e)a.l-=.2;else if(4<e)a.l-=.04;else{a.g.error(d,"MediaSource threw QuotaExceededError too many times");b.Rc=!0;a.o=!0;a.D.onError(c);return}a.g.warn(d,wB,"reducing buffering goals by "+(100-Math.round(100*a.l))+"%");b.Ze=!0}rG(a,b,4)};
jH=function(a,b,c,d){return _.x(function*(){let e=!0;1001===d.code&&500<=d.data.status||(e=!a.D.ve(b.stream,c));e&&(b.Rc=!0,d.a(_.G),yield aH(a,d))})};kH=function(a,b,c){return _.x(function*(){if(a.h.patchEdgeWhenMixedContent&&_.tk()){const d=fG(b);yield iF(a.D.aa,c.type,d.buffer,null,null,!!c.stream.closedCaptions&&0<c.stream.closedCaptions.size)}})};
lH=function(a,b){let c=null;a.B.has(b)||(c=WG(a,b).then(()=>{a.f||(a.g.debug(HB),a.D.Oe())}).catch(oC));XG(a);a.D.ci&&(a.g.debug("calling onStartupComplete()..."),a.D.ci());return c};
mH=function(a,b,c){if(a.f)return Promise.resolve();const d=iG(b);a.g.debug(d,"checking buffer length");const e=Math.max(a.h.bufferBehind,a.j.presentationTimeline.h),f=a.D.aa.Ob(b.type);if(null==f)return a.g.debug(d,"buffer behind okay because nothing buffered:",TB+c,FB+e),Promise.resolve();const g=c-f,h=g-e;if(.01>=h)return a.g.debug(d,"buffer behind okay:",TB+c,GB+g,FB+e,"underflow\x3d"+Math.abs(h)),Promise.resolve();a.g.debug(d,"buffer behind too large:",TB+c,GB+g,FB+e,"overflow\x3d"+h);return a.D.aa.remove(b.type,
f,f+h).then(()=>{a.f||a.g.debug(d,"evicted "+h+" seconds")})};oH=function(a,b,c){(new _.om).N(_.ye,_.hm).N(_.ag,_.hm).N(_.qe,_.hm).N(_.xe,_.hm).N(_.Mf,_.hm).ea(_.Of,_.im).N("encv",d=>{d.reader.skip(78);_.hm(d)}).N(_.Gf,_.hm).N("schi",_.hm).N("tenc",d=>{d.reader.skip(6);if(_.$l(d.reader)){d.reader.skip(1);const e=_.Ll(_.em(d.reader,16));e!==b.stream.keyId&&(a.g.debug(iG(b),"Key id from tenc mismatches with key id from manifest. Switching from "+`${b.stream.keyId} to ${e}.`),b.stream.keyId=e)}d.parser.stop()}).parse(c)};
nH=function(a,b){return a.D.Kc&&(b=b.Ka)?_.dE(a.D.Kc,b.id):null};pH=function(a,b,c){if(a.D.Kc&&b){c&&0===c.request.uriIndex||_.eE(a.D.Kc,b.la[0].serviceLocationId);const e=c.request;var d=c.timeMs;c=c.data.byteLength;d&&c&&(a=_.bE(a.D.Kc,b.la[e.uriIndex].serviceLocationId),_.TD(a.ue,d,c),a.yd=!0)}};
qH=function(a){const b=c=>c.video&&c.audio||c.video&&c.video.codecs.includes(",");if(a.some(c=>c.variants.some(b))){_.qh("Found variant with audio and video content, so filtering out audio-only content in all periods.");for(const c of a)c.variants=c.variants.filter(b)}};EE=function(a){if(!a.f||!a.C)return[];const b=rH(a),c=sH(a),d=[];for(const e of tH(a))a=DF(e),a.activeVideo=e.video===b,a.activeAudio=e.audio===c,d.push(a);return d};
FE=function(a,b,c){c=void 0===c?!1:c;var d=void 0===d?0:d;_.x(function*(){if(!a.f||!a.a)throw Error("Player not ready to select tracks.");var e=QE(a);if(!e)throw Error(xB);if(b){a.configuration.abr.enabled&&(a.log.info("Disable ABR and enable manual track selection to "+`select ${b.width}x${b.height}@${b.bandwidth}`),a.configuration.abr.enabled=!1,a.h.disable());var f=uH(a).find(h=>h.id===b.id)||null;if(!f)throw a.log.error("No variant with id",b.id),Error("Variant not found.");if(!LF(f))throw a.log.error("Unable to switch to restricted track",
b.id),Error("Unable to switch to restricted track.");a.da=f.video.id;var g=yield a.j.loadVariant(f,e.id);RE(a.o,e).Za?g.video&&(vH(a,e,g.video,!1),_.IG(a.a,g.video,c,d)):(wH(a,e,g,!1),xH(a,g,c,d));null==a.pc&&(a.pc=a.oc);a.oc=new yH(f);zH(a,e.variants)}else a.da=null,null!=a.pc&&(a.oc=a.pc,a.pc=null),a.configuration.abr.enabled||(a.log.info("Enable ABR Selection"),a.configuration.abr.enabled=!0,a.h.enable()),e=zH(a,e.variants).variant,null==e||a.X||AH(a,e)})};
CH=function(a,b){_.x(function*(){if(a.configuration.streaming.disableAudioTracks)throw Error("Audio tracks are disabled by config.");if(!a.a||!a.f||!a.C)throw Error("Not ready to select audio track.");var c=(a.f.muxedAudioTracks||[]).find(k=>k.id===b);if(c)BH(a,c);else{var d=xG(a.a),e=wG(a.a);c=QE(a);if(!c)throw Error(xB);var f=uH(a).filter(k=>k.audio.id===b&&LF(k)),g=!1,h=void 0;if(d){if(h=f.find(k=>k.video.id===d.id),!h){a.log.debug("Cannot find exact variant, looking for anything else that matches with given audioId");
g=!0;const k=a.getTrackManager().Ea();if(k){const l=k.renditions.map(m=>m.id);h=f.find(m=>l.find(n=>n===String(m.video.id)))}}}else h=f[0];if(!h)throw Error("Variant with target audio track not found.");if(!RE(a.o,c).Za&&e.codecs.split(".")[0]!==h.audio.codecs.split(".")[0])throw a.log.warn("Cannot select audio track, codecs are not compatible with active track."),Error("Audio codecs not compatible with active audio.");e=yield a.j.loadVariant(h,c.id);h=e.audio;a.Ja=h.id;f=f.map(xE);a.h.setTracks(f);
wH(a,c,e,!1);g||a.X?xH(a,e,!0,0):LG(a.a,h)}})};IE=function(a,b){return _.x(function*(){if(a.af!==b&&(a.af=b,a.H===DH&&(a.L.getTextDisplayer().setTextVisibility(b),!a.configuration.streaming.alwaysStreamText)))if(b){var c=QE(a);c=_.NF(c.textStreams,a.lc,a.Wd,a.kc);0<c.length&&(yield yG(a.a,c[0]))}else zG(a.a)})};
JE=function(a,b){return _.x(function*(){if(a.f&&a.a){var c=QE(a);const d=yield a.j.loadTextStream(b.id,c.id);yield yG(a.a,d);EH(a,c,d,!1);c=d;a.X?a.S=c:_.IG(a.a,c,!0,0);a.lc=d.language;a.kc=d.kind===_.Ud}})};ME=function(a){const b=a.af;return a.f?a.L.getTextDisplayer().isTextVisible():b};
FH=function(a,b){a.l||(a.w.on(b,_.q,()=>{if(a.l.error){var c=a.l.error.code;if(1===c)c=null;else{var d=a.l.error.msExtendedCode;d&&(0>d&&(d+=Math.pow(2,32)),d=d.toString(16));c=new _.I(_.G,3,3016,{code:c,extendedError:d,message:a.l.error.message})}}else c=null;if(c)a.onError(c)}),a.l=b)};HH=function(a){return new _.GH(b=>{const c=a.getTrackManager(),d=[];if(c)for(const e of c.getVideoTracks())d.push(...e.renditions);return d.find(e=>e.id===b.toString())||null})};
IH=function(a,b){if(a.za!==b)if(a.za===_.Mo&&b!==_.To)b=xC(b,_.So),a.log.info(_.yB+`${b}`);else{var c=a.rf;c=0===c?0:Date.now()-c;var d=a.za;a.za=b;a.rf=Date.now();null!==a.I&&(a.I.A=b===_.Vo);a.G&&_.Eo(a.G.a,a.za);b===_.Po&&(a.Hg=a.Ye?1:2);var e=a.Hg,f={currentState:a.za,previousState:d,timeSinceLastStateChangeMS:c,reason:b===_.Po||d===_.Po?e:void 0},g=xC(d,_.So),h=xC(b,_.So),k=b!==_.Po?"":`[${xC(e,_.Ro)}]`;a.log.info(`Player state change: ${g} -> `+`${h}${k}`);a.trigger(new _.F(_.Kf,{detail:f}));
(b===_.Lo||b===_.Mo)&&a.Ua&&a.Ua.stop();b===_.Po?a.trigger(new _.F(_.Nc,{detail:{bufferedTimeMS:-1,reason:e}})):d===_.Po&&a.trigger(new _.F(_.Mc,{detail:{bufferedTimeMS:c,reason:e}}))}};NH=function(a){return _.x(function*(){JH(a);yield KH(a);LH(a);if(_.vk(4)||_.vk(5)){const b=a.getSurface().getMedia();FH(a,b);yield MH(a,b)}a.configuration=a.ia})};
OH=function(a){return _.x(function*(){const b=a.A.a;b&&(yield b.catch(()=>{}));a.Xd&&(a.Xd.release(),a.Xd=null);yield Object.getPrototypeOf(Object.getPrototypeOf(a)).release.call(a);yield a.unload();IH(a,_.To)})};LH=function(a){a.l&&(a.w.off(a.l,_.q),a.l=null)};JH=function(a){if(a.H===PH)throw new _.I(_.G,7,7E3,"Player is destroyed.");};QH=function(a){return a.ba?a.ba.catch(()=>{}):Promise.resolve()};
RH=function(a){const b=new _.Kv;(a=a.playlist)&&a.cropTimeline&&(a.startTime||a.endTime)&&(b.h={start:a.startTime||null,end:a.endTime||null});return b};VH=function(a,b){return _.x(function*(){a.G=new _.gv;IH(a,_.Uo);const c=SH(a,a.configuration);yield MH(a,c);QF(a.A,b);a.K=new TH;mD(a.K,d=>{a.log.info("Timeline cue found",d);UH(a,_.Vf,d)},()=>{a.log.info("Timeline cues changed");a.trigger(new _.F(_.Yf))})})};
YH=function(a,b,c,d,e){return _.x(function*(){var f=_.Zo(b)[c];const g=yield WH(a,f);QF(a.A,d);_.vn(QB);f=yield XH(a,g,f,b.id||"");QF(a.A,d);e&&f.presentationTimeline.l&&(yield g.stop(),QF(a.A,d));_.vn("manifest.end");_.xn("Fetch and parse manifest",QB,"manifest.end");return{parser:g,manifest:f}})};
bI=function(a,b,c){return _.x(function*(){_.vn("initDrm.start");const d=new _.cp({vb:a.getNetworkEngine(),onError:h=>a.onError(h),Se:h=>{if(a.a){var k=QE(a),l=!1,m=Object.keys(h);0===m.length&&a.log.warn("Got a key status event without any key statuses, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");var n=1===m.length&&"00"===m[0];n&&a.log.warn("Got a synthetic key status event, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");
if(m.length&&!a.configuration.disableRestrictions){m=a.getPeriods();for(let A=0;A<m.length;A++){const D=m[A];for(var r of D.variants){var u=r;var v=[];u.audio&&v.push(u.audio);u.video&&v.push(u.video);u=v;for(var y of u)u=r.allowedByKeySystem,y.keyId&&(v=h[n?"00":y.keyId],v=!!v&&!ZH.includes(v),r.allowedByKeySystem=v),u!==r.allowedByKeySystem&&(v=y.type,y.type===_.w&&(v=`video ${y.width}x${y.height}@`+`${_.ej(y.bandwidth)}`),a.log.warn("DRM Key not available for "+`KID: '${y.keyId}'. Applying restrictions to ${v}`)),
D===k&&u!==r.allowedByKeySystem&&(l=!0)}}}if(h=uG(a.a)){r=wG(a.a);y=xG(a.a);a:{n=h.variants;for(m=0;m<n.length;m++)if(n[m].audio===r&&n[m].video===y){n=n[m];break a}n=null}if(!n||n.allowedByKeySystem)a.log.info(tB),$H(a),zH(a,h.variants)}l&&h!==k&&(a.log.info(tB),$H(a),zH(a,k.variants))}},Re:(h,k)=>{a.trigger(new _.F(_.Hd,{expirationTime:k}))},onEvent:h=>a.nf(h),getConfiguration:()=>a.getConfiguration(),Qc:()=>a.Qc()});var e=b.periods.every(h=>h.variants.some(k=>k.drmInfos.some(l=>l.licenseServerUriOrigin===
_.MB)));c.drmResolver&&(c.drm=c.drmResolver({hasLaurl:e}));e=c.drm;var f=_.Tl(e);d.f=f;e=e?e.offlineId||"":"";f=[];const g=_.Vs(b.periods);if(e){const h=_.wl(_.Oe);h&&(yield h.l(a,g),f=yield h.j(e))}yield _.Vn(d,g,f);a.B=d;aI(a,b.periods);_.vn("initDrm.end");_.xn("Init DRM","initDrm.start","initDrm.end");return d})};
oI=function(a,b){return _.x(function*(){const c=a.l;cI(a,c);dI(a,a.f.periods);a.oc=new eI(a.configuration.preferredAudioLanguage||[],a.configuration.preferredAudioRole,a.configuration.preferredAudioChannelCount,a.configuration.preferSpatialAudio,a.configuration.mediaSource.codecSwitchingStrategy);a.lc=a.configuration.preferredTextLanguage;a.Wd=a.configuration.preferredTextRole;a.kc=a.configuration.preferForcedSubtitles;yield _.no(a.B,c);QF(a.A,b);a.h.configure(a.configuration.abr);a.Te&&a.h.setCmsdManager(a.Te);
a.h.init((f,g,h)=>_.x(function*(){if(!a.X){var k=uH(a).find(l=>l.id===f.id)||null;if(k){const l=QE(a);k=yield a.j.loadVariant(k,l.id);AH(a,k,g,h)}else a.log.warn("No matching variant found for track switch")}}));a.C=fI(a,c,a.configuration.startTime);a.bb=gI(a);a.I=new hI({ag:()=>c.playbackRate,Ai:f=>{c.playbackRate=f},Zh:f=>{c.currentTime+=f}});aG(a.I,a.configuration.trickPlay);a.isLive()&&a.configuration.streaming.enableLiveEdgeChasing&&(a.Yd=new iI(a));jI(a,Math.max(1E-4,a.configuration.streaming.rebufferingGoal));
kI(a)?xF(a.f,_.$h(a.configuration.preferredVideoCodec),_.$h(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount):wF(a.f,_.$h(a.configuration.preferredVideoCodec),_.$h(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount);var d=lI(a);d.h=a.configuration.streaming;a.a=d;a.H=DH;yield d.start();QF(a.A,b);a.configuration.streaming.startAtSegmentBoundary&&(d=mI(a,MD(a.C)),FD(a.C.f,d));for(var e of a.f.periods)nI(a,e);$H(a);e=uH(a);d=e.some(f=>f.primary);
a.configuration.preferredAudioLanguage||d||a.log.warn("No preferred audio language set.  We will choose an arbitrary language initially");zH(a,e)})};
pI=function(a,b){var c=a.getMediaPosition(),d=a.mc,e=b.periods,f=d.a;d.a=[];var g=null,h=null;for(var k of e)e=k.endTime-k.startTime,k.configurationId===g?h.a+=e:(g=k.configurationId||"",h=new _.Iv(g||"",k.startTime,e,!1),d.a.push(h));d.h&&(h=d.h.start,g=d.h.end,k=d.a[0],null!=h&&k&&h>=k.f&&h<=k.f+k.a&&(e=h-k.f,e<k.a&&(k.f=h,k.a-=e)),h=d.a[d.a.length-1],null!=g&&h&&g>=h.f&&g<=h.f+h.a&&(h.a=g-h.f));mC(d,c);a:if(c=f,d=d.a,c.length!==d.length)d=!1;else{for(f=0;f<c.length;f++)if(!c[f].Oc(d[f])){d=!1;
break a}d=!0}!d&&a.trigger(new _.F(_.Af));pD(a.be);nD(a.K,b.cues)};rI=function(a,b,c){b=qI(a,b,c);c.catch(()=>{});c.reject(b);a.onError(b);throw b;};sI=function(a,b){return _.x(function*(){const c=yield YH(a,b,0,null,!0);try{const d=[a.f,sE(c.manifest)],e=vE(d,a.f.presentationTimeline);return{parser:c.parser,manifest:e}}catch(d){throw new _.I(_.G,7,7003,"Failed to append load manifest");}})};
tI=function(a,b){a.configuration.ads.hls.mockCuesFn?(b=a.configuration.ads.hls.mockCuesFn(a),nD(a.K,b)):nD(a.K,b)};uI=function(a,b){return _.x(function*(){if(a.R===_.ma)tI(a,b.cues);else if(a.R===_.bb){a.f=wE(a.f,sE(b));const c=a.configuration.playlist.endTime,d=a.f.presentationTimeline.a.a;c&&d>c&&(a.log.info("Reached end of playlist. Turning timeline static."),a.j.requestStop(),a.j=null,_.cD(a.f.presentationTimeline,!0),a.trigger(new _.F(_.je)));pI(a,a.f)}else MG(a.a,b)})};
vI=function(a){return _.x(function*(){a.j.requestStop();a.j=null;a.R===_.bb?a.trigger(new _.F(_.zf)):a.trigger(new _.F(_.je))})};
KH=function(a){return _.x(function*(){a.H!==PH&&(a.H=wI);const b=a.l;b&&(a.w.off(b,_.le),a.w.off(b,_.bf),a.w.off(b,_.Ne),a.w.off(b,_.Sd),a.w.off(b,_.pf),a.w.off(b,_.nf));a.K&&(a.K.release(),a.K=null);a.bb&&(a.bb.release(),a.bb=null);a.Ua&&(a.Ua.stop(),a.Ua=null);a.j&&(yield a.j.stop(),a.j=null);a.h&&(yield a.h.stop());a.a&&(yield a.a.destroy(),a.a=null);a.V&&(yield a.V.destroy(),a.V=null);a.C&&(a.C.release(),a.C=null);a.I&&(a.I.release(),a.I=null);a.L&&(yield a.L.destroy(),a.L=null);a.Db&&(a.Db.release(),
a.Db=null);a.Yd&&(a.Yd.release(),a.Yd=null);b&&b.src&&(b.removeAttribute("src"),b.load());a.B&&(yield a.B.destroy(),a.B=null);a.o.clear();a.J=null;a.Zd.clear();a.f=null;a.G=null;a.X=!0;a.Cb.clear();a.rc=!1;xI(a)})};MH=function(a,b){return _.x(function*(){var c=window.muxjs?new yI:new _.zI;const d=_.Do(a.configuration,[_.ae,"single-native"]).create(a);a.P=d;const e=HH(a);e.track(a);a.Db=e;c=new _.AI(b,c,d,e,a.configuration);yield c.open();a.L=c})};
CI=function(a,b,c){c=void 0===c?!0:c;return _.x(function*(){const d=Date.now()/1E3,e=new _.bn;a.A.a=e;b.cmcd&&b.cmcd.enabled&&(a.Xd=new BI(a.getNetworkEngine(),b.cmcd));try{JH(a);yield QH(a);QF(a.A,e);a.ga=_.Zo(b);a.configuration=_.tl(a.ia,b);JC(a.configuration.xmlParser);a.jf&&a.configuration.mse.sendPlaybackSessionIdHeader&&a.getNetworkEngine().headers.set(EB,a.jf);a.log.info(_.Oa,a.configuration);a.log.info(_.fb,a.ga);yield VH(a,e);QF(a.A,e);const f=yield YH(a,b,a.getSourceIndex(),e,!1);QF(a.A,
e);a.j=f.parser;a.f=f.manifest;tI(a,f.manifest.cues);a.B=yield bI(a,a.f,a.configuration);QF(a.A,e);c&&(yield oI(a,e),QF(a.A,e),a.w.one(a.l,_.le,()=>{const g=Date.now()/1E3-d;a.G&&(a.G.B=g)}));e.resolve()}catch(f){rI(a,f,e)}})};EI=function(a,b){return _.x(function*(){return a.configuration.contentSteering.enabled?(a.V||(a.V=new DI(a.configuration.contentSteering,a.getNetworkEngine()),a.V.on(_.vd,c=>{a.trigger(c)}),yield $D(a.V,b)),a.V):null})};
qI=function(a,b,c){var d=a.A;return null!=d.a&&d.a===c||b instanceof _.I&&7E3===b.code?b instanceof _.I?b:new _.I(_.G,7,7003,"Unexpected error.",b):PF(a.A)};SH=function(a,b){const c=a.getSurface().getMedia();c.loop=!!b.loop;_.B(b.volume)||a.setVolume(b.volume);_.B(b.muted)||a.setMuted(b.muted);FH(a,c);return c};UH=function(a,b,c){a.trigger(new _.F(b,{detail:lD(c,FI(a))}))};
WH=function(a,b){return _.x(function*(){var c=a.getNetworkEngine();c=yield _.Xs(b.url,c,a.configuration.manifest.attemptParameters,b.type||null);c.configure(a.configuration.manifest);return c})};
XH=function(a,b,c,d){return(new _.gp(Promise.resolve().then(()=>_.x(function*(){let e=null;for(;!e;)try{{var f=b,g=c.url;const k=GI(a,d);var h=f.start(g,k)}e=yield h}catch(k){if(a.Ic)if(f=yield a.Ic(c.url,k))c.url=f;else throw k;else throw k;}if(0===e.periods.length)throw new _.I(_.G,4,4014);qH(e.periods);return e})),()=>{a.log.info("Aborting parser step...");return b.stop()})).T};
xI=function(a){if(a.G&&a.J&&a.C){var b=HI(a)===_.Po,c=a.I;c.l=b;dG(c,c.o?"seek":void 0);a.C.j.o=b;II(a);a.be&&(c=1>Math.abs(a.getMediaDuration()-a.getMediaPosition()),a=a.be,b&&c&&(b=a.a,b.a[b.a.length-1]&&a.f(new _.F(_.xf))))}};
aI=function(a,b){var c=a.a?wG(a.a):null;const d=a.a?xG(a.a):null,e=!kI(a);for(const g of b)CF(a.B,c,d,g,e);c=yC(b,g=>g.variants.some(LF));if(a.configuration.streaming.disableAudioTracks)for(var f of b)for(const g of f.variants)delete g.audio;if(a.configuration.streaming.disableVideoTracks)for(const g of b)for(const h of g.variants)(f=h.video)&&!zC(f.type,_.mk(f.mimeType,f.codecs))&&delete h.video;if(0===c)throw new _.I(_.G,4,4032);if(c<b.length)throw new _.I(_.G,4,4011);for(const g of b)zF(g.variants,
a.configuration.restrictions)&&a.a&&QE(a)===g&&$H(a),JI(a,g.variants)};cI=function(a,b){const c=d=>{a.l&&a.J&&(d.type===_.Cf&&a.md?(a.J.a=KI,xI(a)):d.type===_.yg&&a.getState()===_.Wo&&.1>a.getBufferInfo().Wa(a.getMediaPosition())?(a.J.a=KI,xI(a)):a.J&&LI(a));II(a)};a.w.on(b,_.bf,c);a.w.on(b,_.Ne,c);a.w.on(b,_.Sd,c);a.w.on(b,_.Cf,c);a.w.on(b,_.Bf,c);a.w.on(b,_.nf,c);a.w.on(b,_.yg,c);a.w.on(b,_.pf,()=>{if(a.l){var d=a.l.playbackRate;0!==d&&a.I.set(d)}})};
dI=function(a,b){for(let c=0;c<b.length;c++){const d=b[c],e=new Map;for(const f of uH(a))if(f.video&&f.video.closedCaptions){const g=f.video;for(const h of g.closedCaptions.keys())if(!e.has(h)){const k={id:a.yf++,originalId:h,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>null,getSegmentReference:()=>null,initSegmentReference:null,Ca:0,mimeType:_.sc,codecs:"",kind:_.JB,encrypted:!1,keyId:null,language:g.closedCaptions.get(h),label:null,type:_.H,primary:!1,trickModeVideo:null,
emsgSchemeIdUris:null,roles:g.roles,channelsCount:null,spatialAudio:!1,closedCaptions:null};e.set(h,k)}}for(const f of e.values())d.textStreams.push(f)}};uH=function(a){return a.f.alternativeVariants&&0<a.f.alternativeVariants.length?a.f.alternativeVariants:a.C?QE(a).variants:a.f.periods[0].variants};QE=function(a){const b=MD(a.C);let c=null;for(const d of a.f.periods)d.startTime<=b&&(c=d);return c};
AH=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;if(a.configuration.abr.enabled&&a.a){var e=MI(a,b);if(RE(a.o,e).Za){const f=b.video;if(f){NI(a,e,()=>vH(a,e,f,!0));e===QE(a)&&OI(a);_.IG(a.a,f,c,d);return}}NI(a,e,()=>{wH(a,e,b,!0)});e===QE(a)&&OI(a);JG(a.a,b,c,d)}};fI=function(a,b,c){return new PI(b,a.f,a.configuration.streaming,c,d=>{a.bb&&OD(a.bb,!0,d);a.a&&NG(a.a)},d=>a.dispatchEvent(d),a.R===_.bb)};
gI=function(a){const b=new QI(a.l);var c=new RI(a.f);$F(c,()=>{$H(a)});b.a.add(c);a.K&&(c=new SI(a.K),QD(c,d=>{d.ee&&d.ee();UH(a,_.Wf,d)},d=>{d.Qe&&d.Qe();UH(a,_.Xf,d)},(d,e)=>{e||(d.ee&&d.ee(),UH(a,_.Wf,d),d.Qe&&d.Qe(),UH(a,_.Xf,d))}),b.a.add(c));a.R===_.bb&&(c=new TI(a.mc,a.uc,d=>a.trigger(d),a.configuration.playlist),b.a.add(c),a.be=c);return b};jI=function(a,b){a.J=new UI(b,Math.min(.5,b/2));a.J.a=KI;xI(a);a.Ua=(new _.rk(()=>{LI(a)})).Bb(.25)};
kI=function(a){return a.configuration.mediaSource.codecSwitchingStrategy===_.Hf&&(_.vk(2)||_.vk(3)||_.vk(4)||_.vk(5)||_.vk(6)||_.yk()&&38===_.zk().major||_.yk()&&53===_.zk().major||_.yk()&&68===_.zk().major?!1:!0)};
lI=function(a){const b={configuration:{Th:a.R===_.bb},Ib:()=>MD(a.C),aa:a.L,vb:a.getNetworkEngine(),Kc:a.V,Pe:a.Mg.bind(a),Oe:a.Lg.bind(a),onError:a.onError.bind(a),og:a.Ng.bind(a),onEvent:a.nf.bind(a),sg:a.Rg.bind(a),ge:a.Og.bind(a),gd:()=>a.h,ve:a.Kg.bind(a),Eg:a.Qg.bind(a),ed:a.B};return new _.VI(a.f,b)};
mI=function(a,b){function c(g,h){if(!g)return null;h=g.findSegmentPosition(h-f.startTime);return null==h?null:(g=g.getSegmentReference(h))?g.startTime+f.startTime:null}const d=wG(a.a);var e=xG(a.a);const f=QE(a);a=c(d,b);e=c(e,b);return null!=e&&null!=a?Math.max(e,a):null!=e?e:null!=a?a:b};
nI=function(a,b){var c=a.a?wG(a.a):null;const d=a.a?xG(a.a):null,e=!kI(a);CF(a.B,c,d,b,e);c=b.variants;if(a.configuration.streaming.disableAudioTracks)for(const f of c)delete f.audio;if(!c.some(LF))throw new _.I(_.G,4,4011);JI(a,b.variants);zF(c,a.configuration.restrictions)&&a.a&&QE(a)===b&&$H(a);if(!_.vk(2)&&(b=a.B?a.B.getDrmInfo():null))for(const f of c)for(const g of f.drmInfos)if(g.keySystem===b.keySystem)for(const h of g.initData||[])_.$n(a.B,h.keyId,h.initData)||_.bo(a.B,h.initDataType,h.initData,
h.keyId)};$H=function(a){const b=a.getTrackManager();b&&a.H!==PH&&(b.m&&(PE(b),b.m.trigger(new _.F(_.$f))),OI(a))};zH=function(a,b){b=WI(a,b);if(!b)return{variant:null,Za:null};a=XI(a,b);return{variant:b,Za:a}};
LI=function(a){switch(a.H){case DH:a:if(a.l.ended||eF(a.L))var b=!0;else{if(a.isLive()){b=iD(a.f.presentationTimeline);var c=a.getBufferInfo();if(null!==c&&(c=c.La(),null!==c&&c>=b)){b=!0;break a}}b=!1}break;default:b=!1}if(a.L){var d=gF(a.L);c=d.video;d=d.audio;var e=a.l.currentTime;c&&d?(c=c.Wa(e),d=d.Wa(e),c=Math.min(c,d)):c=c?c.Wa(e):d?d.Wa(e):0}else c=0;if(d=a.J){{d=a.J;var f=b;const g=d.f.get(d.a);e=d.a;c=f||c>=g?YI:KI;d.a=c;d=e!==c}}c=d;d=ZI(a);c||a.getState()===_.Po&&!d?(a.log.debug("Buffering state changed. Is buffering",
d,"buffered to end",b,"state",a.getState()),xI(a)):a.rc&&II(a)};II=function(a){IH(a,HI(a))};ZI=function(a){return a.B&&a.B.F?!0:a.J?a.J.getState()===KI:!1};rH=function(a){const b=QE(a);return b?RE(a.o,b).video:null};sH=function(a){const b=QE(a);return b?RE(a.o,b).audio:null};tH=function(a){if(null==QE(a))return[];$I(a);return uH(a).filter(b=>LF(b))};aJ=function(a){const b=QE(a);if(null==b)return[];$I(a);return a.f.alternativeTextStreams?a.f.alternativeTextStreams:b.textStreams.filter(c=>!a.Zd.has(c))};
EH=function(a,b,c,d){SF(a.o,b,c);if(b=a.getTrackManager())TE(b,c.id,_.L,d),c=b.Qa(),a=a.G.f,a.h!==c&&(a.h=c,a.a.push({timestamp:Date.now()/1E3,id:c.id,trackId:c.track.id,type:c.track.type,fromAdaptation:d,width:null,height:null,bandwidth:null}))};
vH=function(a,b,c,d){const e=a.getTrackManager();if(e){var f=a.G.f;RE(a.o,b).video=c;TE(e,c.id,_.N,d);a=e.na();f.j!==a&&(f.j=a,f.a.push({timestamp:Date.now()/1E3,id:a.id,trackId:a.track.id,type:a.track.type,fromAdaptation:d,width:a.width,height:a.height,bandwidth:a.bandwidth}))}};wH=function(a,b,c,d){a.j&&a.j.setCurrentVariant(c);c.video&&vH(a,b,c.video,d);c.audio&&bJ(a,b,c.audio,d)};xH=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;a.X?(a.fa=b,a.xf=c,a.wf=d):JG(a.a,b,c,d)};
BH=function(a,b){const c=QE(a);if(!c)throw Error(xB);const d=c.variants.filter(g=>g.video&&g.video.muxedAudioId===b.groupId&&LF(g));if(0===d.length)throw Error("No variants containing muxed audio found.");let e=d[0];const f=xG(a.a);f&&(e=d.find(g=>g.video.id===f.id)||null);e&&e.video&&(a.Ja=b.id,a.log.info(`Select muxed audio track ${b.id}`),cJ(a,c,b,!1),KG(a.a))};cJ=function(a,b,c,d){b=RE(a.o,b);b.audio=null;b.Za=c;if(b=a.getTrackManager())a=a.G.f,TE(b,c.id,_.M,d),c=b.Ma(),jC(a,c,d)};
FI=function(a){return a.R===_.bb&&"flat"===a.configuration.playlist.timeline};eJ=function(a,b,c){c=void 0===c?!0:c;_.x(function*(){var d=zH(a,b.variants).variant;a.Ja=d&&d.audio&&d.audio.id;d&&(d=yield a.j.loadVariant(d,b.id),wH(a,b,d,!0),xH(a,d,c));(d=dJ(a,b.textStreams))&&(a.configuration.streaming.alwaysStreamText||ME(a))&&(EH(a,b,d,!0),a.X?a.S=d:_.IG(a.a,d,!0,0))})};
bJ=function(a,b,c,d){const e=a.getTrackManager();if(e){var f=a.G.f;a=RE(a.o,b);a.audio=c;a.Za=null;TE(e,c.id,_.M,d);c=e.Ma();jC(f,c,d)}};
JI=function(a,b){a=a.B?_.hh(a.B.ba):{};var c=Object.keys(a);c=c.length&&"00"===c[0];let d=!1,e=!1;const f=[],g=[];for(const h of b){b=[];h.audio&&b.push(h.audio);h.video&&b.push(h.video);for(const k of b)k.keyId&&((b=a[c?"00":k.keyId])?ZH.includes(b)&&(g.includes(b)||g.push(b)):f.includes(k.keyId)||f.push(k.keyId));h.allowedByApplication?h.allowedByKeySystem&&(d=!0):e=!0}if(!d)throw new _.I(_.G,4,4012,{hasAppRestrictions:e,missingKeys:f,restrictedKeyStatuses:g});};
$I=function(a){if(a.a&&a.f){var b=uG(a.a),c=QE(a);null!=b&&b===c&&(wG(a.a),xG(a.a),_.vG(a.a,_.H),RE(a.o,c),RE(a.o,c),RE(a.o,c),RE(a.o,c))}};HI=function(a){if(a.md)var b=!1;else if(a.l&&a.l.ended)b=!0;else{b=a.getMediaDuration();var c=a.getMediaPosition();b=a.rc&&0<=c&&b<=c?!0:!1}return b?_.Lo:ZI(a)||a.md?_.Po:a.l&&a.l.paused?_.Vo:_.Wo};
WI=function(a,b){try{JI(a,b)}catch(e){return a.onError(e),null}b=b.filter(e=>LF(e));var c=oE(b,a.Ja);b=a.oc.create(c);b=Array.from(b.values());var d=b.map(xE);a.h.setTracks(d);if(null!==a.da&&null!==a.Ja&&(d=b.find(e=>e.video.id===a.da&&e.audio.id===a.Ja),a.da=null,d))return d;if(a.configuration.abr.enabled||null===a.da)return c=a.h.chooseTrack(),yE(c,b);c=c.find(e=>null!==e.video&&e.video.id===a.da);return c?c:(a.log.warn("Selected video track not found. Falling back to ABR selection"),c=a.h.chooseTrack(),
yE(c,b))};XI=function(a,b){return b&&b.video?(a=(a.f.muxedAudioTracks||[]).find(c=>c.groupId===b.video.muxedAudioId))&&a.primary?a:null:null};dJ=function(a,b){return _.NF(b,a.lc,a.Wd,a.kc)[0]||null};
fJ=function(a,b){a.X=!0;a.h.disable();a.log.debug("Choosing new streams after period changed");var c=zH(a,b.variants);let d=c.variant;const e=c.Za;let f=dJ(a,b.textStreams);a.fa&&(b.variants.includes(a.fa)&&(d=a.fa),a.fa=null);a.S&&(b.textStreams.includes(a.S)&&(f=a.S),a.S=null);const g=d?d.video:null,h=d&&!e?d.audio:null;d&&a.j&&a.j.setCurrentVariant(d);g&&NI(a,b,()=>vH(a,b,g,!0));h&&NI(a,b,()=>bJ(a,b,h,!0));e&&NI(a,b,()=>cJ(a,b,e,!0));f&&(a.configuration.streaming.alwaysStreamText||ME(a))&&NI(a,
b,()=>EH(a,b,f,!0));b===QE(a)&&OI(a);c=a.configuration.streaming.alwaysStreamText||ME(a)?f:null;return{video:g,audio:h,text:c,Za:e}};NI=function(a,b,c){a.Cb.has(b)||a.Cb.set(b,[]);a.Cb.get(b).push(c)};OI=function(a){const b=QE(a);if(b){const c=a.Cb.get(b)||[];for(a.Cb.delete(b);c.length;)c.shift()()}};MI=function(a,b){for(const c of a.f.periods)if(c.variants.some(d=>d.id===b.id))return c;return null};
gJ=function(a,b,c,d){return _.x(function*(){let e;try{e=yield _.Xs(b.url,a.getNetworkEngine(),a.configuration.manifest.attemptParameters,b.type||null);e.configure(a.configuration.manifest);{var f=e,g=b.url;const E=GI(a,a.configuration.id||"");var h=f.start(g,E)}const k=yield h;qH(k.periods);if(!k.periods.length)throw new _.I(_.G,4,4014);yield a.j.stop();a.j=e;const l=d&&d.id,m=c&&c.id;a.f.periods=k.periods;const n=RC(k.periods,MD(a.C))||k.periods[0];kI(a)?xF(a.f,_.$h(a.configuration.preferredVideoCodec),
_.$h(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount):wF(a.f,_.$h(a.configuration.preferredVideoCodec),_.$h(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount);const r=pE(l,m,n.variants),u=dJ(a,n.textStreams);zH(a,n.variants);const v=r&&r.video,y=r&&r.audio;h=[];const A=new Set;for(const E of n.variants)E.video&&A.add(E.video),E.audio&&A.add(E.audio);const D=a.getNetworkEngine();for(const E of[...A,...n.textStreams])h.push(E.createSegmentIndex(D));
yield Promise.all(h);SG(a.a,_.p,y);SG(a.a,_.w,v);SG(a.a,_.H,u);r&&wH(a,n,r,!1);a.log.info("Switch CDN successful.")}catch(k){throw e&&(yield e.stop()),k;}})};GI=function(a,b){return{networkingEngine:a.getNetworkEngine(),onContentSteeringInfoFound:c=>EI(a,c),configurationId:b,filterNewPeriod:c=>nI(a,c),filterAllPeriods:c=>aI(a,c),onEvent:c=>a.nf(c),onError:c=>a.onError(c),onUpdate:c=>uI(a,c),onTurnedStatic:()=>vI(a),gd:()=>a.h}};
hJ=function(){const a=MediaSource.isTypeSupported,b=/^dv(?:h[e1]|a[v1])\./;MediaSource.isTypeSupported=c=>{var d=c.split(/ *; */),e=d.shift();const f={};for(var g of d)d=g.split("\x3d"),f[d[0]]=d[1].replace(/"(.*)"/,"$1");g=f.codecs;if(!g)return a(c);let h=!1,k=!1;c=g.split(",").filter(l=>{b.test(l)&&(k=!0);/^(hev|hvc)1\.2/.test(l)&&(h=!0);return!0});k&&(h=!1);f.codecs=c.join(",");h&&(f.eotf="smpte2084");for(const l in f)e+="; "+l+'\x3d"'+f[l]+'"';return cast.__platform__.canDisplayType(e)}};
iJ=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"mp2t"===b.split(/ *; */)[0].split("/")[1].toLowerCase()?!1:a(b)};jJ=function(){const a=MediaSource.prototype.addSourceBuffer;MediaSource.prototype.addSourceBuffer=function(...b){b=a.apply(this,b);b.abort=function(){};return b}};kJ=function(){const a=SourceBuffer.prototype.remove;SourceBuffer.prototype.remove=function(b,c){return a.call(this,b,c-.001)}};
lJ=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"opus"!==_.CC(b)&&a(b)};mJ=function(a,b){const c=a.mode;a.mode=c===_.Df?_.Df:_.$d;const d=a.cues;for(let e=d.length-1;0<=e;e--){const f=d[e];f&&b(f)&&a.removeCue(f)}a.mode=c};bC=[112,115,115,104,0,0,0,0];_.nJ=class{constructor(a,b,c,d,e,f="",g){this.Ya=a;this.ya=b;this.pa=c;this.keyInfo=d||null;this.Mc=_.B(e)?!1:!!e;this.wd=f;this.Ka=g}kd(){return this.pa?this.pa-this.ya+1:null}f(){return this.keyInfo}};
_.sD=class{constructor(a,b,c,d,e,f,g,h=null,k=!1,l=null,m=null,n=null,r=null,u=[],v=null,y="",A){this.position=a;this.startTime=b;this.endTime=c;this.Ca=g;this.Ya=d;this.ya=e;this.pa=f;this.keyInfo=h||null;this.Mc=_.B(k)?!1:!!k;this.timescale=l;this.horizontalTiles=m;this.verticalTiles=n;this.durationPerTile=r;this.a=u||[];this.h=!1;this.initSegment=v;this.wd=y;this.Ka=A}getPosition(){return this.position}kd(){return this.pa?this.pa-this.ya+1:null}f(){return this.keyInfo}};
_.GC=class{constructor(a,b,c,d,e,f,g){this.tagName=a;this.textContent=b;this.attributes=c;this.childNodes=d;this.localName=f;this.a=g}getAttribute(a){a=this.attributes[a];return null==a?null:a}};
_.IC=class{j(a,b){a=HC(a).childNodes[0];return b&&a.tagName!==b?null:a}h(a,b){a=this.a(a,b);return 1!==a.length?null:a[0]}a(a,b){return Array.from(a.childNodes).filter(c=>c.tagName===b)}f(a){return a.childNodes.every(b=>b.tagName===_.da||"#cdata"===b.tagName)?a.childNodes.map(b=>b.textContent).join(""):null}getAttributeNS(a,b,c){return(b=a.a.get(b))?a.attributes[`${b}:${c}`]||null:null}removeChild(a,b){a.childNodes=a.childNodes.filter(c=>c!==b)}};_.Lg=_.IC.prototype;_.Lg.Dd=_.Ng(18);_.Lg.le=_.Ng(16);
_.Lg.$d=_.Ng(14);_.Lg.ae=_.Ng(12);_.Lg.ke=_.Ng(10);_.Lg.Jc=_.Ng(8);_.Lg.Qd=_.Ng(6);_.Lg.$=_.Ng(4);_.Lg.sc=_.Ng(2);_.Lg.Pb=_.Ng(0);_.oJ=0;
_.GH=class{constructor(a=null){this.j=a;this.log=new _.S("clpp.renditions");this.U=[];this.h=this.player=null;this.f=!1}track(a){null!=this.player&&NC(this);a&&(this.player=a,this.player.on(_.vf,this.a,this))}release(){NC(this);this.U=[];this.h=this.j=null}append(a,b,c=null){const d=this.j&&null!==c?this.j(c):null;d||this.log.debug("Unable to resolve rendition for ID",c);c={start:a,end:b,rendition:d,width:d?d.width:0,height:d?d.height:0,bandwidth:d?d.bandwidth:0};const e=this.U.find(f=>f.start>=a&&
f.end<=b);if(e)e.rendition=d,e.width=c.width,e.height=c.height,e.bandwidth=c.bandwidth,e.start=c.start,e.end=c.end;else{for(const f of this.U)a>=f.start&&a<f.end?f.end=a:b>=f.start&&b<f.end&&(f.start=b);this.U.push(c);this.U.sort(LC)}PC(this);this.a();this.player&&this.player.trigger(new _.F(_.qg))}clear(){this.U=[];PC(this);this.player&&(this.player.trigger(new _.F(_.qg)),this.player.trigger(new _.F(_.Hc)))}a(){if(this.player){var a=this.player.getMediaPosition();if(0<=a){a:{var b=this.U.length,
c=Number.MAX_SAFE_INTEGER;for(var d=0;d<b;d++){const e=this.U[d];c=Math.min(e.start,c);if(e.start<=a&&e.end>a){a=.1>e.end-a&&d<b-1?this.U[d+1].rendition:e.rendition;break a}if(e.start>a)break}a=0<b&&c>a&&.25>c-a?this.U[0].rendition:null}if(a&&this.h!==a&&(this.h=a,this.player)){c=b=-1;if(a)b=a.width||-1,c=a.height||-1;else if(d=this.player.getSurface().getMedia())b=d.videoWidth,c=d.videoHeight;this.player.trigger(new _.F(_.Kc,{detail:{width:b,height:c,bandwidth:a?a.bandwidth:null,rendition:a}}))}}}}};
_.pJ=class{constructor(a){this.h=Math.exp(Math.log(.5)/a);this.f=this.a=0}};qJ=class{constructor(a){this.a=this.h=0;this.f=a}Rb(){return this.h}getDuration(){return this.f?this.a-this.h:Infinity}};
_.rJ=class{constructor(a,b,c,d,e,f){f=void 0===f?!1:f;this.j=a;this.F=b;this.J=c;this.A=this.f=Infinity;this.h=1;this.G=0;this.o=this.w=null;this.H=0;this.C=this.l=d;this.L=void 0===e?!0:e;this.g=new _.S("clpp.media.PresentationTimeline");this.M=f;this.K=null;this.a=new qJ(d);this.I=null;this.B=this.j.type||null}vc(){return this.K}getDuration(){return 2===this.j.version?this.a.getDuration():this.f}getPresentationStartTime(){return this.F}offset(a){null!=this.w&&(this.w+=a);null!=this.o&&(this.o+=
a)}isLive(){return 2===this.j.version?!this.a.f:Infinity===this.f&&!this.l}qd(){return!this.l}};TH=class{constructor(){this.f=()=>{};this.h=()=>{};this.a=new Set}release(){this.f=()=>{};this.h=()=>{};this.a.clear()}cues(){return this.a}};TI=class{constructor(a,b,c,d){this.a=a;this.h=null;this.j=b;this.f=c;this.o=d;"flat"===d.timeline&&d.cropTimeline&&(a=d.startTime||0,this.j.a=new _.Iv("crop",a,d.endTime?d.endTime-a:Infinity,!1))}release(){this.f=this.j=this.h=this.a=null}l(a){mC(this.a,a);pD(this)}};
vD=class{constructor(a,b,c){this.h=a;this.a=b;this.f=c;this.g=new _.S("clpp.media.SegmentIterator")}next(){var a=this.h.get(this.a);a&&0<a.a.length?(this.f+=1,a.Ya().length&&this.f===a.a.length&&(this.a+=1,this.f=0)):(this.a+=1,this.f=0);a=qD(this);return{value:a,done:!a}}};
_.sJ=class{constructor(a){this.a=a;this.g=new _.S("clpp.media.SegmentIndex")}destroy(){this.a=[];return Promise.resolve()}f(a){for(var b=this.a.length-1;0<=b;--b){const c=this.a[b];if(a>=c.startTime&&a<c.endTime)return c.position}if(this.a.length&&a<this.a[0].startTime)return this.a[0].position;this.g.warn("No Segment found for "+a+". We have "+this.a.length+" references");for(a=0;a<this.a.length;a++)b=this.a[a],this.g.debug("SegmentIndex Ref "+a+" start: "+b.startTime+" end: "+b.endTime+" pos: "+
b.position);return null}get(a){if(0===this.a.length)return null;a-=this.a[0].position;return 0>a||a>=this.a.length?null:this.a[a]}offset(a){this.g.info("Apply offset"+a+" to segment index");for(const b of this.a)b.startTime+=a,b.endTime+=a,b.Ca-=a}h(a,b){a-=this.a[0].position;if(0<=a&&a<this.a.length)for(this.g.warn("Accounting for segment duration drift",b,"at",a),this.a[a].endTime+=b,a+=1;a<this.a.length;++a)this.a[a].startTime+=b,this.a[a].endTime+=b}getDuration(){return 0===this.a.length?0:this.a[this.a.length-
1].endTime-this.a[0].startTime}replace(a){this.a=a}};GD=class{constructor(a,b){this.h=a;this.l=yD(a);this.a=a.a.currentTime;this.j=Date.now()/1E3;this.o=b;this.f=()=>{}}release(){this.h=null;this.f=()=>{}}};HD=class{constructor(a){this.a=a}};
tJ=class{constructor(a,b,c,d,e){this.a=a;this.G=b;this.h=c;this.F=e;this.j=new _.Nt;this.C=!1;this.I=a.readyState;this.l=!1;this.f=d;this.B=this.o=this.H=this.A=!1;this.j.on(a,_.yg,()=>zD(this));this.w=(new _.rk(()=>{zD(this)})).Bb(.25)}release(){this.j&&(this.j.release(),this.j=null);null!=this.w&&(this.w.stop(),this.w=null);this.f&&(this.f.release(),this.f=null);this.a=this.G=this.F=null;this.o=!1}ge(){this.A=!0;zD(this)}};
uJ=class{constructor(a,b){this.f=a;this.o=b;this.l=this.h=this.j=0;this.a=new _.rk(()=>{0>=this.j?(_.C(["Failed to move playhead from",this.h,"to",this.l].join(" ")),this.a.stop()):this.f.currentTime!==this.h?this.a.stop():(this.f.currentTime=this.l,this.j--)})}release(){this.a&&(this.a.stop(),this.a=null);this.f=null}};
vJ=class{constructor(a,b,c,d){this.a=a;this.j=b;this.o=d;this.A=c;this.l=!1;this.f=new _.Nt;this.h=new uJ(a,10);this.w=!1;0<a.readyState?CD(this,c):DD(this,c)}release(){this.f&&(this.f.release(),this.f=null);null!=this.h&&(this.h.release(),this.h=null);this.j=()=>{};this.a=null;this.o=()=>{};this.w=!1}};
PI=class{constructor(a,b,c,d,e,f,g){this.h=a;this.a=b.presentationTimeline;this.B=b.minBufferTime||0;this.l=c;this.A=e;this.w=null;this.j=new tJ(a,b.presentationTimeline,c,ID(this,a,c),f);this.f=new vJ(a,()=>{a:{var h=this.j;var k=h.B;h.B=!1;h.C=!0;h.A=!1;h.l=!1;h=k;k=ED(this.f);const l=ND(this,k);if(Math.abs(l-k)>this.l.gapTolerance){const m=(new Date).getTime()/1E3;if(!this.w||this.w<m-1){this.w=m;FD(this.f,l);h=void 0;break a}}this.g.debug("Seek to "+k);this.A(h?1:0);h=void 0}return h},LD(this,
d,g),()=>{this.j.H=!0});this.o=(new _.rk(()=>{if(0!==this.h.readyState&&!this.h.paused){var h=ED(this.f),k=aD(this.a),l=kD(this.a);3>l-k&&(k=l-3);h<k&&(k=ND(this,h),this.g.info("Jumping forward "+(k-h)+" seconds to catch up with the seek range."),this.h.currentTime=k)}})).Bb(.25);this.g=new _.S("clpp.mse.Playhead")}release(){this.f&&(this.f.release(),this.f=null);this.j&&(this.j.release(),this.j=null);this.o&&(this.o.stop(),this.o=null);this.h=this.f=this.a=this.l=null;this.A=()=>{}}};
QI=class{constructor(a){this.f=a;this.a=new Set;this.h=(new _.rk(()=>{OD(this,!1)})).Bb(.25)}release(){this.h.stop();for(const a of this.a)a.release();this.a.clear()}};
SI=class{constructor(a){this.j=a;this.o=new Map;this.a=()=>{};this.f=()=>{};this.h=()=>{};this.w=[{Fc:null,Ec:2,wc:(b,c)=>this.a(b,c)},{Fc:1,Ec:2,wc:(b,c)=>this.a(b,c)},{Fc:3,Ec:2,wc:(b,c)=>this.a(b,c)},{Fc:2,Ec:1,wc:(b,c)=>this.f(b,c)},{Fc:2,Ec:3,wc:(b,c)=>this.f(b,c)},{Fc:1,Ec:3,wc:(b,c)=>this.h(b,c)},{Fc:3,Ec:1,wc:(b,c)=>this.h(b,c)}]}release(){this.j=null;this.o.clear();this.a=()=>{};this.f=()=>{};this.h=()=>{}}l(a,b,c){if(this.j)for(const d of this.j.cues()){const e=this.o.get(d)||null,f=PD(d,
a);this.o.set(d,f);const g=this.w.find(h=>h.Fc===e&&h.Ec===f);g&&g.wc(d,b&&0===c)}}};aE=class{constructor(){this.f=new _.pJ(2);this.h=new _.pJ(5);this.a=0}getBandwidthEstimate(a){return 128E3>this.a?a:Math.min(_.XC(this.f),_.XC(this.h))}};_.cE=class{constructor(a,b){this.id=a;this.la=b}};
DI=class extends _.su{constructor(a,b){super();this.A=a;this.h=null;this.B=b;this.C=new _.lu;this.f=300;this.o=new Map;this.l=new Map;this.w=new Map;this.j=new Map;this.a=null;this.g=new _.S("clpp.net.ContentSteeringManager")}destroy(){this.B=this.h=this.A=null;this.o.clear();this.l.clear();this.j.clear();this.w.clear();null!=this.a&&(this.a.stop(),this.a=null);return this.C.destroy()}};BI=class{constructor(a,b){this.f=a;this.a=b;this.h=gE(this);this.f.Jd(this.h)}release(){this.f.me(this.h)}};
XE=class{constructor(a,b){this.w=null;this.C=a;this.h=b;this.j=this.A=0;this.l=Infinity;this.f=this.a=null;this.B="";this.o=new Map}destroy(){this.h=this.w=null;this.o.clear();return Promise.resolve()}remove(a,b){return Promise.resolve().then(()=>{!this.h||!this.h.remove(a,b)||null==this.a||b<=this.a||a>=this.f||(a<=this.a&&b>=this.f?this.a=this.f=null:a<=this.a&&b<this.f?this.a=b:a>this.a&&b>=this.f&&(this.f=a))})}Ob(){return this.a}La(){return this.f}yc(a){return null==this.a||null==this.f?!1:a>=
this.a&&a<this.f}Wa(a){return null==this.f||this.f<a?0:this.f-Math.max(a,this.a)}};var wJ=class extends _.T{constructor(){super();this.g=new _.S("clpp.mse.TrackManager");this.m=null;this.h=[];this.a=new Map;this.f=new Map}initialize(a){this.m=a}release(){this.h=[];this.a.clear();this.f.clear()}load(){}destroy(){this.release();this.m=null}getVideoTracks(){return zE(this,_.N)}getAudioTracks(){return zE(this,_.M)}ma(){return zE(this,_.L)}na(){return this.a.get(_.N)||null}Ma(){return this.a.get(_.M)||null}Qa(){return this.a.get(_.L)||null}rb(){return this.f.get(_.N)||null}Fb(){return this.f.get(_.M)||
null}Gb(){return this.f.get(_.L)||null}Ea(){return AE(this,_.N)}qa(){return AE(this,_.M)}wa(){return AE(this,_.L)}Ab(a){this.m&&BE(this,_.N,a)}xa(a){this.m&&BE(this,_.M,a)}Sa(a){this.m&&BE(this,_.L,a)}jb(a,b){b=void 0===b?!1:b;if(this.m)if(a)GE(this,a,b);else if(a=b,b=AE(this,_.N))this.g.info("Unset video rendition."),b.trickPlay?this.g.info("Enabling ABR for trick play tracks is not supported"):(this.g.info("Enable ABR."),FE(this.m,null,a))}yb(a){this.m&&(a?(CE(this,a,_.M),DE(this,a,_.M)&&(this.g.info(`Set audio rendition with ID: ${a.id}`),
this.f.set(_.M,a),CH(this.m,parseInt(a.id,10)))):this.g.info("Enabling ABR for audio is not supported"))}addTextTrack(a){const b=this;return _.x(function*(){b.m&&(yield b.m.addTextTrack(a.url,a.language,a.kind,a.mimeType,a.codec,a.label))})}ta(){return!!this.m&&this.m.ta()}zb(a){if(this.m){var b=a;if(!a){const c=this.Qa();if(c&&c.track.kind!==_.Ud){a=this.ma().find(d=>d.kind===_.Ud&&d.language===c.track.language);if(!a){const d=this.qa();d&&(a=this.ma().find(e=>e.kind===_.Ud&&e.language===d.language))}a&&
(b=a.renditions[0])}}b?KE(this,b):LE(this)}}};wJ.prototype.setTextRendition=wJ.prototype.zb;wJ.prototype.isAbrEnabled=wJ.prototype.ta;wJ.prototype.addTextTrack=wJ.prototype.addTextTrack;wJ.prototype.setAudioRendition=wJ.prototype.yb;wJ.prototype.setVideoRendition=wJ.prototype.jb;wJ.prototype.setTextTrack=wJ.prototype.Sa;wJ.prototype.setAudioTrack=wJ.prototype.xa;wJ.prototype.setVideoTrack=wJ.prototype.Ab;wJ.prototype.getTextTrack=wJ.prototype.wa;wJ.prototype.getAudioTrack=wJ.prototype.qa;
wJ.prototype.getVideoTrack=wJ.prototype.Ea;wJ.prototype.getLoadingTextRendition=wJ.prototype.Gb;wJ.prototype.getLoadingAudioRendition=wJ.prototype.Fb;wJ.prototype.getLoadingVideoRendition=wJ.prototype.rb;wJ.prototype.getTextRendition=wJ.prototype.Qa;wJ.prototype.getAudioRendition=wJ.prototype.Ma;wJ.prototype.getVideoRendition=wJ.prototype.na;wJ.prototype.getTextTracks=wJ.prototype.ma;wJ.prototype.getAudioTracks=wJ.prototype.getAudioTracks;wJ.prototype.getVideoTracks=wJ.prototype.getVideoTracks;var yI;yI=class{constructor(){this.a=new muxjs.mp4.CaptionParser;this.l=[];this.j={}}init(a){const b=muxjs.mp4.probe;a=_.K(a);this.l=b.videoTrackIds(a);this.j=b.timescale(a)||{};this.a.init()}h(a,b){a=_.K(a);(a=this.a.parse(a,this.l,this.j))&&a.captions&&b(a.captions);this.a.clearParsedCaptions()}f(){this.a.resetCaptionStream()}};_.zI=class{init(){}h(){}f(){}};var VE;
_.AI=class{constructor(a,b,c,d,e){this.j=a;this.C=c;this.a={};this.J={};this.P=!1;this.f=null;this.h={};this.l=new _.Nt;this.K=!1;this.w={};this.H=b;this.F=d;this.I=e;this.fa=this.I.streaming.maxSegmentToMediaOffset||1;this.M=new _.bn;this.B="";this.G={};this.o=WE(this,this.M);this.R=!0;this.g=new _.S("clpp.mse.MediaSourceEngine")}destroy(){window.ManagedMediaSource&&(this.j.disableRemotePlayback=!1);this.K=!0;const a=[];for(const c in this.h){const d=this.h[c];var b=d[0];this.h[c]=d.slice(0,1);b&&
a.push(b.p.catch(oC));for(b=1;b<d.length;++b)d[b].p.catch(oC),d[b].p.reject()}this.f&&a.push(this.f.destroy());this.C&&a.push(this.C.destroy());for(const c in this.w)this.w[c].destroy(),delete this.w[c];return Promise.all(a).then(()=>{this.l&&(this.l.release(),this.l=null);this.j&&(this.j.removeAttribute("src"),this.j.load(),this.j=null);this.B="";this.C=this.f=this.o=null;this.a={};this.J={};this.w={};this.G={};this.H=null;this.P=!1;for(const c in this.h);this.h={}})}open(){return this.M}init(a,
b,c){c=void 0===c?!1:c;const d=this;return _.x(function*(){yield d.M;for(const g of a){const [h,k]=g;{var e=k;const l=h,m=_.mk(e.mimeType,e.codecs);if(l===_.H)YE(d,m);else{var f=new Map;f.set(l,m);_.Ds(m)&&b&&!e.aesEncrypted||!_.lk(m,l)||!(e=_.lk(m))||(f=e(),d.w[l]=f,f=f.demuxMimeTypes(l,m),c&&f.delete(_.p));yield $E(d,f);d.P=f.has(_.p)&&f.has(_.w)}}}})}Ob(a){return a===_.H?this.f.Ob():(a=fF(this,a))?a.Ob():null}La(a){return a===_.H?this.f.La():(a=fF(this,a))?a.La():null}yc(a,b,c){return a===_.H?
this.f.yc(b):(a=fF(this,a))?a.yc(b,!1,c):!1}Wa(a,b){return a===_.H?this.f.Wa(b):(a=fF(this,a))?a.Wa(b):0}remove(a,b,c){return a===_.H?this.f.remove(b,c):bF(this,a,this.V.bind(this,a,b,c)).then(()=>{if(a===_.w){var d=this.Ob(a);const e=this.La(a);null!==d&&null!==e&&QC(this.F,d,e)}else a===_.p&&(d=this.F,d.player&&d.player.trigger(new _.F(_.Hc)))})}clear(a){if(a===_.H){if(!this.f)return Promise.resolve();this.H.f();return this.f.remove(0,Infinity)}return bF(this,a,this.V.bind(this,a,0,this.o.duration))}flush(a){return a===
_.H?Promise.resolve():bF(this,a,this.S.bind(this,a))}endOfStream(a){return pF(this,()=>{eF(this)||(a?this.o.endOfStream(a):this.o.endOfStream())})}getDuration(){return this.o.duration}L(a,b){this.g.debug("Appending data to "+a+pB);try{this.a[a].appendBuffer(b)}catch(c){throw this.g.warn("Failed to append data for "+a,c),c;}this.g.debug("Done Appending data to "+a+pB)}V(a,b,c){if(c<=b)this.A(a);else{this.g.debug("Removing data from "+a+" range:",b,c);try{this.a[a].remove(b,c)}catch(d){throw this.g.warn("Failed to remove data from "+
a+" buffer. Range:",b,c,d),d;}this.g.debug("Done Removing data from "+a+" range:",b,c)}}ba(a){try{this.g.debug("Aborting operations for "+a+pB);const b=this.a[a].appendWindowStart,c=this.a[a].appendWindowEnd;this.a[a].abort();this.a[a].appendWindowStart=b;this.a[a].appendWindowEnd=c}catch(b){throw this.g.warn("Failed to abort operations for "+a+pB,b),b;}this.g.debug("Done Aborting operations for "+a+pB);this.A(a)}S(a){try{this.j.readyState>HTMLMediaElement.HAVE_NOTHING?(this.g.debug("Flushing buffer for "+
a),this.j.currentTime-=.001):this.g.warn("Skip buffer flush for "+a+" with element state: "+this.j.readyState)}catch(b){throw this.g.warn("Failed to flush buffer for "+a,b),b;}this.g.debug("Done Flushing buffer for "+a);this.A(a)}X(a,b){0>b&&(b+=.001);try{this.g.debug("Setting timestamp offset for "+a,b),this.a[a].timestampOffset=b}catch(c){throw this.g.warn("Failed to set timestamp offset for "+a,b,c),c;}this.g.debug("Done Setting timestamp offset for "+a,b);this.A(a)}ia(a,b,c){try{this.g.debug("Setting append window for "+
a,b,c),this.a[a].appendWindowStart=0,this.a[a].appendWindowEnd=c,this.a[a].appendWindowStart=b}catch(d){throw this.g.warn("Failed to set append window for "+a,b,c,d),d;}this.g.debug("Done Setting append window for "+a,b,c);this.A(a)}da(a){this.h[a][0].p.reject(new _.I(_.G,3,3014,{mediaError:this.j.error?this.j.error.code:0}))}A(a){const b=this.h[a][0];b&&(b.p.resolve(),this.g.debug("Update-End received for "+a),oF(this,a))}getTextDisplayer(){return this.C}};VE=window.URL.createObjectURL;_.xJ=class{constructor(){this.g=new _.S("clpp.abr");this.A=null;this.l=!1;this.w=new aE;this.f=[];this.o=1;this.C=this.B=!1;this.j=this.a=this.h=null}stop(){this.A=null;this.l=!1;this.f=[];this.o=1;this.h=null;this.C=!1}init(a){this.A=a}chooseTrack(){let a=OF(this,!this.C&&this.a.initialRestrictions?this.a.initialRestrictions:this.a.restrictions,this.f);var b=this.getBandwidthEstimate();this.f.length&&!a.length&&(this.g.warn("No tracks met the ABR restrictions. Choosing a track by lowest bandwidth."),
a=OF(this,null,this.f),a=[a[0]]);this.h=Date.now();this.C=!0;{var c=a;let e=c[0]||null;for(let f=0;f<c.length;f++){const g=c[f];var d=c[f+1];const h=isNaN(this.o)||0===this.o?1:Math.abs(this.o),k=h*g.bandwidth,l=k/this.a.bandwidthDowngradeTarget;d=h*(d?d.bandwidth:Infinity)/this.a.bandwidthUpgradeTarget;this.g.debug("Bandwidth ranges:",(k/1E6).toFixed(3),(l/1E6).toFixed(3),(d/1E6).toFixed(3));b>=l&&b<=d&&(e=g)}b=e}return b||a[0]||this.f[0]}enable(){this.l=!0}disable(){this.l=!1}segmentDownloaded(a,
b){this.g.debug("Segment downloaded:","deltaTimeMs\x3d"+a,"numBytes\x3d"+b,"lastTimeChosenMs\x3d"+this.h,"enabled\x3d"+this.l);_.TD(this.w,a,b);if(null!=this.h&&this.l)a:{this.g.debug("Suggesting Streams...");if(!this.B){if(!(128E3<=this.w.a)){this.g.debug("Still waiting for a good estimate...");break a}this.B=!0;if(this.a.useSwitchIntervalForInitialSwitch&&Date.now()-this.h<1E3*this.a.switchInterval){this.g.debug("Skipping initial estimation switch due to switch interval...");break a}}else if(Date.now()-
this.h<1E3*this.a.switchInterval){this.g.debug("Still within switch interval...");break a}a=this.chooseTrack();b=this.getBandwidthEstimate();this.g.debug("Calling switch_(), bandwidth\x3d"+Math.round(b/1E3)+" kbps");a&&this.A(a)}}playbackRateChanged(a){this.o=a}getBandwidthEstimate(){if(this.j&&this.a.useCmsd){var a=kC(this.j,_.Td);a=null==a?null:a;if(null!==a)return this.g.debug("Using CMSD estimatedThroughputKbps:",a),1E3*a}return this.w.getBandwidthEstimate(this.a.defaultBandwidthEstimate)}setTracks(a){this.f=
a}setCmsdManager(a){this.j=a}configure(a){this.a=a}reset(){this.B=!1;this.w=new aE;const a=this.chooseTrack();a&&this.A(a)}};var yJ=class{constructor(){this.a=null}};var zJ=class{constructor(){this.a=new Map}clear(){this.a.clear()}},RF=class{constructor(){this.text=this.video=this.Za=this.audio=null}};var AJ=class{constructor(a,b){this.f=a;this.a=new Set([a]);b=b||[];for(const c of b)this.add(c)}add(a,b){b=void 0===b?!0:b;if(VF(this.f,a,void 0===b?!0:b))return this.a.add(a),!0;_.C("Dropping variant due to incompatible codecs for the current adaptation set. This may be because CodecSwitchingStrategy is set to PREVENT or SourceBuffer.changeType() is not available on this platform. Variant dropped:",a,"because it is not compatible with",this.f);return!1}values(){return this.a.values()}};var yH=class{constructor(a,b){b=void 0===b?_.lf:b;this.f=a;this.a=b;this.h=new eI(a.language,"",a.audio&&a.audio.channelsCount?a.audio.channelsCount:0,!1,b)}create(a){const b=this.a===_.Hf&&KC(),c=a.filter(d=>VF(this.f,d,!b));return c.length?new AJ(c[0],c):this.h.create(a)}},eI=class{constructor(a,b,c,d,e){this.j=_.$h(a);this.a=b;this.f=c;this.l=void 0===d?!1:d;this.h=void 0===e?_.lf:e}create(a){var b=WF(a,this.j);0<b.length&&(a=b);b=!1;if(this.a){var c=XF(a,this.a);0<c.length?(a=c,b=!0):_.C("No exact match for preferred variant role could be "+
`found. Role: ${this.a}`)}b||(b=a.filter(d=>d.primary),0<b.length&&(a=b));this.f&&(b=sF(a,this.f),b.length?a=b:_.C("No exact match for the channel count could be found."));b=YF(a,this.l);b.length?a=b:_.C("No exact match for spatial audio could be found.");b=this.h===_.Hf&&KC();c=new AJ(a[0]);for(const d of a)c.add(d,!b);return c}};var UI=class{constructor(a,b){this.a=YI;this.f=(new Map).set(YI,b).set(KI,a)}getState(){return this.a}},KI=0,YI=1;var iI=class{constructor(a){this.D=a;this.a=a.getConfiguration().streaming;this.f=new _.Nt;this.g=new _.S("clpp.mse.media.LiveEdgeObserver");ZF(this)&&(a=this.D.getSurface().getMedia(),this.f.on(a,_.Zf,()=>{{var b=this.D.getPosition();const c=this.D.getSeekRange().end;b=c-b;const d=this.D.getPlaybackRate(),e=this.a.stopChasingAt;1<=d&&b>=this.a.chaseJumpDistance?(this.g.debug("Too far from edge, jump to beginning."),this.D.setPlaybackRate(1),this.D.seek(c)):1===d&&b>=this.a.startChasingAt?(this.g.debug("Not on live edge, increase playback rate."),
this.D.setPlaybackRate(this.a.chasingRate,_.zd)):1<d&&b<=e&&(this.g.debug("On live edge, reduce playback rate."),this.D.setPlaybackRate(1))}}))}release(){this.f.release()}};var RI=class{constructor(a){this.h=a;this.a=null;this.f=()=>{}}release(){this.a=this.h=null;this.f=()=>{}}l(a){const b=this.a;{const c=this.h.periods;a=RC(c,a)||c[0]}b!==a&&this.f(a);this.a=a}};var hI=class{constructor(a){this.f=a;this.o=this.A=this.l=!1;this.h=this.f.ag();this.w=_.zd;this.j=null;this.a=new _.rk(()=>{this.A||this.f.Zh(.25*this.h)});this.g=new _.S("clpp.mse.media.PlayRateController")}getConfiguration(){return this.j}release(){this.a&&(this.a.stop(),this.a=null);this.f=null}set(a,b){this.h=a;dG(this,b)}};var gG=new _.Hu(()=>new Uint8Array([0,0,0,80,115,105,110,102,0,0,0,12,102,114,109,97,0,0,0,0,0,0,0,20,115,99,104,109,0,0,0,0,99,101,110,99,0,1,0,0,0,0,0,40,115,99,104,105,0,0,0,32,116,101,110,99,0,0,0,0,0,0,1,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));_.VI=class{constructor(a,b){this.D=b;this.j=a;kG(a);this.h=null;this.l=1;this.G=Promise.resolve();this.B=new Map;this.w=new Map;this.a=new Map;this.I=this.f=this.o=this.C=!1;this.H=0;this.g=new _.S("clpp.mse.Streaming");this.A=this.F=!1}destroy(){const a=this;return _.x(function*(){const b=[];for(const c of a.a.values())lG(c),b.push(mG(c));yield Promise.all(b);a.a.clear();a.w.clear();a.D=null;a.j=null;a.G=null;a.B.clear();a.h=null;a.f=!0})}start(){const a=this;return _.x(function*(){const b=a.D.Ib();
var c=RC(a.j.periods,b+_.fu);if(!c)throw new _.I(_.G,5,5006,"No period found.");c=a.D.Pe(c);if(!c.video&&!c.audio&&!c.text)throw a.g.error("start(): No streams chosen"),new _.I(_.G,5,5005,"No streams chosen.");a.F=!c.video&&!c.audio&&!!c.text;a.A=!!c.Za;yield sG(a,c.audio,c.video,c.text,b);a.f||(a.g.debug("init: completed initial Stream setup"),a.D&&a.D.ai&&(a.g.debug("init: calling onInitialStreamsSetup()..."),a.D.ai()))})}resume(){if(!PG(this))for(const a of this.a.values())a.endOfStream=!1,rG(this,
a,0)}Vb(a){const b=this;return _.x(function*(){if(!b.f){var c=iG(a);if(!a.wb&&null!=a.kb&&!a.nc)if(a.kb=null,a.$b)b.g.debug(c,"skipping update and clearing the buffer"),yield HG(b,a,a.qe,a.Md);else{try{const d=$G(b,a);null!=d&&(rG(b,a,d),a.Rc=!1)}catch(d){yield aH(b,d);return}bH(b,a);if(QG(b))if(b.D.configuration.Th){b.g.debug("End of stream reached, keeping MediaSource open.");for(const d of b.a.values())d.kb=null}else b.g.debug("End of stream reached, calling ms.endOfStream()."),yield b.D.aa.endOfStream(),
b.f||(c=b.D.aa.getDuration(),c<b.j.presentationTimeline.getDuration()&&(b.j.presentationTimeline.f=c),b.D.og())}}})}J(a,b,c,d){const e=aC(d.reader),f=aC(d.reader),g=_.P(d.reader),h=_.P(d.reader),k=_.P(d.reader),l=_.P(d.reader);d=_.em(d.reader,d.reader.Na()-d.reader.getPosition());a=a.startTime+b.startTime+h/g;c.includes(e)&&("urn:mpeg:dash:event:2012"===e?this.D.sg():(c=new _.F("emsg",{detail:{startTime:a,endTime:a+k/g,schemeIdUri:e,value:f,timescale:g,presentationTimeDelta:h,eventDuration:k,id:l,
messageData:d}}),this.D.onEvent(c)))}K(a){let b=!1,c=0;(new _.om).N(_.ye,_.hm).N(_.ag,_.hm).N(_.qe,_.hm).N(_.xe,_.hm).N(_.Mf,_.hm).ea(_.Of,_.im).N("encv",d=>{d.reader.skip(78);_.hm(d)}).N("pasp",d=>{c=d.start+d.headerSize;const e=_.P(d.reader),f=_.P(d.reader);b=e!==f;this.g.debug(`hSpacing=${e}, vSpacing=${f}, updatePASP=${b}`);d.parser.stop()}).parse(a.data);b&&(a=new _.qm(new DataView(a.data)),a.seek(c),_.O(a,1),_.O(a,1))}};var BJ=class{constructor(){this.a=null}};var CJ=class extends _.vu{constructor(){super(KB);this.H=wI;this.l=this.ba=null;this.rf=0;this.Hg=2;this.Db=null;this.af=!1;this.w=new _.Nt;this.Ua=this.vf=this.Yd=this.I=this.bb=this.C=this.L=this.B=null;this.rc=!1;this.f=this.j=this.a=this.K=this.J=null;this.h=new _.xJ;this.V=this.Xd=null;this.yf=1E9;this.Zd=new Set;this.X=!0;this.fa=null;this.xf=!1;this.wf=0;this.S=null;this.o=new zJ;this.G=null;this.za=_.To;this.oc=new eI(this.configuration.preferredAudioLanguage||[],this.configuration.preferredAudioRole,
this.configuration.preferredAudioChannelCount,this.configuration.preferSpatialAudio,this.configuration.mediaSource.codecSwitchingStrategy);this.lc=this.configuration.preferredTextLanguage;this.A=new yJ;this.da=this.Ja=null;this.Cb=new Map;this.pc=null;this.Wd=this.configuration.preferredTextRole;this.kc=this.configuration.preferForcedSubtitles;this.w.on(window,"online",()=>{this.H===DH&&OG(this.a)});this.be=this.mc=this.de=null;this.R=_.ma;this.uc=new BJ;this.jf=null}init(a,b){const c=a.getMedia();
super.init(a,b);FH(this,c)}namespace(){return KB}setSeekInterceptor(a){this.vf=a||null}setPlaybackSessionId(a){this.jf=a}Jg(){return new wJ}getState(){return this.za}getDrmInfo(){return this.B?this.B.getDrmInfo():null}unload(){const a=this;return _.x(function*(){IE(a,!1);a.rc=!1;if(a.ga){a.log.debug("Unload player with source",a.ga);var b=a.getTrackManager();b&&b.release();a.H!==PH&&(yield NH(a),a.ga=null,a.rf=0,a.Ja=null,a.da=null,a.getNetworkEngine().headers.delete(EB))}})}release(){const a=this;
return _.x(function*(){if(a.ba)return a.ba;a.ba=OH(a);a.ba.finally(()=>{a.ba=null});return a.ba})}getBufferInfo(a){if(this.L){var b=gF(this.L);const c=new _.ru(void 0,a);switch(a){case _.N:return b.video?b.video:c;case _.M:return b.audio?b.audio:c;case _.L:return b.text?b.text:c}return b.total?b.total:c}return this.Db?(b=MC(this.Db),EC(b,a)):super.getBufferInfo(a)}getPosition(){var a=this.uc,b=this.getMediaPosition();a.a&&(a=a.a,b-=a.f,b=0>b?0:b>a.a?a.a:b);return b}getMediaPosition(){return this.C?
MD(this.C):super.getMediaPosition()}seek(a,b){if(this.vf&&!this.vf(a,b))return Promise.resolve();b=this.uc;b=b.a?a+b.a.Rb():a;b!==a&&this.log.info(`Seeking to ${a} s corresponding to `+`media time of ${b} s.`);return super.seek(b)}getPresentationStartTime(){return this.f?this.f.presentationTimeline.getPresentationStartTime():null}getDuration(){var a=this.uc,b=this.getMediaDuration();return a.a?a.a.getDuration():b}getMediaDuration(){return this.f?this.f.presentationTimeline.getDuration():Infinity}destroy(){const a=
this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.x(function*(){yield b().call(a);a.H!==PH&&(a.log.debug("Destroying player..."),a.H=PH,LH(a),a.w&&(a.w.release(),a.w=null),a.mc=null,a.h=null)})}getTimeline(){return this.mc}setupPlaylist(a){const b=this;return _.x(function*(){const c=new _.bn;b.A.a=c;try{JH(b);b.R=_.bb;yield QH(b);QF(b.A,c);const d=a[0];d.playlist&&d.playlist.startTime&&(d.startTime=d.playlist.startTime);b.ga=_.Zo(d);b.configuration=_.tl(b.ia,d);b.log.info("Loading playlist configurations",
a);b.mc=RH(b.configuration);yield VH(b,c);QF(b.A,c);const e=a.map(n=>YH(b,n,0,null,!0)),f=yield Promise.all(e),g=f.filter(n=>n.manifest.presentationTimeline.isLive()),h=g[0];h&&(b.j=h.parser);if(1<g.length)throw new _.I(_.G,7,7003,"Playlist of multiple live streams is not supported.");if(h){const n=b.configuration.playlist.content;if(n===_.Cb)throw new _.I(_.G,7,7003,"Cannot play live content in VOD mode.");if("IPR"===n&&h!==f[f.length-1])throw new _.I(_.G,7,7003,"Wrong order of playlist assets.");
}const k=new _.rJ({version:2},null,0,null==h),l=f.map(n=>sE(n.manifest)),m=vE(l,k);b.f=m;b.B=yield bI(b,m,b.configuration);QF(b.A,c);yield oI(b,c);QF(b.A,c);MG(b.a,m);pI(b,m);c.resolve()}catch(d){b.j&&(yield b.j.stop(),b.j=null),rI(b,d,c)}})}appendLoad(a){const b=this;return _.x(function*(){JH(b);if(b.R!==_.bb)throw new _.I(_.G,7,7003,"Cannot append-load to non-playlist player.");const c=yield sI(b,a);b.f=c.manifest;b.j=c.parser;MG(b.a,c.manifest);QG(b.a)&&b.a.resume();pI(b,c.manifest)})}seekWith(a){return this.seek(this.getPosition()+
a)}Ig(){const a=this;return _.x(function*(){JH(a);a.de?(a.log.info("Loading preloaded asset",a.de),a.de=null,yield oI(a,null)):a.log.warn("No preloaded asset found")})}preload(a){const b=this;return _.x(function*(){JH(b);_.vn("preload.start");b.log.info("Preloading asset",a);yield CI(b,a,!1);b.de=a;b.log.info("Preloaded asset",a);_.vn("preload.end");_.xn("preload","preload.start","preload.end")})}load(a){return CI(this,a)}detach(){const a=this;return _.x(function*(){yield KH(a);a.configuration=a.ia;
LH(a)})}isLive(){var a;this.f?(a=this.f.presentationTimeline.isLive())||(a=this.f.presentationTimeline,a=Infinity!==a.f&&!a.l):a=!1;return a}zf(){this.log.debug("User seeking finished");this.J&&LI(this);II(this)}getSeekRange(){var a={start:0,end:0};if(this.f){var b=this.f.presentationTimeline;a={start:aD(b),end:kD(b)}}b=this.uc;b.a?(b=b.a.getDuration(),b>a.end&&(b=a.end),b={start:0,end:b}):b=a;return b}vc(){return this.f?this.f.presentationTimeline.vc():null}getPlaybackRate(){if(this.I){var a=this.I;
a=a.l?0:a.h}else a=0;return a}setPlaybackRate(a,b){if(0===a)this.log.warn("A trick play rate of 0 is unsupported!");else if(this.H===DH){if(_.vk()){this.log.warn("Pausing and unpausing to mitigate playbackRate platform issue.");var c=this.getSurface().getMedia();c.pause();this.I.set(a,b);c.play()}else this.I.set(a,b);if((b=this.I.getConfiguration())&&b.preferTrickPlayTracks){b=this.a;var d=1<Math.abs(a);if(c=b.a.get(_.w)){var e=c.stream;if(e)if(b.g.debug("setTrickPlay",d),d)(d=e.trickModeVideo)&&
!c.ec&&(b.g.debug("Engaging trick mode stream",d),_.IG(b,d,!1,0),c.ec=e);else if(e=c.ec)b.g.debug("Restoring non-trick-mode stream",e),c.ec=null,_.IG(b,e,!0,0)}}this.h.playbackRateChanged(a)}}ma(){if(this.f&&this.C){var a=QE(this);if(null==a)a=null;else{if(!RE(this.o,a).text){var b=_.NF(a.textStreams,this.lc,this.Wd,this.kc);b.length&&SF(this.o,a,b[0])}a=RE(this.o,a).text}b=[];for(const c of aJ(this)){const d=EF(c);d.activeText=c===a;b.push(d)}return b}return[]}getPeriods(){return this.f.periods}getStats(){if(this.H!==
DH)return _.Io();II(this);var a=this.l;if(a.getVideoPlaybackQuality){var b=a.getVideoPlaybackQuality();a=this.G;var c=Number(b.totalVideoFrames);a.o=Number(b.droppedVideoFrames);a.l=c}if(this.H===DH){(c=QE(this))?(a=RE(this.o,c).video,c=RE(this.o,c).audio,a=(a.bandwidth||0)+(c.bandwidth||0)):a=null;a&&(this.G.w=a);if(b=rH(this))a=this.G,c=b.height||NaN,a.A=b.width||NaN,a.j=c;a=this.h.getBandwidthEstimate();this.G.h=a}return this.G.getStats()}getBandwidthEstimate(){return this.h.getBandwidthEstimate()}getCueTimeline(){return this.K}getTimelineCues(){return this.K?
oD(this.K,FI(this)):[]}resetAbr(){this.h&&this.h.reset()}gd(){return this.h}addTextTrack(a,b,c,d,e,f){const g=this;return _.x(function*(){if(g.H!==DH)throw g.log.error("Must call load() and wait for it to resolve before adding text tracks."),Error("State error!");const h=QE(g);var k=g.f.periods.indexOf(h)+1;const l=(k>=g.f.periods.length?g.f.presentationTimeline.getDuration():g.f.periods[k].startTime)-h.startTime;if(Infinity===l)throw new _.I(1,4,4040);const m=new _.sD(1,0,l,()=>[a],0,null,0);k={id:g.yf++,
originalId:null,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>1,getSegmentReference:r=>1===r?m:null,adjustSegmentDurations:()=>{},getDuration:()=>l,segmentLookupStrategy:_.NB,initSegmentReference:null,mimeType:d,codecs:e||"",kind:c,encrypted:!1,keyId:null,language:b,originalLanguage:b,label:f||null,type:_.H,primary:!1,trickModeVideo:null,emsgSchemeIdUris:null,roles:[],channelsCount:null,spatialAudio:!1,closedCaptions:null};g.Zd.add(k);h.textStreams.push(k);yield yG(g.a,
k);const n=_.vG(g.a,_.H);n&&SF(g.o,h,n);g.Zd.delete(k);g.log.debug("Choosing new streams after adding a text stream");eJ(g,h);$H(g);return EF(k)})}Mg(a){this.log.debug(_.RB,a);try{this.log.debug("onChooseStreams_, choosing variant from ",a.variants);this.log.debug("onChooseStreams_, choosing text from ",a.textStreams);const b=fJ(this,a);this.log.debug("onChooseStreams_, chose video ",b.video);this.log.debug("onChooseStreams_, chose audio ",b.audio);this.log.debug("onChooseStreams_, chose text ",b.text);
return b}catch(b){return this.onError(b),{audio:null,video:null,text:null,Za:null}}}Lg(){this.log.debug("canSwitch_");this.X=!1;this.configuration.abr.enabled&&this.h.enable();this.fa&&(JG(this.a,this.fa,this.xf,this.wf),this.fa=null);this.S&&(_.IG(this.a,this.S,!0,0),this.S=null)}Rg(){this.j&&this.j.update()}Og(){this.C&&this.C.j.ge()}Kg(a,b,c){if((void 0===c?"":c)===PB)return $H(this),this.ta()||(this.configuration.abr.enabled=!0,this.h.enable()),eJ(this,b,!1),!0;if(c=b.variants.some(d=>{let e=
!1;const f=d[a.type];f&&(e=d.allowedByApplication&&f.id!==a.id,a.type===_.p&&(e=e&&f.language===a.language));return e})&&this.ta()){for(const d of b.variants){const e=d[a.type];e&&e.id===a.id&&(d.allowedByApplication=!1)}$H(this);this.ta()||(this.configuration.abr.enabled=!0,this.h.enable());eJ(this,b)}return c}Ng(){this.log.debug("endOfStream called by streaming engine");this.rc=!0}onError(a){if(this.H!==PH&&7001!==a.code&&7E3!==a.code){var b=new _.F(_.q,{detail:a});a.severity===_.G&&IH(this,_.Mo);
this.trigger(b);b.defaultPrevented&&(b.a=!0)}}nf(a){a.type===_.Md?this.dispatchEvent(a):"largegap"!==a.type&&(a.type===_.zg?xI(this):"emsg"!==a.type&&(a instanceof _.F?this.dispatchEvent(a):this.log.debug(_.vb,a.type)))}ta(){return this.configuration.abr.enabled}Qg(a){const b=this;return _.x(function*(){if(b.Ic){b.log.info("Attempt to switch CDN.");var c=b.getLoadedSource(),d=b.ta();if(c=yield b.Ic(c.url,a)){c=_.Wg(b.getLoadedSource(),{url:c});d&&b.h.disable();yield RG(b.a);var e=rH(b),f=sH(b);do{var g=
!1;try{b.log.info(`Switching CDN to ${c.url}.`),yield gJ(b,c,e,f)}catch(h){if(b.log.info("Switch failed"),g=yield b.Ic(c.url,a))c.url=g,g=!0;else throw h;}}while(g);d&&b.h.enable();OG(b.a,!0);b.ga[b.getSourceIndex()]=c;a.f=!0;b.trigger(new _.F(_.Sc,{newManifest:c.url}))}}})}},PH=0,wI=1,DH=2,ZH=[_.Me,_.ce];
_.uh(new class{a(){return KB}canPlay(a,b){if(_.Ek())return 0;const c=a.type||"",d=(window.ManagedMediaSource?!0:!1)||(window.MediaSource&&MediaSource.isTypeSupported?!0:!1);a=window.ManagedMediaSource||window.MediaSource&&MediaSource.isTypeSupported?c in _.Ys||_.Zs(a.url)in _.$s?!0:!1:!1;if(d&&a){if(_.vk(2))return 1;if(_.Fk()&&c===_.kl){if(b.streaming.preferNativeHlsOnSafari)return 1;_.C("Support for MSE + FairPlay on Apple is experimental. In case of issues, consider using native HLS.")}return 2}return 0}f(a){return a===
_.ma||a===_.bb}create(){return new CJ}});_.hr(function(){_.qh("MediaSource.install");if(window.MediaSource)if(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType)_.ph("Patching Chromecast MSE bugs."),hJ();else if(_.Fk()){var a=navigator.appVersion;a=0<=a.indexOf("Version")?parseInt(a.match(/Version\/(\d+)/)[1],10):13;iJ();10>=a?(_.ph("Blacklisting MSE on Safari \x3c\x3d 10."),window.MediaSource=null):12>=a?(_.ph("Patching Safari 11 \x26 12 MSE bugs."),jJ(),kJ()):(_.ph("Patching Safari 13 MSE bugs."),jJ())}else _.vk(2)||_.vk(3)||
_.vk(4)?lJ():_.ph("Using native MSE as-is.");else _.ph("No MSE implementation available.")});var DJ=class extends _.Ov{constructor(a){super(a);a=a.getSurface().getMedia();this.a=null;for(let b=0;b<a.textTracks.length;++b){const c=a.textTracks[b];c.mode=_.Bd;c.label===zB&&(this.a=c)}this.a||(this.a=a.addTextTrack(_.YB,zB));this.a.mode=_.$d}append(a){const b=[],c=d=>{if(d.startTime>=d.endTime)_.C("Invalid cue times: "+d.startTime+" - "+d.endTime),d=null;else{var e=d.payload||"";e=e.replace(/<br\s*\/?>/igm,"\n");e=_.gj(e);e=new VTTCue(d.startTime,d.endTime,e);e.line=-1;try{e.align=_.Uc}catch(f){e.align=
"middle"}d.writingMode===_.mg?e.vertical="lr":d.writingMode===_.ng&&(e.vertical="rl");d=e}d&&b.push(d)};for(const d of a)c(d);a=b.slice().sort((d,e)=>d.startTime!==e.startTime?d.startTime-e.startTime:d.endTime!==e.endTime?d.endTime-e.startTime:b.indexOf(e)-b.indexOf(d));for(const d of a)this.a.addCue(d)}remove(a,b){if(!this.a)return!1;mJ(this.a,c=>c.startTime<b&&c.endTime>a);return!0}isTextVisible(){return this.a.mode===_.Df}setTextVisibility(a){null!==this.a&&(this.a.mode=a?_.Df:_.$d)}destroy(){this.a&&
mJ(this.a,()=>!0);this.a=null;return Promise.resolve()}};_.Co("single-native",new class{a(){return!0}create(a){return new DJ(a)}});};f.call(g, window);