stream-engine-player 0.0.41 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,7 +101,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
101
101
|
`;return n},sP=function(t){var i=t.bytes;return BT(i)},oP=function(t){var i="",r=void 0;for(r=0;r<t.length;r++)i+=iP(t,r)+" ";return i},uP=Object.freeze({createTransferableMessage:FT,initSegmentId:Kf,segmentKeyId:UT,hexDump:BT,tagDump:sP,textRanges:oP}),jT=.25,lP=function(t,i){if(!i.dateTimeObject)return null;var r=i.videoTimingInfo.transmuxerPrependedSeconds,n=i.videoTimingInfo.transmuxedPresentationStart,a=n+r,s=t-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},cP=function(t){return t.transmuxedPresentationEnd-t.transmuxedPresentationStart-t.transmuxerPrependedSeconds},dP=function(t,i){var r=void 0;try{r=new Date(t)}catch{return null}if(!i||!i.segments||i.segments.length===0)return null;var n=i.segments[0];if(r<n.dateTimeObject)return null;for(var a=0;a<i.segments.length-1;a++){n=i.segments[a];var s=i.segments[a+1].dateTimeObject;if(r<s)break}var o=i.segments[i.segments.length-1],l=o.dateTimeObject,u=o.videoTimingInfo?cP(o.videoTimingInfo):o.duration+o.duration*jT,h=new Date(l.getTime()+u*1e3);return r>h?null:(r>l&&(n=o),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:sa.duration(i,i.mediaSequence+i.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},fP=function(t,i){if(!i||!i.segments||i.segments.length===0)return null;for(var r=0,n=void 0,a=0;a<i.segments.length&&(n=i.segments[a],r=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:r+n.duration,!(t<=r));a++);var s=i.segments[i.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<t)return null;if(t>r){if(t>r+s.duration*jT)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:r-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},hP=function(t,i){var r=void 0,n=void 0;try{r=new Date(t),n=new Date(i)}catch{}var a=r.getTime(),s=n.getTime();return(s-a)/1e3},pP=function(t){if(!t.segments||t.segments.length===0)return!1;for(var i=0;i<t.segments.length;i++){var r=t.segments[i];if(!r.dateTimeObject)return!1}return!0},gP=function(t){var i=t.playlist,r=t.time,n=r===void 0?void 0:r,a=t.callback;if(!a)throw new Error("getProgramTime: callback must be provided");if(!i||n===void 0)return a({message:"getProgramTime: playlist and time must be provided"});var s=fP(n,i);if(!s)return a({message:"valid programTime was not found"});if(s.type==="estimate")return a({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var o={mediaSeconds:n},l=lP(n,s.segment);return l&&(o.programDateTime=l.toISOString()),a(null,o)},vP=function e(t){var i=t.programTime,r=t.playlist,n=t.retryCount,a=n===void 0?2:n,s=t.seekTo,o=t.pauseAfterSeek,l=o===void 0?!0:o,u=t.tech,h=t.callback;if(!h)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!r||!s)return h({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!r.endList&&!u.hasStarted_)return h({message:"player must be playing a live stream to start buffering"});if(!pP(r))return h({message:"programDateTime tags must be provided in the manifest "+r.resolvedUri});var c=dP(i,r);if(!c)return h({message:i+" was not found in the stream"});var d=c.segment,f=hP(d.dateTimeObject,i);if(c.type==="estimate"){if(a===0)return h({message:i+" is not buffered yet. Try again"});s(c.estimatedStart+f),u.one("seeked",function(){e({programTime:i,playlist:r,retryCount:a-1,seekTo:s,pauseAfterSeek:l,tech:u,callback:h})});return}var T=d.start+f,p=function(){return h(null,u.currentTime())};u.one("seeked",p),l&&u.pause(),s(T)},zf=1/30,ao=zf*3,$T=function(t,i){var r=[],n=void 0;if(t&&t.length)for(n=0;n<t.length;n++)i(t.start(n),t.end(n))&&r.push([t.start(n),t.end(n)]);return re.createTimeRanges(r)},HT=function(t,i){return $T(t,function(r,n){return r-ao<=i&&n+ao>=i})},GT=function(t,i){return $T(t,function(r){return r-zf>=i})},mP=function(t){if(t.length<2)return re.createTimeRanges();for(var i=[],r=1;r<t.length;r++){var n=t.end(r-1),a=t.start(r);i.push([n,a])}return re.createTimeRanges(i)},bv=function(t){var i=[];if(!t||!t.length)return"";for(var r=0;r<t.length;r++)i.push(t.start(r)+" => "+t.end(r));return i.join(", ")},yP=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=t.length?t.end(t.length-1):0;return(n-i)/r},VT=function(t){for(var i=[],r=0;r<t.length;r++)i.push({start:t.start(r),end:t.end(r)});return i},_P=function(t,i,r){var n=i.player_;if(r.captions&&r.captions.length){t.inbandTextTracks_||(t.inbandTextTracks_={});for(var a in r.captionStreams)if(!t.inbandTextTracks_[a]){n.tech_.trigger({type:"usage",name:"hls-608"});var s=n.textTracks().getTrackById(a);s?t.inbandTextTracks_[a]=s:t.inbandTextTracks_[a]=n.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}r.metadata&&r.metadata.length&&!t.metadataTrack_&&(t.metadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,t.metadataTrack_.inBandMetadataTrackDispatchType=r.metadata.dispatchType)},ql=function(t,i,r){var n=void 0,a=void 0;if(!!r&&!!r.cues)for(n=r.cues.length;n--;)a=r.cues[n],a.startTime<=i&&a.endTime>=t&&r.removeCue(a)},bP=function(t){Object.defineProperties(t.frame,{id:{get:function(){return re.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return re.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return re.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},qT=function(t){var i=void 0;return isNaN(t)||Math.abs(t)===1/0?i=Number.MAX_VALUE:i=t,i},TP=function(t,i,r){var n=Be.WebKitDataCue||Be.VTTCue;if(i&&i.forEach(function(c){var d=c.stream;this.inbandTextTracks_[d].addCue(new n(c.startTime+this.timestampOffset,c.endTime+this.timestampOffset,c.text))},t),r){var a=qT(t.mediaSource_.duration);if(r.forEach(function(c){var d=c.cueTime+this.timestampOffset;typeof d!="number"||Be.isNaN(d)||d<0||!(d<1/0)||c.frames.forEach(function(f){var T=new n(d,d,f.value||f.url||f.data||"");T.frame=f,T.value=f,bP(T),this.metadataTrack_.addCue(T)},this)},t),t.metadataTrack_&&t.metadataTrack_.cues&&t.metadataTrack_.cues.length){for(var s=t.metadataTrack_.cues,o=[],l=0;l<s.length;l++)s[l]&&o.push(s[l]);var u=o.reduce(function(c,d){var f=c[d.startTime]||[];return f.push(d),c[d.startTime]=f,c},{}),h=Object.keys(u).sort(function(c,d){return Number(c)-Number(d)});h.forEach(function(c,d){var f=u[c],T=Number(h[d+1])||a;f.forEach(function(p){p.endTime=T})})}}},Lu=typeof window<"u"?window:{},Tv=typeof Symbol>"u"?"__target":Symbol(),SP="application/javascript",EP=Lu.BlobBuilder||Lu.WebKitBlobBuilder||Lu.MozBlobBuilder||Lu.MSBlobBuilder,Wl=Lu.URL||Lu.webkitURL||Wl&&Wl.msURL,Yl=Lu.Worker;function WT(e,t){return function(r){var n=this;if(t)if(Yl&&!r){var a=t.toString().replace(/^function.+?{/,"").slice(0,-1),s=XT(a);return this[Tv]=new Yl(s),xP(this[Tv],s),this[Tv]}else{var o={postMessage:function(u){n.onmessage&&setTimeout(function(){n.onmessage({data:u,target:o})})}};t.call(o),this.postMessage=function(l){setTimeout(function(){o.onmessage({data:l,target:n})})},this.isThisThread=!0}else return new Yl(e)}}if(Yl){var Xf,KT=XT("self.onmessage = function () {}"),zT=new Uint8Array(1);try{Xf=new Yl(KT),Xf.postMessage(zT,[zT.buffer])}catch{Yl=null}finally{Wl.revokeObjectURL(KT),Xf&&Xf.terminate()}}function XT(e){try{return Wl.createObjectURL(new Blob([e],{type:SP}))}catch{var t=new EP;return t.append(e),Wl.createObjectURL(t.getBlob(type))}}function xP(e,t){if(!(!e||!t)){var i=e.terminate;e.objURL=t,e.terminate=function(){e.objURL&&Wl.revokeObjectURL(e.objURL),i.call(e)}}}var wP=new WT("./transmuxer-worker.worker.js",function(e,t){var i=this;(function(){var r=function(){this.init=function(){var q={};this.on=function(z,ie){q[z]||(q[z]=[]),q[z]=q[z].concat(ie)},this.off=function(z,ie){var ne;return q[z]?(ne=q[z].indexOf(ie),q[z]=q[z].slice(),q[z].splice(ne,1),ne>-1):!1},this.trigger=function(z){var ie,ne,pe,me;if(ie=q[z],!!ie)if(arguments.length===2)for(pe=ie.length,ne=0;ne<pe;++ne)ie[ne].call(this,arguments[1]);else{for(me=[],ne=arguments.length,ne=1;ne<arguments.length;++ne)me.push(arguments[ne]);for(pe=ie.length,ne=0;ne<pe;++ne)ie[ne].apply(this,me)}},this.dispose=function(){q={}}}};r.prototype.pipe=function(xe){return this.on("data",function(q){xe.push(q)}),this.on("done",function(q){xe.flush(q)}),this.on("partialdone",function(q){xe.partialFlush(q)}),this.on("endedtimeline",function(q){xe.endTimeline(q)}),this.on("reset",function(q){xe.reset(q)}),xe},r.prototype.push=function(xe){this.trigger("data",xe)},r.prototype.flush=function(xe){this.trigger("done",xe)},r.prototype.partialFlush=function(xe){this.trigger("partialdone",xe)},r.prototype.endTimeline=function(xe){this.trigger("endedtimeline",xe)},r.prototype.reset=function(xe){this.trigger("reset",xe)};var n=r,a=Math.pow(2,32)-1,s,o,l,u,h,c,d,f,T,p,m,y,v,g,E,x,A,S,b,C,D,R,P,N,j,O,I,F,H,K,J,le,ce,Z,ve,Ce;(function(){var xe;if(P={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(xe in P)P.hasOwnProperty(xe)&&(P[xe]=[xe.charCodeAt(0),xe.charCodeAt(1),xe.charCodeAt(2),xe.charCodeAt(3)]);N=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),O=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),j=new Uint8Array([0,0,0,1]),I=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),F=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),H={video:I,audio:F},le=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),J=new Uint8Array([0,0,0,0,0,0,0,0]),ce=new Uint8Array([0,0,0,0,0,0,0,0]),Z=ce,ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ce=ce,K=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(q){var z=[],ie=0,ne,pe,me;for(ne=1;ne<arguments.length;ne++)z.push(arguments[ne]);for(ne=z.length;ne--;)ie+=z[ne].byteLength;for(pe=new Uint8Array(ie+8),me=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),me.setUint32(0,pe.byteLength),pe.set(q,4),ne=0,ie=8;ne<z.length;ne++)pe.set(z[ne],ie),ie+=z[ne].byteLength;return pe},o=function(){return s(P.dinf,s(P.dref,le))},l=function(q){return s(P.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,q.audioobjecttype<<3|q.samplingfrequencyindex>>>1,q.samplingfrequencyindex<<7|q.channelcount<<3,6,1,2]))},u=function(){return s(P.ftyp,N,j,N,O)},x=function(q){return s(P.hdlr,H[q])},h=function(q){return s(P.mdat,q)},E=function(q){var z=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,q.duration>>>24&255,q.duration>>>16&255,q.duration>>>8&255,q.duration&255,85,196,0,0]);return q.samplerate&&(z[12]=q.samplerate>>>24&255,z[13]=q.samplerate>>>16&255,z[14]=q.samplerate>>>8&255,z[15]=q.samplerate&255),s(P.mdhd,z)},g=function(q){return s(P.mdia,E(q),x(q.type),d(q))},c=function(q){return s(P.mfhd,new Uint8Array([0,0,0,0,(q&4278190080)>>24,(q&16711680)>>16,(q&65280)>>8,q&255]))},d=function(q){return s(P.minf,q.type==="video"?s(P.vmhd,K):s(P.smhd,J),o(),S(q))},f=function(q,z){for(var ie=[],ne=z.length;ne--;)ie[ne]=C(z[ne]);return s.apply(null,[P.moof,c(q)].concat(ie))},T=function(q){for(var z=q.length,ie=[];z--;)ie[z]=y(q[z]);return s.apply(null,[P.moov,m(4294967295)].concat(ie).concat(p(q)))},p=function(q){for(var z=q.length,ie=[];z--;)ie[z]=D(q[z]);return s.apply(null,[P.mvex].concat(ie))},m=function(q){var z=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(q&4278190080)>>24,(q&16711680)>>16,(q&65280)>>8,q&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s(P.mvhd,z)},A=function(q){var z=q.samples||[],ie=new Uint8Array(4+z.length),ne,pe;for(pe=0;pe<z.length;pe++)ne=z[pe].flags,ie[pe+4]=ne.dependsOn<<4|ne.isDependedOn<<2|ne.hasRedundancy;return s(P.sdtp,ie)},S=function(q){return s(P.stbl,b(q),s(P.stts,Ce),s(P.stsc,Z),s(P.stsz,ve),s(P.stco,ce))},function(){var xe,q;b=function(ie){return s(P.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),ie.type==="video"?xe(ie):q(ie))},xe=function(ie){var ne=ie.sps||[],pe=ie.pps||[],me=[],we=[],ke,Ve;for(ke=0;ke<ne.length;ke++)me.push((ne[ke].byteLength&65280)>>>8),me.push(ne[ke].byteLength&255),me=me.concat(Array.prototype.slice.call(ne[ke]));for(ke=0;ke<pe.length;ke++)we.push((pe[ke].byteLength&65280)>>>8),we.push(pe[ke].byteLength&255),we=we.concat(Array.prototype.slice.call(pe[ke]));if(Ve=[P.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(ie.width&65280)>>8,ie.width&255,(ie.height&65280)>>8,ie.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s(P.avcC,new Uint8Array([1,ie.profileIdc,ie.profileCompatibility,ie.levelIdc,255].concat([ne.length],me,[pe.length],we))),s(P.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],ie.sarRatio){var st=ie.sarRatio[0],Ft=ie.sarRatio[1];Ve.push(s(P.pasp,new Uint8Array([(st&4278190080)>>24,(st&16711680)>>16,(st&65280)>>8,st&255,(Ft&4278190080)>>24,(Ft&16711680)>>16,(Ft&65280)>>8,Ft&255])))}return s.apply(null,Ve)},q=function(ie){return s(P.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(ie.channelcount&65280)>>8,ie.channelcount&255,(ie.samplesize&65280)>>8,ie.samplesize&255,0,0,0,0,(ie.samplerate&65280)>>8,ie.samplerate&255,0,0]),l(ie))}}(),v=function(q){var z=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,0,(q.duration&4278190080)>>24,(q.duration&16711680)>>16,(q.duration&65280)>>8,q.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(q.width&65280)>>8,q.width&255,0,0,(q.height&65280)>>8,q.height&255,0,0]);return s(P.tkhd,z)},C=function(q){var z,ie,ne,pe,me,we,ke;return z=s(P.tfhd,new Uint8Array([0,0,0,58,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),we=Math.floor(q.baseMediaDecodeTime/(a+1)),ke=Math.floor(q.baseMediaDecodeTime%(a+1)),ie=s(P.tfdt,new Uint8Array([1,0,0,0,we>>>24&255,we>>>16&255,we>>>8&255,we&255,ke>>>24&255,ke>>>16&255,ke>>>8&255,ke&255])),me=32+20+8+16+8+8,q.type==="audio"?(ne=R(q,me),s(P.traf,z,ie,ne)):(pe=A(q),ne=R(q,pe.length+me),s(P.traf,z,ie,ne,pe))},y=function(q){return q.duration=q.duration||4294967295,s(P.trak,v(q),g(q))},D=function(q){var z=new Uint8Array([0,0,0,0,(q.id&4278190080)>>24,(q.id&16711680)>>16,(q.id&65280)>>8,q.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return q.type!=="video"&&(z[z.length-1]=0),s(P.trex,z)},function(){var xe,q,z;z=function(ne,pe){var me=0,we=0,ke=0,Ve=0;return ne.length&&(ne[0].duration!==void 0&&(me=1),ne[0].size!==void 0&&(we=2),ne[0].flags!==void 0&&(ke=4),ne[0].compositionTimeOffset!==void 0&&(Ve=8)),[0,0,me|we|ke|Ve,1,(ne.length&4278190080)>>>24,(ne.length&16711680)>>>16,(ne.length&65280)>>>8,ne.length&255,(pe&4278190080)>>>24,(pe&16711680)>>>16,(pe&65280)>>>8,pe&255]},q=function(ne,pe){var me,we,ke,Ve;for(we=ne.samples||[],pe+=8+12+16*we.length,me=z(we,pe),Ve=0;Ve<we.length;Ve++)ke=we[Ve],me=me.concat([(ke.duration&4278190080)>>>24,(ke.duration&16711680)>>>16,(ke.duration&65280)>>>8,ke.duration&255,(ke.size&4278190080)>>>24,(ke.size&16711680)>>>16,(ke.size&65280)>>>8,ke.size&255,ke.flags.isLeading<<2|ke.flags.dependsOn,ke.flags.isDependedOn<<6|ke.flags.hasRedundancy<<4|ke.flags.paddingValue<<1|ke.flags.isNonSyncSample,ke.flags.degradationPriority&240<<8,ke.flags.degradationPriority&15,(ke.compositionTimeOffset&4278190080)>>>24,(ke.compositionTimeOffset&16711680)>>>16,(ke.compositionTimeOffset&65280)>>>8,ke.compositionTimeOffset&255]);return s(P.trun,new Uint8Array(me))},xe=function(ne,pe){var me,we,ke,Ve;for(we=ne.samples||[],pe+=8+12+8*we.length,me=z(we,pe),Ve=0;Ve<we.length;Ve++)ke=we[Ve],me=me.concat([(ke.duration&4278190080)>>>24,(ke.duration&16711680)>>>16,(ke.duration&65280)>>>8,ke.duration&255,(ke.size&4278190080)>>>24,(ke.size&16711680)>>>16,(ke.size&65280)>>>8,ke.size&255]);return s(P.trun,new Uint8Array(me))},R=function(ne,pe){return ne.type==="audio"?xe(ne,pe):q(ne,pe)}}();var Ne={ftyp:u,mdat:h,moof:f,moov:T,initSegment:function(q){var z=u(),ie=T(q),ne;return ne=new Uint8Array(z.byteLength+ie.byteLength),ne.set(z),ne.set(ie,z.byteLength),ne}},ot=function(q){var z,ie,ne=[],pe=[];for(pe.byteLength=0,pe.nalCount=0,pe.duration=0,ne.byteLength=0,z=0;z<q.length;z++)ie=q[z],ie.nalUnitType==="access_unit_delimiter_rbsp"?(ne.length&&(ne.duration=ie.dts-ne.dts,pe.byteLength+=ne.byteLength,pe.nalCount+=ne.length,pe.duration+=ne.duration,pe.push(ne)),ne=[ie],ne.byteLength=ie.data.byteLength,ne.pts=ie.pts,ne.dts=ie.dts):(ie.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(ne.keyFrame=!0),ne.duration=ie.dts-ne.dts,ne.byteLength+=ie.data.byteLength,ne.push(ie));return pe.length&&(!ne.duration||ne.duration<=0)&&(ne.duration=pe[pe.length-1].duration),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.length,pe.duration+=ne.duration,pe.push(ne),pe},ze=function(q){var z,ie,ne=[],pe=[];for(ne.byteLength=0,ne.nalCount=0,ne.duration=0,ne.pts=q[0].pts,ne.dts=q[0].dts,pe.byteLength=0,pe.nalCount=0,pe.duration=0,pe.pts=q[0].pts,pe.dts=q[0].dts,z=0;z<q.length;z++)ie=q[z],ie.keyFrame?(ne.length&&(pe.push(ne),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.nalCount,pe.duration+=ne.duration),ne=[ie],ne.nalCount=ie.length,ne.byteLength=ie.byteLength,ne.pts=ie.pts,ne.dts=ie.dts,ne.duration=ie.duration):(ne.duration+=ie.duration,ne.nalCount+=ie.length,ne.byteLength+=ie.byteLength,ne.push(ie));return pe.length&&ne.duration<=0&&(ne.duration=pe[pe.length-1].duration),pe.byteLength+=ne.byteLength,pe.nalCount+=ne.nalCount,pe.duration+=ne.duration,pe.push(ne),pe},je=function(q){var z;return!q[0][0].keyFrame&&q.length>1&&(z=q.shift(),q.byteLength-=z.byteLength,q.nalCount-=z.nalCount,q[0][0].dts=z.dts,q[0][0].pts=z.pts,q[0][0].duration+=z.duration),q},Ze=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},Bt=function(q,z){var ie=Ze();return ie.dataOffset=z,ie.compositionTimeOffset=q.pts-q.dts,ie.duration=q.duration,ie.size=4*q.length,ie.size+=q.byteLength,q.keyFrame&&(ie.flags.dependsOn=2,ie.flags.isNonSyncSample=0),ie},qt=function(q,z){var ie,ne,pe,me,we,ke=z||0,Ve=[];for(ie=0;ie<q.length;ie++)for(me=q[ie],ne=0;ne<me.length;ne++)we=me[ne],pe=Bt(we,ke),ke+=pe.size,Ve.push(pe);return Ve},ir=function(q){var z,ie,ne,pe,me,we,ke=0,Ve=q.byteLength,st=q.nalCount,Ft=Ve+4*st,er=new Uint8Array(Ft),nr=new DataView(er.buffer);for(z=0;z<q.length;z++)for(pe=q[z],ie=0;ie<pe.length;ie++)for(me=pe[ie],ne=0;ne<me.length;ne++)we=me[ne],nr.setUint32(ke,we.data.byteLength),ke+=4,er.set(we.data,ke),ke+=we.data.byteLength;return er},We=function(q,z){var ie,ne=z||0,pe=[];return ie=Bt(q,ne),pe.push(ie),pe},vt=function(q){var z,ie,ne=0,pe=q.byteLength,me=q.length,we=pe+4*me,ke=new Uint8Array(we),Ve=new DataView(ke.buffer);for(z=0;z<q.length;z++)ie=q[z],Ve.setUint32(ne,ie.data.byteLength),ne+=4,ke.set(ie.data,ne),ne+=ie.data.byteLength;return ke},Tt={groupNalsIntoFrames:ot,groupFramesIntoGops:ze,extendFirstKeyFrame:je,generateSampleTable:qt,concatenateNalData:ir,generateSampleTableForFrame:We,concatenateNalDataForFrame:vt},wt=[33,16,5,32,164,27],Pt=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],at=function(q){for(var z=[];q--;)z.push(0);return z},Ot=function(q){return Object.keys(q).reduce(function(z,ie){return z[ie]=new Uint8Array(q[ie].reduce(function(ne,pe){return ne.concat(pe)},[])),z},{})},It={96e3:[wt,[227,64],at(154),[56]],88200:[wt,[231],at(170),[56]],64e3:[wt,[248,192],at(240),[56]],48e3:[wt,[255,192],at(268),[55,148,128],at(54),[112]],44100:[wt,[255,192],at(268),[55,163,128],at(84),[112]],32e3:[wt,[255,192],at(268),[55,234],at(226),[112]],24e3:[wt,[255,192],at(268),[55,255,128],at(268),[111,112],at(126),[224]],16e3:[wt,[255,192],at(268),[55,255,128],at(268),[111,255],at(269),[223,108],at(195),[1,192]],12e3:[Pt,at(268),[3,127,248],at(268),[6,255,240],at(268),[13,255,224],at(268),[27,253,128],at(259),[56]],11025:[Pt,at(268),[3,127,248],at(268),[6,255,240],at(268),[13,255,224],at(268),[27,255,192],at(268),[55,175,128],at(108),[112]],8e3:[Pt,at(268),[3,121,16],at(47),[7]]},sr=Ot(It),lt=9e4,ni,ei,wr,Ti,Vr,hi,pi;ni=function(q){return q*lt},ei=function(q,z){return q*z},wr=function(q){return q/lt},Ti=function(q,z){return q/z},Vr=function(q,z){return ni(Ti(q,z))},hi=function(q,z){return ei(wr(q),z)},pi=function(q,z,ie){return wr(ie?q:q-z)};var oi={ONE_SECOND_IN_TS:lt,secondsToVideoTs:ni,secondsToAudioTs:ei,videoTsToSeconds:wr,audioTsToSeconds:Ti,audioTsToVideoTs:Vr,videoTsToAudioTs:hi,metadataTsToSeconds:pi},Kr=function(q){var z,ie,ne=0;for(z=0;z<q.length;z++)ie=q[z],ne+=ie.data.byteLength;return ne},bn=function(q,z,ie,ne){var pe,me=0,we=0,ke=0,Ve=0,st,Ft,er;if(!!z.length&&(pe=oi.audioTsToVideoTs(q.baseMediaDecodeTime,q.samplerate),me=Math.ceil(oi.ONE_SECOND_IN_TS/(q.samplerate/1024)),ie&&ne&&(we=pe-Math.max(ie,ne),ke=Math.floor(we/me),Ve=ke*me),!(ke<1||Ve>oi.ONE_SECOND_IN_TS/2))){for(st=sr[q.samplerate],st||(st=z[0].data),Ft=0;Ft<ke;Ft++)er=z[0],z.splice(0,0,{data:st,dts:er.dts-me,pts:er.pts-me});q.baseMediaDecodeTime-=Math.floor(oi.videoTsToAudioTs(Ve,q.samplerate))}},Ba=function(q,z,ie){return z.minSegmentDts>=ie?q:(z.minSegmentDts=1/0,q.filter(function(ne){return ne.dts>=ie?(z.minSegmentDts=Math.min(z.minSegmentDts,ne.dts),z.minSegmentPts=z.minSegmentDts,!0):!1}))},xo=function(q){var z,ie,ne=[];for(z=0;z<q.length;z++)ie=q[z],ne.push({size:ie.data.byteLength,duration:1024});return ne},ls=function(q){var z,ie,ne=0,pe=new Uint8Array(Kr(q));for(z=0;z<q.length;z++)ie=q[z],pe.set(ie.data,ne),ne+=ie.data.byteLength;return pe},Kn={prefixWithSilence:bn,trimAdtsFramesByEarliestDts:Ba,generateSampleTable:xo,concatenateFrameData:ls},cs=oi.ONE_SECOND_IN_TS,wo=function(q,z){typeof z.pts=="number"&&(q.timelineStartInfo.pts===void 0&&(q.timelineStartInfo.pts=z.pts),q.minSegmentPts===void 0?q.minSegmentPts=z.pts:q.minSegmentPts=Math.min(q.minSegmentPts,z.pts),q.maxSegmentPts===void 0?q.maxSegmentPts=z.pts:q.maxSegmentPts=Math.max(q.maxSegmentPts,z.pts)),typeof z.dts=="number"&&(q.timelineStartInfo.dts===void 0&&(q.timelineStartInfo.dts=z.dts),q.minSegmentDts===void 0?q.minSegmentDts=z.dts:q.minSegmentDts=Math.min(q.minSegmentDts,z.dts),q.maxSegmentDts===void 0?q.maxSegmentDts=z.dts:q.maxSegmentDts=Math.max(q.maxSegmentDts,z.dts))},Tn=function(q){delete q.minSegmentDts,delete q.maxSegmentDts,delete q.minSegmentPts,delete q.maxSegmentPts},ya=function(q,z){var ie,ne,pe=q.minSegmentDts;return z||(pe-=q.timelineStartInfo.dts),ie=q.timelineStartInfo.baseMediaDecodeTime,ie+=pe,ie=Math.max(0,ie),q.type==="audio"&&(ne=q.samplerate/cs,ie*=ne,ie=Math.floor(ie)),ie},xi={clearDtsInfo:Tn,calculateTrackBaseMediaDecodeTime:ya,collectDtsInfo:wo},Ms=4,ou=128,Ao=function(q){for(var z=0,ie={payloadType:-1,payloadSize:0},ne=0,pe=0;z<q.byteLength&&q[z]!==ou;){for(;q[z]===255;)ne+=255,z++;for(ne+=q[z++];q[z]===255;)pe+=255,z++;if(pe+=q[z++],!ie.payload&&ne===Ms){ie.payloadType=ne,ie.payloadSize=pe,ie.payload=q.subarray(z,z+pe);break}z+=pe,ne=0,pe=0}return ie},ds=function(q){return q.payload[0]!==181||(q.payload[1]<<8|q.payload[2])!==49||String.fromCharCode(q.payload[3],q.payload[4],q.payload[5],q.payload[6])!=="GA94"||q.payload[7]!==3?null:q.payload.subarray(8,q.payload.length-1)},Sn=function(q,z){var ie=[],ne,pe,me,we;if(!(z[0]&64))return ie;for(pe=z[0]&31,ne=0;ne<pe;ne++)me=ne*3,we={type:z[me+2]&3,pts:q},z[me+2]&4&&(we.ccData=z[me+3]<<8|z[me+4],ie.push(we));return ie},ja=function(q){for(var z=q.byteLength,ie=[],ne=1,pe,me;ne<z-2;)q[ne]===0&&q[ne+1]===0&&q[ne+2]===3?(ie.push(ne+2),ne+=2):ne++;if(ie.length===0)return q;pe=z-ie.length,me=new Uint8Array(pe);var we=0;for(ne=0;ne<pe;we++,ne++)we===ie[0]&&(we++,ie.shift()),me[ne]=q[we];return me},$a={parseSei:Ao,parseUserData:ds,parseCaptionPackets:Sn,discardEmulationPreventionBytes:ja,USER_DATA_REGISTERED_ITU_T_T35:Ms},fn=function xe(){xe.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new ui(0,0),new ui(0,1),new ui(1,0),new ui(1,1)],this.reset(),this.ccStreams_.forEach(function(q){q.on("data",this.trigger.bind(this,"data")),q.on("partialdone",this.trigger.bind(this,"partialdone")),q.on("done",this.trigger.bind(this,"done"))},this)};fn.prototype=new n,fn.prototype.push=function(xe){var q,z,ie;if(xe.nalUnitType==="sei_rbsp"&&(q=$a.parseSei(xe.escapedRBSP),q.payloadType===$a.USER_DATA_REGISTERED_ITU_T_T35&&(z=$a.parseUserData(q),!!z))){if(xe.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(xe.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}ie=$a.parseCaptionPackets(xe.pts,z),this.captionPackets_=this.captionPackets_.concat(ie),this.latestDts_!==xe.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=xe.dts}},fn.prototype.flushCCStreams=function(xe){this.ccStreams_.forEach(function(q){return xe==="flush"?q.flush():q.partialFlush()},this)},fn.prototype.flushStream=function(xe){if(!this.captionPackets_.length){this.flushCCStreams(xe);return}this.captionPackets_.forEach(function(q,z){q.presortIndex=z}),this.captionPackets_.sort(function(q,z){return q.pts===z.pts?q.presortIndex-z.presortIndex:q.pts-z.pts}),this.captionPackets_.forEach(function(q){q.type<2&&this.dispatchCea608Packet(q)},this),this.captionPackets_.length=0,this.flushCCStreams(xe)},fn.prototype.flush=function(){return this.flushStream("flush")},fn.prototype.partialFlush=function(){return this.flushStream("partialFlush")},fn.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(xe){xe.reset()})},fn.prototype.dispatchCea608Packet=function(xe){this.setsTextOrXDSActive(xe)?this.activeCea608Channel_[xe.type]=null:this.setsChannel1Active(xe)?this.activeCea608Channel_[xe.type]=0:this.setsChannel2Active(xe)&&(this.activeCea608Channel_[xe.type]=1),this.activeCea608Channel_[xe.type]!==null&&this.ccStreams_[(xe.type<<1)+this.activeCea608Channel_[xe.type]].push(xe)},fn.prototype.setsChannel1Active=function(xe){return(xe.ccData&30720)===4096},fn.prototype.setsChannel2Active=function(xe){return(xe.ccData&30720)===6144},fn.prototype.setsTextOrXDSActive=function(xe){return(xe.ccData&28928)===256||(xe.ccData&30974)===4138||(xe.ccData&30974)===6186};var uu={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Ns=function(q){return q===null?"":(q=uu[q]||q,String.fromCharCode(q))},Fs=14,lu=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],zn=function(){for(var q=[],z=Fs+1;z--;)q.push("");return q},ui=function xe(q,z){xe.prototype.init.call(this),this.field_=q||0,this.dataChannel_=z||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(ie){var ne,pe,me,we,ke;if(ne=ie.ccData&32639,ne===this.lastControlCode_){this.lastControlCode_=null;return}if((ne&61440)===4096?this.lastControlCode_=ne:ne!==this.PADDING_&&(this.lastControlCode_=null),me=ne>>>8,we=ne&255,ne!==this.PADDING_)if(ne===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(ne===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(ie.pts),this.flushDisplayed(ie.pts),pe=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=pe,this.startPts_=ie.pts;else if(ne===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(ie.pts);else if(ne===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(ie.pts);else if(ne===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(ie.pts);else if(ne===this.CARRIAGE_RETURN_)this.clearFormatting(ie.pts),this.flushDisplayed(ie.pts),this.shiftRowsUp_(),this.startPts_=ie.pts;else if(ne===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(ne===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(ie.pts),this.displayed_=zn();else if(ne===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=zn();else if(ne===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(ie.pts),this.displayed_=zn()),this.mode_="paintOn",this.startPts_=ie.pts;else if(this.isSpecialCharacter(me,we))me=(me&3)<<8,ke=Ns(me|we),this[this.mode_](ie.pts,ke),this.column_++;else if(this.isExtCharacter(me,we))this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),me=(me&3)<<8,ke=Ns(me|we),this[this.mode_](ie.pts,ke),this.column_++;else if(this.isMidRowCode(me,we))this.clearFormatting(ie.pts),this[this.mode_](ie.pts," "),this.column_++,(we&14)===14&&this.addFormatting(ie.pts,["i"]),(we&1)===1&&this.addFormatting(ie.pts,["u"]);else if(this.isOffsetControlCode(me,we))this.column_+=we&3;else if(this.isPAC(me,we)){var Ve=lu.indexOf(ne&7968);this.mode_==="rollUp"&&(Ve-this.rollUpRows_+1<0&&(Ve=this.rollUpRows_-1),this.setRollUp(ie.pts,Ve)),Ve!==this.row_&&(this.clearFormatting(ie.pts),this.row_=Ve),we&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(ie.pts,["u"]),(ne&16)===16&&(this.column_=((ne&14)>>1)*4),this.isColorPAC(we)&&(we&14)===14&&this.addFormatting(ie.pts,["i"])}else this.isNormalChar(me)&&(we===0&&(we=null),ke=Ns(me),ke+=Ns(we),this[this.mode_](ie.pts,ke),this.column_+=ke.length)}};ui.prototype=new n,ui.prototype.flushDisplayed=function(xe){var q=this.displayed_.map(function(z){try{return z.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
|
102
102
|
`).replace(/^\n+|\n+$/g,"");q.length&&this.trigger("data",{startPts:this.startPts_,endPts:xe,text:q,stream:this.name_})},ui.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=zn(),this.nonDisplayed_=zn(),this.lastControlCode_=null,this.column_=0,this.row_=Fs,this.rollUpRows_=2,this.formatting_=[]},ui.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},ui.prototype.isSpecialCharacter=function(xe,q){return xe===this.EXT_&&q>=48&&q<=63},ui.prototype.isExtCharacter=function(xe,q){return(xe===this.EXT_+1||xe===this.EXT_+2)&&q>=32&&q<=63},ui.prototype.isMidRowCode=function(xe,q){return xe===this.EXT_&&q>=32&&q<=47},ui.prototype.isOffsetControlCode=function(xe,q){return xe===this.OFFSET_&&q>=33&&q<=35},ui.prototype.isPAC=function(xe,q){return xe>=this.BASE_&&xe<this.BASE_+8&&q>=64&&q<=127},ui.prototype.isColorPAC=function(xe){return xe>=64&&xe<=79||xe>=96&&xe<=127},ui.prototype.isNormalChar=function(xe){return xe>=32&&xe<=127},ui.prototype.setRollUp=function(xe,q){if(this.mode_!=="rollUp"&&(this.row_=Fs,this.mode_="rollUp",this.flushDisplayed(xe),this.nonDisplayed_=zn(),this.displayed_=zn()),q!==void 0&&q!==this.row_)for(var z=0;z<this.rollUpRows_;z++)this.displayed_[q-z]=this.displayed_[this.row_-z],this.displayed_[this.row_-z]="";q===void 0&&(q=this.row_),this.topRow_=q-this.rollUpRows_+1},ui.prototype.addFormatting=function(xe,q){this.formatting_=this.formatting_.concat(q);var z=q.reduce(function(ie,ne){return ie+"<"+ne+">"},"");this[this.mode_](xe,z)},ui.prototype.clearFormatting=function(xe){if(!!this.formatting_.length){var q=this.formatting_.reverse().reduce(function(z,ie){return z+"</"+ie+">"},"");this.formatting_=[],this[this.mode_](xe,q)}},ui.prototype.popOn=function(xe,q){var z=this.nonDisplayed_[this.row_];z+=q,this.nonDisplayed_[this.row_]=z},ui.prototype.rollUp=function(xe,q){var z=this.displayed_[this.row_];z+=q,this.displayed_[this.row_]=z},ui.prototype.shiftRowsUp_=function(){var xe;for(xe=0;xe<this.topRow_;xe++)this.displayed_[xe]="";for(xe=this.row_+1;xe<Fs+1;xe++)this.displayed_[xe]="";for(xe=this.topRow_;xe<this.row_;xe++)this.displayed_[xe]=this.displayed_[xe+1];this.displayed_[this.row_]=""},ui.prototype.paintOn=function(xe,q){var z=this.displayed_[this.row_];z+=q,this.displayed_[this.row_]=z};var Us={CaptionStream:fn,Cea608Stream:ui},rn={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Bs=8589934592,Ha=4294967296,_a="shared",fs=function(q,z){var ie=1;for(q>z&&(ie=-1);Math.abs(z-q)>Ha;)q+=ie*Bs;return q},hs=function xe(q){var z,ie;xe.prototype.init.call(this),this.type_=q||_a,this.push=function(ne){this.type_!==_a&&ne.type!==this.type_||(ie===void 0&&(ie=ne.dts),ne.dts=fs(ne.dts,ie),ne.pts=fs(ne.pts,ie),z=ne.dts,this.trigger("data",ne))},this.flush=function(){ie=z,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){ie=void 0,z=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};hs.prototype=new n;var wi={TimestampRolloverStream:hs,handleRollover:fs},En=function(q,z,ie){var ne,pe="";for(ne=z;ne<ie;ne++)pe+="%"+("00"+q[ne].toString(16)).slice(-2);return pe},js=function(q,z,ie){return decodeURIComponent(En(q,z,ie))},Ga=function(q,z,ie){return unescape(En(q,z,ie))},Mn=function(q){return q[0]<<21|q[1]<<14|q[2]<<7|q[3]},$s={TXXX:function(q){var z;if(q.data[0]===3){for(z=1;z<q.data.length;z++)if(q.data[z]===0){q.description=js(q.data,1,z),q.value=js(q.data,z+1,q.data.length).replace(/\0*$/,"");break}q.data=q.value}},WXXX:function(q){var z;if(q.data[0]===3){for(z=1;z<q.data.length;z++)if(q.data[z]===0){q.description=js(q.data,1,z),q.url=js(q.data,z+1,q.data.length);break}}},PRIV:function(q){var z;for(z=0;z<q.data.length;z++)if(q.data[z]===0){q.owner=Ga(q.data,0,z);break}q.privateData=q.data.subarray(z+1),q.data=q.privateData}},la;la=function(q){var z={debug:!!(q&&q.debug),descriptor:q&&q.descriptor},ie=0,ne=[],pe=0,me;if(la.prototype.init.call(this),this.dispatchType=rn.METADATA_STREAM_TYPE.toString(16),z.descriptor)for(me=0;me<z.descriptor.length;me++)this.dispatchType+=("00"+z.descriptor[me].toString(16)).slice(-2);this.push=function(we){var ke,Ve,st,Ft,er,nr;if(we.type==="timed-metadata"){if(we.dataAlignmentIndicator&&(pe=0,ne.length=0),ne.length===0&&(we.data.length<10||we.data[0]!=="I".charCodeAt(0)||we.data[1]!=="D".charCodeAt(0)||we.data[2]!=="3".charCodeAt(0))){z.debug&&console.log("Skipping unrecognized metadata packet");return}if(ne.push(we),pe+=we.data.byteLength,ne.length===1&&(ie=Mn(we.data.subarray(6,10)),ie+=10),!(pe<ie)){for(ke={data:new Uint8Array(ie),frames:[],pts:ne[0].pts,dts:ne[0].dts},er=0;er<ie;)ke.data.set(ne[0].data.subarray(0,ie-er),er),er+=ne[0].data.byteLength,pe-=ne[0].data.byteLength,ne.shift();Ve=10,ke.data[5]&64&&(Ve+=4,Ve+=Mn(ke.data.subarray(10,14)),ie-=Mn(ke.data.subarray(16,20)));do{if(st=Mn(ke.data.subarray(Ve+4,Ve+8)),st<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(nr=String.fromCharCode(ke.data[Ve],ke.data[Ve+1],ke.data[Ve+2],ke.data[Ve+3]),Ft={id:nr,data:ke.data.subarray(Ve+10,Ve+st+10)},Ft.key=Ft.id,$s[Ft.id]&&($s[Ft.id](Ft),Ft.owner==="com.apple.streaming.transportStreamTimestamp")){var br=Ft.data,Dr=(br[3]&1)<<30|br[4]<<22|br[5]<<14|br[6]<<6|br[7]>>>2;Dr*=4,Dr+=br[7]&3,Ft.timeStamp=Dr,ke.pts===void 0&&ke.dts===void 0&&(ke.pts=Ft.timeStamp,ke.dts=Ft.timeStamp),this.trigger("timestamp",Ft)}ke.frames.push(Ft),Ve+=10,Ve+=st}while(Ve<ie);this.trigger("data",ke)}}}},la.prototype=new n;var Va=la,Co=wi.TimestampRolloverStream,xn,ps,ba,hn=188,Hs=71;xn=function(){var q=new Uint8Array(hn),z=0;xn.prototype.init.call(this),this.push=function(ie){var ne=0,pe=hn,me;for(z?(me=new Uint8Array(ie.byteLength+z),me.set(q.subarray(0,z)),me.set(ie,z),z=0):me=ie;pe<me.byteLength;){if(me[ne]===Hs&&me[pe]===Hs){this.trigger("data",me.subarray(ne,pe)),ne+=hn,pe+=hn;continue}ne++,pe++}ne<me.byteLength&&(q.set(me.subarray(ne),0),z=me.byteLength-ne)},this.flush=function(){z===hn&&q[0]===Hs&&(this.trigger("data",q),z=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){z=0,this.trigger("reset")}},xn.prototype=new n,ps=function(){var q,z,ie,ne;ps.prototype.init.call(this),ne=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,q=function(me,we){var ke=0;we.payloadUnitStartIndicator&&(ke+=me[ke]+1),we.type==="pat"?z(me.subarray(ke),we):ie(me.subarray(ke),we)},z=function(me,we){we.section_number=me[7],we.last_section_number=me[8],ne.pmtPid=(me[10]&31)<<8|me[11],we.pmtPid=ne.pmtPid},ie=function(me,we){var ke,Ve,st,Ft;if(!!(me[5]&1)){for(ne.programMapTable={video:null,audio:null,"timed-metadata":{}},ke=(me[1]&15)<<8|me[2],Ve=3+ke-4,st=(me[10]&15)<<8|me[11],Ft=12+st;Ft<Ve;){var er=me[Ft],nr=(me[Ft+1]&31)<<8|me[Ft+2];er===rn.H264_STREAM_TYPE&&ne.programMapTable.video===null?ne.programMapTable.video=nr:er===rn.ADTS_STREAM_TYPE&&ne.programMapTable.audio===null?ne.programMapTable.audio=nr:er===rn.METADATA_STREAM_TYPE&&(ne.programMapTable["timed-metadata"][nr]=er),Ft+=((me[Ft+3]&15)<<8|me[Ft+4])+5}we.programMapTable=ne.programMapTable}},this.push=function(pe){var me={},we=4;if(me.payloadUnitStartIndicator=!!(pe[1]&64),me.pid=pe[1]&31,me.pid<<=8,me.pid|=pe[2],(pe[3]&48)>>>4>1&&(we+=pe[we]+1),me.pid===0)me.type="pat",q(pe.subarray(we),me),this.trigger("data",me);else if(me.pid===this.pmtPid)for(me.type="pmt",q(pe.subarray(we),me),this.trigger("data",me);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([pe,we,me]):this.processPes_(pe,we,me)},this.processPes_=function(pe,me,we){we.pid===this.programMapTable.video?we.streamType=rn.H264_STREAM_TYPE:we.pid===this.programMapTable.audio?we.streamType=rn.ADTS_STREAM_TYPE:we.streamType=this.programMapTable["timed-metadata"][we.pid],we.type="pes",we.data=pe.subarray(me),this.trigger("data",we)}},ps.prototype=new n,ps.STREAM_TYPES={h264:27,adts:15},ba=function(){var q=this,z={data:[],size:0},ie={data:[],size:0},ne={data:[],size:0},pe,me=function(Ve,st){var Ft;st.packetLength=6+(Ve[4]<<8|Ve[5]),st.dataAlignmentIndicator=(Ve[6]&4)!==0,Ft=Ve[7],Ft&192&&(st.pts=(Ve[9]&14)<<27|(Ve[10]&255)<<20|(Ve[11]&254)<<12|(Ve[12]&255)<<5|(Ve[13]&254)>>>3,st.pts*=4,st.pts+=(Ve[13]&6)>>>1,st.dts=st.pts,Ft&64&&(st.dts=(Ve[14]&14)<<27|(Ve[15]&255)<<20|(Ve[16]&254)<<12|(Ve[17]&255)<<5|(Ve[18]&254)>>>3,st.dts*=4,st.dts+=(Ve[18]&6)>>>1)),st.data=Ve.subarray(9+Ve[8])},we=function(Ve,st,Ft){var er=new Uint8Array(Ve.size),nr={type:st},br=0,Dr=0,Rt=!1,Mi;if(!(!Ve.data.length||Ve.size<9)){for(nr.trackId=Ve.data[0].pid,br=0;br<Ve.data.length;br++)Mi=Ve.data[br],er.set(Mi.data,Dr),Dr+=Mi.data.byteLength;me(er,nr),Rt=st==="video"||nr.packetLength<=Ve.size,(Ft||Rt)&&(Ve.size=0,Ve.data.length=0),Rt&&q.trigger("data",nr)}};ba.prototype.init.call(this),this.push=function(ke){({pat:function(){},pes:function(){var st,Ft;switch(ke.streamType){case rn.H264_STREAM_TYPE:case rn.H264_STREAM_TYPE:st=z,Ft="video";break;case rn.ADTS_STREAM_TYPE:st=ie,Ft="audio";break;case rn.METADATA_STREAM_TYPE:st=ne,Ft="timed-metadata";break;default:return}ke.payloadUnitStartIndicator&&we(st,Ft,!0),st.data.push(ke),st.size+=ke.data.byteLength},pmt:function(){var st={type:"metadata",tracks:[]};pe=ke.programMapTable,pe.video!==null&&st.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+pe.video,codec:"avc",type:"video"}),pe.audio!==null&&st.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+pe.audio,codec:"adts",type:"audio"}),q.trigger("data",st)}})[ke.type]()},this.reset=function(){z.size=0,z.data.length=0,ie.size=0,ie.data.length=0,this.trigger("reset")},this.flushStreams_=function(){we(z,"video"),we(ie,"audio"),we(ne,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},ba.prototype=new n;var qa={PAT_PID:0,MP2T_PACKET_LENGTH:hn,TransportPacketStream:xn,TransportParseStream:ps,ElementaryStream:ba,TimestampRolloverStream:Co,CaptionStream:Us.CaptionStream,Cea608Stream:Us.Cea608Stream,MetadataStream:Va};for(var Xn in rn)rn.hasOwnProperty(Xn)&&(qa[Xn]=rn[Xn]);var Jn=qa,cu=oi.ONE_SECOND_IN_TS,de,Ee=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];de=function(q){var z,ie=0;de.prototype.init.call(this),this.push=function(ne){var pe=0,me,we,ke,Ve,st,Ft;if(q||(ie=0),ne.type==="audio")for(z?(Ve=z,z=new Uint8Array(Ve.byteLength+ne.data.byteLength),z.set(Ve),z.set(ne.data,Ve.byteLength)):z=ne.data;pe+5<z.length;){if(z[pe]!==255||(z[pe+1]&246)!==240){pe++;continue}if(we=(~z[pe+1]&1)*2,me=(z[pe+3]&3)<<11|z[pe+4]<<3|(z[pe+5]&224)>>5,st=((z[pe+6]&3)+1)*1024,Ft=st*cu/Ee[(z[pe+2]&60)>>>2],ke=pe+me,z.byteLength<ke)return;if(this.trigger("data",{pts:ne.pts+ie*Ft,dts:ne.dts+ie*Ft,sampleCount:st,audioobjecttype:(z[pe+2]>>>6&3)+1,channelcount:(z[pe+2]&1)<<2|(z[pe+3]&192)>>>6,samplerate:Ee[(z[pe+2]&60)>>>2],samplingfrequencyindex:(z[pe+2]&60)>>>2,samplesize:16,data:z.subarray(pe+7+we,ke)}),ie++,z.byteLength===ke){z=void 0;return}z=z.subarray(ke)}},this.flush=function(){ie=0,this.trigger("done")},this.reset=function(){z=void 0,this.trigger("reset")},this.endTimeline=function(){z=void 0,this.trigger("endedtimeline")}},de.prototype=new n;var ge=de,Me;Me=function(q){var z=q.byteLength,ie=0,ne=0;this.length=function(){return 8*z},this.bitsAvailable=function(){return 8*z+ne},this.loadWord=function(){var pe=q.byteLength-z,me=new Uint8Array(4),we=Math.min(4,z);if(we===0)throw new Error("no bytes available");me.set(q.subarray(pe,pe+we)),ie=new DataView(me.buffer).getUint32(0),ne=we*8,z-=we},this.skipBits=function(pe){var me;ne>pe?(ie<<=pe,ne-=pe):(pe-=ne,me=Math.floor(pe/8),pe-=me*8,z-=me,this.loadWord(),ie<<=pe,ne-=pe)},this.readBits=function(pe){var me=Math.min(ne,pe),we=ie>>>32-me;return ne-=me,ne>0?ie<<=me:z>0&&this.loadWord(),me=pe-me,me>0?we<<me|this.readBits(me):we},this.skipLeadingZeros=function(){var pe;for(pe=0;pe<ne;++pe)if((ie&2147483648>>>pe)!==0)return ie<<=pe,ne-=pe,pe;return this.loadWord(),pe+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var pe=this.skipLeadingZeros();return this.readBits(pe+1)-1},this.readExpGolomb=function(){var pe=this.readUnsignedExpGolomb();return 1&pe?1+pe>>>1:-1*(pe>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var He=Me,Le,et,yt;et=function(){var q=0,z,ie;et.prototype.init.call(this),this.push=function(ne){var pe;ie?(pe=new Uint8Array(ie.byteLength+ne.data.byteLength),pe.set(ie),pe.set(ne.data,ie.byteLength),ie=pe):ie=ne.data;for(var me=ie.byteLength;q<me-3;q++)if(ie[q+2]===1){z=q+5;break}for(;z<me;)switch(ie[z]){case 0:if(ie[z-1]!==0){z+=2;break}else if(ie[z-2]!==0){z++;break}q+3!==z-2&&this.trigger("data",ie.subarray(q+3,z-2));do z++;while(ie[z]!==1&&z<me);q=z-2,z+=3;break;case 1:if(ie[z-1]!==0||ie[z-2]!==0){z+=3;break}this.trigger("data",ie.subarray(q+3,z-2)),q=z-2,z+=3;break;default:z+=3;break}ie=ie.subarray(q),z-=q,q=0},this.reset=function(){ie=null,q=0,this.trigger("reset")},this.flush=function(){ie&&ie.byteLength>3&&this.trigger("data",ie.subarray(q+3)),ie=null,q=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},et.prototype=new n,yt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Le=function(){var q=new et,z,ie,ne,pe,me,we,ke;Le.prototype.init.call(this),z=this,this.push=function(Ve){Ve.type==="video"&&(ie=Ve.trackId,ne=Ve.pts,pe=Ve.dts,q.push(Ve))},q.on("data",function(Ve){var st={trackId:ie,pts:ne,dts:pe,data:Ve};switch(Ve[0]&31){case 5:st.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:st.nalUnitType="sei_rbsp",st.escapedRBSP=me(Ve.subarray(1));break;case 7:st.nalUnitType="seq_parameter_set_rbsp",st.escapedRBSP=me(Ve.subarray(1)),st.config=we(st.escapedRBSP);break;case 8:st.nalUnitType="pic_parameter_set_rbsp";break;case 9:st.nalUnitType="access_unit_delimiter_rbsp";break}z.trigger("data",st)}),q.on("done",function(){z.trigger("done")}),q.on("partialdone",function(){z.trigger("partialdone")}),q.on("reset",function(){z.trigger("reset")}),q.on("endedtimeline",function(){z.trigger("endedtimeline")}),this.flush=function(){q.flush()},this.partialFlush=function(){q.partialFlush()},this.reset=function(){q.reset()},this.endTimeline=function(){q.endTimeline()},ke=function(st,Ft){var er=8,nr=8,br,Dr;for(br=0;br<st;br++)nr!==0&&(Dr=Ft.readExpGolomb(),nr=(er+Dr+256)%256),er=nr===0?er:nr},me=function(st){for(var Ft=st.byteLength,er=[],nr=1,br,Dr;nr<Ft-2;)st[nr]===0&&st[nr+1]===0&&st[nr+2]===3?(er.push(nr+2),nr+=2):nr++;if(er.length===0)return st;br=Ft-er.length,Dr=new Uint8Array(br);var Rt=0;for(nr=0;nr<br;Rt++,nr++)Rt===er[0]&&(Rt++,er.shift()),Dr[nr]=st[Rt];return Dr},we=function(st){var Ft=0,er=0,nr=0,br=0,Dr=1,Rt,Mi,Zn,qs,xa,hu,il,gs,nl,pu,nn,Ci,al,vs;if(Rt=new He(st),Mi=Rt.readUnsignedByte(),qs=Rt.readUnsignedByte(),Zn=Rt.readUnsignedByte(),Rt.skipUnsignedExpGolomb(),yt[Mi]&&(xa=Rt.readUnsignedExpGolomb(),xa===3&&Rt.skipBits(1),Rt.skipUnsignedExpGolomb(),Rt.skipUnsignedExpGolomb(),Rt.skipBits(1),Rt.readBoolean()))for(nn=xa!==3?8:12,vs=0;vs<nn;vs++)Rt.readBoolean()&&(vs<6?ke(16,Rt):ke(64,Rt));if(Rt.skipUnsignedExpGolomb(),hu=Rt.readUnsignedExpGolomb(),hu===0)Rt.readUnsignedExpGolomb();else if(hu===1)for(Rt.skipBits(1),Rt.skipExpGolomb(),Rt.skipExpGolomb(),il=Rt.readUnsignedExpGolomb(),vs=0;vs<il;vs++)Rt.skipExpGolomb();if(Rt.skipUnsignedExpGolomb(),Rt.skipBits(1),gs=Rt.readUnsignedExpGolomb(),nl=Rt.readUnsignedExpGolomb(),pu=Rt.readBits(1),pu===0&&Rt.skipBits(1),Rt.skipBits(1),Rt.readBoolean()&&(Ft=Rt.readUnsignedExpGolomb(),er=Rt.readUnsignedExpGolomb(),nr=Rt.readUnsignedExpGolomb(),br=Rt.readUnsignedExpGolomb()),Rt.readBoolean()&&Rt.readBoolean()){switch(al=Rt.readUnsignedByte(),al){case 1:Ci=[1,1];break;case 2:Ci=[12,11];break;case 3:Ci=[10,11];break;case 4:Ci=[16,11];break;case 5:Ci=[40,33];break;case 6:Ci=[24,11];break;case 7:Ci=[20,11];break;case 8:Ci=[32,11];break;case 9:Ci=[80,33];break;case 10:Ci=[18,11];break;case 11:Ci=[15,11];break;case 12:Ci=[64,33];break;case 13:Ci=[160,99];break;case 14:Ci=[4,3];break;case 15:Ci=[3,2];break;case 16:Ci=[2,1];break;case 255:{Ci=[Rt.readUnsignedByte()<<8|Rt.readUnsignedByte(),Rt.readUnsignedByte()<<8|Rt.readUnsignedByte()];break}}Ci&&(Dr=Ci[0]/Ci[1])}return{profileIdc:Mi,levelIdc:Zn,profileCompatibility:qs,width:Math.ceil(((gs+1)*16-Ft*2-er*2)*Dr),height:(2-pu)*(nl+1)*16-nr*2-br*2,sarRatio:Ci}}},Le.prototype=new n;var gt={H264Stream:Le,NalByteStream:et},St=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],kt=function(q){return q[0]==="I".charCodeAt(0)&&q[1]==="D".charCodeAt(0)&&q[2]==="3".charCodeAt(0)},Zt=function(q){return q[0]<<21|q[1]<<14|q[2]<<7|q[3]},_r=function(q,z,ie){var ne,pe="";for(ne=z;ne<ie;ne++)pe+="%"+("00"+q[ne].toString(16)).slice(-2);return pe},jr=function(q,z,ie){return unescape(_r(q,z,ie))},$r=function(q,z){var ie=q[z+6]<<21|q[z+7]<<14|q[z+8]<<7|q[z+9],ne=q[z+5],pe=(ne&16)>>4;return pe?ie+20:ie+10},Ai=function(q,z){var ie=(q[z+5]&224)>>5,ne=q[z+4]<<3,pe=q[z+3]&3<<11;return pe|ne|ie},mr=function(q,z){return q[z]==="I".charCodeAt(0)&&q[z+1]==="D".charCodeAt(0)&&q[z+2]==="3".charCodeAt(0)?"timed-metadata":q[z]&!0&&(q[z+1]&240)===240?"audio":null},Qi=function(q){for(var z=0;z+5<q.length;){if(q[z]!==255||(q[z+1]&246)!==240){z++;continue}return St[(q[z+2]&60)>>>2]}return null},ca=function(q){var z,ie,ne,pe;z=10,q[5]&64&&(z+=4,z+=Zt(q.subarray(10,14)));do{if(ie=Zt(q.subarray(z+4,z+8)),ie<1)return null;if(pe=String.fromCharCode(q[z],q[z+1],q[z+2],q[z+3]),pe==="PRIV"){ne=q.subarray(z+10,z+ie+10);for(var me=0;me<ne.byteLength;me++)if(ne[me]===0){var we=jr(ne,0,me);if(we==="com.apple.streaming.transportStreamTimestamp"){var ke=ne.subarray(me+1),Ve=(ke[3]&1)<<30|ke[4]<<22|ke[5]<<14|ke[6]<<6|ke[7]>>>2;return Ve*=4,Ve+=ke[7]&3,Ve}break}}z+=10,z+=ie}while(z<q.byteLength);return null},Wa={isLikelyAacData:kt,parseId3TagSize:$r,parseAdtsSize:Ai,parseType:mr,parseSampleRate:Qi,parseAacTimestamp:ca},wn;wn=function(){var q=new Uint8Array,z=0;wn.prototype.init.call(this),this.setTimestamp=function(ie){z=ie},this.push=function(ie){var ne=0,pe=0,me,we,ke,Ve;for(q.length?(Ve=q.length,q=new Uint8Array(ie.byteLength+Ve),q.set(q.subarray(0,Ve)),q.set(ie,Ve)):q=ie;q.length-pe>=3;){if(q[pe]==="I".charCodeAt(0)&&q[pe+1]==="D".charCodeAt(0)&&q[pe+2]==="3".charCodeAt(0)){if(q.length-pe<10||(ne=Wa.parseId3TagSize(q,pe),pe+ne>q.length))break;we={type:"timed-metadata",data:q.subarray(pe,pe+ne)},this.trigger("data",we),pe+=ne;continue}else if((q[pe]&255)===255&&(q[pe+1]&240)===240){if(q.length-pe<7||(ne=Wa.parseAdtsSize(q,pe),pe+ne>q.length))break;ke={type:"audio",data:q.subarray(pe,pe+ne),pts:z,dts:z},this.trigger("data",ke),pe+=ne;continue}pe++}me=q.length-pe,me>0?q=q.subarray(pe):q=new Uint8Array},this.reset=function(){q=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){q=new Uint8Array,this.trigger("endedtimeline")}},wn.prototype=new n;var Ya=wn,du=gt.H264Stream,Qn=Wa.isLikelyAacData,da=oi.ONE_SECOND_IN_TS,Ta=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Do=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Gs,Sa,ko,Ea,Tc=function(q,z){var ie;if(q.length!==z.length)return!1;for(ie=0;ie<q.length;ie++)if(q[ie]!==z[ie])return!1;return!0},fa=function(q,z,ie,ne,pe,me){var we=ie-z,ke=ne-z,Ve=pe-ie;return{start:{dts:q,pts:q+we},end:{dts:q+ke,pts:q+Ve},prependedContentDuration:me,baseMediaDecodeTime:q}};Sa=function(q,z){var ie=[],ne=0,pe=0,me=0,we=1/0;z=z||{},Sa.prototype.init.call(this),this.push=function(ke){xi.collectDtsInfo(q,ke),q&&Ta.forEach(function(Ve){q[Ve]=ke[Ve]}),ie.push(ke)},this.setEarliestDts=function(ke){pe=ke-q.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(ke){we=ke},this.setAudioAppendStart=function(ke){me=ke},this.flush=function(){var ke,Ve,st,Ft,er;if(ie.length===0){this.trigger("done","AudioSegmentStream");return}ke=Kn.trimAdtsFramesByEarliestDts(ie,q,pe),q.baseMediaDecodeTime=xi.calculateTrackBaseMediaDecodeTime(q,z.keepOriginalTimestamps),Kn.prefixWithSilence(q,ke,me,we),q.samples=Kn.generateSampleTable(ke),st=Ne.mdat(Kn.concatenateFrameData(ke)),ie=[],Ve=Ne.moof(ne,[q]),Ft=new Uint8Array(Ve.byteLength+st.byteLength),ne++,Ft.set(Ve),Ft.set(st,Ve.byteLength),xi.clearDtsInfo(q),er=Math.ceil(da*1024/q.samplerate),ke.length&&this.trigger("timingInfo",{start:ke[0].dts,end:ke[0].dts+ke.length*er}),this.trigger("data",{track:q,boxes:Ft}),this.trigger("done","AudioSegmentStream")},this.reset=function(){xi.clearDtsInfo(q),ie=[],this.trigger("reset")}},Sa.prototype=new n,Gs=function(q,z){var ie=0,ne=[],pe=[],me,we;z=z||{},Gs.prototype.init.call(this),delete q.minPTS,this.gopCache_=[],this.push=function(ke){xi.collectDtsInfo(q,ke),ke.nalUnitType==="seq_parameter_set_rbsp"&&!me&&(me=ke.config,q.sps=[ke.data],Do.forEach(function(Ve){q[Ve]=me[Ve]},this)),ke.nalUnitType==="pic_parameter_set_rbsp"&&!we&&(we=ke.data,q.pps=[ke.data]),ne.push(ke)},this.flush=function(){for(var ke,Ve,st,Ft,er,nr,br=0,Dr,Rt;ne.length&&ne[0].nalUnitType!=="access_unit_delimiter_rbsp";)ne.shift();if(ne.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(ke=Tt.groupNalsIntoFrames(ne),st=Tt.groupFramesIntoGops(ke),st[0][0].keyFrame||(Ve=this.getGopForFusion_(ne[0],q),Ve?(br=Ve.duration,st.unshift(Ve),st.byteLength+=Ve.byteLength,st.nalCount+=Ve.nalCount,st.pts=Ve.pts,st.dts=Ve.dts,st.duration+=Ve.duration):st=Tt.extendFirstKeyFrame(st)),pe.length){var Mi;if(z.alignGopsAtEnd?Mi=this.alignGopsAtEnd_(st):Mi=this.alignGopsAtStart_(st),!Mi){this.gopCache_.unshift({gop:st.pop(),pps:q.pps,sps:q.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),ne=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}xi.clearDtsInfo(q),st=Mi}xi.collectDtsInfo(q,st),q.samples=Tt.generateSampleTable(st),er=Ne.mdat(Tt.concatenateNalData(st)),q.baseMediaDecodeTime=xi.calculateTrackBaseMediaDecodeTime(q,z.keepOriginalTimestamps),this.trigger("processedGopsInfo",st.map(function(Zn){return{pts:Zn.pts,dts:Zn.dts,byteLength:Zn.byteLength}})),Dr=st[0],Rt=st[st.length-1],this.trigger("segmentTimingInfo",fa(q.baseMediaDecodeTime,Dr.dts,Dr.pts,Rt.dts+Rt.duration,Rt.pts+Rt.duration,br)),this.trigger("timingInfo",{start:st[0].dts,end:st[st.length-1].dts+st[st.length-1].duration}),this.gopCache_.unshift({gop:st.pop(),pps:q.pps,sps:q.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),ne=[],this.trigger("baseMediaDecodeTime",q.baseMediaDecodeTime),this.trigger("timelineStartInfo",q.timelineStartInfo),Ft=Ne.moof(ie,[q]),nr=new Uint8Array(Ft.byteLength+er.byteLength),ie++,nr.set(Ft),nr.set(er,Ft.byteLength),this.trigger("data",{track:q,boxes:nr}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),ne=[],this.gopCache_.length=0,pe.length=0,this.trigger("reset")},this.resetStream_=function(){xi.clearDtsInfo(q),me=void 0,we=void 0},this.getGopForFusion_=function(ke){var Ve=45e3,st=1e4,Ft=1/0,er,nr,br,Dr,Rt;for(Rt=0;Rt<this.gopCache_.length;Rt++)Dr=this.gopCache_[Rt],br=Dr.gop,!(!(q.pps&&Tc(q.pps[0],Dr.pps[0]))||!(q.sps&&Tc(q.sps[0],Dr.sps[0])))&&(br.dts<q.timelineStartInfo.dts||(er=ke.dts-br.dts-br.duration,er>=-st&&er<=Ve&&(!nr||Ft>er)&&(nr=Dr,Ft=er)));return nr?nr.gop:null},this.alignGopsAtStart_=function(ke){var Ve,st,Ft,er,nr,br,Dr,Rt;for(nr=ke.byteLength,br=ke.nalCount,Dr=ke.duration,Ve=st=0;Ve<pe.length&&st<ke.length&&(Ft=pe[Ve],er=ke[st],Ft.pts!==er.pts);){if(er.pts>Ft.pts){Ve++;continue}st++,nr-=er.byteLength,br-=er.nalCount,Dr-=er.duration}return st===0?ke:st===ke.length?null:(Rt=ke.slice(st),Rt.byteLength=nr,Rt.duration=Dr,Rt.nalCount=br,Rt.pts=Rt[0].pts,Rt.dts=Rt[0].dts,Rt)},this.alignGopsAtEnd_=function(ke){var Ve,st,Ft,er,nr,br;for(Ve=pe.length-1,st=ke.length-1,nr=null,br=!1;Ve>=0&&st>=0;){if(Ft=pe[Ve],er=ke[st],Ft.pts===er.pts){br=!0;break}if(Ft.pts>er.pts){Ve--;continue}Ve===pe.length-1&&(nr=st),st--}if(!br&&nr===null)return null;var Dr;if(br?Dr=st:Dr=nr,Dr===0)return ke;var Rt=ke.slice(Dr),Mi=Rt.reduce(function(Zn,qs){return Zn.byteLength+=qs.byteLength,Zn.duration+=qs.duration,Zn.nalCount+=qs.nalCount,Zn},{byteLength:0,duration:0,nalCount:0});return Rt.byteLength=Mi.byteLength,Rt.duration=Mi.duration,Rt.nalCount=Mi.nalCount,Rt.pts=Rt[0].pts,Rt.dts=Rt[0].dts,Rt},this.alignGopsWith=function(ke){pe=ke}},Gs.prototype=new n,Ea=function(q,z){this.numberOfTracks=0,this.metadataStream=z,q=q||{},typeof q.remux<"u"?this.remuxTracks=!!q.remux:this.remuxTracks=!0,typeof q.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=q.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Ea.prototype.init.call(this),this.push=function(ie){if(ie.text)return this.pendingCaptions.push(ie);if(ie.frames)return this.pendingMetadata.push(ie);this.pendingTracks.push(ie.track),this.pendingBytes+=ie.boxes.byteLength,ie.track.type==="video"&&(this.videoTrack=ie.track,this.pendingBoxes.push(ie.boxes)),ie.track.type==="audio"&&(this.audioTrack=ie.track,this.pendingBoxes.unshift(ie.boxes))}},Ea.prototype=new n,Ea.prototype.flush=function(xe){var q=0,z={captions:[],captionStreams:{},metadata:[],info:{}},ie,ne,pe,me=0,we;if(this.pendingTracks.length<this.numberOfTracks){if(xe!=="VideoSegmentStream"&&xe!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(me=this.videoTrack.timelineStartInfo.pts,Do.forEach(function(ke){z.info[ke]=this.videoTrack[ke]},this)):this.audioTrack&&(me=this.audioTrack.timelineStartInfo.pts,Ta.forEach(function(ke){z.info[ke]=this.audioTrack[ke]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?z.type=this.pendingTracks[0].type:z.type="combined",this.emittedTracks+=this.pendingTracks.length,pe=Ne.initSegment(this.pendingTracks),z.initSegment=new Uint8Array(pe.byteLength),z.initSegment.set(pe),z.data=new Uint8Array(this.pendingBytes),we=0;we<this.pendingBoxes.length;we++)z.data.set(this.pendingBoxes[we],q),q+=this.pendingBoxes[we].byteLength;for(we=0;we<this.pendingCaptions.length;we++)ie=this.pendingCaptions[we],ie.startTime=oi.metadataTsToSeconds(ie.startPts,me,this.keepOriginalTimestamps),ie.endTime=oi.metadataTsToSeconds(ie.endPts,me,this.keepOriginalTimestamps),z.captionStreams[ie.stream]=!0,z.captions.push(ie);for(we=0;we<this.pendingMetadata.length;we++)ne=this.pendingMetadata[we],ne.cueTime=oi.metadataTsToSeconds(ne.pts,me,this.keepOriginalTimestamps),z.metadata.push(ne);for(z.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",z),we=0;we<z.captions.length;we++)ie=z.captions[we],this.trigger("caption",ie);for(we=0;we<z.metadata.length;we++)ne=z.metadata[we],this.trigger("id3Frame",ne)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},Ea.prototype.setRemux=function(xe){this.remuxTracks=xe},ko=function(q){var z=this,ie=!0,ne,pe;ko.prototype.init.call(this),q=q||{},this.baseMediaDecodeTime=q.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var me={};this.transmuxPipeline_=me,me.type="aac",me.metadataStream=new Jn.MetadataStream,me.aacStream=new Ya,me.audioTimestampRolloverStream=new Jn.TimestampRolloverStream("audio"),me.timedMetadataTimestampRolloverStream=new Jn.TimestampRolloverStream("timed-metadata"),me.adtsStream=new ge,me.coalesceStream=new Ea(q,me.metadataStream),me.headOfPipeline=me.aacStream,me.aacStream.pipe(me.audioTimestampRolloverStream).pipe(me.adtsStream),me.aacStream.pipe(me.timedMetadataTimestampRolloverStream).pipe(me.metadataStream).pipe(me.coalesceStream),me.metadataStream.on("timestamp",function(we){me.aacStream.setTimestamp(we.timeStamp)}),me.aacStream.on("data",function(we){we.type==="timed-metadata"&&!me.audioSegmentStream&&(pe=pe||{timelineStartInfo:{baseMediaDecodeTime:z.baseMediaDecodeTime},codec:"adts",type:"audio"},me.coalesceStream.numberOfTracks++,me.audioSegmentStream=new Sa(pe,q),me.audioSegmentStream.on("timingInfo",z.trigger.bind(z,"audioTimingInfo")),me.adtsStream.pipe(me.audioSegmentStream).pipe(me.coalesceStream)),z.trigger("trackinfo",{hasAudio:!!pe,hasVideo:!!ne})}),me.coalesceStream.on("data",this.trigger.bind(this,"data")),me.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var me={};this.transmuxPipeline_=me,me.type="ts",me.metadataStream=new Jn.MetadataStream,me.packetStream=new Jn.TransportPacketStream,me.parseStream=new Jn.TransportParseStream,me.elementaryStream=new Jn.ElementaryStream,me.timestampRolloverStream=new Jn.TimestampRolloverStream,me.adtsStream=new ge,me.h264Stream=new du,me.captionStream=new Jn.CaptionStream,me.coalesceStream=new Ea(q,me.metadataStream),me.headOfPipeline=me.packetStream,me.packetStream.pipe(me.parseStream).pipe(me.elementaryStream).pipe(me.timestampRolloverStream),me.timestampRolloverStream.pipe(me.h264Stream),me.timestampRolloverStream.pipe(me.adtsStream),me.timestampRolloverStream.pipe(me.metadataStream).pipe(me.coalesceStream),me.h264Stream.pipe(me.captionStream).pipe(me.coalesceStream),me.elementaryStream.on("data",function(we){var ke;if(we.type==="metadata"){for(ke=we.tracks.length;ke--;)!ne&&we.tracks[ke].type==="video"?(ne=we.tracks[ke],ne.timelineStartInfo.baseMediaDecodeTime=z.baseMediaDecodeTime):!pe&&we.tracks[ke].type==="audio"&&(pe=we.tracks[ke],pe.timelineStartInfo.baseMediaDecodeTime=z.baseMediaDecodeTime);ne&&!me.videoSegmentStream&&(me.coalesceStream.numberOfTracks++,me.videoSegmentStream=new Gs(ne,q),me.videoSegmentStream.on("timelineStartInfo",function(Ve){pe&&(pe.timelineStartInfo=Ve,me.audioSegmentStream.setEarliestDts(Ve.dts))}),me.videoSegmentStream.on("processedGopsInfo",z.trigger.bind(z,"gopInfo")),me.videoSegmentStream.on("segmentTimingInfo",z.trigger.bind(z,"videoSegmentTimingInfo")),me.videoSegmentStream.on("baseMediaDecodeTime",function(Ve){pe&&me.audioSegmentStream.setVideoBaseMediaDecodeTime(Ve)}),me.videoSegmentStream.on("timingInfo",z.trigger.bind(z,"videoTimingInfo")),me.h264Stream.pipe(me.videoSegmentStream).pipe(me.coalesceStream)),pe&&!me.audioSegmentStream&&(me.coalesceStream.numberOfTracks++,me.audioSegmentStream=new Sa(pe,q),me.audioSegmentStream.on("timingInfo",z.trigger.bind(z,"audioTimingInfo")),me.adtsStream.pipe(me.audioSegmentStream).pipe(me.coalesceStream)),z.trigger("trackinfo",{hasAudio:!!pe,hasVideo:!!ne})}}),me.coalesceStream.on("data",this.trigger.bind(this,"data")),me.coalesceStream.on("id3Frame",function(we){we.dispatchType=me.metadataStream.dispatchType,z.trigger("id3Frame",we)}),me.coalesceStream.on("caption",this.trigger.bind(this,"caption")),me.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(me){var we=this.transmuxPipeline_;q.keepOriginalTimestamps||(this.baseMediaDecodeTime=me),pe&&(pe.timelineStartInfo.dts=void 0,pe.timelineStartInfo.pts=void 0,xi.clearDtsInfo(pe),q.keepOriginalTimestamps||(pe.timelineStartInfo.baseMediaDecodeTime=me),we.audioTimestampRolloverStream&&we.audioTimestampRolloverStream.discontinuity()),ne&&(we.videoSegmentStream&&(we.videoSegmentStream.gopCache_=[]),ne.timelineStartInfo.dts=void 0,ne.timelineStartInfo.pts=void 0,xi.clearDtsInfo(ne),we.captionStream.reset(),q.keepOriginalTimestamps||(ne.timelineStartInfo.baseMediaDecodeTime=me)),we.timestampRolloverStream&&we.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(me){pe&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(me)},this.setRemux=function(me){var we=this.transmuxPipeline_;q.remux=me,we&&we.coalesceStream&&we.coalesceStream.setRemux(me)},this.alignGopsWith=function(me){ne&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(me)},this.push=function(me){if(ie){var we=Qn(me);we&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!we&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),ie=!1}this.transmuxPipeline_.headOfPipeline.push(me)},this.flush=function(){ie=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},ko.prototype=new n;var Vs={Transmuxer:ko,VideoSegmentStream:Gs,AudioSegmentStream:Sa,AUDIO_PROPERTIES:Ta,VIDEO_PROPERTIES:Do,generateVideoSegmentTimingInfo:fa},rl=function(q,z){if(!(q instanceof z))throw new TypeError("Cannot call a class as a function")},fu=function(){function xe(q,z){for(var ie=0;ie<z.length;ie++){var ne=z[ie];ne.enumerable=ne.enumerable||!1,ne.configurable=!0,"value"in ne&&(ne.writable=!0),Object.defineProperty(q,ne.key,ne)}}return function(q,z,ie){return z&&xe(q.prototype,z),ie&&xe(q,ie),q}}(),Sc=function(q,z){z.on("data",function(ie){var ne=ie.initSegment;ie.initSegment={data:ne.buffer,byteOffset:ne.byteOffset,byteLength:ne.byteLength};var pe=ie.data;ie.data=pe.buffer,q.postMessage({action:"data",segment:ie,byteOffset:pe.byteOffset,byteLength:pe.byteLength},[ie.data])}),z.captionStream&&z.captionStream.on("data",function(ie){q.postMessage({action:"caption",data:ie})}),z.on("done",function(ie){q.postMessage({action:"done"})}),z.on("gopInfo",function(ie){q.postMessage({action:"gopInfo",gopInfo:ie})}),z.on("videoSegmentTimingInfo",function(ie){q.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:ie})})},Ec=function(){function xe(q,z){rl(this,xe),this.options=z||{},this.self=q,this.init()}return fu(xe,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Vs.Transmuxer(this.options),Sc(this.self,this.transmuxer)}},{key:"push",value:function(z){var ie=new Uint8Array(z.data,z.byteOffset,z.byteLength);this.transmuxer.push(ie)}},{key:"reset",value:function(){this.init()}},{key:"setTimestampOffset",value:function(z){var ie=z.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(ie*9e4))}},{key:"setAudioAppendStart",value:function(z){this.transmuxer.setAudioAppendStart(Math.ceil(z.appendStart*9e4))}},{key:"flush",value:function(z){this.transmuxer.flush()}},{key:"resetCaptions",value:function(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function(z){this.transmuxer.alignGopsWith(z.gopsToAlignWith.slice())}}]),xe}(),$d=function(q){q.onmessage=function(z){if(z.data.action==="init"&&z.data.options){this.messageHandlers=new Ec(q,z.data.options);return}this.messageHandlers||(this.messageHandlers=new Ec(q)),z.data&&z.data.action&&z.data.action!=="init"&&this.messageHandlers[z.data.action]&&this.messageHandlers[z.data.action](z.data)}},Hd=new $d(i);return Hd})()}),JT={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},QT=function(t){return t.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(r,n,a){var s=("00"+Number(n).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},dd=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i={codecCount:0},r=void 0;return i.codecCount=t.split(",").length,i.codecCount=i.codecCount||2,r=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(t),r&&(i.videoCodec=r[2],i.videoObjectTypeIndicator=r[3]),i.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(t),i.audioProfile=i.audioProfile&&i.audioProfile[2],i},AP=function(t){return t.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return QT([i])[0]})},Sv=function(t,i,r){return t+"/"+i+'; codecs="'+r.filter(function(n){return!!n}).join(", ")+'"'},CP=function(t){return t.segments&&t.segments.length&&t.segments[0].map?"mp4":"mp2t"},DP=function(t){var i=t.attributes||{};return i.CODECS?dd(i.CODECS):JT},kP=function(t,i){if(!t.mediaGroups.AUDIO||!i)return null;var r=t.mediaGroups.AUDIO[i];if(!r)return null;for(var n in r){var a=r[n];if(a.default&&a.playlists)return dd(a.playlists[0].attributes.CODECS).audioProfile}return null},RP=function(t,i){var r=CP(i),n=DP(i),a=i.attributes||{},s=!0,o=!1;if(!i)return[];if(t.mediaGroups.AUDIO&&a.AUDIO){var l=t.mediaGroups.AUDIO[a.AUDIO];if(l){o=!0,s=!1;for(var u in l)if(!l[u].uri&&!l[u].playlists){s=!0;break}}}o&&!n.audioProfile&&(s||(n.audioProfile=kP(t,a.AUDIO)),n.audioProfile||(re.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),n.audioProfile=JT.audioProfile));var h={};n.videoCodec&&(h.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(h.audio="mp4a.40."+n.audioProfile);var c=Sv("audio",r,[h.audio]),d=Sv("video",r,[h.video]),f=Sv("video",r,[h.video,h.audio]);return o?!s&&h.video?[d,c]:!s&&!h.video?[c,c]:[f,c]:h.video?[f]:[c]},PP=function(t){var i={type:"",parameters:{}},r=t.trim().split(";");return i.type=r.shift().trim(),r.forEach(function(n){var a=n.trim().split("=");if(a.length>1){var s=a[0].replace(/"/g,"").trim(),o=a[1].replace(/"/g,"").trim();i.parameters[s]=o}}),i},ZT=function(t){return/mp4a\.\d+.\d+/i.test(t)},eS=function(t){return/avc1\.[\da-f]+/i.test(t)},OP=function(t,i,r){if(typeof i>"u"||i===null||!t.length)return[];var n=Math.ceil((i-r+3)*9e4),a=void 0;for(a=0;a<t.length&&!(t[a].pts>n);a++);return t.slice(a)},LP=function(t,i,r){if(!i.length)return t;if(r)return i.slice();var n=i[0].pts,a=0;for(a;a<t.length&&!(t[a].pts>=n);a++);return t.slice(0,a).concat(i)},IP=function(t,i,r,n){for(var a=Math.ceil((i-n)*9e4),s=Math.ceil((r-n)*9e4),o=t.slice(),l=t.length;l--&&!(t[l].pts<=s););if(l===-1)return o;for(var u=l+1;u--&&!(t[u].pts<=a););return u=Math.max(u,0),o.splice(u,l-u+1),o},MP=function(t,i,r){var n=null,a=null,s=0,o=[],l=[];if(!t&&!i)return re.createTimeRange();if(!t)return i.buffered;if(!i||r)return t.buffered;if(t.buffered.length===0&&i.buffered.length===0)return re.createTimeRange();for(var u=t.buffered,h=i.buffered,c=u.length;c--;)o.push({time:u.start(c),type:"start"}),o.push({time:u.end(c),type:"end"});for(c=h.length;c--;)o.push({time:h.start(c),type:"start"}),o.push({time:h.end(c),type:"end"});for(o.sort(function(d,f){return d.time-f.time}),c=0;c<o.length;c++)o[c].type==="start"?(s++,s===2&&(n=o[c].time)):o[c].type==="end"&&(s--,s===1&&(a=o[c].time)),n!==null&&a!==null&&(l.push([n,a]),n=null,a=null);return re.createTimeRanges(l)},Kl=9e4,NP=function(t,i){var r=t.addSourceBuffer(i),n=Object.create(null);n.updating=!1,n.realBuffer_=r;var a=function(l){typeof r[l]=="function"?n[l]=function(){return r[l].apply(r,arguments)}:typeof n[l]>"u"&&Object.defineProperty(n,l,{get:function(){return r[l]},set:function(h){return r[l]=h}})};for(var s in r)a(s);return n},FP=function(e){no(t,e);function t(i,r){Ia(this,t);var n=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,re.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=i,n.codecs_=r,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=re.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach(function(s){ZT(s)?n.audioCodec_=s:eS(s)&&(n.videoCodec_=s)}),n.transmuxer_=new wP,n.transmuxer_.postMessage({action:"init",options:a}),n.transmuxer_.onmessage=function(s){if(s.data.action==="data")return n.data_(s);if(s.data.action==="done")return n.done_(s);if(s.data.action==="gopInfo")return n.appendGopInfo_(s);if(s.data.action==="videoSegmentTimingInfo")return n.videoSegmentTimingInfo_(s.data.videoSegmentTimingInfo)},Object.defineProperty(n,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(o){typeof o=="number"&&o>=0&&(this.timestampOffset_=o,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:o}))}}),Object.defineProperty(n,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(o){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=o),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=o)}}),Object.defineProperty(n,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(n,"buffered",{get:function(){return MP(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),n}return Za(t,[{key:"data_",value:function(r){var n=r.data.segment;n.data=new Uint8Array(n.data,r.data.byteOffset,r.data.byteLength),n.initSegment=new Uint8Array(n.initSegment.data,n.initSegment.byteOffset,n.initSegment.byteLength),_P(this,this.mediaSource_,n),this.pendingBuffers_.push(n)}},{key:"done_",value:function(r){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(r){var n={start:{decode:r.start.dts/Kl,presentation:r.start.pts/Kl},end:{decode:r.end.dts/Kl,presentation:r.end.pts/Kl},baseMediaDecodeTime:r.baseMediaDecodeTime/Kl};r.prependedContentDuration&&(n.prependedContentDuration=r.prependedContentDuration/Kl),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:n})}},{key:"createRealSourceBuffers_",value:function(){var r=this,n=["audio","video"];n.forEach(function(a){if(!!r[a+"Codec_"]&&!r[a+"Buffer_"]){var s=null;if(r.mediaSource_[a+"Buffer_"])s=r.mediaSource_[a+"Buffer_"],s.updating=!1;else{var o=a+"Codec_",l=a+'/mp4;codecs="'+r[o]+'"';s=NP(r.mediaSource_.nativeMediaSource_,l),r.mediaSource_[a+"Buffer_"]=s}r[a+"Buffer_"]=s,["update","updatestart","updateend"].forEach(function(u){s.addEventListener(u,function(){if(!(a==="audio"&&r.audioDisabled_)){u==="updateend"&&(r[a+"Buffer_"].updating=!1);var h=n.every(function(c){return c==="audio"&&r.audioDisabled_?!0:!(a!==c&&r[c+"Buffer_"]&&r[c+"Buffer_"].updating)});if(h)return r.trigger(u)}})})}})}},{key:"appendBuffer",value:function(r){if(this.bufferUpdating_=!0,this.audioBuffer_&&this.audioBuffer_.buffered.length){var n=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:n.end(n.length-1)})}this.videoBuffer_&&this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:OP(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:"push",data:r.buffer,byteOffset:r.byteOffset,byteLength:r.byteLength},[r.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function(r){this.gopBuffer_=LP(this.gopBuffer_,r.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(r,n){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(r,n),this.gopBuffer_=IP(this.gopBuffer_,r,n,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(r,n)),ql(r,n,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)ql(r,n,this.inbandTextTracks_[a])}},{key:"processPendingSegments_",value:function(){var r={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend"),this.bufferUpdating_=!1;return}r=this.pendingBuffers_.reduce(function(a,s){var o=s.type,l=s.data,u=s.initSegment;return a[o].segments.push(l),a[o].bytes+=l.byteLength,a[o].initSegment=u,s.captions&&(a.captions=a.captions.concat(s.captions)),s.info&&(a[o].info=s.info),s.metadata&&(a.metadata=a.metadata.concat(s.metadata)),a},r),!this.videoBuffer_&&!this.audioBuffer_&&(r.video.bytes===0&&(this.videoCodec_=null),r.audio.bytes===0&&(this.audioCodec_=null),this.createRealSourceBuffers_()),r.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:r.audio.info}),r.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:r.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(r.audio.segments.unshift(r.audio.initSegment),r.audio.bytes+=r.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var n=!1;this.videoBuffer_&&r.video.bytes?(r.video.segments.unshift(r.video.initSegment),r.video.bytes+=r.video.initSegment.byteLength,this.concatAndAppendSegments_(r.video,this.videoBuffer_)):this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)&&(n=!0),TP(this,r.captions,r.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(r.audio,this.audioBuffer_),this.pendingBuffers_.length=0,n&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(r,n){var a=0,s=void 0;if(r.bytes){s=new Uint8Array(r.bytes),r.segments.forEach(function(o){s.set(o,a),a+=o.byteLength});try{n.updating=!0,n.appendBuffer(s)}catch(o){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:o.message,originalError:o})}}}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}}]),t}(re.EventTarget),Ev=function(e){no(t,e);function t(){Ia(this,t);var i=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=void 0;i.nativeMediaSource_=new Be.MediaSource;for(r in i.nativeMediaSource_)!(r in t.prototype)&&typeof i.nativeMediaSource_[r]=="function"&&(i[r]=i.nativeMediaSource_[r].bind(i.nativeMediaSource_));return i.duration_=NaN,Object.defineProperty(i,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(a){if(this.duration_=a,a!==1/0){this.nativeMediaSource_.duration=a;return}}}),Object.defineProperty(i,"seekable",{get:function(){return this.duration_===1/0?re.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(i,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(i,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),i.sourceBuffers=[],i.activeSourceBuffers_=[],i.updateActiveSourceBuffers_=function(){if(i.activeSourceBuffers_.length=0,i.sourceBuffers.length===1){var n=i.sourceBuffers[0];n.appendAudioInitSegment_=!0,n.audioDisabled_=!n.audioCodec_,i.activeSourceBuffers_.push(n);return}for(var a=!1,s=!0,o=0;o<i.player_.audioTracks().length;o++){var l=i.player_.audioTracks()[o];if(l.enabled&&l.kind!=="main"){a=!0,s=!1;break}}i.sourceBuffers.forEach(function(u,h){if(u.appendAudioInitSegment_=!0,u.videoCodec_&&u.audioCodec_)u.audioDisabled_=a;else if(u.videoCodec_&&!u.audioCodec_)u.audioDisabled_=!0,s=!1;else if(!u.videoCodec_&&u.audioCodec_&&(u.audioDisabled_=h?s:!s,u.audioDisabled_))return;i.activeSourceBuffers_.push(u)})},i.onPlayerMediachange_=function(){i.sourceBuffers.forEach(function(n){n.appendAudioInitSegment_=!0})},i.onHlsReset_=function(){i.sourceBuffers.forEach(function(n){n.transmuxer_&&n.transmuxer_.postMessage({action:"resetCaptions"})})},i.onHlsSegmentTimeMapping_=function(n){i.sourceBuffers.forEach(function(a){return a.timeMapping_=n.mapping})},["sourceopen","sourceclose","sourceended"].forEach(function(n){this.nativeMediaSource_.addEventListener(n,this.trigger.bind(this))},i),i.on("sourceopen",function(n){var a=Mt.querySelector('[src="'+i.url_+'"]');!a||(i.player_=re(a.parentNode),i.player_&&(i.player_.tech_.on("hls-reset",i.onHlsReset_),i.player_.tech_.on("hls-segment-time-mapping",i.onHlsSegmentTimeMapping_),i.player_.audioTracks&&i.player_.audioTracks()&&(i.player_.audioTracks().on("change",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("addtrack",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("removetrack",i.updateActiveSourceBuffers_)),i.player_.on("mediachange",i.onPlayerMediachange_)))}),i.on("sourceended",function(n){for(var a=qT(i.duration),s=0;s<i.sourceBuffers.length;s++){var o=i.sourceBuffers[s],l=o.metadataTrack_&&o.metadataTrack_.cues;l&&l.length&&(l[l.length-1].endTime=a)}}),i.on("sourceclose",function(n){this.sourceBuffers.forEach(function(a){a.transmuxer_&&a.transmuxer_.terminate()}),this.sourceBuffers.length=0,this.player_&&(this.player_.audioTracks&&this.player_.audioTracks()&&(this.player_.audioTracks().off("change",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("addtrack",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("removetrack",this.updateActiveSourceBuffers_)),this.player_.el_&&this.player_.off("mediachange",this.onPlayerMediachange_),this.player_.tech_&&this.player_.tech_.el_&&(this.player_.tech_.off("hls-reset",this.onHlsReset_),this.player_.tech_.off("hls-segment-time-mapping",this.onHlsSegmentTimeMapping_)))}),i}return Za(t,[{key:"addSeekableRange_",value:function(r,n){var a=void 0;if(this.duration!==1/0)throw a=new Error("MediaSource.addSeekableRange() can only be invoked when the duration is Infinity"),a.name="InvalidStateError",a.code=11,a;(n>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=n)}},{key:"addSourceBuffer",value:function(r){var n=void 0,a=PP(r);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=QT(s),s=s.filter(function(o){return ZT(o)||eS(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),n=new FP(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),n.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else n=this.nativeMediaSource_.addSourceBuffer(r);return this.sourceBuffers.push(n),n}}]),t}(re.EventTarget),tS=0;re.mediaSources={};var rS=function(t,i){var r=re.mediaSources[t];if(r)r.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},xv=function(){return!!Be.MediaSource&&!!Be.MediaSource.isTypeSupported&&Be.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},fd=function(){if(this.MediaSource={open:rS,supportsNativeMediaSources:xv},xv())return new Ev;throw new Error("Cannot use create a virtual MediaSource for this video")};fd.open=rS,fd.supportsNativeMediaSources=xv;var iS={createObjectURL:function(t){var i="blob:vjs-media-source/",r=void 0;return t instanceof Ev?(r=Be.URL.createObjectURL(t.nativeMediaSource_),t.url_=r,r):t instanceof Ev?(r=i+tS,tS++,re.mediaSources[r]=t,r):(r=Be.URL.createObjectURL(t),t.url_=r,r)}};re.MediaSource=fd,re.URL=iS;var UP=re.EventTarget,nS=re.mergeOptions,aS=function(t,i){for(var r=void 0,n=nS(t,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=vv(n,i.playlists[a]);s?n=s:r=!0}return qf(i,function(o,l,u,h){if(o.playlists&&o.playlists.length){var c=o.playlists[0].uri,d=vv(n,o.playlists[0]);d&&(n=d,n.mediaGroups[l][u][h].playlists[0]=n.playlists[c],r=!1)}}),r?null:n},wv=function(t){var i=t.byterange.offset+t.byterange.length-1;return t.uri+"-"+t.byterange.offset+"-"+i},BP=function(t,i){var r=Boolean(!t.map&&!i.map),n=r||Boolean(t.map&&i.map&&t.map.byterange.offset===i.map.byterange.offset&&t.map.byterange.length===i.map.byterange.length);return n&&t.uri===i.uri&&t.byterange.offset===i.byterange.offset&&t.byterange.length===i.byterange.length},sS=function(t,i){var r={};for(var n in t){var a=t[n],s=a.sidx;if(s){var o=wv(s);if(!i[o])break;var l=i[o].sidxInfo;BP(l,s)&&(r[o]=i[o])}}return r},jP=function(t,i,r,n){var a=l_(t,{manifestUri:i,clientOffset:r}),s=sS(a.playlists,n),o=s;return qf(a,function(l,u,h,c){if(l.playlists&&l.playlists.length){var d=l.playlists;o=nS(o,sS(d,n))}}),o},oS=function(t,i,r,n,a){var s={uri:Vf(n.handleManifestRedirects,t.resolvedUri),byterange:t.byterange,playlist:i},o=re.mergeOptions(s,{responseType:"arraybuffer",headers:_v(s)});return r(o,a)},Av=function(e){no(t,e);function t(i,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];Ia(this,t);var s=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),o=n.withCredentials,l=o===void 0?!1:o,u=n.handleManifestRedirects,h=u===void 0?!1:u;if(s.hls_=r,s.withCredentials=l,s.handleManifestRedirects=h,!i)throw new Error("A non-empty playlist URL or playlist is required");return s.on("minimumUpdatePeriod",function(){s.refreshXml_()}),s.on("mediaupdatetimeout",function(){s.refreshMedia_(s.media().uri)}),s.state="HAVE_NOTHING",s.loadedPlaylists_={},typeof i=="string"?(s.srcUrl=i,s.sidxMapping_={},Es(s)):(s.setupChildLoader(a,i),s)}return Za(t,[{key:"setupChildLoader",value:function(r,n){this.masterPlaylistLoader_=r,this.childPlaylist_=n}},{key:"dispose",value:function(){this.stopRequest(),this.loadedPlaylists_={},Be.clearTimeout(this.minimumUpdatePeriodTimeout_),Be.clearTimeout(this.mediaRequest_),Be.clearTimeout(this.mediaUpdateTimeout)}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var r=this.request;this.request=null,r.onreadystatechange=null,r.abort()}}},{key:"sidxRequestFinished_",value:function(r,n,a,s){var o=this;return function(l,u){if(!!o.request){if(o.request=null,l)return o.error={status:u.status,message:"DASH playlist request error at URL: "+r.uri,response:u.response,code:2},a&&(o.state=a),o.trigger("error"),s(n,null);var h=new Uint8Array(u.response),c=aD.parseSidx(h.subarray(8));return s(n,c)}}}},{key:"media",value:function(r){var n=this;if(!r)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);var a=this.state;if(typeof r=="string"){if(!this.master.playlists[r])throw new Error("Unknown playlist URI: "+r);r=this.master.playlists[r]}var s=!this.media_||r.uri!==this.media_.uri;if(s&&this.loadedPlaylists_[r.uri]&&this.loadedPlaylists_[r.uri].endList){this.state="HAVE_METADATA",this.media_=r,s&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}if(!!s){if(this.media_&&this.trigger("mediachanging"),!r.sidx){this.mediaRequest_=Be.setTimeout(this.haveMetadata.bind(this,{startingState:a,playlist:r}),0);return}var o=void 0,l=void 0;this.masterPlaylistLoader_?(o=this.masterPlaylistLoader_.master,l=this.masterPlaylistLoader_.sidxMapping_):(o=this.master,l=this.sidxMapping_);var u=wv(r.sidx);l[u]={sidxInfo:r.sidx},this.request=oS(r.sidx,r,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(r,o,a,function(h,c){if(!h||!c)throw new Error("failed to request sidx");l[u].sidx=c,n.haveMetadata({startingState:a,playlist:h.playlists[r.uri]})}))}}},{key:"haveMetadata",value:function(r){var n=r.startingState,a=r.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[a.uri]=a,this.mediaRequest_=null,this.refreshMedia_(a.uri),n==="HAVE_MASTER"?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),Be.clearTimeout(this.mediaUpdateTimeout),Be.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(r){var n=this;Be.clearTimeout(this.mediaUpdateTimeout),Be.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(r){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=Be.setTimeout(function(){return n.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var r=l_(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});r.uri=this.srcUrl;for(var n=0;n<r.playlists.length;n++){var a="placeholder-uri-"+n;r.playlists[n].uri=a,r.playlists[a]=r.playlists[n]}return qf(r,function(s,o,l,u){if(s.playlists&&s.playlists.length){var h="placeholder-uri-"+o+"-"+l+"-"+u;s.playlists[0].uri=h,r.playlists[h]=s.playlists[0]}}),xT(r),wT(r),r}},{key:"start",value:function(){var r=this;if(this.started=!0,this.masterPlaylistLoader_){this.mediaRequest_=Be.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!r.request){if(r.request=null,n)return r.error={status:a.status,message:"DASH playlist request error at URL: "+r.srcUrl,responseText:a.responseText,code:2},r.state==="HAVE_NOTHING"&&(r.started=!1),r.trigger("error");r.masterXml_=a.responseText,a.responseHeaders&&a.responseHeaders.date?r.masterLoaded_=Date.parse(a.responseHeaders.date):r.masterLoaded_=Date.now(),r.srcUrl=Vf(r.handleManifestRedirects,r.srcUrl,a),r.syncClientServerClock_(r.onClientServerClockSync_.bind(r))}})}},{key:"syncClientServerClock_",value:function(r){var n=this,a=$C(this.masterXml_);if(a===null)return this.clientOffset_=this.masterLoaded_-Date.now(),r();if(a.method==="DIRECT")return this.clientOffset_=a.value-Date.now(),r();this.request=this.hls_.xhr({uri:Ou(this.srcUrl,a.value),method:a.method,withCredentials:this.withCredentials},function(s,o){if(!!n.request){if(s)return n.clientOffset_=n.masterLoaded_-Date.now(),r();var l=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?l=n.masterLoaded_:l=Date.parse(o.responseHeaders.date):l=Date.parse(o.responseText),n.clientOffset_=l-Date.now(),r()}})}},{key:"haveMaster_",value:function(){this.state="HAVE_MASTER",this.mediaRequest_=null,this.masterPlaylistLoader_?this.media_||this.media(this.childPlaylist_):(this.master=this.parseMasterXml(),this.trigger("loadedplaylist"))}},{key:"onClientServerClockSync_",value:function(){var r=this;this.haveMaster_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.master.playlists[0]),this.master&&this.master.minimumUpdatePeriod&&(this.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){r.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod))}},{key:"refreshXml_",value:function(){var r=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!r.request){if(r.request=null,n)return r.error={status:a.status,message:"DASH playlist request error at URL: "+r.srcUrl,responseText:a.responseText,code:2},r.state==="HAVE_NOTHING"&&(r.started=!1),r.trigger("error");r.masterXml_=a.responseText,r.sidxMapping_=jP(r.masterXml_,r.srcUrl,r.clientOffset_,r.sidxMapping_);var s=r.parseMasterXml(),o=aS(r.master,s),l=r.media().sidx;if(o)if(l){var u=wv(l);if(!r.sidxMapping_[u]){var h=r.media();r.request=oS(h.sidx,h,r.hls_.xhr,{handleManifestRedirects:r.handleManifestRedirects},r.sidxRequestFinished_(h,s,r.state,function(c,d){if(!c||!d)throw new Error("failed to request sidx on minimumUpdatePeriod");r.sidxMapping_[u].sidx=d,r.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){r.trigger("minimumUpdatePeriod")},r.master.minimumUpdatePeriod),r.refreshMedia_(r.media().uri)}))}}else r.master=o;r.minimumUpdatePeriodTimeout_=Be.setTimeout(function(){r.trigger("minimumUpdatePeriod")},r.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(r){var n=this;if(!r)throw new Error("refreshMedia_ must take a media uri");var a=void 0,s=void 0;this.masterPlaylistLoader_?(a=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.parseMasterXml()):(a=this.master,s=this.parseMasterXml());var o=aS(a,s);o?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=o:this.master=o,this.media_=o.playlists[r]):(this.media_=s.playlists[r],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=Be.setTimeout(function(){n.trigger("mediaupdatetimeout")},AT(this.media(),!!o))),this.trigger("loadedplaylist")}}]),t}(UP),hd=function(t){return re.log.debug?re.log.debug.bind(re,"VHS:",t+" >"):function(){}};function zl(){}var $P=function(){function e(t,i,r,n){Ia(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=t,this.processedAppend_=!1,this.type_=r,this.mimeType_=i,this.logger_=hd("SourceUpdater["+r+"]["+i+"]"),t.readyState==="closed"?t.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,n)):this.createSourceBuffer_(i,n)}return Za(e,[{key:"createSourceBuffer_",value:function(i,r){var n=this;if(this.sourceBuffer_=this.mediaSource.addSourceBuffer(i),this.logger_("created SourceBuffer"),r&&(r.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)){r.on("sourcebufferadded",function(){n.start_()});return}this.start_()}},{key:"start_",value:function(){var i=this;this.started_=!0,this.onUpdateendCallback_=function(){var r=i.pendingCallback_;i.pendingCallback_=null,i.sourceBuffer_.removing=!1,i.logger_("buffered ["+bv(i.buffered())+"]"),r&&r(),i.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(i){var r=this;this.processedAppend_&&this.queueCallback_(function(){r.sourceBuffer_.abort()},i)}},{key:"appendBuffer",value:function(i,r){var n=this;this.processedAppend_=!0,this.queueCallback_(function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.addEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),n.sourceBuffer_.appendBuffer(i.bytes)},function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),r()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:re.createTimeRanges()}},{key:"remove",value:function(i,r){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zl;this.processedAppend_&&this.queueCallback_(function(){n.logger_("remove ["+i+" => "+r+"]"),n.sourceBuffer_.removing=!0,n.sourceBuffer_.remove(i,r)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==zl}},{key:"timestampOffset",value:function(i){var r=this;return typeof i<"u"&&(this.queueCallback_(function(){r.sourceBuffer_.timestampOffset=i,r.runCallback_()}),this.timestampOffset_=i),this.timestampOffset_}},{key:"queueCallback_",value:function(i,r){this.callbacks_.push([i.bind(this),r]),this.runCallback_()}},{key:"runCallback_",value:function(){var i=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(i=this.callbacks_.shift(),this.pendingCallback_=i[1],i[0]())}},{key:"dispose",value:function(){var i=this,r=function n(){i.sourceBuffer_&&i.mediaSource.readyState==="open"&&i.sourceBuffer_.abort(),i.sourceBuffer_.removeEventListener("updateend",n)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",r):r()}}]),e}(),va={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1},Vo={FAILURE:2,TIMEOUT:-101,ABORTED:-102},uS=function(t){t.forEach(function(i){i.abort()})},HP=function(t){return{bandwidth:t.bandwidth,bytesReceived:t.bytesReceived||0,roundTripTime:t.roundTripTime||0}},GP=function(t){var i=t.target,r=Date.now()-i.requestTime,n={bandwidth:1/0,bytesReceived:0,roundTripTime:r||0};return n.bytesReceived=t.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},Cv=function(t,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:Vo.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:Vo.ABORTED,xhr:i}:t?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:Vo.FAILURE,xhr:i}:null},VP=function(t,i){return function(r,n){var a=n.response,s=Cv(r,n);if(s)return i(s,t);if(a.byteLength!==16)return i({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:Vo.FAILURE,xhr:n},t);var o=new DataView(a);return t.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),i(null,t)}},qP=function(t,i,r){return function(n,a){var s=a.response,o=Cv(n,a);return o?r(o,t):s.byteLength===0?r({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:Vo.FAILURE,xhr:a},t):(t.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),t.map.timescales=hf.timescale(t.map.bytes),t.map.videoTrackIds=hf.videoTrackIds(t.map.bytes),r(null,t))}},WP=function(t,i,r){return function(n,a){var s=a.response,o=Cv(n,a),l=void 0;return o?r(o,t):s.byteLength===0?r({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:Vo.FAILURE,xhr:a},t):(t.stats=HP(a),t.key?t.encryptedBytes=new Uint8Array(a.response):t.bytes=new Uint8Array(a.response),i&&t.map&&t.map.bytes&&(i.isInitialized()||i.init(),l=i.parse(t.bytes,t.map.videoTrackIds,t.map.timescales),l&&l.captions&&(t.captionStreams=l.captionStreams,t.fmp4Captions=l.captions)),r(null,t))}},YP=function(t,i,r){var n=function s(o){if(o.data.source===i.requestId){t.removeEventListener("message",s);var l=o.data.decrypted;return i.bytes=new Uint8Array(l.bytes,l.byteOffset,l.byteLength),r(null,i)}};t.addEventListener("message",n);var a=void 0;i.key.bytes.slice?a=i.key.bytes.slice():a=new Uint32Array(Array.prototype.slice.call(i.key.bytes)),t.postMessage(FT({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},KP=function(t,i,r){var n=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,uS(t),r(s,o);if(n+=1,n===t.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?YP(i,o,r):r(null,o)}}},zP=function(t,i){return function(r){return t.stats=re.mergeOptions(t.stats,GP(r)),!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()),i(r,t)}},XP=function(t,i,r,n,a,s,o){var l=[],u=KP(l,r,o);if(a.key&&!a.key.bytes){var h=re.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),c=VP(a,u),d=t(h,c);l.push(d)}if(a.map&&!a.map.bytes){var f=re.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:_v(a.map)}),T=qP(a,n,u),p=t(f,T);l.push(p)}var m=re.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:_v(a)}),y=WP(a,n,u),v=t(m,y);return v.addEventListener("progress",zP(a,s)),l.push(v),function(){return uS(l)}},lS=function(t,i){var r=void 0;return!t||(r=Be.getComputedStyle(t),!r)?"":r[i]},pd=function(t,i){var r=t.slice();t.sort(function(n,a){var s=i(n,a);return s===0?r.indexOf(n)-r.indexOf(a):s})},Dv=function(t,i){var r=void 0,n=void 0;return t.attributes.BANDWIDTH&&(r=t.attributes.BANDWIDTH),r=r||Be.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(n=i.attributes.BANDWIDTH),n=n||Be.Number.MAX_VALUE,r-n},JP=function(t,i){var r=void 0,n=void 0;return t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),r=r||Be.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(n=i.attributes.RESOLUTION.width),n=n||Be.Number.MAX_VALUE,r===n&&t.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?t.attributes.BANDWIDTH-i.attributes.BANDWIDTH:r-n},QP=function(t,i,r,n,a){var s=t.playlists.map(function(g){var E=void 0,x=void 0,A=void 0;return E=g.attributes.RESOLUTION&&g.attributes.RESOLUTION.width,x=g.attributes.RESOLUTION&&g.attributes.RESOLUTION.height,A=g.attributes.BANDWIDTH,A=A||Be.Number.MAX_VALUE,{bandwidth:A,width:E,height:x,playlist:g}});pd(s,function(g,E){return g.bandwidth-E.bandwidth}),s=s.filter(function(g){return!sa.isIncompatible(g.playlist)});var o=s.filter(function(g){return sa.isEnabled(g.playlist)});o.length||(o=s.filter(function(g){return!sa.isDisabled(g.playlist)}));var l=o.filter(function(g){return g.bandwidth*va.BANDWIDTH_VARIANCE<i}),u=l[l.length-1],h=l.filter(function(g){return g.bandwidth===u.bandwidth})[0];if(a===!1){var c=h||o[0]||s[0];return c?c.playlist:null}var d=l.filter(function(g){return g.width&&g.height});pd(d,function(g,E){return g.width-E.width});var f=d.filter(function(g){return g.width===r&&g.height===n});u=f[f.length-1];var T=f.filter(function(g){return g.bandwidth===u.bandwidth})[0],p=void 0,m=void 0,y=void 0;T||(p=d.filter(function(g){return g.width>r||g.height>n}),m=p.filter(function(g){return g.width===p[0].width&&g.height===p[0].height}),u=m[m.length-1],y=m.filter(function(g){return g.bandwidth===u.bandwidth})[0]);var v=y||T||h||o[0]||s[0];return v?v.playlist:null},ZP=function(){return QP(this.playlists.master,this.systemBandwidth,parseInt(lS(this.tech_.el(),"width"),10),parseInt(lS(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},e2=function(t){var i=t.master,r=t.currentTime,n=t.bandwidth,a=t.duration,s=t.segmentDuration,o=t.timeUntilRebuffer,l=t.currentTimeline,u=t.syncController,h=i.playlists.filter(function(p){return!sa.isIncompatible(p)}),c=h.filter(sa.isEnabled);c.length||(c=h.filter(function(p){return!sa.isDisabled(p)}));var d=c.filter(sa.hasAttribute.bind(null,"BANDWIDTH")),f=d.map(function(p){var m=u.getSyncPoint(p,a,l,r),y=m?1:2,v=sa.estimateSegmentRequestTime(s,n,p),g=v*y-o;return{playlist:p,rebufferingImpact:g}}),T=f.filter(function(p){return p.rebufferingImpact<=0});return pd(T,function(p,m){return Dv(m.playlist,p.playlist)}),T.length?T[0]:(pd(f,function(p,m){return p.rebufferingImpact-m.rebufferingImpact}),f[0]||null)},t2=function(){var t=this.playlists.master.playlists.filter(sa.isEnabled);pd(t,function(r,n){return Dv(r,n)});var i=t.filter(function(r){return dd(r.attributes.CODECS).videoCodec});return i[0]||null},r2=function(t,i,r){for(var n in r)if(!t[n]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(n);a?t[n]=a:t[n]=i.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}},i2=function(t){var i=t.inbandTextTracks,r=t.captionArray,n=t.timestampOffset;if(!!r){var a=window.WebKitDataCue||window.VTTCue;r.forEach(function(s){var o=s.stream,l=s.startTime,u=s.endTime;!i[o]||(l+=n,u+=n,i[o].addCue(new a(l,u,s.text)))})}},n2=500,a2=function(t,i,r){if(!t||!i)return!1;var n=t.segments,a=r===n.length;return t.endList&&i.readyState==="open"&&a},cS=function(t){return typeof t=="number"&&isFinite(t)},s2=function(t,i,r){return t!=="main"||!i||!r?null:!r.containsAudio&&!r.containsVideo?"Neither audio nor video found in segment.":i.containsVideo&&!r.containsVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!i.containsVideo&&r.containsVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null},o2=function(t,i,r){var n=void 0;return t.length&&t.start(0)>0&&t.start(0)<i?n=t.start(0):n=i-30,Math.min(n,i-r)},u2=function(t){var i=t.segment,r=i.start,n=i.end,a=t.playlist,s=a.mediaSequence,o=a.id,l=a.segments,u=l===void 0?[]:l,h=t.mediaIndex,c=t.timeline;return["appending ["+h+"] of ["+s+", "+(s+u.length)+"] from playlist ["+o+"]","["+r+" => "+n+"] in timeline ["+c+"]"].join(" ")},kv=function(e){no(t,e);function t(i){Ia(this,t);var r=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!i)throw new TypeError("Initialization settings are required");if(typeof i.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!i.mediaSource)throw new TypeError("No MediaSource specified");return r.bandwidth=i.bandwidth,r.throughput={rate:0,count:0},r.roundTrip=NaN,r.resetStats_(),r.mediaIndex=null,r.hasPlayed_=i.hasPlayed,r.currentTime_=i.currentTime,r.seekable_=i.seekable,r.seeking_=i.seeking,r.duration_=i.duration,r.mediaSource_=i.mediaSource,r.hls_=i.hls,r.loaderType_=i.loaderType,r.startingMedia_=void 0,r.segmentMetadataTrack_=i.segmentMetadataTrack,r.goalBufferLength_=i.goalBufferLength,r.sourceType_=i.sourceType,r.inbandTextTracks_=i.inbandTextTracks,r.state_="INIT",r.checkBufferTimeout_=null,r.error_=void 0,r.currentTimeline_=-1,r.pendingSegment_=null,r.mimeType_=null,r.sourceUpdater_=null,r.xhrOptions_=null,r.activeInitSegmentId_=null,r.initSegments_={},r.cacheEncryptionKeys_=i.cacheEncryptionKeys,r.keyCache_={},r.loaderType_==="main"?r.captionParser_=new PD:r.captionParser_=null,r.decrypter_=i.decrypter,r.syncController_=i.syncController,r.syncPoint_={segmentIndex:0,time:0},r.syncController_.on("syncinfoupdate",function(){return r.trigger("syncinfoupdate")}),r.mediaSource_.addEventListener("sourceopen",function(){return r.ended_=!1}),r.fetchAtBuffer_=!1,r.logger_=hd("SegmentLoader["+r.loaderType_+"]"),Object.defineProperty(r,"state",{get:function(){return this.state_},set:function(a){a!==this.state_&&(this.logger_(this.state_+" -> "+a),this.state_=a)}}),r}return Za(t,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset()}},{key:"abort",value:function(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(r){return typeof r<"u"&&(this.error_=r),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():re.createTimeRanges()}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Kf(r),s=this.initSegments_[a];return n&&!s&&r.bytes&&(this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:r.bytes,timescales:r.timescales,videoTrackIds:r.videoTrackIds}),s||r}},{key:"segmentKey",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=UT(r),s=this.keyCache_[a];this.cacheEncryptionKeys_&&n&&!s&&r.bytes&&(this.keyCache_[a]=s={resolvedUri:r.resolvedUri,bytes:r.bytes});var o={resolvedUri:(s||r).resolvedUri};return s&&(o.bytes=s.bytes),o}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&this.state==="INIT")&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),!!this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new $P(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!r){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=r,this.xhrOptions_=n,this.hasPlayed_()||(r.syncInfo={mediaSequence:r.mediaSequence,time:0});var o=null;if(a&&(a.id?o=a.id:a.uri&&(o=a.uri)),this.logger_("playlist update ["+o+" => "+(r.id||r.uri)+"]"),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==r.uri){this.mediaIndex!==null&&this.resyncLoader();return}var l=r.mediaSequence-a.mediaSequence;this.logger_("live window shift ["+l+"]"),this.mediaIndex!==null&&(this.mediaIndex-=l),s&&(s.mediaIndex-=l,s.mediaIndex>=0&&(s.segment=r.segments[s.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(a,r)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(r,n){this.mimeType_||(this.mimeType_=r,this.sourceBufferEmitter_=n,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(r){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_(),r),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(r,n,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(r,n,a),ql(r,n,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)ql(r,n,this.inbandTextTracks_[s])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=Be.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&Be.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=Be.setTimeout(this.monitorBufferTick_.bind(this),n2)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var r=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(!!r){if(this.isEndOfStream_(r.mediaIndex)){this.endOfStream();return}r.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()||(r.timeline!==this.currentTimeline_&&(this.syncController_.reset(),r.timestampOffset=r.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(r))}}}},{key:"isEndOfStream_",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return a2(n,this.mediaSource_,r)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(r,n,a,s,o,l){var u=0,h=void 0;r.length&&(u=r.end(r.length-1));var c=Math.max(0,u-o);if(!n.segments.length||c>=this.goalBufferLength_()||!s&&c>=1)return null;if(l===null)return a=this.getSyncSegmentCandidate_(n),this.generateSegmentInfo_(n,a,null,!0);if(a!==null)return n.segments[a],h=u,this.generateSegmentInfo_(n,a+1,h,!1);if(this.fetchAtBuffer_){var d=sa.getMediaInfoForTime(n,u,l.segmentIndex,l.time);a=d.mediaIndex,h=d.startTime}else{var f=sa.getMediaInfoForTime(n,o,l.segmentIndex,l.time);a=f.mediaIndex,h=f.startTime}return this.generateSegmentInfo_(n,a,h,!1)}},{key:"getSyncSegmentCandidate_",value:function(r){var n=this;if(this.currentTimeline_===-1)return 0;var a=r.segments.map(function(s,o){return{timeline:s.timeline,segmentIndex:o}}).filter(function(s){return s.timeline===n.currentTimeline_});return a.length?a[Math.min(a.length-1,1)].segmentIndex:Math.max(r.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(r,n,a,s){if(n<0||n>=r.segments.length)return null;var o=r.segments[n];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:n,isSyncRequest:s,startOfSegment:a,playlist:r,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:o.timeline,duration:o.duration,segment:o}}},{key:"abortRequestEarly_",value:function(r){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(r.firstBytesReceivedAt||Date.now())<1e3)return!1;var n=this.currentTime_(),a=r.bandwidth,s=this.pendingSegment_.duration,o=sa.estimateSegmentRequestTime(s,a,this.playlist_,r.bytesReceived),l=yP(this.buffered_(),n,this.hls_.tech_.playbackRate())-1;if(o<=l)return!1;var u=e2({master:this.hls_.playlists.master,currentTime:n,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:l,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!u){var h=o-l,c=h-u.rebufferingImpact,d=.5;return l<=zf&&(d=1),!u.playlist||u.playlist.uri===this.playlist_.uri||c<d?!1:(this.bandwidth=u.playlist.attributes.BANDWIDTH*va.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(r,n){!this.pendingSegment_||n.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(n.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(r){this.state="WAITING",this.pendingSegment_=r,this.trimBackBuffer_(r),r.abortRequests=XP(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(r),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function(r){var n=o2(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);n>0&&this.remove(0,n)}},{key:"createSimplifiedSegmentObj_",value:function(r){var n=r.segment,a={resolvedUri:n.resolvedUri,byterange:n.byterange,requestId:r.requestId};if(n.key){var s=n.key.iv||new Uint32Array([0,0,0,r.mediaIndex+r.playlist.mediaSequence]);a.key=this.segmentKey(n.key),a.key.iv=s}return n.map&&(a.map=this.initSegment(n.map)),a}},{key:"segmentRequestFinished_",value:function(r,n){if(this.mediaRequests+=1,n.stats&&(this.mediaBytesTransferred+=n.stats.bytesReceived,this.mediaTransferDuration+=n.stats.roundTripTime),!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(n.requestId===this.pendingSegment_.requestId){if(r){if(this.pendingSegment_=null,this.state="READY",r.code===Vo.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),r.code===Vo.TIMEOUT){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1,this.error(r),this.trigger("error");return}this.bandwidth=n.stats.bandwidth,this.roundTrip=n.stats.roundTripTime,n.map&&(n.map=this.initSegment(n.map,!0)),n.key&&this.segmentKey(n.key,!0),this.processSegmentResponse_(n)}}},{key:"processSegmentResponse_",value:function(r){var n=this.pendingSegment_;n.bytes=r.bytes,r.map&&(n.segment.map.bytes=r.map.bytes),n.endOfAllRequests=r.endOfAllRequests,r.fmp4Captions&&(r2(this.inbandTextTracks_,this.hls_.tech_,r.captionStreams),i2({inbandTextTracks:this.inbandTextTracks_,captionArray:r.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var r=this;if(!this.pendingSegment_){this.state="READY";return}var n=this.pendingSegment_,a=n.segment,s=this.syncController_.probeSegmentInfo(n);typeof this.startingMedia_>"u"&&s&&(s.containsAudio||s.containsVideo)&&(this.startingMedia_={containsAudio:s.containsAudio,containsVideo:s.containsVideo});var o=s2(this.loaderType_,this.startingMedia_,s);if(o){this.error({message:o,blacklistDuration:1/0}),this.trigger("error");return}if(n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}if(n.timestampOffset!==null&&n.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(s&&s.segmentTimestampInfo){var l=s.segmentTimestampInfo[0].ptsTime,u=s.segmentTimestampInfo[0].dtsTime;n.timestampOffset-=l-u}this.sourceUpdater_.timestampOffset(n.timestampOffset),this.trigger("timestampoffset")}var h=this.syncController_.mappingForTimeline(n.timeline);if(h!==null&&this.trigger({type:"segmenttimemapping",mapping:h}),this.state="APPENDING",a.map){var c=Kf(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==c){var d=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:d.bytes},function(){r.activeInitSegmentId_=c})}}n.byteLength=n.bytes.byteLength,typeof a.start=="number"&&typeof a.end=="number"?this.mediaSecondsLoaded+=a.end-a.start:this.mediaSecondsLoaded+=a.duration,this.logger_(u2(n)),this.sourceUpdater_.appendBuffer({bytes:n.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,n.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(r,n){if(!(!this.pendingSegment_||r!==this.pendingSegment_.requestId)){var a=this.pendingSegment_.segment;a.videoTimingInfo||(a.videoTimingInfo={}),a.videoTimingInfo.transmuxerPrependedSeconds=n.videoSegmentTimingInfo.prependedContentDuration||0,a.videoTimingInfo.transmuxedPresentationStart=n.videoSegmentTimingInfo.start.presentation,a.videoTimingInfo.transmuxedPresentationEnd=n.videoSegmentTimingInfo.end.presentation,a.videoTimingInfo.baseMediaDecodeTime=n.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}var r=this.pendingSegment_,n=r.segment,a=this.mediaIndex!==null;if(this.pendingSegment_=null,this.recordThroughput_(r),this.addSegmentMetadataCue_(r),this.state="READY",this.mediaIndex=r.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=r.timeline,this.trigger("syncinfoupdate"),n.end&&this.currentTime_()-n.end>r.playlist.targetDuration*3){this.resetEverything();return}a&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(r.mediaIndex+1,r.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(r){var n=this.throughput.rate,a=Date.now()-r.endOfAllRequests+1,s=Math.floor(r.byteLength/a*8*1e3);this.throughput.rate+=(s-n)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(r){if(!!this.segmentMetadataTrack_){var n=r.segment,a=n.start,s=n.end;if(!(!cS(a)||!cS(s))){ql(a,s,this.segmentMetadataTrack_);var o=Be.WebKitDataCue||Be.VTTCue,l={custom:n.custom,dateTimeObject:n.dateTimeObject,dateTimeString:n.dateTimeString,bandwidth:r.playlist.attributes.BANDWIDTH,resolution:r.playlist.attributes.RESOLUTION,codecs:r.playlist.attributes.CODECS,byteLength:r.byteLength,uri:r.uri,timeline:r.timeline,playlist:r.playlist.uri,start:a,end:s},u=JSON.stringify(l),h=new o(a,s,u);h.value=l,this.segmentMetadataTrack_.addCue(h)}}}}]),t}(re.EventTarget),dS=function(t){return decodeURIComponent(escape(String.fromCharCode.apply(null,t)))},fS=new Uint8Array(`
|
103
103
|
|
104
|
-
`.split("").map(function(e){return e.charCodeAt(0)})),l2=function(e){no(t,e);function t(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ia(this,t);var n=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,r));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Za(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return re.createTimeRanges();var r=this.subtitlesTrack_.cues,n=r[0].startTime,a=r[r.length-1].startTime;return re.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Kf(r),s=this.initSegments_[a];if(n&&!s&&r.bytes){var o=fS.byteLength+r.bytes.byteLength,l=new Uint8Array(o);l.set(r.bytes),l.set(fS,r.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:l}}return s||r}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(r){return typeof r>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=r,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(r,n){ql(r,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var r=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.timeline)===null){var a=function(){r.state="READY",r.paused()||r.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(r){for(;r&&r.segment.empty;)r=this.generateSegmentInfo_(r.playlist,r.mediaIndex+1,r.startOfSegment+r.duration,r.isSyncRequest);return r}},{key:"handleSegment_",value:function(){var r=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof Be.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){r.subtitlesTrack_.tech_.off("vttjsloaded",s),r.error({message:"Error loading vtt.js"}),r.state="READY",r.pause(),r.trigger("error")};s=function(){r.subtitlesTrack_.tech_.off("vttjserror",o),r.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){return this.error({message:l.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(l){r.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(r){var n=void 0,a=!1;typeof Be.TextDecoder=="function"?n=new Be.TextDecoder("utf8"):(n=Be.WebVTT.StringDecoder(),a=!0);var s=new Be.WebVTT.Parser(Be,Be.vttjs,n);if(r.cues=[],r.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=r.cues.push.bind(r.cues),s.ontimestampmap=function(u){return r.timestampmap=u},s.onparsingerror=function(u){re.log.warn("Error encountered when parsing cues: "+u.message)},r.segment.map){var o=r.segment.map.bytes;a&&(o=dS(o)),s.parse(o)}var l=r.bytes;a&&(l=dS(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(r,n,a){var s=r.segment;if(!!n){if(!r.cues.length){s.empty=!0;return}var o=r.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(r.cues.forEach(function(c){c.startTime+=l,c.endTime+=l}),!a.syncInfo){var u=r.cues[0].startTime,h=r.cues[r.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:Math.min(u,h-s.duration)}}}}}]),t}(kv),c2=function(t,i){for(var r=t.cues,n=0;n<r.length;n++){var a=r[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},d2=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!t.segments)for(var n=r,a=void 0,s=0;s<t.segments.length;s++){var o=t.segments[s];if(a||(a=c2(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Be.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,h=o.cueOutCont.split("/").map(parseFloat),c=BR(h,2);l=c[0],u=c[1],a=new Be.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},f2=ak.inspect,hS=[{name:"VOD",run:function(t,i,r,n,a){if(r!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(t,i,r,n,a){if(!t.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var h=s[u];if(h.dateTimeObject){var c=h.dateTimeObject.getTime()/1e3,d=c+t.datetimeToDisplayTime,f=Math.abs(a-d);if(l!==null&&(f===0||l<f))break;l=f,o={time:d,segmentIndex:u}}}return o}},{name:"Segment",run:function(t,i,r,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var h=s[u];if(h.timeline===n&&typeof h.start<"u"){var c=Math.abs(a-h.start);if(l!==null&&l<c)break;(!o||l===null||l>=c)&&(l=c,o={time:h.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(t,i,r,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],h=i.discontinuitySequence+l+1,c=t.discontinuities[h];if(c){var d=Math.abs(a-c.time);if(o!==null&&o<d)break;(!s||o===null||o>=d)&&(o=d,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(t,i,r,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],h2=function(e){no(t,e);function t(){Ia(this,t);var i=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=hd("SyncController"),i}return Za(t,[{key:"getSyncPoint",value:function(r,n,a,s){var o=this.runStrategies_(r,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(r,n){if(!r||!r.segments)return null;var a=this.runStrategies_(r,n,r.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+cd(r,s.segmentIndex,0))}},{key:"runStrategies_",value:function(r,n,a,s){for(var o=[],l=0;l<hS.length;l++){var u=hS[l],h=u.run(this,r,n,a,s);h&&(h.strategy=u.name,o.push({strategy:u.name,syncPoint:h}))}return o}},{key:"selectSyncPoint_",value:function(r,n){for(var a=r[0].syncPoint,s=Math.abs(r[0].syncPoint[n.key]-n.value),o=r[0].strategy,l=1;l<r.length;l++){var u=Math.abs(r[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=r[l].syncPoint,o=r[l].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(r,n){for(var a=n.mediaSequence-r.mediaSequence,s=a-1;s>=0;s--){var o=r.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:r.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(r){if(!this.datetimeToDisplayTime&&r.segments&&r.segments.length&&r.segments[0].dateTimeObject){var n=r.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(r){var n=r.segment,a=r.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(r):s=this.probeTsSegment_(r),s&&this.calculateSegmentTimeMapping_(r,s)&&(this.saveDiscontinuitySyncInfo_(r),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(r){var n=r.segment,a=hf.timescale(n.map.bytes),s=hf.startTime(a,r.bytes);return r.timestampOffset!==null&&(r.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(r){var n=f2(r.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].time}},{key:"mappingForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].mapping}},{key:"calculateSegmentTimeMapping_",value:function(r,n){var a=r.segment,s=this.timelines[r.timeline];if(r.timestampOffset!==null)s={time:r.startOfSegment,mapping:r.startOfSegment-n.start},this.timelines[r.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+r.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=r.startOfSegment,a.end=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(r){var n=r.playlist,a=r.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],l=n.discontinuitySequence+s+1,u=o-r.mediaIndex,h=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>h){var c=void 0;u<0?c=a.start-cd(n,r.mediaIndex,o):c=a.end+cd(n,r.mediaIndex+1,o),this.discontinuities[l]={time:c,accuracy:h}}}}}]),t}(re.EventTarget),p2=new WT("./decrypter-worker.worker.js",function(e,t){var i=this;(function(){function r(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}var n=function(E,x){if(!(E instanceof x))throw new TypeError("Cannot call a class as a function")},a=function(){function g(E,x){for(var A=0;A<x.length;A++){var S=x[A];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(E,S.key,S)}}return function(E,x,A){return x&&g(E.prototype,x),A&&g(E,A),E}}(),s=function(E,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);E.prototype=Object.create(x&&x.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(E,x):E.__proto__=x)},o=function(E,x){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:E},l=function(){var E=[[[],[],[],[],[]],[[],[],[],[],[]]],x=E[0],A=E[1],S=x[4],b=A[4],C=void 0,D=void 0,R=void 0,P=[],N=[],j=void 0,O=void 0,I=void 0,F=void 0,H=void 0,K=void 0;for(C=0;C<256;C++)N[(P[C]=C<<1^(C>>7)*283)^C]=C;for(D=R=0;!S[D];D^=j||1,R=N[R]||1)for(F=R^R<<1^R<<2^R<<3^R<<4,F=F>>8^F&255^99,S[D]=F,b[F]=D,I=P[O=P[j=P[D]]],K=I*16843009^O*65537^j*257^D*16843008,H=P[F]*257^F*16843008,C=0;C<4;C++)x[C][D]=H=H<<24^H>>>8,A[C][F]=K=K<<24^K>>>8;for(C=0;C<5;C++)x[C]=x[C].slice(0),A[C]=A[C].slice(0);return E},u=null,h=function(){function g(E){n(this,g),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var x=void 0,A=void 0,S=void 0,b=void 0,C=void 0,D=this._tables[0][4],R=this._tables[1],P=E.length,N=1;if(P!==4&&P!==6&&P!==8)throw new Error("Invalid aes key size");for(b=E.slice(0),C=[],this._key=[b,C],x=P;x<4*P+28;x++)S=b[x-1],(x%P===0||P===8&&x%P===4)&&(S=D[S>>>24]<<24^D[S>>16&255]<<16^D[S>>8&255]<<8^D[S&255],x%P===0&&(S=S<<8^S>>>24^N<<24,N=N<<1^(N>>7)*283)),b[x]=b[x-P]^S;for(A=0;x;A++,x--)S=b[A&3?x:x-4],x<=4||A<4?C[A]=S:C[A]=R[0][D[S>>>24]]^R[1][D[S>>16&255]]^R[2][D[S>>8&255]]^R[3][D[S&255]]}return g.prototype.decrypt=function(x,A,S,b,C,D){var R=this._key[1],P=x^R[0],N=b^R[1],j=S^R[2],O=A^R[3],I=void 0,F=void 0,H=void 0,K=R.length/4-2,J=void 0,le=4,ce=this._tables[1],Z=ce[0],ve=ce[1],Ce=ce[2],Ne=ce[3],ot=ce[4];for(J=0;J<K;J++)I=Z[P>>>24]^ve[N>>16&255]^Ce[j>>8&255]^Ne[O&255]^R[le],F=Z[N>>>24]^ve[j>>16&255]^Ce[O>>8&255]^Ne[P&255]^R[le+1],H=Z[j>>>24]^ve[O>>16&255]^Ce[P>>8&255]^Ne[N&255]^R[le+2],O=Z[O>>>24]^ve[P>>16&255]^Ce[N>>8&255]^Ne[j&255]^R[le+3],le+=4,P=I,N=F,j=H;for(J=0;J<4;J++)C[(3&-J)+D]=ot[P>>>24]<<24^ot[N>>16&255]<<16^ot[j>>8&255]<<8^ot[O&255]^R[le++],I=P,P=N,N=j,j=O,O=I},g}(),c=function(){function g(){n(this,g),this.listeners={}}return g.prototype.on=function(x,A){this.listeners[x]||(this.listeners[x]=[]),this.listeners[x].push(A)},g.prototype.off=function(x,A){if(!this.listeners[x])return!1;var S=this.listeners[x].indexOf(A);return this.listeners[x].splice(S,1),S>-1},g.prototype.trigger=function(x){var A=this.listeners[x];if(!!A)if(arguments.length===2)for(var S=A.length,b=0;b<S;++b)A[b].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),D=A.length,R=0;R<D;++R)A[R].apply(this,C)},g.prototype.dispose=function(){this.listeners={}},g.prototype.pipe=function(x){this.on("data",function(A){x.push(A)})},g}(),d=function(g){s(E,g);function E(){n(this,E);var x=o(this,g.call(this,c));return x.jobs=[],x.delay=1,x.timeout_=null,x}return E.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},E.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},E}(c),f=function(E){return E<<24|(E&65280)<<8|(E&16711680)>>8|E>>>24},T=function(E,x,A){var S=new Int32Array(E.buffer,E.byteOffset,E.byteLength>>2),b=new h(Array.prototype.slice.call(x)),C=new Uint8Array(E.byteLength),D=new Int32Array(C.buffer),R=void 0,P=void 0,N=void 0,j=void 0,O=void 0,I=void 0,F=void 0,H=void 0,K=void 0;for(R=A[0],P=A[1],N=A[2],j=A[3],K=0;K<S.length;K+=4)O=f(S[K]),I=f(S[K+1]),F=f(S[K+2]),H=f(S[K+3]),b.decrypt(O,I,F,H,D,K),D[K]=f(D[K]^R),D[K+1]=f(D[K+1]^P),D[K+2]=f(D[K+2]^N),D[K+3]=f(D[K+3]^j),R=O,P=I,N=F,j=H;return C},p=function(){function g(E,x,A,S){n(this,g);var b=g.STEP,C=new Int32Array(E.buffer),D=new Uint8Array(E.byteLength),R=0;for(this.asyncStream_=new d,this.asyncStream_.push(this.decryptChunk_(C.subarray(R,R+b),x,A,D)),R=b;R<C.length;R+=b)A=new Uint32Array([f(C[R-4]),f(C[R-3]),f(C[R-2]),f(C[R-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(R,R+b),x,A,D));this.asyncStream_.push(function(){S(null,r(D))})}return g.prototype.decryptChunk_=function(x,A,S,b){return function(){var C=T(x,A,S);b.set(C,x.byteOffset)}},a(g,null,[{key:"STEP",get:function(){return 32e3}}]),g}(),m=function(E){var x={};return Object.keys(E).forEach(function(A){var S=E[A];ArrayBuffer.isView(S)?x[A]={bytes:S.buffer,byteOffset:S.byteOffset,byteLength:S.byteLength}:x[A]=S}),x},y=function(E){E.onmessage=function(x){var A=x.data,S=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),b=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(S,b,C,function(D,R){E.postMessage(m({source:A.source,decrypted:R}),[R.buffer])})}},v=new y(i);return v})()}),g2=function(t){var i=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Jf=function(t,i){t.abort(),t.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},Rv=function(t,i){i.activePlaylistLoader=t,t.load()},v2=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Jf(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),Rv(l.playlistLoader,s)}}},m2=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Jf(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){Rv(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),Rv(l.playlistLoader,s)}}},Qf={AUDIO:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t],a=i.blacklistCurrentPlaylist;Jf(r,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(c){return c.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}re.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var h in n.tracks)n.tracks[h].enabled=n.tracks[h]===u;n.onTrackChanged()}},SUBTITLES:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t];re.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Jf(r,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},pS={AUDIO:function(t,i,r){if(!!i){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Qf[t](t,r))}},SUBTITLES:function(t,i,r){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t],o=r.mediaTypes[t];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Qf[t](t,r))}},y2={AUDIO:function(t,i){var r=i.hls,n=i.sourceType,a=i.segmentLoaders[t],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[t],u=l.groups,h=l.tracks,c=i.masterPlaylistLoader;(!o[t]||Object.keys(o[t]).length===0)&&(o[t]={main:{default:{default:!0}}});for(var d in o[t]){u[d]||(u[d]=[]);for(var f in o[t][d]){var T=o[t][d][f],p=void 0;if(T.resolvedUri?p=new Wf(T.resolvedUri,r,s):T.playlists&&n==="dash"?p=new Av(T.playlists[0],r,s,c):p=null,T=re.mergeOptions({id:f,playlistLoader:p},T),pS[t](t,T.playlistLoader,i),u[d].push(T),typeof h[f]>"u"){var m=new re.AudioTrack({id:f,kind:g2(T),enabled:!1,language:T.language,default:T.default,label:f});h[f]=m}}}a.on("error",Qf[t](t,i))},SUBTITLES:function(t,i){var r=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[t],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[t],h=u.groups,c=u.tracks,d=i.masterPlaylistLoader;for(var f in l[t]){h[f]||(h[f]=[]);for(var T in l[t][f])if(!l[t][f][T].forced){var p=l[t][f][T],m=void 0;if(a==="hls"?m=new Wf(p.resolvedUri,n,o):a==="dash"&&(m=new Av(p.playlists[0],n,o,d)),p=re.mergeOptions({id:T,playlistLoader:m},p),pS[t](t,p.playlistLoader,i),h[f].push(p),typeof c[T]>"u"){var y=r.addRemoteTextTrack({id:T,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:T},!1).track;c[T]=y}}}s.on("error",Qf[t](t,i))},"CLOSED-CAPTIONS":function(t,i){var r=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[t],s=a.groups,o=a.tracks;for(var l in n[t]){s[l]||(s[l]=[]);for(var u in n[t][l]){var h=n[t][l][u];if(!!h.instreamId.match(/CC\d/)&&(s[l].push(re.mergeOptions({id:u},h)),typeof o[u]>"u")){var c=r.addRemoteTextTrack({id:h.instreamId,kind:"captions",default:h.default&&h.autoselect,language:h.language,label:u},!1).track;o[u]=c}}}}},_2=function(t,i){return function(r){var n=i.masterPlaylistLoader,a=i.mediaTypes[t].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[t]&&(o=a[s.attributes[t]]),o=o||a.main,typeof r>"u"?o:r===null?null:o.filter(function(l){return l.id===r.id})[0]||null}},b2={AUDIO:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].enabled)return r[n];return null}},SUBTITLES:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].mode==="showing")return r[n];return null}}},T2=function(t){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(h){y2[h](h,t)});var i=t.mediaTypes,r=t.masterPlaylistLoader,n=t.tech,a=t.hls;["AUDIO","SUBTITLES"].forEach(function(h){i[h].activeGroup=_2(h,t),i[h].activeTrack=b2[h](h,t),i[h].onGroupChanged=v2(h,t),i[h].onTrackChanged=m2(h,t)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(h){return h.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),r.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(h){return i[h].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},S2=function(){var t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){t[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:zl,activeTrack:zl,onGroupChanged:zl,onTrackChanged:zl}}),t},E2=60*2,qo=void 0,x2=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],w2=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},A2=function(e){no(t,e);function t(i){Ia(this,t);var r=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,h=i.useCueTags,c=i.blacklistDuration,d=i.enableLowInitialPlaylist,f=i.sourceType,T=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");qo=u,r.withCredentials=s,r.tech_=o,r.hls_=o.hls,r.seekTo_=T,r.sourceType_=f,r.useCueTags_=h,r.blacklistDuration=c,r.enableLowInitialPlaylist=d,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},r.mediaTypes_=S2(),r.mediaSource=new re.MediaSource,r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_.bind(r)),r.seekable_=re.createTimeRanges(),r.hasPlayed_=function(){return!1},r.syncController_=new h2(i),r.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new p2,r.inbandTextTracks_={};var m={hls:r.hls_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.mediaSource.duration},hasPlayed:function(){return r.hasPlayed_()},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:p};return r.masterPlaylistLoader_=r.sourceType_==="dash"?new Av(n,r.hls_,r.requestOptions_):new Wf(n,r.hls_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new kv(re.mergeOptions(m,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),i),r.audioSegmentLoader_=new kv(re.mergeOptions(m,{loaderType:"audio"}),i),r.subtitleSegmentLoader_=new l2(re.mergeOptions(m,{loaderType:"vtt"}),i),r.setupSegmentLoaderListeners_(),x2.forEach(function(y){r[y+"_"]=w2.bind(r,y)}),r.logger_=hd("MPC"),r.masterPlaylistLoader_.load(),r}return Za(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var r=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;yv(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,n.endList&&r.tech_.preload()!=="none"&&(r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load()),T2({sourceType:r.sourceType_,segmentLoaders:{AUDIO:r.audioSegmentLoader_,SUBTITLES:r.subtitleSegmentLoader_,main:r.mainSegmentLoader_},tech:r.tech_,requestOptions:r.requestOptions_,masterPlaylistLoader:r.masterPlaylistLoader_,hls:r.hls_,master:r.master(),mediaTypes:r.mediaTypes_,blacklistCurrentPlaylist:r.blacklistCurrentPlaylist.bind(r)}),r.triggerPresenceUsage_(r.master(),n);try{r.setupSourceBuffers_()}catch(s){return re.log.warn("Failed to create SourceBuffers",s),r.mediaSource.endOfStream("decode")}r.setupFirstPlay(),!r.mediaTypes_.AUDIO.activePlaylistLoader||r.mediaTypes_.AUDIO.activePlaylistLoader.media()?r.trigger("selectedinitialmedia"):r.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){r.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=r.masterPlaylistLoader_.media();if(!n){r.excludeUnsupportedVariants_();var a=void 0;r.enableLowInitialPlaylist&&(a=r.selectInitialPlaylist()),a||(a=r.selectPlaylist()),r.initialMedia_=a,r.masterPlaylistLoader_.media(r.initialMedia_);return}if(r.useCueTags_&&r.updateAdCues_(n),r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.updateDuration(),r.tech_.paused()||(r.mainSegmentLoader_.load(),r.audioSegmentLoader_&&r.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=r.seekable();u.length!==0&&r.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(r.duration()!==1/0){var o=function l(){r.duration()===1/0?s():r.tech_.one("durationchange",l)};r.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){r.mainSegmentLoader_.abort(),r.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;yv(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load(),r.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=r.masterPlaylistLoader_.media(),a=r.stuckAtPlaylistEnd_(n);a&&(r.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),r.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(r,n){var a=r.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var h=a.AUDIO[l][u];h.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),qo.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),qo.Playlist.isFmp4(n)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var r=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=r.selectPlaylist(),a=r.masterPlaylistLoader_.media(),s=r.tech_.buffered(),o=s.length?s.end(s.length-1)-r.tech_.currentTime():0,l=r.bufferLowWaterLine();(!a.endList||r.duration()<va.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&r.masterPlaylistLoader_.media(n),r.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){r.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){r.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){r.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){r.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},E2)}),this.mainSegmentLoader_.on("reseteverything",function(){r.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){r.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){r.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var r=this.selectPlaylist();r!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(r),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var r=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){re.browser.IE_VERSION||re.browser.IS_EDGE?r.tech_.setCurrentTime(r.tech_.currentTime()+.04):r.tech_.setCurrentTime(r.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var r=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<r.start(0))return this.seekTo_(r.end(r.length-1))}}},{key:"setupFirstPlay",value:function(){var r=this,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(re.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){r.trigger("firstplay"),r.seekTo_(a.end(0)),r.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(n){return re.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var r=this.tech_.play();typeof r<"u"&&typeof r.then=="function"&&r.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var r=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?r=r&&this.audioSegmentLoader_.ended_:r=this.audioSegmentLoader_.ended_),!!r){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){re.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(r){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(r,this.mediaSource.duration);if(a===null)return!1;var s=qo.Playlist.playlistEnd(r,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=ao;var u=l.end(l.length-1);return u-o<=ao&&s-u<=ao}},{key:"blacklistCurrentPlaylist",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=r.playlist||this.masterPlaylistLoader_.media(),n=n||r.blacklistDuration||this.blacklistDuration,!a){this.error=r;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Yf).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(re.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(re.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),re.log.warn("Problem encountered with the current HLS playlist."+(r.message?" "+r.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(r){var n=HT(this.tech_.buffered(),r);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return r;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:qo.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var r=void 0,n=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(r=qo.Playlist.seekable(a,s),r.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=qo.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>r.end(0)||r.start(0)>n.end(0)?this.seekable_=r:this.seekable_=re.createTimeRanges([[n.start(0)>r.start(0)?n.start(0):r.start(0),n.end(0)<r.end(0)?n.end(0):r.end(0)]]):this.seekable_=r,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+bv(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var r=this,n=this.mediaSource.duration,a=qo.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){r.logger_("Setting duration from "+r.mediaSource.duration+" => "+a);try{r.mediaSource.duration=a}catch(u){re.log.warn("Failed to set media source duration",u)}r.tech_.trigger("durationchange"),r.mediaSource.removeEventListener("sourceopen",l)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),n!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var r=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=r.mediaTypes_[n].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var r=this.masterPlaylistLoader_.media(),n=void 0;if(!(!r||this.mediaSource.readyState!=="open")){if(n=RP(this.masterPlaylistLoader_.master,r),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+r.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(r)}}},{key:"configureLoaderMimeTypes_",value:function(r){var n=r.length>1&&r[0].indexOf(",")===-1&&r[0]!==r[1]?new re.EventTarget:null;this.mainSegmentLoader_.mimeType(r[0],n),r[1]&&this.audioSegmentLoader_.mimeType(r[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(r){r.attributes.CODECS&&Be.MediaSource&&Be.MediaSource.isTypeSupported&&!Be.MediaSource.isTypeSupported('video/mp4; codecs="'+AP(r.attributes.CODECS)+'"')&&(r.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(r){var n=2,a=null,s=void 0;r.attributes.CODECS&&(s=dd(r.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=dd(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(r){var n=0,a=this.seekable();a.length&&(n=a.start(0)),d2(r,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var r=this.tech_.currentTime(),n=va.GOAL_BUFFER_LENGTH,a=va.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,va.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+r*a,s)}},{key:"bufferLowWaterLine",value:function(){var r=this.tech_.currentTime(),n=va.BUFFER_LOW_WATER_LINE,a=va.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,va.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+r*a,s)}}]),t}(re.EventTarget),C2=function(t,i,r){return function(n){var a=t.master.playlists[i],s=mv(a),o=Yf(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(r(),n?t.trigger("renditionenabled"):t.trigger("renditiondisabled")),n)}},D2=function e(t,i,r){Ia(this,e);var n=t.masterPlaylistController_,a=t.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=r,this.enabled=C2(t.playlists,i.uri,o)},k2=function(t){var i=t.playlists;t.representations=function(){return i.master.playlists.filter(function(r){return!mv(r)}).map(function(r,n){return new D2(t,r,r.uri)})}},gS=["seeking","seeked","pause","playing","error"],R2=function(){function e(t){var i=this;Ia(this,e),this.tech_=t.tech,this.seekable=t.seekable,this.seekTo=t.seekTo,this.allowSeeksWithinUnsafeLiveWindow=t.allowSeeksWithinUnsafeLiveWindow,this.media=t.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=hd("PlaybackWatcher"),this.logger_("initialize");var r=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(gS,a),this.tech_.on("canplay",r),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(gS,a),i.tech_.off("canplay",r),i.checkCurrentTimeTimeout_&&Be.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Za(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&Be.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=Be.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),r=this.tech_.buffered();if(this.lastRecordedTime===i&&(!r.length||i+ao>=r.end(r.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var r=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(r,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=r.end(r.length-1);s=o}if(this.beforeSeekableWindow_(r,n)){var l=r.start(0);s=l+ao}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+bv(r)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),r=this.tech_.buffered(),n=HT(r,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+n.start(0)+" -> "+n.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),r=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,r)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+r+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=GT(a,r);if(this.videoUnderflow_(s,a,r))return this.cancelTimer_(),this.seekTo(r),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-r;return this.logger_("Stopped at "+r+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,r),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,r,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+ao,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),r>s}},{key:"beforeSeekableWindow_",value:function(i,r){return!!(i.length&&i.start(0)>0&&r<i.start(0)-ao)}},{key:"videoUnderflow_",value:function(i,r,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(r,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var r=this.tech_.buffered(),n=this.tech_.currentTime(),a=GT(r,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+zf),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,r){for(var n=mP(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(r-s<4&&r-s>2)return{start:s,end:o}}return null}}]),e}(),P2={errorInterval:30,getSource:function(t){var i=this.tech({IWillNotUseThisInPlugins:!0}),r=i.currentSource_;return t(r)}},O2=function e(t,i){var r=0,n=0,a=re.mergeOptions(P2,i);t.ready(function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&t.currentTime(n)},o=function(d){d!=null&&(n=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),t.src(d),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},l=function(){if(Date.now()-r<a.errorInterval*1e3){t.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){re.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return r=Date.now(),a.getSource.call(t,o)},u=function c(){t.off("loadedmetadata",s),t.off("error",l),t.off("dispose",c)},h=function(d){u(),e(t,d)};t.on("error",l),t.on("dispose",u),t.reloadSourceOnError=h},vS=function(t){O2(this,t)},L2="1.10.6";re.use("*",function(e){return{setSource:function(i,r){r(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var oa={PlaylistLoader:Wf,Playlist:sa,Decrypter:fk,AsyncStream:U_,decrypt:B_,utils:uP,STANDARD_PLAYLIST_SELECTOR:ZP,INITIAL_PLAYLIST_SELECTOR:t2,comparePlaylistBandwidth:Dv,comparePlaylistResolution:JP,xhr:NT()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(oa,e,{get:function(){return re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),va[e]},set:function(i){if(re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){re.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}va[e]=i}})});var mS="videojs-vhs",yS=function(t){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(t))return"hls";var r=/^application\/dash\+xml/i;return r.test(t)?"dash":null},_S=function(t,i){for(var r=i.media(),n=-1,a=0;a<t.length;a++)if(t[a].id===r.uri){n=a;break}t.selectedIndex_=n,t.trigger({selectedIndex:n,type:"change"})},I2=function(t,i){i.representations().forEach(function(r){t.addQualityLevel(r)}),_S(t,i.playlists)};oa.canPlaySource=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var M2=function(t,i,r){if(!t)return t;var n={};for(var a in t)n[a]={audioContentType:'audio/mp4; codecs="'+r.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof t[a]=="string"&&(n[a].url=t[a]);return re.mergeOptions(t,n)},N2=function(t){if(t.options_.sourceType==="dash"){var i=re.players[t.tech_.options_.playerId];if(i.eme){var r=M2(t.source_.keySystems,t.playlists.media(),t.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());r&&(i.currentSource().keySystems=r,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},bS=function(){if(!window.localStorage)return null;var t=window.localStorage.getItem(mS);if(!t)return null;try{return JSON.parse(t)}catch{return null}},F2=function(t){if(!window.localStorage)return!1;var i=bS();i=i?re.mergeOptions(i,t):t;try{window.localStorage.setItem(mS,JSON.stringify(i))}catch{return!1}return i};oa.supportsNativeHls=function(){var e=Mt.createElement("video");if(!re.getTech("Html5").isSupported())return!1;var t=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return t.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),oa.supportsNativeDash=function(){return re.getTech("Html5").isSupported()?/maybe|probably/i.test(Mt.createElement("video").canPlayType("application/dash+xml")):!1}(),oa.supportsTypeNatively=function(e){return e==="hls"?oa.supportsNativeHls:e==="dash"?oa.supportsNativeDash:!1},oa.isSupported=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var U2=re.getComponent("Component"),TS=function(e){no(t,e);function t(i,r,n){Ia(this,t);var a=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r,n.hls));if(r.options_&&r.options_.playerId){var s=re(r.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return re.log.warn("player.hls is deprecated. Use player.tech().hls instead."),r.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=r,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(r.featuresNativeVideoTracks||r.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(Mt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var l=Mt.fullscreenElement||Mt.webkitFullscreenElement||Mt.mozFullScreenElement||Mt.msFullscreenElement;l&&l.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return Za(t,[{key:"setOptions_",value:function(){var r=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var n=bS();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=va.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===va.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof r.source_[a]<"u"&&(r.options_[a]=r.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(r,n){var a=this;!r||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=oa,this.options_.sourceType=yS(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new A2(this.options_),this.playbackWatcher_=new R2(re.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=re.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):oa.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=oa.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){re.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return VT(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return VT(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&F2({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){k2(a),N2(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(re.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var r=this,n=re.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){I2(r.qualityLevels_,r)}),this.playlists.on("mediachange",function(){_S(r.qualityLevels_,r.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(r){this.masterPlaylistController_.setCurrentTime(r)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,UR(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(r,n){return gP({playlist:this.masterPlaylistController_.media(),time:r,callback:n})}},{key:"seekToProgramTime",value:function(r,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return vP({programTime:r,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),t}(U2),Pv={name:"videojs-http-streaming",VERSION:L2,canHandleSource:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=re.mergeOptions(re.options,i);return Pv.canPlayType(t.type,r)},handleSource:function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=re.mergeOptions(re.options,r);return i.hls=new TS(t,i,n),i.hls.xhr=NT(),i.hls.src(t.src,t.type),i.hls},canPlayType:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=re.mergeOptions(re.options,i),n=r.hls.overrideNative,a=yS(t),s=a&&(!oa.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof re.MediaSource>"u"||typeof re.URL>"u")&&(re.MediaSource=fd,re.URL=iS),fd.supportsNativeMediaSources()&&re.getTech("Html5").registerSourceHandler(Pv,0),re.HlsHandler=TS,re.HlsSourceHandler=Pv,re.Hls=oa,re.use||re.registerComponent("Hls",oa),re.options.hls=re.options.hls||{},re.registerPlugin?re.registerPlugin("reloadSourceOnError",vS):re.plugin("reloadSourceOnError",vS);const B2=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"})),SS={name:"stream-engine-player",version:"0.0.41",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}};var _n=[];for(let e=0;e<256;++e)_n.push((e+256).toString(16).slice(1));function j2(e,t=0){return(_n[e[t+0]]+_n[e[t+1]]+_n[e[t+2]]+_n[e[t+3]]+"-"+_n[e[t+4]]+_n[e[t+5]]+"-"+_n[e[t+6]]+_n[e[t+7]]+"-"+_n[e[t+8]]+_n[e[t+9]]+"-"+_n[e[t+10]]+_n[e[t+11]]+_n[e[t+12]]+_n[e[t+13]]+_n[e[t+14]]+_n[e[t+15]]).toLowerCase()}var Ov,$2=new Uint8Array(16);function H2(){if(!Ov){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ov=crypto.getRandomValues.bind(crypto)}return Ov($2)}var G2=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ES={randomUUID:G2};function V2(e,t,i){var n,a,s;if(ES.randomUUID&&!t&&!e)return ES.randomUUID();e=e||{};let r=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:H2();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(i=i||0,i<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[i+o]=r[o];return t}return j2(r)}var q2=V2,xS="000000",wS=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return xS.slice(e.length)+e},Xl=function(){return q2()},W2=function(){return(xS+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Lv=e=>{if(!e)return["localhost","localhost"];try{let t=new URL(e).hostname,i=t.split("."),r=i.length>=2?i.slice(-2).join("."):t;return[t,r]}catch{}return["localhost","localhost"]},xs=e=>Lv(e)[0],Iv=e=>Lv(e)[1],Y2=e=>{var t,i;if(e&&e.nodeName)return(t=e.uniqueId)!=null?t:e.uniqueId=wS();try{let r=document.querySelector(e);return r&&!r.uniqueId&&(r.uniqueId=e),(i=r==null?void 0:r.uniqueId)!=null?i:e}catch{}return e},K2=e=>{var r;let t=null;e&&e.nodeName!==void 0?(t=e,e=Y2(t)):t=document.querySelector(e);let i=((r=t==null?void 0:t.nodeName)==null?void 0:r.toLowerCase())||"";return[t,e,i]},AS=e=>{var i,r;let t=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=W2()),e.elementId;try{t=document.querySelector(e)}catch{}return t&&!t.elementId&&(t.elementId=e),(r=t==null?void 0:t.elementId)!=null?r:e};function z2(...e){return e.reduce((t,i)=>{for(let[r,n]of Object.entries(i))n!==void 0&&(t[r]=n);return t},{})}function Zf(e,t,i=1){var r;e[t]=((r=e[t])!=null?r:0)+i}function X2(e,t){let{beaconDomain:i}=t;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function CS(){var t,i;let e=(i=(t=navigator.doNotTrack)!=null?t:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var J2=class{constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(i=>{i(t)})}},Wo={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},eh={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.navigationStart:null}};function Q2(e){if(!e)return{};let t=eh.getNavigationStartTime(),{loading:i,trequest:r,tfirst:n,tload:a,total:s}=e,o=i?i.start:r,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(t+o),responseStart:Math.round(t+l),responseEnd:Math.round(t+u)}}var Z2=()=>{var t,i,r;let e=navigator;return(r=(i=(t=e==null?void 0:e.connection)!=null?t:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:r.type},eO=()=>{switch(Z2()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},tO=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function rO(e){let t={},i=new Set(tO.map(r=>r.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(r=>{let[n,...a]=r.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(t[n]=s)}),t)}var th=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return rO(e.getAllResponseHeaders())},iO={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:Lv,fetchDomain:Iv,fetchHost:xs,generateIdToken:wS,buildUUID:Xl,now:Wo.now};function nO(e){let t=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,r=window==null?void 0:window.Worker;if(!t||!i||!r||!e)return null;let n=new i([e]);return new r(t.createObjectURL(n))}var aO=`
|
104
|
+
`.split("").map(function(e){return e.charCodeAt(0)})),l2=function(e){no(t,e);function t(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ia(this,t);var n=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,r));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Za(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return re.createTimeRanges();var r=this.subtitlesTrack_.cues,n=r[0].startTime,a=r[r.length-1].startTime;return re.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Kf(r),s=this.initSegments_[a];if(n&&!s&&r.bytes){var o=fS.byteLength+r.bytes.byteLength,l=new Uint8Array(o);l.set(r.bytes),l.set(fS,r.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:l}}return s||r}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(r){return typeof r>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=r,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(r,n){ql(r,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var r=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.timeline)===null){var a=function(){r.state="READY",r.paused()||r.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(r){for(;r&&r.segment.empty;)r=this.generateSegmentInfo_(r.playlist,r.mediaIndex+1,r.startOfSegment+r.duration,r.isSyncRequest);return r}},{key:"handleSegment_",value:function(){var r=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof Be.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){r.subtitlesTrack_.tech_.off("vttjsloaded",s),r.error({message:"Error loading vtt.js"}),r.state="READY",r.pause(),r.trigger("error")};s=function(){r.subtitlesTrack_.tech_.off("vttjserror",o),r.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){return this.error({message:l.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(l){r.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(r){var n=void 0,a=!1;typeof Be.TextDecoder=="function"?n=new Be.TextDecoder("utf8"):(n=Be.WebVTT.StringDecoder(),a=!0);var s=new Be.WebVTT.Parser(Be,Be.vttjs,n);if(r.cues=[],r.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=r.cues.push.bind(r.cues),s.ontimestampmap=function(u){return r.timestampmap=u},s.onparsingerror=function(u){re.log.warn("Error encountered when parsing cues: "+u.message)},r.segment.map){var o=r.segment.map.bytes;a&&(o=dS(o)),s.parse(o)}var l=r.bytes;a&&(l=dS(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(r,n,a){var s=r.segment;if(!!n){if(!r.cues.length){s.empty=!0;return}var o=r.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(r.cues.forEach(function(c){c.startTime+=l,c.endTime+=l}),!a.syncInfo){var u=r.cues[0].startTime,h=r.cues[r.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:Math.min(u,h-s.duration)}}}}}]),t}(kv),c2=function(t,i){for(var r=t.cues,n=0;n<r.length;n++){var a=r[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},d2=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!t.segments)for(var n=r,a=void 0,s=0;s<t.segments.length;s++){var o=t.segments[s];if(a||(a=c2(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Be.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,h=o.cueOutCont.split("/").map(parseFloat),c=BR(h,2);l=c[0],u=c[1],a=new Be.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},f2=ak.inspect,hS=[{name:"VOD",run:function(t,i,r,n,a){if(r!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(t,i,r,n,a){if(!t.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var h=s[u];if(h.dateTimeObject){var c=h.dateTimeObject.getTime()/1e3,d=c+t.datetimeToDisplayTime,f=Math.abs(a-d);if(l!==null&&(f===0||l<f))break;l=f,o={time:d,segmentIndex:u}}}return o}},{name:"Segment",run:function(t,i,r,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var h=s[u];if(h.timeline===n&&typeof h.start<"u"){var c=Math.abs(a-h.start);if(l!==null&&l<c)break;(!o||l===null||l>=c)&&(l=c,o={time:h.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(t,i,r,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],h=i.discontinuitySequence+l+1,c=t.discontinuities[h];if(c){var d=Math.abs(a-c.time);if(o!==null&&o<d)break;(!s||o===null||o>=d)&&(o=d,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(t,i,r,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],h2=function(e){no(t,e);function t(){Ia(this,t);var i=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=hd("SyncController"),i}return Za(t,[{key:"getSyncPoint",value:function(r,n,a,s){var o=this.runStrategies_(r,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(r,n){if(!r||!r.segments)return null;var a=this.runStrategies_(r,n,r.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+cd(r,s.segmentIndex,0))}},{key:"runStrategies_",value:function(r,n,a,s){for(var o=[],l=0;l<hS.length;l++){var u=hS[l],h=u.run(this,r,n,a,s);h&&(h.strategy=u.name,o.push({strategy:u.name,syncPoint:h}))}return o}},{key:"selectSyncPoint_",value:function(r,n){for(var a=r[0].syncPoint,s=Math.abs(r[0].syncPoint[n.key]-n.value),o=r[0].strategy,l=1;l<r.length;l++){var u=Math.abs(r[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=r[l].syncPoint,o=r[l].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(r,n){for(var a=n.mediaSequence-r.mediaSequence,s=a-1;s>=0;s--){var o=r.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:r.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(r){if(!this.datetimeToDisplayTime&&r.segments&&r.segments.length&&r.segments[0].dateTimeObject){var n=r.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(r){var n=r.segment,a=r.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(r):s=this.probeTsSegment_(r),s&&this.calculateSegmentTimeMapping_(r,s)&&(this.saveDiscontinuitySyncInfo_(r),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(r){var n=r.segment,a=hf.timescale(n.map.bytes),s=hf.startTime(a,r.bytes);return r.timestampOffset!==null&&(r.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(r){var n=f2(r.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].time}},{key:"mappingForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].mapping}},{key:"calculateSegmentTimeMapping_",value:function(r,n){var a=r.segment,s=this.timelines[r.timeline];if(r.timestampOffset!==null)s={time:r.startOfSegment,mapping:r.startOfSegment-n.start},this.timelines[r.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+r.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=r.startOfSegment,a.end=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(r){var n=r.playlist,a=r.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],l=n.discontinuitySequence+s+1,u=o-r.mediaIndex,h=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>h){var c=void 0;u<0?c=a.start-cd(n,r.mediaIndex,o):c=a.end+cd(n,r.mediaIndex+1,o),this.discontinuities[l]={time:c,accuracy:h}}}}}]),t}(re.EventTarget),p2=new WT("./decrypter-worker.worker.js",function(e,t){var i=this;(function(){function r(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}var n=function(E,x){if(!(E instanceof x))throw new TypeError("Cannot call a class as a function")},a=function(){function g(E,x){for(var A=0;A<x.length;A++){var S=x[A];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(E,S.key,S)}}return function(E,x,A){return x&&g(E.prototype,x),A&&g(E,A),E}}(),s=function(E,x){if(typeof x!="function"&&x!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof x);E.prototype=Object.create(x&&x.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),x&&(Object.setPrototypeOf?Object.setPrototypeOf(E,x):E.__proto__=x)},o=function(E,x){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return x&&(typeof x=="object"||typeof x=="function")?x:E},l=function(){var E=[[[],[],[],[],[]],[[],[],[],[],[]]],x=E[0],A=E[1],S=x[4],b=A[4],C=void 0,D=void 0,R=void 0,P=[],N=[],j=void 0,O=void 0,I=void 0,F=void 0,H=void 0,K=void 0;for(C=0;C<256;C++)N[(P[C]=C<<1^(C>>7)*283)^C]=C;for(D=R=0;!S[D];D^=j||1,R=N[R]||1)for(F=R^R<<1^R<<2^R<<3^R<<4,F=F>>8^F&255^99,S[D]=F,b[F]=D,I=P[O=P[j=P[D]]],K=I*16843009^O*65537^j*257^D*16843008,H=P[F]*257^F*16843008,C=0;C<4;C++)x[C][D]=H=H<<24^H>>>8,A[C][F]=K=K<<24^K>>>8;for(C=0;C<5;C++)x[C]=x[C].slice(0),A[C]=A[C].slice(0);return E},u=null,h=function(){function g(E){n(this,g),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var x=void 0,A=void 0,S=void 0,b=void 0,C=void 0,D=this._tables[0][4],R=this._tables[1],P=E.length,N=1;if(P!==4&&P!==6&&P!==8)throw new Error("Invalid aes key size");for(b=E.slice(0),C=[],this._key=[b,C],x=P;x<4*P+28;x++)S=b[x-1],(x%P===0||P===8&&x%P===4)&&(S=D[S>>>24]<<24^D[S>>16&255]<<16^D[S>>8&255]<<8^D[S&255],x%P===0&&(S=S<<8^S>>>24^N<<24,N=N<<1^(N>>7)*283)),b[x]=b[x-P]^S;for(A=0;x;A++,x--)S=b[A&3?x:x-4],x<=4||A<4?C[A]=S:C[A]=R[0][D[S>>>24]]^R[1][D[S>>16&255]]^R[2][D[S>>8&255]]^R[3][D[S&255]]}return g.prototype.decrypt=function(x,A,S,b,C,D){var R=this._key[1],P=x^R[0],N=b^R[1],j=S^R[2],O=A^R[3],I=void 0,F=void 0,H=void 0,K=R.length/4-2,J=void 0,le=4,ce=this._tables[1],Z=ce[0],ve=ce[1],Ce=ce[2],Ne=ce[3],ot=ce[4];for(J=0;J<K;J++)I=Z[P>>>24]^ve[N>>16&255]^Ce[j>>8&255]^Ne[O&255]^R[le],F=Z[N>>>24]^ve[j>>16&255]^Ce[O>>8&255]^Ne[P&255]^R[le+1],H=Z[j>>>24]^ve[O>>16&255]^Ce[P>>8&255]^Ne[N&255]^R[le+2],O=Z[O>>>24]^ve[P>>16&255]^Ce[N>>8&255]^Ne[j&255]^R[le+3],le+=4,P=I,N=F,j=H;for(J=0;J<4;J++)C[(3&-J)+D]=ot[P>>>24]<<24^ot[N>>16&255]<<16^ot[j>>8&255]<<8^ot[O&255]^R[le++],I=P,P=N,N=j,j=O,O=I},g}(),c=function(){function g(){n(this,g),this.listeners={}}return g.prototype.on=function(x,A){this.listeners[x]||(this.listeners[x]=[]),this.listeners[x].push(A)},g.prototype.off=function(x,A){if(!this.listeners[x])return!1;var S=this.listeners[x].indexOf(A);return this.listeners[x].splice(S,1),S>-1},g.prototype.trigger=function(x){var A=this.listeners[x];if(!!A)if(arguments.length===2)for(var S=A.length,b=0;b<S;++b)A[b].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),D=A.length,R=0;R<D;++R)A[R].apply(this,C)},g.prototype.dispose=function(){this.listeners={}},g.prototype.pipe=function(x){this.on("data",function(A){x.push(A)})},g}(),d=function(g){s(E,g);function E(){n(this,E);var x=o(this,g.call(this,c));return x.jobs=[],x.delay=1,x.timeout_=null,x}return E.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},E.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},E}(c),f=function(E){return E<<24|(E&65280)<<8|(E&16711680)>>8|E>>>24},T=function(E,x,A){var S=new Int32Array(E.buffer,E.byteOffset,E.byteLength>>2),b=new h(Array.prototype.slice.call(x)),C=new Uint8Array(E.byteLength),D=new Int32Array(C.buffer),R=void 0,P=void 0,N=void 0,j=void 0,O=void 0,I=void 0,F=void 0,H=void 0,K=void 0;for(R=A[0],P=A[1],N=A[2],j=A[3],K=0;K<S.length;K+=4)O=f(S[K]),I=f(S[K+1]),F=f(S[K+2]),H=f(S[K+3]),b.decrypt(O,I,F,H,D,K),D[K]=f(D[K]^R),D[K+1]=f(D[K+1]^P),D[K+2]=f(D[K+2]^N),D[K+3]=f(D[K+3]^j),R=O,P=I,N=F,j=H;return C},p=function(){function g(E,x,A,S){n(this,g);var b=g.STEP,C=new Int32Array(E.buffer),D=new Uint8Array(E.byteLength),R=0;for(this.asyncStream_=new d,this.asyncStream_.push(this.decryptChunk_(C.subarray(R,R+b),x,A,D)),R=b;R<C.length;R+=b)A=new Uint32Array([f(C[R-4]),f(C[R-3]),f(C[R-2]),f(C[R-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(R,R+b),x,A,D));this.asyncStream_.push(function(){S(null,r(D))})}return g.prototype.decryptChunk_=function(x,A,S,b){return function(){var C=T(x,A,S);b.set(C,x.byteOffset)}},a(g,null,[{key:"STEP",get:function(){return 32e3}}]),g}(),m=function(E){var x={};return Object.keys(E).forEach(function(A){var S=E[A];ArrayBuffer.isView(S)?x[A]={bytes:S.buffer,byteOffset:S.byteOffset,byteLength:S.byteLength}:x[A]=S}),x},y=function(E){E.onmessage=function(x){var A=x.data,S=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),b=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(S,b,C,function(D,R){E.postMessage(m({source:A.source,decrypted:R}),[R.buffer])})}},v=new y(i);return v})()}),g2=function(t){var i=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Jf=function(t,i){t.abort(),t.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},Rv=function(t,i){i.activePlaylistLoader=t,t.load()},v2=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Jf(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),Rv(l.playlistLoader,s)}}},m2=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Jf(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){Rv(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),Rv(l.playlistLoader,s)}}},Qf={AUDIO:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t],a=i.blacklistCurrentPlaylist;Jf(r,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(c){return c.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}re.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var h in n.tracks)n.tracks[h].enabled=n.tracks[h]===u;n.onTrackChanged()}},SUBTITLES:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t];re.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Jf(r,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},pS={AUDIO:function(t,i,r){if(!!i){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Qf[t](t,r))}},SUBTITLES:function(t,i,r){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t],o=r.mediaTypes[t];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Qf[t](t,r))}},y2={AUDIO:function(t,i){var r=i.hls,n=i.sourceType,a=i.segmentLoaders[t],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[t],u=l.groups,h=l.tracks,c=i.masterPlaylistLoader;(!o[t]||Object.keys(o[t]).length===0)&&(o[t]={main:{default:{default:!0}}});for(var d in o[t]){u[d]||(u[d]=[]);for(var f in o[t][d]){var T=o[t][d][f],p=void 0;if(T.resolvedUri?p=new Wf(T.resolvedUri,r,s):T.playlists&&n==="dash"?p=new Av(T.playlists[0],r,s,c):p=null,T=re.mergeOptions({id:f,playlistLoader:p},T),pS[t](t,T.playlistLoader,i),u[d].push(T),typeof h[f]>"u"){var m=new re.AudioTrack({id:f,kind:g2(T),enabled:!1,language:T.language,default:T.default,label:f});h[f]=m}}}a.on("error",Qf[t](t,i))},SUBTITLES:function(t,i){var r=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[t],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[t],h=u.groups,c=u.tracks,d=i.masterPlaylistLoader;for(var f in l[t]){h[f]||(h[f]=[]);for(var T in l[t][f])if(!l[t][f][T].forced){var p=l[t][f][T],m=void 0;if(a==="hls"?m=new Wf(p.resolvedUri,n,o):a==="dash"&&(m=new Av(p.playlists[0],n,o,d)),p=re.mergeOptions({id:T,playlistLoader:m},p),pS[t](t,p.playlistLoader,i),h[f].push(p),typeof c[T]>"u"){var y=r.addRemoteTextTrack({id:T,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:T},!1).track;c[T]=y}}}s.on("error",Qf[t](t,i))},"CLOSED-CAPTIONS":function(t,i){var r=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[t],s=a.groups,o=a.tracks;for(var l in n[t]){s[l]||(s[l]=[]);for(var u in n[t][l]){var h=n[t][l][u];if(!!h.instreamId.match(/CC\d/)&&(s[l].push(re.mergeOptions({id:u},h)),typeof o[u]>"u")){var c=r.addRemoteTextTrack({id:h.instreamId,kind:"captions",default:h.default&&h.autoselect,language:h.language,label:u},!1).track;o[u]=c}}}}},_2=function(t,i){return function(r){var n=i.masterPlaylistLoader,a=i.mediaTypes[t].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[t]&&(o=a[s.attributes[t]]),o=o||a.main,typeof r>"u"?o:r===null?null:o.filter(function(l){return l.id===r.id})[0]||null}},b2={AUDIO:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].enabled)return r[n];return null}},SUBTITLES:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].mode==="showing")return r[n];return null}}},T2=function(t){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(h){y2[h](h,t)});var i=t.mediaTypes,r=t.masterPlaylistLoader,n=t.tech,a=t.hls;["AUDIO","SUBTITLES"].forEach(function(h){i[h].activeGroup=_2(h,t),i[h].activeTrack=b2[h](h,t),i[h].onGroupChanged=v2(h,t),i[h].onTrackChanged=m2(h,t)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(h){return h.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),r.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(h){return i[h].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},S2=function(){var t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){t[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:zl,activeTrack:zl,onGroupChanged:zl,onTrackChanged:zl}}),t},E2=60*2,qo=void 0,x2=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],w2=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},A2=function(e){no(t,e);function t(i){Ia(this,t);var r=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,h=i.useCueTags,c=i.blacklistDuration,d=i.enableLowInitialPlaylist,f=i.sourceType,T=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");qo=u,r.withCredentials=s,r.tech_=o,r.hls_=o.hls,r.seekTo_=T,r.sourceType_=f,r.useCueTags_=h,r.blacklistDuration=c,r.enableLowInitialPlaylist=d,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},r.mediaTypes_=S2(),r.mediaSource=new re.MediaSource,r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_.bind(r)),r.seekable_=re.createTimeRanges(),r.hasPlayed_=function(){return!1},r.syncController_=new h2(i),r.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new p2,r.inbandTextTracks_={};var m={hls:r.hls_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.mediaSource.duration},hasPlayed:function(){return r.hasPlayed_()},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:p};return r.masterPlaylistLoader_=r.sourceType_==="dash"?new Av(n,r.hls_,r.requestOptions_):new Wf(n,r.hls_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new kv(re.mergeOptions(m,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),i),r.audioSegmentLoader_=new kv(re.mergeOptions(m,{loaderType:"audio"}),i),r.subtitleSegmentLoader_=new l2(re.mergeOptions(m,{loaderType:"vtt"}),i),r.setupSegmentLoaderListeners_(),x2.forEach(function(y){r[y+"_"]=w2.bind(r,y)}),r.logger_=hd("MPC"),r.masterPlaylistLoader_.load(),r}return Za(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var r=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;yv(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,n.endList&&r.tech_.preload()!=="none"&&(r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load()),T2({sourceType:r.sourceType_,segmentLoaders:{AUDIO:r.audioSegmentLoader_,SUBTITLES:r.subtitleSegmentLoader_,main:r.mainSegmentLoader_},tech:r.tech_,requestOptions:r.requestOptions_,masterPlaylistLoader:r.masterPlaylistLoader_,hls:r.hls_,master:r.master(),mediaTypes:r.mediaTypes_,blacklistCurrentPlaylist:r.blacklistCurrentPlaylist.bind(r)}),r.triggerPresenceUsage_(r.master(),n);try{r.setupSourceBuffers_()}catch(s){return re.log.warn("Failed to create SourceBuffers",s),r.mediaSource.endOfStream("decode")}r.setupFirstPlay(),!r.mediaTypes_.AUDIO.activePlaylistLoader||r.mediaTypes_.AUDIO.activePlaylistLoader.media()?r.trigger("selectedinitialmedia"):r.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){r.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=r.masterPlaylistLoader_.media();if(!n){r.excludeUnsupportedVariants_();var a=void 0;r.enableLowInitialPlaylist&&(a=r.selectInitialPlaylist()),a||(a=r.selectPlaylist()),r.initialMedia_=a,r.masterPlaylistLoader_.media(r.initialMedia_);return}if(r.useCueTags_&&r.updateAdCues_(n),r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.updateDuration(),r.tech_.paused()||(r.mainSegmentLoader_.load(),r.audioSegmentLoader_&&r.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=r.seekable();u.length!==0&&r.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(r.duration()!==1/0){var o=function l(){r.duration()===1/0?s():r.tech_.one("durationchange",l)};r.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){r.mainSegmentLoader_.abort(),r.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;yv(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load(),r.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=r.masterPlaylistLoader_.media(),a=r.stuckAtPlaylistEnd_(n);a&&(r.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),r.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(r,n){var a=r.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var h=a.AUDIO[l][u];h.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),qo.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),qo.Playlist.isFmp4(n)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var r=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=r.selectPlaylist(),a=r.masterPlaylistLoader_.media(),s=r.tech_.buffered(),o=s.length?s.end(s.length-1)-r.tech_.currentTime():0,l=r.bufferLowWaterLine();(!a.endList||r.duration()<va.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&r.masterPlaylistLoader_.media(n),r.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){r.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){r.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){r.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){r.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},E2)}),this.mainSegmentLoader_.on("reseteverything",function(){r.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){r.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){r.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var r=this.selectPlaylist();r!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(r),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var r=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){re.browser.IE_VERSION||re.browser.IS_EDGE?r.tech_.setCurrentTime(r.tech_.currentTime()+.04):r.tech_.setCurrentTime(r.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var r=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<r.start(0))return this.seekTo_(r.end(r.length-1))}}},{key:"setupFirstPlay",value:function(){var r=this,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(re.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){r.trigger("firstplay"),r.seekTo_(a.end(0)),r.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(n){return re.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var r=this.tech_.play();typeof r<"u"&&typeof r.then=="function"&&r.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var r=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?r=r&&this.audioSegmentLoader_.ended_:r=this.audioSegmentLoader_.ended_),!!r){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){re.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(r){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(r,this.mediaSource.duration);if(a===null)return!1;var s=qo.Playlist.playlistEnd(r,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=ao;var u=l.end(l.length-1);return u-o<=ao&&s-u<=ao}},{key:"blacklistCurrentPlaylist",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=r.playlist||this.masterPlaylistLoader_.media(),n=n||r.blacklistDuration||this.blacklistDuration,!a){this.error=r;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Yf).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(re.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(re.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),re.log.warn("Problem encountered with the current HLS playlist."+(r.message?" "+r.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(r){var n=HT(this.tech_.buffered(),r);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return r;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:qo.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var r=void 0,n=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(r=qo.Playlist.seekable(a,s),r.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=qo.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>r.end(0)||r.start(0)>n.end(0)?this.seekable_=r:this.seekable_=re.createTimeRanges([[n.start(0)>r.start(0)?n.start(0):r.start(0),n.end(0)<r.end(0)?n.end(0):r.end(0)]]):this.seekable_=r,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+bv(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var r=this,n=this.mediaSource.duration,a=qo.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){r.logger_("Setting duration from "+r.mediaSource.duration+" => "+a);try{r.mediaSource.duration=a}catch(u){re.log.warn("Failed to set media source duration",u)}r.tech_.trigger("durationchange"),r.mediaSource.removeEventListener("sourceopen",l)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),n!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var r=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=r.mediaTypes_[n].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var r=this.masterPlaylistLoader_.media(),n=void 0;if(!(!r||this.mediaSource.readyState!=="open")){if(n=RP(this.masterPlaylistLoader_.master,r),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+r.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(r)}}},{key:"configureLoaderMimeTypes_",value:function(r){var n=r.length>1&&r[0].indexOf(",")===-1&&r[0]!==r[1]?new re.EventTarget:null;this.mainSegmentLoader_.mimeType(r[0],n),r[1]&&this.audioSegmentLoader_.mimeType(r[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(r){r.attributes.CODECS&&Be.MediaSource&&Be.MediaSource.isTypeSupported&&!Be.MediaSource.isTypeSupported('video/mp4; codecs="'+AP(r.attributes.CODECS)+'"')&&(r.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(r){var n=2,a=null,s=void 0;r.attributes.CODECS&&(s=dd(r.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=dd(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(r){var n=0,a=this.seekable();a.length&&(n=a.start(0)),d2(r,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var r=this.tech_.currentTime(),n=va.GOAL_BUFFER_LENGTH,a=va.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,va.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+r*a,s)}},{key:"bufferLowWaterLine",value:function(){var r=this.tech_.currentTime(),n=va.BUFFER_LOW_WATER_LINE,a=va.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,va.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+r*a,s)}}]),t}(re.EventTarget),C2=function(t,i,r){return function(n){var a=t.master.playlists[i],s=mv(a),o=Yf(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(r(),n?t.trigger("renditionenabled"):t.trigger("renditiondisabled")),n)}},D2=function e(t,i,r){Ia(this,e);var n=t.masterPlaylistController_,a=t.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=r,this.enabled=C2(t.playlists,i.uri,o)},k2=function(t){var i=t.playlists;t.representations=function(){return i.master.playlists.filter(function(r){return!mv(r)}).map(function(r,n){return new D2(t,r,r.uri)})}},gS=["seeking","seeked","pause","playing","error"],R2=function(){function e(t){var i=this;Ia(this,e),this.tech_=t.tech,this.seekable=t.seekable,this.seekTo=t.seekTo,this.allowSeeksWithinUnsafeLiveWindow=t.allowSeeksWithinUnsafeLiveWindow,this.media=t.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=hd("PlaybackWatcher"),this.logger_("initialize");var r=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(gS,a),this.tech_.on("canplay",r),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(gS,a),i.tech_.off("canplay",r),i.checkCurrentTimeTimeout_&&Be.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Za(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&Be.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=Be.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),r=this.tech_.buffered();if(this.lastRecordedTime===i&&(!r.length||i+ao>=r.end(r.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var r=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(r,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=r.end(r.length-1);s=o}if(this.beforeSeekableWindow_(r,n)){var l=r.start(0);s=l+ao}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+bv(r)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),r=this.tech_.buffered(),n=HT(r,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+n.start(0)+" -> "+n.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),r=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,r)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+r+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=GT(a,r);if(this.videoUnderflow_(s,a,r))return this.cancelTimer_(),this.seekTo(r),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-r;return this.logger_("Stopped at "+r+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,r),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,r,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+ao,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),r>s}},{key:"beforeSeekableWindow_",value:function(i,r){return!!(i.length&&i.start(0)>0&&r<i.start(0)-ao)}},{key:"videoUnderflow_",value:function(i,r,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(r,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var r=this.tech_.buffered(),n=this.tech_.currentTime(),a=GT(r,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+zf),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,r){for(var n=mP(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(r-s<4&&r-s>2)return{start:s,end:o}}return null}}]),e}(),P2={errorInterval:30,getSource:function(t){var i=this.tech({IWillNotUseThisInPlugins:!0}),r=i.currentSource_;return t(r)}},O2=function e(t,i){var r=0,n=0,a=re.mergeOptions(P2,i);t.ready(function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&t.currentTime(n)},o=function(d){d!=null&&(n=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),t.src(d),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},l=function(){if(Date.now()-r<a.errorInterval*1e3){t.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){re.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return r=Date.now(),a.getSource.call(t,o)},u=function c(){t.off("loadedmetadata",s),t.off("error",l),t.off("dispose",c)},h=function(d){u(),e(t,d)};t.on("error",l),t.on("dispose",u),t.reloadSourceOnError=h},vS=function(t){O2(this,t)},L2="1.10.6";re.use("*",function(e){return{setSource:function(i,r){r(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var oa={PlaylistLoader:Wf,Playlist:sa,Decrypter:fk,AsyncStream:U_,decrypt:B_,utils:uP,STANDARD_PLAYLIST_SELECTOR:ZP,INITIAL_PLAYLIST_SELECTOR:t2,comparePlaylistBandwidth:Dv,comparePlaylistResolution:JP,xhr:NT()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(oa,e,{get:function(){return re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),va[e]},set:function(i){if(re.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){re.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}va[e]=i}})});var mS="videojs-vhs",yS=function(t){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(t))return"hls";var r=/^application\/dash\+xml/i;return r.test(t)?"dash":null},_S=function(t,i){for(var r=i.media(),n=-1,a=0;a<t.length;a++)if(t[a].id===r.uri){n=a;break}t.selectedIndex_=n,t.trigger({selectedIndex:n,type:"change"})},I2=function(t,i){i.representations().forEach(function(r){t.addQualityLevel(r)}),_S(t,i.playlists)};oa.canPlaySource=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var M2=function(t,i,r){if(!t)return t;var n={};for(var a in t)n[a]={audioContentType:'audio/mp4; codecs="'+r.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof t[a]=="string"&&(n[a].url=t[a]);return re.mergeOptions(t,n)},N2=function(t){if(t.options_.sourceType==="dash"){var i=re.players[t.tech_.options_.playerId];if(i.eme){var r=M2(t.source_.keySystems,t.playlists.media(),t.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());r&&(i.currentSource().keySystems=r,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},bS=function(){if(!window.localStorage)return null;var t=window.localStorage.getItem(mS);if(!t)return null;try{return JSON.parse(t)}catch{return null}},F2=function(t){if(!window.localStorage)return!1;var i=bS();i=i?re.mergeOptions(i,t):t;try{window.localStorage.setItem(mS,JSON.stringify(i))}catch{return!1}return i};oa.supportsNativeHls=function(){var e=Mt.createElement("video");if(!re.getTech("Html5").isSupported())return!1;var t=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return t.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),oa.supportsNativeDash=function(){return re.getTech("Html5").isSupported()?/maybe|probably/i.test(Mt.createElement("video").canPlayType("application/dash+xml")):!1}(),oa.supportsTypeNatively=function(e){return e==="hls"?oa.supportsNativeHls:e==="dash"?oa.supportsNativeDash:!1},oa.isSupported=function(){return re.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var U2=re.getComponent("Component"),TS=function(e){no(t,e);function t(i,r,n){Ia(this,t);var a=Es(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r,n.hls));if(r.options_&&r.options_.playerId){var s=re(r.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return re.log.warn("player.hls is deprecated. Use player.tech().hls instead."),r.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=r,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(r.featuresNativeVideoTracks||r.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(Mt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var l=Mt.fullscreenElement||Mt.webkitFullscreenElement||Mt.mozFullScreenElement||Mt.msFullscreenElement;l&&l.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return Za(t,[{key:"setOptions_",value:function(){var r=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var n=bS();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=va.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===va.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof r.source_[a]<"u"&&(r.options_[a]=r.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(r,n){var a=this;!r||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=oa,this.options_.sourceType=yS(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new A2(this.options_),this.playbackWatcher_=new R2(re.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=re.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):oa.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=oa.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){re.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return VT(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return VT(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&F2({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){k2(a),N2(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(re.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var r=this,n=re.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){I2(r.qualityLevels_,r)}),this.playlists.on("mediachange",function(){_S(r.qualityLevels_,r.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(r){this.masterPlaylistController_.setCurrentTime(r)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,UR(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(r,n){return gP({playlist:this.masterPlaylistController_.media(),time:r,callback:n})}},{key:"seekToProgramTime",value:function(r,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return vP({programTime:r,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),t}(U2),Pv={name:"videojs-http-streaming",VERSION:L2,canHandleSource:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=re.mergeOptions(re.options,i);return Pv.canPlayType(t.type,r)},handleSource:function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=re.mergeOptions(re.options,r);return i.hls=new TS(t,i,n),i.hls.xhr=NT(),i.hls.src(t.src,t.type),i.hls},canPlayType:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=re.mergeOptions(re.options,i),n=r.hls.overrideNative,a=yS(t),s=a&&(!oa.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof re.MediaSource>"u"||typeof re.URL>"u")&&(re.MediaSource=fd,re.URL=iS),fd.supportsNativeMediaSources()&&re.getTech("Html5").registerSourceHandler(Pv,0),re.HlsHandler=TS,re.HlsSourceHandler=Pv,re.Hls=oa,re.use||re.registerComponent("Hls",oa),re.options.hls=re.options.hls||{},re.registerPlugin?re.registerPlugin("reloadSourceOnError",vS):re.plugin("reloadSourceOnError",vS);const B2=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"})),SS={name:"stream-engine-player",version:"0.0.42",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}};var _n=[];for(let e=0;e<256;++e)_n.push((e+256).toString(16).slice(1));function j2(e,t=0){return(_n[e[t+0]]+_n[e[t+1]]+_n[e[t+2]]+_n[e[t+3]]+"-"+_n[e[t+4]]+_n[e[t+5]]+"-"+_n[e[t+6]]+_n[e[t+7]]+"-"+_n[e[t+8]]+_n[e[t+9]]+"-"+_n[e[t+10]]+_n[e[t+11]]+_n[e[t+12]]+_n[e[t+13]]+_n[e[t+14]]+_n[e[t+15]]).toLowerCase()}var Ov,$2=new Uint8Array(16);function H2(){if(!Ov){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ov=crypto.getRandomValues.bind(crypto)}return Ov($2)}var G2=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ES={randomUUID:G2};function V2(e,t,i){var n,a,s;if(ES.randomUUID&&!t&&!e)return ES.randomUUID();e=e||{};let r=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:H2();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(i=i||0,i<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[i+o]=r[o];return t}return j2(r)}var q2=V2,xS="000000",wS=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return xS.slice(e.length)+e},Xl=function(){return q2()},W2=function(){return(xS+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Lv=e=>{if(!e)return["localhost","localhost"];try{let t=new URL(e).hostname,i=t.split("."),r=i.length>=2?i.slice(-2).join("."):t;return[t,r]}catch{}return["localhost","localhost"]},xs=e=>Lv(e)[0],Iv=e=>Lv(e)[1],Y2=e=>{var t,i;if(e&&e.nodeName)return(t=e.uniqueId)!=null?t:e.uniqueId=wS();try{let r=document.querySelector(e);return r&&!r.uniqueId&&(r.uniqueId=e),(i=r==null?void 0:r.uniqueId)!=null?i:e}catch{}return e},K2=e=>{var r;let t=null;e&&e.nodeName!==void 0?(t=e,e=Y2(t)):t=document.querySelector(e);let i=((r=t==null?void 0:t.nodeName)==null?void 0:r.toLowerCase())||"";return[t,e,i]},AS=e=>{var i,r;let t=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=W2()),e.elementId;try{t=document.querySelector(e)}catch{}return t&&!t.elementId&&(t.elementId=e),(r=t==null?void 0:t.elementId)!=null?r:e};function z2(...e){return e.reduce((t,i)=>{for(let[r,n]of Object.entries(i))n!==void 0&&(t[r]=n);return t},{})}function Zf(e,t,i=1){var r;e[t]=((r=e[t])!=null?r:0)+i}function X2(e,t){let{beaconDomain:i}=t;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function CS(){var t,i;let e=(i=(t=navigator.doNotTrack)!=null?t:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var J2=class{constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(i=>{i(t)})}},Wo={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},eh={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.navigationStart:null}};function Q2(e){if(!e)return{};let t=eh.getNavigationStartTime(),{loading:i,trequest:r,tfirst:n,tload:a,total:s}=e,o=i?i.start:r,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(t+o),responseStart:Math.round(t+l),responseEnd:Math.round(t+u)}}var Z2=()=>{var t,i,r;let e=navigator;return(r=(i=(t=e==null?void 0:e.connection)!=null?t:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:r.type},eO=()=>{switch(Z2()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},tO=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function rO(e){let t={},i=new Set(tO.map(r=>r.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(r=>{let[n,...a]=r.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(t[n]=s)}),t)}var th=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return rO(e.getAllResponseHeaders())},iO={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:Lv,fetchDomain:Iv,fetchHost:xs,generateIdToken:wS,buildUUID:Xl,now:Wo.now};function nO(e){let t=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,r=window==null?void 0:window.Worker;if(!t||!i||!r||!e)return null;let n=new i([e]);return new r(t.createObjectURL(n))}var aO=`
|
105
105
|
let pulseInterval = null;
|
106
106
|
let throbInterval = null
|
107
107
|
|