import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var ZQ="Full MP4 box must have flags defined",$Q="clpp.smooth.SmoothMP4Processor",aR="codecPrivateData",bR=function(a,b){const c=Math.floor(b/Math.pow(2,32));b-=c*Math.pow(2,32);_.O(a,c);_.O(a,b)},cR=function(a,b){try{a.f.setUint8(a.a,b),a.a+=1}catch(c){_.Wl()}},dR=function(a,b){cR(a,b>>16&255);cR(a,b>>8&255);cR(a,b&255)},eR=function(a,b){try{a.f.setUint16(a.a,b,a.h),a.a+=2}catch(c){_.Wl()}},fR=function(a,b){try{a.f.setInt32(a.a,b,a.h),a.a+=4}catch(c){_.Wl()}},gR=function(a,b){try{a.f.setInt16(a.a,
b,a.h),a.a+=2}catch(c){_.Wl()}},hR=function(a,b){if(void 0!==b){var c=new Uint8Array(b);const d=Math.min(a.length,b);let e=0;for(;e<d;++e)c[e]=a.charCodeAt(e);for(;e<b;e++)c[e]=0;return c}b=new Uint8Array(a.length);for(c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b},iR=function(a){const b=a.split("/");return b[b.length-1].toLowerCase().match("manifest(\\(.+\\))?")?a:`${a}/Manifest`},jR=function(a,b,c,d){c=b.Vf[c];b=b.Ni;a=a.replace("Manifest","");b=b.replace("{bitrate}",String(d.bitrate)).replace("{Bitrate}",
String(d.bitrate)).replace("{start time}",String(c.t)).replace("{start_time}",String(c.t));return _.pC([a],[b])[0]},kR=function(a,b){if(a.type!==b.type)return!1;let c=[];a.type===_.w?c=["maxWidth","maxHeight","bitrate",aR,"fourCC"]:a.type===_.p&&(c=["bitrate",aR,"channels","bitsPerSample","samplingRate","fourCC"]);return _.eh(a,b,c,["id","segmentIndex"])},lR=function(a,b,c){const d=c.Nd.split("00000001");a={id:1,type:c.type,duration:a/b,timescale:b,ab:null,dc:null,width:NaN,height:NaN,ac:null,zd:NaN,
sampleSize:NaN,channelCount:NaN};switch(c.type){case _.w:a.ab=[_.Kl(d[1])];a.dc=[_.Kl(d[2])];a.width=c.maxWidth;a.height=c.maxHeight;break;case _.p:a.ac=_.Kl(c.Nd),a.sampleSize=c.ah||16,a.zd=c.zd,a.channelCount=c.Mf}return a},mR=function(a,b){return a.filter(c=>c.type===b)},nR=function(a,b){a=a.exec(b);return null==a||""===a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},uR=function(a,b,c){var d=null;if(oR.test(a)){{a=oR.exec(a);d=Number(a[1]);const e=
Number(a[2]);let f=Number(a[3]),g=Number(a[4]);g+=(Number(a[5])||0)/c.f;f+=g/c.frameRate;d=f+60*e+3600*d}}else pR.test(a)?d=nR(pR,a):qR.test(a)?d=nR(qR,a):rR.test(a)?(a=rR.exec(a),d=Number(a[1])/c.frameRate):sR.test(a)?(a=sR.exec(a),d=Number(a[1])/c.a):tR.test(a)&&(d=nR(tR,a));c=d;d=c+b;b=Math.floor(d/3600);c=Math.floor((d-3600*b)/60);a=Math.floor(d-3600*b-60*c);d-=a;10>b&&(b="0"+b);10>c&&(c="0"+c);10>a&&(a="0"+a);0===d?d="000":d=Math.round(1E3*d);return b+":"+c+":"+a+"."+d},vR=function(a){let b=
0;for(let c=0;c<a.a.length;c++)b+=a.a[c].a();return new _.qm(b)},CR=function(a,b,c){a:{var d=[_.td,_.rd];for(e of d)if((d=c.Sd(e))&&d.keyId){var e=d.keyId;break a}_.C($Q,"Could not get default Key ID for DRM init data!");e=null}c=new wR("xxxx");a.type===_.w?c=new xR(a.width,a.height):c=new yR(a.channelCount,a.sampleSize,a.zd);a=new zR;a.f=1;a.h=8;a.l=e||"00000000000000000000000000000000";a=(new wR("schi")).append([a]);b=(new wR(_.Gf)).append([new AR(b),new BR(_.Tc,65536),a]);c.append([b]);return c},
fS=function(a,b){var c=b.Vd(),d=new DR(a.timescale,a.duration,a.id),e=(new ER).append([new FR(a.id)]),f=new GR(a.id,a.duration,a.timescale,a.width,a.height),g=new HR(a.timescale,a.duration);const h=new IR(a.type);var k=null,l=new JR;l.entries=[new KR];var m=new LR;switch(a.type){case _.w:k=new MR(a.ab,a.dc);c?(a=CR(a,"avc1",b),a.append([k]),m.entries=[a]):(a=(new NR(a.width,a.height)).append([k]),m.entries=[a]);k=new OR;break;case _.p:k=new PR(a.ac),c?(a=CR(a,"mp4a",b),a.append([k]),m.entries=[a]):
(a=(new QR(a.channelCount,a.sampleSize,a.zd)).append([k]),m.entries=[a]),k=new RR}m=(new SR).append([m,new TR,new UR,new VR,new WR]);l=(new YR).append([l]);l=(new ZR).append([k,l,m]);g=(new $R).append([g,h,l]);f=(new aS).append([f,g]);d=(new bS).append([d,f,e]);e=new cS("dash",0,["iso6","mp41","avc1"]);c&&(c=b.Sd(_.rd),b=b.Sd(_.td),c&&d.append([new dS("pssh",c.initData,8)]),b&&d.append([new dS("pssh",b.initData,8)]),c||b||_.C($Q,"Could not get PSSH init data!"));b=new eS([e,d]);return _.K(b.write())},
pS=function(a,b){let c,d,e,f,g,h;(new _.om).N("moof",_.hm).ea("mfhd",k=>{{const l=new gS;l.f=_.P(k.reader);c=l}}).N("traf",_.hm).ea("tfhd",k=>{{const l=k.reader.Na();if(null===k.flags)throw new _.I(_.G,3,3019,ZQ);const m=new hS(k.version||0,k.flags||0);m.f=_.P(k.reader);0<l-k.reader.getPosition()&&k.flags&1&&(m.h=_.cm(k.reader));0<l-k.reader.getPosition()&&k.flags&2&&(m.A=_.P(k.reader));0<l-k.reader.getPosition()&&k.flags&8&&(m.j=_.P(k.reader));0<l-k.reader.getPosition()&&k.flags&16&&(m.o=_.P(k.reader));
0<l-k.reader.getPosition()&&k.flags&32&&(m.l=_.P(k.reader));d=m}}).ea("trun",k=>{{var l=k.reader.Na();if(null===k.flags)throw new _.I(_.G,3,3019,ZQ);const m=new iS(k.version||0,k.flags||0);m.f=_.P(k.reader);0<l-k.reader.getPosition()&&k.flags&1&&(m.j=_.bm(k.reader));0<l-k.reader.getPosition()&&k.flags&4&&(m.l=_.P(k.reader));if(0<l-k.reader.getPosition())for(l=0;l<m.f;l++)k.flags&256&&m.o.push(_.P(k.reader)),k.flags&512&&m.sampleSize.push(_.P(k.reader)),k.flags&1024&&m.A.push(_.P(k.reader)),k.flags&
2048&&(0===k.version?m.h.push(_.P(k.reader)):m.h.push(_.bm(k.reader)));e=m}}).ea("sdtp",k=>{{const l=_.em(k.reader,k.reader.Na());f=new jS("sdtp",k.version||0,k.flags||0,l,0)}}).N("uuid",k=>{var l=_.em(k.reader,16);if(_.Ml(l,kS)){l=_.P(k.reader);k.version=l>>>24;k.flags=l&16777215;l=new lS(k.version,k.flags);l.h=_.P(k.reader);k.flags&1&&(l.j=_.$l(k.reader));for(let m=0;m<l.h;m++){const n={gg:_.em(k.reader,8),Yc:0,hf:[]};if(k.flags&2){n.Yc=_.am(k.reader);for(let r=0;r<n.Yc;r++){const u={If:0,Jf:0};
u.If=_.am(k.reader);u.Jf=_.P(k.reader);n.hf.push(u)}}l.f.push(n)}g=l}}).N(_.pe,k=>{{const l=new mS;0<k.reader.Na()?l.f=_.em(k.reader,k.reader.Na()):(_.C($Q,"mdat box is empty!"),l.f=new Uint8Array(0));h=l}}).parse(a,!1);if(!h)return null;a=(new nS).append([d,e]);f&&a.append([f]);b.Vd()&&g&&a.append([g]);b=(new oS).append([c,a]);return new eS([b,h])},uS=function(a,b,c,d){var e=d.Vd(),f=parseInt(c*b,10);b=a.data||new ArrayBuffer(0);var g=pS(b,d);if(null===g)return a.request.contentType===_.H?a.data:
g;d=g.get(_.pe);if(a.request.contentType===_.H){e=d.f.buffer;if(c){e=_.Xi(e);if((e=(new DOMParser).parseFromString(e,_.Tf))&&"tt"===e.documentElement.tagName.toLowerCase())var h=e.documentElement;if(h&&(d=new qS(h.getAttribute("ttp:frameRate"),h.getAttribute("ttp:subFrameRate"),h.getAttribute("ttp:frameRateMultiplier"),h.getAttribute("ttp:tickRate")),h=h.getElementsByTagName("body")[0])){f=h.getElementsByTagName("p");for(let u=0,v=f.length;u<v;u++){h=f[u];a=c;b=d;g=["begin",_.Rd];for(let y=0,A=g.length;y<
A;y++){b:{var k=h;var l=g[y],m=new RegExp("\\w+:"+l),n=0;if(k.hasAttribute(l)){k=k.getAttribute(l);break b}l=k.attributes;const D=l.length;for(;n<D;n++){var r=l[n].name;if(r=r.match(m)){k=k.getAttribute(r[0]);break b}}k=null}h.setAttribute(g[y],uR(k||"",a,b))}}}e=(new XMLSerializer).serializeToString(e);c=_.Yi(e).buffer}else c=e;return c}h=new oS;a=g.get("mfhd");b=new nS;k=g.get("tfhd");m=new rS(1,f);f=g.get("trun");n=g.get("sdtp");c=g.get("senc");k.f=1;k.flags&=16777214;k.flags|=131072;b.append([k,
m,f]);n&&b.append([n]);if(e){g=0;k=[];if(c.flags&2)for(k=[],m=0;m<c.h;m++)k.push(10+6*c.f[m].Yc);else g=8;b.append([c,new sS,new tS(g,k,c.h)])}h.append([a,b]);f.flags|=1;f.j=h.a()+8;d=new eS([h,d]);h=d.write();e&&(e=d.get("saio"),d=d.f,e.offset[0]=c.start+16,d.seek(e.start),e.write(d),h=d.buffer);return h},vS=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[b],keyIds:c,
periodId:null}},wS=function(a){return{initData:_.cC(_.kn(a)),initDataType:_.Tc,keyId:a,periodId:null}},xS=function(a,b,c){a=_.tn(a);c&&a.version!==c&&(a=_.eC(a,c));return{initData:_.cC(a),initDataType:_.Tc,keyId:b,periodId:null}},yS=function(a,b){return _.x(function*(){var c=_.mj(b);c.timeout=a.f.attemptParameters.timeout;c.maxAttempts=Math.max(a.f.attemptParameters.maxAttempts,b.length);c.baseDelay=a.f.attemptParameters.baseDelay;c.backoffFactor=a.f.attemptParameters.backoffFactor;c.fuzzFactor=a.f.attemptParameters.fuzzFactor;
c.type=1;c=yield a.D.networkingEngine.fetch(c).T;a.o=c.uri;return c})},GS=function(a,b){const c=_.on;let d=null;try{const hb=_.Xi(b);d=c.j(hb,_.qb)}catch(hb){}if(!d)throw a.g.error("Unable to parse manifest"),new _.I(_.G,4,4033,a.o);const e=+zS(a,d,"MajorVersion"),f=+zS(a,d,"MinorVersion"),g=+d.getAttribute("TimeScale")||1E7;let h=+zS(a,d,"Duration");const k="TRUE"===d.getAttribute("IsLive"),l=+d.getAttribute("LookAheadCount"),m=+d.getAttribute("DVRWindowLength")||Infinity,n=c.a(d,"Protection")[0];
if(!1===/^[2].[0-2]$/.test(""+e+"."+f))throw a.g.error("Smooth Streaming version must be 2.0, 2.1 or 2.2"),new _.I(_.G,4,4036,a.o);k?(AS(a,BS),a.B=typeof a.f.liveRefreshPeriod===_.t?1E3*a.f.liveRefreshPeriod:Math.min(1E3*a.I,1E4),h=Infinity):AS(a,CS);a.a={startTime:0,delay:0,duration:h/g,Ae:m/g,sd:0};if(n){{var r=a.f.playreadyVersion;const hb=_.on,ua=[],zb=hb.a(n,"ProtectionHeader")[0],Bc=_.Jl(hb.f(zb)||""),kc=_.tn(Bc).a;ua.push(vS(_.td,wS(kc),[kc]));ua.push(vS(_.rd,xS(Bc,kc,r),[kc]));var u=ua}a.w=
u}{const hb=[],ua=_.on.a(d,"StreamIndex");if(!ua.length)throw a.g.error("No streams found!"),new _.I(_.G,4,4034,a.o);for(let zb=0;zb<ua.length;zb++){{var v=a,y=ua[zb];const Bc=zS(v,y,"Type"),kc=+y.getAttribute("Chunks"),Uh=y.getAttribute("Subtype")||"",ue=y.getAttribute("Language")||_.dg,ve=_.Bi(ue),Vh=y.getAttribute("Name")||"",rf=+y.getAttribute(_.Qa),sg=+y.getAttribute(_.Pa),Es=zS(v,y,"Url"),Lm=+y.getAttribute("TimeScale")||null;{const fd=[],Dj=_.on.a(y,_.jb);for(let we=0;we<Dj.length;we++){{let gd,
Na,Wd;var A=v,D=Dj[we],E=Bc;const Ej=+D.getAttribute("Index"),tg=+zS(A,D,"Bitrate");let Cc=NaN,ug=NaN,Mm=NaN,Fs=NaN,FF=NaN,GF=NaN,HF=NaN;const IF=D.getAttribute("FourCC")||"";switch(E){case _.w:Cc=+zS(A,D,_.Pa);ug=+zS(A,D,_.Qa);break;case _.p:Fs=+D.getAttribute("Channels")||2,Mm=+zS(A,D,"SamplingRate"),GF=+zS(A,D,"AudioTag"),FF=+zS(A,D,"BitsPerSample"),HF=+zS(A,D,"PacketSize")}let Gs=String(D.getAttribute("CodecPrivateData"));if(E===_.p&&!Gs){{var X=Fs;const JF={96E3:0,88200:1,64E3:2,48E3:3,44100:4,
32E3:5,24E3:6,22050:7,16E3:8,12E3:9,11025:10,8E3:11,7350:12},Nm=JF[Mm];if("AACH"===IF){Na=new Uint8Array(4);const KF=JF[2*Mm];Na[0]=40|Nm>>1;Na[1]=Nm<<7|X<<3|KF>>1;Na[2]=KF<<7|8;Na[3]=0;gd=new Uint16Array(2);gd[0]=(Na[0]<<8)+Na[1];gd[1]=(Na[2]<<8)+Na[3];Wd=gd[0].toString(16)+gd[1].toString(16)}else Na=new Uint8Array(2),Na[0]=16|Nm>>1,Na[1]=Nm<<7|X<<3,gd=new Uint16Array(1),gd[0]=(Na[0]<<8)+Na[1],Wd=gd[0].toString(16);Gs=Wd.toUpperCase()}}var cd={id:A.V++,type:E,index:Ej,bitrate:tg,Nd:Gs,maxHeight:Cc,
maxWidth:ug,zd:Mm,Mf:Fs,Ti:GF,ah:FF,fj:HF,uh:IF,segmentIndex:null}}fd.push(cd)}var gc=fd}{const fd=[],Dj=_.on.a(y,"c");for(let we=0;we<Dj.length;we++){const gd=Dj[we];let Na=parseInt(gd.getAttribute("t"),10),Wd=parseInt(gd.getAttribute("d"),10),Ej=parseInt(gd.getAttribute("r"),10),tg=0;if(isNaN(Na)&&isNaN(Wd))throw v.g.error("Either one or both FragmentDuration and FragmentTime field MUST be present in StreamFragmentElement"),new _.I(_.G,4,4037,v.o);0===we&&isNaN(Na)&&(tg=Na=0);if(0<we){const Cc=
fd[fd.length-1];tg=Cc.n+1;Cc.d||(Cc.d=Na-Cc.t);Na||(Na=Cc.t+Cc.d);Wd||(Wd=Na-Cc.t)}fd.push({n:tg,d:Wd,t:Na});if(Ej){Ej--;for(let Cc=0;Cc<Ej;Cc++){const ug=fd[fd.length-1];tg=ug.n+1;Na=ug.t+ug.d;Wd=ug.d;fd.push({n:tg,d:Wd,t:Na})}}}v.F()||fd.length===kc||v.g.warn("Number of fragments ("+kc+") differs from number of chunks ("+fd.length+").");var Ob=fd}var Vd={type:Bc,Xi:kc,Di:Uh,language:ve,Sc:ue,name:Vh,maxWidth:rf,maxHeight:sg,Ni:Es,tracks:gc,Vf:Ob,timescale:Lm}}hb.push(Vd)}var Pb=hb}const hc={ej:e,
mg:f,timescale:g,duration:h,isLive:k,dj:l,Ae:m,Ge:!1,streams:Pb};if(a.j&&a.A)return DS(a,hc),Promise.resolve();a.H.clear();{const hb=hc.timescale,ua=hc.duration,zb=mR(hc.streams,_.p),Bc=mR(hc.streams,_.w),kc=mR(hc.streams,_.H),Uh=[];let ue=ES(a,ua,hb,zb),ve=ES(a,ua,hb,Bc);const Vh=ES(a,ua,hb,kc);ue.length||(ue=[null]);ve.length||(ve=[null]);for(let rf=0;rf<ve.length;rf++)for(let sg=0;sg<ue.length;sg++)Uh.push(FS(a,ve[rf],ue[sg]));var ic={id:"ID",configurationId:void 0,startTime:0,endTime:ua,variants:Uh,
textStreams:Vh,thumbStreams:[]}}{var Gb=hc.streams;let hb=a.a.startTime,ua=a.a.delay;const zb=a.J;let Bc=Math.min(a.a.duration||Infinity,zb);const kc=a.F(),Uh=a.a.Ae,ue=a.a.sd,ve=a.I,Vh=isFinite(a.G)?a.G:0;if(kc)Bc=Infinity,hb=Date.now()/1E3-ue,a.a.startTime=hb,ua=3*ve;else{const sg=isFinite(zb)?zb:a.a.duration;for(const Es of Gb)for(const Lm of Es.tracks)Lm.segmentIndex.offset(-Vh),_.UC(Lm.segmentIndex,sg)}const rf=a.f.timeline||{};rf.type=void 0;a.C=new _.rJ(rf,hb,ua,!kc,!0);a.C.f=Bc;_.hD(a.C,ve);
a.C.A=Uh;kc||a.C.offset(-Vh)}a.D.filterAllPeriods([ic]);a.j={presentationTimeline:a.C,periods:[ic],minBufferTime:0,cues:[]};Promise.resolve();a.L||(a.D.networkingEngine.Gc(a.M),a.L=!0);a.A=hc;return Promise.resolve()},HS=function(a,b){null!=a.B&&null!=b&&(a.l=window.setTimeout(a.Vb.bind(a),b))},zS=function(a,b,c){if(b=b.getAttribute(c))return b;a.g.error("required attribute not provided: "+c);throw new _.I(_.G,4,4038,a.o,c);},AS=function(a,b){const c=b===CS;a.j&&a.j.presentationTimeline&&_.cD(a.j.presentationTimeline,
c);c&&null!=a.l&&(window.clearTimeout(a.l),a.l=null,a.B=null);a.P=b},DS=function(a,b){for(let e=0;e<a.A.streams.length;e++){const f=b.streams[e];for(const g of a.A.streams[e].tracks){var c=f.tracks.find(h=>h.type===g.type&&h.bitrate===g.bitrate);if(c){kR(g,c)||a.g.warn("The current stream is updated with a stream that seems to have different base properties!");var d=IS(a,a.A.timescale,f,c);c=g.segmentIndex;_.tD(c,d);(d=a.a.Ae)&&_.uD(c,_.rD(c)-d).forEach(h=>{h.Ya().forEach(k=>{a.H.delete(k)})})}else a.g.warn(`Cannot find satisfying update for ${g.type} `+
`track with bitrate ${g.bitrate}. Skipping update.`)}}},IS=function(a,b,c,d){let e=0;const f=[],g=c.timescale||b;c.Vf.forEach((h,k)=>{const l=h.d/g;0===k?(h=h.t/g,a.G=Math.min(a.G,h)):h=f[k-1].endTime;const m=h+l,n=jR(a.o,c,k,d);a.I=Math.max(a.I,l);f.push(new _.sD(k,h,m,()=>[n],0,null,0,null,!0,g));a.H.set(n,h);e+=l});if(c.type===_.w||c.type===_.p)b=f[f.length-1],a.J=Math.min(a.J,e),0===a.a.sd?a.a.sd=b.endTime:a.a.sd=Math.min(a.a.sd,b.endTime);return f},ES=function(a,b,c,d){let e=[];for(let f=0;f<
d.length;f++){const g=d[f].tracks.map(h=>{{var k=d[f],l=IS(a,c,k,h);const X=new _.sJ(l);var m=null;k.type!==_.H&&(m=JS(a,b,c,k,h));h.segmentIndex=X;l=_.oJ++;var n=Promise.resolve.bind(Promise),r=X.f.bind(X),u=X.get.bind(X),v=X.h.bind(X),y=X.getDuration.bind(X),A=KS[k.type];var D="";switch(k.type){case _.w:D=h.Nd;var E=/00000001[0-9]7/.exec(D);D="avc1."+(E&&E[0]?D.substr(D.indexOf(E[0])+10,6):"42c00c");a.g.debug("VIDEO CODECS: ",D);break;case _.p:D=h.Nd,E=2,"AACH"===h.uh?E=5:D&&(E=(parseInt(D.substr(0,
2),16)&248)>>3),D="mp4a.40."+E,a.g.debug("AUDIO CODECS: ",D)}E=k.type===_.H?LS[k.Di]:void 0;h={id:l,originalId:null,ij:null,createSegmentIndex:n,findSegmentPosition:r,getSegmentReference:u,adjustSegmentDurations:v,getDuration:y,segmentIndex:X,segmentLookupStrategy:_.NB,initSegmentReference:m,mimeType:A,codecs:D,frameRate:void 0,bandwidth:h.bitrate,width:h.maxWidth||void 0,height:h.maxHeight||void 0,kind:E,encrypted:a.K(),keyId:null,language:k.language,originalLanguage:k.Sc,label:k.name,type:k.type,
primary:!1,trickModeVideo:null,emsgSchemeIdUris:null,roles:[],channelsCount:h.Mf||null,spatialAudio:!1,closedCaptions:null}}return h});e=e.concat(g)}return e},FS=function(a,b,c){const d=(c?c.bandwidth:0)+(b?b.bandwidth:0),e=c?c.language:_.dg;return c||b?{id:a.h++,language:e,primary:!1,audio:c,video:b,bandwidth:d,drmInfos:a.w,allowedByApplication:!0,allowedByKeySystem:!0}:null},JS=function(a,b,c,d,e){b=lR(b,d.timescale||c,e);c={isLive:a.F.bind(a),Vd:a.K.bind(a),Bh:()=>1,Sd:a.R.bind(a)};d=new Uint8Array(0);
try{d=fS(b,c)}catch(g){throw a.g.error("Failed to generate initialization segment."),new _.I(_.G,3,4035,g);}const f="data:text/plain;base64,"+_.Il(d);return new _.nJ(()=>[f],0,null,null,!0)},wR=class{constructor(a){this.type=a;this.size=this.start=0;this.parent=null;this.w=!1;this.entries=[];this.children=[]}append(a=[]){for(let b=0;b<a.length;b++)this.children.push(a[b]),a[b].parent=this;return this}get(a){if(this.type===a)return this;for(let b=0;b<this.children.length;b++){if(this.children[b].type===
a)return this.children[b];{const c=this.children[b].get(a);if(c)return c}}return null}a(){const a=Math.pow(2,32)-1;let b;b=4+this.type.length;"uuid"===this.type&&(b+=16);if(0<this.children.length)for(let c=0;c<this.children.length;c++)b+=this.children[c].a();this.size>a&&(b+=8);return b}write(a){var b=Math.pow(2,32)-1;this.start=a.getPosition();this.size=this.a();this.size>b?_.O(a,1):_.O(a,this.size);_.Xl(a,hR(this.type));this.size>b&&bR(a,this.size);"uuid"===this.type&&_.Xl(a,null);if(0<this.children.length&&
!this.w)for(b=0;b<this.children.length;b++)this.children[b].write(a),this.children[b].a(),a.getPosition()}},MS=class extends wR{constructor(a,b,c){super(a);this.version=b;this.flags=c}a(){return 4+super.a()}write(a){super.write(a);cR(a,this.version);dR(a,this.flags)}},dS=class extends wR{constructor(a,b,c){super(a);this.f=b;this.offset=c}a(){return this.f.byteLength+super.a()-this.offset}write(a){super.write(a);_.Xl(a,this.f,this.offset);a.getPosition()}},jS=class extends MS{constructor(a,b,c,d,e){super(a,
b,c);this.f=d;this.offset=e}a(){return this.f.byteLength+super.a()-this.offset}write(a){super.write(a);_.Xl(a,this.f,this.offset);a.getPosition()}},cS=class extends wR{constructor(a,b,c){super("ftyp");this.h=a;this.mg=b;this.f=c}a(){let a=this.h.length;a=a+4+this.f.join("").length;return a+super.a()}write(a){super.write(a);_.Xl(a,hR(this.h));_.O(a,this.mg);_.Xl(a,hR(this.f.join("")));a.getPosition()}},bS=class extends wR{constructor(){super(_.ye)}},aS=class extends wR{constructor(){super(_.ag)}},
DR=class extends MS{constructor(a,b,c){super("mvhd",1,0);this.timescale=a;this.duration=b;this.volume=256;this.h=c+1;this.f=[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]}a(){let a=0;a=1===this.version?a+28:a+16;a=a+44+this.f.length;return a+=super.a()}write(a){super.write(a);1===this.version?(bR(a,0),bR(a,0),_.O(a,this.timescale),bR(a,this.duration*this.timescale)):(_.O(a,0),_.O(a,0),_.O(a,this.timescale),_.O(a,this.duration*this.timescale));_.O(a,65536);eR(a,this.volume);
eR(a,0);_.O(a,0);_.O(a,0);for(let b=0;b<this.f.length;b++)cR(a,this.f[b]);_.O(a,0);_.O(a,0);_.O(a,0);_.O(a,0);_.O(a,0);_.O(a,0);_.O(a,this.h);a.getPosition()}},ER=class extends wR{constructor(){super("mvex")}},FR=class extends MS{constructor(a){super("trex",0,0);this.f=a}a(){return 20+super.a()}write(a){super.write(a);_.O(a,this.f);_.O(a,1);_.O(a,0);_.O(a,0);_.O(a,0);a.getPosition()}},GR=class extends MS{constructor(a,b,c,d,e){super("tkhd",1,7);this.h=a;this.duration=b;this.timescale=c;this.width=
d;this.height=e;this.volume=1;this.f=[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]}a(){let a=0;a=1===this.version?a+32:a+20;a=a+24+this.f.length;return a+super.a()}write(a){super.write(a);1===this.version?(bR(a,0),bR(a,0),_.O(a,this.h),_.O(a,0),bR(a,this.duration*this.timescale)):(_.O(a,0),_.O(a,0),_.O(a,this.h),_.O(a,0),_.O(a,this.duration*this.timescale));_.O(a,0);_.O(a,0);eR(a,0);eR(a,0);eR(a,this.volume);eR(a,0);for(let b=0;b<this.f.length;b++)cR(a,this.f[b]);eR(a,
this.width);eR(a,0);eR(a,this.height);eR(a,0);a.getPosition()}},HR=class extends MS{constructor(a,b){super("mdhd",1,0);this.timescale=a;this.duration=b;this.language=21956}a(){let a=0;a=1===this.version?a+28:a+16;return a+4+super.a()}write(a){super.write(a);1===this.version?(bR(a,0),bR(a,0),_.O(a,this.timescale),bR(a,this.duration*this.timescale)):(_.O(a,0),_.O(a,0),_.O(a,this.timescale),_.O(a,this.duration*this.timescale));eR(a,this.language);eR(a,0);a.getPosition()}},IR=class extends MS{constructor(a){super("hdlr",
0,0);this.f=a}a(){return 33+super.a()}write(a){super.write(a);_.O(a,0);this.f===_.w?_.Xl(a,hR("vide")):_.Xl(a,hR("soun"));_.O(a,0);_.O(a,0);_.O(a,0);this.f===_.w?_.Xl(a,hR("VideoHandler\x00")):_.Xl(a,hR("SoundHandler\x00"));a.getPosition()}},OR=class extends MS{constructor(){super("vmhd",0,1);this.f=new Uint8Array([0,0,0,0,0,0])}a(){return 2+this.f.byteLength+super.a()}write(a){super.write(a);eR(a,0);_.Xl(a,this.f);a.getPosition()}},NS=class extends wR{constructor(a){super(a);this.w=!0}a(){return 8+
super.a()}write(a){super.write(a);_.O(a,0);eR(a,0);eR(a,1)}},OS=class extends NS{constructor(a){super(a);this.height=this.width=0;this.depth=24}a(){return 70+super.a()}write(a){super.write(a);eR(a,0);eR(a,0);_.O(a,0);_.O(a,0);_.O(a,0);eR(a,this.width);eR(a,this.height);_.O(a,4718592);_.O(a,4718592);_.O(a,0);eR(a,1);cR(a,10);_.Xl(a,hR("AVC Coding",31));eR(a,this.depth);gR(a,-1)}},PS=class extends NS{constructor(a,b,c,d){super(a);this.channelCount=b;this.sampleSize=c;this.sampleRate=d}a(){return 20+
super.a()}write(a){super.write(a);_.O(a,0);_.O(a,0);eR(a,this.channelCount);eR(a,this.sampleSize);gR(a,0);eR(a,0);eR(a,this.sampleRate);eR(a,0)}},NR=class extends OS{constructor(a,b){super("avc1");this.width=a;this.height=b}write(a){super.write(a);for(let b=0;b<this.children.length;b++)this.children[b].write(a);a.getPosition()}},xR=class extends NR{constructor(a,b){super(a,b);this.type="encv"}},QR=class extends PS{constructor(a,b,c){super("mp4a",a,b,c)}write(a){super.write(a);for(let b=0;b<this.children.length;b++)this.children[b].write(a);
a.getPosition()}},yR=class extends QR{constructor(a,b,c){super(a,b,c);this.type="enca"}},MR=class extends wR{constructor(a,b){super("avcC");this.ab=a;this.dc=b;this.version=1;this.f=this.ab[0][1];this.h=this.ab[0][2];this.level=this.ab[0][3]}a(){let a=7;for(var b=0;b<this.ab.length;b++)a+=2,a+=this.ab[b].byteLength;for(b=0;b<this.ab.length;b++)a+=2,a+=this.dc[b].byteLength;return a+super.a()}write(a){super.write(a);cR(a,this.version);cR(a,this.f);cR(a,this.h);cR(a,this.level);cR(a,255);cR(a,224|this.ab.length);
for(var b=0;b<this.ab.length;b++)eR(a,this.ab[b].length),_.Xl(a,this.ab[b]);cR(a,this.dc.length);for(b=0;b<this.dc.length;b++)eR(a,this.dc[b].length),_.Xl(a,this.dc[b]);a.getPosition()}},PR=class extends MS{constructor(a){super("esds",0,0);this.ac=a}a(){return 22+(this.ac.byteLength+3)+super.a()}write(a){super.write(a);cR(a,3);cR(a,23+this.ac.byteLength);eR(a,1);cR(a,0);cR(a,4);cR(a,15+this.ac.byteLength);cR(a,64);cR(a,21);dR(a,0);_.O(a,0);_.O(a,0);cR(a,5);cR(a,this.ac.byteLength);_.Xl(a,this.ac);
_.Xl(a,new Uint8Array([6,1,2]));a.getPosition()}},KR=class extends MS{constructor(a=""){super("url ",0,1);this.location=a}a(){return this.location.length+super.a()}write(a){super.write(a);0<this.location.length&&_.Xl(a,hR(this.location));a.getPosition()}},JR=class extends MS{constructor(){super("dref",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.O(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);
a.getPosition()}},SR=class extends wR{constructor(){super(_.Mf)}},LR=class extends MS{constructor(){super(_.Of,0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.O(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},TR=class extends MS{constructor(){super("stts",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);
_.O(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},UR=class extends MS{constructor(){super("stsc",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();return a+super.a()}write(a){super.write(a);_.O(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},WR=class extends MS{constructor(){super("stco",0,0)}a(){let a=4;for(let b=0;b<this.entries.length;b++)a+=this.entries[b].a();
return a+super.a()}write(a){super.write(a);_.O(a,this.entries.length);for(let b=0;b<this.entries.length;b++)this.entries[b].write(a);a.getPosition()}},VR=class extends MS{constructor(){super("stsz",0,0)}a(){return 8+super.a()}write(a){super.write(a);_.O(a,0);_.O(a,0);a.getPosition()}},RR=class extends MS{constructor(){super("smhd",0,0)}a(){return 4+super.a()}write(a){super.write(a);gR(a,0);eR(a,0);a.getPosition()}},YR=class extends wR{constructor(){super("dinf")}},ZR=class extends wR{constructor(){super(_.xe)}},
$R=class extends wR{constructor(){super(_.qe)}},rS=class extends MS{constructor(a,b){super("tfdt",a,0);this.baseMediaDecodeTime=b}a(){let a=0;a=1===this.version?a+8:a+4;return a+super.a()}write(a){super.write(a);1===this.version?bR(a,this.baseMediaDecodeTime):_.O(a,this.baseMediaDecodeTime);a.getPosition()}},gS=class extends MS{constructor(){super("mfhd",0,0);this.f=0}a(){return 4+super.a()}write(a){super.write(a);_.O(a,this.f);a.getPosition()}},iS=class extends MS{constructor(a,b){super("trun",a,
b);this.l=this.j=this.f=0;this.o=[];this.sampleSize=[];this.A=[];this.h=[]}a(){let a=4;this.flags&QS&&(a+=4);this.flags&RS&&(a+=4);for(let b=0;b<this.f;b++)this.flags&SS&&(a+=4),this.flags&TS&&(a+=4),this.flags&US&&(a+=4),this.flags&VS&&(a+=4);return a+super.a()}write(a){super.write(a);_.O(a,this.f);this.flags&QS&&(a.getPosition(),fR(a,this.j));this.flags&RS&&_.O(a,this.l);for(let b=0;b<this.f;b++)this.flags&SS&&_.O(a,this.o[b]),this.flags&TS&&_.O(a,this.sampleSize[b]),this.flags&US&&_.O(a,this.A[b]),
this.flags&VS&&(0===this.version?_.O(a,this.h[b]):fR(a,this.h[b]));a.getPosition()}},QS=1,RS=4,SS=256,TS=512,US=1024,VS=2048,hS=class extends MS{constructor(a,b){super("tfhd",a,b);this.f=255;this.l=this.o=this.j=this.A=this.h=0}a(){let a=4;this.flags&WS&&(a+=8);this.flags&XS&&(a+=4);this.flags&YS&&(a+=4);this.flags&ZS&&(a+=4);this.flags&$S&&(a+=4);return a+super.a()}write(a){super.write(a);_.O(a,this.f);this.flags&WS&&bR(a,this.h);this.flags&XS&&_.O(a,this.A);this.flags&YS&&_.O(a,this.j);this.flags&
ZS&&_.O(a,this.o);this.flags&$S&&_.O(a,this.l);a.getPosition()}},WS=1,XS=2,YS=8,ZS=16,$S=32,nS=class extends wR{constructor(){super("traf")}},oS=class extends wR{constructor(){super("moof")}},mS=class extends wR{constructor(){super(_.pe);this.f=new Uint8Array(0)}a(){return this.f.byteLength+super.a()}write(a){super.write(a);0<this.f.byteLength&&_.Xl(a,this.f)}},zR=class extends MS{constructor(){super("tenc",0,0);this.f=1;this.h=8;this.l="";this.j=[]}a(){let a;a=20;1===this.f&&0===this.h&&(a=a+1+this.j.length);
return a+super.a()}write(a){super.write(a);cR(a,0);0===this.version?cR(a,0):cR(a,0);cR(a,this.f);cR(a,this.h);_.Xl(a,_.Kl(this.l));if(1===this.f&&0===this.h){cR(a,0);for(let b=0;b<this.j.length;b++)cR(a,this.j[b])}a.getPosition()}},BR=class extends MS{constructor(a,b){super("schm",0,0);this.f=a;this.h=b;this.Xb=""}a(){let a=8;this.flags&1&&(a+=hR(this.Xb).byteLength);return a+super.a()}write(a){super.write(a);_.Xl(a,hR(this.f));_.O(a,this.h);this.flags&1&&_.Xl(a,hR(this.Xb));a.getPosition()}},AR=
class extends wR{constructor(a){super("frma");this.f=a}a(){return hR(this.f).byteLength+super.a()}write(a){super.write(a);_.Xl(a,hR(this.f));a.getPosition()}},sS=class extends MS{constructor(){super("saio",0,0);this.offset=[0]}a(){let a=0;this.flags&1&&(a+=8);a+=4;for(let b=0;1>b;b++)a=0===this.version?a+4:a+8;return a+super.a()}write(a){super.write(a);this.flags&1&&(_.O(a,0),_.O(a,0));_.O(a,1);for(let b=0;1>b;b++)0===this.version?_.O(a,this.offset[b]):bR(a,this.offset[b]);a.getPosition()}},tS=class extends MS{constructor(a,
b,c){super("saiz",0,0);this.f=a;this.j=b;this.h=c}a(){let a=0;this.flags&1&&(a+=8);a+=5;0===this.f&&(a+=this.j.length);return a+super.a()}write(a){super.write(a);this.flags&1&&(_.O(a,0),_.O(a,0));cR(a,this.f);_.O(a,this.h);if(0===this.f)for(let b=0;b<this.h;b++)cR(a,this.j[b]);a.getPosition()}},lS=class extends MS{constructor(a,b){super("senc",a,b);this.h=0;this.j=8;this.f=[]}a(){let a=4;this.flags&1&&(a+=1);for(let b=0;b<this.h;b++)if(a+=this.f[b].gg.byteLength,this.flags&2){a+=2;for(let c=0;c<this.f[b].Yc;c++)a+=
2,a+=4}return a+super.a()}write(a){super.write(a);_.O(a,this.h);this.flags&1&&cR(a,this.j);for(let b=0;b<this.h;b++)if(_.Xl(a,this.f[b].gg),this.flags&2){eR(a,this.f[b].Yc);for(let c=0;c<this.f[b].Yc;c++)eR(a,this.f[b].hf[c].If),_.O(a,this.f[b].hf[c].Jf)}a.getPosition()}};var qS=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0===this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=parseInt(a[1],10)/parseInt(a[2],10))}},oR=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,pR=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,qR=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,rR=/^(\d*\.?\d*)f$/,sR=/^(\d*\.?\d*)t$/,tR=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/;var eS=class{constructor(a){this.a=a;this.f=vR(this)}get(a){for(let b=0;b<this.a.length;b++){const c=this.a[b].get(a);if(c)return c}return null}write(){this.f=vR(this);for(let a=0;a<this.a.length;a++)this.a[a].write(this.f);return this.f.buffer}};var kS=new Uint8Array([162,57,79,82,90,155,79,20,162,68,108,66,124,100,141,244]);var aT=class{constructor(){this.A=this.j=this.f=this.D=null;this.h=1;this.V=0;this.o="";this.C=this.a=null;this.g=new _.S("clpp.smooth.SmoothParser");this.L=!1;this.l=this.B=null;this.P=CS;this.I=0;this.G=this.J=Infinity;this.w=[];this.M=this.S.bind(this);this.H=new Map}configure(a){this.f=a}start(a,b){this.D=b;a=[...new Set([a,iR(a)])];return yS(this,a).then(c=>GS(this,c.data).then(()=>{HS(this,this.B);return this.j}))}requestStop(){}stop(){this.D&&this.D.networkingEngine.xd(this.M);this.B=this.A=
this.j=this.f=this.D=null;this.l&&(clearTimeout(this.l),this.l=null);this.L=!1;this.J=this.G=Infinity;return Promise.resolve()}update(){if(this.F())return yS(this,[this.o]).then(a=>GS(this,a.data).then(()=>this.j)).catch(a=>{if(this.D)this.D.onError(a)})}setCurrentVariant(){}Vb(){this.g.debug(_.DB);this.D&&(this.l=null,this.update().then(()=>{HS(this,this.B)}).catch(a=>{this.D&&(this.D.onError(a),1===a.severity&&HS(this,100))}))}F(){return this.P===BS}K(){return 0<this.w.length}R(a){let b=null;if(this.w.length)for(let c=
0;c<this.w.length;c++)if(this.w[c].keySystem===a){b=this.w[c].initData[0];break}return b}S(a){if(2!==a.request.type||a.uri.startsWith("data:"))return Promise.resolve(a);const b=a.request.timescale||this.A.timescale,c={isLive:this.F.bind(this),Vd:this.K.bind(this),Bh:()=>1,Sd:this.R.bind(this)};let d=!1;const e=new _.I(_.G,3,4035,null);let f=null;try{const g=this.H.get(a.request.uris[a.request.uriIndex])||a.request.startTime||0;g!==a.request.startTime&&this.g.debug(`Using base media decode time ${g} instead of `+
`segment reference time ${a.request.startTime}`);f=uS(a,b,g,c)}catch(g){d=!0,e.data=g,3E3===g.code&&(e.code=4039)}if(d||!f)return Promise.reject(e);a.data=f;return Promise.resolve(a)}loadVariant(a){return _.x(function*(){return a})}loadTextStream(a,b){const c=this;return _.x(function*(){let d;const e=c.j.periods.find(f=>f.id===b);e&&(d=e.textStreams.find(f=>f.id===a)||null);if(!d)throw new _.ji(`Could not load text stream with id: ${a}`);return d})}},KS={video:_.pg,audio:_.Fc,text:_.xc},CS=_.Cb,BS=
"LIVE",LS={Pi:_.JB,Qi:_.XB};_.z("clpp.smooth.SmoothComponent",class extends _.Av{f(){_.$s.ism=aT;_.Ys[_.yc]=aT}a(){_.RD("ism");_.SD(_.yc)}id(){return _.Hf}});};f.call(g, window);