(()=>{var s={368:(l,c,p)=>{var r=p(454);l.exports=function(i){var t,n="",a=(i=i||{}).video,o=i.options,d=r.$escape,g=i.tran,m=i.icons,v=r.$each,b=(i.$value,i.$index,i.index);return n+=``,t=p(953)(a),n+=t,n+=` @@ -2168,54 +2168,54 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho \v\f\r \u2028\u2029\uFEFF`},9575:function(i,t,n){var a=n(2109),o=n(7293),d=n(3331),g=n(9670),m=n(1400),v=n(7466),b=n(6707),w=d.ArrayBuffer,C=d.DataView,D=w.prototype.slice;a({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:o(function(){return!new w(2).slice(1,void 0).byteLength})},{slice:function(R,T){if(D!==void 0&&T===void 0)return D.call(g(this),R);for(var P=g(this).byteLength,L=m(R,P),I=m(T===void 0?P:T,P),x=new(b(this,w))(v(I-L)),O=new C(this),G=new C(x),J=0;L=51||!o(function(){var G=[];return G[T]=!1,G.concat()[0]!==G}),x=C("concat"),O=function(G){if(!g(G))return!1;var J=G[T];return J!==void 0?!!J:d(G)};a({target:"Array",proto:!0,forced:!I||!x},{concat:function(G){var J,te,le,ne,ee,M=m(this),Y=w(M,0),j=0;for(J=-1,le=arguments.length;JP)throw TypeError(L);for(te=0;te =P)throw TypeError(L);b(Y,j++,ee)}return Y.length=j,Y}})},3290:function(i,t,n){var a=n(2109),o=n(1285),d=n(1223);a({target:"Array",proto:!0},{fill:o}),d("fill")},7327:function(i,t,n){var a=n(2109),o=n(2092).filter,d=n(1194),g=n(9207),m=d("filter"),v=g("filter");a({target:"Array",proto:!0,forced:!m||!v},{filter:function(b){return o(this,b,arguments.length>1?arguments[1]:void 0)}})},4553:function(i,t,n){var a=n(2109),o=n(2092).findIndex,d=n(1223),g=n(9207),m="findIndex",v=!0,b=g(m);m in[]&&Array(1).findIndex(function(){v=!1}),a({target:"Array",proto:!0,forced:v||!b},{findIndex:function(w){return o(this,w,arguments.length>1?arguments[1]:void 0)}}),d(m)},9826:function(i,t,n){var a=n(2109),o=n(2092).find,d=n(1223),g=n(9207),m="find",v=!0,b=g(m);m in[]&&Array(1).find(function(){v=!1}),a({target:"Array",proto:!0,forced:v||!b},{find:function(w){return o(this,w,arguments.length>1?arguments[1]:void 0)}}),d(m)},9554:function(i,t,n){var a=n(2109),o=n(8533);a({target:"Array",proto:!0,forced:[].forEach!=o},{forEach:o})},6699:function(i,t,n){var a=n(2109),o=n(1318).includes,d=n(1223);a({target:"Array",proto:!0,forced:!n(9207)("indexOf",{ACCESSORS:!0,1:0})},{includes:function(g){return o(this,g,arguments.length>1?arguments[1]:void 0)}}),d("includes")},6992:function(i,t,n){var a=n(5656),o=n(1223),d=n(7497),g=n(9909),m=n(654),v="Array Iterator",b=g.set,w=g.getterFor(v);i.exports=m(Array,"Array",function(C,D){b(this,{type:v,target:a(C),index:0,kind:D})},function(){var C=w(this),D=C.target,R=C.kind,T=C.index++;return!D||T>=D.length?(C.target=void 0,{value:void 0,done:!0}):R=="keys"?{value:T,done:!1}:R=="values"?{value:D[T],done:!1}:{value:[T,D[T]],done:!1}},"values"),d.Arguments=d.Array,o("keys"),o("values"),o("entries")},7042:function(i,t,n){var a=n(2109),o=n(111),d=n(3157),g=n(1400),m=n(7466),v=n(5656),b=n(6135),w=n(5112),C=n(1194),D=n(9207),R=C("slice"),T=D("slice",{ACCESSORS:!0,0:0,1:2}),P=w("species"),L=[].slice,I=Math.max;a({target:"Array",proto:!0,forced:!R||!T},{slice:function(x,O){var G,J,te,le=v(this),ne=m(le.length),ee=g(x,ne),M=g(O===void 0?ne:O,ne);if(d(le)&&(typeof(G=le.constructor)!="function"||G!==Array&&!d(G.prototype)?o(G)&&(G=G[P])===null&&(G=void 0):G=void 0,G===Array||G===void 0))return L.call(le,ee,M);for(J=new(G===void 0?Array:G)(I(M-ee,0)),te=0;ee 1?arguments[1]:void 0)}})},2707:function(i,t,n){var a=n(2109),o=n(3099),d=n(7908),g=n(7293),m=n(9341),v=[],b=v.sort,w=g(function(){v.sort(void 0)}),C=g(function(){v.sort(null)}),D=m("sort");a({target:"Array",proto:!0,forced:w||!C||!D},{sort:function(R){return R===void 0?b.call(d(this)):b.call(d(this),o(R))}})},561:function(i,t,n){var a=n(2109),o=n(1400),d=n(9958),g=n(7466),m=n(7908),v=n(5417),b=n(6135),w=n(1194),C=n(9207),D=w("splice"),R=C("splice",{ACCESSORS:!0,0:0,1:2}),T=Math.max,P=Math.min,L=9007199254740991,I="Maximum allowed length exceeded";a({target:"Array",proto:!0,forced:!D||!R},{splice:function(x,O){var G,J,te,le,ne,ee,M=m(this),Y=g(M.length),j=o(x,Y),z=arguments.length;if(z===0?G=J=0:z===1?(G=0,J=Y-j):(G=z-2,J=P(T(d(O),0),Y-j)),Y+G-J>L)throw TypeError(I);for(te=v(M,J),le=0;le Y-J+G;le--)delete M[le-1]}else if(G>J)for(le=Y-J;le>j;le--)ee=le+G-1,(ne=le+J-1)in M?M[ee]=M[ne]:delete M[ee];for(le=0;le 2){if((Y=(ie=L(ie)).charCodeAt(0))===43||Y===45){if((j=ie.charCodeAt(2))===88||j===120)return NaN}else if(Y===48){switch(ie.charCodeAt(1)){case 66:case 98:z=2,q=49;break;case 79:case 111:z=8,q=55;break;default:return+ie}for(X=(Z=ie.slice(2)).length,oe=0;oe /g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}resize(){const ge=this.container.offsetWidth,Le=this.container.querySelectorAll(".dplayer-danmaku-item");for(let Xe=0;Xeq)return NaN;return parseInt(Z,z)}}return+ie};if(d(I,!x(" 0o1")||!x("0b1")||x("+0x1"))){for(var te,le=function(M){var Y=arguments.length<1?0:M,j=this;return j instanceof le&&(G?C(function(){O.valueOf.call(j)}):v(j)!=I)?b(new x(J(Y)),j,le):J(Y)},ne=a?R(x):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),ee=0;ne.length>ee;ee++)m(x,te=ne[ee])&&!m(le,te)&&P(le,te,T(x,te));le.prototype=O,O.constructor=le,g(o,I,le)}},5192:function(i,t,n){n(2109)({target:"Number",stat:!0},{isFinite:n(7023)})},4363:function(i,t,n){n(2109)({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991})},9494:function(i,t,n){var a=n(2109),o=n(3009);a({target:"Number",stat:!0,forced:Number.parseInt!=o},{parseInt:o})},9720:function(i,t,n){var a=n(2109),o=n(4699).entries;a({target:"Object",stat:!0},{entries:function(d){return o(d)}})},489:function(i,t,n){var a=n(2109),o=n(7293),d=n(7908),g=n(9518),m=n(8544);a({target:"Object",stat:!0,forced:o(function(){g(1)}),sham:!m},{getPrototypeOf:function(v){return g(d(v))}})},8304:function(i,t,n){n(2109)({target:"Object",stat:!0},{setPrototypeOf:n(7674)})},1539:function(i,t,n){var a=n(1694),o=n(1320),d=n(288);a||o(Object.prototype,"toString",d,{unsafe:!0})},4916:function(i,t,n){var a=n(2109),o=n(2261);a({target:"RegExp",proto:!0,forced:/./.exec!==o},{exec:o})},9714:function(i,t,n){var a=n(1320),o=n(9670),d=n(7293),g=n(7066),m="toString",v=RegExp.prototype,b=v.toString,w=d(function(){return b.call({source:"a",flags:"b"})!="/a/b"}),C=b.name!=m;(w||C)&&a(RegExp.prototype,m,function(){var D=o(this),R=String(D.source),T=D.flags;return"/"+R+"/"+String(T===void 0&&D instanceof RegExp&&!("flags"in v)?g.call(D):T)},{unsafe:!0})},189:function(i,t,n){var a=n(7710),o=n(5631);i.exports=a("Set",function(d){return function(){return d(this,arguments.length?arguments[0]:void 0)}},o)},2023:function(i,t,n){var a=n(2109),o=n(3929),d=n(4488);a({target:"String",proto:!0,forced:!n(4964)("includes")},{includes:function(g){return!!~String(d(this)).indexOf(o(g),arguments.length>1?arguments[1]:void 0)}})},8783:function(i,t,n){var a=n(8710).charAt,o=n(9909),d=n(654),g="String Iterator",m=o.set,v=o.getterFor(g);d(String,"String",function(b){m(this,{type:g,string:String(b),index:0})},function(){var b,w=v(this),C=w.string,D=w.index;return D>=C.length?{value:void 0,done:!0}:(b=a(C,D),w.index+=b.length,{value:b,done:!1})})},3112:function(i,t,n){var a=n(2109),o=n(6650).start;a({target:"String",proto:!0,forced:n(4986)},{padStart:function(d){return o(this,d,arguments.length>1?arguments[1]:void 0)}})},5306:function(i,t,n){var a=n(7007),o=n(9670),d=n(7466),g=n(9958),m=n(4488),v=n(1530),b=n(647),w=n(7651),C=Math.max,D=Math.min;a("replace",2,function(R,T,P,L){var I=L.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,x=L.REPLACE_KEEPS_$0,O=I?"$":"$0";return[function(G,J){var te=m(this),le=G==null?void 0:G[R];return le!==void 0?le.call(G,te,J):T.call(String(te),G,J)},function(G,J){if(!I&&x||typeof J=="string"&&J.indexOf(O)===-1){var te=P(T,G,this,J);if(te.done)return te.value}var le=o(G),ne=String(this),ee=typeof J=="function";ee||(J=String(J));var M=le.global;if(M){var Y=le.unicode;le.lastIndex=0}for(var j=[];;){var z=w(le,ne);if(z===null||(j.push(z),!M))break;String(z[0])===""&&(le.lastIndex=v(ne,d(le.lastIndex),Y))}for(var q,Z="",X=0,oe=0;oe =X&&(Z+=ne.slice(X,ie)+Ie,X=ie+he.length)}return Z+ne.slice(X)}]})},1817:function(i,t,n){var a=n(2109),o=n(9781),d=n(7854),g=n(6656),m=n(111),v=n(3070).f,b=n(9920),w=d.Symbol;if(o&&typeof w=="function"&&(!("description"in w.prototype)||w().description!==void 0)){var C={},D=function(){var I=arguments.length<1||arguments[0]===void 0?void 0:String(arguments[0]),x=this instanceof D?new w(I):I===void 0?w():w(I);return I===""&&(C[x]=!0),x};b(D,w);var R=D.prototype=w.prototype;R.constructor=D;var T=R.toString,P=String(w("test"))=="Symbol(test)",L=/^Symbol\((.*)\)[^)]+$/;v(R,"description",{configurable:!0,get:function(){var I=m(this)?this.valueOf():this,x=T.call(I);if(g(C,I))return"";var O=P?x.slice(7,-1):x.replace(L,"$1");return O===""?void 0:O}}),a({global:!0,forced:!0},{Symbol:D})}},2526:function(i,t,n){var a=n(2109),o=n(7854),d=n(5005),g=n(1913),m=n(9781),v=n(133),b=n(3307),w=n(7293),C=n(6656),D=n(3157),R=n(111),T=n(9670),P=n(7908),L=n(5656),I=n(7593),x=n(9114),O=n(30),G=n(1956),J=n(8006),te=n(1156),le=n(5181),ne=n(1236),ee=n(3070),M=n(5296),Y=n(8880),j=n(1320),z=n(2309),q=n(6200),Z=n(3501),X=n(9711),oe=n(5112),he=n(6061),ie=n(7235),fe=n(8003),se=n(9909),Ee=n(2092).forEach,He=q("hidden"),Ie="Symbol",at=oe("toPrimitive"),je=se.set,ht=se.getterFor(Ie),_e=Object.prototype,Oe=o.Symbol,pt=d("JSON","stringify"),vt=ne.f,tt=ee.f,pe=te.f,ue=M.f,W=z("symbols"),ke=z("op-symbols"),Ae=z("string-to-symbol-registry"),Ye=z("symbol-to-string-registry"),lt=z("wks"),mt=o.QObject,Ue=!mt||!mt.prototype||!mt.prototype.findChild,Ve=m&&w(function(){return O(tt({},"a",{get:function(){return tt(this,"a",{value:7}).a}})).a!=7})?function($e,Be,it){var Ne=vt(_e,Be);Ne&&delete _e[Be],tt($e,Be,it),Ne&&$e!==_e&&tt(_e,Be,Ne)}:tt,De=function($e,Be){var it=W[$e]=O(Oe.prototype);return je(it,{type:Ie,tag:$e,description:Be}),m||(it.description=Be),it},Re=b?function($e){return typeof $e=="symbol"}:function($e){return Object($e)instanceof Oe},ut=function($e,Be,it){$e===_e&&ut(ke,Be,it),T($e);var Ne=I(Be,!0);return T(it),C(W,Ne)?(it.enumerable?(C($e,He)&&$e[He][Ne]&&($e[He][Ne]=!1),it=O(it,{enumerable:x(0,!1)})):(C($e,He)||tt($e,He,x(1,{})),$e[He][Ne]=!0),Ve($e,Ne,it)):tt($e,Ne,it)},gt=function($e,Be){T($e);var it=L(Be),Ne=G(it).concat(Je(it));return Ee(Ne,function(Qe){m&&!Ce.call(it,Qe)||ut($e,Qe,it[Qe])}),$e},Ce=function($e){var Be=I($e,!0),it=ue.call(this,Be);return!(this===_e&&C(W,Be)&&!C(ke,Be))&&(!(it||!C(this,Be)||!C(W,Be)||C(this,He)&&this[He][Be])||it)},ze=function($e,Be){var it=L($e),Ne=I(Be,!0);if(it!==_e||!C(W,Ne)||C(ke,Ne)){var Qe=vt(it,Ne);return!Qe||!C(W,Ne)||C(it,He)&&it[He][Ne]||(Qe.enumerable=!0),Qe}},At=function($e){var Be=pe(L($e)),it=[];return Ee(Be,function(Ne){C(W,Ne)||C(Z,Ne)||it.push(Ne)}),it},Je=function($e){var Be=$e===_e,it=pe(Be?ke:L($e)),Ne=[];return Ee(it,function(Qe){!C(W,Qe)||Be&&!C(_e,Qe)||Ne.push(W[Qe])}),Ne};v||(j((Oe=function(){if(this instanceof Oe)throw TypeError("Symbol is not a constructor");var $e=arguments.length&&arguments[0]!==void 0?String(arguments[0]):void 0,Be=X($e),it=function(Ne){this===_e&&it.call(ke,Ne),C(this,He)&&C(this[He],Be)&&(this[He][Be]=!1),Ve(this,Be,x(1,Ne))};return m&&Ue&&Ve(_e,Be,{configurable:!0,set:it}),De(Be,$e)}).prototype,"toString",function(){return ht(this).tag}),j(Oe,"withoutSetter",function($e){return De(X($e),$e)}),M.f=Ce,ee.f=ut,ne.f=ze,J.f=te.f=At,le.f=Je,he.f=function($e){return De(oe($e),$e)},m&&(tt(Oe.prototype,"description",{configurable:!0,get:function(){return ht(this).description}}),g||j(_e,"propertyIsEnumerable",Ce,{unsafe:!0}))),a({global:!0,wrap:!0,forced:!v,sham:!v},{Symbol:Oe}),Ee(G(lt),function($e){ie($e)}),a({target:Ie,stat:!0,forced:!v},{for:function($e){var Be=String($e);if(C(Ae,Be))return Ae[Be];var it=Oe(Be);return Ae[Be]=it,Ye[it]=Be,it},keyFor:function($e){if(!Re($e))throw TypeError($e+" is not a symbol");if(C(Ye,$e))return Ye[$e]},useSetter:function(){Ue=!0},useSimple:function(){Ue=!1}}),a({target:"Object",stat:!0,forced:!v,sham:!m},{create:function($e,Be){return Be===void 0?O($e):gt(O($e),Be)},defineProperty:ut,defineProperties:gt,getOwnPropertyDescriptor:ze}),a({target:"Object",stat:!0,forced:!v},{getOwnPropertyNames:At,getOwnPropertySymbols:Je}),a({target:"Object",stat:!0,forced:w(function(){le.f(1)})},{getOwnPropertySymbols:function($e){return le.f(P($e))}}),pt&&a({target:"JSON",stat:!0,forced:!v||w(function(){var $e=Oe();return pt([$e])!="[null]"||pt({a:$e})!="{}"||pt(Object($e))!="{}"})},{stringify:function($e,Be,it){for(var Ne,Qe=[$e],Me=1;arguments.length>Me;)Qe.push(arguments[Me++]);if(Ne=Be,(R(Be)||$e!==void 0)&&!Re($e))return D(Be)||(Be=function(Se,K){if(typeof Ne=="function"&&(K=Ne.call(this,Se,K)),!Re(K))return K}),Qe[1]=Be,pt.apply(null,Qe)}}),Oe.prototype[at]||Y(Oe.prototype,at,Oe.prototype.valueOf),fe(Oe,Ie),Z[He]=!0},2990:function(i,t,n){var a=n(260),o=n(1048),d=a.aTypedArray;(0,a.exportTypedArrayMethod)("copyWithin",function(g,m){return o.call(d(this),g,m,arguments.length>2?arguments[2]:void 0)})},8927:function(i,t,n){var a=n(260),o=n(2092).every,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("every",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},3105:function(i,t,n){var a=n(260),o=n(1285),d=a.aTypedArray;(0,a.exportTypedArrayMethod)("fill",function(g){return o.apply(d(this),arguments)})},5035:function(i,t,n){var a=n(260),o=n(2092).filter,d=n(6707),g=a.aTypedArray,m=a.aTypedArrayConstructor;(0,a.exportTypedArrayMethod)("filter",function(v){for(var b=o(g(this),v,arguments.length>1?arguments[1]:void 0),w=d(this,this.constructor),C=0,D=b.length,R=new(m(w))(D);D>C;)R[C]=b[C++];return R})},7174:function(i,t,n){var a=n(260),o=n(2092).findIndex,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("findIndex",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},4345:function(i,t,n){var a=n(260),o=n(2092).find,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("find",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},2846:function(i,t,n){var a=n(260),o=n(2092).forEach,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("forEach",function(g){o(d(this),g,arguments.length>1?arguments[1]:void 0)})},4731:function(i,t,n){var a=n(260),o=n(1318).includes,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("includes",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},7209:function(i,t,n){var a=n(260),o=n(1318).indexOf,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("indexOf",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},6319:function(i,t,n){var a=n(7854),o=n(260),d=n(6992),g=n(5112)("iterator"),m=a.Uint8Array,v=d.values,b=d.keys,w=d.entries,C=o.aTypedArray,D=o.exportTypedArrayMethod,R=m&&m.prototype[g],T=!!R&&(R.name=="values"||R.name==null),P=function(){return v.call(C(this))};D("entries",function(){return w.call(C(this))}),D("keys",function(){return b.call(C(this))}),D("values",P,!T),D(g,P,!T)},8867:function(i,t,n){var a=n(260),o=a.aTypedArray,d=a.exportTypedArrayMethod,g=[].join;d("join",function(m){return g.apply(o(this),arguments)})},7789:function(i,t,n){var a=n(260),o=n(6583),d=a.aTypedArray;(0,a.exportTypedArrayMethod)("lastIndexOf",function(g){return o.apply(d(this),arguments)})},3739:function(i,t,n){var a=n(260),o=n(2092).map,d=n(6707),g=a.aTypedArray,m=a.aTypedArrayConstructor;(0,a.exportTypedArrayMethod)("map",function(v){return o(g(this),v,arguments.length>1?arguments[1]:void 0,function(b,w){return new(m(d(b,b.constructor)))(w)})})},4483:function(i,t,n){var a=n(260),o=n(3671).right,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("reduceRight",function(g){return o(d(this),g,arguments.length,arguments.length>1?arguments[1]:void 0)})},9368:function(i,t,n){var a=n(260),o=n(3671).left,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("reduce",function(g){return o(d(this),g,arguments.length,arguments.length>1?arguments[1]:void 0)})},2056:function(i,t,n){var a=n(260),o=a.aTypedArray,d=a.exportTypedArrayMethod,g=Math.floor;d("reverse",function(){for(var m,v=this,b=o(v).length,w=g(b/2),C=0;C 1?arguments[1]:void 0,1),C=this.length,D=g(b),R=o(D.length),T=0;if(R+w>C)throw RangeError("Wrong length");for(;T T;)L[T]=D[T++];return L},d(function(){new Int8Array(1).slice()}))},7462:function(i,t,n){var a=n(260),o=n(2092).some,d=a.aTypedArray;(0,a.exportTypedArrayMethod)("some",function(g){return o(d(this),g,arguments.length>1?arguments[1]:void 0)})},3824:function(i,t,n){var a=n(260),o=a.aTypedArray,d=a.exportTypedArrayMethod,g=[].sort;d("sort",function(m){return g.call(o(this),m)})},5021:function(i,t,n){var a=n(260),o=n(7466),d=n(1400),g=n(6707),m=a.aTypedArray;(0,a.exportTypedArrayMethod)("subarray",function(v,b){var w=m(this),C=w.length,D=d(v,C);return new(g(w,w.constructor))(w.buffer,w.byteOffset+D*w.BYTES_PER_ELEMENT,o((b===void 0?C:d(b,C))-D))})},2974:function(i,t,n){var a=n(7854),o=n(260),d=n(7293),g=a.Int8Array,m=o.aTypedArray,v=o.exportTypedArrayMethod,b=[].toLocaleString,w=[].slice,C=!!g&&d(function(){b.call(new g(1))});v("toLocaleString",function(){return b.apply(C?w.call(m(this)):m(this),arguments)},d(function(){return[1,2].toLocaleString()!=new g([1,2]).toLocaleString()})||!d(function(){g.prototype.toLocaleString.call([1,2])}))},5016:function(i,t,n){var a=n(260).exportTypedArrayMethod,o=n(7293),d=n(7854).Uint8Array,g=d&&d.prototype||{},m=[].toString,v=[].join;o(function(){m.call({})})&&(m=function(){return v.call(this)});var b=g.toString!=m;a("toString",m,b)},2472:function(i,t,n){n(9843)("Uint8",function(a){return function(o,d,g){return a(this,o,d,g)}})},4747:function(i,t,n){var a=n(7854),o=n(8324),d=n(8533),g=n(8880);for(var m in o){var v=a[m],b=v&&v.prototype;if(b&&b.forEach!==d)try{g(b,"forEach",d)}catch{b.forEach=d}}},3948:function(i,t,n){var a=n(7854),o=n(8324),d=n(6992),g=n(8880),m=n(5112),v=m("iterator"),b=m("toStringTag"),w=d.values;for(var C in o){var D=a[C],R=D&&D.prototype;if(R){if(R[v]!==w)try{g(R,v,w)}catch{R[v]=w}if(R[b]||g(R,b,C),o[C]){for(var T in d)if(R[T]!==d[T])try{g(R,T,d[T])}catch{R[T]=d[T]}}}}}},p={};function r(i){if(p[i])return p[i].exports;var t=p[i]={exports:{}};return c[i](t,t.exports,r),t.exports}return r.d=function(i,t){for(var n in t)r.o(t,n)&&!r.o(i,n)&&Object.defineProperty(i,n,{enumerable:!0,get:t[n]})},r.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),r.o=function(i,t){return Object.prototype.hasOwnProperty.call(i,t)},r.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},r(9798)}()},13:(l,c,p)=>{/*! art-template@runtime | https://github.com/aui/art-template */var r=typeof self<"u"?self:typeof window<"u"?window:p.g!==void 0?p.g:{},i=Object.create(r),t=/["&'<>]/;function n(a){return typeof a!="string"&&(a=a==null?"":typeof a=="function"?n(a.call(a)):JSON.stringify(a)),a}i.$escape=function(a){return function(o){var d=""+o,g=t.exec(d);if(!g)return o;var m="",v=void 0,b=void 0,w=void 0;for(v=g.index,b=0;v {l.exports=p(13)},66:l=>{l.exports=function(c){var p=[];return p.toString=function(){return this.map(function(r){var i="",t=r[5]!==void 0;return r[4]&&(i+="@supports (".concat(r[4],") {")),r[2]&&(i+="@media ".concat(r[2]," {")),t&&(i+="@layer".concat(r[5].length>0?" ".concat(r[5]):""," {")),i+=c(r),t&&(i+="}"),r[2]&&(i+="}"),r[4]&&(i+="}"),i}).join("")},p.i=function(r,i,t,n,a){typeof r=="string"&&(r=[[null,r,void 0]]);var o={};if(t)for(var d=0;d 0?" ".concat(v[5]):""," {").concat(v[1],"}")),v[5]=a),i&&(v[2]&&(v[1]="@media ".concat(v[2]," {").concat(v[1],"}")),v[2]=i),n&&(v[4]?(v[1]="@supports (".concat(v[4],") {").concat(v[1],"}"),v[4]=n):v[4]="".concat(n)),p.push(v))}},p}},236:l=>{l.exports=function(c){var p=c[1],r=c[3];if(!r)return p;if(typeof btoa=="function"){var i=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),t="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),n="/*# ".concat(t," */");return[p].concat([n]).join(` `)}return[p].join(` `)}},379:l=>{var c=[];function p(t){for(var n=-1,a=0;a {var c={};l.exports=function(p,r){var i=function(t){if(c[t]===void 0){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch{n=null}c[t]=n}return c[t]}(p);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(r)}},216:l=>{l.exports=function(c){var p=document.createElement("style");return c.setAttributes(p,c.attributes),c.insert(p,c.options),p}},565:(l,c,p)=>{l.exports=function(r){var i=p.nc;i&&r.setAttribute("nonce",i)}},795:l=>{l.exports=function(c){if(typeof document>"u")return{update:function(){},remove:function(){}};var p=c.insertStyleElement(c);return{update:function(r){(function(i,t,n){var a="";n.supports&&(a+="@supports (".concat(n.supports,") {")),n.media&&(a+="@media ".concat(n.media," {"));var o=n.layer!==void 0;o&&(a+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),a+=n.css,o&&(a+="}"),n.media&&(a+="}"),n.supports&&(a+="}");var d=n.sourceMap;d&&typeof btoa<"u"&&(a+=` -/*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(d))))," */")),t.styleTagTransform(a,i,t.options)})(p,c,r)},remove:function(){(function(r){if(r.parentNode===null)return!1;r.parentNode.removeChild(r)})(p)}}}},589:l=>{l.exports=function(c,p){if(p.styleSheet)p.styleSheet.cssText=c;else{for(;p.firstChild;)p.removeChild(p.firstChild);p.appendChild(document.createTextNode(c))}}},597:l=>{l.exports=''},704:l=>{l.exports=''},409:l=>{l.exports=''},243:l=>{l.exports=''},478:l=>{l.exports=''},885:l=>{l.exports=''},189:l=>{l.exports=''},783:l=>{l.exports=''},241:l=>{l.exports=''},863:l=>{l.exports=''},112:l=>{l.exports=''},310:l=>{l.exports=' '},723:l=>{l.exports=' '},355:l=>{l.exports=' '},7:l=>{l.exports=' '},381:l=>{l.exports=' '},916:l=>{l.exports=' '},531:l=>{l.exports=' '},223:l=>{l.exports=' '},813:l=>{l.exports=' '},480:l=>{l.exports=' '},848:l=>{l.exports=' '}},u={};function y(l){var c=u[l];if(c!==void 0)return c.exports;var p=u[l]={id:l,exports:{}};return s[l].call(p.exports,p,p.exports,y),p.exports}y.n=l=>{var c=l&&l.__esModule?()=>l.default:()=>l;return y.d(c,{a:c}),c},y.d=(l,c)=>{for(var p in c)y.o(c,p)&&!y.o(l,p)&&Object.defineProperty(l,p,{enumerable:!0,get:c[p]})},y.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),y.o=(l,c)=>Object.prototype.hasOwnProperty.call(l,c),y.nc=void 0;var A={};return(()=>{y.d(A,{default:()=>is});var l=y(379),c=y.n(l),p=y(795),r=y.n(p),i=y(569),t=y.n(i),n=y(565),a=y.n(n),o=y(216),d=y.n(o),g=y(589),m=y.n(g),v=y(869),b={};b.styleTagTransform=m(),b.setAttributes=a(),b.insert=t().bind(null,"head"),b.domAPI=r(),b.insertStyleElement=d(),c()(v.Z,b),v.Z&&v.Z.locals&&v.Z.locals;function w(ge,Le){return function(){return ge.apply(Le,arguments)}}const{toString:C}=Object.prototype,{getPrototypeOf:D}=Object,R=(T=Object.create(null),ge=>{const Le=C.call(ge);return T[Le]||(T[Le]=Le.slice(8,-1).toLowerCase())});var T;const P=ge=>(ge=ge.toLowerCase(),Le=>R(Le)===ge),L=ge=>Le=>typeof Le===ge,{isArray:I}=Array,x=L("undefined"),O=P("ArrayBuffer"),G=L("string"),J=L("function"),te=L("number"),le=ge=>ge!==null&&typeof ge=="object",ne=ge=>{if(R(ge)!=="object")return!1;const Le=D(ge);return!(Le!==null&&Le!==Object.prototype&&Object.getPrototypeOf(Le)!==null||Symbol.toStringTag in ge||Symbol.iterator in ge)},ee=P("Date"),M=P("File"),Y=P("Blob"),j=P("FileList"),z=P("URLSearchParams");function q(ge,Le,{allOwnKeys:Xe=!1}={}){if(ge==null)return;let ft,_t;if(typeof ge!="object"&&(ge=[ge]),I(ge))for(ft=0,_t=ge.length;ft<_t;ft++)Le.call(null,ge[ft],ft,ge);else{const Ct=Xe?Object.getOwnPropertyNames(ge):Object.keys(ge),Pt=Ct.length;let ci;for(ft=0;ft 0;)if(ft=Xe[_t],Le===ft.toLowerCase())return ft;return null}const X=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Ho,oe=ge=>!x(ge)&&ge!==X,he=(ie=typeof Uint8Array<"u"&&D(Uint8Array),ge=>ie&&ge instanceof ie);var ie;const fe=P("HTMLFormElement"),se=(({hasOwnProperty:ge})=>(Le,Xe)=>ge.call(Le,Xe))(Object.prototype),Ee=P("RegExp"),He=(ge,Le)=>{const Xe=Object.getOwnPropertyDescriptors(ge),ft={};q(Xe,(_t,Ct)=>{let Pt;(Pt=Le(_t,Ct,ge))!==!1&&(ft[Ct]=Pt||_t)}),Object.defineProperties(ge,ft)},Ie="abcdefghijklmnopqrstuvwxyz",at="0123456789",je={DIGIT:at,ALPHA:Ie,ALPHA_DIGIT:Ie+Ie.toUpperCase()+at},ht=P("AsyncFunction"),_e={isArray:I,isArrayBuffer:O,isBuffer:function(ge){return ge!==null&&!x(ge)&&ge.constructor!==null&&!x(ge.constructor)&&J(ge.constructor.isBuffer)&&ge.constructor.isBuffer(ge)},isFormData:ge=>{let Le;return ge&&(typeof FormData=="function"&&ge instanceof FormData||J(ge.append)&&((Le=R(ge))==="formdata"||Le==="object"&&J(ge.toString)&&ge.toString()==="[object FormData]"))},isArrayBufferView:function(ge){let Le;return Le=typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(ge):ge&&ge.buffer&&O(ge.buffer),Le},isString:G,isNumber:te,isBoolean:ge=>ge===!0||ge===!1,isObject:le,isPlainObject:ne,isUndefined:x,isDate:ee,isFile:M,isBlob:Y,isRegExp:Ee,isFunction:J,isStream:ge=>le(ge)&&J(ge.pipe),isURLSearchParams:z,isTypedArray:he,isFileList:j,forEach:q,merge:function ge(){const{caseless:Le}=oe(this)&&this||{},Xe={},ft=(_t,Ct)=>{const Pt=Le&&Z(Xe,Ct)||Ct;ne(Xe[Pt])&&ne(_t)?Xe[Pt]=ge(Xe[Pt],_t):ne(_t)?Xe[Pt]=ge({},_t):I(_t)?Xe[Pt]=_t.slice():Xe[Pt]=_t};for(let _t=0,Ct=arguments.length;_t (q(Le,(_t,Ct)=>{Xe&&J(_t)?ge[Ct]=w(_t,Xe):ge[Ct]=_t},{allOwnKeys:ft}),ge),trim:ge=>ge.trim?ge.trim():ge.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:ge=>(ge.charCodeAt(0)===65279&&(ge=ge.slice(1)),ge),inherits:(ge,Le,Xe,ft)=>{ge.prototype=Object.create(Le.prototype,ft),ge.prototype.constructor=ge,Object.defineProperty(ge,"super",{value:Le.prototype}),Xe&&Object.assign(ge.prototype,Xe)},toFlatObject:(ge,Le,Xe,ft)=>{let _t,Ct,Pt;const ci={};if(Le=Le||{},ge==null)return Le;do{for(_t=Object.getOwnPropertyNames(ge),Ct=_t.length;Ct-- >0;)Pt=_t[Ct],ft&&!ft(Pt,ge,Le)||ci[Pt]||(Le[Pt]=ge[Pt],ci[Pt]=!0);ge=Xe!==!1&&D(ge)}while(ge&&(!Xe||Xe(ge,Le))&&ge!==Object.prototype);return Le},kindOf:R,kindOfTest:P,endsWith:(ge,Le,Xe)=>{ge=String(ge),(Xe===void 0||Xe>ge.length)&&(Xe=ge.length),Xe-=Le.length;const ft=ge.indexOf(Le,Xe);return ft!==-1&&ft===Xe},toArray:ge=>{if(!ge)return null;if(I(ge))return ge;let Le=ge.length;if(!te(Le))return null;const Xe=new Array(Le);for(;Le-- >0;)Xe[Le]=ge[Le];return Xe},forEachEntry:(ge,Le)=>{const Xe=(ge&&ge[Symbol.iterator]).call(ge);let ft;for(;(ft=Xe.next())&&!ft.done;){const _t=ft.value;Le.call(ge,_t[0],_t[1])}},matchAll:(ge,Le)=>{let Xe;const ft=[];for(;(Xe=ge.exec(Le))!==null;)ft.push(Xe);return ft},isHTMLForm:fe,hasOwnProperty:se,hasOwnProp:se,reduceDescriptors:He,freezeMethods:ge=>{He(ge,(Le,Xe)=>{if(J(ge)&&["arguments","caller","callee"].indexOf(Xe)!==-1)return!1;const ft=ge[Xe];J(ft)&&(Le.enumerable=!1,"writable"in Le?Le.writable=!1:Le.set||(Le.set=()=>{throw Error("Can not rewrite read-only method '"+Xe+"'")}))})},toObjectSet:(ge,Le)=>{const Xe={},ft=_t=>{_t.forEach(Ct=>{Xe[Ct]=!0})};return I(ge)?ft(ge):ft(String(ge).split(Le)),Xe},toCamelCase:ge=>ge.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(Le,Xe,ft){return Xe.toUpperCase()+ft}),noop:()=>{},toFiniteNumber:(ge,Le)=>(ge=+ge,Number.isFinite(ge)?ge:Le),findKey:Z,global:X,isContextDefined:oe,ALPHABET:je,generateString:(ge=16,Le=je.ALPHA_DIGIT)=>{let Xe="";const{length:ft}=Le;for(;ge--;)Xe+=Le[Math.random()*ft|0];return Xe},isSpecCompliantForm:function(ge){return!!(ge&&J(ge.append)&&ge[Symbol.toStringTag]==="FormData"&&ge[Symbol.iterator])},toJSONObject:ge=>{const Le=new Array(10),Xe=(ft,_t)=>{if(le(ft)){if(Le.indexOf(ft)>=0)return;if(!("toJSON"in ft)){Le[_t]=ft;const Ct=I(ft)?[]:{};return q(ft,(Pt,ci)=>{const hi=Xe(Pt,_t+1);!x(hi)&&(Ct[ci]=hi)}),Le[_t]=void 0,Ct}}return ft};return Xe(ge,0)},isAsyncFn:ht,isThenable:ge=>ge&&(le(ge)||J(ge))&&J(ge.then)&&J(ge.catch)};function Oe(ge,Le,Xe,ft,_t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=ge,this.name="AxiosError",Le&&(this.code=Le),Xe&&(this.config=Xe),ft&&(this.request=ft),_t&&(this.response=_t)}_e.inherits(Oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_e.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const pt=Oe.prototype,vt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(ge=>{vt[ge]={value:ge}}),Object.defineProperties(Oe,vt),Object.defineProperty(pt,"isAxiosError",{value:!0}),Oe.from=(ge,Le,Xe,ft,_t,Ct)=>{const Pt=Object.create(pt);return _e.toFlatObject(ge,Pt,function(ci){return ci!==Error.prototype},ci=>ci!=="isAxiosError"),Oe.call(Pt,ge.message,Le,Xe,ft,_t),Pt.cause=ge,Pt.name=ge.name,Ct&&Object.assign(Pt,Ct),Pt};const tt=Oe;function pe(ge){return _e.isPlainObject(ge)||_e.isArray(ge)}function ue(ge){return _e.endsWith(ge,"[]")?ge.slice(0,-2):ge}function W(ge,Le,Xe){return ge?ge.concat(Le).map(function(ft,_t){return ft=ue(ft),!Xe&&_t?"["+ft+"]":ft}).join(Xe?".":""):Le}const ke=_e.toFlatObject(_e,{},null,function(ge){return/^is[A-Z]/.test(ge)}),Ae=function(ge,Le,Xe){if(!_e.isObject(ge))throw new TypeError("target must be an object");Le=Le||new FormData;const ft=(Xe=_e.toFlatObject(Xe,{metaTokens:!0,dots:!1,indexes:!1},!1,function(bi,pi){return!_e.isUndefined(pi[bi])})).metaTokens,_t=Xe.visitor||Xt,Ct=Xe.dots,Pt=Xe.indexes,ci=(Xe.Blob||typeof Blob<"u"&&Blob)&&_e.isSpecCompliantForm(Le);if(!_e.isFunction(_t))throw new TypeError("visitor must be a function");function hi(bi){if(bi===null)return"";if(_e.isDate(bi))return bi.toISOString();if(!ci&&_e.isBlob(bi))throw new tt("Blob is not supported. Use a Buffer instead.");return _e.isArrayBuffer(bi)||_e.isTypedArray(bi)?ci&&typeof Blob=="function"?new Blob([bi]):Buffer.from(bi):bi}function Xt(bi,pi,Di){let On=bi;if(bi&&!Di&&typeof bi=="object"){if(_e.endsWith(pi,"{}"))pi=ft?pi:pi.slice(0,-2),bi=JSON.stringify(bi);else if(_e.isArray(bi)&&function(Ji){return _e.isArray(Ji)&&!Ji.some(pe)}(bi)||(_e.isFileList(bi)||_e.endsWith(pi,"[]"))&&(On=_e.toArray(bi)))return pi=ue(pi),On.forEach(function(Ji,tn){!_e.isUndefined(Ji)&&Ji!==null&&Le.append(Pt===!0?W([pi],tn,Ct):Pt===null?pi:pi+"[]",hi(Ji))}),!1}return!!pe(bi)||(Le.append(W(Di,pi,Ct),hi(bi)),!1)}const _i=[],Ui=Object.assign(ke,{defaultVisitor:Xt,convertValue:hi,isVisitable:pe});if(!_e.isObject(ge))throw new TypeError("data must be an object");return function bi(pi,Di){if(!_e.isUndefined(pi)){if(_i.indexOf(pi)!==-1)throw Error("Circular reference detected in "+Di.join("."));_i.push(pi),_e.forEach(pi,function(On,Ji){(!(_e.isUndefined(On)||On===null)&&_t.call(Le,On,_e.isString(Ji)?Ji.trim():Ji,Di,Ui))===!0&&bi(On,Di?Di.concat(Ji):[Ji])}),_i.pop()}}(ge),Le};function Ye(ge){const Le={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ge).replace(/[!'()~]|%20|%00/g,function(Xe){return Le[Xe]})}function lt(ge,Le){this._pairs=[],ge&&Ae(ge,this,Le)}const mt=lt.prototype;mt.append=function(ge,Le){this._pairs.push([ge,Le])},mt.toString=function(ge){const Le=ge?function(Xe){return ge.call(this,Xe,Ye)}:Ye;return this._pairs.map(function(Xe){return Le(Xe[0])+"="+Le(Xe[1])},"").join("&")};const Ue=lt;function Ve(ge){return encodeURIComponent(ge).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function De(ge,Le,Xe){if(!Le)return ge;const ft=Xe&&Xe.encode||Ve,_t=Xe&&Xe.serialize;let Ct;if(Ct=_t?_t(Le,Xe):_e.isURLSearchParams(Le)?Le.toString():new Ue(Le,Xe).toString(ft),Ct){const Pt=ge.indexOf("#");Pt!==-1&&(ge=ge.slice(0,Pt)),ge+=(ge.indexOf("?")===-1?"?":"&")+Ct}return ge}const Re=class{constructor(){this.handlers=[]}use(ge,Le,Xe){return this.handlers.push({fulfilled:ge,rejected:Le,synchronous:!!Xe&&Xe.synchronous,runWhen:Xe?Xe.runWhen:null}),this.handlers.length-1}eject(ge){this.handlers[ge]&&(this.handlers[ge]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(ge){_e.forEach(this.handlers,function(Le){Le!==null&&ge(Le)})}},ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ue,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},isStandardBrowserEnv:(()=>{let ge;return(typeof navigator>"u"||(ge=navigator.product)!=="ReactNative"&&ge!=="NativeScript"&&ge!=="NS")&&typeof window<"u"&&typeof document<"u"})(),isStandardBrowserWebWorkerEnv:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",protocols:["http","https","file","blob","url","data"]},Ce=function(ge){function Le(Xe,ft,_t,Ct){let Pt=Xe[Ct++];const ci=Number.isFinite(+Pt),hi=Ct>=Xe.length;return Pt=!Pt&&_e.isArray(_t)?_t.length:Pt,hi?(_e.hasOwnProp(_t,Pt)?_t[Pt]=[_t[Pt],ft]:_t[Pt]=ft,!ci):(_t[Pt]&&_e.isObject(_t[Pt])||(_t[Pt]=[]),Le(Xe,ft,_t[Pt],Ct)&&_e.isArray(_t[Pt])&&(_t[Pt]=function(Xt){const _i={},Ui=Object.keys(Xt);let bi;const pi=Ui.length;let Di;for(bi=0;bi {Le(function(Ct){return _e.matchAll(/\w+|\[(\w*)]/g,Ct).map(Pt=>Pt[0]==="[]"?"":Pt[1]||Pt[0])}(ft),_t,Xe,0)}),Xe}return null},ze={transitional:ut,adapter:["xhr","http"],transformRequest:[function(ge,Le){const Xe=Le.getContentType()||"",ft=Xe.indexOf("application/json")>-1,_t=_e.isObject(ge);if(_t&&_e.isHTMLForm(ge)&&(ge=new FormData(ge)),_e.isFormData(ge))return ft&&ft?JSON.stringify(Ce(ge)):ge;if(_e.isArrayBuffer(ge)||_e.isBuffer(ge)||_e.isStream(ge)||_e.isFile(ge)||_e.isBlob(ge))return ge;if(_e.isArrayBufferView(ge))return ge.buffer;if(_e.isURLSearchParams(ge))return Le.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),ge.toString();let Ct;if(_t){if(Xe.indexOf("application/x-www-form-urlencoded")>-1)return function(Pt,ci){return Ae(Pt,new gt.classes.URLSearchParams,Object.assign({visitor:function(hi,Xt,_i,Ui){return gt.isNode&&_e.isBuffer(hi)?(this.append(Xt,hi.toString("base64")),!1):Ui.defaultVisitor.apply(this,arguments)}},ci))}(ge,this.formSerializer).toString();if((Ct=_e.isFileList(ge))||Xe.indexOf("multipart/form-data")>-1){const Pt=this.env&&this.env.FormData;return Ae(Ct?{"files[]":ge}:ge,Pt&&new Pt,this.formSerializer)}}return _t||ft?(Le.setContentType("application/json",!1),function(Pt,ci,hi){if(_e.isString(Pt))try{return(ci||JSON.parse)(Pt),_e.trim(Pt)}catch(Xt){if(Xt.name!=="SyntaxError")throw Xt}return(hi||JSON.stringify)(Pt)}(ge)):ge}],transformResponse:[function(ge){const Le=this.transitional||ze.transitional,Xe=Le&&Le.forcedJSONParsing,ft=this.responseType==="json";if(ge&&_e.isString(ge)&&(Xe&&!this.responseType||ft)){const _t=!(Le&&Le.silentJSONParsing)&&ft;try{return JSON.parse(ge)}catch(Ct){if(_t)throw Ct.name==="SyntaxError"?tt.from(Ct,tt.ERR_BAD_RESPONSE,this,null,this.response):Ct}}return ge}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(ge){return ge>=200&&ge<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_e.forEach(["delete","get","head","post","put","patch"],ge=>{ze.headers[ge]={}});const At=ze,Je=_e.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=Symbol("internals");function Be(ge){return ge&&String(ge).trim().toLowerCase()}function it(ge){return ge===!1||ge==null?ge:_e.isArray(ge)?ge.map(it):String(ge)}function Ne(ge,Le,Xe,ft,_t){return _e.isFunction(ft)?ft.call(this,Le,Xe):(_t&&(Le=Xe),_e.isString(Le)?_e.isString(ft)?Le.indexOf(ft)!==-1:_e.isRegExp(ft)?ft.test(Le):void 0:void 0)}class Qe{constructor(Le){Le&&this.set(Le)}set(Le,Xe,ft){const _t=this;function Ct(ci,hi,Xt){const _i=Be(hi);if(!_i)throw new Error("header name must be a non-empty string");const Ui=_e.findKey(_t,_i);(!Ui||_t[Ui]===void 0||Xt===!0||Xt===void 0&&_t[Ui]!==!1)&&(_t[Ui||hi]=it(ci))}const Pt=(ci,hi)=>_e.forEach(ci,(Xt,_i)=>Ct(Xt,_i,hi));return _e.isPlainObject(Le)||Le instanceof this.constructor?Pt(Le,Xe):_e.isString(Le)&&(Le=Le.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(Le.trim())?Pt((ci=>{const hi={};let Xt,_i,Ui;return ci&&ci.split(` +/*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(d))))," */")),t.styleTagTransform(a,i,t.options)})(p,c,r)},remove:function(){(function(r){if(r.parentNode===null)return!1;r.parentNode.removeChild(r)})(p)}}}},589:l=>{l.exports=function(c,p){if(p.styleSheet)p.styleSheet.cssText=c;else{for(;p.firstChild;)p.removeChild(p.firstChild);p.appendChild(document.createTextNode(c))}}},597:l=>{l.exports=' '},704:l=>{l.exports=' '},409:l=>{l.exports=' '},243:l=>{l.exports=' '},478:l=>{l.exports=' '},885:l=>{l.exports=' '},189:l=>{l.exports=' '},783:l=>{l.exports=' '},241:l=>{l.exports=' '},863:l=>{l.exports=' '},112:l=>{l.exports=' '},310:l=>{l.exports=' '},723:l=>{l.exports=' '},355:l=>{l.exports=' '},7:l=>{l.exports=' '},381:l=>{l.exports=' '},916:l=>{l.exports=' '},531:l=>{l.exports=' '},223:l=>{l.exports=' '},813:l=>{l.exports=' '},480:l=>{l.exports=' '},848:l=>{l.exports=' '}},u={};function A(l){var c=u[l];if(c!==void 0)return c.exports;var p=u[l]={id:l,exports:{}};return s[l].call(p.exports,p,p.exports,A),p.exports}A.n=l=>{var c=l&&l.__esModule?()=>l.default:()=>l;return A.d(c,{a:c}),c},A.d=(l,c)=>{for(var p in c)A.o(c,p)&&!A.o(l,p)&&Object.defineProperty(l,p,{enumerable:!0,get:c[p]})},A.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),A.o=(l,c)=>Object.prototype.hasOwnProperty.call(l,c),A.nc=void 0;var y={};return(()=>{A.d(y,{default:()=>is});var l=A(379),c=A.n(l),p=A(795),r=A.n(p),i=A(569),t=A.n(i),n=A(565),a=A.n(n),o=A(216),d=A.n(o),g=A(589),m=A.n(g),v=A(869),b={};b.styleTagTransform=m(),b.setAttributes=a(),b.insert=t().bind(null,"head"),b.domAPI=r(),b.insertStyleElement=d(),c()(v.Z,b),v.Z&&v.Z.locals&&v.Z.locals;function w(ge,Le){return function(){return ge.apply(Le,arguments)}}const{toString:C}=Object.prototype,{getPrototypeOf:D}=Object,R=(T=Object.create(null),ge=>{const Le=C.call(ge);return T[Le]||(T[Le]=Le.slice(8,-1).toLowerCase())});var T;const P=ge=>(ge=ge.toLowerCase(),Le=>R(Le)===ge),L=ge=>Le=>typeof Le===ge,{isArray:I}=Array,x=L("undefined"),O=P("ArrayBuffer"),G=L("string"),J=L("function"),te=L("number"),le=ge=>ge!==null&&typeof ge=="object",ne=ge=>{if(R(ge)!=="object")return!1;const Le=D(ge);return!(Le!==null&&Le!==Object.prototype&&Object.getPrototypeOf(Le)!==null||Symbol.toStringTag in ge||Symbol.iterator in ge)},ee=P("Date"),M=P("File"),Y=P("Blob"),j=P("FileList"),z=P("URLSearchParams");function q(ge,Le,{allOwnKeys:Xe=!1}={}){if(ge==null)return;let ft,_t;if(typeof ge!="object"&&(ge=[ge]),I(ge))for(ft=0,_t=ge.length;ft<_t;ft++)Le.call(null,ge[ft],ft,ge);else{const Ct=Xe?Object.getOwnPropertyNames(ge):Object.keys(ge),Pt=Ct.length;let ci;for(ft=0;ft 0;)if(ft=Xe[_t],Le===ft.toLowerCase())return ft;return null}const X=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Ho,oe=ge=>!x(ge)&&ge!==X,he=(ie=typeof Uint8Array<"u"&&D(Uint8Array),ge=>ie&&ge instanceof ie);var ie;const fe=P("HTMLFormElement"),se=(({hasOwnProperty:ge})=>(Le,Xe)=>ge.call(Le,Xe))(Object.prototype),Ee=P("RegExp"),He=(ge,Le)=>{const Xe=Object.getOwnPropertyDescriptors(ge),ft={};q(Xe,(_t,Ct)=>{let Pt;(Pt=Le(_t,Ct,ge))!==!1&&(ft[Ct]=Pt||_t)}),Object.defineProperties(ge,ft)},Ie="abcdefghijklmnopqrstuvwxyz",at="0123456789",je={DIGIT:at,ALPHA:Ie,ALPHA_DIGIT:Ie+Ie.toUpperCase()+at},ht=P("AsyncFunction"),_e={isArray:I,isArrayBuffer:O,isBuffer:function(ge){return ge!==null&&!x(ge)&&ge.constructor!==null&&!x(ge.constructor)&&J(ge.constructor.isBuffer)&&ge.constructor.isBuffer(ge)},isFormData:ge=>{let Le;return ge&&(typeof FormData=="function"&&ge instanceof FormData||J(ge.append)&&((Le=R(ge))==="formdata"||Le==="object"&&J(ge.toString)&&ge.toString()==="[object FormData]"))},isArrayBufferView:function(ge){let Le;return Le=typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(ge):ge&&ge.buffer&&O(ge.buffer),Le},isString:G,isNumber:te,isBoolean:ge=>ge===!0||ge===!1,isObject:le,isPlainObject:ne,isUndefined:x,isDate:ee,isFile:M,isBlob:Y,isRegExp:Ee,isFunction:J,isStream:ge=>le(ge)&&J(ge.pipe),isURLSearchParams:z,isTypedArray:he,isFileList:j,forEach:q,merge:function ge(){const{caseless:Le}=oe(this)&&this||{},Xe={},ft=(_t,Ct)=>{const Pt=Le&&Z(Xe,Ct)||Ct;ne(Xe[Pt])&&ne(_t)?Xe[Pt]=ge(Xe[Pt],_t):ne(_t)?Xe[Pt]=ge({},_t):I(_t)?Xe[Pt]=_t.slice():Xe[Pt]=_t};for(let _t=0,Ct=arguments.length;_t (q(Le,(_t,Ct)=>{Xe&&J(_t)?ge[Ct]=w(_t,Xe):ge[Ct]=_t},{allOwnKeys:ft}),ge),trim:ge=>ge.trim?ge.trim():ge.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:ge=>(ge.charCodeAt(0)===65279&&(ge=ge.slice(1)),ge),inherits:(ge,Le,Xe,ft)=>{ge.prototype=Object.create(Le.prototype,ft),ge.prototype.constructor=ge,Object.defineProperty(ge,"super",{value:Le.prototype}),Xe&&Object.assign(ge.prototype,Xe)},toFlatObject:(ge,Le,Xe,ft)=>{let _t,Ct,Pt;const ci={};if(Le=Le||{},ge==null)return Le;do{for(_t=Object.getOwnPropertyNames(ge),Ct=_t.length;Ct-- >0;)Pt=_t[Ct],ft&&!ft(Pt,ge,Le)||ci[Pt]||(Le[Pt]=ge[Pt],ci[Pt]=!0);ge=Xe!==!1&&D(ge)}while(ge&&(!Xe||Xe(ge,Le))&&ge!==Object.prototype);return Le},kindOf:R,kindOfTest:P,endsWith:(ge,Le,Xe)=>{ge=String(ge),(Xe===void 0||Xe>ge.length)&&(Xe=ge.length),Xe-=Le.length;const ft=ge.indexOf(Le,Xe);return ft!==-1&&ft===Xe},toArray:ge=>{if(!ge)return null;if(I(ge))return ge;let Le=ge.length;if(!te(Le))return null;const Xe=new Array(Le);for(;Le-- >0;)Xe[Le]=ge[Le];return Xe},forEachEntry:(ge,Le)=>{const Xe=(ge&&ge[Symbol.iterator]).call(ge);let ft;for(;(ft=Xe.next())&&!ft.done;){const _t=ft.value;Le.call(ge,_t[0],_t[1])}},matchAll:(ge,Le)=>{let Xe;const ft=[];for(;(Xe=ge.exec(Le))!==null;)ft.push(Xe);return ft},isHTMLForm:fe,hasOwnProperty:se,hasOwnProp:se,reduceDescriptors:He,freezeMethods:ge=>{He(ge,(Le,Xe)=>{if(J(ge)&&["arguments","caller","callee"].indexOf(Xe)!==-1)return!1;const ft=ge[Xe];J(ft)&&(Le.enumerable=!1,"writable"in Le?Le.writable=!1:Le.set||(Le.set=()=>{throw Error("Can not rewrite read-only method '"+Xe+"'")}))})},toObjectSet:(ge,Le)=>{const Xe={},ft=_t=>{_t.forEach(Ct=>{Xe[Ct]=!0})};return I(ge)?ft(ge):ft(String(ge).split(Le)),Xe},toCamelCase:ge=>ge.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(Le,Xe,ft){return Xe.toUpperCase()+ft}),noop:()=>{},toFiniteNumber:(ge,Le)=>(ge=+ge,Number.isFinite(ge)?ge:Le),findKey:Z,global:X,isContextDefined:oe,ALPHABET:je,generateString:(ge=16,Le=je.ALPHA_DIGIT)=>{let Xe="";const{length:ft}=Le;for(;ge--;)Xe+=Le[Math.random()*ft|0];return Xe},isSpecCompliantForm:function(ge){return!!(ge&&J(ge.append)&&ge[Symbol.toStringTag]==="FormData"&&ge[Symbol.iterator])},toJSONObject:ge=>{const Le=new Array(10),Xe=(ft,_t)=>{if(le(ft)){if(Le.indexOf(ft)>=0)return;if(!("toJSON"in ft)){Le[_t]=ft;const Ct=I(ft)?[]:{};return q(ft,(Pt,ci)=>{const hi=Xe(Pt,_t+1);!x(hi)&&(Ct[ci]=hi)}),Le[_t]=void 0,Ct}}return ft};return Xe(ge,0)},isAsyncFn:ht,isThenable:ge=>ge&&(le(ge)||J(ge))&&J(ge.then)&&J(ge.catch)};function Oe(ge,Le,Xe,ft,_t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=ge,this.name="AxiosError",Le&&(this.code=Le),Xe&&(this.config=Xe),ft&&(this.request=ft),_t&&(this.response=_t)}_e.inherits(Oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_e.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const pt=Oe.prototype,vt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(ge=>{vt[ge]={value:ge}}),Object.defineProperties(Oe,vt),Object.defineProperty(pt,"isAxiosError",{value:!0}),Oe.from=(ge,Le,Xe,ft,_t,Ct)=>{const Pt=Object.create(pt);return _e.toFlatObject(ge,Pt,function(ci){return ci!==Error.prototype},ci=>ci!=="isAxiosError"),Oe.call(Pt,ge.message,Le,Xe,ft,_t),Pt.cause=ge,Pt.name=ge.name,Ct&&Object.assign(Pt,Ct),Pt};const tt=Oe;function pe(ge){return _e.isPlainObject(ge)||_e.isArray(ge)}function ue(ge){return _e.endsWith(ge,"[]")?ge.slice(0,-2):ge}function W(ge,Le,Xe){return ge?ge.concat(Le).map(function(ft,_t){return ft=ue(ft),!Xe&&_t?"["+ft+"]":ft}).join(Xe?".":""):Le}const ke=_e.toFlatObject(_e,{},null,function(ge){return/^is[A-Z]/.test(ge)}),Ae=function(ge,Le,Xe){if(!_e.isObject(ge))throw new TypeError("target must be an object");Le=Le||new FormData;const ft=(Xe=_e.toFlatObject(Xe,{metaTokens:!0,dots:!1,indexes:!1},!1,function(bi,pi){return!_e.isUndefined(pi[bi])})).metaTokens,_t=Xe.visitor||Xt,Ct=Xe.dots,Pt=Xe.indexes,ci=(Xe.Blob||typeof Blob<"u"&&Blob)&&_e.isSpecCompliantForm(Le);if(!_e.isFunction(_t))throw new TypeError("visitor must be a function");function hi(bi){if(bi===null)return"";if(_e.isDate(bi))return bi.toISOString();if(!ci&&_e.isBlob(bi))throw new tt("Blob is not supported. Use a Buffer instead.");return _e.isArrayBuffer(bi)||_e.isTypedArray(bi)?ci&&typeof Blob=="function"?new Blob([bi]):Buffer.from(bi):bi}function Xt(bi,pi,Di){let On=bi;if(bi&&!Di&&typeof bi=="object"){if(_e.endsWith(pi,"{}"))pi=ft?pi:pi.slice(0,-2),bi=JSON.stringify(bi);else if(_e.isArray(bi)&&function(Ji){return _e.isArray(Ji)&&!Ji.some(pe)}(bi)||(_e.isFileList(bi)||_e.endsWith(pi,"[]"))&&(On=_e.toArray(bi)))return pi=ue(pi),On.forEach(function(Ji,tn){!_e.isUndefined(Ji)&&Ji!==null&&Le.append(Pt===!0?W([pi],tn,Ct):Pt===null?pi:pi+"[]",hi(Ji))}),!1}return!!pe(bi)||(Le.append(W(Di,pi,Ct),hi(bi)),!1)}const _i=[],Ui=Object.assign(ke,{defaultVisitor:Xt,convertValue:hi,isVisitable:pe});if(!_e.isObject(ge))throw new TypeError("data must be an object");return function bi(pi,Di){if(!_e.isUndefined(pi)){if(_i.indexOf(pi)!==-1)throw Error("Circular reference detected in "+Di.join("."));_i.push(pi),_e.forEach(pi,function(On,Ji){(!(_e.isUndefined(On)||On===null)&&_t.call(Le,On,_e.isString(Ji)?Ji.trim():Ji,Di,Ui))===!0&&bi(On,Di?Di.concat(Ji):[Ji])}),_i.pop()}}(ge),Le};function Ye(ge){const Le={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(ge).replace(/[!'()~]|%20|%00/g,function(Xe){return Le[Xe]})}function lt(ge,Le){this._pairs=[],ge&&Ae(ge,this,Le)}const mt=lt.prototype;mt.append=function(ge,Le){this._pairs.push([ge,Le])},mt.toString=function(ge){const Le=ge?function(Xe){return ge.call(this,Xe,Ye)}:Ye;return this._pairs.map(function(Xe){return Le(Xe[0])+"="+Le(Xe[1])},"").join("&")};const Ue=lt;function Ve(ge){return encodeURIComponent(ge).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function De(ge,Le,Xe){if(!Le)return ge;const ft=Xe&&Xe.encode||Ve,_t=Xe&&Xe.serialize;let Ct;if(Ct=_t?_t(Le,Xe):_e.isURLSearchParams(Le)?Le.toString():new Ue(Le,Xe).toString(ft),Ct){const Pt=ge.indexOf("#");Pt!==-1&&(ge=ge.slice(0,Pt)),ge+=(ge.indexOf("?")===-1?"?":"&")+Ct}return ge}const Re=class{constructor(){this.handlers=[]}use(ge,Le,Xe){return this.handlers.push({fulfilled:ge,rejected:Le,synchronous:!!Xe&&Xe.synchronous,runWhen:Xe?Xe.runWhen:null}),this.handlers.length-1}eject(ge){this.handlers[ge]&&(this.handlers[ge]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(ge){_e.forEach(this.handlers,function(Le){Le!==null&&ge(Le)})}},ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ue,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},isStandardBrowserEnv:(()=>{let ge;return(typeof navigator>"u"||(ge=navigator.product)!=="ReactNative"&&ge!=="NativeScript"&&ge!=="NS")&&typeof window<"u"&&typeof document<"u"})(),isStandardBrowserWebWorkerEnv:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",protocols:["http","https","file","blob","url","data"]},Ce=function(ge){function Le(Xe,ft,_t,Ct){let Pt=Xe[Ct++];const ci=Number.isFinite(+Pt),hi=Ct>=Xe.length;return Pt=!Pt&&_e.isArray(_t)?_t.length:Pt,hi?(_e.hasOwnProp(_t,Pt)?_t[Pt]=[_t[Pt],ft]:_t[Pt]=ft,!ci):(_t[Pt]&&_e.isObject(_t[Pt])||(_t[Pt]=[]),Le(Xe,ft,_t[Pt],Ct)&&_e.isArray(_t[Pt])&&(_t[Pt]=function(Xt){const _i={},Ui=Object.keys(Xt);let bi;const pi=Ui.length;let Di;for(bi=0;bi {Le(function(Ct){return _e.matchAll(/\w+|\[(\w*)]/g,Ct).map(Pt=>Pt[0]==="[]"?"":Pt[1]||Pt[0])}(ft),_t,Xe,0)}),Xe}return null},ze={transitional:ut,adapter:["xhr","http"],transformRequest:[function(ge,Le){const Xe=Le.getContentType()||"",ft=Xe.indexOf("application/json")>-1,_t=_e.isObject(ge);if(_t&&_e.isHTMLForm(ge)&&(ge=new FormData(ge)),_e.isFormData(ge))return ft&&ft?JSON.stringify(Ce(ge)):ge;if(_e.isArrayBuffer(ge)||_e.isBuffer(ge)||_e.isStream(ge)||_e.isFile(ge)||_e.isBlob(ge))return ge;if(_e.isArrayBufferView(ge))return ge.buffer;if(_e.isURLSearchParams(ge))return Le.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),ge.toString();let Ct;if(_t){if(Xe.indexOf("application/x-www-form-urlencoded")>-1)return function(Pt,ci){return Ae(Pt,new gt.classes.URLSearchParams,Object.assign({visitor:function(hi,Xt,_i,Ui){return gt.isNode&&_e.isBuffer(hi)?(this.append(Xt,hi.toString("base64")),!1):Ui.defaultVisitor.apply(this,arguments)}},ci))}(ge,this.formSerializer).toString();if((Ct=_e.isFileList(ge))||Xe.indexOf("multipart/form-data")>-1){const Pt=this.env&&this.env.FormData;return Ae(Ct?{"files[]":ge}:ge,Pt&&new Pt,this.formSerializer)}}return _t||ft?(Le.setContentType("application/json",!1),function(Pt,ci,hi){if(_e.isString(Pt))try{return(ci||JSON.parse)(Pt),_e.trim(Pt)}catch(Xt){if(Xt.name!=="SyntaxError")throw Xt}return(hi||JSON.stringify)(Pt)}(ge)):ge}],transformResponse:[function(ge){const Le=this.transitional||ze.transitional,Xe=Le&&Le.forcedJSONParsing,ft=this.responseType==="json";if(ge&&_e.isString(ge)&&(Xe&&!this.responseType||ft)){const _t=!(Le&&Le.silentJSONParsing)&&ft;try{return JSON.parse(ge)}catch(Ct){if(_t)throw Ct.name==="SyntaxError"?tt.from(Ct,tt.ERR_BAD_RESPONSE,this,null,this.response):Ct}}return ge}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(ge){return ge>=200&&ge<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_e.forEach(["delete","get","head","post","put","patch"],ge=>{ze.headers[ge]={}});const At=ze,Je=_e.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=Symbol("internals");function Be(ge){return ge&&String(ge).trim().toLowerCase()}function it(ge){return ge===!1||ge==null?ge:_e.isArray(ge)?ge.map(it):String(ge)}function Ne(ge,Le,Xe,ft,_t){return _e.isFunction(ft)?ft.call(this,Le,Xe):(_t&&(Le=Xe),_e.isString(Le)?_e.isString(ft)?Le.indexOf(ft)!==-1:_e.isRegExp(ft)?ft.test(Le):void 0:void 0)}class Qe{constructor(Le){Le&&this.set(Le)}set(Le,Xe,ft){const _t=this;function Ct(ci,hi,Xt){const _i=Be(hi);if(!_i)throw new Error("header name must be a non-empty string");const Ui=_e.findKey(_t,_i);(!Ui||_t[Ui]===void 0||Xt===!0||Xt===void 0&&_t[Ui]!==!1)&&(_t[Ui||hi]=it(ci))}const Pt=(ci,hi)=>_e.forEach(ci,(Xt,_i)=>Ct(Xt,_i,hi));return _e.isPlainObject(Le)||Le instanceof this.constructor?Pt(Le,Xe):_e.isString(Le)&&(Le=Le.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(Le.trim())?Pt((ci=>{const hi={};let Xt,_i,Ui;return ci&&ci.split(` `).forEach(function(bi){Ui=bi.indexOf(":"),Xt=bi.substring(0,Ui).trim().toLowerCase(),_i=bi.substring(Ui+1).trim(),!Xt||hi[Xt]&&Je[Xt]||(Xt==="set-cookie"?hi[Xt]?hi[Xt].push(_i):hi[Xt]=[_i]:hi[Xt]=hi[Xt]?hi[Xt]+", "+_i:_i)}),hi})(Le),Xe):Le!=null&&Ct(Xe,Le,ft),this}get(Le,Xe){if(Le=Be(Le)){const ft=_e.findKey(this,Le);if(ft){const _t=this[ft];if(!Xe)return _t;if(Xe===!0)return function(Ct){const Pt=Object.create(null),ci=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let hi;for(;hi=ci.exec(Ct);)Pt[hi[1]]=hi[2];return Pt}(_t);if(_e.isFunction(Xe))return Xe.call(this,_t,ft);if(_e.isRegExp(Xe))return Xe.exec(_t);throw new TypeError("parser must be boolean|regexp|function")}}}has(Le,Xe){if(Le=Be(Le)){const ft=_e.findKey(this,Le);return!(!ft||this[ft]===void 0||Xe&&!Ne(0,this[ft],ft,Xe))}return!1}delete(Le,Xe){const ft=this;let _t=!1;function Ct(Pt){if(Pt=Be(Pt)){const ci=_e.findKey(ft,Pt);!ci||Xe&&!Ne(0,ft[ci],ci,Xe)||(delete ft[ci],_t=!0)}}return _e.isArray(Le)?Le.forEach(Ct):Ct(Le),_t}clear(Le){const Xe=Object.keys(this);let ft=Xe.length,_t=!1;for(;ft--;){const Ct=Xe[ft];Le&&!Ne(0,this[Ct],Ct,Le,!0)||(delete this[Ct],_t=!0)}return _t}normalize(Le){const Xe=this,ft={};return _e.forEach(this,(_t,Ct)=>{const Pt=_e.findKey(ft,Ct);if(Pt)return Xe[Pt]=it(_t),void delete Xe[Ct];const ci=Le?function(hi){return hi.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(Xt,_i,Ui)=>_i.toUpperCase()+Ui)}(Ct):String(Ct).trim();ci!==Ct&&delete Xe[Ct],Xe[ci]=it(_t),ft[ci]=!0}),this}concat(...Le){return this.constructor.concat(this,...Le)}toJSON(Le){const Xe=Object.create(null);return _e.forEach(this,(ft,_t)=>{ft!=null&&ft!==!1&&(Xe[_t]=Le&&_e.isArray(ft)?ft.join(", "):ft)}),Xe}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([Le,Xe])=>Le+": "+Xe).join(` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(Le){return Le instanceof this?Le:new this(Le)}static concat(Le,...Xe){const ft=new this(Le);return Xe.forEach(_t=>ft.set(_t)),ft}static accessor(Le){const Xe=(this[$e]=this[$e]={accessors:{}}).accessors,ft=this.prototype;function _t(Ct){const Pt=Be(Ct);Xe[Pt]||(function(ci,hi){const Xt=_e.toCamelCase(" "+hi);["get","set","has"].forEach(_i=>{Object.defineProperty(ci,_i+Xt,{value:function(Ui,bi,pi){return this[_i].call(this,hi,Ui,bi,pi)},configurable:!0})})}(ft,Ct),Xe[Pt]=!0)}return _e.isArray(Le)?Le.forEach(_t):_t(Le),this}}Qe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_e.reduceDescriptors(Qe.prototype,({value:ge},Le)=>{let Xe=Le[0].toUpperCase()+Le.slice(1);return{get:()=>ge,set(ft){this[Xe]=ft}}}),_e.freezeMethods(Qe);const Me=Qe;function Se(ge,Le){const Xe=this||At,ft=Le||Xe,_t=Me.from(ft.headers);let Ct=ft.data;return _e.forEach(ge,function(Pt){Ct=Pt.call(Xe,Ct,_t.normalize(),Le?Le.status:void 0)}),_t.normalize(),Ct}function K(ge){return!(!ge||!ge.__CANCEL__)}function xe(ge,Le,Xe){tt.call(this,ge??"canceled",tt.ERR_CANCELED,Le,Xe),this.name="CanceledError"}_e.inherits(xe,tt,{__CANCEL__:!0});const be=xe,Te=gt.isStandardBrowserEnv?{write:function(ge,Le,Xe,ft,_t,Ct){const Pt=[];Pt.push(ge+"="+encodeURIComponent(Le)),_e.isNumber(Xe)&&Pt.push("expires="+new Date(Xe).toGMTString()),_e.isString(ft)&&Pt.push("path="+ft),_e.isString(_t)&&Pt.push("domain="+_t),Ct===!0&&Pt.push("secure"),document.cookie=Pt.join("; ")},read:function(ge){const Le=document.cookie.match(new RegExp("(^|;\\s*)("+ge+")=([^;]*)"));return Le?decodeURIComponent(Le[3]):null},remove:function(ge){this.write(ge,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function V(ge,Le){return ge&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(Le)?function(Xe,ft){return ft?Xe.replace(/\/+$/,"")+"/"+ft.replace(/^\/+/,""):Xe}(ge,Le):Le}const N=gt.isStandardBrowserEnv?function(){const ge=/(msie|trident)/i.test(navigator.userAgent),Le=document.createElement("a");let Xe;function ft(_t){let Ct=_t;return ge&&(Le.setAttribute("href",Ct),Ct=Le.href),Le.setAttribute("href",Ct),{href:Le.href,protocol:Le.protocol?Le.protocol.replace(/:$/,""):"",host:Le.host,search:Le.search?Le.search.replace(/^\?/,""):"",hash:Le.hash?Le.hash.replace(/^#/,""):"",hostname:Le.hostname,port:Le.port,pathname:Le.pathname.charAt(0)==="/"?Le.pathname:"/"+Le.pathname}}return Xe=ft(window.location.href),function(_t){const Ct=_e.isString(_t)?ft(_t):_t;return Ct.protocol===Xe.protocol&&Ct.host===Xe.host}}():function(){return!0},S=function(ge,Le){ge=ge||10;const Xe=new Array(ge),ft=new Array(ge);let _t,Ct=0,Pt=0;return Le=Le!==void 0?Le:1e3,function(ci){const hi=Date.now(),Xt=ft[Pt];_t||(_t=hi),Xe[Ct]=ci,ft[Ct]=hi;let _i=Pt,Ui=0;for(;_i!==Ct;)Ui+=Xe[_i++],_i%=ge;if(Ct=(Ct+1)%ge,Ct===Pt&&(Pt=(Pt+1)%ge),hi-_t {const Ct=_t.loaded,Pt=_t.lengthComputable?_t.total:void 0,ci=Ct-Xe,hi=ft(ci);Xe=Ct;const Xt={loaded:Ct,total:Pt,progress:Pt?Ct/Pt:void 0,bytes:ci,rate:hi||void 0,estimated:hi&&Pt&&Ct<=Pt?(Pt-Ct)/hi:void 0,event:_t};Xt[Le?"download":"upload"]=!0,ge(Xt)}}const re={http:null,xhr:typeof XMLHttpRequest<"u"&&function(ge){return new Promise(function(Le,Xe){let ft=ge.data;const _t=Me.from(ge.headers).normalize(),Ct=ge.responseType;let Pt,ci;function hi(){ge.cancelToken&&ge.cancelToken.unsubscribe(Pt),ge.signal&&ge.signal.removeEventListener("abort",Pt)}_e.isFormData(ft)&&(gt.isStandardBrowserEnv||gt.isStandardBrowserWebWorkerEnv?_t.setContentType(!1):_t.getContentType(/^\s*multipart\/form-data/)?_e.isString(ci=_t.getContentType())&&_t.setContentType(ci.replace(/^\s*(multipart\/form-data);+/,"$1")):_t.setContentType("multipart/form-data"));let Xt=new XMLHttpRequest;if(ge.auth){const pi=ge.auth.username||"",Di=ge.auth.password?unescape(encodeURIComponent(ge.auth.password)):"";_t.set("Authorization","Basic "+btoa(pi+":"+Di))}const _i=V(ge.baseURL,ge.url);function Ui(){if(!Xt)return;const pi=Me.from("getAllResponseHeaders"in Xt&&Xt.getAllResponseHeaders());(function(Di,On,Ji){const tn=Ji.config.validateStatus;Ji.status&&tn&&!tn(Ji.status)?On(new tt("Request failed with status code "+Ji.status,[tt.ERR_BAD_REQUEST,tt.ERR_BAD_RESPONSE][Math.floor(Ji.status/100)-4],Ji.config,Ji.request,Ji)):Di(Ji)})(function(Di){Le(Di),hi()},function(Di){Xe(Di),hi()},{data:Ct&&Ct!=="text"&&Ct!=="json"?Xt.response:Xt.responseText,status:Xt.status,statusText:Xt.statusText,headers:pi,config:ge,request:Xt}),Xt=null}if(Xt.open(ge.method.toUpperCase(),De(_i,ge.params,ge.paramsSerializer),!0),Xt.timeout=ge.timeout,"onloadend"in Xt?Xt.onloadend=Ui:Xt.onreadystatechange=function(){Xt&&Xt.readyState===4&&(Xt.status!==0||Xt.responseURL&&Xt.responseURL.indexOf("file:")===0)&&setTimeout(Ui)},Xt.onabort=function(){Xt&&(Xe(new tt("Request aborted",tt.ECONNABORTED,ge,Xt)),Xt=null)},Xt.onerror=function(){Xe(new tt("Network Error",tt.ERR_NETWORK,ge,Xt)),Xt=null},Xt.ontimeout=function(){let pi=ge.timeout?"timeout of "+ge.timeout+"ms exceeded":"timeout exceeded";const Di=ge.transitional||ut;ge.timeoutErrorMessage&&(pi=ge.timeoutErrorMessage),Xe(new tt(pi,Di.clarifyTimeoutError?tt.ETIMEDOUT:tt.ECONNABORTED,ge,Xt)),Xt=null},gt.isStandardBrowserEnv){const pi=N(_i)&&ge.xsrfCookieName&&Te.read(ge.xsrfCookieName);pi&&_t.set(ge.xsrfHeaderName,pi)}ft===void 0&&_t.setContentType(null),"setRequestHeader"in Xt&&_e.forEach(_t.toJSON(),function(pi,Di){Xt.setRequestHeader(Di,pi)}),_e.isUndefined(ge.withCredentials)||(Xt.withCredentials=!!ge.withCredentials),Ct&&Ct!=="json"&&(Xt.responseType=ge.responseType),typeof ge.onDownloadProgress=="function"&&Xt.addEventListener("progress",F(ge.onDownloadProgress,!0)),typeof ge.onUploadProgress=="function"&&Xt.upload&&Xt.upload.addEventListener("progress",F(ge.onUploadProgress)),(ge.cancelToken||ge.signal)&&(Pt=pi=>{Xt&&(Xe(!pi||pi.type?new be(null,ge,Xt):pi),Xt.abort(),Xt=null)},ge.cancelToken&&ge.cancelToken.subscribe(Pt),ge.signal&&(ge.signal.aborted?Pt():ge.signal.addEventListener("abort",Pt)));const bi=function(pi){const Di=/^([-+\w]{1,25})(:?\/\/|:)/.exec(pi);return Di&&Di[1]||""}(_i);bi&>.protocols.indexOf(bi)===-1?Xe(new tt("Unsupported protocol "+bi+":",tt.ERR_BAD_REQUEST,ge)):Xt.send(ft||null)})}};_e.forEach(re,(ge,Le)=>{if(ge){try{Object.defineProperty(ge,"name",{value:Le})}catch{}Object.defineProperty(ge,"adapterName",{value:Le})}});const ce=ge=>`- ${ge}`,me=ge=>_e.isFunction(ge)||ge===null||ge===!1,ye=ge=>{ge=_e.isArray(ge)?ge:[ge];const{length:Le}=ge;let Xe,ft;const _t={};for(let Ct=0;Ct `adapter ${ci} `+(hi===!1?"is not supported by the environment":"is not available in the build"));let Pt=Le?Ct.length>1?`since : `+Ct.map(ce).join(` -`):" "+ce(Ct[0]):"as no adapter specified";throw new tt("There is no suitable adapter to dispatch the request "+Pt,"ERR_NOT_SUPPORT")}return ft};function Pe(ge){if(ge.cancelToken&&ge.cancelToken.throwIfRequested(),ge.signal&&ge.signal.aborted)throw new be(null,ge)}function We(ge){return Pe(ge),ge.headers=Me.from(ge.headers),ge.data=Se.call(ge,ge.transformRequest),["post","put","patch"].indexOf(ge.method)!==-1&&ge.headers.setContentType("application/x-www-form-urlencoded",!1),ye(ge.adapter||At.adapter)(ge).then(function(Le){return Pe(ge),Le.data=Se.call(ge,ge.transformResponse,Le),Le.headers=Me.from(Le.headers),Le},function(Le){return K(Le)||(Pe(ge),Le&&Le.response&&(Le.response.data=Se.call(ge,ge.transformResponse,Le.response),Le.response.headers=Me.from(Le.response.headers))),Promise.reject(Le)})}const nt=ge=>ge instanceof Me?ge.toJSON():ge;function et(ge,Le){Le=Le||{};const Xe={};function ft(Xt,_i,Ui){return _e.isPlainObject(Xt)&&_e.isPlainObject(_i)?_e.merge.call({caseless:Ui},Xt,_i):_e.isPlainObject(_i)?_e.merge({},_i):_e.isArray(_i)?_i.slice():_i}function _t(Xt,_i,Ui){return _e.isUndefined(_i)?_e.isUndefined(Xt)?void 0:ft(void 0,Xt,Ui):ft(Xt,_i,Ui)}function Ct(Xt,_i){if(!_e.isUndefined(_i))return ft(void 0,_i)}function Pt(Xt,_i){return _e.isUndefined(_i)?_e.isUndefined(Xt)?void 0:ft(void 0,Xt):ft(void 0,_i)}function ci(Xt,_i,Ui){return Ui in Le?ft(Xt,_i):Ui in ge?ft(void 0,Xt):void 0}const hi={url:Ct,method:Ct,data:Ct,baseURL:Pt,transformRequest:Pt,transformResponse:Pt,paramsSerializer:Pt,timeout:Pt,timeoutMessage:Pt,withCredentials:Pt,adapter:Pt,responseType:Pt,xsrfCookieName:Pt,xsrfHeaderName:Pt,onUploadProgress:Pt,onDownloadProgress:Pt,decompress:Pt,maxContentLength:Pt,maxBodyLength:Pt,beforeRedirect:Pt,transport:Pt,httpAgent:Pt,httpsAgent:Pt,cancelToken:Pt,socketPath:Pt,responseEncoding:Pt,validateStatus:ci,headers:(Xt,_i)=>_t(nt(Xt),nt(_i),!0)};return _e.forEach(Object.keys(Object.assign({},ge,Le)),function(Xt){const _i=hi[Xt]||_t,Ui=_i(ge[Xt],Le[Xt],Xt);_e.isUndefined(Ui)&&_i!==ci||(Xe[Xt]=Ui)}),Xe}const ot="1.6.0",dt={};["object","boolean","number","function","string","symbol"].forEach((ge,Le)=>{dt[ge]=function(Xe){return typeof Xe===ge||"a"+(Le<1?"n ":" ")+ge}});const yt={};dt.transitional=function(ge,Le,Xe){function ft(_t,Ct){return"[Axios v1.6.0] Transitional option '"+_t+"'"+Ct+(Xe?". "+Xe:"")}return(_t,Ct,Pt)=>{if(ge===!1)throw new tt(ft(Ct," has been removed"+(Le?" in "+Le:"")),tt.ERR_DEPRECATED);return Le&&!yt[Ct]&&(yt[Ct]=!0,console.warn(ft(Ct," has been deprecated since v"+Le+" and will be removed in the near future"))),!ge||ge(_t,Ct,Pt)}};const wt={assertOptions:function(ge,Le,Xe){if(typeof ge!="object")throw new tt("options must be an object",tt.ERR_BAD_OPTION_VALUE);const ft=Object.keys(ge);let _t=ft.length;for(;_t-- >0;){const Ct=ft[_t],Pt=Le[Ct];if(Pt){const ci=ge[Ct],hi=ci===void 0||Pt(ci,Ct,ge);if(hi!==!0)throw new tt("option "+Ct+" must be "+hi,tt.ERR_BAD_OPTION_VALUE)}else if(Xe!==!0)throw new tt("Unknown option "+Ct,tt.ERR_BAD_OPTION)}},validators:dt},bt=wt.validators;class Rt{constructor(Le){this.defaults=Le,this.interceptors={request:new Re,response:new Re}}request(Le,Xe){typeof Le=="string"?(Xe=Xe||{}).url=Le:Xe=Le||{},Xe=et(this.defaults,Xe);const{transitional:ft,paramsSerializer:_t,headers:Ct}=Xe;ft!==void 0&&wt.assertOptions(ft,{silentJSONParsing:bt.transitional(bt.boolean),forcedJSONParsing:bt.transitional(bt.boolean),clarifyTimeoutError:bt.transitional(bt.boolean)},!1),_t!=null&&(_e.isFunction(_t)?Xe.paramsSerializer={serialize:_t}:wt.assertOptions(_t,{encode:bt.function,serialize:bt.function},!0)),Xe.method=(Xe.method||this.defaults.method||"get").toLowerCase();let Pt=Ct&&_e.merge(Ct.common,Ct[Xe.method]);Ct&&_e.forEach(["delete","get","head","post","put","patch","common"],Di=>{delete Ct[Di]}),Xe.headers=Me.concat(Pt,Ct);const ci=[];let hi=!0;this.interceptors.request.forEach(function(Di){typeof Di.runWhen=="function"&&Di.runWhen(Xe)===!1||(hi=hi&&Di.synchronous,ci.unshift(Di.fulfilled,Di.rejected))});const Xt=[];let _i;this.interceptors.response.forEach(function(Di){Xt.push(Di.fulfilled,Di.rejected)});let Ui,bi=0;if(!hi){const Di=[We.bind(this),void 0];for(Di.unshift.apply(Di,ci),Di.push.apply(Di,Xt),Ui=Di.length,_i=Promise.resolve(Xe);bi {if(!ft._listeners)return;let Ct=ft._listeners.length;for(;Ct-- >0;)ft._listeners[Ct](_t);ft._listeners=null}),this.promise.then=_t=>{let Ct;const Pt=new Promise(ci=>{ft.subscribe(ci),Ct=ci}).then(_t);return Pt.cancel=function(){ft.unsubscribe(Ct)},Pt},Le(function(_t,Ct,Pt){ft.reason||(ft.reason=new be(_t,Ct,Pt),Xe(ft.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(Le){this.reason?Le(this.reason):this._listeners?this._listeners.push(Le):this._listeners=[Le]}unsubscribe(Le){if(!this._listeners)return;const Xe=this._listeners.indexOf(Le);Xe!==-1&&this._listeners.splice(Xe,1)}static source(){let Le;return{token:new Tt(function(Xe){Le=Xe}),cancel:Le}}}const xt=Tt,Ut={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ut).forEach(([ge,Le])=>{Ut[Le]=ge});const Vt=Ut,Bt=function ge(Le){const Xe=new Lt(Le),ft=w(Lt.prototype.request,Xe);return _e.extend(ft,Lt.prototype,Xe,{allOwnKeys:!0}),_e.extend(ft,Xe,null,{allOwnKeys:!0}),ft.create=function(_t){return ge(et(Le,_t))},ft}(At);Bt.Axios=Lt,Bt.CanceledError=be,Bt.CancelToken=xt,Bt.isCancel=K,Bt.VERSION=ot,Bt.toFormData=Ae,Bt.AxiosError=tt,Bt.Cancel=Bt.CanceledError,Bt.all=function(ge){return Promise.all(ge)},Bt.spread=function(ge){return function(Le){return ge.apply(null,Le)}},Bt.isAxiosError=function(ge){return _e.isObject(ge)&&ge.isAxiosError===!0},Bt.mergeConfig=et,Bt.AxiosHeaders=Me,Bt.formToJSON=ge=>Ce(_e.isHTMLForm(ge)?new FormData(ge):ge),Bt.getAdapter=ye,Bt.HttpStatusCode=Vt,Bt.default=Bt;const jt=Bt;var Mt=y(662);const Ot=/iPhone|iPad|iPod|Windows|Macintosh|Android|Mobile/i.test(navigator.userAgent)&&"ontouchend"in document,Jt={secondToTime:ge=>{if((ge=ge||0)===0||ge===1/0||ge.toString()==="NaN")return"00:00";const Le=Math.floor(ge/3600),Xe=Math.floor((ge-3600*Le)/60),ft=Math.floor(ge-3600*Le-60*Xe);return(Le>0?[Le,Xe,ft]:[Xe,ft]).map(_t=>_t<10?"0"+_t:""+_t).join(":")},getVideoDuration:(ge,Le)=>{let Xe=ge.duration;return Xe===1/0&&(ge.seekable.length>0?(Le.dtime.textContent=Jt.secondToTime(ge.seekable.end(0)),Xe=ge.seekable.end(0)):ge.buffered.length>0&&(Le.dtime.textContent=Jt.secondToTime(ge.buffered.end(0)),Xe=ge.buffered.end(0))),Xe},getElementViewLeft:ge=>{let Le=ge.offsetLeft,Xe=ge.offsetParent;const ft=document.body.scrollLeft+document.documentElement.scrollLeft;if(document.fullscreenElement||document.webkitFullscreenElement)for(;Xe!==null&&Xe!==ge;)Le+=Xe.offsetLeft,Xe=Xe.offsetParent;else for(;Xe!==null;)Le+=Xe.offsetLeft,Xe=Xe.offsetParent;return Le-ft},getBoundingClientRectViewLeft(ge){const Le=window.scrollY||window.pageYOffset||document.body.scrollTop+(document.documentElement&&document.documentElement.scrollTop||0);if(ge.getBoundingClientRect){if(typeof this.getBoundingClientRectViewLeft.offset!="number"){let _t=document.createElement("div");_t.style.cssText="position:absolute;top:0;left:0;",document.body.appendChild(_t),this.getBoundingClientRectViewLeft.offset=-_t.getBoundingClientRect().top-Le,document.body.removeChild(_t),_t=null}const Xe=ge.getBoundingClientRect(),ft=this.getBoundingClientRectViewLeft.offset;return Xe.left+ft}return this.getElementViewLeft(ge)},getScrollPosition:()=>({left:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0}),setScrollPosition({left:ge=0,top:Le=0}){this.isFirefox?(document.documentElement.scrollLeft=ge,document.documentElement.scrollTop=Le):window.scrollTo(ge,Le)},isMobile:Ot,isFirefox:/firefox/i.test(window.navigator.userAgent),isChrome:/chrome/i.test(window.navigator.userAgent),storage:{set:(ge,Le)=>{localStorage.setItem(ge,Le)},get:ge=>localStorage.getItem(ge)},nameMap:{dragStart:Ot?"touchstart":"mousedown",dragMove:Ot?"touchmove":"mousemove",dragEnd:Ot?"touchend":"mouseup"},color2Number:ge=>(ge[0]==="#"&&(ge=ge.substr(1)),ge.length===3&&(ge=`${ge[0]}${ge[0]}${ge[1]}${ge[1]}${ge[2]}${ge[2]}`),parseInt(ge,16)+0&16777215),number2Color:ge=>"#"+("00000"+ge.toString(16)).slice(-6),number2Type:ge=>{switch(ge){case 0:default:return"right";case 1:return"top";case 2:return"bottom"}}},Wt=Jt,di={send:ge=>{ge.url!==void 0?jt.post(ge.url,ge.data).then(Le=>{const Xe=Le.data;Xe&&Xe.code===0?ge.success&&ge.success():ge.error&&ge.error(Xe&&Xe.msg)}).catch(Le=>{console.error(Le),ge.error&&ge.error()}):ge.error&&ge.error()},read:ge=>{ge.url!==void 0?jt.get(ge.url).then(Le=>{const Xe=Le.data;Xe&&Xe.code===0?Xe.data?ge.success&&ge.success(Xe.data.map(ft=>({author:ft[3],time:ft[0],text:ft[4],color:ft[2],type:ft[1],size:ft[5]&&(ft[5]==="big"||ft[5]==="small")?ft[5]:"medium"}))):ge.success&&ge.success([{author:"",time:0,text:"",color:"#ffeaea",type:"right",size:"medium"}]):ge.error&&ge.error(Xe&&Xe.msg)}).catch(Le=>{console.error(Le),ge.error&&ge.error()}):ge.error&&ge.error()}},oi=di,$t={"zh-cn":{"Danmaku is loading":"弹幕加载中",Top:"顶部",Bottom:"底部",Rolling:"滚动",Big:"大的",Medium:"中等的",Small:"小的","Input danmaku, hit Enter":"输入弹幕,回车发送","About author":"关于作者","DPlayer feedback":"播放器意见反馈","About DPlayer":"关于 DPlayer 播放器",Loop:"洗脑循环",Speed:"速度",Audio:"音频","Primary audio":"主要音频","Secondary audio":"辅助音频","Opacity for danmaku":"弹幕透明度",Normal:"正常","Please input danmaku content!":"要输入弹幕内容啊喂!","Set danmaku color":"设置弹幕颜色","Set danmaku type":"设置弹幕类型","Set danmaku size":"设置弹幕大小","Show danmaku":"显示弹幕","Video load failed":"视频加载失败","Danmaku load failed":"弹幕加载失败","Danmaku send failed":"弹幕发送失败","Switching to":"正在切换至","Switched to":"已经切换至",Synchronize:"同步",Synchronized:"同步的",Quality:"画质",quality:"画质",FF:"快进",REW:"快退","Unlimited danmaku":"海量弹幕","Send danmaku":"发送弹幕",Setting:"设置","Full screen":"全屏","Web full screen":"页面全屏","Picture-in-Picture":"子母画面",Send:"发送",Screenshot:"截图",AirPlay:"无线投屏",s:"秒","Show comment":"显示弹幕","Hide comment":"隐藏弹幕","Show subtitle":"显示字幕","Hide subtitle":"隐藏字幕",Volume:"音量",Live:"直播","Video info":"视频统计信息"},"zh-tw":{"Danmaku is loading":"彈幕載入中",Top:"頂部",Bottom:"底部",Rolling:"滾動",Big:"大的",Medium:"中等的",Small:"小的","Input danmaku, hit Enter":"輸入彈幕,Enter 發送","About author":"關於作者","DPlayer feedback":"播放器意見回饋","About DPlayer":"關於 DPlayer 播放器",Loop:"循環播放",Speed:"速度",Audio:"音頻","Primary audio":"主要音頻","Secondary audio":"輔助音頻","Opacity for danmaku":"彈幕透明度",Normal:"正常","Please input danmaku content!":"請輸入彈幕內容啊!","Set danmaku color":"設定彈幕顏色","Set danmaku type":"設定彈幕類型","Set danmaku size":"设置弹幕大小","Show danmaku":"顯示彈幕","Video load failed":"影片載入失敗","Danmaku load failed":"彈幕載入失敗","Danmaku send failed":"彈幕發送失敗","Switching to":"正在切換至","Switched to":"已經切換至",Synchronize:"同步",Synchronized:"同步的",Quality:"畫質",quality:"畫質",FF:"快進",REW:"快退","Unlimited danmaku":"巨量彈幕","Send danmaku":"發送彈幕",Setting:"設定","Full screen":"全螢幕","Web full screen":"頁面全螢幕","Picture-in-Picture":"子母畫面",Send:"發送",Screenshot:"截圖",AirPlay:"無線投屏",s:"秒","Show comment":"顯示彈幕","Hide comment":"隱藏彈幕","Show subtitle":"顯示字幕","Hide subtitle":"隱藏字幕",Volume:"音量",Live:"直播","Video info":"影片統計訊息"},"ja-jp":{"Danmaku is loading":"コメントを読み込み中…",Top:"上固定",Bottom:"下固定",Rolling:"スクロール",Big:"大きめ",Medium:"標準",Small:"小さめ","Input danmaku, hit Enter":"右のボタンを押すとコメントできます","About author":"作者について","DPlayer feedback":"フィードバック","About DPlayer":"DPlayer について",Loop:"リピート再生",Speed:"再生速度",Audio:"音声","Primary audio":"主音声","Secondary audio":"副音声","Opacity for danmaku":"コメントの透明度",Normal:"標準","Please input danmaku content!":"コメント内容を入力して下さい!","Set danmaku color":"コメントの色","Set danmaku type":"コメントの位置","Set danmaku size":"コメントのサイズ","Show danmaku":"コメントを表示","Video load failed":"動画の読み込みに失敗しました…","Danmaku load failed":"コメントの読み込みに失敗しました…","Danmaku send failed":"コメントの送信に失敗しました…","Switching to":"画質を切り替えています…","Switched to":"画質を切り替えました",Synchronize:"同期する",Synchronized:"同期しました",Quality:"画質",quality:"画質",FF:"早送り",REW:"巻き戻し","Unlimited danmaku":"コメントを無制限に表示","Send danmaku":"コメントする",Setting:"設定","Full screen":"フルスクリーン","Web full screen":"ブラウザフルスクリーン","Picture-in-Picture":"Picture-in-Picture",Send:"コメントする",Screenshot:"スクリーンショット",s:"秒","Show comment":"コメントを表示する","Hide comment":"コメントを表示しない","Show subtitle":"字幕を表示する","Hide subtitle":"字幕を表示しない",Volume:"音量",Live:"Live","Video info":"動画の統計情報"}},ui=function(ge){this.lang=ge,this.lang==="ja"&&(this.lang="ja-jp"),this.tran=Le=>$t[this.lang]&&$t[this.lang][Le]?$t[this.lang][Le]:Le};var ti=y(7),li=y.n(ti),wi=y(723),Pi=y.n(wi),mi=y(704),gi=y.n(mi),Kt=y(189),Ii=y.n(Kt),ei=y(848),ji=y.n(ei),Li=y(813),Ti=y.n(Li),Bi=y(480),dn=y.n(Bi),rn=y(241),Un=y.n(rn),on=y(783),gn=y.n(on),An=y(355),tr=y.n(An),Kn=y(531),ir=y.n(Kn),yn=y(863),nr=y.n(yn),rr=y(381),Or=y.n(rr),br=y(243),cr=y.n(br),_r=y(885),Mr=y.n(_r),cs=y(478),sr=y.n(cs),kt=y(916),Gt=y.n(kt),ii=y(310),yi=y.n(ii),Ei=y(409),Mi=y.n(Ei),xi=y(597),Vi=y.n(xi),$i=y(223),pn=y.n($i),ar=y(112),Hn=y.n(ar);const En={play:li(),pause:Pi(),backward:gi(),forward:Ii(),volumeUp:ji(),volumeDown:Ti(),volumeOff:dn(),full:Un(),fullWeb:gn(),pip:tr(),setting:ir(),left:nr(),right:Or(),check:cr(),comment:Mr(),commentOff:sr(),send:Gt(),pallette:yi(),camera:Mi(),subtitle:pn(),loading:Hn(),airplay:Vi()};var Pa=y(368),ds=y.n(Pa);const ha=class{constructor(ge){we(this,"container");we(this,"options");we(this,"index");we(this,"tran");we(this,"volumeBar");we(this,"volumeBarWrap");we(this,"volumeBarWrapWrap");we(this,"volumeButton");we(this,"volumeButtonIcon");we(this,"volumeIcon");we(this,"playedBar");we(this,"loadedBar");we(this,"playedBarWrap");we(this,"playedBarTime");we(this,"danmaku");we(this,"danmakuLoading");we(this,"video");we(this,"bezel");we(this,"playButton");we(this,"mobileBackwardButton");we(this,"mobilePlayButton");we(this,"mobileForwardButton");we(this,"videoWrap");we(this,"videoWrapAspect");we(this,"controllerMask");we(this,"ptime");we(this,"settingButton");we(this,"settingBox");we(this,"settingOriginPanel");we(this,"mask");we(this,"syncButton");we(this,"loop");we(this,"loopToggle");we(this,"showDanmaku");we(this,"showDanmakuToggle");we(this,"unlimitDanmaku");we(this,"unlimitDanmakuToggle");we(this,"quality");we(this,"qualityValue");we(this,"qualityHeader");we(this,"qualityItem");we(this,"speed");we(this,"speedValue");we(this,"speedHeader");we(this,"speedItem");we(this,"audio");we(this,"audioValue");we(this,"audioHeader");we(this,"audioItem");we(this,"danmakuOpacityBar");we(this,"danmakuOpacityBarWrap");we(this,"danmakuOpacityBarWrapWrap");we(this,"danmakuOpacityBox");we(this,"danmakuOpacityValue");we(this,"dtime");we(this,"controller");we(this,"commentInput");we(this,"commentButton");we(this,"commentSettingBox");we(this,"commentSettingButton");we(this,"commentSettingFill");we(this,"commentSendButton");we(this,"commentSendFill");we(this,"commentColorSettingBox");we(this,"browserFullButton");we(this,"webFullButton");we(this,"pipButton");we(this,"menu");we(this,"menuItem");we(this,"cameraButton");we(this,"airplayButton");we(this,"subtitleButton");we(this,"subtitleButtonInner");we(this,"subtitle");we(this,"barPreview");we(this,"barWrap");we(this,"notice");we(this,"infoPanel");we(this,"infoPanelClose");we(this,"infoMimeType");we(this,"infoVersion");we(this,"infoVideoFPS");we(this,"infoPageFPS");we(this,"infoDroppedFrames");we(this,"infoType");we(this,"infoUrl");we(this,"infoResolution");we(this,"infoDuration");we(this,"infoBufferRemain");we(this,"infoDownloadSpeed");this.container=ge.container,this.options=ge.options,this.index=ge.index,this.tran=ge.tran,this.init()}init(){this.container.innerHTML=ds()({options:this.options,index:this.index,tran:this.tran,icons:En,mobile:Wt.isMobile,video:{current:!0,pic:this.options.video.pic,screenshot:this.options.screenshot,airplay:this.options.airplay,preload:this.options.preload,url:this.options.video.type==="live-llhls-for-KonomiTV"?"":this.options.video.url,subtitle:this.options.subtitle,crossOrigin:this.options.crossOrigin}}),this.volumeBar=this.container.querySelector(".dplayer-volume-bar-inner"),this.volumeBarWrap=this.container.querySelector(".dplayer-volume-bar"),this.volumeBarWrapWrap=this.container.querySelector(".dplayer-volume-bar-wrap"),this.volumeButton=this.container.querySelector(".dplayer-volume"),this.volumeButtonIcon=this.container.querySelector(".dplayer-volume-icon"),this.volumeIcon=this.container.querySelector(".dplayer-volume-icon .dplayer-icon-content"),this.playedBar=this.container.querySelector(".dplayer-played"),this.loadedBar=this.container.querySelector(".dplayer-loaded"),this.playedBarWrap=this.container.querySelector(".dplayer-bar-wrap"),this.playedBarTime=this.container.querySelector(".dplayer-bar-time"),this.danmaku=this.container.querySelector(".dplayer-danmaku"),this.danmakuLoading=this.container.querySelector(".dplayer-danloading"),this.video=this.container.querySelector(".dplayer-video-current"),this.bezel=this.container.querySelector(".dplayer-bezel-icon"),this.playButton=this.container.querySelector(".dplayer-play-icon"),this.mobileBackwardButton=this.container.querySelector(".dplayer-mobile-icon-backward"),this.mobilePlayButton=this.container.querySelector(".dplayer-mobile-icon-play"),this.mobileForwardButton=this.container.querySelector(".dplayer-mobile-icon-forward"),this.videoWrap=this.container.querySelector(".dplayer-video-wrap"),this.videoWrapAspect=this.container.querySelector(".dplayer-video-wrap-aspect"),this.controllerMask=this.container.querySelector(".dplayer-controller-mask"),this.ptime=this.container.querySelector(".dplayer-ptime"),this.settingButton=this.container.querySelector(".dplayer-setting-icon"),this.settingBox=this.container.querySelector(".dplayer-setting-box"),this.settingOriginPanel=this.container.querySelector(".dplayer-setting-origin-panel"),this.mask=this.container.querySelector(".dplayer-mask"),this.syncButton=this.container.querySelector(".dplayer-live-badge"),this.loop=this.container.querySelector(".dplayer-setting-loop"),this.loopToggle=this.container.querySelector(".dplayer-setting-loop .dplayer-toggle-setting-input"),this.showDanmaku=this.container.querySelector(".dplayer-setting-showdan"),this.showDanmakuToggle=this.container.querySelector(".dplayer-showdan-setting-input"),this.unlimitDanmaku=this.container.querySelector(".dplayer-setting-danunlimit"),this.unlimitDanmakuToggle=this.container.querySelector(".dplayer-danunlimit-setting-input"),this.quality=this.container.querySelector(".dplayer-setting-quality"),this.qualityValue=this.container.querySelector(".dplayer-setting-quality .dplayer-label-value"),this.qualityHeader=this.container.querySelector(".dplayer-setting-quality-header"),this.qualityItem=this.container.querySelectorAll(".dplayer-setting-quality-item"),this.speed=this.container.querySelector(".dplayer-setting-speed"),this.speedValue=this.container.querySelector(".dplayer-setting-speed .dplayer-label-value"),this.speedHeader=this.container.querySelector(".dplayer-setting-speed-header"),this.speedItem=this.container.querySelectorAll(".dplayer-setting-speed-item"),this.audio=this.container.querySelector(".dplayer-setting-audio"),this.audioValue=this.container.querySelector(".dplayer-setting-audio .dplayer-label-value"),this.audioHeader=this.container.querySelector(".dplayer-setting-audio-header"),this.audioItem=this.container.querySelectorAll(".dplayer-setting-audio-item"),this.danmakuOpacityBar=this.container.querySelector(".dplayer-danmaku-bar-inner"),this.danmakuOpacityBarWrap=this.container.querySelector(".dplayer-danmaku-bar"),this.danmakuOpacityBarWrapWrap=this.container.querySelector(".dplayer-danmaku-bar-wrap"),this.danmakuOpacityBox=this.container.querySelector(".dplayer-setting-danmaku"),this.danmakuOpacityValue=this.container.querySelector(".dplayer-setting-danmaku .dplayer-label-value"),this.dtime=this.container.querySelector(".dplayer-dtime"),this.controller=this.container.querySelector(".dplayer-controller"),this.commentInput=this.container.querySelector(".dplayer-comment-input"),this.commentButton=this.container.querySelector(".dplayer-comment-icon"),this.commentSettingBox=this.container.querySelector(".dplayer-comment-setting-box"),this.commentSettingButton=this.container.querySelector(".dplayer-comment-setting-icon"),this.commentSettingFill=this.container.querySelector(".dplayer-comment-setting-icon path"),this.commentSendButton=this.container.querySelector(".dplayer-send-icon"),this.commentSendFill=this.container.querySelector(".dplayer-send-icon path"),this.commentColorSettingBox=this.container.querySelector(".dplayer-comment-setting-color"),this.browserFullButton=this.container.querySelector(".dplayer-full-icon"),this.webFullButton=this.container.querySelector(".dplayer-full-in-icon"),this.pipButton=this.container.querySelector(".dplayer-pip-icon"),this.menu=this.container.querySelector(".dplayer-menu"),this.menuItem=this.container.querySelectorAll(".dplayer-menu-item"),this.cameraButton=this.container.querySelector(".dplayer-camera-icon"),this.airplayButton=this.container.querySelector(".dplayer-airplay-icon"),this.subtitleButton=this.container.querySelector(".dplayer-subtitle-icon"),this.subtitleButtonInner=this.container.querySelector(".dplayer-subtitle-icon .dplayer-icon-content"),this.subtitle=this.container.querySelector(".dplayer-subtitle"),this.barPreview=this.container.querySelector(".dplayer-bar-preview"),this.barWrap=this.container.querySelector(".dplayer-bar-wrap"),this.notice=this.container.querySelector(".dplayer-notice"),this.infoPanel=this.container.querySelector(".dplayer-info-panel"),this.infoPanelClose=this.container.querySelector(".dplayer-info-panel-close"),this.infoMimeType=this.container.querySelector(".dplayer-info-panel-item-mimetype .dplayer-info-panel-item-data"),this.infoVersion=this.container.querySelector(".dplayer-info-panel-item-version .dplayer-info-panel-item-data"),this.infoVideoFPS=this.container.querySelector(".dplayer-info-panel-item-video-fps .dplayer-info-panel-item-data"),this.infoPageFPS=this.container.querySelector(".dplayer-info-panel-item-page-fps .dplayer-info-panel-item-data"),this.infoDroppedFrames=this.container.querySelector(".dplayer-info-panel-item-dropped-frames .dplayer-info-panel-item-data"),this.infoType=this.container.querySelector(".dplayer-info-panel-item-type .dplayer-info-panel-item-data"),this.infoUrl=this.container.querySelector(".dplayer-info-panel-item-url .dplayer-info-panel-item-data"),this.infoResolution=this.container.querySelector(".dplayer-info-panel-item-resolution .dplayer-info-panel-item-data"),this.infoDuration=this.container.querySelector(".dplayer-info-panel-item-duration .dplayer-info-panel-item-data"),this.infoBufferRemain=this.container.querySelector(".dplayer-info-panel-item-buffer-remain .dplayer-info-panel-item-data"),this.infoDownloadSpeed=this.container.querySelector(".dplayer-info-panel-item-download-speed .dplayer-info-panel-item-data")}},el=class{constructor(ge){we(this,"options");we(this,"player");we(this,"container");we(this,"danTunnel");we(this,"danIndex");we(this,"danFontSize");we(this,"dan");we(this,"_opacity");we(this,"events");we(this,"unlimited");we(this,"context",null);we(this,"showing");we(this,"paused",!1);this.options=ge,this.player=this.options.player,this.container=this.options.container,this.danTunnel={right:{},top:{},bottom:{}},this.danIndex=0,this.danFontSize=24,this.dan=[],this.showing=!0,this._opacity=this.options.opacity,this.events=this.options.events,this.unlimited=this.options.unlimited===1,this._measure("",0),this.load()}load(){let ge;ge=this.options.api.maximum?`${this.options.api.address}?id=${this.options.api.id}&max=${this.options.api.maximum}`:`${this.options.api.address}?id=${this.options.api.id}`;const Le=(this.options.api.addition||[]).slice(0);Le.push(ge),this.events&&this.events.trigger("danmaku_load_start",Le),this._readAllEndpoints(Le,Xe=>{this.dan=[].concat(...Xe).sort((ft,_t)=>ft.time-_t.time),window.requestAnimationFrame(()=>{this.frame()}),this.options.callback(),this.events&&this.events.trigger("danmaku_load_end")})}reload(ge){this.options.api=ge,this.dan=[],this.clear(),this.load()}_readAllEndpoints(ge,Le){const Xe=[];let ft=0;for(let _t=0;_t {Xe[_t]=Ct,++ft,ft===ge.length&&Le(Xe)},error:Ct=>{this.options.error(Ct||this.options.tran("Danmaku load failed")),Xe[_t]=[],++ft,ft===ge.length&&Le(Xe)}})}send(ge,Le,Xe=!1){const ft={token:this.options.api.token,id:this.options.api.id,author:this.options.api.user,time:this.options.time(),text:ge.text,color:ge.color,type:ge.type,size:ge.size};this.options.apiBackend.send({url:this.options.api.address,data:ft,success:()=>{this.dan.splice(this.danIndex,0,ft),this.danIndex++,this.draw({text:this.htmlEncode(ft.text),color:ft.color,type:ft.type,size:ft.size,border:!0}),this.events&&this.events.trigger("danmaku_send",ft),Le()},error:_t=>{this.options.error(_t||this.options.tran("Danmaku send failed")),Xe===!0&&Le()}})}frame(){if(this.dan.length&&!this.paused&&this.showing){let ge=this.dan[this.danIndex];const Le=[];for(;ge&&this.options.time()>(typeof ge.time=="number"?ge.time:parseFloat(ge.time));)Le.push(ge),ge=this.dan[++this.danIndex];this.draw(Le)}window.requestAnimationFrame(()=>{this.frame()})}opacity(ge){return ge!==void 0&&(this.container.style.setProperty("--dplayer-danmaku-opacity",`${ge}`),this._opacity=ge,this.events&&this.events.trigger("danmaku_opacity",this._opacity)),this._opacity}draw(ge){if(this.showing){let Le;Le=Object.prototype.toString.call(ge)!=="[object Array]"?[ge]:ge;let ft=this.container.offsetWidth/1024*1.25;ft>=1&&(ft=1);let _t=this.options.fontSize*ft;const Ct=_t+6*ft,Pt=this.container.offsetWidth,ci=this.container.offsetHeight/Ct,hi=bi=>{const pi=bi.offsetWidth||parseInt(bi.style.width),Di=bi.getBoundingClientRect().right||this.container.getBoundingClientRect().right+pi;return this.container.getBoundingClientRect().right-Di},Xt=bi=>(Pt+bi)/5,_i=(bi,pi,Di)=>{const On=Pt/Xt(Di);for(let Ji=0;this.unlimited||Ji {this.danTunnel[pi][Ji+""].splice(0,1)}),Ji%ci;if(pi==="right")for(let Cn=0;Cn {this.danTunnel[pi][Ji+""].splice(0,1)}),Ji%ci}}return-1},Ui=document.createDocumentFragment();for(let bi=0;bi {let Ji=0;for(const tn of pi.text.split(` +`):" "+ce(Ct[0]):"as no adapter specified";throw new tt("There is no suitable adapter to dispatch the request "+Pt,"ERR_NOT_SUPPORT")}return ft};function Pe(ge){if(ge.cancelToken&&ge.cancelToken.throwIfRequested(),ge.signal&&ge.signal.aborted)throw new be(null,ge)}function We(ge){return Pe(ge),ge.headers=Me.from(ge.headers),ge.data=Se.call(ge,ge.transformRequest),["post","put","patch"].indexOf(ge.method)!==-1&&ge.headers.setContentType("application/x-www-form-urlencoded",!1),ye(ge.adapter||At.adapter)(ge).then(function(Le){return Pe(ge),Le.data=Se.call(ge,ge.transformResponse,Le),Le.headers=Me.from(Le.headers),Le},function(Le){return K(Le)||(Pe(ge),Le&&Le.response&&(Le.response.data=Se.call(ge,ge.transformResponse,Le.response),Le.response.headers=Me.from(Le.response.headers))),Promise.reject(Le)})}const nt=ge=>ge instanceof Me?ge.toJSON():ge;function et(ge,Le){Le=Le||{};const Xe={};function ft(Xt,_i,Ui){return _e.isPlainObject(Xt)&&_e.isPlainObject(_i)?_e.merge.call({caseless:Ui},Xt,_i):_e.isPlainObject(_i)?_e.merge({},_i):_e.isArray(_i)?_i.slice():_i}function _t(Xt,_i,Ui){return _e.isUndefined(_i)?_e.isUndefined(Xt)?void 0:ft(void 0,Xt,Ui):ft(Xt,_i,Ui)}function Ct(Xt,_i){if(!_e.isUndefined(_i))return ft(void 0,_i)}function Pt(Xt,_i){return _e.isUndefined(_i)?_e.isUndefined(Xt)?void 0:ft(void 0,Xt):ft(void 0,_i)}function ci(Xt,_i,Ui){return Ui in Le?ft(Xt,_i):Ui in ge?ft(void 0,Xt):void 0}const hi={url:Ct,method:Ct,data:Ct,baseURL:Pt,transformRequest:Pt,transformResponse:Pt,paramsSerializer:Pt,timeout:Pt,timeoutMessage:Pt,withCredentials:Pt,adapter:Pt,responseType:Pt,xsrfCookieName:Pt,xsrfHeaderName:Pt,onUploadProgress:Pt,onDownloadProgress:Pt,decompress:Pt,maxContentLength:Pt,maxBodyLength:Pt,beforeRedirect:Pt,transport:Pt,httpAgent:Pt,httpsAgent:Pt,cancelToken:Pt,socketPath:Pt,responseEncoding:Pt,validateStatus:ci,headers:(Xt,_i)=>_t(nt(Xt),nt(_i),!0)};return _e.forEach(Object.keys(Object.assign({},ge,Le)),function(Xt){const _i=hi[Xt]||_t,Ui=_i(ge[Xt],Le[Xt],Xt);_e.isUndefined(Ui)&&_i!==ci||(Xe[Xt]=Ui)}),Xe}const ot="1.6.0",dt={};["object","boolean","number","function","string","symbol"].forEach((ge,Le)=>{dt[ge]=function(Xe){return typeof Xe===ge||"a"+(Le<1?"n ":" ")+ge}});const yt={};dt.transitional=function(ge,Le,Xe){function ft(_t,Ct){return"[Axios v1.6.0] Transitional option '"+_t+"'"+Ct+(Xe?". "+Xe:"")}return(_t,Ct,Pt)=>{if(ge===!1)throw new tt(ft(Ct," has been removed"+(Le?" in "+Le:"")),tt.ERR_DEPRECATED);return Le&&!yt[Ct]&&(yt[Ct]=!0,console.warn(ft(Ct," has been deprecated since v"+Le+" and will be removed in the near future"))),!ge||ge(_t,Ct,Pt)}};const wt={assertOptions:function(ge,Le,Xe){if(typeof ge!="object")throw new tt("options must be an object",tt.ERR_BAD_OPTION_VALUE);const ft=Object.keys(ge);let _t=ft.length;for(;_t-- >0;){const Ct=ft[_t],Pt=Le[Ct];if(Pt){const ci=ge[Ct],hi=ci===void 0||Pt(ci,Ct,ge);if(hi!==!0)throw new tt("option "+Ct+" must be "+hi,tt.ERR_BAD_OPTION_VALUE)}else if(Xe!==!0)throw new tt("Unknown option "+Ct,tt.ERR_BAD_OPTION)}},validators:dt},bt=wt.validators;class Rt{constructor(Le){this.defaults=Le,this.interceptors={request:new Re,response:new Re}}request(Le,Xe){typeof Le=="string"?(Xe=Xe||{}).url=Le:Xe=Le||{},Xe=et(this.defaults,Xe);const{transitional:ft,paramsSerializer:_t,headers:Ct}=Xe;ft!==void 0&&wt.assertOptions(ft,{silentJSONParsing:bt.transitional(bt.boolean),forcedJSONParsing:bt.transitional(bt.boolean),clarifyTimeoutError:bt.transitional(bt.boolean)},!1),_t!=null&&(_e.isFunction(_t)?Xe.paramsSerializer={serialize:_t}:wt.assertOptions(_t,{encode:bt.function,serialize:bt.function},!0)),Xe.method=(Xe.method||this.defaults.method||"get").toLowerCase();let Pt=Ct&&_e.merge(Ct.common,Ct[Xe.method]);Ct&&_e.forEach(["delete","get","head","post","put","patch","common"],Di=>{delete Ct[Di]}),Xe.headers=Me.concat(Pt,Ct);const ci=[];let hi=!0;this.interceptors.request.forEach(function(Di){typeof Di.runWhen=="function"&&Di.runWhen(Xe)===!1||(hi=hi&&Di.synchronous,ci.unshift(Di.fulfilled,Di.rejected))});const Xt=[];let _i;this.interceptors.response.forEach(function(Di){Xt.push(Di.fulfilled,Di.rejected)});let Ui,bi=0;if(!hi){const Di=[We.bind(this),void 0];for(Di.unshift.apply(Di,ci),Di.push.apply(Di,Xt),Ui=Di.length,_i=Promise.resolve(Xe);bi {if(!ft._listeners)return;let Ct=ft._listeners.length;for(;Ct-- >0;)ft._listeners[Ct](_t);ft._listeners=null}),this.promise.then=_t=>{let Ct;const Pt=new Promise(ci=>{ft.subscribe(ci),Ct=ci}).then(_t);return Pt.cancel=function(){ft.unsubscribe(Ct)},Pt},Le(function(_t,Ct,Pt){ft.reason||(ft.reason=new be(_t,Ct,Pt),Xe(ft.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(Le){this.reason?Le(this.reason):this._listeners?this._listeners.push(Le):this._listeners=[Le]}unsubscribe(Le){if(!this._listeners)return;const Xe=this._listeners.indexOf(Le);Xe!==-1&&this._listeners.splice(Xe,1)}static source(){let Le;return{token:new Tt(function(Xe){Le=Xe}),cancel:Le}}}const xt=Tt,Ut={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ut).forEach(([ge,Le])=>{Ut[Le]=ge});const Vt=Ut,Bt=function ge(Le){const Xe=new Lt(Le),ft=w(Lt.prototype.request,Xe);return _e.extend(ft,Lt.prototype,Xe,{allOwnKeys:!0}),_e.extend(ft,Xe,null,{allOwnKeys:!0}),ft.create=function(_t){return ge(et(Le,_t))},ft}(At);Bt.Axios=Lt,Bt.CanceledError=be,Bt.CancelToken=xt,Bt.isCancel=K,Bt.VERSION=ot,Bt.toFormData=Ae,Bt.AxiosError=tt,Bt.Cancel=Bt.CanceledError,Bt.all=function(ge){return Promise.all(ge)},Bt.spread=function(ge){return function(Le){return ge.apply(null,Le)}},Bt.isAxiosError=function(ge){return _e.isObject(ge)&&ge.isAxiosError===!0},Bt.mergeConfig=et,Bt.AxiosHeaders=Me,Bt.formToJSON=ge=>Ce(_e.isHTMLForm(ge)?new FormData(ge):ge),Bt.getAdapter=ye,Bt.HttpStatusCode=Vt,Bt.default=Bt;const jt=Bt;var Mt=A(662);const Ot=/iPhone|iPad|iPod|Windows|Macintosh|Android|Mobile/i.test(navigator.userAgent)&&"ontouchend"in document,Jt={secondToTime:ge=>{if((ge=ge||0)===0||ge===1/0||ge.toString()==="NaN")return"00:00";const Le=Math.floor(ge/3600),Xe=Math.floor((ge-3600*Le)/60),ft=Math.floor(ge-3600*Le-60*Xe);return(Le>0?[Le,Xe,ft]:[Xe,ft]).map(_t=>_t<10?"0"+_t:""+_t).join(":")},getVideoDuration:(ge,Le)=>{let Xe=ge.duration;return Xe===1/0&&(ge.seekable.length>0?(Le.dtime.textContent=Jt.secondToTime(ge.seekable.end(0)),Xe=ge.seekable.end(0)):ge.buffered.length>0&&(Le.dtime.textContent=Jt.secondToTime(ge.buffered.end(0)),Xe=ge.buffered.end(0))),Xe},getElementViewLeft:ge=>{let Le=ge.offsetLeft,Xe=ge.offsetParent;const ft=document.body.scrollLeft+document.documentElement.scrollLeft;if(document.fullscreenElement||document.webkitFullscreenElement)for(;Xe!==null&&Xe!==ge;)Le+=Xe.offsetLeft,Xe=Xe.offsetParent;else for(;Xe!==null;)Le+=Xe.offsetLeft,Xe=Xe.offsetParent;return Le-ft},getBoundingClientRectViewLeft(ge){const Le=window.scrollY||window.pageYOffset||document.body.scrollTop+(document.documentElement&&document.documentElement.scrollTop||0);if(ge.getBoundingClientRect){if(typeof this.getBoundingClientRectViewLeft.offset!="number"){let _t=document.createElement("div");_t.style.cssText="position:absolute;top:0;left:0;",document.body.appendChild(_t),this.getBoundingClientRectViewLeft.offset=-_t.getBoundingClientRect().top-Le,document.body.removeChild(_t),_t=null}const Xe=ge.getBoundingClientRect(),ft=this.getBoundingClientRectViewLeft.offset;return Xe.left+ft}return this.getElementViewLeft(ge)},getScrollPosition:()=>({left:window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0}),setScrollPosition({left:ge=0,top:Le=0}){this.isFirefox?(document.documentElement.scrollLeft=ge,document.documentElement.scrollTop=Le):window.scrollTo(ge,Le)},isMobile:Ot,isFirefox:/firefox/i.test(window.navigator.userAgent),isChrome:/chrome/i.test(window.navigator.userAgent),storage:{set:(ge,Le)=>{localStorage.setItem(ge,Le)},get:ge=>localStorage.getItem(ge)},nameMap:{dragStart:Ot?"touchstart":"mousedown",dragMove:Ot?"touchmove":"mousemove",dragEnd:Ot?"touchend":"mouseup"},color2Number:ge=>(ge[0]==="#"&&(ge=ge.substr(1)),ge.length===3&&(ge=`${ge[0]}${ge[0]}${ge[1]}${ge[1]}${ge[2]}${ge[2]}`),parseInt(ge,16)+0&16777215),number2Color:ge=>"#"+("00000"+ge.toString(16)).slice(-6),number2Type:ge=>{switch(ge){case 0:default:return"right";case 1:return"top";case 2:return"bottom"}}},Wt=Jt,di={send:ge=>{ge.url!==void 0?jt.post(ge.url,ge.data).then(Le=>{const Xe=Le.data;Xe&&Xe.code===0?ge.success&&ge.success():ge.error&&ge.error(Xe&&Xe.msg)}).catch(Le=>{console.error(Le),ge.error&&ge.error()}):ge.error&&ge.error()},read:ge=>{ge.url!==void 0?jt.get(ge.url).then(Le=>{const Xe=Le.data;Xe&&Xe.code===0?Xe.data?ge.success&&ge.success(Xe.data.map(ft=>({author:ft[3],time:ft[0],text:ft[4],color:ft[2],type:ft[1],size:ft[5]&&(ft[5]==="big"||ft[5]==="small")?ft[5]:"medium"}))):ge.success&&ge.success([{author:"",time:0,text:"",color:"#ffeaea",type:"right",size:"medium"}]):ge.error&&ge.error(Xe&&Xe.msg)}).catch(Le=>{console.error(Le),ge.error&&ge.error()}):ge.error&&ge.error()}},oi=di,$t={"zh-cn":{"Danmaku is loading":"弹幕加载中",Top:"顶部",Bottom:"底部",Rolling:"滚动",Big:"大的",Medium:"中等的",Small:"小的","Input danmaku, hit Enter":"输入弹幕,回车发送","About author":"关于作者","DPlayer feedback":"播放器意见反馈","About DPlayer":"关于 DPlayer 播放器",Loop:"洗脑循环",Speed:"速度",Audio:"音频","Primary audio":"主要音频","Secondary audio":"辅助音频","Opacity for danmaku":"弹幕透明度",Normal:"正常","Please input danmaku content!":"要输入弹幕内容啊喂!","Set danmaku color":"设置弹幕颜色","Set danmaku type":"设置弹幕类型","Set danmaku size":"设置弹幕大小","Show danmaku":"显示弹幕","Video load failed":"视频加载失败","Danmaku load failed":"弹幕加载失败","Danmaku send failed":"弹幕发送失败","Switching to":"正在切换至","Switched to":"已经切换至",Synchronize:"同步",Synchronized:"同步的",Quality:"画质",quality:"画质",FF:"快进",REW:"快退","Unlimited danmaku":"海量弹幕","Send danmaku":"发送弹幕",Setting:"设置","Full screen":"全屏","Web full screen":"页面全屏","Picture-in-Picture":"子母画面",Send:"发送",Screenshot:"截图",AirPlay:"无线投屏",s:"秒","Show comment":"显示弹幕","Hide comment":"隐藏弹幕","Show subtitle":"显示字幕","Hide subtitle":"隐藏字幕",Volume:"音量",Live:"直播","Video info":"视频统计信息"},"zh-tw":{"Danmaku is loading":"彈幕載入中",Top:"頂部",Bottom:"底部",Rolling:"滾動",Big:"大的",Medium:"中等的",Small:"小的","Input danmaku, hit Enter":"輸入彈幕,Enter 發送","About author":"關於作者","DPlayer feedback":"播放器意見回饋","About DPlayer":"關於 DPlayer 播放器",Loop:"循環播放",Speed:"速度",Audio:"音頻","Primary audio":"主要音頻","Secondary audio":"輔助音頻","Opacity for danmaku":"彈幕透明度",Normal:"正常","Please input danmaku content!":"請輸入彈幕內容啊!","Set danmaku color":"設定彈幕顏色","Set danmaku type":"設定彈幕類型","Set danmaku size":"设置弹幕大小","Show danmaku":"顯示彈幕","Video load failed":"影片載入失敗","Danmaku load failed":"彈幕載入失敗","Danmaku send failed":"彈幕發送失敗","Switching to":"正在切換至","Switched to":"已經切換至",Synchronize:"同步",Synchronized:"同步的",Quality:"畫質",quality:"畫質",FF:"快進",REW:"快退","Unlimited danmaku":"巨量彈幕","Send danmaku":"發送彈幕",Setting:"設定","Full screen":"全螢幕","Web full screen":"頁面全螢幕","Picture-in-Picture":"子母畫面",Send:"發送",Screenshot:"截圖",AirPlay:"無線投屏",s:"秒","Show comment":"顯示彈幕","Hide comment":"隱藏彈幕","Show subtitle":"顯示字幕","Hide subtitle":"隱藏字幕",Volume:"音量",Live:"直播","Video info":"影片統計訊息"},"ja-jp":{"Danmaku is loading":"コメントを読み込み中…",Top:"上固定",Bottom:"下固定",Rolling:"スクロール",Big:"大きめ",Medium:"標準",Small:"小さめ","Input danmaku, hit Enter":"右のボタンを押すとコメントできます","About author":"作者について","DPlayer feedback":"フィードバック","About DPlayer":"DPlayer について",Loop:"リピート再生",Speed:"再生速度",Audio:"音声","Primary audio":"主音声","Secondary audio":"副音声","Opacity for danmaku":"コメントの透明度",Normal:"標準","Please input danmaku content!":"コメント内容を入力して下さい!","Set danmaku color":"コメントの色","Set danmaku type":"コメントの位置","Set danmaku size":"コメントのサイズ","Show danmaku":"コメントを表示","Video load failed":"動画の読み込みに失敗しました…","Danmaku load failed":"コメントの読み込みに失敗しました…","Danmaku send failed":"コメントの送信に失敗しました…","Switching to":"画質を切り替えています…","Switched to":"画質を切り替えました",Synchronize:"同期する",Synchronized:"同期しました",Quality:"画質",quality:"画質",FF:"早送り",REW:"巻き戻し","Unlimited danmaku":"コメントを無制限に表示","Send danmaku":"コメントする",Setting:"設定","Full screen":"フルスクリーン","Web full screen":"ブラウザフルスクリーン","Picture-in-Picture":"Picture-in-Picture",Send:"コメントする",Screenshot:"スクリーンショット",s:"秒","Show comment":"コメントを表示する","Hide comment":"コメントを表示しない","Show subtitle":"字幕を表示する","Hide subtitle":"字幕を表示しない",Volume:"音量",Live:"Live","Video info":"動画の統計情報"}},ui=function(ge){this.lang=ge,this.lang==="ja"&&(this.lang="ja-jp"),this.tran=Le=>$t[this.lang]&&$t[this.lang][Le]?$t[this.lang][Le]:Le};var ti=A(7),li=A.n(ti),wi=A(723),Pi=A.n(wi),mi=A(704),gi=A.n(mi),Kt=A(189),Ii=A.n(Kt),ei=A(848),ji=A.n(ei),Li=A(813),Ti=A.n(Li),Bi=A(480),dn=A.n(Bi),rn=A(241),Un=A.n(rn),on=A(783),gn=A.n(on),An=A(355),tr=A.n(An),Kn=A(531),ir=A.n(Kn),yn=A(863),nr=A.n(yn),rr=A(381),Or=A.n(rr),br=A(243),cr=A.n(br),_r=A(885),Mr=A.n(_r),cs=A(478),sr=A.n(cs),kt=A(916),Gt=A.n(kt),ii=A(310),yi=A.n(ii),Ei=A(409),Mi=A.n(Ei),xi=A(597),Vi=A.n(xi),$i=A(223),pn=A.n($i),ar=A(112),Hn=A.n(ar);const En={play:li(),pause:Pi(),backward:gi(),forward:Ii(),volumeUp:ji(),volumeDown:Ti(),volumeOff:dn(),full:Un(),fullWeb:gn(),pip:tr(),setting:ir(),left:nr(),right:Or(),check:cr(),comment:Mr(),commentOff:sr(),send:Gt(),pallette:yi(),camera:Mi(),subtitle:pn(),loading:Hn(),airplay:Vi()};var Pa=A(368),ds=A.n(Pa);const ha=class{constructor(ge){we(this,"container");we(this,"options");we(this,"index");we(this,"tran");we(this,"volumeBar");we(this,"volumeBarWrap");we(this,"volumeBarWrapWrap");we(this,"volumeButton");we(this,"volumeButtonIcon");we(this,"volumeIcon");we(this,"playedBar");we(this,"loadedBar");we(this,"playedBarWrap");we(this,"playedBarTime");we(this,"danmaku");we(this,"danmakuLoading");we(this,"video");we(this,"bezel");we(this,"playButton");we(this,"mobileBackwardButton");we(this,"mobilePlayButton");we(this,"mobileForwardButton");we(this,"videoWrap");we(this,"videoWrapAspect");we(this,"controllerMask");we(this,"ptime");we(this,"settingButton");we(this,"settingBox");we(this,"settingOriginPanel");we(this,"mask");we(this,"syncButton");we(this,"loop");we(this,"loopToggle");we(this,"showDanmaku");we(this,"showDanmakuToggle");we(this,"unlimitDanmaku");we(this,"unlimitDanmakuToggle");we(this,"quality");we(this,"qualityValue");we(this,"qualityHeader");we(this,"qualityItem");we(this,"speed");we(this,"speedValue");we(this,"speedHeader");we(this,"speedItem");we(this,"audio");we(this,"audioValue");we(this,"audioHeader");we(this,"audioItem");we(this,"danmakuOpacityBar");we(this,"danmakuOpacityBarWrap");we(this,"danmakuOpacityBarWrapWrap");we(this,"danmakuOpacityBox");we(this,"danmakuOpacityValue");we(this,"dtime");we(this,"controller");we(this,"commentInput");we(this,"commentButton");we(this,"commentSettingBox");we(this,"commentSettingButton");we(this,"commentSettingFill");we(this,"commentSendButton");we(this,"commentSendFill");we(this,"commentColorSettingBox");we(this,"browserFullButton");we(this,"webFullButton");we(this,"pipButton");we(this,"menu");we(this,"menuItem");we(this,"cameraButton");we(this,"airplayButton");we(this,"subtitleButton");we(this,"subtitleButtonInner");we(this,"subtitle");we(this,"barPreview");we(this,"barWrap");we(this,"notice");we(this,"infoPanel");we(this,"infoPanelClose");we(this,"infoMimeType");we(this,"infoVersion");we(this,"infoVideoFPS");we(this,"infoPageFPS");we(this,"infoDroppedFrames");we(this,"infoType");we(this,"infoUrl");we(this,"infoResolution");we(this,"infoDuration");we(this,"infoBufferRemain");we(this,"infoDownloadSpeed");this.container=ge.container,this.options=ge.options,this.index=ge.index,this.tran=ge.tran,this.init()}init(){this.container.innerHTML=ds()({options:this.options,index:this.index,tran:this.tran,icons:En,mobile:Wt.isMobile,video:{current:!0,pic:this.options.video.pic,screenshot:this.options.screenshot,airplay:this.options.airplay,preload:this.options.preload,url:this.options.video.type==="live-llhls-for-KonomiTV"?"":this.options.video.url,subtitle:this.options.subtitle,crossOrigin:this.options.crossOrigin}}),this.volumeBar=this.container.querySelector(".dplayer-volume-bar-inner"),this.volumeBarWrap=this.container.querySelector(".dplayer-volume-bar"),this.volumeBarWrapWrap=this.container.querySelector(".dplayer-volume-bar-wrap"),this.volumeButton=this.container.querySelector(".dplayer-volume"),this.volumeButtonIcon=this.container.querySelector(".dplayer-volume-icon"),this.volumeIcon=this.container.querySelector(".dplayer-volume-icon .dplayer-icon-content"),this.playedBar=this.container.querySelector(".dplayer-played"),this.loadedBar=this.container.querySelector(".dplayer-loaded"),this.playedBarWrap=this.container.querySelector(".dplayer-bar-wrap"),this.playedBarTime=this.container.querySelector(".dplayer-bar-time"),this.danmaku=this.container.querySelector(".dplayer-danmaku"),this.danmakuLoading=this.container.querySelector(".dplayer-danloading"),this.video=this.container.querySelector(".dplayer-video-current"),this.bezel=this.container.querySelector(".dplayer-bezel-icon"),this.playButton=this.container.querySelector(".dplayer-play-icon"),this.mobileBackwardButton=this.container.querySelector(".dplayer-mobile-icon-backward"),this.mobilePlayButton=this.container.querySelector(".dplayer-mobile-icon-play"),this.mobileForwardButton=this.container.querySelector(".dplayer-mobile-icon-forward"),this.videoWrap=this.container.querySelector(".dplayer-video-wrap"),this.videoWrapAspect=this.container.querySelector(".dplayer-video-wrap-aspect"),this.controllerMask=this.container.querySelector(".dplayer-controller-mask"),this.ptime=this.container.querySelector(".dplayer-ptime"),this.settingButton=this.container.querySelector(".dplayer-setting-icon"),this.settingBox=this.container.querySelector(".dplayer-setting-box"),this.settingOriginPanel=this.container.querySelector(".dplayer-setting-origin-panel"),this.mask=this.container.querySelector(".dplayer-mask"),this.syncButton=this.container.querySelector(".dplayer-live-badge"),this.loop=this.container.querySelector(".dplayer-setting-loop"),this.loopToggle=this.container.querySelector(".dplayer-setting-loop .dplayer-toggle-setting-input"),this.showDanmaku=this.container.querySelector(".dplayer-setting-showdan"),this.showDanmakuToggle=this.container.querySelector(".dplayer-showdan-setting-input"),this.unlimitDanmaku=this.container.querySelector(".dplayer-setting-danunlimit"),this.unlimitDanmakuToggle=this.container.querySelector(".dplayer-danunlimit-setting-input"),this.quality=this.container.querySelector(".dplayer-setting-quality"),this.qualityValue=this.container.querySelector(".dplayer-setting-quality .dplayer-label-value"),this.qualityHeader=this.container.querySelector(".dplayer-setting-quality-header"),this.qualityItem=this.container.querySelectorAll(".dplayer-setting-quality-item"),this.speed=this.container.querySelector(".dplayer-setting-speed"),this.speedValue=this.container.querySelector(".dplayer-setting-speed .dplayer-label-value"),this.speedHeader=this.container.querySelector(".dplayer-setting-speed-header"),this.speedItem=this.container.querySelectorAll(".dplayer-setting-speed-item"),this.audio=this.container.querySelector(".dplayer-setting-audio"),this.audioValue=this.container.querySelector(".dplayer-setting-audio .dplayer-label-value"),this.audioHeader=this.container.querySelector(".dplayer-setting-audio-header"),this.audioItem=this.container.querySelectorAll(".dplayer-setting-audio-item"),this.danmakuOpacityBar=this.container.querySelector(".dplayer-danmaku-bar-inner"),this.danmakuOpacityBarWrap=this.container.querySelector(".dplayer-danmaku-bar"),this.danmakuOpacityBarWrapWrap=this.container.querySelector(".dplayer-danmaku-bar-wrap"),this.danmakuOpacityBox=this.container.querySelector(".dplayer-setting-danmaku"),this.danmakuOpacityValue=this.container.querySelector(".dplayer-setting-danmaku .dplayer-label-value"),this.dtime=this.container.querySelector(".dplayer-dtime"),this.controller=this.container.querySelector(".dplayer-controller"),this.commentInput=this.container.querySelector(".dplayer-comment-input"),this.commentButton=this.container.querySelector(".dplayer-comment-icon"),this.commentSettingBox=this.container.querySelector(".dplayer-comment-setting-box"),this.commentSettingButton=this.container.querySelector(".dplayer-comment-setting-icon"),this.commentSettingFill=this.container.querySelector(".dplayer-comment-setting-icon path"),this.commentSendButton=this.container.querySelector(".dplayer-send-icon"),this.commentSendFill=this.container.querySelector(".dplayer-send-icon path"),this.commentColorSettingBox=this.container.querySelector(".dplayer-comment-setting-color"),this.browserFullButton=this.container.querySelector(".dplayer-full-icon"),this.webFullButton=this.container.querySelector(".dplayer-full-in-icon"),this.pipButton=this.container.querySelector(".dplayer-pip-icon"),this.menu=this.container.querySelector(".dplayer-menu"),this.menuItem=this.container.querySelectorAll(".dplayer-menu-item"),this.cameraButton=this.container.querySelector(".dplayer-camera-icon"),this.airplayButton=this.container.querySelector(".dplayer-airplay-icon"),this.subtitleButton=this.container.querySelector(".dplayer-subtitle-icon"),this.subtitleButtonInner=this.container.querySelector(".dplayer-subtitle-icon .dplayer-icon-content"),this.subtitle=this.container.querySelector(".dplayer-subtitle"),this.barPreview=this.container.querySelector(".dplayer-bar-preview"),this.barWrap=this.container.querySelector(".dplayer-bar-wrap"),this.notice=this.container.querySelector(".dplayer-notice"),this.infoPanel=this.container.querySelector(".dplayer-info-panel"),this.infoPanelClose=this.container.querySelector(".dplayer-info-panel-close"),this.infoMimeType=this.container.querySelector(".dplayer-info-panel-item-mimetype .dplayer-info-panel-item-data"),this.infoVersion=this.container.querySelector(".dplayer-info-panel-item-version .dplayer-info-panel-item-data"),this.infoVideoFPS=this.container.querySelector(".dplayer-info-panel-item-video-fps .dplayer-info-panel-item-data"),this.infoPageFPS=this.container.querySelector(".dplayer-info-panel-item-page-fps .dplayer-info-panel-item-data"),this.infoDroppedFrames=this.container.querySelector(".dplayer-info-panel-item-dropped-frames .dplayer-info-panel-item-data"),this.infoType=this.container.querySelector(".dplayer-info-panel-item-type .dplayer-info-panel-item-data"),this.infoUrl=this.container.querySelector(".dplayer-info-panel-item-url .dplayer-info-panel-item-data"),this.infoResolution=this.container.querySelector(".dplayer-info-panel-item-resolution .dplayer-info-panel-item-data"),this.infoDuration=this.container.querySelector(".dplayer-info-panel-item-duration .dplayer-info-panel-item-data"),this.infoBufferRemain=this.container.querySelector(".dplayer-info-panel-item-buffer-remain .dplayer-info-panel-item-data"),this.infoDownloadSpeed=this.container.querySelector(".dplayer-info-panel-item-download-speed .dplayer-info-panel-item-data")}},el=class{constructor(ge){we(this,"options");we(this,"player");we(this,"container");we(this,"danTunnel");we(this,"danIndex");we(this,"danFontSize");we(this,"dan");we(this,"_opacity");we(this,"events");we(this,"unlimited");we(this,"context",null);we(this,"showing");we(this,"paused",!1);this.options=ge,this.player=this.options.player,this.container=this.options.container,this.danTunnel={right:{},top:{},bottom:{}},this.danIndex=0,this.danFontSize=24,this.dan=[],this.showing=!0,this._opacity=this.options.opacity,this.events=this.options.events,this.unlimited=this.options.unlimited===1,this._measure("",0),this.load()}load(){let ge;ge=this.options.api.maximum?`${this.options.api.address}?id=${this.options.api.id}&max=${this.options.api.maximum}`:`${this.options.api.address}?id=${this.options.api.id}`;const Le=(this.options.api.addition||[]).slice(0);Le.push(ge),this.events&&this.events.trigger("danmaku_load_start",Le),this._readAllEndpoints(Le,Xe=>{this.dan=[].concat(...Xe).sort((ft,_t)=>ft.time-_t.time),window.requestAnimationFrame(()=>{this.frame()}),this.options.callback(),this.events&&this.events.trigger("danmaku_load_end")})}reload(ge){this.options.api=ge,this.dan=[],this.clear(),this.load()}_readAllEndpoints(ge,Le){const Xe=[];let ft=0;for(let _t=0;_t {Xe[_t]=Ct,++ft,ft===ge.length&&Le(Xe)},error:Ct=>{this.options.error(Ct||this.options.tran("Danmaku load failed")),Xe[_t]=[],++ft,ft===ge.length&&Le(Xe)}})}send(ge,Le,Xe=!1){const ft={token:this.options.api.token,id:this.options.api.id,author:this.options.api.user,time:this.options.time(),text:ge.text,color:ge.color,type:ge.type,size:ge.size};this.options.apiBackend.send({url:this.options.api.address,data:ft,success:()=>{this.dan.splice(this.danIndex,0,ft),this.danIndex++,this.draw({text:this.htmlEncode(ft.text),color:ft.color,type:ft.type,size:ft.size,border:!0}),this.events&&this.events.trigger("danmaku_send",ft),Le()},error:_t=>{this.options.error(_t||this.options.tran("Danmaku send failed")),Xe===!0&&Le()}})}frame(){if(this.dan.length&&!this.paused&&this.showing){let ge=this.dan[this.danIndex];const Le=[];for(;ge&&this.options.time()>(typeof ge.time=="number"?ge.time:parseFloat(ge.time));)Le.push(ge),ge=this.dan[++this.danIndex];this.draw(Le)}window.requestAnimationFrame(()=>{this.frame()})}opacity(ge){return ge!==void 0&&(this.container.style.setProperty("--dplayer-danmaku-opacity",`${ge}`),this._opacity=ge,this.events&&this.events.trigger("danmaku_opacity",this._opacity)),this._opacity}draw(ge){if(this.showing){let Le;Le=Object.prototype.toString.call(ge)!=="[object Array]"?[ge]:ge;let ft=this.container.offsetWidth/1024*1.25;ft>=1&&(ft=1);let _t=this.options.fontSize*ft;const Ct=_t+6*ft,Pt=this.container.offsetWidth,ci=this.container.offsetHeight/Ct,hi=bi=>{const pi=bi.offsetWidth||parseInt(bi.style.width),Di=bi.getBoundingClientRect().right||this.container.getBoundingClientRect().right+pi;return this.container.getBoundingClientRect().right-Di},Xt=bi=>(Pt+bi)/5,_i=(bi,pi,Di)=>{const On=Pt/Xt(Di);for(let Ji=0;this.unlimited||Ji {this.danTunnel[pi][Ji+""].splice(0,1)}),Ji%ci;if(pi==="right")for(let Cn=0;Cn {this.danTunnel[pi][Ji+""].splice(0,1)}),Ji%ci}}return-1},Ui=document.createDocumentFragment();for(let bi=0;bi {let Ji=0;for(const tn of pi.text.split(` `)){const Cn=this._measure(tn,_t);Cn>Ji&&(Ji=Cn)}return Ji})(),On=pi.text.split(` `);for(const Ji of pi.type==="bottom"?On.reverse():On){const tn=document.createElement("div");if(tn.classList.add("dplayer-danmaku-item"),tn.classList.add(`dplayer-danmaku-${pi.type}`),tn.classList.add(`dplayer-danmaku-size-${pi.size}`),tn.style.color=pi.color,"border"in pi&&pi.border){const ns=document.createElement("span");ns.style.border=`2px solid ${this.options.borderColor}`,ns.textContent=Ji,tn.appendChild(ns)}else tn.textContent=Ji;tn.addEventListener("animationend",()=>{this.container.removeChild(tn)});const Cn=_i(tn,pi.type,Di);switch(pi.type){case"right":Cn>=0&&(tn.style.width=Di+1+"px",tn.style.top=Ct*Cn+8+"px",tn.style.transform=`translateX(-${Pt}px)`,tn.style.willChange="transform");break;case"top":Cn>=0&&(tn.style.width=Di+1+"px",tn.style.top=Ct*Cn+8+"px",tn.style.willChange="visibility");break;case"bottom":Cn>=0&&(tn.style.width=Di+1+"px",tn.style.bottom=Ct*Cn+8+"px",tn.style.willChange="visibility");break;default:console.error(`Can't handled danmaku type: ${pi.type}`)}Cn>=0&&(tn.classList.add("dplayer-danmaku-move"),tn.style.animationDuration=this._danAnimation(pi.type),Ui.appendChild(tn))}}return this.container.style.setProperty("--dplayer-danmaku-font-size",`${_t}px`),this.container.appendChild(Ui),Ui}return null}play(){this.paused=!1}pause(){this.paused=!0}_measure(ge,Le){this.context&&this.danFontSize===Le||(this.danFontSize=Le,this.context=document.createElement("canvas").getContext("2d"),this.context.font=`bold ${this.danFontSize}px "Segoe UI", Arial`);const Xe=ge.split(` -`);let ft=0;for(let _t=0;_t =this.options.time()){this.danIndex=ge;break}this.danIndex=this.dan.length}}clear(){this.danTunnel={right:{},top:{},bottom:{}},this.danIndex=0,this.options.container.innerHTML="",this.events&&this.events.trigger("danmaku_clear")}htmlEncode(ge){return ge.replace(/&/g,"&").replace(/ {this.player.resize()}),this.player.events.on("webfullscreen_cancel",()=>{this.player.resize(),Wt.setScrollPosition(this.lastScrollPosition)}),this.fullscreenchange=()=>{this.player.resize(),this.isFullScreen("browser")?this.player.events.trigger("fullscreen"):(Wt.setScrollPosition(this.lastScrollPosition),this.player.container.classList.remove("dplayer-fulled-browser"),this.player.events.trigger("fullscreen_cancel"))},this.player.container.onfullscreenchange!==void 0?this.player.container.addEventListener("fullscreenchange",this.fullscreenchange):this.player.container.addEventListener("webkitfullscreenchange",this.fullscreenchange)}isFullScreen(ge="browser"){switch(ge){case"browser":{const Le=document.fullscreenElement||document.webkitFullscreenElement;return!(!Le||Le!==this.player.container)}case"web":return this.player.container.classList.contains("dplayer-fulled")}}request(ge="browser"){const Le=ge==="browser"?"web":"browser",Xe=this.isFullScreen(Le);switch(Xe||(this.lastScrollPosition=Wt.getScrollPosition()),ge){case"browser":if(this.player.container.requestFullscreen=this.player.container.requestFullscreen||this.player.container.webkitRequestFullscreen,this.player.container.requestFullscreen!==void 0?this.player.container.requestFullscreen():this.player.video.webkitEnterFullscreen&&this.player.video.webkitEnterFullscreen(),screen.orientation)try{screen.orientation.lock("landscape").catch(()=>{})}catch{}this.player.container.requestFullscreen!==void 0&&this.player.container.classList.add("dplayer-fulled-browser");break;case"web":this.player.container.classList.add("dplayer-fulled"),document.body.classList.add("dplayer-web-fullscreen-fix"),this.player.events.trigger("webfullscreen")}Xe&&this.cancel(Le)}cancel(ge="browser"){switch(ge){case"browser":if(document.exitFullscreen=document.exitFullscreen||document.webkitExitFullscreen,document.exitFullscreen&&document.exitFullscreen(),screen.orientation)try{screen.orientation.unlock()}catch{}this.player.container.classList.remove("dplayer-fulled-browser");break;case"web":this.player.container.classList.remove("dplayer-fulled"),document.body.classList.remove("dplayer-web-fullscreen-fix"),this.player.events.trigger("webfullscreen_cancel")}}toggle(ge="browser"){this.isFullScreen(ge)?this.cancel(ge):this.request(ge)}destroy(){this.player.container.removeEventListener("fullscreenchange",this.fullscreenchange),this.player.container.removeEventListener("webkitfullscreenchange",this.fullscreenchange)}},Er=class{constructor(ge){we(this,"storageName");we(this,"default");we(this,"data");this.storageName={opacity:"dplayer-danmaku-opacity",volume:"dplayer-volume",unlimited:"dplayer-danmaku-unlimited",danmaku:"dplayer-danmaku-show",subtitle:"dplayer-subtitle-show"},this.default={opacity:1,volume:Object.prototype.hasOwnProperty.call(ge.options,"volume")?ge.options.volume:1,unlimited:(ge.options.danmaku&&ge.options.danmaku.unlimited?1:0)||0,danmaku:1,subtitle:1},this.data={},this.init()}init(){for(const ge in this.storageName){const Le=this.storageName[ge];this.data[ge]=parseFloat(Wt.storage.get(Le)||this.default[ge].toString())}}get(ge){return this.data[ge]}set(ge,Le){this.data[ge]=Le,Wt.storage.set(this.storageName[ge],Le)}},ks=class{constructor(ge,Le,Xe,ft,_t){we(this,"container");we(this,"video");we(this,"plugins");we(this,"options");we(this,"events");this.container=ge,this.video=Le,this.plugins=Xe,this.options=ft,this.events=_t,this.init()}init(){if(this.container.style.fontSize=this.options.fontSize,this.container.style.bottom=this.options.bottom,this.container.style.color=this.options.color,this.options.type==="webvtt"&&this.video.textTracks&&this.video.textTracks[0]){const ge=this.video.textTracks[0];ge.oncuechange=()=>{if(!ge.activeCues)return;const Le=ge.activeCues[0];if(this.container.innerHTML="",Le){const Xe=document.createElement("div");Xe.appendChild(Le.getCueAsHTML());const ft=Xe.innerHTML.split(/\r?\n/).map(_t=>` ${_t}
`).join("");this.container.innerHTML=ft}this.events.trigger("subtitle_change")}}}show(){this.container.classList.remove("dplayer-subtitle-hide"),this.options.type==="aribb24"&&this.plugins.aribb24Caption&&this.plugins.aribb24Caption.show(),this.events.trigger("subtitle_show")}hide(){this.container.classList.add("dplayer-subtitle-hide"),this.options.type==="aribb24"&&this.plugins.aribb24Caption&&this.plugins.aribb24Caption.hide(),this.events.trigger("subtitle_hide")}toggle(){this.container.classList.contains("dplayer-subtitle-hide")?this.show():this.hide()}},Xr=class{constructor(ge){we(this,"elements");this.elements={},this.elements.volume=ge.volumeBar,this.elements.played=ge.playedBar,this.elements.loaded=ge.loadedBar,this.elements.danmaku=ge.danmakuOpacityBar}set(ge,Le,Xe){Le=Math.max(Le,0),Le=Math.min(Le,1),this.elements[ge].style[Xe]=100*Le+"%"}get(ge){return parseFloat(this.elements[ge].style.width)/100}},Rs=class{constructor(ge){we(this,"player");we(this,"types");we(this,"enablefpsChecker");we(this,"enableinfoChecker");we(this,"enableloadingChecker");we(this,"fpsIndex");we(this,"fpsStart");we(this,"fpsChecker");we(this,"infoChecker");we(this,"loadingChecker");this.player=ge,window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(Le){window.setTimeout(Le,1e3/60)},this.types=["loading","info","fps"],this.init()}init(){this.types.map(ge=>(ge!=="fps"&&this[`init${ge}Checker`](),ge))}initloadingChecker(){let ge=0,Le=0,Xe=!1;this.loadingChecker=window.setInterval(()=>{this.enableloadingChecker&&(Le=this.player.video.currentTime,Xe||Le!==ge||this.player.video.paused||(this.player.container.classList.add("dplayer-loading"),Xe=!0),Xe&&Le>ge&&!this.player.video.paused&&(this.player.container.classList.remove("dplayer-loading"),Xe=!1),ge=Le)},100)}initfpsChecker(){window.requestAnimationFrame(()=>{if(this.enablefpsChecker)if(this.initfpsChecker(),this.fpsStart){this.fpsIndex++;const ge=new Date;ge-this.fpsStart>1e3&&(this.player.infoPanel.fps(this.fpsIndex/(ge-this.fpsStart)*1e3),this.fpsStart=new Date,this.fpsIndex=0)}else this.fpsStart=new Date,this.fpsIndex=0;else this.fpsStart=0,this.fpsIndex=0})}initinfoChecker(){this.infoChecker=window.setInterval(()=>{this.enableinfoChecker&&this.player.infoPanel.update()},1e3)}enable(ge){this[`enable${ge}Checker`]=!0,ge==="fps"&&this.initfpsChecker()}disable(ge){this[`enable${ge}Checker`]=!1}destroy(){this.types.map(ge=>(this[`enable${ge}Checker`]=!1,this[`${ge}Checker`]&&window.clearInterval(this[`${ge}Checker`]),ge))}},Ba=class{constructor(ge){we(this,"container");this.container=ge,this.container.addEventListener("animationend",()=>{this.container.classList.remove("dplayer-bezel-transition")})}switch(ge){this.container.innerHTML=ge,this.container.classList.add("dplayer-bezel-transition")}},il=class{constructor(ge){we(this,"container");we(this,"barWidth");we(this,"events");this.container=ge.container,this.barWidth=ge.barWidth,this.container.style.backgroundImage=`url('${ge.url}')`,this.events=ge.events}resize(ge,Le,Xe){this.container.style.width=`${ge}px`,this.container.style.height=`${Le}px`,this.container.style.top=2-Le+"px",this.barWidth=Xe}show(){this.container.style.display="block",this.events&&this.events.trigger("thumbnails_show")}move(ge){this.container.style.backgroundPosition=`-${160*(Math.ceil(ge/this.barWidth*100)-1)}px 0`,this.container.style.left=`${Math.min(Math.max(ge-this.container.offsetWidth/2,-10),this.barWidth-150)}px`}hide(){this.container.style.display="none",this.events&&this.events.trigger("thumbnails_hide")}},pa=class{constructor(ge){we(this,"player");we(this,"disableAutoHide",!1);we(this,"autoHideTimer");we(this,"mobileSkipTimer");we(this,"mobileBackwardTime");we(this,"mobileForwardTime");we(this,"setAutoHideHandler");we(this,"thumbnails",null);this.player=ge,this.autoHideTimer=0,this.mobileSkipTimer=0,this.mobileBackwardTime=0,this.mobileForwardTime=0,this.setAutoHideHandler=()=>this.setAutoHide(),Wt.isMobile?this.player.container.addEventListener("touchmove",this.setAutoHideHandler):(this.player.container.addEventListener("mousemove",this.setAutoHideHandler),this.player.container.addEventListener("click",this.setAutoHideHandler)),this.player.on("play",this.setAutoHideHandler),this.player.on("pause",this.setAutoHideHandler),this.initPlayButton(),this.initThumbnails(),this.initPlayedBar(),this.initFullButton(),this.initPipButton(),this.initSyncButton(),this.initScreenshotButton(),this.initSubtitleButton(),this.initHighlights(),this.initAirplayButton(),Wt.isMobile||this.initVolumeButton()}initPlayButton(){this.player.template.playButton.addEventListener("click",()=>{this.player.toggle()}),this.player.template.mobilePlayButton.addEventListener("click",()=>{this.player.toggle()}),Wt.isMobile?(this.player.template.videoWrap.addEventListener("click",()=>{this.toggle(),this.isShow()&&this.setAutoHide()}),this.player.template.controllerMask.addEventListener("click",()=>{this.toggle(),this.isShow()&&this.setAutoHide()})):(this.player.template.videoWrap.addEventListener("click",()=>{this.player.toggle()}),this.player.template.controllerMask.addEventListener("click",()=>{this.player.toggle()})),this.player.template.mobileBackwardButton.addEventListener("click",()=>{this.mobileBackwardTime+=10,this.player.seek(this.player.video.currentTime-10),this.player.notice(`${this.player.tran("REW")} ${this.mobileBackwardTime.toFixed(0)} ${this.player.tran("s")}`),window.clearTimeout(this.mobileSkipTimer),this.mobileSkipTimer=window.setTimeout(()=>{this.mobileBackwardTime=0},1e3),this.setAutoHide()}),this.player.template.mobileForwardButton.addEventListener("click",()=>{this.mobileForwardTime+=10,this.player.seek(this.player.video.currentTime+10),this.player.notice(`${this.player.tran("FF")} ${this.mobileForwardTime.toFixed(0)} ${this.player.tran("s")}`),window.clearTimeout(this.mobileSkipTimer),this.mobileSkipTimer=window.setTimeout(()=>{this.mobileForwardTime=0},1e3),this.setAutoHide()})}initHighlights(){this.player.on("durationchange",()=>{if(this.player.video.duration!==1&&this.player.video.duration!==1/0&&this.player.options.highlight){const ge=this.player.template.playedBarWrap.querySelectorAll(".dplayer-highlight");[].slice.call(ge,0).forEach(Le=>{this.player.template.playedBarWrap.removeChild(Le)});for(let Le=0;Le{this.thumbnails.resize(160,this.player.video.videoHeight/this.player.video.videoWidth*160,this.player.template.barWrap.offsetWidth)}))}initPlayedBar(){let ge;const Le=ft=>{let _t=((ft.clientX||ft.changedTouches&&ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.playedBarWrap))/this.player.template.playedBarWrap.clientWidth;_t=Math.max(_t,0),_t=Math.min(_t,1),this.player.bar.set("played",_t,"width");const Ct=Wt.getVideoDuration(this.player.video,this.player.template);this.player.template.ptime.textContent=Wt.secondToTime(_t*Ct),this.player.container.classList.add("dplayer-seeking"),this.player.video.paused||this.player.video.pause()},Xe=ft=>{document.removeEventListener(Wt.nameMap.dragEnd,Xe),document.removeEventListener(Wt.nameMap.dragMove,Le);let _t=((ft.clientX||ft.changedTouches&&ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.playedBarWrap))/this.player.template.playedBarWrap.clientWidth;_t=Math.max(_t,0),_t=Math.min(_t,1),this.player.bar.set("played",_t,"width");const Ct=Wt.getVideoDuration(this.player.video,this.player.template);this.player.seek(this.player.bar.get("played")*Ct),ge||this.player.video.play(),this.player.container.classList.remove("dplayer-seeking")};this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragStart,()=>{ge=this.player.video.paused,document.addEventListener(Wt.nameMap.dragMove,Le),document.addEventListener(Wt.nameMap.dragEnd,Xe)}),this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragMove,ft=>{const _t=Wt.getVideoDuration(this.player.video,this.player.template);if(_t){const Ct=this.player.template.playedBarWrap.getBoundingClientRect().left,Pt=(ft.clientX||ft.changedTouches[0].clientX)-Ct;if(Pt<0||Pt>this.player.template.playedBarWrap.offsetWidth)return;const ci=_t*(Pt/this.player.template.playedBarWrap.offsetWidth);Wt.isMobile&&this.thumbnails&&this.thumbnails.show(),this.thumbnails&&this.thumbnails.move(Pt),this.player.template.playedBarTime.style.left=Pt-(ci>=3600?25:20)+"px",this.player.template.playedBarTime.textContent=Wt.secondToTime(ci),this.player.template.playedBarTime.classList.remove("hidden")}}),this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragEnd,()=>{Wt.isMobile&&this.thumbnails&&this.thumbnails.hide()}),Wt.isMobile||(this.player.template.playedBarWrap.addEventListener("mouseenter",()=>{this.player.video.duration&&(this.thumbnails&&this.thumbnails.show(),this.player.template.playedBarTime.classList.remove("hidden"))}),this.player.template.playedBarWrap.addEventListener("mouseleave",()=>{this.player.video.duration&&(this.thumbnails&&this.thumbnails.hide(),this.player.template.playedBarTime.classList.add("hidden"))}))}initFullButton(){this.player.template.browserFullButton.addEventListener("click",()=>{this.player.fullScreen.toggle("browser")}),this.player.template.webFullButton.addEventListener("click",()=>{this.player.fullScreen.toggle("web")})}initPipButton(){document.pictureInPictureEnabled?this.player.template.pipButton.addEventListener("click",()=>{document.pictureInPictureElement?document.exitPictureInPicture():this.player.video.requestPictureInPicture().catch(ge=>{console.error(ge),this.player.options.lang==="ja"||this.player.options.lang==="ja-jp"?this.player.notice("Picture-in-Picture を開始できませんでした。",void 0,void 0,"#FF6F6A"):this.player.notice("Picture-in-Picture could not be started.",void 0,void 0,"#FF6F6A")})}):this.player.template.pipButton.style.display="none"}initVolumeButton(){const ge=Xe=>{const ft=Xe||window.event,_t=((ft.clientX||ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap)-5.5)/35;this.player.volume(_t)},Le=()=>{document.removeEventListener(Wt.nameMap.dragEnd,Le),document.removeEventListener(Wt.nameMap.dragMove,ge),this.player.template.volumeButton.classList.remove("dplayer-volume-active")};this.player.template.volumeBarWrapWrap.addEventListener("click",Xe=>{const ft=Xe||window.event,_t=((ft.clientX||ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap)-5.5)/35;this.player.volume(_t)}),this.player.template.volumeBarWrapWrap.addEventListener(Wt.nameMap.dragStart,()=>{document.addEventListener(Wt.nameMap.dragMove,ge),document.addEventListener(Wt.nameMap.dragEnd,Le),this.player.template.volumeButton.classList.add("dplayer-volume-active")}),this.player.template.volumeButtonIcon.addEventListener("click",()=>{this.player.video.muted?(this.player.video.muted=!1,this.player.switchVolumeIcon(),this.player.bar.set("volume",this.player.volume(),"width")):(this.player.video.muted=!0,this.player.template.volumeIcon.innerHTML=En.volumeOff,this.player.bar.set("volume",0,"width"))})}initSyncButton(){this.player.options.live&&this.player.template.syncButton.addEventListener("click",()=>{this.player.sync()})}initScreenshotButton(){this.player.options.screenshot&&this.player.template.cameraButton.addEventListener("click",()=>{const ge=document.createElement("canvas");ge.width=this.player.video.videoWidth,ge.height=this.player.video.videoHeight,ge.getContext("2d").drawImage(this.player.video,0,0,ge.width,ge.height),ge.toBlob(Le=>{if(Le===null)return;const Xe=new Date,ft=`Capture_${Xe.getFullYear()}${("0"+(Xe.getMonth()+1)).slice(-2)}${("0"+Xe.getDate()).slice(-2)}-${("0"+Xe.getHours()).slice(-2)}${("0"+Xe.getMinutes()).slice(-2)}${("0"+Xe.getSeconds()).slice(-2)}.jpg`,_t=URL.createObjectURL(Le),Ct=document.createElement("a");Ct.download!==void 0?(Ct.download=ft,Ct.href=_t,Ct.click(),URL.revokeObjectURL(_t),this.player.events.trigger("screenshot",Le)):this.player.notice("Error: Screenshot download is not supported.",void 0,void 0,"#FF6F6A")},"image/jpeg",1)})}initAirplayButton(){this.player.options.airplay&&(window.WebKitPlaybackTargetAvailabilityEvent?this.player.video.addEventListener("webkitplaybacktargetavailabilitychanged",(function(ge){ge.availability==="available"?this.template.airplayButton.disable=!1:this.template.airplayButton.disable=!0,this.template.airplayButton.addEventListener("click",(function(){this.video.webkitShowPlaybackTargetPicker()}).bind(this))}).bind(this.player)):this.player.template.airplayButton.style.display="none")}initSubtitleButton(){this.player.options.subtitle&&(this.player.events.on("subtitle_show",()=>{this.player.template.subtitleButton.ariaLabel=this.player.tran("Hide subtitle"),this.player.template.subtitleButtonInner.style.opacity="",this.player.user.set("subtitle",1)}),this.player.events.on("subtitle_hide",()=>{this.player.template.subtitleButton.ariaLabel=this.player.tran("Show subtitle"),this.player.template.subtitleButtonInner.style.opacity="0.4",this.player.user.set("subtitle",0)}),this.player.template.subtitleButton.addEventListener("click",()=>{this.player.subtitle!==null&&this.player.subtitle.toggle()}))}setAutoHide(ge=3e3){this.show(),window.clearTimeout(this.autoHideTimer),this.autoHideTimer=window.setTimeout(()=>{!this.player.video.played.length||this.player.paused||this.disableAutoHide||this.hide()},ge)}show(){this.player.container.classList.remove("dplayer-hide-controller")}hide(){this.player.container.classList.add("dplayer-hide-controller"),this.player.setting.hide(),this.player.comment&&this.player.comment.hide()}isShow(){return!this.player.container.classList.contains("dplayer-hide-controller")}toggle(){this.isShow()?this.hide():this.show()}destroy(){Wt.isMobile?this.player.container.removeEventListener("touchmove",this.setAutoHideHandler):(this.player.container.removeEventListener("mousemove",this.setAutoHideHandler),this.player.container.removeEventListener("click",this.setAutoHideHandler)),window.clearTimeout(this.autoHideTimer)}},ma=class{constructor(ge){we(this,"player");we(this,"loop");we(this,"showDanmaku");we(this,"unlimitDanmaku");we(this,"currentAudio","primary");we(this,"resizeObserver");this.player=ge,this.player.template.mask.addEventListener("click",()=>{this.hide()}),this.player.template.settingButton.addEventListener("click",()=>{this.show()});const Le=()=>{const Xe=this.player.template.settingOriginPanel.scrollHeight;this.player.template.settingBox.style.clipPath=`inset(calc(100% - ${Xe}px) 0 0 round 7px)`};if(Le(),this.resizeObserver=new ResizeObserver(Le),this.resizeObserver.observe(this.player.template.settingOriginPanel),this.player.options.video.quality){this.player.template.quality.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-quality")}),this.player.template.qualityHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-quality")});for(let Xe=0;Xe {this.player.switchingQuality||this.player.switchQuality(parseInt(this.player.template.qualityItem[Xe].dataset.index))})}this.player.template.speed.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-speed")}),this.player.template.speedHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-speed")});for(let Xe=0;Xe {this.player.speed(parseFloat(ft.target.dataset.speed))});this.player.template.audio.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-audio")}),this.player.template.audioHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")});for(let Xe=0;Xe {if(this.player.plugins.mpegts||this.player.plugins.liveLLHLSForKonomiTV){if(this.player.template.audioItem[Xe].dataset.audio===this.currentAudio)return;this.player.template.audioItem[Xe].dataset.audio==="primary"?(this.currentAudio="primary",this.player.template.audioItem[0].classList.add("dplayer-setting-audio-current"),this.player.template.audioItem[1].classList.remove("dplayer-setting-audio-current"),this.player.template.audioValue.textContent=this.player.tran("Primary audio"),window.mpegts&&this.player.plugins.mpegts&&this.player.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.player.plugins.mpegts.switchPrimaryAudio():this.player.plugins.liveLLHLSForKonomiTV&&this.player.plugins.liveLLHLSForKonomiTV.switchPrimaryAudio()):this.player.template.audioItem[Xe].dataset.audio==="secondary"&&(this.currentAudio="secondary",this.player.template.audioItem[0].classList.remove("dplayer-setting-audio-current"),this.player.template.audioItem[1].classList.add("dplayer-setting-audio-current"),this.player.template.audioValue.textContent=this.player.tran("Secondary audio"),window.mpegts&&this.player.plugins.mpegts&&this.player.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.player.plugins.mpegts.switchSecondaryAudio():this.player.plugins.liveLLHLSForKonomiTV&&this.player.plugins.liveLLHLSForKonomiTV.switchSecondaryAudio()),this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")}});if(this.loop=this.player.options.loop,this.player.template.loopToggle.checked=this.loop,this.player.template.loop.addEventListener("click",()=>{this.player.template.loopToggle.checked=!this.player.template.loopToggle.checked,this.player.template.loopToggle.checked?this.loop=!0:this.loop=!1}),this.showDanmaku=this.player.user.get("danmaku")===1,this.showDanmaku||this.player.danmaku&&this.player.danmaku.hide(),this.player.template.showDanmakuToggle.checked=this.showDanmaku,this.player.template.showDanmaku.addEventListener("click",()=>{this.player.template.showDanmakuToggle.checked=!this.player.template.showDanmakuToggle.checked,this.player.template.showDanmakuToggle.checked?(this.showDanmaku=!0,this.player.danmaku!==null&&this.player.danmaku.show()):(this.showDanmaku=!1,this.player.danmaku!==null&&this.player.danmaku.hide()),this.player.user.set("danmaku",this.showDanmaku?1:0)}),this.unlimitDanmaku=this.player.user.get("unlimited")===1,this.player.template.unlimitDanmakuToggle.checked=this.unlimitDanmaku,this.player.template.unlimitDanmaku.addEventListener("click",()=>{this.player.template.unlimitDanmakuToggle.checked=!this.player.template.unlimitDanmakuToggle.checked,this.player.template.unlimitDanmakuToggle.checked?(this.unlimitDanmaku=!0,this.player.danmaku!==null&&this.player.danmaku.unlimit(!0)):(this.unlimitDanmaku=!1,this.player.danmaku!==null&&this.player.danmaku.unlimit(!1)),this.player.user.set("unlimited",this.unlimitDanmaku?1:0)}),this.player.danmaku){this.player.on("danmaku_opacity",Ct=>{this.player.bar.set("danmaku",Ct,"width"),this.player.user.set("opacity",Ct),this.player.template.danmakuOpacityValue.textContent=Ct.toFixed(1)}),this.player.danmaku.opacity(this.player.user.get("opacity")),this.player.template.danmakuOpacityValue.textContent=this.player.user.get("opacity").toFixed(1);const ft=Ct=>{const Pt=Ct||window.event;let ci=((Pt.clientX||Pt.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.danmakuOpacityBarWrap))/190;ci=Math.max(ci,0),ci=Math.min(ci,1),this.player.danmaku!==null&&this.player.danmaku.opacity(ci)},_t=()=>{document.removeEventListener(Wt.nameMap.dragEnd,_t),document.removeEventListener(Wt.nameMap.dragMove,ft),this.player.template.danmakuOpacityBox.classList.remove("dplayer-setting-danmaku-active")};this.player.template.danmakuOpacityBarWrapWrap.addEventListener("click",Ct=>{const Pt=Ct||window.event;let ci=((Pt.clientX||Pt.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.danmakuOpacityBarWrap))/190;ci=Math.max(ci,0),ci=Math.min(ci,1),this.player.danmaku!==null&&this.player.danmaku.opacity(ci)}),this.player.template.danmakuOpacityBarWrapWrap.addEventListener(Wt.nameMap.dragStart,()=>{document.addEventListener(Wt.nameMap.dragMove,ft),document.addEventListener(Wt.nameMap.dragEnd,_t),this.player.template.danmakuOpacityBox.classList.add("dplayer-setting-danmaku-active")})}}hide(){this.player.template.container.classList.remove("dplayer-show-controller"),this.player.template.settingBox.classList.remove("dplayer-setting-box-open"),this.player.template.mask.classList.remove("dplayer-mask-show"),window.setTimeout(()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-speed"),this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")},300),this.player.controller.disableAutoHide=!1}show(){this.player.template.container.classList.add("dplayer-show-controller"),this.player.template.settingBox.classList.add("dplayer-setting-box-open"),this.player.template.mask.classList.add("dplayer-mask-show"),this.player.controller.disableAutoHide=!0}destroy(){this.resizeObserver.disconnect()}},nl=class{constructor(ge){we(this,"player");this.player=ge,this.player.template.mask.addEventListener("click",()=>{this.hide()}),this.player.template.commentButton.addEventListener("click",()=>{this.show()}),this.player.template.commentSettingButton.addEventListener("click",()=>{this.toggleSetting()}),this.player.template.commentColorSettingBox.addEventListener("click",()=>{if(this.player.template.commentColorSettingBox.querySelector("input:checked+span")){const Le=this.player.template.commentColorSettingBox.querySelector("input:checked").value;this.player.template.commentSettingFill.style.fill=Le,this.player.template.commentInput.style.color=Le,this.player.template.commentSendFill.style.fill=Le}}),this.player.template.commentInput.addEventListener("click",()=>{this.hideSetting()}),this.player.template.commentInput.addEventListener("keydown",Le=>{(Le||window.event).keyCode===13&&this.send()}),this.player.template.commentSendButton.addEventListener("click",()=>{this.send()})}show(){this.player.controller.disableAutoHide=!0,this.player.template.controller.classList.add("dplayer-controller-comment"),this.player.template.mask.classList.add("dplayer-mask-show"),this.player.container.classList.add("dplayer-show-controller"),this.player.template.commentInput.focus()}hide(){this.player.template.controller.classList.remove("dplayer-controller-comment"),this.player.template.mask.classList.remove("dplayer-mask-show"),this.player.container.classList.remove("dplayer-show-controller"),this.player.controller.disableAutoHide=!1,this.hideSetting()}showSetting(){this.player.template.commentSettingBox.classList.add("dplayer-comment-setting-open")}hideSetting(){this.player.template.commentSettingBox.classList.remove("dplayer-comment-setting-open")}toggleSetting(){this.player.template.commentSettingBox.classList.contains("dplayer-comment-setting-open")?this.hideSetting():this.showSetting()}send(){var ge;((ge=this.player.options.danmaku)==null?void 0:ge.closeCommentFormAfterSend)===!0&&this.player.template.commentInput.blur(),this.player.template.commentInput.value.replace(/^\s+|\s+$/g,"")?(this.player.danmaku!==null&&this.player.danmaku.send({text:this.player.template.commentInput.value,color:this.player.container.querySelector(".dplayer-comment-setting-color input:checked").value,type:this.player.container.querySelector(".dplayer-comment-setting-type input:checked").value,size:this.player.container.querySelector(".dplayer-comment-setting-size input:checked").value},()=>{var Le;((Le=this.player.options.danmaku)==null?void 0:Le.closeCommentFormAfterSend)===!0&&(this.hide(),this.player.controller.setAutoHide(750))},!0),this.player.template.commentInput.value=""):this.player.notice(this.player.tran("Please input danmaku content!"),void 0,void 0,"#FF6F6A")}},Is=class{constructor(ge){we(this,"player");we(this,"doHotKeyHandler");we(this,"cancelFullScreenHandler");this.player=ge,this.doHotKeyHandler=this.doHotKey.bind(this),this.cancelFullScreenHandler=this.cancelFullScreen.bind(this),this.player.options.hotkey&&document.addEventListener("keydown",this.doHotKeyHandler),document.addEventListener("keydown",this.cancelFullScreenHandler)}doHotKey(ge){var ft,_t;const Le=(ft=document.activeElement)==null?void 0:ft.tagName.toUpperCase(),Xe=(_t=document.activeElement)==null?void 0:_t.getAttribute("contenteditable");if(Le!=="INPUT"&&Le!=="TEXTAREA"&&Xe!==""&&Xe!=="true"){const Ct=ge||window.event;let Pt;switch(Ct.keyCode){case 32:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),this.player.toggle());break;case 37:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),Ct.altKey?this.player.seek(this.player.video.currentTime-60):Ct.shiftKey?this.player.seek(this.player.video.currentTime-30):Ct.ctrlKey||Ct.metaKey?this.player.seek(this.player.video.currentTime-15):this.player.seek(this.player.video.currentTime-5),this.player.controller.setAutoHide());break;case 39:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),Ct.altKey?this.player.seek(this.player.video.currentTime+60):Ct.shiftKey?this.player.seek(this.player.video.currentTime+30):Ct.ctrlKey||Ct.metaKey?this.player.seek(this.player.video.currentTime+15):this.player.seek(this.player.video.currentTime+5),this.player.controller.setAutoHide());break;case 38:this.player.focus&&(Ct.preventDefault(),Pt=this.player.volume()+.1,this.player.volume(Pt));break;case 40:this.player.focus&&(Ct.preventDefault(),Pt=this.player.volume()-.1,this.player.volume(Pt));break;case 70:Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.fullScreen.toggle("browser"));break;case 87:Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.fullScreen.toggle("web"));break;case 76:this.player.options.live&&(Ct.preventDefault(),this.player.sync());break;case 80:this.player.options.pictureInPicture&&document.pictureInPictureEnabled&&(Ct.preventDefault(),this.player.template.pipButton.click());break;case 67:typeof this.player.options.danmaku=="object"&&this.player.options.danmaku&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.controller.show(),this.player.comment!=null&&this.player.comment.show()));break;case 68:typeof this.player.options.danmaku=="object"&&this.player.options.danmaku&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.template.showDanmaku.click(),this.player.template.showDanmakuToggle.checked?this.player.notice(`${this.player.tran("Show comment")}`):this.player.notice(`${this.player.tran("Hide comment")}`)));break;case 83:this.player.options.subtitle&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.subtitle!==null&&(this.player.subtitle.container.classList.contains("dplayer-subtitle-hide")?this.player.notice(`${this.player.tran("Show subtitle")}`):this.player.notice(`${this.player.tran("Hide subtitle")}`),this.player.subtitle.toggle())))}}}cancelFullScreen(ge){(ge||window.event).keyCode===27&&this.player.fullScreen.isFullScreen("web")&&this.player.fullScreen.cancel("web")}destroy(){this.player.options.hotkey&&document.removeEventListener("keydown",this.doHotKeyHandler),document.removeEventListener("keydown",this.cancelFullScreenHandler)}},Na=class{constructor(ge){we(this,"contextmenuHandler");we(this,"player");we(this,"shown");this.player=ge,this.shown=!1,Array.prototype.slice.call(this.player.template.menuItem).forEach((Le,Xe)=>{this.player.options.contextmenu[Xe].click&&Le.addEventListener("click",()=>{const ft=this.player.options.contextmenu[Xe];ft.click&&ft.click(this.player),this.hide()})}),this.contextmenuHandler=Le=>{const Xe=Le||window.event;if(Xe.preventDefault(),this.shown)return void this.hide();const ft=this.player.container.getBoundingClientRect();this.show(Xe.clientX-ft.left,Xe.clientY-ft.top),this.player.template.mask.addEventListener("click",()=>{this.hide()})},this.player.container.addEventListener("contextmenu",this.contextmenuHandler)}show(ge,Le){this.player.template.menu.classList.add("dplayer-menu-show");const Xe=this.player.container.getBoundingClientRect();ge+this.player.template.menu.offsetWidth>=Xe.width?(this.player.template.menu.style.right=Xe.width-ge+"px",this.player.template.menu.style.left="initial"):(this.player.template.menu.style.left=ge+"px",this.player.template.menu.style.right="initial"),Le+this.player.template.menu.offsetHeight>=Xe.height?(this.player.template.menu.style.bottom=Xe.height-Le+"px",this.player.template.menu.style.top="initial"):(this.player.template.menu.style.top=Le+"px",this.player.template.menu.style.bottom="initial"),this.player.template.mask.classList.add("dplayer-mask-show"),this.shown=!0,this.player.events.trigger("contextmenu_show")}hide(){this.player.template.mask.classList.remove("dplayer-mask-show"),this.player.template.menu.classList.remove("dplayer-menu-show"),this.shown=!1,this.player.events.trigger("contextmenu_hide")}destroy(){this.player.container.removeEventListener("contextmenu",this.contextmenuHandler)}},us=class{constructor(ge){we(this,"player");we(this,"container");we(this,"template");we(this,"video");we(this,"beginTime",0);this.player=ge,this.container=ge.template.infoPanel,this.template=ge.template,this.video=ge.video,this.template.infoPanelClose.addEventListener("click",()=>{this.hide()})}show(){this.beginTime=Date.now(),this.update(),this.player.timer.enable("info"),this.player.timer.enable("fps"),this.container.classList.remove("dplayer-info-panel-hide")}hide(){this.player.timer.disable("info"),this.player.timer.disable("fps"),this.container.classList.add("dplayer-info-panel-hide")}toggle(){this.container.classList.contains("dplayer-info-panel-hide")?this.show():this.hide()}update(){var ge;if(this.template.infoVersion.textContent="v1.31.2 7131b6b",this.template.infoType.textContent=this.player.type,this.template.infoUrl.textContent=this.player.options.video.url??"N/A",this.template.infoResolution.textContent=`${this.player.video.videoWidth} x ${this.player.video.videoHeight}`,this.template.infoDuration.textContent=`${this.player.video.duration}`,this.player.video.getVideoPlaybackQuality!=null){const Le=this.player.video.getVideoPlaybackQuality();this.template.infoDroppedFrames.textContent=`${Le.droppedVideoFrames} / ${Le.totalVideoFrames}`}else if(this.player.video.webkitDecodedFrameCount!=null){const Le=this.player.video.webkitDecodedFrameCount,Xe=this.player.video.webkitDroppedFrameCount;this.template.infoDroppedFrames.textContent=`${Xe} / ${Le}`}else this.template.infoDroppedFrames.textContent="N/A";if(this.player.video.buffered.length>0){const Le=this.player.video.buffered.length,Xe=this.player.video.buffered.end(Le-1)-this.player.video.currentTime;this.template.infoBufferRemain.textContent=`${Xe.toFixed(3)} s`}else this.template.infoBufferRemain.textContent="N/A";if(this.player.type==="mpegts"||this.player.type==="flv"){const Le=this.player.plugins.mpegts||this.player.plugins.flvjs;if(Le){const Xe=Le.mediaInfo,ft=Le.statisticsInfo;this.template.infoMimeType.textContent=Xe.mimeType??"N/A",this.template.infoVideoFPS.textContent=`${((ge=Xe.fps)==null?void 0:ge.toFixed(3))??"N/A"}`,ft.speed!=null?this.template.infoDownloadSpeed.textContent=`${ft.speed.toFixed(3)} KB/s`:this.template.infoDownloadSpeed.textContent="N/A"}}else this.template.infoMimeType.textContent="N/A",this.template.infoVideoFPS.textContent="N/A",this.template.infoDownloadSpeed.textContent="N/A"}fps(ge){this.template.infoPageFPS.textContent=`${ge.toFixed(1)}`}};var Fa=y(953),$r=y.n(Fa);let es=0;const ts=[],Ls=class{constructor(ge){we(this,"bar");we(this,"bezel");we(this,"comment",null);we(this,"contextmenu");we(this,"controller");we(this,"danmaku",null);we(this,"events");we(this,"fullScreen");we(this,"hotkey");we(this,"infoPanel");we(this,"setting");we(this,"subtitle",null);we(this,"template");we(this,"timer");we(this,"user");we(this,"container");we(this,"containerClickFun");we(this,"docClickFun");we(this,"focus",!1);we(this,"narrow",!1);we(this,"noticeTime",null);we(this,"options");we(this,"paused",!1);we(this,"plugins");we(this,"prevVideoCurrentTime",0);we(this,"prevVideo",null);we(this,"quality",null);we(this,"qualityIndex",null);we(this,"switchingQuality",!1);we(this,"resizeObserver");we(this,"tran");we(this,"type","auto");we(this,"video");this.options=(Le=>{const Xe={container:Le.container||document.querySelector(".dplayer")||void 0,live:!1,liveSyncMinBufferSize:.8,syncWhenPlayingLive:!0,autoplay:!1,theme:"#b7daff",loop:!1,lang:navigator.language.toLowerCase(),screenshot:!1,pictureInPicture:!0,airplay:!0,hotkey:!0,preload:"metadata",crossOrigin:null,volume:1,playbackSpeed:[.25,.5,.75,1,1.25,1.5,1.75,2],apiBackend:oi,video:{},contextmenu:[],mutex:!0,pluginOptions:{}};for(const ft in Xe)Object.prototype.hasOwnProperty.call(Xe,ft)&&!Object.prototype.hasOwnProperty.call(Le,ft)&&(Le[ft]=Xe[ft]);return Le.video&&!Le.video.type&&(Le.video.type="auto"),typeof Le.danmaku=="object"&&Le.danmaku&&(!Le.danmaku.user&&(Le.danmaku.user="DPlayer"),!Le.danmaku.speedRate&&(Le.danmaku.speedRate=1),!Le.danmaku.fontSize&&(Le.danmaku.fontSize=35),Le.danmaku.closeCommentFormAfterSend!==!1&&(Le.danmaku.closeCommentFormAfterSend=!0)),Le.subtitle&&(!Le.subtitle.type&&(Le.subtitle.type="webvtt"),!Le.subtitle.fontSize&&(Le.subtitle.fontSize="20px"),!Le.subtitle.bottom&&(Le.subtitle.bottom="40px"),!Le.subtitle.color&&(Le.subtitle.color="#fff")),Le.video.quality&&(typeof Le.video.defaultQuality=="string"&&(Le.video.quality.forEach((ft,_t)=>{Le.video.defaultQuality===ft.name&&(Le.video.defaultQuality=_t)}),typeof Le.video.defaultQuality=="string"&&(Le.video.defaultQuality=0)),Le.video.defaultQuality===void 0&&(Le.video.defaultQuality=0),Le.video.type=Le.video.quality[Le.video.defaultQuality].type,Le.video.url=Le.video.quality[Le.video.defaultQuality].url),Le.lang&&(Le.lang=Le.lang.toLowerCase()),Le.contextmenu=Le.contextmenu.concat([{text:"Video info",click:ft=>{ft.infoPanel.toggle()}},{text:"DPlayer v1.31.2",link:"https://github.com/tsukumijima/DPlayer"}]),{container:Le.container,live:Le.live,liveSyncMinBufferSize:Le.liveSyncMinBufferSize,syncWhenPlayingLive:Le.syncWhenPlayingLive,autoplay:Le.autoplay,theme:Le.theme,loop:Le.loop,lang:Le.lang,screenshot:Le.screenshot,pictureInPicture:Le.pictureInPicture,airplay:Le.airplay,hotkey:Le.hotkey,preload:Le.preload,crossOrigin:Le.crossOrigin,volume:Le.volume,playbackSpeed:Le.playbackSpeed,logo:Le.logo,apiBackend:Le.apiBackend,video:Le.video,subtitle:Le.subtitle,danmaku:Le.danmaku,contextmenu:Le.contextmenu,highlight:Le.highlight,mutex:Le.mutex,pluginOptions:Le.pluginOptions}})({preload:ge.video.type==="webtorrent"?"none":"metadata",...ge}),this.options.video.quality&&(this.qualityIndex=this.options.video.defaultQuality,this.quality=this.options.video.quality[this.options.video.defaultQuality]),this.tran=new ui(this.options.lang).tran,this.events=new tl,this.user=new Er(this),this.container=this.options.container,this.container.classList.add("dplayer"),this.options.danmaku||this.container.classList.add("dplayer-no-danmaku"),this.options.live?this.container.classList.add("dplayer-live"):this.container.classList.remove("dplayer-live"),Wt.isMobile&&this.container.classList.add("dplayer-mobile"),this.narrow=this.container.offsetWidth<=500,this.narrow&&this.container.classList.add("dplayer-narrow"),this.resizeObserver=new ResizeObserver(Le=>{for(const Xe of Le)Xe.target===this.container&&(this.narrow=this.container.offsetWidth<=500,this.narrow?this.container.classList.add("dplayer-narrow"):this.container.classList.remove("dplayer-narrow"))}),this.resizeObserver.observe(this.container),this.template=new ha({container:this.container,options:this.options,index:es,tran:this.tran}),this.video=this.template.video,this.bar=new Xr(this.template),this.bezel=new Ba(this.template.bezel),this.fullScreen=new fa(this),this.controller=new pa(this),this.options.danmaku&&(this.danmaku=new el({player:this,container:this.template.danmaku,opacity:this.user.get("opacity"),callback:()=>{setTimeout(()=>{this.template.danmakuLoading.style.display="none",this.options.autoplay&&this.play()},0)},error:Le=>{this.notice(Le,void 0,void 0,"#FF6F6A")},apiBackend:this.options.apiBackend,borderColor:this.options.theme,fontSize:this.options.danmaku.fontSize,time:()=>this.video.currentTime,unlimited:this.user.get("unlimited"),speedRate:this.options.danmaku.speedRate,api:{id:this.options.danmaku.id,address:this.options.danmaku.api,token:this.options.danmaku.token,maximum:this.options.danmaku.maximum,addition:this.options.danmaku.addition,user:this.options.danmaku.user},events:this.events,tran:Le=>this.tran(Le)}),this.comment=new nl(this)),this.plugins={},this.docClickFun=()=>{this.focus=!1},this.containerClickFun=()=>{this.focus=!0},document.addEventListener("click",this.docClickFun,!0),this.container.addEventListener("click",this.containerClickFun,!0),this.paused=!0,this.timer=new Rs(this),this.hotkey=new Is(this),this.contextmenu=new Na(this),this.initVideo(this.video,this.quality&&this.quality.type||this.options.video.type),this.setting=new ma(this),this.infoPanel=new us(this),!this.danmaku&&this.options.autoplay&&this.play(),es++,ts.push(this)}seek(ge){ge=Math.max(ge,0);const Le=Wt.getVideoDuration(this.video,this.template);Le&&(ge=Math.min(ge,Le)),this.video.currentTime ge&&this.notice(`${this.tran("REW")} ${(this.video.currentTime-ge).toFixed(0)} ${this.tran("s")}`),isFinite(ge)&&(this.video.currentTime=ge),this.danmaku&&this.danmaku.seek(),this.bar.set("played",ge/Le,"width"),this.template.ptime.textContent=Wt.secondToTime(ge)}sync(ge=!1){if(this.options.live){const Le=Wt.getVideoDuration(this.video,this.template)-this.options.liveSyncMinBufferSize;try{this.video.currentTime=Le}catch{return}this.danmaku&&this.danmaku.seek(),this.template.ptime.textContent=Wt.secondToTime(Le),ge||this.notice(this.tran("Synchronized"))}}play(ge=!1){if(this.paused=!1,this.video.paused&&!Wt.isMobile&&this.bezel.switch(En.play),this.template.playButton.innerHTML=En.pause,this.template.mobilePlayButton.innerHTML=En.pause,this.options.live&&this.options.syncWhenPlayingLive&&this.sync(!0),!ge){const Le=this.type==="mpegts"&&this.plugins.mpegts&&this.plugins.mpegts.play.bind(this.plugins.mpegts)||this.video.play.bind(this.video);Promise.resolve(Le()).catch(()=>{this.pause()}).then(()=>{})}if(this.timer.enable("loading"),this.container.classList.remove("dplayer-paused"),this.container.classList.add("dplayer-playing"),this.danmaku&&this.danmaku.play(),this.options.mutex)for(let Le=0;Le =.95?this.template.volumeIcon.innerHTML=En.volumeUp:this.volume()>0?this.template.volumeIcon.innerHTML=En.volumeDown:this.template.volumeIcon.innerHTML=En.volumeOff}volume(ge=NaN,Le=!1,Xe=!1){if(typeof ge=="string"&&(ge=parseFloat(ge)),!isNaN(ge)){ge=Math.max(ge,0),ge=Math.min(ge,1),this.bar.set("volume",ge,"width");const ft=`${(100*ge).toFixed(0)}%`;this.template.volumeBarWrapWrap.ariaLabel=ft,Le||this.user.set("volume",ge),Xe||this.notice(`${this.tran("Volume")} ${(100*ge).toFixed(0)}%`),this.video.volume=ge,this.video.muted&&(this.video.muted=!1),this.switchVolumeIcon()}return this.video.volume}toggle(){this.video.paused?this.play():this.pause()}on(ge,Le,Xe=!1){this.events.on(ge,Le,Xe)}off(ge,Le){this.events.off(ge,Le)}switchVideo(ge,Le){this.pause(),this.video.poster=ge.pic?ge.pic:"",this.video.src=ge.url,this.initMSE(this.video,ge.type||"auto"),Le&&(this.template.danmakuLoading.style.display="block",this.bar.set("played",0,"width"),this.bar.set("loaded",0,"width"),this.template.ptime.textContent="00:00",this.template.danmaku.innerHTML="",this.danmaku&&this.danmaku.reload({id:Le.id,address:Le.api,token:Le.token,maximum:Le.maximum,addition:Le.addition,user:Le.user}))}initMSE(ge,Le){if(this.type=Le,this.options.video.customType&&this.options.video.customType[Le])Object.prototype.toString.call(this.options.video.customType[Le])==="[object Function]"?this.options.video.customType[Le](this.video,this):console.error(`Illegal customType: ${Le}`);else switch(this.type==="auto"&&(/m3u8(#|\?|$)/i.exec(ge.src)?this.type="hls":/.ts(#|\?|$)/i.exec(ge.src)?this.type="mpegts":/.flv(#|\?|$)/i.exec(ge.src)?this.type="flv":/.mpd(#|\?|$)/i.exec(ge.src)?this.type="dash":this.type="normal"),this.type!=="mpegts"&&this.type!=="live-llhls-for-KonomiTV"&&this.container.classList.add("dplayer-no-audio-switching"),this.type){case"hls":if(window.Hls){const Xe=/Safari/i.test(navigator.userAgent)&&/iPad|Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document&&(ge.canPlayType("application/x-mpegURL")||ge.canPlayType("application/vnd.apple.mpegURL"));if(window.Hls.isSupported()&&!Xe){this.plugins.hls&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.plugins.hls.destroy(),delete this.plugins.hls);const ft=this.options.pluginOptions.hls,_t=new window.Hls(ft);if(this.plugins.hls=_t,_t.loadSource(ge.src),_t.attachMedia(ge),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),_t.destroy(),delete this.plugins.hls}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!1;const Ct=this.options.pluginOptions.aribb24,Pt=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...Ct,data_identifier:128});if(Pt.attachMedia(ge),Pt.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const ci=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...Ct,data_identifier:129});ci.attachMedia(ge),ci.show()}_t.on(window.Hls.Events.FRAG_PARSING_METADATA,(ci,hi)=>{for(const Xt of hi.samples)this.plugins.aribb24Caption&&this.plugins.aribb24Caption.pushID3v2Data(Xt.pts,Xt.data),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.pushID3v2Data(Xt.pts,Xt.data)})}}else if(ge.canPlayType("application/x-mpegURL")||ge.canPlayType("application/vnd.apple.mpegURL")){if(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose)}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!0;const ft=this.options.pluginOptions.aribb24,_t=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...ft,data_identifier:128});if(_t.attachMedia(ge),_t.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ct=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...ft,data_identifier:129});Ct.attachMedia(ge),Ct.show()}}}else this.notice("Error: HLS is not supported.",void 0,void 0,"#FF6F6A")}else this.notice("Error: Can't find hls.js.",void 0,void 0,"#FF6F6A");break;case"live-llhls-for-KonomiTV":this.plugins.liveLLHLSForKonomiTV&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),jt.delete(`${this.plugins.liveLLHLSForKonomiTV.baseUrl}/${this.plugins.liveLLHLSForKonomiTV.clientId}`),delete this.plugins.liveLLHLSForKonomiTV),(async()=>{const Xe=this.quality!==null?this.quality.url:this.options.video.url,ft=(await jt.post(Xe)).data.client_id,_t=(Pt=!1)=>{let ci=Xe.replace("/ll-hls",`/ll-hls/${ft}/primary-audio/playlist.m3u8`);if(Pt===!0&&(ci=Xe.replace("/ll-hls",`/ll-hls/${ft}/secondary-audio/playlist.m3u8`)),ge.src===ci)return;const hi=ge.paused;if(ge.src=ci,ge.load(),this.plugins.aribb24Caption&&this.plugins.aribb24Caption.dispose(),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.dispose(),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!0;const Xt=this.options.pluginOptions.aribb24,_i=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...Xt,data_identifier:128});if(_i.attachMedia(ge),_i.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ui=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...Xt,data_identifier:129});Ui.attachMedia(ge),Ui.show()}}hi||ge.play()},Ct={baseUrl:Xe,clientId:ft,switchPrimaryAudio(){_t(!1)},switchSecondaryAudio(){_t(!0)}};this.plugins.liveLLHLSForKonomiTV=Ct,_t(!1),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),jt.delete(`${Ct.baseUrl}/${Ct.clientId}`),delete this.plugins.liveLLHLSForKonomiTV})})();break;case"mpegts":if(window.mpegts)if(window.mpegts.isSupported()){this.plugins.mpegts&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.plugins.mpegts.unload(),this.plugins.mpegts.detachMediaElement(),this.plugins.mpegts.destroy(),delete this.plugins.mpegts),this.options.pluginOptions.mpegts===void 0&&(this.options.pluginOptions.mpegts={});const Xe=window.mpegts.createPlayer(Object.assign(this.options.pluginOptions.mpegts.mediaDataSource||{},{type:"mpegts",isLive:this.options.live,url:ge.src}),this.options.pluginOptions.mpegts.config);if(this.plugins.mpegts=Xe,Xe.attachMediaElement(ge),Xe.load(),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),Xe.unload(),Xe.detachMediaElement(),Xe.destroy(),delete this.plugins.mpegts}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!1;const ft=this.options.pluginOptions.aribb24,_t=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...ft,data_identifier:128});if(_t.attachMedia(ge),_t.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ct=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...ft,data_identifier:129});Ct.attachMedia(ge),Ct.show()}Xe.on(window.mpegts.Events.TIMED_ID3_METADATA_ARRIVED,Ct=>{this.plugins.aribb24Caption&&this.plugins.aribb24Caption.pushID3v2Data(Ct.pts/1e3,Ct.data),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.pushID3v2Data(Ct.pts/1e3,Ct.data)})}}else this.notice("Error: mpegts.js is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find mpegts.js.",void 0,void 0,"#FF6F6A");break;case"flv":if(window.flvjs)if(window.flvjs.isSupported()){this.options.pluginOptions.flv===void 0&&(this.options.pluginOptions.flv={});const Xe=window.flvjs.createPlayer(Object.assign(this.options.pluginOptions.flv.mediaDataSource||{},{type:"flv",url:ge.src}),this.options.pluginOptions.flv.config);this.plugins.flvjs=Xe,Xe.attachMediaElement(ge),Xe.load(),this.events.on("destroy",()=>{Xe.unload(),Xe.detachMediaElement(),Xe.destroy(),delete this.plugins.flvjs})}else this.notice("Error: flv.js is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find flv.js.",void 0,void 0,"#FF6F6A");break;case"dash":if(window.dashjs){const Xe=window.dashjs.MediaPlayer().create();Xe.initialize(ge,ge.src,!1);const ft=this.options.pluginOptions.dash;Xe.updateSettings(ft??{}),this.plugins.dash=Xe,this.events.on("destroy",()=>{Xe.reset(),delete this.plugins.dash})}else this.notice("Error: Can't find dash.js.",void 0,void 0,"#FF6F6A");break;case"webtorrent":if(window.WebTorrent)if(window.WebTorrent.WEBRTC_SUPPORT){this.container.classList.add("dplayer-loading");const Xe=this.options.pluginOptions.webtorrent,ft=new window.WebTorrent(Xe);this.plugins.webtorrent=ft;const _t=ge.src;ge.src="",ge.preload="metadata",ge.addEventListener("durationchange",()=>this.container.classList.remove("dplayer-loading"),{once:!0}),ft.add(_t,Ct=>{const Pt=Ct.files.find(ci=>ci.name.endsWith(".mp4"));Pt&&Pt.renderTo(this.video,{autoplay:this.options.autoplay,controls:!1})}),this.events.on("destroy",()=>{ft.remove(_t),ft.destroy(),delete this.plugins.webtorrent})}else this.notice("Error: Webtorrent is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find Webtorrent.",void 0,void 0,"#FF6F6A")}}initVideo(ge,Le){this.initMSE(ge,Le),this.on("durationchange",()=>{ge.duration!==1&&ge.duration!==1/0&&(this.template.dtime.textContent=Wt.secondToTime(ge.duration))}),this.on("progress",()=>{const Xe=Wt.getVideoDuration(this.video,this.template),ft=ge.buffered.length?ge.buffered.end(ge.buffered.length-1)/Xe:0;this.bar.set("loaded",ft,"width")}),this.on("error",()=>{this.video.error&&(this.switchingQuality&&(this.prevVideo!==null&&this.template.videoWrapAspect.removeChild(this.prevVideo),this.video.classList.add("dplayer-video-current"),this.prevVideo=null,this.switchingQuality=!1,this.events.trigger("quality_end")),this.tran&&this.notice&&this.type!=="webtorrent"&&this.type!=="live-llhls-for-KonomiTV"&&this.notice(this.tran("Video load failed"),-1,void 0,"#FF6F6A"),this.container.classList.remove("dplayer-loading"))}),this.on("ended",()=>{this.bar.set("played",1,"width"),this.setting.loop?(this.seek(0),this.play()):this.pause(),this.danmaku&&(this.danmaku.danIndex=0)}),this.on("play",()=>{this.paused&&this.play(!0)}),this.on("pause",()=>{this.paused||this.pause(!0)}),this.on("timeupdate",()=>{const Xe=Wt.getVideoDuration(this.video,this.template);this.bar.set("played",this.video.currentTime/Xe,"width");const ft=Wt.secondToTime(this.video.currentTime);this.template.ptime.textContent!==ft&&(this.template.ptime.textContent=ft)});for(let Xe=0;Xe {this.events.trigger(this.events.videoEvents[Xe],ft)});this.volume(this.user.get("volume"),!0,!0),this.options.subtitle&&(this.subtitle=new ks(this.template.subtitle,this.video,this.plugins,this.options.subtitle,this.events),this.user.get("subtitle")||this.subtitle.hide())}switchQuality(ge){if(ge=typeof ge=="string"?parseInt(ge):ge,this.options.video.quality===void 0||this.qualityIndex===ge||this.switchingQuality)return;this.qualityIndex=ge,this.switchingQuality=!0,this.quality=this.options.video.quality[ge];const Le=this.video.paused;this.video.pause();const Xe=$r()({current:!1,pic:null,screenshot:this.options.screenshot,preload:"auto",url:this.quality.type==="live-llhls-for-KonomiTV"?"":this.quality.url,subtitle:this.options.subtitle,crossOrigin:this.options.crossOrigin}),ft=new DOMParser().parseFromString(Xe,"text/html").body.firstChild;this.template.videoWrapAspect.insertBefore(ft,this.template.videoWrapAspect.getElementsByTagName("div")[0]),this.prevVideoCurrentTime=this.video.currentTime,this.prevVideo=this.video,this.video=ft,this.initVideo(this.video,this.quality.type||this.options.video.type),this.options.live||this.seek(this.prevVideoCurrentTime),Le||this.video.play(),this.options.lang==="ja"||this.options.lang==="ja-jp"?this.notice(`画質を ${this.quality.name} に切り替えています…`,-1):this.notice(`${this.tran("Switching to")} ${this.quality.name} ${this.tran("quality")}`,-1),this.container.classList.add("dplayer-loading"),this.events.trigger("quality_start",this.quality),this.template.qualityItem.forEach(_t=>{_t.classList.remove("dplayer-setting-quality-current"),parseInt(_t.dataset.index)===ge&&(_t.classList.add("dplayer-setting-quality-current"),this.template.qualityValue.textContent=this.quality.name,this.template.settingBox.classList.remove("dplayer-setting-box-quality"))}),this.on("canplay",()=>{if(this.prevVideo!==null){if(!this.options.live&&this.video.currentTime!==this.prevVideoCurrentTime)return void this.seek(this.prevVideoCurrentTime);this.template.videoWrapAspect.removeChild(this.prevVideo),this.video.classList.add("dplayer-video-current"),Le||this.video.play(),this.prevVideo=null,this.options.lang==="ja"||this.options.lang==="ja-jp"?this.notice(`画質を ${this.quality.name} に切り替えました。`,1e3):this.notice(`${this.tran("Switched to")} ${this.quality.name} ${this.tran("quality")}`),this.switchingQuality=!1;const _t=parseFloat(this.template.settingBox.querySelector(".dplayer-setting-speed-current").dataset.speed);this.speed(_t),this.template.settingBox.querySelector(".dplayer-setting-audio-current").dataset.audio==="secondary"&&(window.mpegts&&this.plugins.mpegts&&this.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.plugins.mpegts.switchSecondaryAudio():this.plugins.liveLLHLSForKonomiTV&&this.plugins.liveLLHLSForKonomiTV.switchSecondaryAudio()),this.container.classList.remove("dplayer-loading"),this.events.trigger("quality_end")}})}notice(ge,Le=2e3,Xe=.8,ft){this.template.notice.textContent=ge,this.template.notice.style.opacity=`${Xe}`,this.template.notice.style.color=ft&&ft!==""?ft:"",this.noticeTime&&window.clearTimeout(this.noticeTime),this.events.trigger("notice_show",ge),Le>0&&(this.noticeTime=window.setTimeout(()=>{this.hideNotice()},Le))}hideNotice(){this.template.notice.style.opacity="0",this.events.trigger("notice_hide")}resize(){this.danmaku&&this.danmaku.resize(),this.plugins.aribb24Caption&&this.plugins.aribb24Caption.refresh(),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.refresh(),this.controller.thumbnails&&this.controller.thumbnails.resize(160,this.video.videoHeight/this.video.videoWidth*160,this.template.barWrap.offsetWidth),this.events.trigger("resize")}speed(ge){this.video.playbackRate=ge,this.template.speedItem.forEach(Le=>{Le.classList.remove("dplayer-setting-speed-current"),parseFloat(Le.dataset.speed)===ge&&(Le.classList.add("dplayer-setting-speed-current"),parseFloat(Le.dataset.speed)===1?this.template.speedValue.textContent=this.tran("Normal"):this.template.speedValue.textContent=`${ge}`,this.template.settingBox.classList.remove("dplayer-setting-box-speed"))})}destroy(ge=!1){ts.splice(ts.indexOf(this),1),this.pause(),document.removeEventListener("click",this.docClickFun,!0),this.container.removeEventListener("click",this.containerClickFun,!0),this.fullScreen.destroy(),this.hotkey.destroy(),this.contextmenu.destroy(),this.controller.destroy(),this.timer.destroy(),this.setting.destroy(),this.resizeObserver.disconnect(),this.video.src="",ge||(this.container.innerHTML=""),this.events.trigger("destroy")}static get version(){return"1.31.2"}};console.log(` +`);let ft=0;for(let _t=0;_t =this.options.time()){this.danIndex=ge;break}this.danIndex=this.dan.length}}clear(){this.danTunnel={right:{},top:{},bottom:{}},this.danIndex=0,this.options.container.innerHTML="",this.events&&this.events.trigger("danmaku_clear")}htmlEncode(ge){return ge.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}resize(){const ge=this.container.offsetWidth,Le=this.container.querySelectorAll(".dplayer-danmaku-item");for(let Xe=0;Xe {this.player.resize()}),this.player.events.on("webfullscreen_cancel",()=>{this.player.resize(),Wt.setScrollPosition(this.lastScrollPosition)}),this.fullscreenchange=()=>{this.player.resize(),this.isFullScreen("browser")?this.player.events.trigger("fullscreen"):(Wt.setScrollPosition(this.lastScrollPosition),this.player.container.classList.remove("dplayer-fulled-browser"),this.player.events.trigger("fullscreen_cancel"))},this.player.container.onfullscreenchange!==void 0?this.player.container.addEventListener("fullscreenchange",this.fullscreenchange):this.player.container.addEventListener("webkitfullscreenchange",this.fullscreenchange)}isFullScreen(ge="browser"){switch(ge){case"browser":{const Le=document.fullscreenElement||document.webkitFullscreenElement;return!(!Le||Le!==this.player.container)}case"web":return this.player.container.classList.contains("dplayer-fulled")}}request(ge="browser"){const Le=ge==="browser"?"web":"browser",Xe=this.isFullScreen(Le);switch(Xe||(this.lastScrollPosition=Wt.getScrollPosition()),ge){case"browser":if(this.player.container.requestFullscreen=this.player.container.requestFullscreen||this.player.container.webkitRequestFullscreen,this.player.container.requestFullscreen!==void 0?this.player.container.requestFullscreen():this.player.video.webkitEnterFullscreen&&this.player.video.webkitEnterFullscreen(),screen.orientation)try{screen.orientation.lock("landscape").catch(()=>{})}catch{}this.player.container.requestFullscreen!==void 0&&this.player.container.classList.add("dplayer-fulled-browser");break;case"web":this.player.container.classList.add("dplayer-fulled"),document.body.classList.add("dplayer-web-fullscreen-fix"),this.player.events.trigger("webfullscreen")}Xe&&this.cancel(Le)}cancel(ge="browser"){switch(ge){case"browser":if(document.exitFullscreen=document.exitFullscreen||document.webkitExitFullscreen,document.exitFullscreen&&document.exitFullscreen(),screen.orientation)try{screen.orientation.unlock()}catch{}this.player.container.classList.remove("dplayer-fulled-browser");break;case"web":this.player.container.classList.remove("dplayer-fulled"),document.body.classList.remove("dplayer-web-fullscreen-fix"),this.player.events.trigger("webfullscreen_cancel")}}toggle(ge="browser"){this.isFullScreen(ge)?this.cancel(ge):this.request(ge)}destroy(){this.player.container.removeEventListener("fullscreenchange",this.fullscreenchange),this.player.container.removeEventListener("webkitfullscreenchange",this.fullscreenchange)}},Er=class{constructor(ge){we(this,"storageName");we(this,"default");we(this,"data");this.storageName={opacity:"dplayer-danmaku-opacity",volume:"dplayer-volume",unlimited:"dplayer-danmaku-unlimited",danmaku:"dplayer-danmaku-show",subtitle:"dplayer-subtitle-show"},this.default={opacity:1,volume:Object.prototype.hasOwnProperty.call(ge.options,"volume")?ge.options.volume:1,unlimited:(ge.options.danmaku&&ge.options.danmaku.unlimited?1:0)||0,danmaku:1,subtitle:1},this.data={},this.init()}init(){for(const ge in this.storageName){const Le=this.storageName[ge];this.data[ge]=parseFloat(Wt.storage.get(Le)||this.default[ge].toString())}}get(ge){return this.data[ge]}set(ge,Le){this.data[ge]=Le,Wt.storage.set(this.storageName[ge],Le)}},ks=class{constructor(ge,Le,Xe,ft,_t){we(this,"container");we(this,"video");we(this,"plugins");we(this,"options");we(this,"events");this.container=ge,this.video=Le,this.plugins=Xe,this.options=ft,this.events=_t,this.init()}init(){if(this.container.style.fontSize=this.options.fontSize,this.container.style.bottom=this.options.bottom,this.container.style.color=this.options.color,this.options.type==="webvtt"&&this.video.textTracks&&this.video.textTracks[0]){const ge=this.video.textTracks[0];ge.oncuechange=()=>{if(!ge.activeCues)return;const Le=ge.activeCues[0];if(this.container.innerHTML="",Le){const Xe=document.createElement("div");Xe.appendChild(Le.getCueAsHTML());const ft=Xe.innerHTML.split(/\r?\n/).map(_t=>` ${_t}
`).join("");this.container.innerHTML=ft}this.events.trigger("subtitle_change")}}}show(){this.container.classList.remove("dplayer-subtitle-hide"),this.options.type==="aribb24"&&this.plugins.aribb24Caption&&this.plugins.aribb24Caption.show(),this.events.trigger("subtitle_show")}hide(){this.container.classList.add("dplayer-subtitle-hide"),this.options.type==="aribb24"&&this.plugins.aribb24Caption&&this.plugins.aribb24Caption.hide(),this.events.trigger("subtitle_hide")}toggle(){this.container.classList.contains("dplayer-subtitle-hide")?this.show():this.hide()}},Xr=class{constructor(ge){we(this,"elements");this.elements={},this.elements.volume=ge.volumeBar,this.elements.played=ge.playedBar,this.elements.loaded=ge.loadedBar,this.elements.danmaku=ge.danmakuOpacityBar}set(ge,Le,Xe){Le=Math.max(Le,0),Le=Math.min(Le,1),this.elements[ge].style[Xe]=100*Le+"%"}get(ge){return parseFloat(this.elements[ge].style.width)/100}},Rs=class{constructor(ge){we(this,"player");we(this,"types");we(this,"enablefpsChecker");we(this,"enableinfoChecker");we(this,"enableloadingChecker");we(this,"fpsIndex");we(this,"fpsStart");we(this,"fpsChecker");we(this,"infoChecker");we(this,"loadingChecker");this.player=ge,window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(Le){window.setTimeout(Le,1e3/60)},this.types=["loading","info","fps"],this.init()}init(){this.types.map(ge=>(ge!=="fps"&&this[`init${ge}Checker`](),ge))}initloadingChecker(){let ge=0,Le=0,Xe=!1;this.loadingChecker=window.setInterval(()=>{this.enableloadingChecker&&(Le=this.player.video.currentTime,Xe||Le!==ge||this.player.video.paused||(this.player.container.classList.add("dplayer-loading"),Xe=!0),Xe&&Le>ge&&!this.player.video.paused&&(this.player.container.classList.remove("dplayer-loading"),Xe=!1),ge=Le)},100)}initfpsChecker(){window.requestAnimationFrame(()=>{if(this.enablefpsChecker)if(this.initfpsChecker(),this.fpsStart){this.fpsIndex++;const ge=new Date;ge-this.fpsStart>1e3&&(this.player.infoPanel.fps(this.fpsIndex/(ge-this.fpsStart)*1e3),this.fpsStart=new Date,this.fpsIndex=0)}else this.fpsStart=new Date,this.fpsIndex=0;else this.fpsStart=0,this.fpsIndex=0})}initinfoChecker(){this.infoChecker=window.setInterval(()=>{this.enableinfoChecker&&this.player.infoPanel.update()},1e3)}enable(ge){this[`enable${ge}Checker`]=!0,ge==="fps"&&this.initfpsChecker()}disable(ge){this[`enable${ge}Checker`]=!1}destroy(){this.types.map(ge=>(this[`enable${ge}Checker`]=!1,this[`${ge}Checker`]&&window.clearInterval(this[`${ge}Checker`]),ge))}},Ba=class{constructor(ge){we(this,"container");this.container=ge,this.container.addEventListener("animationend",()=>{this.container.classList.remove("dplayer-bezel-transition")})}switch(ge){this.container.innerHTML=ge,this.container.classList.add("dplayer-bezel-transition")}},il=class{constructor(ge){we(this,"container");we(this,"barWidth");we(this,"events");this.container=ge.container,this.barWidth=ge.barWidth,this.container.style.backgroundImage=`url('${ge.url}')`,this.events=ge.events}resize(ge,Le,Xe){this.container.style.width=`${ge}px`,this.container.style.height=`${Le}px`,this.container.style.top=2-Le+"px",this.barWidth=Xe}show(){this.container.style.display="block",this.events&&this.events.trigger("thumbnails_show")}move(ge){this.container.style.backgroundPosition=`-${160*(Math.ceil(ge/this.barWidth*100)-1)}px 0`,this.container.style.left=`${Math.min(Math.max(ge-this.container.offsetWidth/2,-10),this.barWidth-150)}px`}hide(){this.container.style.display="none",this.events&&this.events.trigger("thumbnails_hide")}},pa=class{constructor(ge){we(this,"player");we(this,"disableAutoHide",!1);we(this,"autoHideTimer");we(this,"mobileSkipTimer");we(this,"mobileBackwardTime");we(this,"mobileForwardTime");we(this,"setAutoHideHandler");we(this,"thumbnails",null);this.player=ge,this.autoHideTimer=0,this.mobileSkipTimer=0,this.mobileBackwardTime=0,this.mobileForwardTime=0,this.setAutoHideHandler=()=>this.setAutoHide(),Wt.isMobile?this.player.container.addEventListener("touchmove",this.setAutoHideHandler):(this.player.container.addEventListener("mousemove",this.setAutoHideHandler),this.player.container.addEventListener("click",this.setAutoHideHandler)),this.player.on("play",this.setAutoHideHandler),this.player.on("pause",this.setAutoHideHandler),this.initPlayButton(),this.initThumbnails(),this.initPlayedBar(),this.initFullButton(),this.initPipButton(),this.initSyncButton(),this.initScreenshotButton(),this.initSubtitleButton(),this.initHighlights(),this.initAirplayButton(),Wt.isMobile||this.initVolumeButton()}initPlayButton(){this.player.template.playButton.addEventListener("click",()=>{this.player.toggle()}),this.player.template.mobilePlayButton.addEventListener("click",()=>{this.player.toggle()}),Wt.isMobile?(this.player.template.videoWrap.addEventListener("click",()=>{this.toggle(),this.isShow()&&this.setAutoHide()}),this.player.template.controllerMask.addEventListener("click",()=>{this.toggle(),this.isShow()&&this.setAutoHide()})):(this.player.template.videoWrap.addEventListener("click",()=>{this.player.toggle()}),this.player.template.controllerMask.addEventListener("click",()=>{this.player.toggle()})),this.player.template.mobileBackwardButton.addEventListener("click",()=>{this.mobileBackwardTime+=10,this.player.seek(this.player.video.currentTime-10),this.player.notice(`${this.player.tran("REW")} ${this.mobileBackwardTime.toFixed(0)} ${this.player.tran("s")}`),window.clearTimeout(this.mobileSkipTimer),this.mobileSkipTimer=window.setTimeout(()=>{this.mobileBackwardTime=0},1e3),this.setAutoHide()}),this.player.template.mobileForwardButton.addEventListener("click",()=>{this.mobileForwardTime+=10,this.player.seek(this.player.video.currentTime+10),this.player.notice(`${this.player.tran("FF")} ${this.mobileForwardTime.toFixed(0)} ${this.player.tran("s")}`),window.clearTimeout(this.mobileSkipTimer),this.mobileSkipTimer=window.setTimeout(()=>{this.mobileForwardTime=0},1e3),this.setAutoHide()})}initHighlights(){this.player.on("durationchange",()=>{if(this.player.video.duration!==1&&this.player.video.duration!==1/0&&this.player.options.highlight){const ge=this.player.template.playedBarWrap.querySelectorAll(".dplayer-highlight");[].slice.call(ge,0).forEach(Le=>{this.player.template.playedBarWrap.removeChild(Le)});for(let Le=0;Le{this.thumbnails.resize(160,this.player.video.videoHeight/this.player.video.videoWidth*160,this.player.template.barWrap.offsetWidth)}))}initPlayedBar(){let ge;const Le=ft=>{let _t=((ft.clientX||ft.changedTouches&&ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.playedBarWrap))/this.player.template.playedBarWrap.clientWidth;_t=Math.max(_t,0),_t=Math.min(_t,1),this.player.bar.set("played",_t,"width");const Ct=Wt.getVideoDuration(this.player.video,this.player.template);this.player.template.ptime.textContent=Wt.secondToTime(_t*Ct),this.player.container.classList.add("dplayer-seeking"),this.player.video.paused||this.player.video.pause()},Xe=ft=>{document.removeEventListener(Wt.nameMap.dragEnd,Xe),document.removeEventListener(Wt.nameMap.dragMove,Le);let _t=((ft.clientX||ft.changedTouches&&ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.playedBarWrap))/this.player.template.playedBarWrap.clientWidth;_t=Math.max(_t,0),_t=Math.min(_t,1),this.player.bar.set("played",_t,"width");const Ct=Wt.getVideoDuration(this.player.video,this.player.template);this.player.seek(this.player.bar.get("played")*Ct),ge||this.player.video.play(),this.player.container.classList.remove("dplayer-seeking")};this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragStart,()=>{ge=this.player.video.paused,document.addEventListener(Wt.nameMap.dragMove,Le),document.addEventListener(Wt.nameMap.dragEnd,Xe)}),this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragMove,ft=>{const _t=Wt.getVideoDuration(this.player.video,this.player.template);if(_t){const Ct=this.player.template.playedBarWrap.getBoundingClientRect().left,Pt=(ft.clientX||ft.changedTouches[0].clientX)-Ct;if(Pt<0||Pt>this.player.template.playedBarWrap.offsetWidth)return;const ci=_t*(Pt/this.player.template.playedBarWrap.offsetWidth);Wt.isMobile&&this.thumbnails&&this.thumbnails.show(),this.thumbnails&&this.thumbnails.move(Pt),this.player.template.playedBarTime.style.left=Pt-(ci>=3600?25:20)+"px",this.player.template.playedBarTime.textContent=Wt.secondToTime(ci),this.player.template.playedBarTime.classList.remove("hidden")}}),this.player.template.playedBarWrap.addEventListener(Wt.nameMap.dragEnd,()=>{Wt.isMobile&&this.thumbnails&&this.thumbnails.hide()}),Wt.isMobile||(this.player.template.playedBarWrap.addEventListener("mouseenter",()=>{this.player.video.duration&&(this.thumbnails&&this.thumbnails.show(),this.player.template.playedBarTime.classList.remove("hidden"))}),this.player.template.playedBarWrap.addEventListener("mouseleave",()=>{this.player.video.duration&&(this.thumbnails&&this.thumbnails.hide(),this.player.template.playedBarTime.classList.add("hidden"))}))}initFullButton(){this.player.template.browserFullButton.addEventListener("click",()=>{this.player.fullScreen.toggle("browser")}),this.player.template.webFullButton.addEventListener("click",()=>{this.player.fullScreen.toggle("web")})}initPipButton(){document.pictureInPictureEnabled?this.player.template.pipButton.addEventListener("click",()=>{document.pictureInPictureElement?document.exitPictureInPicture():this.player.video.requestPictureInPicture().catch(ge=>{console.error(ge),this.player.options.lang==="ja"||this.player.options.lang==="ja-jp"?this.player.notice("Picture-in-Picture を開始できませんでした。",void 0,void 0,"#FF6F6A"):this.player.notice("Picture-in-Picture could not be started.",void 0,void 0,"#FF6F6A")})}):this.player.template.pipButton.style.display="none"}initVolumeButton(){const ge=Xe=>{const ft=Xe||window.event,_t=((ft.clientX||ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap)-5.5)/35;this.player.volume(_t)},Le=()=>{document.removeEventListener(Wt.nameMap.dragEnd,Le),document.removeEventListener(Wt.nameMap.dragMove,ge),this.player.template.volumeButton.classList.remove("dplayer-volume-active")};this.player.template.volumeBarWrapWrap.addEventListener("click",Xe=>{const ft=Xe||window.event,_t=((ft.clientX||ft.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.volumeBarWrap)-5.5)/35;this.player.volume(_t)}),this.player.template.volumeBarWrapWrap.addEventListener(Wt.nameMap.dragStart,()=>{document.addEventListener(Wt.nameMap.dragMove,ge),document.addEventListener(Wt.nameMap.dragEnd,Le),this.player.template.volumeButton.classList.add("dplayer-volume-active")}),this.player.template.volumeButtonIcon.addEventListener("click",()=>{this.player.video.muted?(this.player.video.muted=!1,this.player.switchVolumeIcon(),this.player.bar.set("volume",this.player.volume(),"width")):(this.player.video.muted=!0,this.player.template.volumeIcon.innerHTML=En.volumeOff,this.player.bar.set("volume",0,"width"))})}initSyncButton(){this.player.options.live&&this.player.template.syncButton.addEventListener("click",()=>{this.player.sync()})}initScreenshotButton(){this.player.options.screenshot&&this.player.template.cameraButton.addEventListener("click",()=>{const ge=document.createElement("canvas");ge.width=this.player.video.videoWidth,ge.height=this.player.video.videoHeight,ge.getContext("2d").drawImage(this.player.video,0,0,ge.width,ge.height),ge.toBlob(Le=>{if(Le===null)return;const Xe=new Date,ft=`Capture_${Xe.getFullYear()}${("0"+(Xe.getMonth()+1)).slice(-2)}${("0"+Xe.getDate()).slice(-2)}-${("0"+Xe.getHours()).slice(-2)}${("0"+Xe.getMinutes()).slice(-2)}${("0"+Xe.getSeconds()).slice(-2)}.jpg`,_t=URL.createObjectURL(Le),Ct=document.createElement("a");Ct.download!==void 0?(Ct.download=ft,Ct.href=_t,Ct.click(),URL.revokeObjectURL(_t),this.player.events.trigger("screenshot",Le)):this.player.notice("Error: Screenshot download is not supported.",void 0,void 0,"#FF6F6A")},"image/jpeg",1)})}initAirplayButton(){this.player.options.airplay&&(window.WebKitPlaybackTargetAvailabilityEvent?this.player.video.addEventListener("webkitplaybacktargetavailabilitychanged",(function(ge){ge.availability==="available"?this.template.airplayButton.disable=!1:this.template.airplayButton.disable=!0,this.template.airplayButton.addEventListener("click",(function(){this.video.webkitShowPlaybackTargetPicker()}).bind(this))}).bind(this.player)):this.player.template.airplayButton.style.display="none")}initSubtitleButton(){this.player.options.subtitle&&(this.player.events.on("subtitle_show",()=>{this.player.template.subtitleButton.ariaLabel=this.player.tran("Hide subtitle"),this.player.template.subtitleButtonInner.style.opacity="",this.player.user.set("subtitle",1)}),this.player.events.on("subtitle_hide",()=>{this.player.template.subtitleButton.ariaLabel=this.player.tran("Show subtitle"),this.player.template.subtitleButtonInner.style.opacity="0.4",this.player.user.set("subtitle",0)}),this.player.template.subtitleButton.addEventListener("click",()=>{this.player.subtitle!==null&&this.player.subtitle.toggle()}))}setAutoHide(ge=3e3){this.show(),window.clearTimeout(this.autoHideTimer),this.autoHideTimer=window.setTimeout(()=>{!this.player.video.played.length||this.player.paused||this.disableAutoHide||this.hide()},ge)}show(){this.player.container.classList.remove("dplayer-hide-controller")}hide(){this.player.container.classList.add("dplayer-hide-controller"),this.player.setting.hide(),this.player.comment&&this.player.comment.hide()}isShow(){return!this.player.container.classList.contains("dplayer-hide-controller")}toggle(){this.isShow()?this.hide():this.show()}destroy(){Wt.isMobile?this.player.container.removeEventListener("touchmove",this.setAutoHideHandler):(this.player.container.removeEventListener("mousemove",this.setAutoHideHandler),this.player.container.removeEventListener("click",this.setAutoHideHandler)),window.clearTimeout(this.autoHideTimer)}},ma=class{constructor(ge){we(this,"player");we(this,"loop");we(this,"showDanmaku");we(this,"unlimitDanmaku");we(this,"currentAudio","primary");we(this,"resizeObserver");this.player=ge,this.player.template.mask.addEventListener("click",()=>{this.hide()}),this.player.template.settingButton.addEventListener("click",()=>{this.show()});const Le=()=>{const Xe=this.player.template.settingOriginPanel.scrollHeight;this.player.template.settingBox.style.clipPath=`inset(calc(100% - ${Xe}px) 0 0 round 7px)`};if(Le(),this.resizeObserver=new ResizeObserver(Le),this.resizeObserver.observe(this.player.template.settingOriginPanel),this.player.options.video.quality){this.player.template.quality.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-quality")}),this.player.template.qualityHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-quality")});for(let Xe=0;Xe {this.player.switchingQuality||this.player.switchQuality(parseInt(this.player.template.qualityItem[Xe].dataset.index))})}this.player.template.speed.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-speed")}),this.player.template.speedHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-speed")});for(let Xe=0;Xe {this.player.speed(parseFloat(ft.target.dataset.speed))});this.player.template.audio.addEventListener("click",()=>{this.player.template.settingBox.classList.add("dplayer-setting-box-audio")}),this.player.template.audioHeader.addEventListener("click",()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")});for(let Xe=0;Xe {if(this.player.plugins.mpegts||this.player.plugins.liveLLHLSForKonomiTV){if(this.player.template.audioItem[Xe].dataset.audio===this.currentAudio)return;this.player.template.audioItem[Xe].dataset.audio==="primary"?(this.currentAudio="primary",this.player.template.audioItem[0].classList.add("dplayer-setting-audio-current"),this.player.template.audioItem[1].classList.remove("dplayer-setting-audio-current"),this.player.template.audioValue.textContent=this.player.tran("Primary audio"),window.mpegts&&this.player.plugins.mpegts&&this.player.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.player.plugins.mpegts.switchPrimaryAudio():this.player.plugins.liveLLHLSForKonomiTV&&this.player.plugins.liveLLHLSForKonomiTV.switchPrimaryAudio()):this.player.template.audioItem[Xe].dataset.audio==="secondary"&&(this.currentAudio="secondary",this.player.template.audioItem[0].classList.remove("dplayer-setting-audio-current"),this.player.template.audioItem[1].classList.add("dplayer-setting-audio-current"),this.player.template.audioValue.textContent=this.player.tran("Secondary audio"),window.mpegts&&this.player.plugins.mpegts&&this.player.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.player.plugins.mpegts.switchSecondaryAudio():this.player.plugins.liveLLHLSForKonomiTV&&this.player.plugins.liveLLHLSForKonomiTV.switchSecondaryAudio()),this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")}});if(this.loop=this.player.options.loop,this.player.template.loopToggle.checked=this.loop,this.player.template.loop.addEventListener("click",()=>{this.player.template.loopToggle.checked=!this.player.template.loopToggle.checked,this.player.template.loopToggle.checked?this.loop=!0:this.loop=!1}),this.showDanmaku=this.player.user.get("danmaku")===1,this.showDanmaku||this.player.danmaku&&this.player.danmaku.hide(),this.player.template.showDanmakuToggle.checked=this.showDanmaku,this.player.template.showDanmaku.addEventListener("click",()=>{this.player.template.showDanmakuToggle.checked=!this.player.template.showDanmakuToggle.checked,this.player.template.showDanmakuToggle.checked?(this.showDanmaku=!0,this.player.danmaku!==null&&this.player.danmaku.show()):(this.showDanmaku=!1,this.player.danmaku!==null&&this.player.danmaku.hide()),this.player.user.set("danmaku",this.showDanmaku?1:0)}),this.unlimitDanmaku=this.player.user.get("unlimited")===1,this.player.template.unlimitDanmakuToggle.checked=this.unlimitDanmaku,this.player.template.unlimitDanmaku.addEventListener("click",()=>{this.player.template.unlimitDanmakuToggle.checked=!this.player.template.unlimitDanmakuToggle.checked,this.player.template.unlimitDanmakuToggle.checked?(this.unlimitDanmaku=!0,this.player.danmaku!==null&&this.player.danmaku.unlimit(!0)):(this.unlimitDanmaku=!1,this.player.danmaku!==null&&this.player.danmaku.unlimit(!1)),this.player.user.set("unlimited",this.unlimitDanmaku?1:0)}),this.player.danmaku){this.player.on("danmaku_opacity",Ct=>{this.player.bar.set("danmaku",Ct,"width"),this.player.user.set("opacity",Ct),this.player.template.danmakuOpacityValue.textContent=Ct.toFixed(1)}),this.player.danmaku.opacity(this.player.user.get("opacity")),this.player.template.danmakuOpacityValue.textContent=this.player.user.get("opacity").toFixed(1);const ft=Ct=>{const Pt=Ct||window.event;let ci=((Pt.clientX||Pt.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.danmakuOpacityBarWrap))/190;ci=Math.max(ci,0),ci=Math.min(ci,1),this.player.danmaku!==null&&this.player.danmaku.opacity(ci)},_t=()=>{document.removeEventListener(Wt.nameMap.dragEnd,_t),document.removeEventListener(Wt.nameMap.dragMove,ft),this.player.template.danmakuOpacityBox.classList.remove("dplayer-setting-danmaku-active")};this.player.template.danmakuOpacityBarWrapWrap.addEventListener("click",Ct=>{const Pt=Ct||window.event;let ci=((Pt.clientX||Pt.changedTouches[0].clientX)-Wt.getBoundingClientRectViewLeft(this.player.template.danmakuOpacityBarWrap))/190;ci=Math.max(ci,0),ci=Math.min(ci,1),this.player.danmaku!==null&&this.player.danmaku.opacity(ci)}),this.player.template.danmakuOpacityBarWrapWrap.addEventListener(Wt.nameMap.dragStart,()=>{document.addEventListener(Wt.nameMap.dragMove,ft),document.addEventListener(Wt.nameMap.dragEnd,_t),this.player.template.danmakuOpacityBox.classList.add("dplayer-setting-danmaku-active")})}}hide(){this.player.template.container.classList.remove("dplayer-show-controller"),this.player.template.settingBox.classList.remove("dplayer-setting-box-open"),this.player.template.mask.classList.remove("dplayer-mask-show"),window.setTimeout(()=>{this.player.template.settingBox.classList.remove("dplayer-setting-box-speed"),this.player.template.settingBox.classList.remove("dplayer-setting-box-audio")},300),this.player.controller.disableAutoHide=!1}show(){this.player.template.container.classList.add("dplayer-show-controller"),this.player.template.settingBox.classList.add("dplayer-setting-box-open"),this.player.template.mask.classList.add("dplayer-mask-show"),this.player.controller.disableAutoHide=!0}destroy(){this.resizeObserver.disconnect()}},nl=class{constructor(ge){we(this,"player");this.player=ge,this.player.template.mask.addEventListener("click",()=>{this.hide()}),this.player.template.commentButton.addEventListener("click",()=>{this.show()}),this.player.template.commentSettingButton.addEventListener("click",()=>{this.toggleSetting()}),this.player.template.commentColorSettingBox.addEventListener("click",()=>{if(this.player.template.commentColorSettingBox.querySelector("input:checked+span")){const Le=this.player.template.commentColorSettingBox.querySelector("input:checked").value;this.player.template.commentSettingFill.style.fill=Le,this.player.template.commentInput.style.color=Le,this.player.template.commentSendFill.style.fill=Le}}),this.player.template.commentInput.addEventListener("click",()=>{this.hideSetting()}),this.player.template.commentInput.addEventListener("keydown",Le=>{(Le||window.event).keyCode===13&&this.send()}),this.player.template.commentSendButton.addEventListener("click",()=>{this.send()})}show(){this.player.controller.disableAutoHide=!0,this.player.template.controller.classList.add("dplayer-controller-comment"),this.player.template.mask.classList.add("dplayer-mask-show"),this.player.container.classList.add("dplayer-show-controller"),this.player.template.commentInput.focus()}hide(){this.player.template.controller.classList.remove("dplayer-controller-comment"),this.player.template.mask.classList.remove("dplayer-mask-show"),this.player.container.classList.remove("dplayer-show-controller"),this.player.controller.disableAutoHide=!1,this.hideSetting()}showSetting(){this.player.template.commentSettingBox.classList.add("dplayer-comment-setting-open")}hideSetting(){this.player.template.commentSettingBox.classList.remove("dplayer-comment-setting-open")}toggleSetting(){this.player.template.commentSettingBox.classList.contains("dplayer-comment-setting-open")?this.hideSetting():this.showSetting()}send(){var ge;((ge=this.player.options.danmaku)==null?void 0:ge.closeCommentFormAfterSend)===!0&&this.player.template.commentInput.blur(),this.player.template.commentInput.value.replace(/^\s+|\s+$/g,"")?(this.player.danmaku!==null&&this.player.danmaku.send({text:this.player.template.commentInput.value,color:this.player.container.querySelector(".dplayer-comment-setting-color input:checked").value,type:this.player.container.querySelector(".dplayer-comment-setting-type input:checked").value,size:this.player.container.querySelector(".dplayer-comment-setting-size input:checked").value},()=>{var Le;((Le=this.player.options.danmaku)==null?void 0:Le.closeCommentFormAfterSend)===!0&&(this.hide(),this.player.controller.setAutoHide(750))},!0),this.player.template.commentInput.value=""):this.player.notice(this.player.tran("Please input danmaku content!"),void 0,void 0,"#FF6F6A")}},Is=class{constructor(ge){we(this,"player");we(this,"doHotKeyHandler");we(this,"cancelFullScreenHandler");this.player=ge,this.doHotKeyHandler=this.doHotKey.bind(this),this.cancelFullScreenHandler=this.cancelFullScreen.bind(this),this.player.options.hotkey&&document.addEventListener("keydown",this.doHotKeyHandler),document.addEventListener("keydown",this.cancelFullScreenHandler)}doHotKey(ge){var ft,_t;const Le=(ft=document.activeElement)==null?void 0:ft.tagName.toUpperCase(),Xe=(_t=document.activeElement)==null?void 0:_t.getAttribute("contenteditable");if(Le!=="INPUT"&&Le!=="TEXTAREA"&&Xe!==""&&Xe!=="true"){const Ct=ge||window.event;let Pt;switch(Ct.keyCode){case 32:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),this.player.toggle());break;case 37:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),Ct.altKey?this.player.seek(this.player.video.currentTime-60):Ct.shiftKey?this.player.seek(this.player.video.currentTime-30):Ct.ctrlKey||Ct.metaKey?this.player.seek(this.player.video.currentTime-15):this.player.seek(this.player.video.currentTime-5),this.player.controller.setAutoHide());break;case 39:(this.player.focus||this.player.options.hotkey)&&(Ct.preventDefault(),Ct.altKey?this.player.seek(this.player.video.currentTime+60):Ct.shiftKey?this.player.seek(this.player.video.currentTime+30):Ct.ctrlKey||Ct.metaKey?this.player.seek(this.player.video.currentTime+15):this.player.seek(this.player.video.currentTime+5),this.player.controller.setAutoHide());break;case 38:this.player.focus&&(Ct.preventDefault(),Pt=this.player.volume()+.1,this.player.volume(Pt));break;case 40:this.player.focus&&(Ct.preventDefault(),Pt=this.player.volume()-.1,this.player.volume(Pt));break;case 70:Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.fullScreen.toggle("browser"));break;case 87:Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.fullScreen.toggle("web"));break;case 76:this.player.options.live&&(Ct.preventDefault(),this.player.sync());break;case 80:this.player.options.pictureInPicture&&document.pictureInPictureEnabled&&(Ct.preventDefault(),this.player.template.pipButton.click());break;case 67:typeof this.player.options.danmaku=="object"&&this.player.options.danmaku&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.controller.show(),this.player.comment!=null&&this.player.comment.show()));break;case 68:typeof this.player.options.danmaku=="object"&&this.player.options.danmaku&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.template.showDanmaku.click(),this.player.template.showDanmakuToggle.checked?this.player.notice(`${this.player.tran("Show comment")}`):this.player.notice(`${this.player.tran("Hide comment")}`)));break;case 83:this.player.options.subtitle&&(Ct.ctrlKey||Ct.metaKey||(Ct.preventDefault(),this.player.subtitle!==null&&(this.player.subtitle.container.classList.contains("dplayer-subtitle-hide")?this.player.notice(`${this.player.tran("Show subtitle")}`):this.player.notice(`${this.player.tran("Hide subtitle")}`),this.player.subtitle.toggle())))}}}cancelFullScreen(ge){(ge||window.event).keyCode===27&&this.player.fullScreen.isFullScreen("web")&&this.player.fullScreen.cancel("web")}destroy(){this.player.options.hotkey&&document.removeEventListener("keydown",this.doHotKeyHandler),document.removeEventListener("keydown",this.cancelFullScreenHandler)}},Na=class{constructor(ge){we(this,"contextmenuHandler");we(this,"player");we(this,"shown");this.player=ge,this.shown=!1,Array.prototype.slice.call(this.player.template.menuItem).forEach((Le,Xe)=>{this.player.options.contextmenu[Xe].click&&Le.addEventListener("click",()=>{const ft=this.player.options.contextmenu[Xe];ft.click&&ft.click(this.player),this.hide()})}),this.contextmenuHandler=Le=>{const Xe=Le||window.event;if(Xe.preventDefault(),this.shown)return void this.hide();const ft=this.player.container.getBoundingClientRect();this.show(Xe.clientX-ft.left,Xe.clientY-ft.top),this.player.template.mask.addEventListener("click",()=>{this.hide()})},this.player.container.addEventListener("contextmenu",this.contextmenuHandler)}show(ge,Le){this.player.template.menu.classList.add("dplayer-menu-show");const Xe=this.player.container.getBoundingClientRect();ge+this.player.template.menu.offsetWidth>=Xe.width?(this.player.template.menu.style.right=Xe.width-ge+"px",this.player.template.menu.style.left="initial"):(this.player.template.menu.style.left=ge+"px",this.player.template.menu.style.right="initial"),Le+this.player.template.menu.offsetHeight>=Xe.height?(this.player.template.menu.style.bottom=Xe.height-Le+"px",this.player.template.menu.style.top="initial"):(this.player.template.menu.style.top=Le+"px",this.player.template.menu.style.bottom="initial"),this.player.template.mask.classList.add("dplayer-mask-show"),this.shown=!0,this.player.events.trigger("contextmenu_show")}hide(){this.player.template.mask.classList.remove("dplayer-mask-show"),this.player.template.menu.classList.remove("dplayer-menu-show"),this.shown=!1,this.player.events.trigger("contextmenu_hide")}destroy(){this.player.container.removeEventListener("contextmenu",this.contextmenuHandler)}},us=class{constructor(ge){we(this,"player");we(this,"container");we(this,"template");we(this,"video");we(this,"beginTime",0);this.player=ge,this.container=ge.template.infoPanel,this.template=ge.template,this.video=ge.video,this.template.infoPanelClose.addEventListener("click",()=>{this.hide()})}show(){this.beginTime=Date.now(),this.update(),this.player.timer.enable("info"),this.player.timer.enable("fps"),this.container.classList.remove("dplayer-info-panel-hide")}hide(){this.player.timer.disable("info"),this.player.timer.disable("fps"),this.container.classList.add("dplayer-info-panel-hide")}toggle(){this.container.classList.contains("dplayer-info-panel-hide")?this.show():this.hide()}update(){var ge;if(this.template.infoVersion.textContent="v1.31.2 7131b6b",this.template.infoType.textContent=this.player.type,this.template.infoUrl.textContent=this.player.options.video.url??"N/A",this.template.infoResolution.textContent=`${this.player.video.videoWidth} x ${this.player.video.videoHeight}`,this.template.infoDuration.textContent=`${this.player.video.duration}`,this.player.video.getVideoPlaybackQuality!=null){const Le=this.player.video.getVideoPlaybackQuality();this.template.infoDroppedFrames.textContent=`${Le.droppedVideoFrames} / ${Le.totalVideoFrames}`}else if(this.player.video.webkitDecodedFrameCount!=null){const Le=this.player.video.webkitDecodedFrameCount,Xe=this.player.video.webkitDroppedFrameCount;this.template.infoDroppedFrames.textContent=`${Xe} / ${Le}`}else this.template.infoDroppedFrames.textContent="N/A";if(this.player.video.buffered.length>0){const Le=this.player.video.buffered.length,Xe=this.player.video.buffered.end(Le-1)-this.player.video.currentTime;this.template.infoBufferRemain.textContent=`${Xe.toFixed(3)} s`}else this.template.infoBufferRemain.textContent="N/A";if(this.player.type==="mpegts"||this.player.type==="flv"){const Le=this.player.plugins.mpegts||this.player.plugins.flvjs;if(Le){const Xe=Le.mediaInfo,ft=Le.statisticsInfo;this.template.infoMimeType.textContent=Xe.mimeType??"N/A",this.template.infoVideoFPS.textContent=`${((ge=Xe.fps)==null?void 0:ge.toFixed(3))??"N/A"}`,ft.speed!=null?this.template.infoDownloadSpeed.textContent=`${ft.speed.toFixed(3)} KB/s`:this.template.infoDownloadSpeed.textContent="N/A"}}else this.template.infoMimeType.textContent="N/A",this.template.infoVideoFPS.textContent="N/A",this.template.infoDownloadSpeed.textContent="N/A"}fps(ge){this.template.infoPageFPS.textContent=`${ge.toFixed(1)}`}};var Fa=A(953),$r=A.n(Fa);let es=0;const ts=[],Ls=class{constructor(ge){we(this,"bar");we(this,"bezel");we(this,"comment",null);we(this,"contextmenu");we(this,"controller");we(this,"danmaku",null);we(this,"events");we(this,"fullScreen");we(this,"hotkey");we(this,"infoPanel");we(this,"setting");we(this,"subtitle",null);we(this,"template");we(this,"timer");we(this,"user");we(this,"container");we(this,"containerClickFun");we(this,"docClickFun");we(this,"focus",!1);we(this,"narrow",!1);we(this,"noticeTime",null);we(this,"options");we(this,"paused",!1);we(this,"plugins");we(this,"prevVideoCurrentTime",0);we(this,"prevVideo",null);we(this,"quality",null);we(this,"qualityIndex",null);we(this,"switchingQuality",!1);we(this,"resizeObserver");we(this,"tran");we(this,"type","auto");we(this,"video");this.options=(Le=>{const Xe={container:Le.container||document.querySelector(".dplayer")||void 0,live:!1,liveSyncMinBufferSize:.8,syncWhenPlayingLive:!0,autoplay:!1,theme:"#b7daff",loop:!1,lang:navigator.language.toLowerCase(),screenshot:!1,pictureInPicture:!0,airplay:!0,hotkey:!0,preload:"metadata",crossOrigin:null,volume:1,playbackSpeed:[.25,.5,.75,1,1.25,1.5,1.75,2],apiBackend:oi,video:{},contextmenu:[],mutex:!0,pluginOptions:{}};for(const ft in Xe)Object.prototype.hasOwnProperty.call(Xe,ft)&&!Object.prototype.hasOwnProperty.call(Le,ft)&&(Le[ft]=Xe[ft]);return Le.video&&!Le.video.type&&(Le.video.type="auto"),typeof Le.danmaku=="object"&&Le.danmaku&&(!Le.danmaku.user&&(Le.danmaku.user="DPlayer"),!Le.danmaku.speedRate&&(Le.danmaku.speedRate=1),!Le.danmaku.fontSize&&(Le.danmaku.fontSize=35),Le.danmaku.closeCommentFormAfterSend!==!1&&(Le.danmaku.closeCommentFormAfterSend=!0)),Le.subtitle&&(!Le.subtitle.type&&(Le.subtitle.type="webvtt"),!Le.subtitle.fontSize&&(Le.subtitle.fontSize="20px"),!Le.subtitle.bottom&&(Le.subtitle.bottom="40px"),!Le.subtitle.color&&(Le.subtitle.color="#fff")),Le.video.quality&&(typeof Le.video.defaultQuality=="string"&&(Le.video.quality.forEach((ft,_t)=>{Le.video.defaultQuality===ft.name&&(Le.video.defaultQuality=_t)}),typeof Le.video.defaultQuality=="string"&&(Le.video.defaultQuality=0)),Le.video.defaultQuality===void 0&&(Le.video.defaultQuality=0),Le.video.type=Le.video.quality[Le.video.defaultQuality].type,Le.video.url=Le.video.quality[Le.video.defaultQuality].url),Le.lang&&(Le.lang=Le.lang.toLowerCase()),Le.contextmenu=Le.contextmenu.concat([{text:"Video info",click:ft=>{ft.infoPanel.toggle()}},{text:"DPlayer v1.31.2",link:"https://github.com/tsukumijima/DPlayer"}]),{container:Le.container,live:Le.live,liveSyncMinBufferSize:Le.liveSyncMinBufferSize,syncWhenPlayingLive:Le.syncWhenPlayingLive,autoplay:Le.autoplay,theme:Le.theme,loop:Le.loop,lang:Le.lang,screenshot:Le.screenshot,pictureInPicture:Le.pictureInPicture,airplay:Le.airplay,hotkey:Le.hotkey,preload:Le.preload,crossOrigin:Le.crossOrigin,volume:Le.volume,playbackSpeed:Le.playbackSpeed,logo:Le.logo,apiBackend:Le.apiBackend,video:Le.video,subtitle:Le.subtitle,danmaku:Le.danmaku,contextmenu:Le.contextmenu,highlight:Le.highlight,mutex:Le.mutex,pluginOptions:Le.pluginOptions}})({preload:ge.video.type==="webtorrent"?"none":"metadata",...ge}),this.options.video.quality&&(this.qualityIndex=this.options.video.defaultQuality,this.quality=this.options.video.quality[this.options.video.defaultQuality]),this.tran=new ui(this.options.lang).tran,this.events=new tl,this.user=new Er(this),this.container=this.options.container,this.container.classList.add("dplayer"),this.options.danmaku||this.container.classList.add("dplayer-no-danmaku"),this.options.live?this.container.classList.add("dplayer-live"):this.container.classList.remove("dplayer-live"),Wt.isMobile&&this.container.classList.add("dplayer-mobile"),this.narrow=this.container.offsetWidth<=500,this.narrow&&this.container.classList.add("dplayer-narrow"),this.resizeObserver=new ResizeObserver(Le=>{for(const Xe of Le)Xe.target===this.container&&(this.narrow=this.container.offsetWidth<=500,this.narrow?this.container.classList.add("dplayer-narrow"):this.container.classList.remove("dplayer-narrow"))}),this.resizeObserver.observe(this.container),this.template=new ha({container:this.container,options:this.options,index:es,tran:this.tran}),this.video=this.template.video,this.bar=new Xr(this.template),this.bezel=new Ba(this.template.bezel),this.fullScreen=new fa(this),this.controller=new pa(this),this.options.danmaku&&(this.danmaku=new el({player:this,container:this.template.danmaku,opacity:this.user.get("opacity"),callback:()=>{setTimeout(()=>{this.template.danmakuLoading.style.display="none",this.options.autoplay&&this.play()},0)},error:Le=>{this.notice(Le,void 0,void 0,"#FF6F6A")},apiBackend:this.options.apiBackend,borderColor:this.options.theme,fontSize:this.options.danmaku.fontSize,time:()=>this.video.currentTime,unlimited:this.user.get("unlimited"),speedRate:this.options.danmaku.speedRate,api:{id:this.options.danmaku.id,address:this.options.danmaku.api,token:this.options.danmaku.token,maximum:this.options.danmaku.maximum,addition:this.options.danmaku.addition,user:this.options.danmaku.user},events:this.events,tran:Le=>this.tran(Le)}),this.comment=new nl(this)),this.plugins={},this.docClickFun=()=>{this.focus=!1},this.containerClickFun=()=>{this.focus=!0},document.addEventListener("click",this.docClickFun,!0),this.container.addEventListener("click",this.containerClickFun,!0),this.paused=!0,this.timer=new Rs(this),this.hotkey=new Is(this),this.contextmenu=new Na(this),this.initVideo(this.video,this.quality&&this.quality.type||this.options.video.type),this.setting=new ma(this),this.infoPanel=new us(this),!this.danmaku&&this.options.autoplay&&this.play(),es++,ts.push(this)}seek(ge){ge=Math.max(ge,0);const Le=Wt.getVideoDuration(this.video,this.template);Le&&(ge=Math.min(ge,Le)),this.video.currentTime ge&&this.notice(`${this.tran("REW")} ${(this.video.currentTime-ge).toFixed(0)} ${this.tran("s")}`),isFinite(ge)&&(this.video.currentTime=ge),this.danmaku&&this.danmaku.seek(),this.bar.set("played",ge/Le,"width"),this.template.ptime.textContent=Wt.secondToTime(ge)}sync(ge=!1){if(this.options.live){const Le=Wt.getVideoDuration(this.video,this.template)-this.options.liveSyncMinBufferSize;try{this.video.currentTime=Le}catch{return}this.danmaku&&this.danmaku.seek(),this.template.ptime.textContent=Wt.secondToTime(Le),ge||this.notice(this.tran("Synchronized"))}}play(ge=!1){if(this.paused=!1,this.video.paused&&!Wt.isMobile&&this.bezel.switch(En.play),this.template.playButton.innerHTML=En.pause,this.template.mobilePlayButton.innerHTML=En.pause,this.options.live&&this.options.syncWhenPlayingLive&&this.sync(!0),!ge){const Le=this.type==="mpegts"&&this.plugins.mpegts&&this.plugins.mpegts.play.bind(this.plugins.mpegts)||this.video.play.bind(this.video);Promise.resolve(Le()).catch(()=>{this.pause()}).then(()=>{})}if(this.timer.enable("loading"),this.container.classList.remove("dplayer-paused"),this.container.classList.add("dplayer-playing"),this.danmaku&&this.danmaku.play(),this.options.mutex)for(let Le=0;Le =.95?this.template.volumeIcon.innerHTML=En.volumeUp:this.volume()>0?this.template.volumeIcon.innerHTML=En.volumeDown:this.template.volumeIcon.innerHTML=En.volumeOff}volume(ge=NaN,Le=!1,Xe=!1){if(typeof ge=="string"&&(ge=parseFloat(ge)),!isNaN(ge)){ge=Math.max(ge,0),ge=Math.min(ge,1),this.bar.set("volume",ge,"width");const ft=`${(100*ge).toFixed(0)}%`;this.template.volumeBarWrapWrap.ariaLabel=ft,Le||this.user.set("volume",ge),Xe||this.notice(`${this.tran("Volume")} ${(100*ge).toFixed(0)}%`),this.video.volume=ge,this.video.muted&&(this.video.muted=!1),this.switchVolumeIcon()}return this.video.volume}toggle(){this.video.paused?this.play():this.pause()}on(ge,Le,Xe=!1){this.events.on(ge,Le,Xe)}off(ge,Le){this.events.off(ge,Le)}switchVideo(ge,Le){this.pause(),this.video.poster=ge.pic?ge.pic:"",this.video.src=ge.url,this.initMSE(this.video,ge.type||"auto"),Le&&(this.template.danmakuLoading.style.display="block",this.bar.set("played",0,"width"),this.bar.set("loaded",0,"width"),this.template.ptime.textContent="00:00",this.template.danmaku.innerHTML="",this.danmaku&&this.danmaku.reload({id:Le.id,address:Le.api,token:Le.token,maximum:Le.maximum,addition:Le.addition,user:Le.user}))}initMSE(ge,Le){if(this.type=Le,this.options.video.customType&&this.options.video.customType[Le])Object.prototype.toString.call(this.options.video.customType[Le])==="[object Function]"?this.options.video.customType[Le](this.video,this):console.error(`Illegal customType: ${Le}`);else switch(this.type==="auto"&&(/m3u8(#|\?|$)/i.exec(ge.src)?this.type="hls":/.ts(#|\?|$)/i.exec(ge.src)?this.type="mpegts":/.flv(#|\?|$)/i.exec(ge.src)?this.type="flv":/.mpd(#|\?|$)/i.exec(ge.src)?this.type="dash":this.type="normal"),this.type!=="mpegts"&&this.type!=="live-llhls-for-KonomiTV"&&this.container.classList.add("dplayer-no-audio-switching"),this.type){case"hls":if(window.Hls){const Xe=/Safari/i.test(navigator.userAgent)&&/iPad|Macintosh/i.test(navigator.userAgent)&&"ontouchend"in document&&(ge.canPlayType("application/x-mpegURL")||ge.canPlayType("application/vnd.apple.mpegURL"));if(window.Hls.isSupported()&&!Xe){this.plugins.hls&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.plugins.hls.destroy(),delete this.plugins.hls);const ft=this.options.pluginOptions.hls,_t=new window.Hls(ft);if(this.plugins.hls=_t,_t.loadSource(ge.src),_t.attachMedia(ge),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),_t.destroy(),delete this.plugins.hls}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!1;const Ct=this.options.pluginOptions.aribb24,Pt=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...Ct,data_identifier:128});if(Pt.attachMedia(ge),Pt.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const ci=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...Ct,data_identifier:129});ci.attachMedia(ge),ci.show()}_t.on(window.Hls.Events.FRAG_PARSING_METADATA,(ci,hi)=>{for(const Xt of hi.samples)this.plugins.aribb24Caption&&this.plugins.aribb24Caption.pushID3v2Data(Xt.pts,Xt.data),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.pushID3v2Data(Xt.pts,Xt.data)})}}else if(ge.canPlayType("application/x-mpegURL")||ge.canPlayType("application/vnd.apple.mpegURL")){if(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose)}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!0;const ft=this.options.pluginOptions.aribb24,_t=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...ft,data_identifier:128});if(_t.attachMedia(ge),_t.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ct=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...ft,data_identifier:129});Ct.attachMedia(ge),Ct.show()}}}else this.notice("Error: HLS is not supported.",void 0,void 0,"#FF6F6A")}else this.notice("Error: Can't find hls.js.",void 0,void 0,"#FF6F6A");break;case"live-llhls-for-KonomiTV":this.plugins.liveLLHLSForKonomiTV&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),jt.delete(`${this.plugins.liveLLHLSForKonomiTV.baseUrl}/${this.plugins.liveLLHLSForKonomiTV.clientId}`),delete this.plugins.liveLLHLSForKonomiTV),(async()=>{const Xe=this.quality!==null?this.quality.url:this.options.video.url,ft=(await jt.post(Xe)).data.client_id,_t=(Pt=!1)=>{let ci=Xe.replace("/ll-hls",`/ll-hls/${ft}/primary-audio/playlist.m3u8`);if(Pt===!0&&(ci=Xe.replace("/ll-hls",`/ll-hls/${ft}/secondary-audio/playlist.m3u8`)),ge.src===ci)return;const hi=ge.paused;if(ge.src=ci,ge.load(),this.plugins.aribb24Caption&&this.plugins.aribb24Caption.dispose(),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.dispose(),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!0;const Xt=this.options.pluginOptions.aribb24,_i=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...Xt,data_identifier:128});if(_i.attachMedia(ge),_i.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ui=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...Xt,data_identifier:129});Ui.attachMedia(ge),Ui.show()}}hi||ge.play()},Ct={baseUrl:Xe,clientId:ft,switchPrimaryAudio(){_t(!1)},switchSecondaryAudio(){_t(!0)}};this.plugins.liveLLHLSForKonomiTV=Ct,_t(!1),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),jt.delete(`${Ct.baseUrl}/${Ct.clientId}`),delete this.plugins.liveLLHLSForKonomiTV})})();break;case"mpegts":if(window.mpegts)if(window.mpegts.isSupported()){this.plugins.mpegts&&(this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),this.plugins.mpegts.unload(),this.plugins.mpegts.detachMediaElement(),this.plugins.mpegts.destroy(),delete this.plugins.mpegts),this.options.pluginOptions.mpegts===void 0&&(this.options.pluginOptions.mpegts={});const Xe=window.mpegts.createPlayer(Object.assign(this.options.pluginOptions.mpegts.mediaDataSource||{},{type:"mpegts",isLive:this.options.live,url:ge.src}),this.options.pluginOptions.mpegts.config);if(this.plugins.mpegts=Xe,Xe.attachMediaElement(ge),Xe.load(),this.events.on("destroy",()=>{this.plugins.aribb24Caption&&(this.plugins.aribb24Caption.dispose(),delete this.plugins.aribb24Caption),this.plugins.aribb24Superimpose&&(this.plugins.aribb24Superimpose.dispose(),delete this.plugins.aribb24Superimpose),Xe.unload(),Xe.detachMediaElement(),Xe.destroy(),delete this.plugins.mpegts}),this.options.subtitle&&this.options.subtitle.type==="aribb24"){this.options.pluginOptions.aribb24===void 0&&(this.options.pluginOptions.aribb24={}),this.options.pluginOptions.aribb24.enableAutoInBandMetadataTextTrackDetection=!1;const ft=this.options.pluginOptions.aribb24,_t=this.plugins.aribb24Caption=new Mt.CanvasRenderer({...ft,data_identifier:128});if(_t.attachMedia(ge),_t.show(),this.options.pluginOptions.aribb24.disableSuperimposeRenderer!==!0){const Ct=this.plugins.aribb24Superimpose=new Mt.CanvasRenderer({...ft,data_identifier:129});Ct.attachMedia(ge),Ct.show()}Xe.on(window.mpegts.Events.TIMED_ID3_METADATA_ARRIVED,Ct=>{this.plugins.aribb24Caption&&this.plugins.aribb24Caption.pushID3v2Data(Ct.pts/1e3,Ct.data),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.pushID3v2Data(Ct.pts/1e3,Ct.data)})}}else this.notice("Error: mpegts.js is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find mpegts.js.",void 0,void 0,"#FF6F6A");break;case"flv":if(window.flvjs)if(window.flvjs.isSupported()){this.options.pluginOptions.flv===void 0&&(this.options.pluginOptions.flv={});const Xe=window.flvjs.createPlayer(Object.assign(this.options.pluginOptions.flv.mediaDataSource||{},{type:"flv",url:ge.src}),this.options.pluginOptions.flv.config);this.plugins.flvjs=Xe,Xe.attachMediaElement(ge),Xe.load(),this.events.on("destroy",()=>{Xe.unload(),Xe.detachMediaElement(),Xe.destroy(),delete this.plugins.flvjs})}else this.notice("Error: flv.js is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find flv.js.",void 0,void 0,"#FF6F6A");break;case"dash":if(window.dashjs){const Xe=window.dashjs.MediaPlayer().create();Xe.initialize(ge,ge.src,!1);const ft=this.options.pluginOptions.dash;Xe.updateSettings(ft??{}),this.plugins.dash=Xe,this.events.on("destroy",()=>{Xe.reset(),delete this.plugins.dash})}else this.notice("Error: Can't find dash.js.",void 0,void 0,"#FF6F6A");break;case"webtorrent":if(window.WebTorrent)if(window.WebTorrent.WEBRTC_SUPPORT){this.container.classList.add("dplayer-loading");const Xe=this.options.pluginOptions.webtorrent,ft=new window.WebTorrent(Xe);this.plugins.webtorrent=ft;const _t=ge.src;ge.src="",ge.preload="metadata",ge.addEventListener("durationchange",()=>this.container.classList.remove("dplayer-loading"),{once:!0}),ft.add(_t,Ct=>{const Pt=Ct.files.find(ci=>ci.name.endsWith(".mp4"));Pt&&Pt.renderTo(this.video,{autoplay:this.options.autoplay,controls:!1})}),this.events.on("destroy",()=>{ft.remove(_t),ft.destroy(),delete this.plugins.webtorrent})}else this.notice("Error: Webtorrent is not supported.",void 0,void 0,"#FF6F6A");else this.notice("Error: Can't find Webtorrent.",void 0,void 0,"#FF6F6A")}}initVideo(ge,Le){this.initMSE(ge,Le),this.on("durationchange",()=>{ge.duration!==1&&ge.duration!==1/0&&(this.template.dtime.textContent=Wt.secondToTime(ge.duration))}),this.on("progress",()=>{const Xe=Wt.getVideoDuration(this.video,this.template),ft=ge.buffered.length?ge.buffered.end(ge.buffered.length-1)/Xe:0;this.bar.set("loaded",ft,"width")}),this.on("error",()=>{this.video.error&&(this.switchingQuality&&(this.prevVideo!==null&&this.template.videoWrapAspect.removeChild(this.prevVideo),this.video.classList.add("dplayer-video-current"),this.prevVideo=null,this.switchingQuality=!1,this.events.trigger("quality_end")),this.tran&&this.notice&&this.type!=="webtorrent"&&this.type!=="live-llhls-for-KonomiTV"&&this.notice(this.tran("Video load failed"),-1,void 0,"#FF6F6A"),this.container.classList.remove("dplayer-loading"))}),this.on("ended",()=>{this.bar.set("played",1,"width"),this.setting.loop?(this.seek(0),this.play()):this.pause(),this.danmaku&&(this.danmaku.danIndex=0)}),this.on("play",()=>{this.paused&&this.play(!0)}),this.on("pause",()=>{this.paused||this.pause(!0)}),this.on("timeupdate",()=>{const Xe=Wt.getVideoDuration(this.video,this.template);this.bar.set("played",this.video.currentTime/Xe,"width");const ft=Wt.secondToTime(this.video.currentTime);this.template.ptime.textContent!==ft&&(this.template.ptime.textContent=ft)});for(let Xe=0;Xe {this.events.trigger(this.events.videoEvents[Xe],ft)});this.volume(this.user.get("volume"),!0,!0),this.options.subtitle&&(this.subtitle=new ks(this.template.subtitle,this.video,this.plugins,this.options.subtitle,this.events),this.user.get("subtitle")||this.subtitle.hide())}switchQuality(ge){if(ge=typeof ge=="string"?parseInt(ge):ge,this.options.video.quality===void 0||this.qualityIndex===ge||this.switchingQuality)return;this.qualityIndex=ge,this.switchingQuality=!0,this.quality=this.options.video.quality[ge];const Le=this.video.paused;this.video.pause();const Xe=$r()({current:!1,pic:null,screenshot:this.options.screenshot,preload:"auto",url:this.quality.type==="live-llhls-for-KonomiTV"?"":this.quality.url,subtitle:this.options.subtitle,crossOrigin:this.options.crossOrigin}),ft=new DOMParser().parseFromString(Xe,"text/html").body.firstChild;this.template.videoWrapAspect.insertBefore(ft,this.template.videoWrapAspect.getElementsByTagName("div")[0]),this.prevVideoCurrentTime=this.video.currentTime,this.prevVideo=this.video,this.video=ft,this.initVideo(this.video,this.quality.type||this.options.video.type),this.options.live||this.seek(this.prevVideoCurrentTime),Le||this.video.play(),this.options.lang==="ja"||this.options.lang==="ja-jp"?this.notice(`画質を ${this.quality.name} に切り替えています…`,-1):this.notice(`${this.tran("Switching to")} ${this.quality.name} ${this.tran("quality")}`,-1),this.container.classList.add("dplayer-loading"),this.events.trigger("quality_start",this.quality),this.template.qualityItem.forEach(_t=>{_t.classList.remove("dplayer-setting-quality-current"),parseInt(_t.dataset.index)===ge&&(_t.classList.add("dplayer-setting-quality-current"),this.template.qualityValue.textContent=this.quality.name,this.template.settingBox.classList.remove("dplayer-setting-box-quality"))}),this.on("canplay",()=>{if(this.prevVideo!==null){if(!this.options.live&&this.video.currentTime!==this.prevVideoCurrentTime)return void this.seek(this.prevVideoCurrentTime);this.template.videoWrapAspect.removeChild(this.prevVideo),this.video.classList.add("dplayer-video-current"),Le||this.video.play(),this.prevVideo=null,this.options.lang==="ja"||this.options.lang==="ja-jp"?this.notice(`画質を ${this.quality.name} に切り替えました。`,1e3):this.notice(`${this.tran("Switched to")} ${this.quality.name} ${this.tran("quality")}`),this.switchingQuality=!1;const _t=parseFloat(this.template.settingBox.querySelector(".dplayer-setting-speed-current").dataset.speed);this.speed(_t),this.template.settingBox.querySelector(".dplayer-setting-audio-current").dataset.audio==="secondary"&&(window.mpegts&&this.plugins.mpegts&&this.plugins.mpegts instanceof window.mpegts.MSEPlayer?this.plugins.mpegts.switchSecondaryAudio():this.plugins.liveLLHLSForKonomiTV&&this.plugins.liveLLHLSForKonomiTV.switchSecondaryAudio()),this.container.classList.remove("dplayer-loading"),this.events.trigger("quality_end")}})}notice(ge,Le=2e3,Xe=.8,ft){this.template.notice.textContent=ge,this.template.notice.style.opacity=`${Xe}`,this.template.notice.style.color=ft&&ft!==""?ft:"",this.noticeTime&&window.clearTimeout(this.noticeTime),this.events.trigger("notice_show",ge),Le>0&&(this.noticeTime=window.setTimeout(()=>{this.hideNotice()},Le))}hideNotice(){this.template.notice.style.opacity="0",this.events.trigger("notice_hide")}resize(){this.danmaku&&this.danmaku.resize(),this.plugins.aribb24Caption&&this.plugins.aribb24Caption.refresh(),this.plugins.aribb24Superimpose&&this.plugins.aribb24Superimpose.refresh(),this.controller.thumbnails&&this.controller.thumbnails.resize(160,this.video.videoHeight/this.video.videoWidth*160,this.template.barWrap.offsetWidth),this.events.trigger("resize")}speed(ge){this.video.playbackRate=ge,this.template.speedItem.forEach(Le=>{Le.classList.remove("dplayer-setting-speed-current"),parseFloat(Le.dataset.speed)===ge&&(Le.classList.add("dplayer-setting-speed-current"),parseFloat(Le.dataset.speed)===1?this.template.speedValue.textContent=this.tran("Normal"):this.template.speedValue.textContent=`${ge}`,this.template.settingBox.classList.remove("dplayer-setting-box-speed"))})}destroy(ge=!1){ts.splice(ts.indexOf(this),1),this.pause(),document.removeEventListener("click",this.docClickFun,!0),this.container.removeEventListener("click",this.containerClickFun,!0),this.fullScreen.destroy(),this.hotkey.destroy(),this.contextmenu.destroy(),this.controller.destroy(),this.timer.destroy(),this.setting.destroy(),this.resizeObserver.disconnect(),this.video.src="",ge||(this.container.innerHTML=""),this.events.trigger("destroy")}static get version(){return"1.31.2"}};console.log(` %c DPlayer v1.31.2 7131b6b %c http://dplayer.js.org -`,"color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");const is=Ls})(),A=A.default})())})(vp);var Bb=vp.exports;const Nb=sd(Bb);function Fb(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var bp={exports:{}};(function(_,e){(function(s){var u=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,y=/^(?=([^\/?#]*))\1([^]*)$/,A=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,c={buildAbsoluteURL:function(p,r,i){if(i=i||{},p=p.trim(),r=r.trim(),!r){if(!i.alwaysNormalize)return p;var t=c.parseURL(p);if(!t)throw new Error("Error trying to parse base URL.");return t.path=c.normalizePath(t.path),c.buildURLFromParts(t)}var n=c.parseURL(r);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return i.alwaysNormalize?(n.path=c.normalizePath(n.path),c.buildURLFromParts(n)):r;var a=c.parseURL(p);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&a.path[0]!=="/"){var o=y.exec(a.path);a.netLoc=o[1],a.path=o[2]}a.netLoc&&!a.path&&(a.path="/");var d={scheme:a.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(d.netLoc=a.netLoc,n.path[0]!=="/"))if(!n.path)d.path=a.path,n.params||(d.params=a.params,n.query||(d.query=a.query));else{var g=a.path,m=g.substring(0,g.lastIndexOf("/")+1)+n.path;d.path=c.normalizePath(m)}return d.path===null&&(d.path=i.alwaysNormalize?c.normalizePath(n.path):n.path),c.buildURLFromParts(d)},parseURL:function(p){var r=u.exec(p);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(A,"");p.length!==(p=p.replace(l,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}};_.exports=c})()})(bp);var yd=bp.exports;function gh(_,e){var s=Object.keys(_);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(_);e&&(u=u.filter(function(y){return Object.getOwnPropertyDescriptor(_,y).enumerable})),s.push.apply(s,u)}return s}function Dn(_){for(var e=1;e `):vs}function Wb(_,...e){e.forEach(function(s){Ta[s]=_[s]?_[s].bind(_):zb(s)})}function Kb(_,e){if(typeof console=="object"&&_===!0||typeof _=="object"){Wb(_,"debug","log","info","warn","error");try{Ta.log(`Debug logs enabled for "${e}" in hls.js version 1.5.1-patch.1`)}catch{Ta=Uc}}else Ta=Uc}const Ft=Ta,qb=/^(\d+)x(\d+)$/,Ah=/(.+?)=(".*?"|.*?)(?:,|$)/g;class bn{constructor(e){typeof e=="string"&&(e=bn.parseAttrList(e)),xn(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const s=parseInt(this[e],10);return s>Number.MAX_SAFE_INTEGER?1/0:s}hexadecimalInteger(e){if(this[e]){let s=(this[e]||"0x").slice(2);s=(s.length&1?"0":"")+s;const u=new Uint8Array(s.length/2);for(let y=0;y Number.MAX_SAFE_INTEGER?1/0:s}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,s){const u=this[e];return u?parseFloat(u):s}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const s=qb.exec(this[e]);if(s!==null)return{width:parseInt(s[1],10),height:parseInt(s[2],10)}}static parseAttrList(e){let s;const u={},y='"';for(Ah.lastIndex=0;(s=Ah.exec(e))!==null;){let A=s[2];A.indexOf(y)===0&&A.lastIndexOf(y)===A.length-1&&(A=A.slice(1,-1));const l=s[1].trim();u[l]=A}return u}}function Yb(_){return _!=="ID"&&_!=="CLASS"&&_!=="START-DATE"&&_!=="DURATION"&&_!=="END-DATE"&&_!=="END-ON-NEXT"}function Jb(_){return _==="SCTE35-OUT"||_==="SCTE35-IN"}class _p{constructor(e,s){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,s){const u=s.attr;for(const y in u)if(Object.prototype.hasOwnProperty.call(e,y)&&e[y]!==u[y]){Ft.warn(`DATERANGE tag attribute: "${y}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=y;break}e=xn(new bn({}),u,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const u=new Date(this.attr["END-DATE"]);Ci(u.getTime())&&(this._endDate=u)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Ci(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Ci(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Zo{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var fn={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ep{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[fn.AUDIO]:null,[fn.VIDEO]:null,[fn.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,s){const u=e.split("@",2);let y;u.length===1?y=(s==null?void 0:s.byteRangeEndOffset)||0:y=parseInt(u[1]),this._byteRange=[y,parseInt(u[0])+y]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=yd.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class ac extends Ep{constructor(e,s){super(s),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Zo,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const s=this.levelkeys.identity;if(s)this._decryptdata=s.getDecryptData(this.sn);else{const u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Ci(this.programDateTime))return null;const e=Ci(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const s=Object.keys(this.levelkeys),u=s.length;if(u>1||u===1&&this.levelkeys[s[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const s=this.levelkeys[e];s&&!this._decryptdata&&(this._decryptdata=s.getDecryptData(this.sn))}}abortRequests(){var e,s;(e=this.loader)==null||e.abort(),(s=this.keyLoader)==null||s.abort()}setElementaryStreamInfo(e,s,u,y,A,l=!1){const{elementaryStreams:c}=this,p=c[e];if(!p){c[e]={startPTS:s,endPTS:u,startDTS:y,endDTS:A,partial:l};return}p.startPTS=Math.min(p.startPTS,s),p.endPTS=Math.max(p.endPTS,u),p.startDTS=Math.min(p.startDTS,y),p.endDTS=Math.max(p.endDTS,A)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[fn.AUDIO]=null,e[fn.VIDEO]=null,e[fn.AUDIOVIDEO]=null}}class Qb extends Ep{constructor(e,s,u,y,A){super(u),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Zo,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=s,this.index=y;const l=e.enumeratedString("BYTERANGE");l&&this.setByteRange(l,A),A&&(this.fragOffset=A.fragOffset+A.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const Zb=10;class Xb{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const s=this.lastPartSn-e.lastPartSn,u=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!u||!!s||!this.live,this.advanced=this.endSN>e.endSN||s>0||s===0&&u>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Ci(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Zb}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function vd(_){return Uint8Array.from(atob(_),e=>e.charCodeAt(0))}function $b(_){const e=Gc(_).subarray(0,16),s=new Uint8Array(16);return s.set(e,16-e.length),s}function e_(_){const e=function(u,y,A){const l=u[y];u[y]=u[A],u[A]=l};e(_,0,3),e(_,1,2),e(_,4,5),e(_,6,7)}function t_(_){const e=_.split(":");let s=null;if(e[0]==="data"&&e.length===2){const u=e[1].split(";"),y=u[u.length-1].split(",");if(y.length===2){const A=y[0]==="base64",l=y[1];A?(u.splice(-1,1),s=vd(l)):s=$b(l)}}return s}function Gc(_){return Uint8Array.from(unescape(encodeURIComponent(_)),e=>e.charCodeAt(0))}const oa=typeof self<"u"?self:void 0;var vn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function yh(_){switch(_){case Zn.FAIRPLAY:return vn.FAIRPLAY;case Zn.PLAYREADY:return vn.PLAYREADY;case Zn.WIDEVINE:return vn.WIDEVINE;case Zn.CLEARKEY:return vn.CLEARKEY}}var wp={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function i_(_){if(_===wp.WIDEVINE)return vn.WIDEVINE}function vh(_){switch(_){case vn.FAIRPLAY:return Zn.FAIRPLAY;case vn.PLAYREADY:return Zn.PLAYREADY;case vn.WIDEVINE:return Zn.WIDEVINE;case vn.CLEARKEY:return Zn.CLEARKEY}}function oc(_){const{drmSystems:e,widevineLicenseUrl:s}=_,u=e?[vn.FAIRPLAY,vn.WIDEVINE,vn.PLAYREADY,vn.CLEARKEY].filter(y=>!!e[y]):[];return!u[vn.WIDEVINE]&&s&&u.push(vn.WIDEVINE),u}const Sp=function(_){return oa!=null&&(_=oa.navigator)!=null&&_.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function n_(_,e,s,u){let y;switch(_){case vn.FAIRPLAY:y=["cenc","sinf"];break;case vn.WIDEVINE:case vn.PLAYREADY:y=["cenc"];break;case vn.CLEARKEY:y=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${_}`)}return r_(y,e,s,u)}function r_(_,e,s,u){return[{initDataTypes:_,persistentState:u.persistentState||"optional",distinctiveIdentifier:u.distinctiveIdentifier||"optional",sessionTypes:u.sessionTypes||[u.sessionType||"temporary"],audioCapabilities:e.map(A=>({contentType:`audio/mp4; codecs="${A}"`,robustness:u.audioRobustness||"",encryptionScheme:u.audioEncryptionScheme||null})),videoCapabilities:s.map(A=>({contentType:`video/mp4; codecs="${A}"`,robustness:u.videoRobustness||"",encryptionScheme:u.videoEncryptionScheme||null}))}]}function Ts(_,e,s){return Uint8Array.prototype.slice?_.slice(e,s):new Uint8Array(Array.prototype.slice.call(_,e,s))}const bd=(_,e)=>e+10<=_.length&&_[e]===73&&_[e+1]===68&&_[e+2]===51&&_[e+3]<255&&_[e+4]<255&&_[e+6]<128&&_[e+7]<128&&_[e+8]<128&&_[e+9]<128,Tp=(_,e)=>e+10<=_.length&&_[e]===51&&_[e+1]===68&&_[e+2]===73&&_[e+3]<255&&_[e+4]<255&&_[e+6]<128&&_[e+7]<128&&_[e+8]<128&&_[e+9]<128,Ra=(_,e)=>{const s=e;let u=0;for(;bd(_,e);){u+=10;const y=Xo(_,e+6);u+=y,Tp(_,e+10)&&(u+=10),e+=u}if(u>0)return _.subarray(s,s+u)},Xo=(_,e)=>{let s=0;return s=(_[e]&127)<<21,s|=(_[e+1]&127)<<14,s|=(_[e+2]&127)<<7,s|=_[e+3]&127,s},s_=(_,e)=>bd(_,e)&&Xo(_,e+6)+10<=_.length-e,_d=_=>{const e=xp(_);for(let s=0;s _&&_.key==="PRIV"&&_.info==="com.apple.streaming.transportStreamTimestamp",a_=_=>{const e=String.fromCharCode(_[0],_[1],_[2],_[3]),s=Xo(_,4),u=10;return{type:e,size:s,data:_.subarray(u,u+s)}},xp=_=>{let e=0;const s=[];for(;bd(_,e);){const u=Xo(_,e+6);e+=10;const y=e+u;for(;e+8 _.type==="PRIV"?l_(_):_.type[0]==="W"?d_(_):c_(_),l_=_=>{if(_.size<2)return;const e=Vr(_.data,!0),s=new Uint8Array(_.data.subarray(e.length+1));return{key:_.type,info:e,data:s.buffer}},c_=_=>{if(_.size<2)return;if(_.type==="TXXX"){let s=1;const u=Vr(_.data.subarray(s),!0);s+=u.length+1;const y=Vr(_.data.subarray(s));return{key:_.type,info:u,data:y}}const e=Vr(_.data.subarray(1));return{key:_.type,data:e}},d_=_=>{if(_.type==="WXXX"){if(_.size<2)return;let s=1;const u=Vr(_.data.subarray(s),!0);s+=u.length+1;const y=Vr(_.data.subarray(s));return{key:_.type,info:u,data:y}}const e=Vr(_.data);return{key:_.type,data:e}},u_=_=>{if(_.data.byteLength===8){const e=new Uint8Array(_.data),s=e[3]&1;let u=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return u/=45,s&&(u+=4772185884e-2),Math.round(u)}},Vr=(_,e=!1)=>{const s=h_();if(s){const r=s.decode(_);if(e){const i=r.indexOf("\0");return i!==-1?r.substring(0,i):r}return r.replace(/\0/g,"")}const u=_.length;let y,A,l,c="",p=0;for(;p>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(y);break;case 12:case 13:A=_[p++],c+=String.fromCharCode((y&31)<<6|A&63);break;case 14:A=_[p++],l=_[p++],c+=String.fromCharCode((y&15)<<12|(A&63)<<6|(l&63)<<0);break}}return c};let lc;function h_(){if(!navigator.userAgent.includes("PlayStation 4"))return!lc&&typeof self.TextDecoder<"u"&&(lc=new self.TextDecoder("utf-8")),lc}const Fr={hexDump:function(_){let e="";for(let s=0;s<_.length;s++){let u=_[s].toString(16);u.length<2&&(u="0"+u),e+=u}return e}},ko=Math.pow(2,32)-1,f_=[].push,kp={video:1,audio:2,id3:3,text:4};function In(_){return String.fromCharCode.apply(null,_)}function Rp(_,e){const s=_[e]<<8|_[e+1];return s<0?65536+s:s}function Ki(_,e){const s=Ip(_,e);return s<0?4294967296+s:s}function Ip(_,e){return _[e]<<24|_[e+1]<<16|_[e+2]<<8|_[e+3]}function cc(_,e,s){_[e]=s>>24,_[e+1]=s>>16&255,_[e+2]=s>>8&255,_[e+3]=s&255}function p_(_){const e=_.byteLength;for(let s=0;s 8&&_[s+4]===109&&_[s+5]===111&&_[s+6]===111&&_[s+7]===102)return!0;s=u>1?s+u:e}return!1}function Zi(_,e){const s=[];if(!e.length)return s;const u=_.byteLength;for(let y=0;y1?y+A:u;if(l===e[0])if(e.length===1)s.push(_.subarray(y+8,c));else{const p=Zi(_.subarray(y+8,c),e.slice(1));p.length&&f_.apply(s,p)}y=c}return s}function m_(_){const e=[],s=_[0];let u=8;const y=Ki(_,u);u+=4;const A=0,l=0;s===0?u+=8:u+=16,u+=2;let c=_.length+l;const p=Rp(_,u);u+=2;for(let r=0;r >>31===1)return Ft.warn("SIDX has hierarchical references (not supported)"),null;const o=Ki(_,i);i+=4,e.push({referenceSize:n,subsegmentDuration:o,info:{duration:o/y,start:c,end:c+n-1}}),c+=n,i+=4,u=i}return{earliestPresentationTime:A,timescale:y,version:s,referencesCount:p,references:e}}function Lp(_){const e=[],s=Zi(_,["moov","trak"]);for(let y=0;y
{const A=Ki(y,4),l=e[A];l&&(l.default={duration:Ki(y,12),flags:Ki(y,20)})}),e}function g_(_){const e=_.subarray(8),s=e.subarray(86),u=In(e.subarray(4,8));let y=u;const A=u==="enca"||u==="encv";if(A){const c=Zi(e,[u])[0].subarray(u==="enca"?28:78);Zi(c,["sinf"]).forEach(r=>{const i=Zi(r,["schm"])[0];if(i){const t=In(i.subarray(4,8));if(t==="cbcs"||t==="cenc"){const n=Zi(r,["frma"])[0];n&&(y=In(n))}}})}switch(y){case"avc1":case"avc2":case"avc3":case"avc4":{const l=Zi(s,["avcC"])[0];y+="."+Za(l[1])+Za(l[2])+Za(l[3]);break}case"mp4a":{const l=Zi(e,[u])[0],c=Zi(l.subarray(28),["esds"])[0];if(c&&c.length>12){let p=4;if(c[p++]!==3)break;p=dc(c,p),p+=2;const r=c[p++];if(r&128&&(p+=2),r&64&&(p+=c[p++]),c[p++]!==4)break;p=dc(c,p);const i=c[p++];if(i===64)y+="."+Za(i);else break;if(p+=12,c[p++]!==5)break;p=dc(c,p);const t=c[p++];let n=(t&248)>>3;n===31&&(n+=1+((t&7)<<3)+((c[p]&224)>>5)),y+="."+n}break}case"hvc1":case"hev1":{const l=Zi(s,["hvcC"])[0],c=l[1],p=["","A","B","C"][c>>6],r=c&31,i=Ki(l,2),t=(c&32)>>5?"H":"L",n=l[12],a=l.subarray(6,12);y+="."+p+r,y+="."+i.toString(16).toUpperCase(),y+="."+t+n;let o="";for(let d=a.length;d--;){const g=a[d];(g||o)&&(o="."+g.toString(16).toUpperCase()+o)}y+=o;break}case"dvh1":case"dvhe":{const l=Zi(s,["dvcC"])[0],c=l[2]>>1&127,p=l[2]<<5&32|l[3]>>3&31;y+="."+Nr(c)+"."+Nr(p);break}case"vp09":{const l=Zi(s,["vpcC"])[0],c=l[4],p=l[5],r=l[6]>>4&15;y+="."+Nr(c)+"."+Nr(p)+"."+Nr(r);break}case"av01":{const l=Zi(s,["av1C"])[0],c=l[1]>>>5,p=l[1]&31,r=l[2]>>>7?"H":"M",i=(l[2]&64)>>6,t=(l[2]&32)>>5,n=c===2&&i?t?12:10:i?10:8,a=(l[2]&16)>>4,o=(l[2]&8)>>3,d=(l[2]&4)>>2,g=l[2]&3;y+="."+c+"."+Nr(p)+r+"."+Nr(n)+"."+a+"."+o+d+g+"."+Nr(1)+"."+Nr(1)+"."+Nr(1)+"."+0;break}}return{codec:y,encrypted:A}}function dc(_,e){const s=e+5;for(;_[e++]&128&&e {const l=Zi(y,["mdia","minf","stbl","stsd"])[0].subarray(8);let c=Zi(l,["enca"]);const p=c.length>0;p||(c=Zi(l,["encv"])),c.forEach(r=>{const i=p?r.subarray(28):r.subarray(78);Zi(i,["sinf"]).forEach(n=>{const a=Dp(n);if(a){const o=a.subarray(8,24);o.some(d=>d!==0)||(Ft.log(`[eme] Patching keyId in 'enc${p?"a":"v"}>sinf>>tenc' box: ${Fr.hexDump(o)} -> ${Fr.hexDump(s)}`),a.set(s,8))}})})}),_}function Dp(_){const e=Zi(_,["schm"])[0];if(e){const s=In(e.subarray(4,8));if(s==="cbcs"||s==="cenc")return Zi(_,["schi","tenc"])[0]}return Ft.error("[eme] missing 'schm' box"),null}function y_(_,e){return Zi(e,["moof","traf"]).reduce((s,u)=>{const y=Zi(u,["tfdt"])[0],A=y[0],l=Zi(u,["tfhd"]).reduce((c,p)=>{const r=Ki(p,4),i=_[r];if(i){let t=Ki(y,4);if(A===1){if(t===ko)return Ft.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),c;t*=ko+1,t+=Ki(y,8)}const n=i.timescale||9e4,a=t/n;if(Ci(a)&&(c===null||ai+t.info.duration||0,0))}return l}return u||y}function b_(_){const e=Ki(_,0);let s=8;e&1&&(s+=4),e&4&&(s+=4);let u=0;const y=Ki(_,4);for(let A=0;A {Zi(u,["tfhd"]).forEach(y=>{const A=Ki(y,4),l=_[A];if(!l)return;const c=l.timescale||9e4;Zi(u,["tfdt"]).forEach(p=>{const r=p[0],i=s*c;if(i){let t=Ki(p,4);if(r===0)t-=i,t=Math.max(t,0),cc(p,4,t);else{t*=Math.pow(2,32),t+=Ki(p,8),t-=i,t=Math.max(t,0);const n=Math.floor(t/(ko+1)),a=Math.floor(t%(ko+1));cc(p,4,n),cc(p,8,a)}}})})})}function E_(_){const e={valid:null,remainder:null},s=Zi(_,["moof"]);if(s.length<2)return e.remainder=_,e;const u=s[s.length-1];return e.valid=Ts(_,0,u.byteOffset-8),e.remainder=Ts(_,u.byteOffset-8),e}function Ar(_,e){const s=new Uint8Array(_.length+e.length);return s.set(_),s.set(e,_.length),s}function bh(_,e){const s=[],u=e.samples,y=e.timescale,A=e.id;let l=!1;return Zi(u,["moof"]).map(p=>{const r=p.byteOffset-8;Zi(p,["traf"]).map(t=>{const n=Zi(t,["tfdt"]).map(a=>{const o=a[0];let d=Ki(a,4);return o===1&&(d*=Math.pow(2,32),d+=Ki(a,8)),d/y})[0];return n!==void 0&&(_=n),Zi(t,["tfhd"]).map(a=>{const o=Ki(a,4),d=Ki(a,0)&16777215,g=(d&1)!==0,m=(d&2)!==0,v=(d&8)!==0;let b=0;const w=(d&16)!==0;let C=0;const D=(d&32)!==0;let R=8;o===A&&(g&&(R+=8),m&&(R+=4),v&&(b=Ki(a,R),R+=4),w&&(C=Ki(a,R),R+=4),D&&(R+=4),e.type==="video"&&(l=w_(e.codec)),Zi(t,["trun"]).map(T=>{const P=T[0],L=Ki(T,0)&16777215,I=(L&1)!==0;let x=0;const O=(L&4)!==0,G=(L&256)!==0;let J=0;const te=(L&512)!==0;let le=0;const ne=(L&1024)!==0,ee=(L&2048)!==0;let M=0;const Y=Ki(T,4);let j=8;I&&(x=Ki(T,j),j+=4),O&&(j+=4);let z=x+r;for(let q=0;q >1&63;return s===39||s===40}else return(e&31)===6}function Ed(_,e,s,u){const y=Op(_);let A=0;A+=e;let l=0,c=0,p=0;for(;A =y.length)break;p=y[A++],l+=p}while(p===255);c=0;do{if(A>=y.length)break;p=y[A++],c+=p}while(p===255);const r=y.length-A;let i=A;if(c r){Ft.error(`Malformed SEI payload. ${c} is too small, only ${r} bytes left to parse.`);break}if(l===4){if(y[i++]===181){const n=Rp(y,i);if(i+=2,n===49){const a=Ki(y,i);if(i+=4,a===1195456820){const o=y[i++];if(o===3){const d=y[i++],g=31&d,m=64&d,v=m?2+g*3:0,b=new Uint8Array(v);if(m){b[0]=d;for(let w=1;w 16){const t=[];for(let o=0;o<16;o++){const d=y[i++].toString(16);t.push(d.length==1?"0"+d:d),(o===3||o===5||o===7||o===9)&&t.push("-")}const n=c-16,a=new Uint8Array(n);for(let o=0;o >24&255,A[1]=u>>16&255,A[2]=u>>8&255,A[3]=u&255,A.set(_,4),y=0,u=8;y 0?(A=new Uint8Array(4),e.length>0&&new DataView(A.buffer).setUint32(0,e.length,!1)):A=new Uint8Array;const l=new Uint8Array(4);return s&&s.byteLength>0&&new DataView(l.buffer).setUint32(0,s.byteLength,!1),C_([112,115,115,104],new Uint8Array([u,0,0,0]),_,A,y,l,s||new Uint8Array)}function k_(_){if(!(_ instanceof ArrayBuffer)||_.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},s=new DataView(_),u=s.getUint32(0);if(_.byteLength!==u&&u>44||s.getUint32(4)!==1886614376||(e.version=s.getUint32(8)>>>24,e.version>1))return null;e.systemId=Fr.hexDump(new Uint8Array(_,12,16));const A=s.getUint32(28);if(e.version===0){if(u-32=22&&(this.keyId=s.subarray(s.length-22,s.length-6));break;case Zn.PLAYREADY:{const u=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=x_(u,null,s);const y=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),A=String.fromCharCode.apply(null,Array.from(y)),l=A.substring(A.indexOf("<"),A.length),r=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(r){const i=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(i){const t=vd(i).subarray(0,16);e_(t),this.keyId=t}}break}default:{let u=s.subarray(0,16);if(u.length!==16){const y=new Uint8Array(16);y.set(u,16-u.length),u=y}this.keyId=u;break}}if(!this.keyId||this.keyId.byteLength!==16){let u=Xa[this.uri];if(!u){const y=Object.keys(Xa).length%Number.MAX_SAFE_INTEGER;u=new Uint8Array(16),new DataView(u.buffer,12,4).setUint32(0,y),Xa[this.uri]=u}this.keyId=u}return this}}function R_(_){const e=new Uint8Array(16);for(let s=12;s<16;s++)e[s]=_>>8*(15-s)&255;return e}const Mp=/\{\$([a-zA-Z0-9-_]+)\}/g;function _h(_){return Mp.test(_)}function Qn(_,e,s){if(_.variableList!==null||_.hasVariableRefs)for(let u=s.length;u--;){const y=s[u],A=e[y];A&&(e[y]=jc(_,A))}}function jc(_,e){if(_.variableList!==null||_.hasVariableRefs){const s=_.variableList;return e.replace(Mp,u=>{const y=u.substring(2,u.length-1),A=s==null?void 0:s[y];return A===void 0?(_.playlistParsingError||(_.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${y}"`)),u):A})}return e}function Eh(_,e,s){let u=_.variableList;u||(_.variableList=u={});let y,A;if("QUERYPARAM"in e){y=e.QUERYPARAM;try{const l=new self.URL(s).searchParams;if(l.has(y))A=l.get(y);else throw new Error(`"${y}" does not match any query parameter in URI: "${s}"`)}catch(l){_.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else y=e.NAME,A=e.VALUE;y in u?_.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${y}"`)):u[y]=A||""}function I_(_,e,s){const u=e.IMPORT;if(s&&u in s){let y=_.variableList;y||(_.variableList=y={}),y[u]=s[u]}else _.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${u}"`))}function ua(_=!0){return typeof self>"u"?void 0:(_||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const Ro={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function L_(_,e){const s=Ro[e];return!!s&&!!s[_.slice(0,4)]}function uc(_,e,s=!0){return!_.split(",").some(u=>!Pp(u,e,s))}function Pp(_,e,s=!0){var u;const y=ua(s);return(u=y==null?void 0:y.isTypeSupported(La(_,e)))!=null?u:!1}function La(_,e){return`${e}/mp4;codecs="${_}"`}function wh(_){if(_){const e=_.substring(0,4);return Ro.video[e]}return 2}function Io(_){return _.split(",").reduce((e,s)=>{const u=Ro.video[s];return u?(u*2+e)/(e?3:2):(Ro.audio[s]+e)/(e?2:1)},0)}const hc={};function D_(_,e=!0){if(hc[_])return hc[_];const s={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[_];for(let u=0;uD_(s.toLowerCase(),e))}function Sh(_,e){return _&&_!=="mp4a"?_:e}function M_(_){const e=_.split(".");if(e.length>2){let s=e.shift()+".";return s+=parseInt(e.shift()).toString(16),s+=("000"+parseInt(e.shift()).toString(16)).slice(-4),s}return _}const Th=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Ch=/#EXT-X-MEDIA:(.*)/g,P_=/^#EXT(?:INF|-X-TARGETDURATION):/m,xh=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),B_=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Gr{static findGroup(e,s){for(let u=0;u 0&&A.length ({id:r.attrs.AUDIO,audioCodec:r.audioCodec})),SUBTITLES:l.map(r=>({id:r.attrs.SUBTITLES,textCodec:r.textCodec})),"CLOSED-CAPTIONS":[]};let p=0;for(Ch.lastIndex=0;(y=Ch.exec(e))!==null;){const r=new bn(y[1]),i=r.TYPE;if(i){const t=c[i],n=A[i]||[];A[i]=n,Qn(u,r,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const a=r.LANGUAGE,o=r["ASSOC-LANGUAGE"],d=r.CHANNELS,g=r.CHARACTERISTICS,m=r["INSTREAM-ID"],v={attrs:r,bitrate:0,id:p++,groupId:r["GROUP-ID"]||"",name:r.NAME||a||"",type:i,default:r.bool("DEFAULT"),autoselect:r.bool("AUTOSELECT"),forced:r.bool("FORCED"),lang:a,url:r.URI?Gr.resolve(r.URI,s):""};if(o&&(v.assocLang=o),d&&(v.channels=d),g&&(v.characteristics=g),m&&(v.instreamId=m),t!=null&&t.length){const b=Gr.findGroup(t,v.groupId)||t[0];Ih(v,b,"audioCodec"),Ih(v,b,"textCodec")}n.push(v)}}return A}static parseLevelPlaylist(e,s,u,y,A,l){const c=new Xb(s),p=c.fragments;let r=null,i=0,t=0,n=0,a=0,o=null,d=new ac(y,s),g,m,v,b=-1,w=!1,C=null;for(xh.lastIndex=0,c.m3u8=e,c.hasVariableRefs=_h(e);(g=xh.exec(e))!==null;){w&&(w=!1,d=new ac(y,s),d.start=n,d.sn=i,d.cc=a,d.level=u,r&&(d.initSegment=r,d.rawProgramDateTime=r.rawProgramDateTime,r.rawProgramDateTime=null,C&&(d.setByteRange(C),C=null)));const P=g[1];if(P){d.duration=parseFloat(P);const L=(" "+g[2]).slice(1);d.title=L||null,d.tagList.push(L?["INF",P,L]:["INF",P])}else if(g[3]){if(Ci(d.duration)){d.start=n,v&&Oh(d,v,c),d.sn=i,d.level=u,d.cc=a,p.push(d);const L=(" "+g[3]).slice(1);d.relurl=jc(c,L),Lh(d,o),o=d,n+=d.duration,i++,t=0,w=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);o?d.setByteRange(L,o):d.setByteRange(L)}else if(g[5])d.rawProgramDateTime=(" "+g[5]).slice(1),d.tagList.push(["PROGRAM-DATE-TIME",d.rawProgramDateTime]),b===-1&&(b=p.length);else{if(g=g[0].match(B_),!g){Ft.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m 0&&O.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),c.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const O=new bn(I);c.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case"PART":{let O=c.partList;O||(O=c.partList=[]);const G=t>0?O[O.length-1]:void 0,J=t++,te=new bn(I);Qn(c,te,["BYTERANGE","URI"]);const le=new Qb(te,d,s,J,G);O.push(le),d.duration+=le.duration;break}case"PRELOAD-HINT":{const O=new bn(I);Qn(c,O,["URI"]),c.preloadHint=O;break}case"RENDITION-REPORT":{const O=new bn(I);Qn(c,O,["URI"]),c.renditionReports=c.renditionReports||[],c.renditionReports.push(O);break}default:Ft.warn(`line parsed but not handled: ${g}`);break}}}o&&!o.relurl?(p.pop(),n-=o.duration,c.partList&&(c.fragmentHint=o)):c.partList&&(Lh(d,o),d.cc=a,c.fragmentHint=d,v&&Oh(d,v,c));const D=p.length,R=p[0],T=p[D-1];if(n+=c.skippedSegments*c.targetduration,n>0&&D&&T){c.averagetargetduration=n/D;const P=T.sn;c.endSN=P!=="initSegment"?P:0,c.live||(T.endList=!0),R&&(c.startCC=R.cc)}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(n+=c.fragmentHint.duration),c.totalduration=n,c.endCC=a,b>0&&F_(p,b),c}}function kh(_,e,s){var u,y;const A=new bn(_);Qn(s,A,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(u=A.METHOD)!=null?u:"",c=A.URI,p=A.hexadecimalInteger("IV"),r=A.KEYFORMATVERSIONS,i=(y=A.KEYFORMAT)!=null?y:"identity";c&&A.IV&&!p&&Ft.error(`Invalid IV: ${A.IV}`);const t=c?Gr.resolve(c,e):"",n=(r||"1").split("/").map(Number).filter(Number.isFinite);return new Ia(l,t,i,n,p)}function Rh(_){const s=new bn(_).decimalFloatingPoint("TIME-OFFSET");return Ci(s)?s:null}function N_(_,e){let s=(_||"").split(/[ ,]+/).filter(u=>u);["video","audio","text"].forEach(u=>{const y=s.filter(A=>L_(A,u));y.length&&(e[`${u}Codec`]=y.join(","),s=s.filter(A=>y.indexOf(A)===-1))}),e.unknownCodecs=s}function Ih(_,e,s){const u=e[s];u&&(_[s]=u)}function F_(_,e){let s=_[e];for(let u=e;u--;){const y=_[u];if(!y)return;y.programDateTime=s.programDateTime-y.duration*1e3,s=y}}function Lh(_,e){_.rawProgramDateTime?_.programDateTime=Date.parse(_.rawProgramDateTime):e!=null&&e.programDateTime&&(_.programDateTime=e.endProgramDateTime),Ci(_.programDateTime)||(_.programDateTime=null,_.rawProgramDateTime=null)}function Dh(_,e,s,u){_.relurl=e.URI,e.BYTERANGE&&_.setByteRange(e.BYTERANGE),_.level=s,_.sn="initSegment",u&&(_.levelkeys=u),_.initSegment=null}function Oh(_,e,s){_.levelkeys=e;const{encryptedFragments:u}=s;(!u.length||u[u.length-1].levelkeys!==e)&&Object.keys(e).some(y=>e[y].isCommonEncryption)&&u.push(_)}var ln={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Hi={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Mh(_){const{type:e}=_;switch(e){case ln.AUDIO_TRACK:return Hi.AUDIO;case ln.SUBTITLE_TRACK:return Hi.SUBTITLE;default:return Hi.MAIN}}function fc(_,e){let s=_.url;return(s===void 0||s.indexOf("data:")===0)&&(s=e.url),s}class U_{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.LEVEL_LOADING,this.onLevelLoading,this),e.on(rt.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(rt.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.LEVEL_LOADING,this.onLevelLoading,this),e.off(rt.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(rt.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const s=this.hls.config,u=s.pLoader,y=s.loader,A=u||y,l=new A(s);return this.loaders[e.type]=l,l}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,s){const{url:u}=s;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ln.MANIFEST,url:u,deliveryDirectives:null})}onLevelLoading(e,s){const{id:u,level:y,pathwayId:A,url:l,deliveryDirectives:c}=s;this.load({id:u,level:y,pathwayId:A,responseType:"text",type:ln.LEVEL,url:l,deliveryDirectives:c})}onAudioTrackLoading(e,s){const{id:u,groupId:y,url:A,deliveryDirectives:l}=s;this.load({id:u,groupId:y,level:null,responseType:"text",type:ln.AUDIO_TRACK,url:A,deliveryDirectives:l})}onSubtitleTrackLoading(e,s){const{id:u,groupId:y,url:A,deliveryDirectives:l}=s;this.load({id:u,groupId:y,level:null,responseType:"text",type:ln.SUBTITLE_TRACK,url:A,deliveryDirectives:l})}load(e){var s;const u=this.hls.config;let y=this.getInternalLoader(e);if(y){const r=y.context;if(r&&r.url===e.url&&r.level===e.level){Ft.trace("[playlist-loader]: playlist request ongoing");return}Ft.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),y.abort()}let A;if(e.type===ln.MANIFEST?A=u.manifestLoadPolicy.default:A=xn({},u.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),y=this.createInternalLoader(e),Ci((s=e.deliveryDirectives)==null?void 0:s.part)){let r;if(e.type===ln.LEVEL&&e.level!==null?r=this.hls.levels[e.level].details:e.type===ln.AUDIO_TRACK&&e.id!==null?r=this.hls.audioTracks[e.id].details:e.type===ln.SUBTITLE_TRACK&&e.id!==null&&(r=this.hls.subtitleTracks[e.id].details),r){const i=r.partTarget,t=r.targetduration;if(i&&t){const n=Math.max(i*3,t*.8)*1e3;A=xn({},A,{maxTimeToFirstByteMs:Math.min(n,A.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(n,A.maxTimeToFirstByteMs)})}}}const l=A.errorRetry||A.timeoutRetry||{},c={loadPolicy:A,timeout:A.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},p={onSuccess:(r,i,t,n)=>{const a=this.getInternalLoader(t);this.resetInternalLoader(t.type);const o=r.data;if(o.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,t,new Error("no EXTM3U delimiter"),n||null,i);return}i.parsing.start=performance.now(),Gr.isMediaPlaylist(o)?this.handleTrackOrLevelPlaylist(r,i,t,n||null,a):this.handleMasterPlaylist(r,i,t,n)},onError:(r,i,t,n)=>{this.handleNetworkError(i,t,!1,r,n)},onTimeout:(r,i,t)=>{this.handleNetworkError(i,t,!0,void 0,r)}};y.load(e,c,p)}handleMasterPlaylist(e,s,u,y){const A=this.hls,l=e.data,c=fc(e,u),p=Gr.parseMasterPlaylist(l,c);if(p.playlistParsingError){this.handleManifestParsingError(e,u,p.playlistParsingError,y,s);return}const{contentSteering:r,levels:i,sessionData:t,sessionKeys:n,startTimeOffset:a,variableList:o}=p;this.variableList=o;const{AUDIO:d=[],SUBTITLES:g,"CLOSED-CAPTIONS":m}=Gr.parseMasterPlaylistMedia(l,c,p);d.length&&!d.some(b=>!b.url)&&i[0].audioCodec&&!i[0].attrs.AUDIO&&(Ft.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new bn({}),bitrate:0,url:""})),A.trigger(rt.MANIFEST_LOADED,{levels:i,audioTracks:d,subtitles:g,captions:m,contentSteering:r,url:c,stats:s,networkDetails:y,sessionData:t,sessionKeys:n,startTimeOffset:a,variableList:o})}handleTrackOrLevelPlaylist(e,s,u,y,A){const l=this.hls,{id:c,level:p,type:r}=u,i=fc(e,u),t=0,n=Ci(p)?p:Ci(c)?c:0,a=Mh(u),o=Gr.parseLevelPlaylist(e.data,i,n,a,t,this.variableList);if(r===ln.MANIFEST){const d={attrs:new bn({}),bitrate:0,details:o,name:"",url:i};l.trigger(rt.MANIFEST_LOADED,{levels:[d],audioTracks:[],url:i,stats:s,networkDetails:y,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}s.parsing.end=performance.now(),u.levelDetails=o,this.handlePlaylistLoaded(o,e,s,u,y,A)}handleManifestParsingError(e,s,u,y,A){this.hls.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.MANIFEST_PARSING_ERROR,fatal:s.type===ln.MANIFEST,url:e.url,err:u,error:u,reason:u.message,response:e,context:s,networkDetails:y,stats:A})}handleNetworkError(e,s,u=!1,y,A){let l=`A network ${u?"timeout":"error"+(y?" (status "+y.code+")":"")} occurred while loading ${e.type}`;e.type===ln.LEVEL?l+=`: ${e.level} id: ${e.id}`:(e.type===ln.AUDIO_TRACK||e.type===ln.SUBTITLE_TRACK)&&(l+=` id: ${e.id} group-id: "${e.groupId}"`);const c=new Error(l);Ft.warn(`[playlist-loader]: ${l}`);let p=qt.UNKNOWN,r=!1;const i=this.getInternalLoader(e);switch(e.type){case ln.MANIFEST:p=u?qt.MANIFEST_LOAD_TIMEOUT:qt.MANIFEST_LOAD_ERROR,r=!0;break;case ln.LEVEL:p=u?qt.LEVEL_LOAD_TIMEOUT:qt.LEVEL_LOAD_ERROR,r=!1;break;case ln.AUDIO_TRACK:p=u?qt.AUDIO_TRACK_LOAD_TIMEOUT:qt.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case ln.SUBTITLE_TRACK:p=u?qt.SUBTITLE_TRACK_LOAD_TIMEOUT:qt.SUBTITLE_LOAD_ERROR,r=!1;break}i&&this.resetInternalLoader(e.type);const t={type:Wi.NETWORK_ERROR,details:p,fatal:r,url:e.url,loader:i,context:e,error:c,networkDetails:s,stats:A};if(y){const n=(s==null?void 0:s.url)||e.url;t.response=Dn({url:n,data:void 0},y)}this.hls.trigger(rt.ERROR,t)}handlePlaylistLoaded(e,s,u,y,A,l){const c=this.hls,{type:p,level:r,id:i,groupId:t,deliveryDirectives:n}=y,a=fc(s,y),o=Mh(y),d=typeof y.level=="number"&&o===Hi.MAIN?r:void 0;if(!e.fragments.length){const m=new Error("No Segments found in Playlist");c.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.LEVEL_EMPTY_ERROR,fatal:!1,url:a,error:m,reason:m.message,response:s,context:y,level:d,parent:o,networkDetails:A,stats:u});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){c.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.LEVEL_PARSING_ERROR,fatal:!1,url:a,error:g,reason:g.message,response:s,context:y,level:d,parent:o,networkDetails:A,stats:u});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),p){case ln.MANIFEST:case ln.LEVEL:c.trigger(rt.LEVEL_LOADED,{details:e,level:d||0,id:i||0,stats:u,networkDetails:A,deliveryDirectives:n});break;case ln.AUDIO_TRACK:c.trigger(rt.AUDIO_TRACK_LOADED,{details:e,id:i||0,groupId:t||"",stats:u,networkDetails:A,deliveryDirectives:n});break;case ln.SUBTITLE_TRACK:c.trigger(rt.SUBTITLE_TRACK_LOADED,{details:e,id:i||0,groupId:t||"",stats:u,networkDetails:A,deliveryDirectives:n});break}}}function Bp(_,e){let s;try{s=new Event("addtrack")}catch{s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=_,e.dispatchEvent(s)}function Np(_,e){const s=_.mode;if(s==="disabled"&&(_.mode="hidden"),_.cues&&!_.cues.getCueById(e.id))try{if(_.addCue(e),!_.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(u){Ft.debug(`[texttrack-utils]: ${u}`);try{const y=new self.TextTrackCue(e.startTime,e.endTime,e.text);y.id=e.id,_.addCue(y)}catch(y){Ft.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${y}`)}}s==="disabled"&&(_.mode=s)}function Zs(_){const e=_.mode;if(e==="disabled"&&(_.mode="hidden"),_.cues)for(let s=_.cues.length;s--;)_.removeCue(_.cues[s]);e==="disabled"&&(_.mode=e)}function Vc(_,e,s,u){const y=_.mode;if(y==="disabled"&&(_.mode="hidden"),_.cues&&_.cues.length>0){const A=j_(_.cues,e,s);for(let l=0;l _[s].endTime)return-1;let u=0,y=s;for(;u<=y;){const A=Math.floor((y+u)/2);if(e<_[A].startTime)y=A-1;else if(e>_[A].startTime&&u -1)for(let A=y,l=_.length;A=e&&c.endTime<=s)u.push(c);else if(c.startTime>s)return u}return u}function po(_){const e=[];for(let s=0;s<_.length;s++){const u=_[s];(u.kind==="subtitles"||u.kind==="captions")&&u.label&&e.push(_[s])}return e}var xr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const V_=.25;function Hc(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ph(_,e,s,u,y){let A=new _(e,s,"");try{A.value=u,y&&(A.type=y)}catch{A=new _(e,s,JSON.stringify(y?Dn({type:y},u):u))}return A}const $a=(()=>{const _=Hc();try{_&&new _(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function pc(_,e){return _.getTime()/1e3-e}function H_(_){return Uint8Array.from(_.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class z_{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(rt.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rt.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(rt.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(rt.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rt.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(rt.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,s){this.media=s.media}onMediaDetaching(){this.id3Track&&(Zs(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const s=this.getID3Track(e.textTracks);return s.mode="hidden",s}getID3Track(e){if(this.media){for(let s=0;s $a&&(t=$a),t-i<=0&&(t=i+V_);for(let a=0;a i.type===xr.audioId3&&p:y==="video"?r=i=>i.type===xr.emsg&&c:r=i=>i.type===xr.audioId3&&p||i.type===xr.emsg&&c,Vc(A,s,u,r)}}onLevelUpdated(e,{details:s}){if(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:u,id3Track:y}=this,{dateRanges:A}=s,l=Object.keys(A);if(y){const i=Object.keys(u).filter(t=>!l.includes(t));for(let t=i.length;t--;){const n=i[t];Object.keys(u[n].cues).forEach(a=>{y.removeCue(u[n].cues[a])}),delete u[n]}}const c=s.fragments[s.fragments.length-1];if(l.length===0||!Ci(c==null?void 0:c.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const p=c.programDateTime/1e3-c.start,r=Hc();for(let i=0;i {if(D!==n.id){const R=A[D];if(R.class===n.class&&R.startDate>n.startDate&&(!C||n.startDate this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:s}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:s?e.liveMaxLatencyDurationCount*s.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:s,partHoldBack:u,targetduration:y}=e,{liveSyncDuration:A,liveSyncDurationCount:l,lowLatencyMode:c}=this.config,p=this.hls.userConfig;let r=c&&u||s;(p.liveSyncDuration||p.liveSyncDurationCount||r===0)&&(r=A!==void 0?A:l*y);const i=y;return r+Math.min(this.stallCount*1,i)}get liveSyncPosition(){const e=this.estimateLiveEdge(),s=this.targetLatency,u=this.levelDetails;if(e===null||s===null||u===null)return null;const y=u.edge,A=e-s-this.edgeStalled,l=y-u.totalduration,c=y-(this.config.lowLatencyMode&&u.partTarget||u.targetduration);return Math.min(Math.max(l,A),c)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const s=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-s,0)}get forwardBufferLength(){const{media:e,levelDetails:s}=this;if(!e||!s)return 0;const u=e.buffered.length;return(u?e.buffered.end(u-1):s.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(rt.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(rt.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(rt.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(rt.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(rt.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(rt.ERROR,this.onError,this)}onMediaAttached(e,s){this.media=s.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:s}){this.levelDetails=s,s.advanced&&this.timeupdate(),!s.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,s){var u;s.details===qt.BUFFER_STALLED_ERROR&&(this.stallCount++,(u=this.levelDetails)!=null&&u.live&&Ft.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:s}=this;if(!e||!s)return;this.currentTime=e.currentTime;const u=this.computeLatency();if(u===null)return;this._latency=u;const{lowLatencyMode:y,maxLiveSyncPlaybackRate:A}=this.config;if(!y||A===1||!s.live)return;const l=this.targetLatency;if(l===null)return;const c=u-l,p=Math.min(this.maxLatency,l+s.targetduration);if(c .05&&this.forwardBufferLength>1){const i=Math.min(2,Math.max(1,A)),t=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;e.playbackRate=Math.min(i,Math.max(1,t))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const zc=["NONE","TYPE-0","TYPE-1",null];function K_(_){return zc.indexOf(_)>-1}const Do=["SDR","PQ","HLG"];function q_(_){return!!_&&Do.indexOf(_)>-1}var Ca={No:"",Yes:"YES",v2:"v2"};function Y_(_,e){const{canSkipUntil:s,canSkipDateRanges:u,endSN:y}=_,A=e!==void 0?e-y:0;return s&&A
!!s).map(s=>s.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Nh(this._audioGroups,e)}hasSubtitleGroup(e){return Nh(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,s){if(s){if(e==="audio"){let u=this._audioGroups;u||(u=this._audioGroups=[]),u.indexOf(s)===-1&&u.push(s)}else if(e==="text"){let u=this._subtitleGroups;u||(u=this._subtitleGroups=[]),u.indexOf(s)===-1&&u.push(s)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Nh(_,e){return!e||!_?!1:_.indexOf(e)!==-1}function mc(_,e){const s=e.startPTS;if(Ci(s)){let u=0,y;e.sn>_.sn?(u=s-_.start,y=_):(u=_.start-s,y=e),y.duration!==u&&(y.duration=u)}else e.sn>_.sn?_.cc===e.cc&&_.minEndPTS?e.start=_.start+(_.minEndPTS-_.start):e.start=_.start+_.duration:e.start=Math.max(_.start-e.duration,0)}function Fp(_,e,s,u,y,A){u-s<=0&&(Ft.warn("Fragment should have a positive duration",e),u=s+e.duration,A=y+e.duration);let c=s,p=u;const r=e.startPTS,i=e.endPTS;if(Ci(r)){const g=Math.abs(r-s);Ci(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,c=Math.max(s,r),s=Math.min(s,r),y=Math.min(y,e.startDTS),p=Math.min(u,i),u=Math.max(u,i),A=Math.max(A,e.endDTS)}const t=s-e.start;e.start!==0&&(e.start=s),e.duration=u-e.start,e.startPTS=s,e.maxStartPTS=c,e.startDTS=y,e.endPTS=u,e.minEndPTS=p,e.endDTS=A;const n=e.sn;if(!_||n<_.startSN||n>_.endSN)return 0;let a;const o=n-_.startSN,d=_.fragments;for(d[o]=e,a=o;a>0;a--)mc(d[a],d[a-1]);for(a=o;a=0;p--){const r=u[p].initSegment;if(r){s=r;break}}_.fragmentHint&&delete _.fragmentHint.endPTS;let y=0,A;if(X_(_,e,(p,r)=>{p.relurl&&(y=p.cc-r.cc),Ci(p.startPTS)&&Ci(p.endPTS)&&(r.start=r.startPTS=p.startPTS,r.startDTS=p.startDTS,r.maxStartPTS=p.maxStartPTS,r.endPTS=p.endPTS,r.endDTS=p.endDTS,r.minEndPTS=p.minEndPTS,r.duration=p.endPTS-p.startPTS,r.duration&&(A=r),e.PTSKnown=e.alignedSliding=!0),r.elementaryStreams=p.elementaryStreams,r.loader=p.loader,r.stats=p.stats,p.initSegment&&(r.initSegment=p.initSegment,s=p.initSegment)}),s&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(r=>{var i;r&&(!r.initSegment||r.initSegment.relurl===((i=s)==null?void 0:i.relurl))&&(r.initSegment=s)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(p=>!p),e.deltaUpdateFailed){Ft.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let p=e.skippedSegments;p--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=Q_(_.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const l=e.fragments;if(y){Ft.warn("discontinuity sliding from playlist, take drift into account");for(let p=0;p {r.elementaryStreams=p.elementaryStreams,r.stats=p.stats}),A?Fp(e,A,A.startPTS,A.endPTS,A.startDTS,A.endDTS):Up(_,e),l.length&&(e.totalduration=e.edge-l[0].start),e.driftStartTime=_.driftStartTime,e.driftStart=_.driftStart;const c=e.advancedDateTime;if(e.advanced&&c){const p=e.edge;e.driftStart||(e.driftStartTime=c,e.driftStart=p),e.driftEndTime=c,e.driftEnd=p}else e.driftEndTime=_.driftEndTime,e.driftEnd=_.driftEnd,e.advancedDateTime=_.advancedDateTime}function Q_(_,e,s){const u=xn({},_);return s&&s.forEach(y=>{delete u[y]}),Object.keys(e).forEach(y=>{const A=new _p(e[y].attr,u[y]);A.isValid?u[y]=A:Ft.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[y].attr)}"`)}),u}function Z_(_,e,s){if(_&&e){let u=0;for(let y=0,A=_.length;y<=A;y++){const l=_[y],c=e[y+u];l&&c&&l.index===c.index&&l.fragment.sn===c.fragment.sn?s(l,c):u--}}}function X_(_,e,s){const u=e.skippedSegments,y=Math.max(_.startSN,e.startSN)-e.startSN,A=(_.fragmentHint?1:0)+(u?e.endSN:Math.min(_.endSN,e.endSN))-e.startSN,l=e.startSN-_.startSN,c=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,p=_.fragmentHint?_.fragments.concat(_.fragmentHint):_.fragments;for(let r=y;r<=A;r++){const i=p[l+r];let t=c[r];u&&!t&&r=u.length||Wc(e,u[s].start)}function Wc(_,e){if(e){const s=_.fragments;for(let u=_.skippedSegments;u e){const A=u[u.length-1].duration*1e3;A {const{details:u}=e;u!=null&&u.fragments&&u.fragments.forEach(y=>{y.level=s})})}function Oo(_){switch(_.details){case qt.FRAG_LOAD_TIMEOUT:case qt.KEY_LOAD_TIMEOUT:case qt.LEVEL_LOAD_TIMEOUT:case qt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Uh(_,e){const s=Oo(e);return _.default[`${s?"timeout":"error"}Retry`]}function wd(_,e){const s=_.backoff==="linear"?1:Math.pow(2,e);return Math.min(s*_.retryDelayMs,_.maxRetryDelayMs)}function Gh(_){return Dn(Dn({},_),{errorRetry:null,timeoutRetry:null})}function Mo(_,e,s,u){if(!_)return!1;const y=u==null?void 0:u.code,A=e<_.maxNumRetry&&(t5(y)||!!s);return _.shouldRetry?_.shouldRetry(_,e,s,u,A):A}function t5(_){return _===0&&navigator.onLine===!1||!!_&&(_<400||_>499)}const Vp={search:function(_,e){let s=0,u=_.length-1,y=null,A=null;for(;s<=u;){y=(s+u)/2|0,A=_[y];const l=e(A);if(l>0)s=y+1;else if(l<0)u=y-1;else return A}return null}};function i5(_,e,s){if(e===null||!Array.isArray(_)||!_.length||!Ci(e))return null;const u=_[0].programDateTime;if(e<(u||0))return null;const y=_[_.length-1].endProgramDateTime;if(e>=(y||0))return null;s=s||0;for(let A=0;A<_.length;++A){const l=_[A];if(n5(e,s,l))return l}return null}function Po(_,e,s=0,u=0){let y=null;if(_){y=e[_.sn-e[0].sn+1]||null;const l=_.endDTS-s;l>0&&l<15e-7&&(s+=15e-7)}else s===0&&e[0].start===0&&(y=e[0]);if(y&&(!_||_.level===y.level)&&Kc(s,u,y)===0)return y;const A=Vp.search(e,Kc.bind(null,s,u));return A&&(A!==_||!y)?A:y}function Kc(_=0,e=0,s){if(s.start<=_&&s.start+s.duration>_)return 0;const u=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-u<=_?1:s.start-u>_&&s.start?-1:0}function n5(_,e,s){const u=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0))*1e3;return(s.endProgramDateTime||0)-u>_}function r5(_,e){return Vp.search(_,s=>s.cce?-1:0)}var Vn={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Tr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class s5{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=Ft.log.bind(Ft,"[info]:"),this.warn=Ft.warn.bind(Ft,"[warning]:"),this.error=Ft.error.bind(Ft,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(rt.ERROR,this.onError,this),e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(rt.ERROR,this.onError,this),e.off(rt.ERROR,this.onErrorOut,this),e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===Hi.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,s){var u,y;if(s.fatal)return;const A=this.hls,l=s.context;switch(s.details){case qt.FRAG_LOAD_ERROR:case qt.FRAG_LOAD_TIMEOUT:case qt.KEY_LOAD_ERROR:case qt.KEY_LOAD_TIMEOUT:s.errorAction=this.getFragRetryOrSwitchAction(s);return;case qt.FRAG_PARSING_ERROR:if((u=s.frag)!=null&&u.gap){s.errorAction={action:Vn.DoNothing,flags:Tr.None};return}case qt.FRAG_GAP:case qt.FRAG_DECRYPT_ERROR:{s.errorAction=this.getFragRetryOrSwitchAction(s),s.errorAction.action=Vn.SendAlternateToPenaltyBox;return}case qt.LEVEL_EMPTY_ERROR:case qt.LEVEL_PARSING_ERROR:{var c,p;const r=s.parent===Hi.MAIN?s.level:A.loadLevel;s.details===qt.LEVEL_EMPTY_ERROR&&((c=s.context)!=null&&(p=c.levelDetails)!=null&&p.live)?s.errorAction=this.getPlaylistRetryOrSwitchAction(s,r):(s.levelRetry=!1,s.errorAction=this.getLevelSwitchAction(s,r))}return;case qt.LEVEL_LOAD_ERROR:case qt.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(s.errorAction=this.getPlaylistRetryOrSwitchAction(s,l.level));return;case qt.AUDIO_TRACK_LOAD_ERROR:case qt.AUDIO_TRACK_LOAD_TIMEOUT:case qt.SUBTITLE_LOAD_ERROR:case qt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const r=A.levels[A.loadLevel];if(r&&(l.type===ln.AUDIO_TRACK&&r.hasAudioGroup(l.groupId)||l.type===ln.SUBTITLE_TRACK&&r.hasSubtitleGroup(l.groupId))){s.errorAction=this.getPlaylistRetryOrSwitchAction(s,A.loadLevel),s.errorAction.action=Vn.SendAlternateToPenaltyBox,s.errorAction.flags=Tr.MoveAllAlternatesMatchingHost;return}}return;case qt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const r=A.levels[A.loadLevel],i=r==null?void 0:r.attrs["HDCP-LEVEL"];i?s.errorAction={action:Vn.SendAlternateToPenaltyBox,flags:Tr.MoveAllAlternatesMatchingHDCP,hdcpLevel:i}:this.keySystemError(s)}return;case qt.BUFFER_ADD_CODEC_ERROR:case qt.REMUX_ALLOC_ERROR:case qt.BUFFER_APPEND_ERROR:s.errorAction=this.getLevelSwitchAction(s,(y=s.level)!=null?y:A.loadLevel);return;case qt.INTERNAL_EXCEPTION:case qt.BUFFER_APPENDING_ERROR:case qt.BUFFER_FULL_ERROR:case qt.LEVEL_SWITCH_ERROR:case qt.BUFFER_STALLED_ERROR:case qt.BUFFER_SEEK_OVER_HOLE:case qt.BUFFER_NUDGE_ON_STALL:s.errorAction={action:Vn.DoNothing,flags:Tr.None};return}s.type===Wi.KEY_SYSTEM_ERROR&&this.keySystemError(s)}keySystemError(e){const s=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,s)}getPlaylistRetryOrSwitchAction(e,s){const u=this.hls,y=Uh(u.config.playlistLoadPolicy,e),A=this.playlistError++;if(Mo(y,A,Oo(e),e.response))return{action:Vn.RetryRequest,flags:Tr.None,retryConfig:y,retryCount:A};const c=this.getLevelSwitchAction(e,s);return y&&(c.retryConfig=y,c.retryCount=A),c}getFragRetryOrSwitchAction(e){const s=this.hls,u=this.getVariantLevelIndex(e.frag),y=s.levels[u],{fragLoadPolicy:A,keyLoadPolicy:l}=s.config,c=Uh(e.details.startsWith("key")?l:A,e),p=s.levels.reduce((i,t)=>i+t.fragmentError,0);if(y&&(e.details!==qt.FRAG_GAP&&y.fragmentError++,Mo(c,p,Oo(e),e.response)))return{action:Vn.RetryRequest,flags:Tr.None,retryConfig:c,retryCount:p};const r=this.getLevelSwitchAction(e,u);return c&&(r.retryConfig=c,r.retryCount=p),r}getLevelSwitchAction(e,s){const u=this.hls;s==null&&(s=u.loadLevel);const y=this.hls.levels[s];if(y){var A,l;const r=e.details;y.loadError++,r===qt.BUFFER_APPEND_ERROR&&y.fragmentError++;let i=-1;const{levels:t,loadLevel:n,minAutoLevel:a,maxAutoLevel:o}=u;u.autoLevelEnabled||(u.loadLevel=-1);const d=(A=e.frag)==null?void 0:A.type,m=(d===Hi.AUDIO&&r===qt.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(r===qt.BUFFER_ADD_CODEC_ERROR||r===qt.BUFFER_APPEND_ERROR))&&t.some(({audioCodec:D})=>y.audioCodec!==D),b=e.sourceBufferName==="video"&&(r===qt.BUFFER_ADD_CODEC_ERROR||r===qt.BUFFER_APPEND_ERROR)&&t.some(({codecSet:D,audioCodec:R})=>y.codecSet!==D&&y.audioCodec===R),{type:w,groupId:C}=(l=e.context)!=null?l:{};for(let D=t.length;D--;){const R=(D+n)%t.length;if(R!==n&&R>=a&&R<=o&&t[R].loadError===0){var c,p;const T=t[R];if(r===qt.FRAG_GAP&&e.frag){const P=t[R].details;if(P){const L=Po(e.frag,P.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(w===ln.AUDIO_TRACK&&T.hasAudioGroup(C)||w===ln.SUBTITLE_TRACK&&T.hasSubtitleGroup(C))continue;if(d===Hi.AUDIO&&(c=y.audioGroups)!=null&&c.some(P=>T.hasAudioGroup(P))||d===Hi.SUBTITLE&&(p=y.subtitleGroups)!=null&&p.some(P=>T.hasSubtitleGroup(P))||m&&y.audioCodec===T.audioCodec||!m&&y.audioCodec!==T.audioCodec||b&&y.codecSet===T.codecSet)continue}i=R;break}}if(i>-1&&u.loadLevel!==i)return e.levelRetry=!0,this.playlistError=0,{action:Vn.SendAlternateToPenaltyBox,flags:Tr.None,nextAutoLevel:i}}return{action:Vn.SendAlternateToPenaltyBox,flags:Tr.MoveAllAlternatesMatchingHost}}onErrorOut(e,s){var u;switch((u=s.errorAction)==null?void 0:u.action){case Vn.DoNothing:break;case Vn.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(s),!s.errorAction.resolved&&s.details!==qt.FRAG_GAP?s.fatal=!0:/MediaSource readyState: ended/.test(s.error.message)&&(this.warn(`MediaSource ended after "${s.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(s.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const s=this.hls,u=e.errorAction;if(!u)return;const{flags:y,hdcpLevel:A,nextAutoLevel:l}=u;switch(y){case Tr.None:this.switchLevel(e,l);break;case Tr.MoveAllAlternatesMatchingHDCP:A&&(s.maxHdcpLevel=zc[zc.indexOf(A)-1],u.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${s.maxHdcpLevel}" or lower`);break}u.resolved||this.switchLevel(e,l)}switchLevel(e,s){s!==void 0&&e.errorAction&&(this.warn(`switching to level ${s} after ${e.details}`),this.hls.nextAutoLevel=s,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class Sd{constructor(e,s){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Ft.log.bind(Ft,`${s}:`),this.warn=Ft.warn.bind(Ft,`${s}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,s){const u=s==null?void 0:s.renditionReports;if(u){let y=-1;for(let A=0;A =0&&p>s.partTarget&&(c+=1)}return new Bh(l,c>=0?c:void 0,Ca.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,s,u){const{details:y,stats:A}=s,l=self.performance.now(),c=A.loading.first?Math.max(0,l-A.loading.first):0;if(y.advancedDateTime=Date.now()-c,y.live||u!=null&&u.live){if(y.reloaded(u),u&&this.log(`live playlist ${e} ${y.advanced?"REFRESHED "+y.lastPartSn+"-"+y.lastPartIndex:y.updated?"UPDATED":"MISSED"}`),u&&y.fragments.length>0&&J_(u,y),!this.canLoad||!y.live)return;let p,r,i;if(y.canBlockReload&&y.endSN&&y.advanced){const g=this.hls.config.lowLatencyMode,m=y.lastPartSn,v=y.endSN,b=y.lastPartIndex,w=b!==-1,C=m===v,D=g?0:b;w?(r=C?v+1:m,i=C?D:b+1):r=v+1;const R=y.age,T=R+y.ageHeader;let P=Math.min(T-y.partTarget,y.targetduration*1.5);if(P>0){if(u&&P>u.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${u.tuneInGoal} to: ${P} with playlist age: ${y.age}`),P=0;else{const L=Math.floor(P/y.targetduration);if(r+=L,i!==void 0){const I=Math.round(P%y.targetduration/y.partTarget);i+=I}this.log(`CDN Tune-in age: ${y.ageHeader}s last advanced ${R.toFixed(2)}s goal: ${P} skip sn ${L} to part ${i}`)}y.tuneInGoal=P}if(p=this.getDeliveryDirectives(y,s.deliveryDirectives,r,i),g||!C){this.loadPlaylist(p);return}}else(y.canBlockReload||y.canSkipUntil)&&(p=this.getDeliveryDirectives(y,s.deliveryDirectives,r,i));const t=this.hls.mainForwardBufferInfo,n=t?t.end-t.len:0,a=(y.edge-n)*1e3,o=$_(y,a);y.updated&&l>this.requestScheduled+o&&(this.requestScheduled=A.loading.start),r!==void 0&&y.canBlockReload?this.requestScheduled=A.loading.first+o-(y.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+o this.loadPlaylist(p),d)}else this.clearTimer()}getDeliveryDirectives(e,s,u,y){let A=Y_(e,u);return s!=null&&s.skip&&e.deltaUpdateFailed&&(u=s.msn,y=s.part,A=Ca.No),new Bh(u,y,A)}checkRetry(e){const s=e.details,u=Oo(e),y=e.errorAction,{action:A,retryCount:l=0,retryConfig:c}=y||{},p=!!y&&!!c&&(A===Vn.RetryRequest||!y.resolved&&A===Vn.SendAlternateToPenaltyBox);if(p){var r;if(this.requestScheduled=-1,l>=c.maxNumRetry)return!1;if(u&&(r=e.context)!=null&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${c.maxNumRetry} after "${s}" without delivery-directives`),this.loadPlaylist();else{const i=wd(c,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),i),this.warn(`Retrying playlist loading ${l+1}/${c.maxNumRetry} after "${s}" in ${i}ms`)}e.levelRetry=!0,y.resolved=!0}return p}}class js{constructor(e,s=0,u=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=s,this.totalWeight_=u}sample(e,s){const u=Math.pow(this.alpha_,e);this.estimate_=s*(1-u)+u*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class a5{constructor(e,s,u,y=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=u,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new js(e),this.fast_=new js(s),this.defaultTTFB_=y,this.ttfb_=new js(e)}update(e,s){const{slow_:u,fast_:y,ttfb_:A}=this;u.halfLife!==e&&(this.slow_=new js(e,u.getEstimate(),u.getTotalWeight())),y.halfLife!==s&&(this.fast_=new js(s,y.getEstimate(),y.getTotalWeight())),A.halfLife!==e&&(this.ttfb_=new js(e,A.getEstimate(),A.getTotalWeight()))}sample(e,s){e=Math.max(e,this.minDelayMs_);const u=8*s,y=e/1e3,A=u/y;this.fast_.sample(y,A),this.slow_.sample(y,A)}sampleTTFB(e){const s=e/1e3,u=Math.sqrt(2)*Math.exp(-Math.pow(s,2)/2);this.ttfb_.sample(u,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const Hp={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},jh={};function o5(_,e,s,u,y,A){const l=_.audioCodec?_.audioGroups:null,c=A==null?void 0:A.audioCodec,p=A==null?void 0:A.channels,r=p?parseInt(p):c?1/0:2;let i=null;if(l!=null&&l.length)try{l.length===1&&l[0]?i=e.groups[l[0]].channels:i=l.reduce((t,n)=>{if(n){const a=e.groups[n];if(!a)throw new Error(`Audio track group ${n} not found`);Object.keys(a.channels).forEach(o=>{t[o]=(t[o]||0)+a.channels[o]})}return t},{2:0})}catch{return!0}return _.videoCodec!==void 0&&(_.width>1920&&_.height>1088||_.height>1920&&_.width>1088||_.frameRate>Math.max(u,30)||_.videoRange!=="SDR"&&_.videoRange!==s||_.bitrate>Math.max(y,8e6))||!!i&&Ci(r)&&Object.keys(i).some(t=>parseInt(t)>r)}function l5(_,e,s){const u=_.videoCodec,y=_.audioCodec;if(!u||!y||!s)return Promise.resolve(Hp);const A={width:_.width,height:_.height,bitrate:Math.ceil(Math.max(_.bitrate*.9,_.averageBitrate)),framerate:_.frameRate||30},l=_.videoRange;l!=="SDR"&&(A.transferFunction=l.toLowerCase());const c=u.split(",").map(p=>({type:"media-source",video:Dn(Dn({},A),{},{contentType:La(p,"video")})}));return y&&_.audioGroups&&_.audioGroups.forEach(p=>{var r;p&&((r=e.groups[p])==null||r.tracks.forEach(i=>{if(i.groupId===p){const t=i.channels||"",n=parseFloat(t);Ci(n)&&n>2&&c.push.apply(c,y.split(",").map(a=>({type:"media-source",audio:{contentType:La(a,"audio"),channels:""+n}})))}}))}),Promise.all(c.map(p=>{const r=c5(p);return jh[r]||(jh[r]=s.decodingInfo(p))})).then(p=>({supported:!p.some(r=>!r.supported),configurations:c,decodingInfoResults:p})).catch(p=>({supported:!1,configurations:c,decodingInfoResults:[],error:p}))}function c5(_){const{audio:e,video:s}=_,u=s||e;if(u){const y=u.contentType.split('"')[1];if(s)return`r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction||"sd"}_${y}_${Math.ceil(s.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${y}`}return""}function d5(){if(typeof matchMedia=="function"){const _=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(_.media!==e.media)return _.matches===!0}return!1}function u5(_,e){let s=!1,u=[];return _&&(s=_!=="SDR",u=[_]),e&&(u=e.allowedVideoRanges||Do.slice(0),s=e.preferHDR!==void 0?e.preferHDR:d5(),s?u=u.filter(y=>y!=="SDR"):u=["SDR"]),{preferHDR:s,allowedVideoRanges:u}}function h5(_,e,s,u,y){const A=Object.keys(_),l=u==null?void 0:u.channels,c=u==null?void 0:u.audioCodec,p=l&&parseInt(l)===2;let r=!0,i=!1,t=1/0,n=1/0,a=1/0,o=0,d=[];const{preferHDR:g,allowedVideoRanges:m}=u5(e,y);for(let C=A.length;C--;){const D=_[A[C]];r=D.channels[2]>0,t=Math.min(t,D.minHeight),n=Math.min(n,D.minFramerate),a=Math.min(a,D.minBitrate);const R=m.filter(T=>D.videoRanges[T]>0);R.length>0&&(i=!0,d=R)}t=Ci(t)?t:0,n=Ci(n)?n:0;const v=Math.max(1080,t),b=Math.max(30,n);return a=Ci(a)?a:s,s=Math.max(a,s),i||(e=void 0,d=[]),{codecSet:A.reduce((C,D)=>{const R=_[D];if(D===C)return C;if(R.minBitrate>s)return Yr(D,`min bitrate of ${R.minBitrate} > current estimate of ${s}`),C;if(!R.hasDefaultAudio)return Yr(D,"no renditions with default or auto-select sound found"),C;if(c&&D.indexOf(c.substring(0,4))%5!==0)return Yr(D,`audio codec preference "${c}" not found`),C;if(l&&!p){if(!R.channels[l])return Yr(D,`no renditions with ${l} channel sound found (channels options: ${Object.keys(R.channels)})`),C}else if((!c||p)&&r&&R.channels[2]===0)return Yr(D,"no renditions with stereo sound found"),C;return R.minHeight>v?(Yr(D,`min resolution of ${R.minHeight} > maximum of ${v}`),C):R.minFramerate>b?(Yr(D,`min framerate of ${R.minFramerate} > maximum of ${b}`),C):d.some(T=>R.videoRanges[T]>0)?R.maxScore =Io(C)||R.fragmentError>_[C].fragmentError)?C:(o=R.maxScore,D):(Yr(D,`no variants with VIDEO-RANGE of ${JSON.stringify(d)} found`),C)},void 0),videoRanges:d,preferHDR:g,minFramerate:n,minBitrate:a}}function Yr(_,e){Ft.log(`[abr] start candidates with "${_}" ignored because ${e}`)}function f5(_){return _.reduce((e,s)=>{let u=e.groups[s.groupId];u||(u=e.groups[s.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),u.tracks.push(s);const y=s.channels||"2";return u.channels[y]=(u.channels[y]||0)+1,u.hasDefault=u.hasDefault||s.default,u.hasAutoSelect=u.hasAutoSelect||s.autoselect,u.hasDefault&&(e.hasDefaultAudio=!0),u.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function p5(_,e,s,u){return _.slice(s,u+1).reduce((y,A)=>{if(!A.codecSet)return y;const l=A.audioGroups;let c=y[A.codecSet];c||(y[A.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!l,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,A.bitrate);const p=Math.min(A.height,A.width);return c.minHeight=Math.min(c.minHeight,p),c.minFramerate=Math.min(c.minFramerate,A.frameRate),c.maxScore=Math.max(c.maxScore,A.score),c.fragmentError+=A.fragmentError,c.videoRanges[A.videoRange]=(c.videoRanges[A.videoRange]||0)+1,l&&l.forEach(r=>{if(!r)return;const i=e.groups[r];c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach(t=>{c.channels[t]=(c.channels[t]||0)+i.channels[t]})}),y},{})}function jr(_,e,s){if("attrs"in _){const u=e.indexOf(_);if(u!==-1)return u}for(let u=0;u u.indexOf(y)===-1)}function Vs(_,e){const{audioCodec:s,channels:u}=_;return(s===void 0||(e.audioCodec||"").substring(0,4)===s.substring(0,4))&&(u===void 0||u===(e.channels||"2"))}function g5(_,e,s,u,y){const A=e[u],c=e.reduce((n,a,o)=>{const d=a.uri;return(n[d]||(n[d]=[])).push(o),n},{})[A.uri];c.length>1&&(u=Math.max.apply(Math,c));const p=A.videoRange,r=A.frameRate,i=A.codecSet.substring(0,4),t=Vh(e,u,n=>{if(n.videoRange!==p||n.frameRate!==r||n.codecSet.substring(0,4)!==i)return!1;const a=n.audioGroups,o=s.filter(d=>!a||a.indexOf(d.groupId)!==-1);return jr(_,o,y)>-1});return t>-1?t:Vh(e,u,n=>{const a=n.audioGroups,o=s.filter(d=>!a||a.indexOf(d.groupId)!==-1);return jr(_,o,y)>-1})}function Vh(_,e,s){for(let u=e;u;u--)if(s(_[u]))return u;for(let u=e+1;u<_.length;u++)if(s(_[u]))return u;return-1}class A5{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:s,partCurrent:u,hls:y}=this,{autoLevelEnabled:A,media:l}=y;if(!s||!l)return;const c=performance.now(),p=u?u.stats:s.stats,r=u?u.duration:s.duration,i=c-p.loading.start,t=y.minAutoLevel;if(p.aborted||p.loaded&&p.loaded===p.total||s.level<=t){this.clearTimer(),this._nextAutoLevel=-1;return}if(!A||l.paused||!l.playbackRate||!l.readyState)return;const n=y.mainForwardBufferInfo;if(n===null)return;const a=this.bwEstimator.getEstimateTTFB(),o=Math.abs(l.playbackRate);if(i<=Math.max(a,1e3*(r/(o*2))))return;const d=n.len/o,g=p.loading.first?p.loading.first-p.loading.start:-1,m=p.loaded&&g>-1,v=this.getBwEstimate(),b=y.levels,w=b[s.level],C=p.total||Math.max(p.loaded,Math.round(r*w.maxBitrate/8));let D=m?i-g:i;D<1&&m&&(D=Math.min(i,p.loaded*8/v));const R=m?p.loaded*1e3/D:0,T=R?(C-p.loaded)/R:C*8/v+a/1e3;if(T<=d)return;const P=R?R*8:v;let L=Number.POSITIVE_INFINITY,I;for(I=s.level-1;I>t;I--){const O=b[I].maxBitrate;if(L=this.getTimeToLoadFrag(a/1e3,P,r*O,!b[I].details),L =T||L>r*10)return;y.nextLoadLevel=y.nextAutoLevel=I,m?this.bwEstimator.sample(i-Math.min(a,g),p.loaded):this.bwEstimator.sampleTTFB(i);const x=b[I].bitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>x&&this.resetEstimator(x),this.clearTimer(),Ft.warn(`[abr] Fragment ${s.sn}${u?" part "+u.index:""} of level ${s.level} is loading too slowly; +`,"color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");const is=Ls})(),y=y.default})())})(vp);var Nb=vp.exports;const Fb=sd(Nb);function Ub(_){return _&&_.__esModule&&Object.prototype.hasOwnProperty.call(_,"default")?_.default:_}var bp={exports:{}};(function(_,e){(function(s){var u=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,A=/^(?=([^\/?#]*))\1([^]*)$/,y=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,c={buildAbsoluteURL:function(p,r,i){if(i=i||{},p=p.trim(),r=r.trim(),!r){if(!i.alwaysNormalize)return p;var t=c.parseURL(p);if(!t)throw new Error("Error trying to parse base URL.");return t.path=c.normalizePath(t.path),c.buildURLFromParts(t)}var n=c.parseURL(r);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return i.alwaysNormalize?(n.path=c.normalizePath(n.path),c.buildURLFromParts(n)):r;var a=c.parseURL(p);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&a.path[0]!=="/"){var o=A.exec(a.path);a.netLoc=o[1],a.path=o[2]}a.netLoc&&!a.path&&(a.path="/");var d={scheme:a.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(d.netLoc=a.netLoc,n.path[0]!=="/"))if(!n.path)d.path=a.path,n.params||(d.params=a.params,n.query||(d.query=a.query));else{var g=a.path,m=g.substring(0,g.lastIndexOf("/")+1)+n.path;d.path=c.normalizePath(m)}return d.path===null&&(d.path=i.alwaysNormalize?c.normalizePath(n.path):n.path),c.buildURLFromParts(d)},parseURL:function(p){var r=u.exec(p);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(y,"");p.length!==(p=p.replace(l,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}};_.exports=c})()})(bp);var yd=bp.exports;function gh(_,e){var s=Object.keys(_);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(_);e&&(u=u.filter(function(A){return Object.getOwnPropertyDescriptor(_,A).enumerable})),s.push.apply(s,u)}return s}function Dn(_){for(var e=1;e `):vs}function Kb(_,...e){e.forEach(function(s){Ta[s]=_[s]?_[s].bind(_):Wb(s)})}function qb(_,e){if(typeof console=="object"&&_===!0||typeof _=="object"){Kb(_,"debug","log","info","warn","error");try{Ta.log(`Debug logs enabled for "${e}" in hls.js version 1.5.1-patch.1`)}catch{Ta=Uc}}else Ta=Uc}const Ft=Ta,Yb=/^(\d+)x(\d+)$/,Ah=/(.+?)=(".*?"|.*?)(?:,|$)/g;class bn{constructor(e){typeof e=="string"&&(e=bn.parseAttrList(e)),xn(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const s=parseInt(this[e],10);return s>Number.MAX_SAFE_INTEGER?1/0:s}hexadecimalInteger(e){if(this[e]){let s=(this[e]||"0x").slice(2);s=(s.length&1?"0":"")+s;const u=new Uint8Array(s.length/2);for(let A=0;A Number.MAX_SAFE_INTEGER?1/0:s}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,s){const u=this[e];return u?parseFloat(u):s}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const s=Yb.exec(this[e]);if(s!==null)return{width:parseInt(s[1],10),height:parseInt(s[2],10)}}static parseAttrList(e){let s;const u={},A='"';for(Ah.lastIndex=0;(s=Ah.exec(e))!==null;){let y=s[2];y.indexOf(A)===0&&y.lastIndexOf(A)===y.length-1&&(y=y.slice(1,-1));const l=s[1].trim();u[l]=y}return u}}function Jb(_){return _!=="ID"&&_!=="CLASS"&&_!=="START-DATE"&&_!=="DURATION"&&_!=="END-DATE"&&_!=="END-ON-NEXT"}function Qb(_){return _==="SCTE35-OUT"||_==="SCTE35-IN"}class _p{constructor(e,s){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,s){const u=s.attr;for(const A in u)if(Object.prototype.hasOwnProperty.call(e,A)&&e[A]!==u[A]){Ft.warn(`DATERANGE tag attribute: "${A}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=A;break}e=xn(new bn({}),u,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const u=new Date(this.attr["END-DATE"]);Ci(u.getTime())&&(this._endDate=u)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Ci(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Ci(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Zo{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var fn={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Ep{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[fn.AUDIO]:null,[fn.VIDEO]:null,[fn.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,s){const u=e.split("@",2);let A;u.length===1?A=(s==null?void 0:s.byteRangeEndOffset)||0:A=parseInt(u[1]),this._byteRange=[A,parseInt(u[0])+A]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=yd.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class ac extends Ep{constructor(e,s){super(s),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Zo,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const s=this.levelkeys.identity;if(s)this._decryptdata=s.getDecryptData(this.sn);else{const u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Ci(this.programDateTime))return null;const e=Ci(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const s=Object.keys(this.levelkeys),u=s.length;if(u>1||u===1&&this.levelkeys[s[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const s=this.levelkeys[e];s&&!this._decryptdata&&(this._decryptdata=s.getDecryptData(this.sn))}}abortRequests(){var e,s;(e=this.loader)==null||e.abort(),(s=this.keyLoader)==null||s.abort()}setElementaryStreamInfo(e,s,u,A,y,l=!1){const{elementaryStreams:c}=this,p=c[e];if(!p){c[e]={startPTS:s,endPTS:u,startDTS:A,endDTS:y,partial:l};return}p.startPTS=Math.min(p.startPTS,s),p.endPTS=Math.max(p.endPTS,u),p.startDTS=Math.min(p.startDTS,A),p.endDTS=Math.max(p.endDTS,y)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[fn.AUDIO]=null,e[fn.VIDEO]=null,e[fn.AUDIOVIDEO]=null}}class Zb extends Ep{constructor(e,s,u,A,y){super(u),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Zo,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=s,this.index=A;const l=e.enumeratedString("BYTERANGE");l&&this.setByteRange(l,y),y&&(this.fragOffset=y.fragOffset+y.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const Xb=10;class $b{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const s=this.lastPartSn-e.lastPartSn,u=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!u||!!s||!this.live,this.advanced=this.endSN>e.endSN||s>0||s===0&&u>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Ci(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Xb}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function vd(_){return Uint8Array.from(atob(_),e=>e.charCodeAt(0))}function e_(_){const e=Gc(_).subarray(0,16),s=new Uint8Array(16);return s.set(e,16-e.length),s}function t_(_){const e=function(u,A,y){const l=u[A];u[A]=u[y],u[y]=l};e(_,0,3),e(_,1,2),e(_,4,5),e(_,6,7)}function i_(_){const e=_.split(":");let s=null;if(e[0]==="data"&&e.length===2){const u=e[1].split(";"),A=u[u.length-1].split(",");if(A.length===2){const y=A[0]==="base64",l=A[1];y?(u.splice(-1,1),s=vd(l)):s=e_(l)}}return s}function Gc(_){return Uint8Array.from(unescape(encodeURIComponent(_)),e=>e.charCodeAt(0))}const oa=typeof self<"u"?self:void 0;var vn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function yh(_){switch(_){case Zn.FAIRPLAY:return vn.FAIRPLAY;case Zn.PLAYREADY:return vn.PLAYREADY;case Zn.WIDEVINE:return vn.WIDEVINE;case Zn.CLEARKEY:return vn.CLEARKEY}}var wp={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function n_(_){if(_===wp.WIDEVINE)return vn.WIDEVINE}function vh(_){switch(_){case vn.FAIRPLAY:return Zn.FAIRPLAY;case vn.PLAYREADY:return Zn.PLAYREADY;case vn.WIDEVINE:return Zn.WIDEVINE;case vn.CLEARKEY:return Zn.CLEARKEY}}function oc(_){const{drmSystems:e,widevineLicenseUrl:s}=_,u=e?[vn.FAIRPLAY,vn.WIDEVINE,vn.PLAYREADY,vn.CLEARKEY].filter(A=>!!e[A]):[];return!u[vn.WIDEVINE]&&s&&u.push(vn.WIDEVINE),u}const Sp=function(_){return oa!=null&&(_=oa.navigator)!=null&&_.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function r_(_,e,s,u){let A;switch(_){case vn.FAIRPLAY:A=["cenc","sinf"];break;case vn.WIDEVINE:case vn.PLAYREADY:A=["cenc"];break;case vn.CLEARKEY:A=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${_}`)}return s_(A,e,s,u)}function s_(_,e,s,u){return[{initDataTypes:_,persistentState:u.persistentState||"optional",distinctiveIdentifier:u.distinctiveIdentifier||"optional",sessionTypes:u.sessionTypes||[u.sessionType||"temporary"],audioCapabilities:e.map(y=>({contentType:`audio/mp4; codecs="${y}"`,robustness:u.audioRobustness||"",encryptionScheme:u.audioEncryptionScheme||null})),videoCapabilities:s.map(y=>({contentType:`video/mp4; codecs="${y}"`,robustness:u.videoRobustness||"",encryptionScheme:u.videoEncryptionScheme||null}))}]}function Ts(_,e,s){return Uint8Array.prototype.slice?_.slice(e,s):new Uint8Array(Array.prototype.slice.call(_,e,s))}const bd=(_,e)=>e+10<=_.length&&_[e]===73&&_[e+1]===68&&_[e+2]===51&&_[e+3]<255&&_[e+4]<255&&_[e+6]<128&&_[e+7]<128&&_[e+8]<128&&_[e+9]<128,Tp=(_,e)=>e+10<=_.length&&_[e]===51&&_[e+1]===68&&_[e+2]===73&&_[e+3]<255&&_[e+4]<255&&_[e+6]<128&&_[e+7]<128&&_[e+8]<128&&_[e+9]<128,Ra=(_,e)=>{const s=e;let u=0;for(;bd(_,e);){u+=10;const A=Xo(_,e+6);u+=A,Tp(_,e+10)&&(u+=10),e+=u}if(u>0)return _.subarray(s,s+u)},Xo=(_,e)=>{let s=0;return s=(_[e]&127)<<21,s|=(_[e+1]&127)<<14,s|=(_[e+2]&127)<<7,s|=_[e+3]&127,s},a_=(_,e)=>bd(_,e)&&Xo(_,e+6)+10<=_.length-e,_d=_=>{const e=xp(_);for(let s=0;s _&&_.key==="PRIV"&&_.info==="com.apple.streaming.transportStreamTimestamp",o_=_=>{const e=String.fromCharCode(_[0],_[1],_[2],_[3]),s=Xo(_,4),u=10;return{type:e,size:s,data:_.subarray(u,u+s)}},xp=_=>{let e=0;const s=[];for(;bd(_,e);){const u=Xo(_,e+6);e+=10;const A=e+u;for(;e+8_.type==="PRIV"?c_(_):_.type[0]==="W"?u_(_):d_(_),c_=_=>{if(_.size<2)return;const e=Vr(_.data,!0),s=new Uint8Array(_.data.subarray(e.length+1));return{key:_.type,info:e,data:s.buffer}},d_=_=>{if(_.size<2)return;if(_.type==="TXXX"){let s=1;const u=Vr(_.data.subarray(s),!0);s+=u.length+1;const A=Vr(_.data.subarray(s));return{key:_.type,info:u,data:A}}const e=Vr(_.data.subarray(1));return{key:_.type,data:e}},u_=_=>{if(_.type==="WXXX"){if(_.size<2)return;let s=1;const u=Vr(_.data.subarray(s),!0);s+=u.length+1;const A=Vr(_.data.subarray(s));return{key:_.type,info:u,data:A}}const e=Vr(_.data);return{key:_.type,data:e}},h_=_=>{if(_.data.byteLength===8){const e=new Uint8Array(_.data),s=e[3]&1;let u=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return u/=45,s&&(u+=4772185884e-2),Math.round(u)}},Vr=(_,e=!1)=>{const s=f_();if(s){const r=s.decode(_);if(e){const i=r.indexOf("\0");return i!==-1?r.substring(0,i):r}return r.replace(/\0/g,"")}const u=_.length;let A,y,l,c="",p=0;for(;p>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(A);break;case 12:case 13:y=_[p++],c+=String.fromCharCode((A&31)<<6|y&63);break;case 14:y=_[p++],l=_[p++],c+=String.fromCharCode((A&15)<<12|(y&63)<<6|(l&63)<<0);break}}return c};let lc;function f_(){if(!navigator.userAgent.includes("PlayStation 4"))return!lc&&typeof self.TextDecoder<"u"&&(lc=new self.TextDecoder("utf-8")),lc}const Fr={hexDump:function(_){let e="";for(let s=0;s<_.length;s++){let u=_[s].toString(16);u.length<2&&(u="0"+u),e+=u}return e}},ko=Math.pow(2,32)-1,p_=[].push,kp={video:1,audio:2,id3:3,text:4};function In(_){return String.fromCharCode.apply(null,_)}function Rp(_,e){const s=_[e]<<8|_[e+1];return s<0?65536+s:s}function Ki(_,e){const s=Ip(_,e);return s<0?4294967296+s:s}function Ip(_,e){return _[e]<<24|_[e+1]<<16|_[e+2]<<8|_[e+3]}function cc(_,e,s){_[e]=s>>24,_[e+1]=s>>16&255,_[e+2]=s>>8&255,_[e+3]=s&255}function m_(_){const e=_.byteLength;for(let s=0;s 8&&_[s+4]===109&&_[s+5]===111&&_[s+6]===111&&_[s+7]===102)return!0;s=u>1?s+u:e}return!1}function Zi(_,e){const s=[];if(!e.length)return s;const u=_.byteLength;for(let A=0;A1?A+y:u;if(l===e[0])if(e.length===1)s.push(_.subarray(A+8,c));else{const p=Zi(_.subarray(A+8,c),e.slice(1));p.length&&p_.apply(s,p)}A=c}return s}function g_(_){const e=[],s=_[0];let u=8;const A=Ki(_,u);u+=4;const y=0,l=0;s===0?u+=8:u+=16,u+=2;let c=_.length+l;const p=Rp(_,u);u+=2;for(let r=0;r >>31===1)return Ft.warn("SIDX has hierarchical references (not supported)"),null;const o=Ki(_,i);i+=4,e.push({referenceSize:n,subsegmentDuration:o,info:{duration:o/A,start:c,end:c+n-1}}),c+=n,i+=4,u=i}return{earliestPresentationTime:y,timescale:A,version:s,referencesCount:p,references:e}}function Lp(_){const e=[],s=Zi(_,["moov","trak"]);for(let A=0;A
{const y=Ki(A,4),l=e[y];l&&(l.default={duration:Ki(A,12),flags:Ki(A,20)})}),e}function A_(_){const e=_.subarray(8),s=e.subarray(86),u=In(e.subarray(4,8));let A=u;const y=u==="enca"||u==="encv";if(y){const c=Zi(e,[u])[0].subarray(u==="enca"?28:78);Zi(c,["sinf"]).forEach(r=>{const i=Zi(r,["schm"])[0];if(i){const t=In(i.subarray(4,8));if(t==="cbcs"||t==="cenc"){const n=Zi(r,["frma"])[0];n&&(A=In(n))}}})}switch(A){case"avc1":case"avc2":case"avc3":case"avc4":{const l=Zi(s,["avcC"])[0];A+="."+Za(l[1])+Za(l[2])+Za(l[3]);break}case"mp4a":{const l=Zi(e,[u])[0],c=Zi(l.subarray(28),["esds"])[0];if(c&&c.length>12){let p=4;if(c[p++]!==3)break;p=dc(c,p),p+=2;const r=c[p++];if(r&128&&(p+=2),r&64&&(p+=c[p++]),c[p++]!==4)break;p=dc(c,p);const i=c[p++];if(i===64)A+="."+Za(i);else break;if(p+=12,c[p++]!==5)break;p=dc(c,p);const t=c[p++];let n=(t&248)>>3;n===31&&(n+=1+((t&7)<<3)+((c[p]&224)>>5)),A+="."+n}break}case"hvc1":case"hev1":{const l=Zi(s,["hvcC"])[0],c=l[1],p=["","A","B","C"][c>>6],r=c&31,i=Ki(l,2),t=(c&32)>>5?"H":"L",n=l[12],a=l.subarray(6,12);A+="."+p+r,A+="."+i.toString(16).toUpperCase(),A+="."+t+n;let o="";for(let d=a.length;d--;){const g=a[d];(g||o)&&(o="."+g.toString(16).toUpperCase()+o)}A+=o;break}case"dvh1":case"dvhe":{const l=Zi(s,["dvcC"])[0],c=l[2]>>1&127,p=l[2]<<5&32|l[3]>>3&31;A+="."+Nr(c)+"."+Nr(p);break}case"vp09":{const l=Zi(s,["vpcC"])[0],c=l[4],p=l[5],r=l[6]>>4&15;A+="."+Nr(c)+"."+Nr(p)+"."+Nr(r);break}case"av01":{const l=Zi(s,["av1C"])[0],c=l[1]>>>5,p=l[1]&31,r=l[2]>>>7?"H":"M",i=(l[2]&64)>>6,t=(l[2]&32)>>5,n=c===2&&i?t?12:10:i?10:8,a=(l[2]&16)>>4,o=(l[2]&8)>>3,d=(l[2]&4)>>2,g=l[2]&3;A+="."+c+"."+Nr(p)+r+"."+Nr(n)+"."+a+"."+o+d+g+"."+Nr(1)+"."+Nr(1)+"."+Nr(1)+"."+0;break}}return{codec:A,encrypted:y}}function dc(_,e){const s=e+5;for(;_[e++]&128&&e {const l=Zi(A,["mdia","minf","stbl","stsd"])[0].subarray(8);let c=Zi(l,["enca"]);const p=c.length>0;p||(c=Zi(l,["encv"])),c.forEach(r=>{const i=p?r.subarray(28):r.subarray(78);Zi(i,["sinf"]).forEach(n=>{const a=Dp(n);if(a){const o=a.subarray(8,24);o.some(d=>d!==0)||(Ft.log(`[eme] Patching keyId in 'enc${p?"a":"v"}>sinf>>tenc' box: ${Fr.hexDump(o)} -> ${Fr.hexDump(s)}`),a.set(s,8))}})})}),_}function Dp(_){const e=Zi(_,["schm"])[0];if(e){const s=In(e.subarray(4,8));if(s==="cbcs"||s==="cenc")return Zi(_,["schi","tenc"])[0]}return Ft.error("[eme] missing 'schm' box"),null}function v_(_,e){return Zi(e,["moof","traf"]).reduce((s,u)=>{const A=Zi(u,["tfdt"])[0],y=A[0],l=Zi(u,["tfhd"]).reduce((c,p)=>{const r=Ki(p,4),i=_[r];if(i){let t=Ki(A,4);if(y===1){if(t===ko)return Ft.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),c;t*=ko+1,t+=Ki(A,8)}const n=i.timescale||9e4,a=t/n;if(Ci(a)&&(c===null||ai+t.info.duration||0,0))}return l}return u||A}function __(_){const e=Ki(_,0);let s=8;e&1&&(s+=4),e&4&&(s+=4);let u=0;const A=Ki(_,4);for(let y=0;y{Zi(u,["tfhd"]).forEach(A=>{const y=Ki(A,4),l=_[y];if(!l)return;const c=l.timescale||9e4;Zi(u,["tfdt"]).forEach(p=>{const r=p[0],i=s*c;if(i){let t=Ki(p,4);if(r===0)t-=i,t=Math.max(t,0),cc(p,4,t);else{t*=Math.pow(2,32),t+=Ki(p,8),t-=i,t=Math.max(t,0);const n=Math.floor(t/(ko+1)),a=Math.floor(t%(ko+1));cc(p,4,n),cc(p,8,a)}}})})})}function w_(_){const e={valid:null,remainder:null},s=Zi(_,["moof"]);if(s.length<2)return e.remainder=_,e;const u=s[s.length-1];return e.valid=Ts(_,0,u.byteOffset-8),e.remainder=Ts(_,u.byteOffset-8),e}function Ar(_,e){const s=new Uint8Array(_.length+e.length);return s.set(_),s.set(e,_.length),s}function bh(_,e){const s=[],u=e.samples,A=e.timescale,y=e.id;let l=!1;return Zi(u,["moof"]).map(p=>{const r=p.byteOffset-8;Zi(p,["traf"]).map(t=>{const n=Zi(t,["tfdt"]).map(a=>{const o=a[0];let d=Ki(a,4);return o===1&&(d*=Math.pow(2,32),d+=Ki(a,8)),d/A})[0];return n!==void 0&&(_=n),Zi(t,["tfhd"]).map(a=>{const o=Ki(a,4),d=Ki(a,0)&16777215,g=(d&1)!==0,m=(d&2)!==0,v=(d&8)!==0;let b=0;const w=(d&16)!==0;let C=0;const D=(d&32)!==0;let R=8;o===y&&(g&&(R+=8),m&&(R+=4),v&&(b=Ki(a,R),R+=4),w&&(C=Ki(a,R),R+=4),D&&(R+=4),e.type==="video"&&(l=S_(e.codec)),Zi(t,["trun"]).map(T=>{const P=T[0],L=Ki(T,0)&16777215,I=(L&1)!==0;let x=0;const O=(L&4)!==0,G=(L&256)!==0;let J=0;const te=(L&512)!==0;let le=0;const ne=(L&1024)!==0,ee=(L&2048)!==0;let M=0;const Y=Ki(T,4);let j=8;I&&(x=Ki(T,j),j+=4),O&&(j+=4);let z=x+r;for(let q=0;q >1&63;return s===39||s===40}else return(e&31)===6}function Ed(_,e,s,u){const A=Op(_);let y=0;y+=e;let l=0,c=0,p=0;for(;y =A.length)break;p=A[y++],l+=p}while(p===255);c=0;do{if(y>=A.length)break;p=A[y++],c+=p}while(p===255);const r=A.length-y;let i=y;if(c r){Ft.error(`Malformed SEI payload. ${c} is too small, only ${r} bytes left to parse.`);break}if(l===4){if(A[i++]===181){const n=Rp(A,i);if(i+=2,n===49){const a=Ki(A,i);if(i+=4,a===1195456820){const o=A[i++];if(o===3){const d=A[i++],g=31&d,m=64&d,v=m?2+g*3:0,b=new Uint8Array(v);if(m){b[0]=d;for(let w=1;w 16){const t=[];for(let o=0;o<16;o++){const d=A[i++].toString(16);t.push(d.length==1?"0"+d:d),(o===3||o===5||o===7||o===9)&&t.push("-")}const n=c-16,a=new Uint8Array(n);for(let o=0;o >24&255,y[1]=u>>16&255,y[2]=u>>8&255,y[3]=u&255,y.set(_,4),A=0,u=8;A 0?(y=new Uint8Array(4),e.length>0&&new DataView(y.buffer).setUint32(0,e.length,!1)):y=new Uint8Array;const l=new Uint8Array(4);return s&&s.byteLength>0&&new DataView(l.buffer).setUint32(0,s.byteLength,!1),x_([112,115,115,104],new Uint8Array([u,0,0,0]),_,y,A,l,s||new Uint8Array)}function R_(_){if(!(_ instanceof ArrayBuffer)||_.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},s=new DataView(_),u=s.getUint32(0);if(_.byteLength!==u&&u>44||s.getUint32(4)!==1886614376||(e.version=s.getUint32(8)>>>24,e.version>1))return null;e.systemId=Fr.hexDump(new Uint8Array(_,12,16));const y=s.getUint32(28);if(e.version===0){if(u-32=22&&(this.keyId=s.subarray(s.length-22,s.length-6));break;case Zn.PLAYREADY:{const u=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=k_(u,null,s);const A=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),y=String.fromCharCode.apply(null,Array.from(A)),l=y.substring(y.indexOf("<"),y.length),r=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(r){const i=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(i){const t=vd(i).subarray(0,16);t_(t),this.keyId=t}}break}default:{let u=s.subarray(0,16);if(u.length!==16){const A=new Uint8Array(16);A.set(u,16-u.length),u=A}this.keyId=u;break}}if(!this.keyId||this.keyId.byteLength!==16){let u=Xa[this.uri];if(!u){const A=Object.keys(Xa).length%Number.MAX_SAFE_INTEGER;u=new Uint8Array(16),new DataView(u.buffer,12,4).setUint32(0,A),Xa[this.uri]=u}this.keyId=u}return this}}function I_(_){const e=new Uint8Array(16);for(let s=12;s<16;s++)e[s]=_>>8*(15-s)&255;return e}const Mp=/\{\$([a-zA-Z0-9-_]+)\}/g;function _h(_){return Mp.test(_)}function Qn(_,e,s){if(_.variableList!==null||_.hasVariableRefs)for(let u=s.length;u--;){const A=s[u],y=e[A];y&&(e[A]=jc(_,y))}}function jc(_,e){if(_.variableList!==null||_.hasVariableRefs){const s=_.variableList;return e.replace(Mp,u=>{const A=u.substring(2,u.length-1),y=s==null?void 0:s[A];return y===void 0?(_.playlistParsingError||(_.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${A}"`)),u):y})}return e}function Eh(_,e,s){let u=_.variableList;u||(_.variableList=u={});let A,y;if("QUERYPARAM"in e){A=e.QUERYPARAM;try{const l=new self.URL(s).searchParams;if(l.has(A))y=l.get(A);else throw new Error(`"${A}" does not match any query parameter in URI: "${s}"`)}catch(l){_.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else A=e.NAME,y=e.VALUE;A in u?_.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${A}"`)):u[A]=y||""}function L_(_,e,s){const u=e.IMPORT;if(s&&u in s){let A=_.variableList;A||(_.variableList=A={}),A[u]=s[u]}else _.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${u}"`))}function ua(_=!0){return typeof self>"u"?void 0:(_||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const Ro={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function D_(_,e){const s=Ro[e];return!!s&&!!s[_.slice(0,4)]}function uc(_,e,s=!0){return!_.split(",").some(u=>!Pp(u,e,s))}function Pp(_,e,s=!0){var u;const A=ua(s);return(u=A==null?void 0:A.isTypeSupported(La(_,e)))!=null?u:!1}function La(_,e){return`${e}/mp4;codecs="${_}"`}function wh(_){if(_){const e=_.substring(0,4);return Ro.video[e]}return 2}function Io(_){return _.split(",").reduce((e,s)=>{const u=Ro.video[s];return u?(u*2+e)/(e?3:2):(Ro.audio[s]+e)/(e?2:1)},0)}const hc={};function O_(_,e=!0){if(hc[_])return hc[_];const s={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[_];for(let u=0;u O_(s.toLowerCase(),e))}function Sh(_,e){return _&&_!=="mp4a"?_:e}function P_(_){const e=_.split(".");if(e.length>2){let s=e.shift()+".";return s+=parseInt(e.shift()).toString(16),s+=("000"+parseInt(e.shift()).toString(16)).slice(-4),s}return _}const Th=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Ch=/#EXT-X-MEDIA:(.*)/g,B_=/^#EXT(?:INF|-X-TARGETDURATION):/m,xh=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),N_=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Gr{static findGroup(e,s){for(let u=0;u 0&&y.length ({id:r.attrs.AUDIO,audioCodec:r.audioCodec})),SUBTITLES:l.map(r=>({id:r.attrs.SUBTITLES,textCodec:r.textCodec})),"CLOSED-CAPTIONS":[]};let p=0;for(Ch.lastIndex=0;(A=Ch.exec(e))!==null;){const r=new bn(A[1]),i=r.TYPE;if(i){const t=c[i],n=y[i]||[];y[i]=n,Qn(u,r,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const a=r.LANGUAGE,o=r["ASSOC-LANGUAGE"],d=r.CHANNELS,g=r.CHARACTERISTICS,m=r["INSTREAM-ID"],v={attrs:r,bitrate:0,id:p++,groupId:r["GROUP-ID"]||"",name:r.NAME||a||"",type:i,default:r.bool("DEFAULT"),autoselect:r.bool("AUTOSELECT"),forced:r.bool("FORCED"),lang:a,url:r.URI?Gr.resolve(r.URI,s):""};if(o&&(v.assocLang=o),d&&(v.channels=d),g&&(v.characteristics=g),m&&(v.instreamId=m),t!=null&&t.length){const b=Gr.findGroup(t,v.groupId)||t[0];Ih(v,b,"audioCodec"),Ih(v,b,"textCodec")}n.push(v)}}return y}static parseLevelPlaylist(e,s,u,A,y,l){const c=new $b(s),p=c.fragments;let r=null,i=0,t=0,n=0,a=0,o=null,d=new ac(A,s),g,m,v,b=-1,w=!1,C=null;for(xh.lastIndex=0,c.m3u8=e,c.hasVariableRefs=_h(e);(g=xh.exec(e))!==null;){w&&(w=!1,d=new ac(A,s),d.start=n,d.sn=i,d.cc=a,d.level=u,r&&(d.initSegment=r,d.rawProgramDateTime=r.rawProgramDateTime,r.rawProgramDateTime=null,C&&(d.setByteRange(C),C=null)));const P=g[1];if(P){d.duration=parseFloat(P);const L=(" "+g[2]).slice(1);d.title=L||null,d.tagList.push(L?["INF",P,L]:["INF",P])}else if(g[3]){if(Ci(d.duration)){d.start=n,v&&Oh(d,v,c),d.sn=i,d.level=u,d.cc=a,p.push(d);const L=(" "+g[3]).slice(1);d.relurl=jc(c,L),Lh(d,o),o=d,n+=d.duration,i++,t=0,w=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);o?d.setByteRange(L,o):d.setByteRange(L)}else if(g[5])d.rawProgramDateTime=(" "+g[5]).slice(1),d.tagList.push(["PROGRAM-DATE-TIME",d.rawProgramDateTime]),b===-1&&(b=p.length);else{if(g=g[0].match(N_),!g){Ft.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m 0&&O.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),c.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const O=new bn(I);c.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case"PART":{let O=c.partList;O||(O=c.partList=[]);const G=t>0?O[O.length-1]:void 0,J=t++,te=new bn(I);Qn(c,te,["BYTERANGE","URI"]);const le=new Zb(te,d,s,J,G);O.push(le),d.duration+=le.duration;break}case"PRELOAD-HINT":{const O=new bn(I);Qn(c,O,["URI"]),c.preloadHint=O;break}case"RENDITION-REPORT":{const O=new bn(I);Qn(c,O,["URI"]),c.renditionReports=c.renditionReports||[],c.renditionReports.push(O);break}default:Ft.warn(`line parsed but not handled: ${g}`);break}}}o&&!o.relurl?(p.pop(),n-=o.duration,c.partList&&(c.fragmentHint=o)):c.partList&&(Lh(d,o),d.cc=a,c.fragmentHint=d,v&&Oh(d,v,c));const D=p.length,R=p[0],T=p[D-1];if(n+=c.skippedSegments*c.targetduration,n>0&&D&&T){c.averagetargetduration=n/D;const P=T.sn;c.endSN=P!=="initSegment"?P:0,c.live||(T.endList=!0),R&&(c.startCC=R.cc)}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(n+=c.fragmentHint.duration),c.totalduration=n,c.endCC=a,b>0&&U_(p,b),c}}function kh(_,e,s){var u,A;const y=new bn(_);Qn(s,y,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(u=y.METHOD)!=null?u:"",c=y.URI,p=y.hexadecimalInteger("IV"),r=y.KEYFORMATVERSIONS,i=(A=y.KEYFORMAT)!=null?A:"identity";c&&y.IV&&!p&&Ft.error(`Invalid IV: ${y.IV}`);const t=c?Gr.resolve(c,e):"",n=(r||"1").split("/").map(Number).filter(Number.isFinite);return new Ia(l,t,i,n,p)}function Rh(_){const s=new bn(_).decimalFloatingPoint("TIME-OFFSET");return Ci(s)?s:null}function F_(_,e){let s=(_||"").split(/[ ,]+/).filter(u=>u);["video","audio","text"].forEach(u=>{const A=s.filter(y=>D_(y,u));A.length&&(e[`${u}Codec`]=A.join(","),s=s.filter(y=>A.indexOf(y)===-1))}),e.unknownCodecs=s}function Ih(_,e,s){const u=e[s];u&&(_[s]=u)}function U_(_,e){let s=_[e];for(let u=e;u--;){const A=_[u];if(!A)return;A.programDateTime=s.programDateTime-A.duration*1e3,s=A}}function Lh(_,e){_.rawProgramDateTime?_.programDateTime=Date.parse(_.rawProgramDateTime):e!=null&&e.programDateTime&&(_.programDateTime=e.endProgramDateTime),Ci(_.programDateTime)||(_.programDateTime=null,_.rawProgramDateTime=null)}function Dh(_,e,s,u){_.relurl=e.URI,e.BYTERANGE&&_.setByteRange(e.BYTERANGE),_.level=s,_.sn="initSegment",u&&(_.levelkeys=u),_.initSegment=null}function Oh(_,e,s){_.levelkeys=e;const{encryptedFragments:u}=s;(!u.length||u[u.length-1].levelkeys!==e)&&Object.keys(e).some(A=>e[A].isCommonEncryption)&&u.push(_)}var ln={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Hi={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Mh(_){const{type:e}=_;switch(e){case ln.AUDIO_TRACK:return Hi.AUDIO;case ln.SUBTITLE_TRACK:return Hi.SUBTITLE;default:return Hi.MAIN}}function fc(_,e){let s=_.url;return(s===void 0||s.indexOf("data:")===0)&&(s=e.url),s}class G_{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.LEVEL_LOADING,this.onLevelLoading,this),e.on(rt.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(rt.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.LEVEL_LOADING,this.onLevelLoading,this),e.off(rt.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(rt.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const s=this.hls.config,u=s.pLoader,A=s.loader,y=u||A,l=new y(s);return this.loaders[e.type]=l,l}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,s){const{url:u}=s;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ln.MANIFEST,url:u,deliveryDirectives:null})}onLevelLoading(e,s){const{id:u,level:A,pathwayId:y,url:l,deliveryDirectives:c}=s;this.load({id:u,level:A,pathwayId:y,responseType:"text",type:ln.LEVEL,url:l,deliveryDirectives:c})}onAudioTrackLoading(e,s){const{id:u,groupId:A,url:y,deliveryDirectives:l}=s;this.load({id:u,groupId:A,level:null,responseType:"text",type:ln.AUDIO_TRACK,url:y,deliveryDirectives:l})}onSubtitleTrackLoading(e,s){const{id:u,groupId:A,url:y,deliveryDirectives:l}=s;this.load({id:u,groupId:A,level:null,responseType:"text",type:ln.SUBTITLE_TRACK,url:y,deliveryDirectives:l})}load(e){var s;const u=this.hls.config;let A=this.getInternalLoader(e);if(A){const r=A.context;if(r&&r.url===e.url&&r.level===e.level){Ft.trace("[playlist-loader]: playlist request ongoing");return}Ft.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),A.abort()}let y;if(e.type===ln.MANIFEST?y=u.manifestLoadPolicy.default:y=xn({},u.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),A=this.createInternalLoader(e),Ci((s=e.deliveryDirectives)==null?void 0:s.part)){let r;if(e.type===ln.LEVEL&&e.level!==null?r=this.hls.levels[e.level].details:e.type===ln.AUDIO_TRACK&&e.id!==null?r=this.hls.audioTracks[e.id].details:e.type===ln.SUBTITLE_TRACK&&e.id!==null&&(r=this.hls.subtitleTracks[e.id].details),r){const i=r.partTarget,t=r.targetduration;if(i&&t){const n=Math.max(i*3,t*.8)*1e3;y=xn({},y,{maxTimeToFirstByteMs:Math.min(n,y.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(n,y.maxTimeToFirstByteMs)})}}}const l=y.errorRetry||y.timeoutRetry||{},c={loadPolicy:y,timeout:y.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},p={onSuccess:(r,i,t,n)=>{const a=this.getInternalLoader(t);this.resetInternalLoader(t.type);const o=r.data;if(o.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(r,t,new Error("no EXTM3U delimiter"),n||null,i);return}i.parsing.start=performance.now(),Gr.isMediaPlaylist(o)?this.handleTrackOrLevelPlaylist(r,i,t,n||null,a):this.handleMasterPlaylist(r,i,t,n)},onError:(r,i,t,n)=>{this.handleNetworkError(i,t,!1,r,n)},onTimeout:(r,i,t)=>{this.handleNetworkError(i,t,!0,void 0,r)}};A.load(e,c,p)}handleMasterPlaylist(e,s,u,A){const y=this.hls,l=e.data,c=fc(e,u),p=Gr.parseMasterPlaylist(l,c);if(p.playlistParsingError){this.handleManifestParsingError(e,u,p.playlistParsingError,A,s);return}const{contentSteering:r,levels:i,sessionData:t,sessionKeys:n,startTimeOffset:a,variableList:o}=p;this.variableList=o;const{AUDIO:d=[],SUBTITLES:g,"CLOSED-CAPTIONS":m}=Gr.parseMasterPlaylistMedia(l,c,p);d.length&&!d.some(b=>!b.url)&&i[0].audioCodec&&!i[0].attrs.AUDIO&&(Ft.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new bn({}),bitrate:0,url:""})),y.trigger(rt.MANIFEST_LOADED,{levels:i,audioTracks:d,subtitles:g,captions:m,contentSteering:r,url:c,stats:s,networkDetails:A,sessionData:t,sessionKeys:n,startTimeOffset:a,variableList:o})}handleTrackOrLevelPlaylist(e,s,u,A,y){const l=this.hls,{id:c,level:p,type:r}=u,i=fc(e,u),t=0,n=Ci(p)?p:Ci(c)?c:0,a=Mh(u),o=Gr.parseLevelPlaylist(e.data,i,n,a,t,this.variableList);if(r===ln.MANIFEST){const d={attrs:new bn({}),bitrate:0,details:o,name:"",url:i};l.trigger(rt.MANIFEST_LOADED,{levels:[d],audioTracks:[],url:i,stats:s,networkDetails:A,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}s.parsing.end=performance.now(),u.levelDetails=o,this.handlePlaylistLoaded(o,e,s,u,A,y)}handleManifestParsingError(e,s,u,A,y){this.hls.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.MANIFEST_PARSING_ERROR,fatal:s.type===ln.MANIFEST,url:e.url,err:u,error:u,reason:u.message,response:e,context:s,networkDetails:A,stats:y})}handleNetworkError(e,s,u=!1,A,y){let l=`A network ${u?"timeout":"error"+(A?" (status "+A.code+")":"")} occurred while loading ${e.type}`;e.type===ln.LEVEL?l+=`: ${e.level} id: ${e.id}`:(e.type===ln.AUDIO_TRACK||e.type===ln.SUBTITLE_TRACK)&&(l+=` id: ${e.id} group-id: "${e.groupId}"`);const c=new Error(l);Ft.warn(`[playlist-loader]: ${l}`);let p=qt.UNKNOWN,r=!1;const i=this.getInternalLoader(e);switch(e.type){case ln.MANIFEST:p=u?qt.MANIFEST_LOAD_TIMEOUT:qt.MANIFEST_LOAD_ERROR,r=!0;break;case ln.LEVEL:p=u?qt.LEVEL_LOAD_TIMEOUT:qt.LEVEL_LOAD_ERROR,r=!1;break;case ln.AUDIO_TRACK:p=u?qt.AUDIO_TRACK_LOAD_TIMEOUT:qt.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case ln.SUBTITLE_TRACK:p=u?qt.SUBTITLE_TRACK_LOAD_TIMEOUT:qt.SUBTITLE_LOAD_ERROR,r=!1;break}i&&this.resetInternalLoader(e.type);const t={type:Wi.NETWORK_ERROR,details:p,fatal:r,url:e.url,loader:i,context:e,error:c,networkDetails:s,stats:y};if(A){const n=(s==null?void 0:s.url)||e.url;t.response=Dn({url:n,data:void 0},A)}this.hls.trigger(rt.ERROR,t)}handlePlaylistLoaded(e,s,u,A,y,l){const c=this.hls,{type:p,level:r,id:i,groupId:t,deliveryDirectives:n}=A,a=fc(s,A),o=Mh(A),d=typeof A.level=="number"&&o===Hi.MAIN?r:void 0;if(!e.fragments.length){const m=new Error("No Segments found in Playlist");c.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.LEVEL_EMPTY_ERROR,fatal:!1,url:a,error:m,reason:m.message,response:s,context:A,level:d,parent:o,networkDetails:y,stats:u});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){c.trigger(rt.ERROR,{type:Wi.NETWORK_ERROR,details:qt.LEVEL_PARSING_ERROR,fatal:!1,url:a,error:g,reason:g.message,response:s,context:A,level:d,parent:o,networkDetails:y,stats:u});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),p){case ln.MANIFEST:case ln.LEVEL:c.trigger(rt.LEVEL_LOADED,{details:e,level:d||0,id:i||0,stats:u,networkDetails:y,deliveryDirectives:n});break;case ln.AUDIO_TRACK:c.trigger(rt.AUDIO_TRACK_LOADED,{details:e,id:i||0,groupId:t||"",stats:u,networkDetails:y,deliveryDirectives:n});break;case ln.SUBTITLE_TRACK:c.trigger(rt.SUBTITLE_TRACK_LOADED,{details:e,id:i||0,groupId:t||"",stats:u,networkDetails:y,deliveryDirectives:n});break}}}function Bp(_,e){let s;try{s=new Event("addtrack")}catch{s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=_,e.dispatchEvent(s)}function Np(_,e){const s=_.mode;if(s==="disabled"&&(_.mode="hidden"),_.cues&&!_.cues.getCueById(e.id))try{if(_.addCue(e),!_.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(u){Ft.debug(`[texttrack-utils]: ${u}`);try{const A=new self.TextTrackCue(e.startTime,e.endTime,e.text);A.id=e.id,_.addCue(A)}catch(A){Ft.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${A}`)}}s==="disabled"&&(_.mode=s)}function Zs(_){const e=_.mode;if(e==="disabled"&&(_.mode="hidden"),_.cues)for(let s=_.cues.length;s--;)_.removeCue(_.cues[s]);e==="disabled"&&(_.mode=e)}function Vc(_,e,s,u){const A=_.mode;if(A==="disabled"&&(_.mode="hidden"),_.cues&&_.cues.length>0){const y=V_(_.cues,e,s);for(let l=0;l _[s].endTime)return-1;let u=0,A=s;for(;u<=A;){const y=Math.floor((A+u)/2);if(e<_[y].startTime)A=y-1;else if(e>_[y].startTime&&u -1)for(let y=A,l=_.length;y=e&&c.endTime<=s)u.push(c);else if(c.startTime>s)return u}return u}function po(_){const e=[];for(let s=0;s<_.length;s++){const u=_[s];(u.kind==="subtitles"||u.kind==="captions")&&u.label&&e.push(_[s])}return e}var xr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const H_=.25;function Hc(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ph(_,e,s,u,A){let y=new _(e,s,"");try{y.value=u,A&&(y.type=A)}catch{y=new _(e,s,JSON.stringify(A?Dn({type:A},u):u))}return y}const $a=(()=>{const _=Hc();try{_&&new _(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function pc(_,e){return _.getTime()/1e3-e}function z_(_){return Uint8Array.from(_.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class W_{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(rt.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rt.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(rt.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(rt.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rt.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(rt.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,s){this.media=s.media}onMediaDetaching(){this.id3Track&&(Zs(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const s=this.getID3Track(e.textTracks);return s.mode="hidden",s}getID3Track(e){if(this.media){for(let s=0;s $a&&(t=$a),t-i<=0&&(t=i+H_);for(let a=0;a i.type===xr.audioId3&&p:A==="video"?r=i=>i.type===xr.emsg&&c:r=i=>i.type===xr.audioId3&&p||i.type===xr.emsg&&c,Vc(y,s,u,r)}}onLevelUpdated(e,{details:s}){if(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:u,id3Track:A}=this,{dateRanges:y}=s,l=Object.keys(y);if(A){const i=Object.keys(u).filter(t=>!l.includes(t));for(let t=i.length;t--;){const n=i[t];Object.keys(u[n].cues).forEach(a=>{A.removeCue(u[n].cues[a])}),delete u[n]}}const c=s.fragments[s.fragments.length-1];if(l.length===0||!Ci(c==null?void 0:c.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const p=c.programDateTime/1e3-c.start,r=Hc();for(let i=0;i {if(D!==n.id){const R=y[D];if(R.class===n.class&&R.startDate>n.startDate&&(!C||n.startDate this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:s}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:s?e.liveMaxLatencyDurationCount*s.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:s,partHoldBack:u,targetduration:A}=e,{liveSyncDuration:y,liveSyncDurationCount:l,lowLatencyMode:c}=this.config,p=this.hls.userConfig;let r=c&&u||s;(p.liveSyncDuration||p.liveSyncDurationCount||r===0)&&(r=y!==void 0?y:l*A);const i=A;return r+Math.min(this.stallCount*1,i)}get liveSyncPosition(){const e=this.estimateLiveEdge(),s=this.targetLatency,u=this.levelDetails;if(e===null||s===null||u===null)return null;const A=u.edge,y=e-s-this.edgeStalled,l=A-u.totalduration,c=A-(this.config.lowLatencyMode&&u.partTarget||u.targetduration);return Math.min(Math.max(l,y),c)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const s=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-s,0)}get forwardBufferLength(){const{media:e,levelDetails:s}=this;if(!e||!s)return 0;const u=e.buffered.length;return(u?e.buffered.end(u-1):s.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(rt.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(rt.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(rt.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(rt.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(rt.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(rt.ERROR,this.onError,this)}onMediaAttached(e,s){this.media=s.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:s}){this.levelDetails=s,s.advanced&&this.timeupdate(),!s.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,s){var u;s.details===qt.BUFFER_STALLED_ERROR&&(this.stallCount++,(u=this.levelDetails)!=null&&u.live&&Ft.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:s}=this;if(!e||!s)return;this.currentTime=e.currentTime;const u=this.computeLatency();if(u===null)return;this._latency=u;const{lowLatencyMode:A,maxLiveSyncPlaybackRate:y}=this.config;if(!A||y===1||!s.live)return;const l=this.targetLatency;if(l===null)return;const c=u-l,p=Math.min(this.maxLatency,l+s.targetduration);if(c .05&&this.forwardBufferLength>1){const i=Math.min(2,Math.max(1,y)),t=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;e.playbackRate=Math.min(i,Math.max(1,t))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const zc=["NONE","TYPE-0","TYPE-1",null];function q_(_){return zc.indexOf(_)>-1}const Do=["SDR","PQ","HLG"];function Y_(_){return!!_&&Do.indexOf(_)>-1}var Ca={No:"",Yes:"YES",v2:"v2"};function J_(_,e){const{canSkipUntil:s,canSkipDateRanges:u,endSN:A}=_,y=e!==void 0?e-A:0;return s&&y
!!s).map(s=>s.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Nh(this._audioGroups,e)}hasSubtitleGroup(e){return Nh(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,s){if(s){if(e==="audio"){let u=this._audioGroups;u||(u=this._audioGroups=[]),u.indexOf(s)===-1&&u.push(s)}else if(e==="text"){let u=this._subtitleGroups;u||(u=this._subtitleGroups=[]),u.indexOf(s)===-1&&u.push(s)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Nh(_,e){return!e||!_?!1:_.indexOf(e)!==-1}function mc(_,e){const s=e.startPTS;if(Ci(s)){let u=0,A;e.sn>_.sn?(u=s-_.start,A=_):(u=_.start-s,A=e),A.duration!==u&&(A.duration=u)}else e.sn>_.sn?_.cc===e.cc&&_.minEndPTS?e.start=_.start+(_.minEndPTS-_.start):e.start=_.start+_.duration:e.start=Math.max(_.start-e.duration,0)}function Fp(_,e,s,u,A,y){u-s<=0&&(Ft.warn("Fragment should have a positive duration",e),u=s+e.duration,y=A+e.duration);let c=s,p=u;const r=e.startPTS,i=e.endPTS;if(Ci(r)){const g=Math.abs(r-s);Ci(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,c=Math.max(s,r),s=Math.min(s,r),A=Math.min(A,e.startDTS),p=Math.min(u,i),u=Math.max(u,i),y=Math.max(y,e.endDTS)}const t=s-e.start;e.start!==0&&(e.start=s),e.duration=u-e.start,e.startPTS=s,e.maxStartPTS=c,e.startDTS=A,e.endPTS=u,e.minEndPTS=p,e.endDTS=y;const n=e.sn;if(!_||n<_.startSN||n>_.endSN)return 0;let a;const o=n-_.startSN,d=_.fragments;for(d[o]=e,a=o;a>0;a--)mc(d[a],d[a-1]);for(a=o;a=0;p--){const r=u[p].initSegment;if(r){s=r;break}}_.fragmentHint&&delete _.fragmentHint.endPTS;let A=0,y;if($_(_,e,(p,r)=>{p.relurl&&(A=p.cc-r.cc),Ci(p.startPTS)&&Ci(p.endPTS)&&(r.start=r.startPTS=p.startPTS,r.startDTS=p.startDTS,r.maxStartPTS=p.maxStartPTS,r.endPTS=p.endPTS,r.endDTS=p.endDTS,r.minEndPTS=p.minEndPTS,r.duration=p.endPTS-p.startPTS,r.duration&&(y=r),e.PTSKnown=e.alignedSliding=!0),r.elementaryStreams=p.elementaryStreams,r.loader=p.loader,r.stats=p.stats,p.initSegment&&(r.initSegment=p.initSegment,s=p.initSegment)}),s&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(r=>{var i;r&&(!r.initSegment||r.initSegment.relurl===((i=s)==null?void 0:i.relurl))&&(r.initSegment=s)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(p=>!p),e.deltaUpdateFailed){Ft.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let p=e.skippedSegments;p--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=Z_(_.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const l=e.fragments;if(A){Ft.warn("discontinuity sliding from playlist, take drift into account");for(let p=0;p {r.elementaryStreams=p.elementaryStreams,r.stats=p.stats}),y?Fp(e,y,y.startPTS,y.endPTS,y.startDTS,y.endDTS):Up(_,e),l.length&&(e.totalduration=e.edge-l[0].start),e.driftStartTime=_.driftStartTime,e.driftStart=_.driftStart;const c=e.advancedDateTime;if(e.advanced&&c){const p=e.edge;e.driftStart||(e.driftStartTime=c,e.driftStart=p),e.driftEndTime=c,e.driftEnd=p}else e.driftEndTime=_.driftEndTime,e.driftEnd=_.driftEnd,e.advancedDateTime=_.advancedDateTime}function Z_(_,e,s){const u=xn({},_);return s&&s.forEach(A=>{delete u[A]}),Object.keys(e).forEach(A=>{const y=new _p(e[A].attr,u[A]);y.isValid?u[A]=y:Ft.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[A].attr)}"`)}),u}function X_(_,e,s){if(_&&e){let u=0;for(let A=0,y=_.length;A<=y;A++){const l=_[A],c=e[A+u];l&&c&&l.index===c.index&&l.fragment.sn===c.fragment.sn?s(l,c):u--}}}function $_(_,e,s){const u=e.skippedSegments,A=Math.max(_.startSN,e.startSN)-e.startSN,y=(_.fragmentHint?1:0)+(u?e.endSN:Math.min(_.endSN,e.endSN))-e.startSN,l=e.startSN-_.startSN,c=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,p=_.fragmentHint?_.fragments.concat(_.fragmentHint):_.fragments;for(let r=A;r<=y;r++){const i=p[l+r];let t=c[r];u&&!t&&r=u.length||Wc(e,u[s].start)}function Wc(_,e){if(e){const s=_.fragments;for(let u=_.skippedSegments;u e){const y=u[u.length-1].duration*1e3;y {const{details:u}=e;u!=null&&u.fragments&&u.fragments.forEach(A=>{A.level=s})})}function Oo(_){switch(_.details){case qt.FRAG_LOAD_TIMEOUT:case qt.KEY_LOAD_TIMEOUT:case qt.LEVEL_LOAD_TIMEOUT:case qt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Uh(_,e){const s=Oo(e);return _.default[`${s?"timeout":"error"}Retry`]}function wd(_,e){const s=_.backoff==="linear"?1:Math.pow(2,e);return Math.min(s*_.retryDelayMs,_.maxRetryDelayMs)}function Gh(_){return Dn(Dn({},_),{errorRetry:null,timeoutRetry:null})}function Mo(_,e,s,u){if(!_)return!1;const A=u==null?void 0:u.code,y=e<_.maxNumRetry&&(i5(A)||!!s);return _.shouldRetry?_.shouldRetry(_,e,s,u,y):y}function i5(_){return _===0&&navigator.onLine===!1||!!_&&(_<400||_>499)}const Vp={search:function(_,e){let s=0,u=_.length-1,A=null,y=null;for(;s<=u;){A=(s+u)/2|0,y=_[A];const l=e(y);if(l>0)s=A+1;else if(l<0)u=A-1;else return y}return null}};function n5(_,e,s){if(e===null||!Array.isArray(_)||!_.length||!Ci(e))return null;const u=_[0].programDateTime;if(e<(u||0))return null;const A=_[_.length-1].endProgramDateTime;if(e>=(A||0))return null;s=s||0;for(let y=0;y<_.length;++y){const l=_[y];if(r5(e,s,l))return l}return null}function Po(_,e,s=0,u=0){let A=null;if(_){A=e[_.sn-e[0].sn+1]||null;const l=_.endDTS-s;l>0&&l<15e-7&&(s+=15e-7)}else s===0&&e[0].start===0&&(A=e[0]);if(A&&(!_||_.level===A.level)&&Kc(s,u,A)===0)return A;const y=Vp.search(e,Kc.bind(null,s,u));return y&&(y!==_||!A)?y:A}function Kc(_=0,e=0,s){if(s.start<=_&&s.start+s.duration>_)return 0;const u=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-u<=_?1:s.start-u>_&&s.start?-1:0}function r5(_,e,s){const u=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0))*1e3;return(s.endProgramDateTime||0)-u>_}function s5(_,e){return Vp.search(_,s=>s.cce?-1:0)}var Vn={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Tr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class a5{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=Ft.log.bind(Ft,"[info]:"),this.warn=Ft.warn.bind(Ft,"[warning]:"),this.error=Ft.error.bind(Ft,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(rt.ERROR,this.onError,this),e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(rt.ERROR,this.onError,this),e.off(rt.ERROR,this.onErrorOut,this),e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===Hi.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,s){var u,A;if(s.fatal)return;const y=this.hls,l=s.context;switch(s.details){case qt.FRAG_LOAD_ERROR:case qt.FRAG_LOAD_TIMEOUT:case qt.KEY_LOAD_ERROR:case qt.KEY_LOAD_TIMEOUT:s.errorAction=this.getFragRetryOrSwitchAction(s);return;case qt.FRAG_PARSING_ERROR:if((u=s.frag)!=null&&u.gap){s.errorAction={action:Vn.DoNothing,flags:Tr.None};return}case qt.FRAG_GAP:case qt.FRAG_DECRYPT_ERROR:{s.errorAction=this.getFragRetryOrSwitchAction(s),s.errorAction.action=Vn.SendAlternateToPenaltyBox;return}case qt.LEVEL_EMPTY_ERROR:case qt.LEVEL_PARSING_ERROR:{var c,p;const r=s.parent===Hi.MAIN?s.level:y.loadLevel;s.details===qt.LEVEL_EMPTY_ERROR&&((c=s.context)!=null&&(p=c.levelDetails)!=null&&p.live)?s.errorAction=this.getPlaylistRetryOrSwitchAction(s,r):(s.levelRetry=!1,s.errorAction=this.getLevelSwitchAction(s,r))}return;case qt.LEVEL_LOAD_ERROR:case qt.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(s.errorAction=this.getPlaylistRetryOrSwitchAction(s,l.level));return;case qt.AUDIO_TRACK_LOAD_ERROR:case qt.AUDIO_TRACK_LOAD_TIMEOUT:case qt.SUBTITLE_LOAD_ERROR:case qt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const r=y.levels[y.loadLevel];if(r&&(l.type===ln.AUDIO_TRACK&&r.hasAudioGroup(l.groupId)||l.type===ln.SUBTITLE_TRACK&&r.hasSubtitleGroup(l.groupId))){s.errorAction=this.getPlaylistRetryOrSwitchAction(s,y.loadLevel),s.errorAction.action=Vn.SendAlternateToPenaltyBox,s.errorAction.flags=Tr.MoveAllAlternatesMatchingHost;return}}return;case qt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const r=y.levels[y.loadLevel],i=r==null?void 0:r.attrs["HDCP-LEVEL"];i?s.errorAction={action:Vn.SendAlternateToPenaltyBox,flags:Tr.MoveAllAlternatesMatchingHDCP,hdcpLevel:i}:this.keySystemError(s)}return;case qt.BUFFER_ADD_CODEC_ERROR:case qt.REMUX_ALLOC_ERROR:case qt.BUFFER_APPEND_ERROR:s.errorAction=this.getLevelSwitchAction(s,(A=s.level)!=null?A:y.loadLevel);return;case qt.INTERNAL_EXCEPTION:case qt.BUFFER_APPENDING_ERROR:case qt.BUFFER_FULL_ERROR:case qt.LEVEL_SWITCH_ERROR:case qt.BUFFER_STALLED_ERROR:case qt.BUFFER_SEEK_OVER_HOLE:case qt.BUFFER_NUDGE_ON_STALL:s.errorAction={action:Vn.DoNothing,flags:Tr.None};return}s.type===Wi.KEY_SYSTEM_ERROR&&this.keySystemError(s)}keySystemError(e){const s=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,s)}getPlaylistRetryOrSwitchAction(e,s){const u=this.hls,A=Uh(u.config.playlistLoadPolicy,e),y=this.playlistError++;if(Mo(A,y,Oo(e),e.response))return{action:Vn.RetryRequest,flags:Tr.None,retryConfig:A,retryCount:y};const c=this.getLevelSwitchAction(e,s);return A&&(c.retryConfig=A,c.retryCount=y),c}getFragRetryOrSwitchAction(e){const s=this.hls,u=this.getVariantLevelIndex(e.frag),A=s.levels[u],{fragLoadPolicy:y,keyLoadPolicy:l}=s.config,c=Uh(e.details.startsWith("key")?l:y,e),p=s.levels.reduce((i,t)=>i+t.fragmentError,0);if(A&&(e.details!==qt.FRAG_GAP&&A.fragmentError++,Mo(c,p,Oo(e),e.response)))return{action:Vn.RetryRequest,flags:Tr.None,retryConfig:c,retryCount:p};const r=this.getLevelSwitchAction(e,u);return c&&(r.retryConfig=c,r.retryCount=p),r}getLevelSwitchAction(e,s){const u=this.hls;s==null&&(s=u.loadLevel);const A=this.hls.levels[s];if(A){var y,l;const r=e.details;A.loadError++,r===qt.BUFFER_APPEND_ERROR&&A.fragmentError++;let i=-1;const{levels:t,loadLevel:n,minAutoLevel:a,maxAutoLevel:o}=u;u.autoLevelEnabled||(u.loadLevel=-1);const d=(y=e.frag)==null?void 0:y.type,m=(d===Hi.AUDIO&&r===qt.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(r===qt.BUFFER_ADD_CODEC_ERROR||r===qt.BUFFER_APPEND_ERROR))&&t.some(({audioCodec:D})=>A.audioCodec!==D),b=e.sourceBufferName==="video"&&(r===qt.BUFFER_ADD_CODEC_ERROR||r===qt.BUFFER_APPEND_ERROR)&&t.some(({codecSet:D,audioCodec:R})=>A.codecSet!==D&&A.audioCodec===R),{type:w,groupId:C}=(l=e.context)!=null?l:{};for(let D=t.length;D--;){const R=(D+n)%t.length;if(R!==n&&R>=a&&R<=o&&t[R].loadError===0){var c,p;const T=t[R];if(r===qt.FRAG_GAP&&e.frag){const P=t[R].details;if(P){const L=Po(e.frag,P.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(w===ln.AUDIO_TRACK&&T.hasAudioGroup(C)||w===ln.SUBTITLE_TRACK&&T.hasSubtitleGroup(C))continue;if(d===Hi.AUDIO&&(c=A.audioGroups)!=null&&c.some(P=>T.hasAudioGroup(P))||d===Hi.SUBTITLE&&(p=A.subtitleGroups)!=null&&p.some(P=>T.hasSubtitleGroup(P))||m&&A.audioCodec===T.audioCodec||!m&&A.audioCodec!==T.audioCodec||b&&A.codecSet===T.codecSet)continue}i=R;break}}if(i>-1&&u.loadLevel!==i)return e.levelRetry=!0,this.playlistError=0,{action:Vn.SendAlternateToPenaltyBox,flags:Tr.None,nextAutoLevel:i}}return{action:Vn.SendAlternateToPenaltyBox,flags:Tr.MoveAllAlternatesMatchingHost}}onErrorOut(e,s){var u;switch((u=s.errorAction)==null?void 0:u.action){case Vn.DoNothing:break;case Vn.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(s),!s.errorAction.resolved&&s.details!==qt.FRAG_GAP?s.fatal=!0:/MediaSource readyState: ended/.test(s.error.message)&&(this.warn(`MediaSource ended after "${s.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(s.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const s=this.hls,u=e.errorAction;if(!u)return;const{flags:A,hdcpLevel:y,nextAutoLevel:l}=u;switch(A){case Tr.None:this.switchLevel(e,l);break;case Tr.MoveAllAlternatesMatchingHDCP:y&&(s.maxHdcpLevel=zc[zc.indexOf(y)-1],u.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${s.maxHdcpLevel}" or lower`);break}u.resolved||this.switchLevel(e,l)}switchLevel(e,s){s!==void 0&&e.errorAction&&(this.warn(`switching to level ${s} after ${e.details}`),this.hls.nextAutoLevel=s,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class Sd{constructor(e,s){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Ft.log.bind(Ft,`${s}:`),this.warn=Ft.warn.bind(Ft,`${s}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,s){const u=s==null?void 0:s.renditionReports;if(u){let A=-1;for(let y=0;y =0&&p>s.partTarget&&(c+=1)}return new Bh(l,c>=0?c:void 0,Ca.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,s,u){const{details:A,stats:y}=s,l=self.performance.now(),c=y.loading.first?Math.max(0,l-y.loading.first):0;if(A.advancedDateTime=Date.now()-c,A.live||u!=null&&u.live){if(A.reloaded(u),u&&this.log(`live playlist ${e} ${A.advanced?"REFRESHED "+A.lastPartSn+"-"+A.lastPartIndex:A.updated?"UPDATED":"MISSED"}`),u&&A.fragments.length>0&&Q_(u,A),!this.canLoad||!A.live)return;let p,r,i;if(A.canBlockReload&&A.endSN&&A.advanced){const g=this.hls.config.lowLatencyMode,m=A.lastPartSn,v=A.endSN,b=A.lastPartIndex,w=b!==-1,C=m===v,D=g?0:b;w?(r=C?v+1:m,i=C?D:b+1):r=v+1;const R=A.age,T=R+A.ageHeader;let P=Math.min(T-A.partTarget,A.targetduration*1.5);if(P>0){if(u&&P>u.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${u.tuneInGoal} to: ${P} with playlist age: ${A.age}`),P=0;else{const L=Math.floor(P/A.targetduration);if(r+=L,i!==void 0){const I=Math.round(P%A.targetduration/A.partTarget);i+=I}this.log(`CDN Tune-in age: ${A.ageHeader}s last advanced ${R.toFixed(2)}s goal: ${P} skip sn ${L} to part ${i}`)}A.tuneInGoal=P}if(p=this.getDeliveryDirectives(A,s.deliveryDirectives,r,i),g||!C){this.loadPlaylist(p);return}}else(A.canBlockReload||A.canSkipUntil)&&(p=this.getDeliveryDirectives(A,s.deliveryDirectives,r,i));const t=this.hls.mainForwardBufferInfo,n=t?t.end-t.len:0,a=(A.edge-n)*1e3,o=e5(A,a);A.updated&&l>this.requestScheduled+o&&(this.requestScheduled=y.loading.start),r!==void 0&&A.canBlockReload?this.requestScheduled=y.loading.first+o-(A.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+o this.loadPlaylist(p),d)}else this.clearTimer()}getDeliveryDirectives(e,s,u,A){let y=J_(e,u);return s!=null&&s.skip&&e.deltaUpdateFailed&&(u=s.msn,A=s.part,y=Ca.No),new Bh(u,A,y)}checkRetry(e){const s=e.details,u=Oo(e),A=e.errorAction,{action:y,retryCount:l=0,retryConfig:c}=A||{},p=!!A&&!!c&&(y===Vn.RetryRequest||!A.resolved&&y===Vn.SendAlternateToPenaltyBox);if(p){var r;if(this.requestScheduled=-1,l>=c.maxNumRetry)return!1;if(u&&(r=e.context)!=null&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${c.maxNumRetry} after "${s}" without delivery-directives`),this.loadPlaylist();else{const i=wd(c,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),i),this.warn(`Retrying playlist loading ${l+1}/${c.maxNumRetry} after "${s}" in ${i}ms`)}e.levelRetry=!0,A.resolved=!0}return p}}class js{constructor(e,s=0,u=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=s,this.totalWeight_=u}sample(e,s){const u=Math.pow(this.alpha_,e);this.estimate_=s*(1-u)+u*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class o5{constructor(e,s,u,A=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=u,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new js(e),this.fast_=new js(s),this.defaultTTFB_=A,this.ttfb_=new js(e)}update(e,s){const{slow_:u,fast_:A,ttfb_:y}=this;u.halfLife!==e&&(this.slow_=new js(e,u.getEstimate(),u.getTotalWeight())),A.halfLife!==s&&(this.fast_=new js(s,A.getEstimate(),A.getTotalWeight())),y.halfLife!==e&&(this.ttfb_=new js(e,y.getEstimate(),y.getTotalWeight()))}sample(e,s){e=Math.max(e,this.minDelayMs_);const u=8*s,A=e/1e3,y=u/A;this.fast_.sample(A,y),this.slow_.sample(A,y)}sampleTTFB(e){const s=e/1e3,u=Math.sqrt(2)*Math.exp(-Math.pow(s,2)/2);this.ttfb_.sample(u,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const Hp={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},jh={};function l5(_,e,s,u,A,y){const l=_.audioCodec?_.audioGroups:null,c=y==null?void 0:y.audioCodec,p=y==null?void 0:y.channels,r=p?parseInt(p):c?1/0:2;let i=null;if(l!=null&&l.length)try{l.length===1&&l[0]?i=e.groups[l[0]].channels:i=l.reduce((t,n)=>{if(n){const a=e.groups[n];if(!a)throw new Error(`Audio track group ${n} not found`);Object.keys(a.channels).forEach(o=>{t[o]=(t[o]||0)+a.channels[o]})}return t},{2:0})}catch{return!0}return _.videoCodec!==void 0&&(_.width>1920&&_.height>1088||_.height>1920&&_.width>1088||_.frameRate>Math.max(u,30)||_.videoRange!=="SDR"&&_.videoRange!==s||_.bitrate>Math.max(A,8e6))||!!i&&Ci(r)&&Object.keys(i).some(t=>parseInt(t)>r)}function c5(_,e,s){const u=_.videoCodec,A=_.audioCodec;if(!u||!A||!s)return Promise.resolve(Hp);const y={width:_.width,height:_.height,bitrate:Math.ceil(Math.max(_.bitrate*.9,_.averageBitrate)),framerate:_.frameRate||30},l=_.videoRange;l!=="SDR"&&(y.transferFunction=l.toLowerCase());const c=u.split(",").map(p=>({type:"media-source",video:Dn(Dn({},y),{},{contentType:La(p,"video")})}));return A&&_.audioGroups&&_.audioGroups.forEach(p=>{var r;p&&((r=e.groups[p])==null||r.tracks.forEach(i=>{if(i.groupId===p){const t=i.channels||"",n=parseFloat(t);Ci(n)&&n>2&&c.push.apply(c,A.split(",").map(a=>({type:"media-source",audio:{contentType:La(a,"audio"),channels:""+n}})))}}))}),Promise.all(c.map(p=>{const r=d5(p);return jh[r]||(jh[r]=s.decodingInfo(p))})).then(p=>({supported:!p.some(r=>!r.supported),configurations:c,decodingInfoResults:p})).catch(p=>({supported:!1,configurations:c,decodingInfoResults:[],error:p}))}function d5(_){const{audio:e,video:s}=_,u=s||e;if(u){const A=u.contentType.split('"')[1];if(s)return`r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction||"sd"}_${A}_${Math.ceil(s.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${A}`}return""}function u5(){if(typeof matchMedia=="function"){const _=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(_.media!==e.media)return _.matches===!0}return!1}function h5(_,e){let s=!1,u=[];return _&&(s=_!=="SDR",u=[_]),e&&(u=e.allowedVideoRanges||Do.slice(0),s=e.preferHDR!==void 0?e.preferHDR:u5(),s?u=u.filter(A=>A!=="SDR"):u=["SDR"]),{preferHDR:s,allowedVideoRanges:u}}function f5(_,e,s,u,A){const y=Object.keys(_),l=u==null?void 0:u.channels,c=u==null?void 0:u.audioCodec,p=l&&parseInt(l)===2;let r=!0,i=!1,t=1/0,n=1/0,a=1/0,o=0,d=[];const{preferHDR:g,allowedVideoRanges:m}=h5(e,A);for(let C=y.length;C--;){const D=_[y[C]];r=D.channels[2]>0,t=Math.min(t,D.minHeight),n=Math.min(n,D.minFramerate),a=Math.min(a,D.minBitrate);const R=m.filter(T=>D.videoRanges[T]>0);R.length>0&&(i=!0,d=R)}t=Ci(t)?t:0,n=Ci(n)?n:0;const v=Math.max(1080,t),b=Math.max(30,n);return a=Ci(a)?a:s,s=Math.max(a,s),i||(e=void 0,d=[]),{codecSet:y.reduce((C,D)=>{const R=_[D];if(D===C)return C;if(R.minBitrate>s)return Yr(D,`min bitrate of ${R.minBitrate} > current estimate of ${s}`),C;if(!R.hasDefaultAudio)return Yr(D,"no renditions with default or auto-select sound found"),C;if(c&&D.indexOf(c.substring(0,4))%5!==0)return Yr(D,`audio codec preference "${c}" not found`),C;if(l&&!p){if(!R.channels[l])return Yr(D,`no renditions with ${l} channel sound found (channels options: ${Object.keys(R.channels)})`),C}else if((!c||p)&&r&&R.channels[2]===0)return Yr(D,"no renditions with stereo sound found"),C;return R.minHeight>v?(Yr(D,`min resolution of ${R.minHeight} > maximum of ${v}`),C):R.minFramerate>b?(Yr(D,`min framerate of ${R.minFramerate} > maximum of ${b}`),C):d.some(T=>R.videoRanges[T]>0)?R.maxScore =Io(C)||R.fragmentError>_[C].fragmentError)?C:(o=R.maxScore,D):(Yr(D,`no variants with VIDEO-RANGE of ${JSON.stringify(d)} found`),C)},void 0),videoRanges:d,preferHDR:g,minFramerate:n,minBitrate:a}}function Yr(_,e){Ft.log(`[abr] start candidates with "${_}" ignored because ${e}`)}function p5(_){return _.reduce((e,s)=>{let u=e.groups[s.groupId];u||(u=e.groups[s.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),u.tracks.push(s);const A=s.channels||"2";return u.channels[A]=(u.channels[A]||0)+1,u.hasDefault=u.hasDefault||s.default,u.hasAutoSelect=u.hasAutoSelect||s.autoselect,u.hasDefault&&(e.hasDefaultAudio=!0),u.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function m5(_,e,s,u){return _.slice(s,u+1).reduce((A,y)=>{if(!y.codecSet)return A;const l=y.audioGroups;let c=A[y.codecSet];c||(A[y.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!l,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,y.bitrate);const p=Math.min(y.height,y.width);return c.minHeight=Math.min(c.minHeight,p),c.minFramerate=Math.min(c.minFramerate,y.frameRate),c.maxScore=Math.max(c.maxScore,y.score),c.fragmentError+=y.fragmentError,c.videoRanges[y.videoRange]=(c.videoRanges[y.videoRange]||0)+1,l&&l.forEach(r=>{if(!r)return;const i=e.groups[r];c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach(t=>{c.channels[t]=(c.channels[t]||0)+i.channels[t]})}),A},{})}function jr(_,e,s){if("attrs"in _){const u=e.indexOf(_);if(u!==-1)return u}for(let u=0;u u.indexOf(A)===-1)}function Vs(_,e){const{audioCodec:s,channels:u}=_;return(s===void 0||(e.audioCodec||"").substring(0,4)===s.substring(0,4))&&(u===void 0||u===(e.channels||"2"))}function A5(_,e,s,u,A){const y=e[u],c=e.reduce((n,a,o)=>{const d=a.uri;return(n[d]||(n[d]=[])).push(o),n},{})[y.uri];c.length>1&&(u=Math.max.apply(Math,c));const p=y.videoRange,r=y.frameRate,i=y.codecSet.substring(0,4),t=Vh(e,u,n=>{if(n.videoRange!==p||n.frameRate!==r||n.codecSet.substring(0,4)!==i)return!1;const a=n.audioGroups,o=s.filter(d=>!a||a.indexOf(d.groupId)!==-1);return jr(_,o,A)>-1});return t>-1?t:Vh(e,u,n=>{const a=n.audioGroups,o=s.filter(d=>!a||a.indexOf(d.groupId)!==-1);return jr(_,o,A)>-1})}function Vh(_,e,s){for(let u=e;u;u--)if(s(_[u]))return u;for(let u=e+1;u<_.length;u++)if(s(_[u]))return u;return-1}class y5{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:s,partCurrent:u,hls:A}=this,{autoLevelEnabled:y,media:l}=A;if(!s||!l)return;const c=performance.now(),p=u?u.stats:s.stats,r=u?u.duration:s.duration,i=c-p.loading.start,t=A.minAutoLevel;if(p.aborted||p.loaded&&p.loaded===p.total||s.level<=t){this.clearTimer(),this._nextAutoLevel=-1;return}if(!y||l.paused||!l.playbackRate||!l.readyState)return;const n=A.mainForwardBufferInfo;if(n===null)return;const a=this.bwEstimator.getEstimateTTFB(),o=Math.abs(l.playbackRate);if(i<=Math.max(a,1e3*(r/(o*2))))return;const d=n.len/o,g=p.loading.first?p.loading.first-p.loading.start:-1,m=p.loaded&&g>-1,v=this.getBwEstimate(),b=A.levels,w=b[s.level],C=p.total||Math.max(p.loaded,Math.round(r*w.maxBitrate/8));let D=m?i-g:i;D<1&&m&&(D=Math.min(i,p.loaded*8/v));const R=m?p.loaded*1e3/D:0,T=R?(C-p.loaded)/R:C*8/v+a/1e3;if(T<=d)return;const P=R?R*8:v;let L=Number.POSITIVE_INFINITY,I;for(I=s.level-1;I>t;I--){const O=b[I].maxBitrate;if(L=this.getTimeToLoadFrag(a/1e3,P,r*O,!b[I].details),L =T||L>r*10)return;A.nextLoadLevel=A.nextAutoLevel=I,m?this.bwEstimator.sample(i-Math.min(a,g),p.loaded):this.bwEstimator.sampleTTFB(i);const x=b[I].bitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>x&&this.resetEstimator(x),this.clearTimer(),Ft.warn(`[abr] Fragment ${s.sn}${u?" part "+u.index:""} of level ${s.level} is loading too slowly; Time to underbuffer: ${d.toFixed(3)} s Estimated load time for current fragment: ${T.toFixed(3)} s Estimated load time for down switch fragment: ${L.toFixed(3)} s TTFB estimate: ${g|0} ms Current BW estimate: ${Ci(v)?v|0:"Unknown"} bps New BW estimate: ${this.getBwEstimate()|0} bps - Switching to level ${I} @ ${x|0} bps`),y.trigger(rt.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:u,stats:p})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(Ft.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new a5(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.FRAG_LOADING,this.onFragLoading,this),e.on(rt.FRAG_LOADED,this.onFragLoaded,this),e.on(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rt.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(rt.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rt.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rt.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(rt.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.FRAG_LOADING,this.onFragLoading,this),e.off(rt.FRAG_LOADED,this.onFragLoaded,this),e.off(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rt.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(rt.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rt.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rt.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(rt.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,s){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,s){const u=s.frag;if(!this.ignoreFragment(u)){if(!u.bitrateTest){var y;this.fragCurrent=u,this.partCurrent=(y=s.part)!=null?y:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,s){this.clearTimer()}onError(e,s){if(!s.fatal)switch(s.details){case qt.BUFFER_ADD_CODEC_ERROR:case qt.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case qt.FRAG_LOAD_TIMEOUT:{const u=s.frag,{fragCurrent:y,partCurrent:A}=this;if(u&&y&&u.sn===y.sn&&u.level===y.level){const l=performance.now(),c=A?A.stats:u.stats,p=l-c.loading.start,r=c.loading.first?c.loading.first-c.loading.start:-1;if(c.loaded&&r>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(p-Math.min(t,r),c.loaded)}else this.bwEstimator.sampleTTFB(p)}break}}}getTimeToLoadFrag(e,s,u,y){const A=e+u/s,l=y?this.lastLevelLoadSec:0;return A+l}onLevelLoaded(e,s){const u=this.hls.config,{loading:y}=s.stats,A=y.end-y.start;Ci(A)&&(this.lastLevelLoadSec=A/1e3),s.details.live?this.bwEstimator.update(u.abrEwmaSlowLive,u.abrEwmaFastLive):this.bwEstimator.update(u.abrEwmaSlowVoD,u.abrEwmaFastVoD)}onFragLoaded(e,{frag:s,part:u}){const y=u?u.stats:s.stats;if(s.type===Hi.MAIN&&this.bwEstimator.sampleTTFB(y.loading.first-y.loading.start),!this.ignoreFragment(s)){if(this.clearTimer(),s.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const A=u?u.duration:s.duration,l=this.hls.levels[s.level],c=(l.loaded?l.loaded.bytes:0)+y.loaded,p=(l.loaded?l.loaded.duration:0)+A;l.loaded={bytes:c,duration:p},l.realBitrate=Math.round(8*c/p)}if(s.bitrateTest){const A={stats:y,frag:s,part:u,id:s.type};this.onFragBuffered(rt.FRAG_BUFFERED,A),s.bitrateTest=!1}else this.lastLoadedFragLevel=s.level}}onFragBuffered(e,s){const{frag:u,part:y}=s,A=y!=null&&y.stats.loaded?y.stats:u.stats;if(A.aborted||this.ignoreFragment(u))return;const l=A.parsing.end-A.loading.start-Math.min(A.loading.first-A.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,A.loaded),A.bwEstimate=this.getBwEstimate(),u.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Hi.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:s}=this.hls,u=this.getBwEstimate(),y=this.hls.config.maxStarvationDelay,A=this.findBestLevel(u,s,e,0,y,1,1);if(A>-1)return A;const l=this.hls.firstLevel,c=Math.min(Math.max(l,s),e);return Ft.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${l} clamped to ${c}`),c}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,u=this.bwEstimator.canEstimate(),y=this.lastLoadedFragLevel>-1;if(e!==-1&&(!u||!y||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const A=u&&y?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const l=this.hls.levels;if(l.length>Math.max(e,A)&&l[e].loadError<=l[A].loadError)return e}return this._nextAutoLevel=A,this.nextAutoLevelKey=this.getAutoLevelKey(),A}getAutoLevelKey(){var e;return`${this.getBwEstimate()}_${(e=this.hls.mainForwardBufferInfo)==null?void 0:e.len}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:s,hls:u}=this,{maxAutoLevel:y,config:A,minAutoLevel:l,media:c}=u,p=s?s.duration:e?e.duration:0,r=c&&c.playbackRate!==0?Math.abs(c.playbackRate):1,i=this.getBwEstimate(),t=u.mainForwardBufferInfo,n=(t?t.len:0)/r;let a=A.abrBandWidthFactor,o=A.abrBandWidthUpFactor;if(n){const b=this.findBestLevel(i,l,y,n,0,a,o);if(b>=0)return b}let d=p?Math.min(p,A.maxStarvationDelay):A.maxStarvationDelay;if(!n){const b=this.bitrateTestDelay;b&&(d=(p?Math.min(p,A.maxLoadingDelay):A.maxLoadingDelay)-b,Ft.info(`[abr] bitrate test took ${Math.round(1e3*b)}ms, set first fragment max fetchDuration to ${Math.round(1e3*d)} ms`),a=o=1)}const g=this.findBestLevel(i,l,y,n,d,a,o);if(Ft.info(`[abr] ${n?"rebuffering expected":"buffer is empty"}, optimal quality level ${g}`),g>-1)return g;const m=u.levels[l],v=u.levels[u.loadLevel];return(m==null?void 0:m.bitrate)<(v==null?void 0:v.bitrate)?l:u.loadLevel}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,s,u,y,A,l,c){var p;const r=y+A,i=this.lastLoadedFragLevel,t=i===-1?this.hls.firstLevel:i,{fragCurrent:n,partCurrent:a}=this,{levels:o,allAudioTracks:d,loadLevel:g,config:m}=this.hls;if(o.length===1)return 0;const v=o[t],b=!!(v!=null&&(p=v.details)!=null&&p.live),w=g===-1||i===-1;let C,D="SDR",R=(v==null?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:P}=m,L=this.audioTracksByGroup||(this.audioTracksByGroup=f5(d));if(w){if(this.firstSelection!==-1)return this.firstSelection;const te=this.codecTiers||(this.codecTiers=p5(o,L,s,u)),le=h5(te,D,e,T,P),{codecSet:ne,videoRanges:ee,minFramerate:M,minBitrate:Y,preferHDR:j}=le;C=ne,D=j?ee[ee.length-1]:ee[0],R=M,e=Math.max(e,Y),Ft.log(`[abr] picked start tier ${JSON.stringify(le)}`)}else C=v==null?void 0:v.codecSet,D=v==null?void 0:v.videoRange;const I=a?a.duration:n?n.duration:0,x=this.bwEstimator.getEstimateTTFB()/1e3,O=[];for(let te=u;te>=s;te--){var G,J;const le=o[te],ne=te>t;if(!le)continue;if(m.useMediaCapabilities&&!le.supportedResult&&!le.supportedPromise){const Z=navigator.mediaCapabilities;typeof(Z==null?void 0:Z.decodingInfo)=="function"&&o5(le,L,D,R,e,T)?(le.supportedPromise=l5(le,L,Z),le.supportedPromise.then(X=>{le.supportedResult=X;const oe=this.hls.levels,he=oe.indexOf(le);X.error?Ft.warn(`[abr] MediaCapabilities decodingInfo error: "${X.error}" for level ${he} ${JSON.stringify(X)}`):X.supported||(Ft.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${he} ${JSON.stringify(X)}`),he>-1&&oe.length>1&&(Ft.log(`[abr] Removing unsupported level ${he}`),this.hls.removeLevel(he)))})):le.supportedResult=Hp}if(C&&le.codecSet!==C||D&&le.videoRange!==D||ne&&R>le.frameRate||!ne&&R>0&&R =I*2&&A===0?o[te].averageBitrate:o[te].maxBitrate,z=this.getTimeToLoadFrag(x,Y,j*M,ee===void 0);if(Y>=j&&(te===i||le.loadError===0&&le.fragmentError===0)&&(z<=x||!Ci(z)||b&&!this.bitrateTestDelay||z ${te} adjustedbw(${Math.round(Y)})-bitrate=${Math.round(Y-j)} ttfb:${x.toFixed(1)} avgDuration:${M.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${z.toFixed(1)} firstSelection:${w} codecSet:${C} videoRange:${D} hls.loadLevel:${g}`)),w&&(this.firstSelection=te),te}}return-1}set nextAutoLevel(e){const s=Math.max(this.hls.minAutoLevel,e);this._nextAutoLevel!=s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}class y5{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var Fn={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class v5{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(rt.BUFFER_APPENDED,this.onBufferAppended,this),e.on(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rt.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(rt.BUFFER_APPENDED,this.onBufferAppended,this),e.off(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rt.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,s){const u=this.activePartLists[s];if(u)for(let y=u.length;y--;){const A=u[y];if(!A)break;const l=A.end;if(A.start<=e&&l!==null&&e<=l)return A}return this.getBufferedFrag(e,s)}getBufferedFrag(e,s){const{fragments:u}=this,y=Object.keys(u);for(let A=y.length;A--;){const l=u[y[A]];if((l==null?void 0:l.body.type)===s&&l.buffered){const c=l.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,s,u,y){this.timeRanges&&(this.timeRanges[e]=s);const A=(y==null?void 0:y.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const c=this.fragments[l];if(!c||A>=c.body.sn)return;if(!c.buffered&&!c.loaded){c.body.type===u&&this.removeFragment(c.body);return}const p=c.range[e];p&&p.time.some(r=>{const i=!this.isTimeBuffered(r.startPTS,r.endPTS,s);return i&&this.removeFragment(c.body),i})})}detectPartialFragments(e){const s=this.timeRanges,{frag:u,part:y}=e;if(!s||u.sn==="initSegment")return;const A=Hs(u),l=this.fragments[A];if(!l||l.buffered&&u.gap)return;const c=!u.relurl;Object.keys(s).forEach(p=>{const r=u.elementaryStreams[p];if(!r)return;const i=s[p],t=c||r.partial===!0;l.range[p]=this.getBufferedTimes(u,y,t,i)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=u.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),eo(l)||this.removeParts(u.sn-1,u.type)):this.removeFragment(l.body)}removeParts(e,s){const u=this.activePartLists[s];u&&(this.activePartLists[s]=u.filter(y=>y.fragment.sn>=e))}fragBuffered(e,s){const u=Hs(e);let y=this.fragments[u];!y&&s&&(y=this.fragments[u]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),y&&(y.loaded=null,y.buffered=!0)}getBufferedTimes(e,s,u,y){const A={time:[],partial:u},l=e.start,c=e.end,p=e.minEndPTS||c,r=e.maxStartPTS||l;for(let i=0;i =t&&p<=n){A.time.push({startPTS:Math.max(l,y.start(i)),endPTS:Math.min(c,y.end(i))});break}else if(l t){const a=Math.max(l,y.start(i)),o=Math.min(c,y.end(i));o>a&&(A.partial=!0,A.time.push({startPTS:a,endPTS:o}))}else if(c<=t)break}return A}getPartialFragment(e){let s=null,u,y,A,l=0;const{bufferPadding:c,fragments:p}=this;return Object.keys(p).forEach(r=>{const i=p[r];i&&eo(i)&&(y=i.body.start-c,A=i.body.end+c,e>=y&&e<=A&&(u=Math.min(e-y,A-e),l<=u&&(s=i.body,l=u)))}),s}isEndListAppended(e){const s=this.endListFragments[e];return s!==void 0&&(s.buffered||eo(s))}getState(e){const s=Hs(e),u=this.fragments[s];return u?u.buffered?eo(u)?Fn.PARTIAL:Fn.OK:Fn.APPENDING:Fn.NOT_LOADED}isTimeBuffered(e,s,u){let y,A;for(let l=0;l =y&&s<=A)return!0;if(s<=y)return!1}return!1}onFragLoaded(e,s){const{frag:u,part:y}=s;if(u.sn==="initSegment"||u.bitrateTest)return;const A=y?null:s,l=Hs(u);this.fragments[l]={body:u,appendedPTS:null,loaded:A,buffered:!1,range:Object.create(null)}}onBufferAppended(e,s){const{frag:u,part:y,timeRanges:A}=s;if(u.sn==="initSegment")return;const l=u.type;if(y){let c=this.activePartLists[l];c||(this.activePartLists[l]=c=[]),c.push(y)}this.timeRanges=A,Object.keys(A).forEach(c=>{const p=A[c];this.detectEvictedFragments(c,p,l,y)})}onFragBuffered(e,s){this.detectPartialFragments(s)}hasFragment(e){const s=Hs(e);return!!this.fragments[s]}hasParts(e){var s;return!!((s=this.activePartLists[e])!=null&&s.length)}removeFragmentsInRange(e,s,u,y,A){y&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const c=this.fragments[l];if(!c)return;const p=c.body;p.type!==u||y&&!p.gap||p.start e&&(c.buffered||A)&&this.removeFragment(p)})}removeFragment(e){const s=Hs(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const u=this.activePartLists[e.type];if(u){const y=e.sn;this.activePartLists[e.type]=u.filter(A=>A.fragment.sn!==y)}delete this.fragments[s],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function eo(_){var e,s,u;return _.buffered&&(_.body.gap||((e=_.range.video)==null?void 0:e.partial)||((s=_.range.audio)==null?void 0:s.partial)||((u=_.range.audiovideo)==null?void 0:u.partial))}function Hs(_){return`${_.type}_${_.level}_${_.sn}`}const b5={length:0,start:()=>0,end:()=>0};class mn{static isBuffered(e,s){try{if(e){const u=mn.getBuffered(e);for(let y=0;y=u.start(y)&&s<=u.end(y))return!0}}catch{}return!1}static bufferInfo(e,s,u){try{if(e){const y=mn.getBuffered(e),A=[];let l;for(l=0;l t&&(y[i-1].end=e[r].end):y.push(e[r])}else y.push(e[r])}else y=e;let A=0,l,c=s,p=s;for(let r=0;r =i&&s s.startCC||_&&_.cc {if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(a=>a[0]==="GAP")){p(Kh(e));return}else e.gap=!1;const r=this.loader=e.loader=A?new A(y):new l(y),i=Wh(e),t=Gh(y.fragLoadPolicy.default),n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:zh};e.stats=r.stats,r.load(i,n,{onSuccess:(a,o,d,g)=>{this.resetLoader(e,r);let m=a.data;d.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(m.slice(0,16)),m=m.slice(16)),c({frag:e,part:null,payload:m,networkDetails:g})},onError:(a,o,d,g)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Dn({url:u,data:void 0},a),error:new Error(`HTTP Error ${a.code} ${a.text}`),networkDetails:d,stats:g}))},onAbort:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:d,stats:a}))},onTimeout:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:d,stats:a}))},onProgress:(a,o,d,g)=>{s&&s({frag:e,part:null,payload:d,networkDetails:g})}})})}loadPart(e,s,u){this.abort();const y=this.config,A=y.fLoader,l=y.loader;return new Promise((c,p)=>{if(this.loader&&this.loader.destroy(),e.gap||s.gap){p(Kh(e,s));return}const r=this.loader=e.loader=A?new A(y):new l(y),i=Wh(e,s),t=Gh(y.fragLoadPolicy.default),n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:zh};s.stats=r.stats,r.load(i,n,{onSuccess:(a,o,d,g)=>{this.resetLoader(e,r),this.updateStatsFromPart(e,s);const m={frag:e,part:s,payload:a.data,networkDetails:g};u(m),c(m)},onError:(a,o,d,g)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:s,response:Dn({url:i.url,data:void 0},a),error:new Error(`HTTP Error ${a.code} ${a.text}`),networkDetails:d,stats:g}))},onAbort:(a,o,d)=>{e.stats.aborted=s.stats.aborted,this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.INTERNAL_ABORTED,fatal:!1,frag:e,part:s,error:new Error("Aborted"),networkDetails:d,stats:a}))},onTimeout:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:s,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:d,stats:a}))}})})}updateStatsFromPart(e,s){const u=e.stats,y=s.stats,A=y.total;if(u.loaded+=y.loaded,A){const p=Math.round(e.duration/s.duration),r=Math.min(Math.round(u.loaded/A),p),t=(p-r)*Math.round(u.loaded/r);u.total=u.loaded+t}else u.total=Math.max(u.loaded,u.total);const l=u.loading,c=y.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end}resetLoader(e,s){e.loader=null,this.loader===s&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),s.destroy()}}function Wh(_,e=null){const s=e||_,u={frag:_,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},y=s.byteRangeStartOffset,A=s.byteRangeEndOffset;if(Ci(y)&&Ci(A)){var l;let c=y,p=A;if(_.sn==="initSegment"&&((l=_.decryptdata)==null?void 0:l.method)==="AES-128"){const r=A-y;r%16&&(p=A+(16-r%16)),y!==0&&(u.resetIV=!0,c=y-16)}u.rangeStart=c,u.rangeEnd=p}return u}function Kh(_,e){const s=new Error(`GAP ${_.gap?"tag":"attribute"} found`),u={type:Wi.MEDIA_ERROR,details:qt.FRAG_GAP,fatal:!1,frag:_,error:s,networkDetails:null};return e&&(u.part=e),(e||_).stats.aborted=!0,new Qr(u)}class Qr extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class C5{constructor(e,s){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=s}decrypt(e,s){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},s,e)}}class x5{constructor(e,s){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=s}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function k5(_){const e=_.byteLength,s=e&&new DataView(_.buffer).getUint8(e-1);return s?Ts(_,0,e-s):_}class R5{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const s=new DataView(e),u=new Uint32Array(4);for(let y=0;y<4;y++)u[y]=s.getUint32(y*4);return u}initTable(){const e=this.sBox,s=this.invSBox,u=this.subMix,y=u[0],A=u[1],l=u[2],c=u[3],p=this.invSubMix,r=p[0],i=p[1],t=p[2],n=p[3],a=new Uint32Array(256);let o=0,d=0,g=0;for(g=0;g<256;g++)g<128?a[g]=g<<1:a[g]=g<<1^283;for(g=0;g<256;g++){let m=d^d<<1^d<<2^d<<3^d<<4;m=m>>>8^m&255^99,e[o]=m,s[m]=o;const v=a[o],b=a[v],w=a[b];let C=a[m]*257^m*16843008;y[o]=C<<24|C>>>8,A[o]=C<<16|C>>>16,l[o]=C<<8|C>>>24,c[o]=C,C=w*16843009^b*65537^v*257^o*16843008,r[m]=C<<24|C>>>8,i[m]=C<<16|C>>>16,t[m]=C<<8|C>>>24,n[m]=C,o?(o=v^a[a[a[w^v]]],d^=a[a[d]]):o=d=1}}expandKey(e){const s=this.uint8ArrayToUint32Array_(e);let u=!0,y=0;for(;y y?(this.logOnce("WebCrypto AES decrypt"),new C5(y,new Uint8Array(u)).decrypt(e.buffer,A)):Promise.reject(new Error("web crypto not initialized"))).catch(A=>(Ft.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${A.name}: ${A.message}`),this.onWebCryptoError(e,s,u)))}onWebCryptoError(e,s,u){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,s,u);const y=this.flush();if(y)return y.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let s=e;const u=e.length-e.length%I5;return u!==e.length&&(s=Ts(e,0,u),this.remainderData=Ts(e,u)),s}logOnce(e){this.logEnabled&&(Ft.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const L5={toString:function(_){let e="";const s=_.length;for(let u=0;u c.end){const t=l>i;(l{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${A.part?" p: "+A.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(A)};this._doFragLoad(e,s,u,y).then(A=>{if(!A)return;const l=this.state;if(this.fragContextChanged(e)){(l===ni.FRAG_LOADING||!this.fragCurrent&&l===ni.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=ni.IDLE);return}"payload"in A&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(rt.FRAG_LOADED,A)),this._handleFragmentLoadComplete(A)}).catch(A=>{this.state===ni.STOPPED||this.state===ni.ERROR||(this.warn(A),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var s;const{fragmentTracker:u}=this;if(u.getState(e)===Fn.APPENDING){const A=e.type,l=this.getFwdBufferInfo(this.mediaBuffer,A),c=Math.max(e.duration,l?l.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&u.removeFragment(e)}else((s=this.mediaBuffer)==null?void 0:s.buffered.length)===0?u.removeAllFragments():u.hasParts(e.type)&&(u.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),u.getState(e)===Fn.PARTIAL&&u.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const s=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:s,part:null,stats:s.stats,id:s.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,s,u=null){if(!(e-s))return;const y={startOffset:e,endOffset:s,type:u};this.hls.trigger(rt.BUFFER_FLUSHING,y)}_loadInitSegment(e,s){this._doFragLoad(e,s).then(u=>{if(!u||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return u}).then(u=>{const{hls:y}=this,{payload:A}=u,l=e.decryptdata;if(A&&A.byteLength>0&&l!=null&&l.key&&l.iv&&l.method==="AES-128"){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(A),l.key.buffer,l.iv.buffer).catch(p=>{throw y.trigger(rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_DECRYPT_ERROR,fatal:!1,error:p,reason:p.message,frag:e}),p}).then(p=>{const r=self.performance.now();return y.trigger(rt.FRAG_DECRYPTED,{frag:e,payload:p,stats:{tstart:c,tdecrypt:r}}),u.payload=p,this.completeInitSegmentLoad(u)})}return this.completeInitSegmentLoad(u)}).catch(u=>{this.state===ni.STOPPED||this.state===ni.ERROR||(this.warn(u),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:s}=this;if(!s)throw new Error("init load aborted, missing levels");const u=e.frag.stats;this.state=ni.IDLE,e.frag.data=new Uint8Array(e.payload),u.parsing.start=u.buffering.start=self.performance.now(),u.parsing.end=u.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:s}=this;return!e||!s||e.sn!==s.sn||e.level!==s.level}fragBufferedComplete(e,s){var u,y,A,l;const c=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${s?" part: "+s.index:""} of ${this.playlistType===Hi.MAIN?"level":"track"} ${e.level} (frag:[${((u=e.startPTS)!=null?u:NaN).toFixed(3)}-${((y=e.endPTS)!=null?y:NaN).toFixed(3)}] > buffer:${c?L5.toString(mn.getBuffered(c)):"(detached)"})`),e.sn!=="initSegment"){var p;if(e.type!==Hi.SUBTITLE){const i=e.elementaryStreams;if(!Object.keys(i).some(t=>!!i[t])){this.state=ni.IDLE;return}}const r=(p=this.levels)==null?void 0:p[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=ni.IDLE,c&&(!this.loadedmetadata&&e.type==Hi.MAIN&&c.buffered.length&&((A=this.fragCurrent)==null?void 0:A.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:s}=this;if(!s)return;const{frag:u,part:y,partsLoaded:A}=e,l=!A||A.length===0||A.some(p=>!p),c=new Td(u.level,u.sn,u.stats.chunkCount+1,0,y?y.index:-1,!l);s.flush(c)}_handleFragmentLoadProgress(e){}_doFragLoad(e,s,u=null,y){var A;const l=s==null?void 0:s.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let c=null;if(e.encrypted&&!((A=e.decryptdata)!=null&&A.key)?(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=ni.KEY_LOADING,this.fragCurrent=e,c=this.keyLoader.load(e).then(i=>{if(!this.fragContextChanged(i.frag))return this.hls.trigger(rt.KEY_LOADED,i),this.state===ni.KEY_LOADING&&(this.state=ni.IDLE),i}),this.hls.trigger(rt.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(c=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(e,l.encryptedFragments),u=Math.max(e.start,u||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const i=l.partList;if(i&&y){u>e.end&&l.fragmentHint&&(e=l.fragmentHint);const t=this.getNextPart(i,e,u);if(t>-1){const n=i[t];this.log(`Loading part sn: ${e.sn} p: ${n.index} cc: ${e.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${t}-${i.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(u.toFixed(3))}`),this.nextLoadPosition=n.start+n.duration,this.state=ni.FRAG_LOADING;let a;return c?a=c.then(o=>!o||this.fragContextChanged(o.frag)?null:this.doFragPartsLoad(e,n,s,y)).catch(o=>this.handleFragLoadError(o)):a=this.doFragPartsLoad(e,n,s,y).catch(o=>this.handleFragLoadError(o)),this.hls.trigger(rt.FRAG_LOADING,{frag:e,part:n,targetBufferTime:u}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):a}else if(!e.url||this.loadedEndOfParts(i,u))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(u.toFixed(3))}`),Ci(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ni.FRAG_LOADING;const p=this.config.progressive;let r;return p&&c?r=c.then(i=>!i||this.fragContextChanged(i==null?void 0:i.frag)?null:this.fragmentLoader.load(e,y)).catch(i=>this.handleFragLoadError(i)):r=Promise.all([this.fragmentLoader.load(e,p?y:void 0),c]).then(([i])=>(!p&&i&&y&&y(i),i)).catch(i=>this.handleFragLoadError(i)),this.hls.trigger(rt.FRAG_LOADING,{frag:e,targetBufferTime:u}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):r}doFragPartsLoad(e,s,u,y){return new Promise((A,l)=>{var c;const p=[],r=(c=u.details)==null?void 0:c.partList,i=t=>{this.fragmentLoader.loadPart(e,t,y).then(n=>{p[t.index]=n;const a=n.part;this.hls.trigger(rt.FRAG_LOADED,n);const o=Fh(u,e.sn,t.index+1)||Gp(r,e.sn,t.index+1);if(o)i(o);else return A({frag:e,part:a,partsLoaded:p})}).catch(l)};i(s)})}handleFragLoadError(e){if("data"in e){const s=e.data;e.data&&s.details===qt.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(rt.ERROR,s)}else this.hls.trigger(rt.ERROR,{type:Wi.OTHER_ERROR,details:qt.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const s=this.getCurrentContext(e);if(!s||this.state!==ni.PARSING){!this.fragCurrent&&this.state!==ni.STOPPED&&this.state!==ni.ERROR&&(this.state=ni.IDLE);return}const{frag:u,part:y,level:A}=s,l=self.performance.now();u.stats.parsing.end=l,y&&(y.stats.parsing.end=l),this.updateLevelTiming(u,y,A,e.partial)}getCurrentContext(e){const{levels:s,fragCurrent:u}=this,{level:y,sn:A,part:l}=e;if(!(s!=null&&s[y]))return this.warn(`Levels object was unset while buffering fragment ${A} of level ${y}. The current chunk will not be buffered.`),null;const c=s[y],p=l>-1?Fh(c,A,l):null,r=p?p.fragment:e5(c,A,u);return r?(u&&u!==r&&(r.stats=u.stats),{frag:r,part:p,level:c}):null}bufferFragmentData(e,s,u,y,A){var l;if(!e||this.state!==ni.PARSING)return;const{data1:c,data2:p}=e;let r=c;if(c&&p&&(r=Ar(c,p)),!((l=r)!=null&&l.length))return;const i={type:e.type,frag:s,part:u,chunkMeta:y,parent:s.type,data:r};if(this.hls.trigger(rt.BUFFER_APPENDING,i),e.dropped&&e.independent&&!u){if(A)return;this.flushBufferGap(s)}}flushBufferGap(e){const s=this.media;if(!s)return;if(!mn.isBuffered(s,s.currentTime)){this.flushMainBuffer(0,e.start);return}const u=s.currentTime,y=mn.bufferInfo(s,u,0),A=e.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,A*.25),c=Math.max(Math.min(e.start-l,y.end-l),u+l);e.start-c>l&&this.flushMainBuffer(c,e.start)}getFwdBufferInfo(e,s){const u=this.getLoadPosition();return Ci(u)?this.getFwdBufferInfoAtPos(e,u,s):null}getFwdBufferInfoAtPos(e,s,u){const{config:{maxBufferHole:y}}=this,A=mn.bufferInfo(e,s,y);if(A.len===0&&A.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(s,u);if(l&&A.nextStart =u?(s.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${s.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,s=Hi.MAIN){const u=this.fragmentTracker.getAppendedFrag(e,Hi.MAIN);return u&&"fragment"in u?u.fragment:u}getNextFragment(e,s){const u=s.fragments,y=u.length;if(!y)return null;const{config:A}=this,l=u[0].start;let c;if(s.live){const p=A.initialLiveManifestSize;if(y s}getNextFragmentLoopLoading(e,s,u,y,A){const l=e.gap,c=this.getNextFragment(this.nextLoadPosition,s);if(c===null)return c;if(e=c,l&&e&&!e.gap&&u.nextStart){const p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,u.nextStart,y);if(p!==null&&u.len+p.len>=A)return this.log(`buffer full after gaps in "${y}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,s,u){let y=-1,A=!1,l=!0;for(let c=0,p=e.length;c
-1&&u
u.start&&u.loaded}getInitialLiveFragment(e,s){const u=this.fragPrevious;let y=null;if(u){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${u.programDateTime}`),y=i5(s,u.endProgramDateTime,this.config.maxFragLookUpTolerance)),!y){const A=u.sn+1;if(A>=e.startSN&&A<=e.endSN){const l=s[A-e.startSN];u.cc===l.cc&&(y=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${y.sn}`))}y||(y=r5(s,u.cc),y&&this.log(`Live playlist, switching playlist, load frag with same CC: ${y.sn}`))}}else{const A=this.hls.liveSyncPosition;A!==null&&(y=this.getFragmentAtPosition(A,this.bitrateTest?e.fragmentEnd:e.edge,e))}return y}getFragmentAtPosition(e,s,u){const{config:y}=this;let{fragPrevious:A}=this,{fragments:l,endSN:c}=u;const{fragmentHint:p}=u,r=y.maxFragLookUpTolerance,i=u.partList,t=!!(y.lowLatencyMode&&i!=null&&i.length&&p);t&&p&&!this.bitrateTest&&(l=l.concat(p),c=p.sn);let n;if(e s-r?0:r;n=Po(A,l,e,a)}else n=l[l.length-1];if(n){const a=n.sn-u.startSN,o=this.fragmentTracker.getState(n);if((o===Fn.OK||o===Fn.PARTIAL&&n.gap)&&(A=n),A&&n.sn===A.sn&&(!t||i[0].fragment.sn>n.sn)&&A&&n.level===A.level){const g=l[a+1];n.sn=l-s.maxFragLookUpTolerance&&A<=c;if(y!==null&&u.duration>y&&(A ${e.startSN} prev-sn: ${p?p.sn:"na"} fragments: ${y}`),r}return A}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,s){let u=this.startPosition;if(u ${(y=this.fragCurrent)==null?void 0:y.url}`);return}const A=s.details===qt.FRAG_GAP;A&&this.fragmentTracker.fragBuffered(u,!0);const l=s.errorAction,{action:c,retryCount:p=0,retryConfig:r}=l||{};if(l&&c===Vn.RetryRequest&&r){this.resetStartWhenNotLoaded(this.levelLastLoaded);const i=wd(r,p);this.warn(`Fragment ${u.sn} of ${e} ${u.level} errored with ${s.details}, retrying loading ${p+1}/${r.maxNumRetry} in ${i}ms`),l.resolved=!0,this.retryDate=self.performance.now()+i,this.state=ni.FRAG_LOADING_WAITING_RETRY}else if(r&&l)if(this.resetFragmentErrors(e),p.5;y&&this.reduceMaxBufferLength(u.len);const A=!y;return A&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${s} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),A}return!1}resetFragmentErrors(e){e===Hi.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ni.STOPPED&&(this.state=ni.IDLE)}afterBufferFlushed(e,s,u){if(!e)return;const y=mn.getBuffered(e);this.fragmentTracker.detectEvictedFragments(s,y,u),this.state===ni.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ni.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const s=e?e.details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,s,u,y){var A;const l=u.details;if(!l){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((p,r)=>{const i=e.elementaryStreams[r];if(i){const t=i.endPTS-i.startPTS;if(t<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${t})`),p||!1;const n=y?0:Fp(l,e,i.startPTS,i.endPTS,i.startDTS,i.endDTS);return this.hls.trigger(rt.LEVEL_PTS_UPDATED,{details:l,level:u,drift:n,type:r,frag:e,start:i.startPTS,end:i.endPTS}),!0}return p},!1)&&((A=this.transmuxer)==null?void 0:A.error)===null){const p=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(u.fragmentError===0&&(u.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(p.message),this.hls.trigger(rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!1,error:p,frag:e,reason:`Found no media in msn ${e.sn} of level "${u.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=ni.PARSED,this.hls.trigger(rt.FRAG_PARSED,{frag:e,part:s})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const s=this._state;s!==e&&(this._state=e,this.log(`${s}->${e}`))}get state(){return this._state}}class Wp{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:s}=this;let u;if(e.length)e.length===1?u=e[0]:u=D5(e,s);else return new Uint8Array(0);return this.reset(),u}reset(){this.chunks.length=0,this.dataLength=0}}function D5(_,e){const s=new Uint8Array(e);let u=0;for(let y=0;y<_.length;y++){const A=_[y];s.set(A,u),u+=A.length}return s}function O5(){return typeof __HLS_WORKER_BUNDLE__=="function"}function M5(){const _=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(_);return{worker:new self.Worker(e),objectURL:e}}function P5(_){const e=new self.URL(_,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Ur(_="",e=9e4){return{type:_,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class kd{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,s,u,y){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,s){return!1}appendFrame(e,s,u){}demux(e,s){this.cachedData&&(e=Ar(this.cachedData,e),this.cachedData=null);let u=Ra(e,0),y=u?u.length:0,A;const l=this._audioTrack,c=this._id3Track,p=u?_d(u):void 0,r=e.length;for((this.basePTS===null||this.frameIndex===0&&Ci(p))&&(this.basePTS=B5(p,s,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),u&&u.length>0&&c.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:xr.audioId3,duration:Number.POSITIVE_INFINITY});y {if(Ci(_))return _*90;const u=s?s.baseTime*9e4/s.timescale:0;return e*9e4+u};function N5(_,e,s,u){let y,A,l,c;const p=navigator.userAgent.toLowerCase(),r=u,i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];y=((e[s+2]&192)>>>6)+1;const t=(e[s+2]&60)>>>2;if(t>i.length-1){const n=new Error(`invalid ADTS sampling index:${t}`);_.emit(rt.ERROR,rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!0,error:n,reason:n.message});return}return l=(e[s+2]&1)<<2,l|=(e[s+3]&192)>>>6,Ft.log(`manifest codec:${u}, ADTS type:${y}, samplingIndex:${t}`),/firefox/i.test(p)?t>=6?(y=5,c=new Array(4),A=t-3):(y=2,c=new Array(2),A=t):p.indexOf("android")!==-1?(y=2,c=new Array(2),A=t):(y=5,c=new Array(4),u&&(u.indexOf("mp4a.40.29")!==-1||u.indexOf("mp4a.40.5")!==-1)||!u&&t>=6?A=t-3:((u&&u.indexOf("mp4a.40.2")!==-1&&(t>=6&&l===1||/vivaldi/i.test(p))||!u&&l===1)&&(y=2,c=new Array(2)),A=t)),c[0]=y<<3,c[0]|=(t&14)>>1,c[1]|=(t&1)<<7,c[1]|=l<<3,y===5&&(c[1]|=(A&14)>>1,c[2]=(A&1)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:i[t],channelCount:l,codec:"mp4a.40."+y,manifestCodec:r}}function Kp(_,e){return _[e]===255&&(_[e+1]&246)===240}function qp(_,e){return _[e+1]&1?7:9}function Rd(_,e){return(_[e+3]&3)<<11|_[e+4]<<3|(_[e+5]&224)>>>5}function F5(_,e){return e+5<_.length}function No(_,e){return e+1<_.length&&Kp(_,e)}function U5(_,e){return F5(_,e)&&Kp(_,e)&&Rd(_,e)<=_.length-e}function G5(_,e){if(No(_,e)){const s=qp(_,e);if(e+s>=_.length)return!1;const u=Rd(_,e);if(u<=s)return!1;const y=e+u;return y===_.length||No(_,y)}return!1}function Yp(_,e,s,u,y){if(!_.samplerate){const A=N5(e,s,u,y);if(!A)return;_.config=A.config,_.samplerate=A.samplerate,_.channelCount=A.channelCount,_.codec=A.codec,_.manifestCodec=A.manifestCodec,Ft.log(`parsed codec:${_.codec}, rate:${A.samplerate}, channels:${A.channelCount}`)}}function Jp(_){return 1024*9e4/_}function j5(_,e){const s=qp(_,e);if(e+s<=_.length){const u=Rd(_,e)-s;if(u>0)return{headerLength:s,frameLength:u}}}function Qp(_,e,s,u,y){const A=Jp(_.samplerate),l=u+y*A,c=j5(e,s);let p;if(c){const{frameLength:t,headerLength:n}=c,a=n+t,o=Math.max(0,s+a-e.length);o?(p=new Uint8Array(a-n),p.set(e.subarray(s+n,e.length),0)):p=e.subarray(s+n,s+a);const d={unit:p,pts:l};return o||_.samples.push(d),{sample:d,length:a,missing:o}}const r=e.length-s;return p=new Uint8Array(r),p.set(e.subarray(s,e.length),0),{sample:{unit:p,pts:l},length:r,missing:-1}}let io=null;const V5=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],H5=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],z5=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],W5=[0,1,1,4];function Zp(_,e,s,u,y){if(s+24>e.length)return;const A=Xp(e,s);if(A&&s+A.frameLength<=e.length){const l=A.samplesPerFrame*9e4/A.sampleRate,c=u+y*l,p={unit:e.subarray(s,s+A.frameLength),pts:c,dts:c};return _.config=[],_.channelCount=A.channelCount,_.samplerate=A.sampleRate,_.samples.push(p),{sample:p,length:A.frameLength,missing:0}}}function Xp(_,e){const s=_[e+1]>>3&3,u=_[e+1]>>1&3,y=_[e+2]>>4&15,A=_[e+2]>>2&3;if(s!==1&&y!==0&&y!==15&&A!==3){const l=_[e+2]>>1&1,c=_[e+3]>>6,p=s===3?3-u:u===3?3:4,r=V5[p*14+y-1]*1e3,t=H5[(s===3?0:s===2?1:2)*3+A],n=c===3?1:2,a=z5[s][u],o=W5[u],d=a*8*o,g=Math.floor(a*r/t+l)*o;if(io===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);io=b?parseInt(b[1]):0}return!!io&&io<=87&&u===2&&r>=224e3&&c===0&&(_[e+3]=_[e+3]|128),{sampleRate:t,channelCount:n,frameLength:g,samplesPerFrame:d}}}function Id(_,e){return _[e]===255&&(_[e+1]&224)===224&&(_[e+1]&6)!==0}function $p(_,e){return e+1<_.length&&Id(_,e)}function K5(_,e){return Id(_,e)&&4<=_.length-e}function e0(_,e){if(e+1<_.length&&Id(_,e)){const u=Xp(_,e);let y=4;u!=null&&u.frameLength&&(y=u.frameLength);const A=e+y;return A===_.length||$p(_,A)}return!1}class q5 extends kd{constructor(e,s){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=s}resetInitSegment(e,s,u,y){super.resetInitSegment(e,s,u,y),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:s,duration:y,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const s=Ra(e,0);let u=(s==null?void 0:s.length)||0;if(e0(e,u))return!1;for(let y=e.length;u {const l=T_(A);if(Y5.test(l.schemeIdUri)){const c=Ci(l.presentationTime)?l.presentationTime/l.timeScale:s+l.presentationTimeDelta/l.timeScale;let p=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;p<=.001&&(p=Number.POSITIVE_INFINITY);const r=l.payload;u.samples.push({data:r,len:r.byteLength,dts:c,pts:c,type:xr.emsg,duration:p})}})}return u}demuxSampleAes(e,s,u){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const t0=(_,e)=>{let s=0,u=5;e+=u;const y=new Uint32Array(1),A=new Uint32Array(1),l=new Uint8Array(1);for(;u>0;){l[0]=_[e];const c=Math.min(u,8),p=8-c;A[0]=4278190080>>>24+p< >p,s=s?s<
e.length||e[s]!==11||e[s+1]!==119)return-1;const A=e[s+4]>>6;if(A>=3)return-1;const c=[48e3,44100,32e3][A],p=e[s+4]&63,i=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][p*3+A]*2;if(s+i>e.length)return-1;const t=e[s+6]>>5;let n=0;t===2?n+=2:(t&1&&t!==1&&(n+=2),t&4&&(n+=2));const a=(e[s+6]<<8|e[s+7])>>12-n&1,d=[2,1,2,3,3,4,4,5][t]+a,g=e[s+5]>>3,m=e[s+5]&7,v=new Uint8Array([A<<6|g<<1|m>>2,(m&3)<<6|t<<3|a<<2|p>>4,p<<4&224]),b=1536/c*9e4,w=u+y*b,C=e.subarray(s,s+i);return _.config=v,_.channelCount=d,_.samplerate=c,_.samples.push({unit:C,pts:w}),i}class n0{constructor(){this.VideoSample=null}createVideoSample(e,s,u,y){return{key:e,frame:!1,pts:s,dts:u,units:[],debug:y,length:0}}getLastNalUnit(e){var s;let u=this.VideoSample,y;if((!u||u.units.length===0)&&(u=e[e.length-1]),(s=u)!=null&&s.units){const A=u.units;y=A[A.length-1]}return y}pushAccessUnit(e,s){if(e.units.length&&e.frame){if(e.pts===void 0){const u=s.samples,y=u.length;if(y){const A=u[y-1];e.pts=A.pts,e.dts=A.dts}else{s.dropped++;return}}s.samples.push(e)}e.debug.length&&Ft.log(e.pts+"/"+e.dts+":"+e.debug)}parseNALu(e,s){const u=s.byteLength;let y=e.naluState||0;const A=y,l=[];let c=0,p,r,i,t=-1,n=0;for(y===-1&&(t=0,n=this.getNALuType(s,0),y=0,c=1);c=0){const a={data:s.subarray(t,r),type:n};l.push(a)}else{const a=this.getLastNalUnit(e.samples);a&&(A&&c<=4-A&&a.state&&(a.data=a.data.subarray(0,a.data.byteLength-A)),r>0&&(a.data=Ar(a.data,s.subarray(0,r)),a.state=0))}c=0&&y>=0){const a={data:s.subarray(t,u),type:n,state:y};l.push(a)}if(l.length===0){const a=this.getLastNalUnit(e.samples);a&&(a.data=Ar(a.data,s))}return e.naluState=y,l}}class xa{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,s=this.bytesAvailable,u=e.byteLength-s,y=new Uint8Array(4),A=Math.min(4,s);if(A===0)throw new Error("no bytes available");y.set(e.subarray(u,u+A)),this.word=new DataView(y.buffer).getUint32(0),this.bitsAvailable=A*8,this.bytesAvailable-=A}skipBits(e){let s;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,s=e>>3,e-=s<<3,this.bytesAvailable-=s,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let s=Math.min(this.bitsAvailable,e);const u=this.word>>>32-s;if(e>32&&Ft.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=s,this.bitsAvailable>0)this.word<<=s;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return s=e-s,s>0&&this.bitsAvailable?u< >>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class qh extends n0{parsePES(e,s,u,y,A){const l=this.parseNALu(e,u.data);let c=this.VideoSample,p,r=!1;u.data=null,c&&l.length&&!e.audFound&&(this.pushAccessUnit(c,e),c=this.VideoSample=this.createVideoSample(!1,u.pts,u.dts,"")),l.forEach(i=>{var t;switch(i.type){case 1:{let d=!1;p=!0;const g=i.data;if(r&&g.length>4){const m=this.readSliceType(g);(m===2||m===4||m===7||m===9)&&(d=!0)}if(d){var n;(n=c)!=null&&n.frame&&!c.key&&(this.pushAccessUnit(c,e),c=this.VideoSample=null)}c||(c=this.VideoSample=this.createVideoSample(!0,u.pts,u.dts,"")),c.frame=!0,c.key=d;break}case 5:p=!0,(t=c)!=null&&t.frame&&!c.key&&(this.pushAccessUnit(c,e),c=this.VideoSample=null),c||(c=this.VideoSample=this.createVideoSample(!0,u.pts,u.dts,"")),c.key=!0,c.frame=!0;break;case 6:{p=!0,Ed(i.data,1,u.pts,s.samples);break}case 7:{var a,o;p=!0,r=!0;const d=i.data,g=this.readSPS(d);if(!e.sps||e.width!==g.width||e.height!==g.height||((a=e.pixelRatio)==null?void 0:a[0])!==g.pixelRatio[0]||((o=e.pixelRatio)==null?void 0:o[1])!==g.pixelRatio[1]){e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[d],e.duration=A;const m=d.subarray(1,4);let v="avc1.";for(let b=0;b<3;b++){let w=m[b].toString(16);w.length<2&&(w="0"+w),v+=w}e.codec=v}break}case 8:p=!0,e.pps=[i.data];break;case 9:p=!0,e.audFound=!0,c&&this.pushAccessUnit(c,e),c=this.VideoSample=this.createVideoSample(!1,u.pts,u.dts,"");break;case 12:p=!0;break;default:p=!1,c&&(c.debug+="unknown NAL "+i.type+" ");break}c&&p&&c.units.push(i)}),y&&c&&(this.pushAccessUnit(c,e),this.VideoSample=null)}getNALuType(e,s){return e[s]&31}readSliceType(e){const s=new xa(e);return s.readUByte(),s.readUEG(),s.readUEG()}skipScalingList(e,s){let u=8,y=8,A;for(let l=0;l{var t;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:c||(c=this.VideoSample=this.createVideoSample(!1,u.pts,u.dts,"")),c.frame=!0,p=!0;break;case 16:case 17:case 18:case 21:if(p=!0,r){var n;(n=c)!=null&&n.frame&&!c.key&&(this.pushAccessUnit(c,e),c=this.VideoSample=null)}c||(c=this.VideoSample=this.createVideoSample(!0,u.pts,u.dts,"")),c.key=!0,c.frame=!0;break;case 19:case 20:p=!0,(t=c)!=null&&t.frame&&!c.key&&(this.pushAccessUnit(c,e),c=this.VideoSample=null),c||(c=this.VideoSample=this.createVideoSample(!0,u.pts,u.dts,"")),c.key=!0,c.frame=!0;break;case 39:p=!0,Ed(i.data,2,u.pts,s.samples);break;case 32:if(p=!0,!e.vps){const a=this.readVPS(i.data);e.params=Dn({},a),this.initVPS=i.data}e.vps=[i.data];break;case 33:if(p=!0,r=!0,typeof e.params=="object"){if(e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],i.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const a=this.readSPS(i.data);e.width=a.width,e.height=a.height,e.pixelRatio=a.pixelRatio,e.duration=A,e.codec=a.codecString,e.sps=[];for(const o in a.params)e.params[o]=a.params[o]}e.vps!==void 0&&e.vps[0]===this.initVPS&&e.sps.push(i.data)}c||(c=this.VideoSample=this.createVideoSample(!0,u.pts,u.dts,"")),c.key=!0;break;case 34:if(p=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const a=this.readPPS(i.data);for(const o in a)e.params[o]=a[o]}(this.initVPS!==null||e.pps.length===0)&&e.pps.push(i.data)}break;case 35:p=!0,e.audFound=!0,c&&this.pushAccessUnit(c,e),c=this.VideoSample=this.createVideoSample(!1,u.pts,u.dts,"");break;default:p=!1,c&&(c.debug+="unknown or irrelevant NAL "+i.type+" ");break}c&&p&&c.units.push(i)}),y&&c&&(this.pushAccessUnit(c,e),this.VideoSample=null)}getNALuType(e,s){return(e[s]&126)>>>1}ebsp2rbsp(e){const s=new Uint8Array(e.byteLength);let u=0;for(let y=0;y =2&&e[y]===3&&e[y-1]===0&&e[y-2]===0||(s[u]=e[y],u++);return new Uint8Array(s.buffer,0,u)}readVPS(e){const s=new xa(e);s.readUByte(),s.readUByte(),s.readBits(4),s.skipBits(2),s.readBits(6);const u=s.readBits(3),y=s.readBoolean();return{numTemporalLayers:u+1,temporalIdNested:y}}readSPS(e){const s=new xa(this.ebsp2rbsp(e));s.readUByte(),s.readUByte(),s.readBits(4);const u=s.readBits(3);s.readBoolean();const y=s.readBits(2),A=s.readBoolean(),l=s.readBits(5),c=s.readUByte(),p=s.readUByte(),r=s.readUByte(),i=s.readUByte(),t=s.readUByte(),n=s.readUByte(),a=s.readUByte(),o=s.readUByte(),d=s.readUByte(),g=s.readUByte(),m=s.readUByte(),v=[],b=[];for(let je=0;je0)for(let je=u;je<8;je++)s.readBits(2);for(let je=0;je1&&s.readEG();for(let vt=0;vt 0&&tt<16?(j=pe[tt-1],z=ue[tt-1]):tt===255&&(j=s.readBits(16),z=s.readBits(16))}if(s.readBoolean()&&s.readBoolean(),s.readBoolean()&&(s.readBits(3),s.readBoolean(),s.readBoolean()&&(s.readUByte(),s.readUByte(),s.readUByte())),s.readBoolean()&&(s.readUEG(),s.readUEG()),s.readBoolean(),s.readBoolean(),s.readBoolean(),oe=s.readBoolean(),oe&&(T+=s.readUEG(),P+=s.readUEG(),L+=s.readUEG(),I+=s.readUEG()),s.readBoolean()&&(Z=s.readBits(32),X=s.readBits(32),s.readBoolean()&&s.readUEG(),s.readBoolean())){const ue=s.readBoolean(),W=s.readBoolean();let ke=!1;(ue||W)&&(ke=s.readBoolean(),ke&&(s.readUByte(),s.readBits(5),s.readBoolean(),s.readBits(5)),s.readBits(4),s.readBits(4),ke&&s.readBits(4),s.readBits(5),s.readBits(5),s.readBits(5));for(let Ae=0;Ae<=u;Ae++){q=s.readBoolean();const Ye=q||s.readBoolean();let lt=!1;Ye?s.readEG():lt=s.readBoolean();const mt=lt?1:s.readUEG()+1;if(ue)for(let Ue=0;Ue >je&1)<<31-je)>>>0;let Ie=He.toString(16);return l===1&&Ie==="2"&&(Ie="6"),{codecString:`hvc1.${se}${l}.${Ie}.${A?"H":"L"}${m}.B0`,params:{general_tier_flag:A,general_profile_idc:l,general_profile_space:y,general_profile_compatibility_flags:[c,p,r,i],general_constraint_indicator_flags:[t,n,a,o,d,g],general_level_idc:m,bit_depth:x+8,bit_depth_luma_minus8:x,bit_depth_chroma_minus8:O,min_spatial_segmentation_idc:Y,chroma_format_idc:w,frame_rate:{fixed:q,fps:X/Z}},width:ie,height:fe,pixelRatio:[j,z]}}readPPS(e){const s=new xa(this.ebsp2rbsp(e));s.readUByte(),s.readUByte(),s.skipUEG(),s.skipUEG(),s.skipBits(2),s.skipBits(3),s.skipBits(2),s.skipUEG(),s.skipUEG(),s.skipEG(),s.skipBits(2),s.readBoolean()&&s.skipUEG(),s.skipEG(),s.skipEG(),s.skipBits(4);const y=s.readBoolean(),A=s.readBoolean();let l=1;return A&&y?l=0:A?l=3:y&&(l=2),{parallelismType:l}}matchSPS(e,s){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,s).substr(3)}}class Z5{constructor(e,s,u){this.keyData=void 0,this.decrypter=void 0,this.keyData=u,this.decrypter=new Cd(s,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,s,u){const y=e[s].unit;if(y.length<=16)return;const A=y.subarray(16,y.length-y.length%16),l=A.buffer.slice(A.byteOffset,A.byteOffset+A.length);this.decryptBuffer(l).then(c=>{const p=new Uint8Array(c);y.set(p,16),this.decrypter.isSync()||this.decryptAacSamples(e,s+1,u)})}decryptAacSamples(e,s,u){for(;;s++){if(s>=e.length){u();return}if(!(e[s].unit.length<32)&&(this.decryptAacSample(e,s,u),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const s=Math.floor((e.length-48)/160)*16+16,u=new Int8Array(s);let y=0;for(let A=32;A {A.data=this.getAvcDecryptedUnit(l,p),this.decrypter.isSync()||this.decryptAvcSamples(e,s,u+1,y)})}decryptAvcSamples(e,s,u,y){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;s++,u=0){if(s>=e.length){y();return}const A=e[s].units;for(;!(u>=A.length);u++){const l=A[u];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,s,u,y,l),!this.decrypter.isSync()))return}}}}const Pn=188;class os{constructor(e,s,u){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=s,this.typeSupported=u,this.videoParser=null}static probe(e){const s=os.syncOffset(e);return s>0&&Ft.warn(`MPEG2-TS detected but first sync word found @ offset ${s}`),s!==-1}static syncOffset(e){const s=e.length;let u=Math.min(Pn*5,s-Pn)+1,y=0;for(;y1&&(l===0&&c>2||p+Pn>u))return l}else{if(c)return-1;break}y++}return-1}static createTrack(e,s){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:kp[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?s:void 0}}resetInitSegment(e,s,u,y){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=os.createTrack("video"),this._audioTrack=os.createTrack("audio",y),this._id3Track=os.createTrack("id3"),this._txtTrack=os.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=s,this.videoCodec=u,this._duration=y}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:s,_id3Track:u}=this;e&&(e.pesData=null),s&&(s.pesData=null),u&&(u.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,s,u=!1,y=!1){u||(this.sampleAes=null);let A;const l=this._videoTrack,c=this._audioTrack,p=this._id3Track,r=this._txtTrack;let i=l.pid,t=l.pesData,n=c.pid,a=p.pid,o=c.pesData,d=p.pesData,g=null,m=this.pmtParsed,v=this._pmtId,b=e.length;if(this.remainderData&&(e=Ar(this.remainderData,e),b=e.length,this.remainderData=null),b >4;let I;if(L>1){if(I=R+5+e[R+4],I===R+Pn)continue}else I=R+4;switch(P){case i:if(T){if(t&&(A=zs(t))){if(this.videoParser===null)switch(l.segmentCodec){case"avc":this.videoParser=new qh;break;case"hevc":this.videoParser=new Yh;break}this.videoParser!==null&&this.videoParser.parsePES(l,r,A,!1,this._duration)}t={data:[],size:0}}t&&(t.data.push(e.subarray(I,R+Pn)),t.size+=R+Pn-I);break;case n:if(T){if(o&&(A=zs(o)))switch(c.segmentCodec){case"aac":this.parseAACPES(c,A);break;case"mp3":this.parseMPEGPES(c,A);break;case"ac3":this.parseAC3PES(c,A);break}o={data:[],size:0}}o&&(o.data.push(e.subarray(I,R+Pn)),o.size+=R+Pn-I);break;case a:T&&(d&&(A=zs(d))&&this.parseID3PES(p,A),d={data:[],size:0}),d&&(d.data.push(e.subarray(I,R+Pn)),d.size+=R+Pn-I);break;case 0:T&&(I+=e[I]+1),v=this._pmtId=X5(e,I);break;case v:{T&&(I+=e[I]+1);const x=$5(e,I,this.typeSupported,u);i=x.videoPid,i>0&&(l.pid=i,l.segmentCodec=x.segmentVideoCodec),n=x.audioPid,n>0&&(c.pid=n,c.segmentCodec=x.segmentAudioCodec),a=x.id3Pid,a>0&&(p.pid=a),g!==null&&!m&&(Ft.warn(`MPEG-TS PMT found at ${R} after unknown PID '${g}'. Backtracking to sync byte @${w} to parse all TS packets.`),g=null,R=w-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=P;break}}else C++;if(C>0){const R=new Error(`Found ${C} TS packet/s that do not start with 0x47`);this.observer.emit(rt.ERROR,rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!1,error:R,reason:R.message})}l.pesData=t,c.pesData=o,p.pesData=d;const D={audioTrack:c,videoTrack:l,id3Track:p,textTrack:r};return y&&this.extractRemainingSamples(D),D}flush(){const{remainderData:e}=this;this.remainderData=null;let s;return e?s=this.demux(e,-1,!1,!0):s={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(s),this.sampleAes?this.decrypt(s,this.sampleAes):s}extractRemainingSamples(e){const{audioTrack:s,videoTrack:u,id3Track:y,textTrack:A}=e,l=u.pesData,c=s.pesData,p=y.pesData;let r;if(l&&(r=zs(l))){if(this.videoParser===null)switch(u.segmentCodec){case"avc":this.videoParser=new qh;break;case"hevc":this.videoParser=new Yh;break}this.videoParser!==null&&(this.videoParser.parsePES(u,A,r,!0,this._duration),u.pesData=null)}else u.pesData=l;if(c&&(r=zs(c))){switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r);break}s.pesData=null}else c!=null&&c.size&&Ft.log("last AAC PES packet truncated,might overlap between fragments"),s.pesData=c;p&&(r=zs(p))?(this.parseID3PES(y,r),y.pesData=null):y.pesData=p}demuxSampleAes(e,s,u){const y=this.demux(e,u,!0,!this.config.progressive),A=this.sampleAes=new Z5(this.observer,this.config,s);return this.decrypt(y,A)}decrypt(e,s){return new Promise(u=>{const{audioTrack:y,videoTrack:A}=e;y.samples&&y.segmentCodec==="aac"?s.decryptAacSamples(y.samples,0,()=>{A.samples?s.decryptAvcSamples(A.samples,0,0,()=>{u(e)}):u(e)}):A.samples&&s.decryptAvcSamples(A.samples,0,0,()=>{u(e)})})}destroy(){this._duration=0}parseAACPES(e,s){let u=0;const y=this.aacOverFlow;let A=s.data;if(y){this.aacOverFlow=null;const t=y.missing,n=y.sample.unit.byteLength;if(t===-1)A=Ar(y.sample.unit,A);else{const a=n-t;y.sample.unit.set(A.subarray(0,t),a),e.samples.push(y.sample),u=y.missing}}let l,c;for(l=u,c=A.length;l 0;)c+=p}}parseID3PES(e,s){if(s.pts===void 0){Ft.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const u=xn({},s,{type:this._videoTrack?xr.emsg:xr.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(u)}}function qc(_,e){return((_[e+1]&31)<<8)+_[e+2]}function X5(_,e){return(_[e+10]&31)<<8|_[e+11]}function $5(_,e,s,u){const y={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},A=(_[e+1]&15)<<8|_[e+2],l=e+3+A-4,c=(_[e+10]&15)<<8|_[e+11];for(e+=12+c;e 0){let i=e+5,t=r;for(;t>2;){switch(_[i]){case 106:s.ac3!==!0?Ft.log("AC-3 audio found, not supported in this browser for now"):(y.audioPid=p,y.segmentAudioCodec="ac3");break}const a=_[i+1]+2;i+=a,t-=a}}break;case 194:case 135:Ft.warn("Unsupported EC-3 in M2TS found");break;case 36:y.videoPid===-1&&(y.videoPid=p,y.segmentVideoCodec="hevc",Ft.log("HEVC in M2TS found"));break}e+=r+5}return y}function gc(_){Ft.log(`${_} with AES-128-CBC encryption found in unencrypted stream`)}function zs(_){let e=0,s,u,y,A,l;const c=_.data;if(!_||_.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=Ar(c[0],c[1]),c.splice(1,1);if(s=c[0],(s[0]<<16)+(s[1]<<8)+s[2]===1){if(u=(s[4]<<8)+s[5],u&&u>_.size-6)return null;const r=s[7];r&192&&(A=(s[9]&14)*536870912+(s[10]&255)*4194304+(s[11]&254)*16384+(s[12]&255)*128+(s[13]&254)/2,r&64?(l=(s[14]&14)*536870912+(s[15]&255)*4194304+(s[16]&254)*16384+(s[17]&255)*128+(s[18]&254)/2,A-l>60*9e4&&(Ft.warn(`${Math.round((A-l)/9e4)}s delta between PTS and DTS, align them`),A=l)):l=A),y=s[8];let i=y+9;if(_.size<=i)return null;_.size-=i;const t=new Uint8Array(_.size);for(let n=0,a=c.length;no){i-=o;continue}else s=s.subarray(i),o-=i,i=0;t.set(s,e),e+=o}return u&&(u-=y+3),{data:t,pts:A,dts:l,len:u}}return null}class e4 extends kd{resetInitSegment(e,s,u,y){super.resetInitSegment(e,s,u,y),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:s,duration:y,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const s=Ra(e,0);let u=(s==null?void 0:s.length)||0;if(s&&e[u]===11&&e[u+1]===119&&_d(s)!==void 0&&t0(e,u)<=16)return!1;for(let y=e.length;u >24&255,l[1]=u>>16&255,l[2]=u>>8&255,l[3]=u&255,l.set(e,4),y=0,u=8;y>24&255,e>>16&255,e>>8&255,e&255,u>>24,u>>16&255,u>>8&255,u&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))}static mdia(e){return Nt.box(Nt.types.mdia,Nt.mdhd(e.timescale,e.duration),Nt.hdlr(e.type),Nt.minf(e))}static mfhd(e){return Nt.box(Nt.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?Nt.box(Nt.types.minf,Nt.box(Nt.types.smhd,Nt.SMHD),Nt.DINF,Nt.stbl(e)):Nt.box(Nt.types.minf,Nt.box(Nt.types.vmhd,Nt.VMHD),Nt.DINF,Nt.stbl(e))}static moof(e,s,u){return Nt.box(Nt.types.moof,Nt.mfhd(e),Nt.traf(u,s))}static moov(e){let s=e.length;const u=[];for(;s--;)u[s]=Nt.trak(e[s]);return Nt.box.apply(null,[Nt.types.moov,Nt.mvhd(e[0].timescale,e[0].duration)].concat(u).concat(Nt.mvex(e)))}static mvex(e){let s=e.length;const u=[];for(;s--;)u[s]=Nt.trex(e[s]);return Nt.box.apply(null,[Nt.types.mvex,...u])}static mvhd(e,s){s*=e;const u=Math.floor(s/(as+1)),y=Math.floor(s%(as+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,u>>24,u>>16&255,u>>8&255,u&255,y>>24,y>>16&255,y>>8&255,y&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 Nt.box(Nt.types.mvhd,A)}static sdtp(e){const s=e.samples||[],u=new Uint8Array(4+s.length);let y,A;for(y=0;y >>8&255),s.push(l&255),s=s.concat(Array.prototype.slice.call(A));for(y=0;y >>8&255),u.push(l&255),u=u.concat(Array.prototype.slice.call(A));const c=Nt.box(Nt.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(u))),p=e.width,r=e.height,i=e.pixelRatio[0],t=e.pixelRatio[1];return Nt.box(Nt.types.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,p>>8&255,p&255,r>>8&255,r&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c,Nt.box(Nt.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Nt.box(Nt.types.pasp,new Uint8Array([i>>24,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255])))}static esds(e){const s=e.config.length;return new Uint8Array([0,0,0,0,3,23+s,0,1,0,4,15+s,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([s]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const s=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,s>>8&255,s&255,0,0])}static mp4a(e){return Nt.box(Nt.types.mp4a,Nt.audioStsd(e),Nt.box(Nt.types.esds,Nt.esds(e)))}static mp3(e){return Nt.box(Nt.types[".mp3"],Nt.audioStsd(e))}static ac3(e){return Nt.box(Nt.types["ac-3"],Nt.audioStsd(e),Nt.box(Nt.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?Nt.box(Nt.types.stsd,Nt.STSD,Nt.mp3(e)):e.segmentCodec==="ac3"?Nt.box(Nt.types.stsd,Nt.STSD,Nt.ac3(e)):Nt.box(Nt.types.stsd,Nt.STSD,Nt.mp4a(e)):e.segmentCodec==="avc"?Nt.box(Nt.types.stsd,Nt.STSD,Nt.avc1(e)):Nt.box(Nt.types.stsd,Nt.STSD,Nt.hvc1(e))}static tkhd(e){const s=e.id,u=e.duration*e.timescale,y=e.width,A=e.height,l=Math.floor(u/(as+1)),c=Math.floor(u%(as+1));return Nt.box(Nt.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,s&255,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,c>>24,c>>16&255,c>>8&255,c&255,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,A>>8&255,A&255,0,0]))}static traf(e,s){const u=Nt.sdtp(e),y=e.id,A=Math.floor(s/(as+1)),l=Math.floor(s%(as+1));return Nt.box(Nt.types.traf,Nt.box(Nt.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),Nt.box(Nt.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,l>>24,l>>16&255,l>>8&255,l&255])),Nt.trun(e,u.length+16+20+8+16+8+8),u)}static trak(e){return e.duration=e.duration||4294967295,Nt.box(Nt.types.trak,Nt.tkhd(e),Nt.mdia(e))}static trex(e){const s=e.id;return Nt.box(Nt.types.trex,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,s){const u=e.samples||[],y=u.length,A=12+16*y,l=new Uint8Array(A);let c,p,r,i,t,n;for(s+=8+A,l.set([e.type==="video"?1:0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255],0),c=0;c >>24&255,r>>>16&255,r>>>8&255,r&255,i>>>24&255,i>>>16&255,i>>>8&255,i&255,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,t.degradPrio&61440,t.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*c);return Nt.box(Nt.types.trun,l)}static initSegment(e){Nt.types||Nt.init();const s=Nt.moov(e);return Ar(Nt.FTYP,s)}static hvc1(e){const s=e.params,u=[e.vps,e.sps,e.pps],y=4,A=new Uint8Array([1,s.general_profile_space<<6|(s.general_tier_flag?32:0)|s.general_profile_idc,s.general_profile_compatibility_flags[0],s.general_profile_compatibility_flags[1],s.general_profile_compatibility_flags[2],s.general_profile_compatibility_flags[3],s.general_constraint_indicator_flags[0],s.general_constraint_indicator_flags[1],s.general_constraint_indicator_flags[2],s.general_constraint_indicator_flags[3],s.general_constraint_indicator_flags[4],s.general_constraint_indicator_flags[5],s.general_level_idc,240|s.min_spatial_segmentation_idc>>8,255&s.min_spatial_segmentation_idc,252|s.parallelismType,252|s.chroma_format_idc,248|s.bit_depth_luma_minus8,248|s.bit_depth_chroma_minus8,0,parseInt(s.frame_rate.fps),y-1|s.temporal_id_nested<<2|s.num_temporal_layers<<3|(s.frame_rate.fixed?64:0),u.length]);let l=A.length;for(let o=0;o >8,u[o][d].length&255]),l),l+=2,c.set(u[o][d],l),l+=u[o][d].length}const r=Nt.box(Nt.types.hvcC,c),i=e.width,t=e.height,n=e.pixelRatio[0],a=e.pixelRatio[1];return Nt.box(Nt.types.hvc1,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,i>>8&255,i&255,t>>8&255,t&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),r,Nt.box(Nt.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Nt.box(Nt.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])))}}Nt.types=void 0;Nt.HDLR_TYPES=void 0;Nt.STTS=void 0;Nt.STSC=void 0;Nt.STCO=void 0;Nt.STSZ=void 0;Nt.VMHD=void 0;Nt.SMHD=void 0;Nt.STSD=void 0;Nt.FTYP=void 0;Nt.DINF=void 0;const r0=9e4;function Ld(_,e,s=1,u=!1){const y=_*e*s;return u?Math.round(y):y}function t4(_,e,s=1,u=!1){return Ld(_,e,1/s,u)}function Sa(_,e=!1){return Ld(_,1e3,1/r0,e)}function i4(_,e=1){return Ld(_,r0,1/e)}const n4=10*1e3,Qh=1024,r4=1152,s4=1536;let Ws=null,Ac=null;class go{constructor(e,s,u,y=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=s,this.typeSupported=u,this.ISGenerated=!1,Ws===null){const l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ws=l?parseInt(l[1]):0}if(Ac===null){const A=navigator.userAgent.match(/Safari\/(\d+)/i);Ac=A?parseInt(A[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){Ft.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){Ft.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Ft.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let s=!1;const u=e.reduce((y,A)=>{const l=A.pts-y;return l<-4294967296?(s=!0,gr(y,A.pts)):l>0?y:A.pts},e[0].pts);return s&&Ft.debug("PTS rollover detected"),u}remux(e,s,u,y,A,l,c,p){let r,i,t,n,a,o,d=A,g=A;const m=e.pid>-1,v=s.pid>-1,b=s.samples.length,w=e.samples.length>0,C=c&&b>0||b>1;if((!m||w)&&(!v||C)||this.ISGenerated||c){if(this.ISGenerated){var R,T,P,L;const G=this.videoTrackConfig;G&&(s.width!==G.width||s.height!==G.height||((R=s.pixelRatio)==null?void 0:R[0])!==((T=G.pixelRatio)==null?void 0:T[0])||((P=s.pixelRatio)==null?void 0:P[1])!==((L=G.pixelRatio)==null?void 0:L[1]))&&this.resetInitSegment()}else t=this.generateIS(e,s,A,l);const I=this.isVideoContiguous;let x=-1,O;if(C&&(x=a4(s.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(o=!0,x>0){Ft.warn(`[mp4-remuxer]: Dropped ${x} out of ${b} video samples due to a missing keyframe`);const G=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(x),s.dropped+=x,g+=(s.samples[0].pts-G)/s.inputTimeScale,O=g}else x===-1&&(Ft.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),o=!1);if(this.ISGenerated){if(w&&C){const G=this.getVideoStartPts(s.samples),te=(gr(e.samples[0].pts,G)-G)/s.inputTimeScale;d+=Math.max(0,te),g+=Math.max(0,-te)}if(w){if(e.samplerate||(Ft.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),t=this.generateIS(e,s,A,l)),i=this.remuxAudio(e,d,this.isAudioContiguous,l,v||C||p===Hi.AUDIO?g:void 0),C){const G=i?i.endPTS-i.startPTS:0;s.inputTimeScale||(Ft.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),t=this.generateIS(e,s,A,l)),r=this.remuxVideo(s,g,I,G)}}else C&&(r=this.remuxVideo(s,g,I,0));r&&(r.firstKeyFrame=x,r.independent=x!==-1,r.firstKeyFramePTS=O)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(u.samples.length&&(a=s0(u,A,this._initPTS,this._initDTS)),y.samples.length&&(n=a0(y,A,this._initPTS))),{audio:i,video:r,initSegment:t,independent:o,text:n,id3:a}}generateIS(e,s,u,y){const A=e.samples,l=s.samples,c=this.typeSupported,p={},r=this._initPTS;let i=!r||y,t="audio/mp4",n,a,o;if(i&&(n=a=1/0),e.config&&A.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":c.mpeg?(t="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}p.audio={id:"audio",container:t,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):Nt.initSegment([e]),metadata:{channelCount:e.channelCount}},i&&(o=e.inputTimeScale,!r||o!==r.timescale?n=a=A[0].pts-Math.round(o*u):i=!1)}if(s.sps&&s.pps&&l.length){if(s.timescale=s.inputTimeScale,p.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:Nt.initSegment([s]),metadata:{width:s.width,height:s.height}},i)if(o=s.inputTimeScale,!r||o!==r.timescale){const d=this.getVideoStartPts(l),g=Math.round(o*u);a=Math.min(a,gr(l[0].dts,d)-g),n=Math.min(n,d-g)}else i=!1;this.videoTrackConfig={width:s.width,height:s.height,pixelRatio:s.pixelRatio}}if(Object.keys(p).length)return this.ISGenerated=!0,i?(this._initPTS={baseTime:n,timescale:o},this._initDTS={baseTime:a,timescale:o}):n=o=void 0,{tracks:p,initPTS:n,timescale:o}}remuxVideo(e,s,u,y){const A=e.inputTimeScale,l=e.samples,c=[],p=l.length,r=this._initPTS;let i=this.nextAvcDts,t=8,n=this.videoSampleDuration,a,o,d=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;if(!u||i===null){const ee=s*A,M=l[0].pts-gr(l[0].dts,l[0].pts);Ws&&i!==null&&Math.abs(ee-M-i)<15e3?u=!0:i=ee-M}const v=r.baseTime*A/r.timescale;for(let ee=0;ee 0?ee-1:ee].dts&&(m=!0)}m&&l.sort(function(ee,M){const Y=ee.dts-M.dts,j=ee.pts-M.pts;return Y||j}),a=l[0].dts,o=l[l.length-1].dts;const b=o-a,w=b?Math.round(b/(p-1)):n||e.inputTimeScale/30;if(u){const ee=a-i,M=ee>w,Y=ee<-1;if((M||Y)&&(M?Ft.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sa(ee,!0)} ms (${ee}dts) hole between fragments detected at ${s.toFixed(3)}`):Ft.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sa(-ee,!0)} ms (${ee}dts) overlapping between fragments detected at ${s.toFixed(3)}`),!Y||i>=l[0].pts||Ws)){a=i;const j=l[0].pts-ee;if(M)l[0].dts=a,l[0].pts=j;else for(let z=0;z
j);z++)l[z].dts-=ee,l[z].pts-=ee;Ft.log(`Video: Initial PTS/DTS adjusted: ${Sa(j,!0)}/${Sa(a,!0)}, delta: ${Sa(ee,!0)} ms`)}}a=Math.max(0,a);let C=0,D=0,R=a;for(let ee=0;ee 0?M.dts-l[ee-1].dts:w;if(z=ee>0?M.pts-l[ee-1].pts:w,Z.stretchShortVideoTrack&&this.nextAudioPts!==null){const oe=Math.floor(Z.maxBufferHole*A),he=(y?d+y*A:this.nextAudioPts)-M.pts;he>oe?(n=he-X,n<0?n=X:I=!0,Ft.log(`[mp4-remuxer]: It is approximately ${he/90} ms to the next segment; using duration ${n/90} ms for the last video frame.`)):n=X}else n=X}const q=Math.round(M.pts-M.dts);x=Math.min(x,n),G=Math.max(G,n),O=Math.min(O,z),J=Math.max(J,z),c.push(new Zh(M.key,n,j,q))}if(c.length){if(Ws){if(Ws<70){const ee=c[0].flags;ee.dependsOn=2,ee.isNonSync=0}}else if(Ac&&J-O
0&&(y&&Math.abs(v-m)<9e3||Math.abs(gr(d[0].pts-b,v)-m)<20*i),d.forEach(function(te){te.pts=gr(te.pts-b,v)}),!u||m<0){if(d=d.filter(te=>te.pts>=0),!d.length)return;A===0?m=0:y&&!o?m=Math.max(0,v):m=d[0].pts}if(e.segmentCodec==="aac"){const te=this.config.maxAudioFramesDrift;for(let le=0,ne=m;le =te*i&&j 0){R+=g;try{D=new Uint8Array(R)}catch(j){this.observer.emit(rt.ERROR,rt.ERROR,{type:Wi.MUX_ERROR,details:qt.REMUX_ALLOC_ERROR,fatal:!1,error:j,bytes:R,reason:`fail allocating audio mdat ${R}`});return}n||(new DataView(D.buffer).setUint32(0,R),D.set(Nt.types.mdat,4))}else return;D.set(ee,g);const Y=ee.byteLength;g+=Y,a.push(new Zh(!0,r,Y,0)),C=M}const P=a.length;if(!P)return;const L=a[a.length-1];this.nextAudioPts=m=C+p*L.duration;const I=n?new Uint8Array(0):Nt.moof(e.sequenceNumber++,w/p,xn({},e,{samples:a}));e.samples=[];const x=w/l,O=m/l,J={data1:I,data2:D,startPTS:x,endPTS:O,startDTS:x,endDTS:O,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,J}remuxEmptyAudio(e,s,u,y){const A=e.inputTimeScale,l=e.samplerate?e.samplerate:A,c=A/l,p=this.nextAudioPts,r=this._initDTS,i=r.baseTime*9e4/r.timescale,t=(p!==null?p:y.startDTS*A)+i,n=y.endDTS*A+i,a=c*Qh,o=Math.ceil((n-t)/a),d=Jh.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(Ft.warn("[mp4-remuxer]: remux empty Audio"),!d){Ft.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const g=[];for(let m=0;m 4294967296;)_+=s;return _}function a4(_){for(let e=0;e<_.length;e++)if(_[e].key)return e;return-1}function s0(_,e,s,u){const y=_.samples.length;if(!y)return;const A=_.inputTimeScale;for(let c=0;c l.pts-c.pts);const A=_.samples;return _.samples=[],{samples:A}}class Zh{constructor(e,s,u,y){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=s,this.size=u,this.cts=y,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class o4{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,s,u,y){this.audioCodec=s,this.videoCodec=u,this.generateInitSegment(A_(e,y)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:s,videoCodec:u}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const y=this.initData=Lp(e);y.audio&&(s=Xh(y.audio,fn.AUDIO)),y.video&&(u=Xh(y.video,fn.VIDEO));const A={};y.audio&&y.video?A.audiovideo={container:"video/mp4",codec:s+","+u,initSegment:e,id:"main"}:y.audio?A.audio={container:"audio/mp4",codec:s,initSegment:e,id:"audio"}:y.video?A.video={container:"video/mp4",codec:u,initSegment:e,id:"main"}:Ft.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=A}remux(e,s,u,y,A,l){var c,p;let{initPTS:r,lastEndTime:i}=this;const t={audio:void 0,video:void 0,text:y,id3:u,initSegment:void 0};Ci(i)||(i=this.lastEndTime=A||0);const n=s.samples;if(!(n!=null&&n.length))return t;const a={initPTS:void 0,timescale:1};let o=this.initData;if((c=o)!=null&&c.length||(this.generateInitSegment(n),o=this.initData),!((p=o)!=null&&p.length))return Ft.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),t;this.emitInitSegment&&(a.tracks=this.initTracks,this.emitInitSegment=!1);const d=v_(n,o),g=y_(o,n),m=g===null?A:g;(l4(r,m,A,d)||a.timescale!==r.timescale&&l)&&(a.initPTS=m-A,r&&r.timescale===1&&Ft.warn(`Adjusting initPTS by ${a.initPTS-r.baseTime}`),this.initPTS=r={baseTime:a.initPTS,timescale:1});const v=e?m-r.baseTime/r.timescale:i,b=v+d;__(o,n,r.baseTime/r.timescale),d>0?this.lastEndTime=b:(Ft.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const w=!!o.audio,C=!!o.video;let D="";w&&(D+="audio"),C&&(D+="video");const R={data1:n,startPTS:v,startDTS:v,endPTS:b,endDTS:b,type:D,hasAudio:w,hasVideo:C,nb:1,dropped:0};return t.audio=R.type==="audio"?R:void 0,t.video=R.type!=="audio"?R:void 0,t.initSegment=a,t.id3=s0(u,A,r,r),y.samples.length&&(t.text=a0(y,A,r)),t}}function l4(_,e,s,u){if(_===null)return!0;const y=Math.max(u,1),A=e-_.baseTime/_.timescale;return Math.abs(A-s)>y}function Xh(_,e){const s=_==null?void 0:_.codec;if(s&&s.length>4)return s;if(e===fn.AUDIO){if(s==="ec-3"||s==="ac-3"||s==="alac")return s;if(s==="fLaC"||s==="Opus")return Lo(s,!1);const u="mp4a.40.5";return Ft.info(`Parsed audio codec "${s}" or audio object type not handled. Using "${u}"`),u}return Ft.warn(`Unhandled video codec "${s}"`),s==="hvc1"||s==="hev1"?"hvc1.1.6.L120.90":s==="av01"?"av01.0.04M.08":"avc1.42e01e"}let Zr;try{Zr=self.performance.now.bind(self.performance)}catch{Ft.debug("Unable to use Performance API on this environment"),Zr=oa==null?void 0:oa.Date.now}const Ao=[{demux:J5,remux:o4},{demux:os,remux:go},{demux:q5,remux:go},{demux:e4,remux:go}];Ao.splice(2,0,{demux:Q5,remux:go});class $h{constructor(e,s,u,y,A){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=s,this.config=u,this.vendor=y,this.id=A}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,s,u,y){const A=u.transmuxing;A.executeStart=Zr();let l=new Uint8Array(e);const{currentTransmuxState:c,transmuxConfig:p}=this;y&&(this.currentTransmuxState=y);const{contiguous:r,discontinuity:i,trackSwitch:t,accurateTimeOffset:n,timeOffset:a,initSegmentChange:o}=y||c,{audioCodec:d,videoCodec:g,defaultInitPts:m,duration:v,initSegmentData:b}=p,w=c4(l,s);if(w&&w.method==="AES-128"){const T=this.getDecrypter();if(T.isSync()){let P=T.softwareDecrypt(l,w.key.buffer,w.iv.buffer);if(u.part>-1&&(P=T.flush()),!P)return A.executeEnd=Zr(),yc(u);l=new Uint8Array(P)}else return this.decryptionPromise=T.webCryptoDecrypt(l,w.key.buffer,w.iv.buffer).then(P=>{const L=this.push(P,null,u);return this.decryptionPromise=null,L}),this.decryptionPromise}const C=this.needsProbing(i,t);if(C){const T=this.configureTransmuxer(l);if(T)return Ft.warn(`[transmuxer] ${T.message}`),this.observer.emit(rt.ERROR,rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!1,error:T,reason:T.message}),A.executeEnd=Zr(),yc(u)}(i||t||o||C)&&this.resetInitSegment(b,d,g,v,s),(i||o||C)&&this.resetInitialTimestamp(m),r||this.resetContiguity();const D=this.transmux(l,w,a,n,u),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,A.executeEnd=Zr(),D}flush(e){const s=e.transmuxing;s.executeStart=Zr();const{decrypter:u,currentTransmuxState:y,decryptionPromise:A}=this;if(A)return A.then(()=>this.flush(e));const l=[],{timeOffset:c}=y;if(u){const t=u.flush();t&&l.push(this.push(t,null,e))}const{demuxer:p,remuxer:r}=this;if(!p||!r)return s.executeEnd=Zr(),[yc(e)];const i=p.flush(c);return yo(i)?i.then(t=>(this.flushRemux(l,t,e),l)):(this.flushRemux(l,i,e),l)}flushRemux(e,s,u){const{audioTrack:y,videoTrack:A,id3Track:l,textTrack:c}=s,{accurateTimeOffset:p,timeOffset:r}=this.currentTransmuxState;Ft.log(`[transmuxer.ts]: Flushed fragment ${u.sn}${u.part>-1?" p: "+u.part:""} of level ${u.level}`);const i=this.remuxer.remux(y,A,l,c,r,p,!0,this.id);e.push({remuxResult:i,chunkMeta:u}),u.transmuxing.executeEnd=Zr()}resetInitialTimestamp(e){const{demuxer:s,remuxer:u}=this;!s||!u||(s.resetTimeStamp(e),u.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:s}=this;!e||!s||(e.resetContiguity(),s.resetNextTimestamp())}resetInitSegment(e,s,u,y,A){const{demuxer:l,remuxer:c}=this;!l||!c||(l.resetInitSegment(e,s,u,y),c.resetInitSegment(e,s,u,A))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,s,u,y,A){let l;return s&&s.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,s,u,y,A):l=this.transmuxUnencrypted(e,u,y,A),l}transmuxUnencrypted(e,s,u,y){const{audioTrack:A,videoTrack:l,id3Track:c,textTrack:p}=this.demuxer.demux(e,s,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(A,l,c,p,s,u,!1,this.id),chunkMeta:y}}transmuxSampleAes(e,s,u,y,A){return this.demuxer.demuxSampleAes(e,s,u).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,u,y,!1,this.id),chunkMeta:A}))}configureTransmuxer(e){const{config:s,observer:u,typeSupported:y,vendor:A}=this;let l;for(let n=0,a=Ao.length;n0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(s=e),s}const yc=_=>({remuxResult:{},chunkMeta:_});function yo(_){return"then"in _&&_.then instanceof Function}class d4{constructor(e,s,u,y,A){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=s,this.initSegmentData=u,this.duration=y,this.defaultInitPts=A||null}}class u4{constructor(e,s,u,y,A,l){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=s,this.accurateTimeOffset=u,this.trackSwitch=y,this.timeOffset=A,this.initSegmentChange=l}}var o0={exports:{}};(function(_){var e=Object.prototype.hasOwnProperty,s="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(s=!1));function y(p,r,i){this.fn=p,this.context=r,this.once=i||!1}function A(p,r,i,t,n){if(typeof i!="function")throw new TypeError("The listener must be a function");var a=new y(i,t||p,n),o=s?s+r:r;return p._events[o]?p._events[o].fn?p._events[o]=[p._events[o],a]:p._events[o].push(a):(p._events[o]=a,p._eventsCount++),p}function l(p,r){--p._eventsCount===0?p._events=new u:delete p._events[r]}function c(){this._events=new u,this._eventsCount=0}c.prototype.eventNames=function(){var r=[],i,t;if(this._eventsCount===0)return r;for(t in i=this._events)e.call(i,t)&&r.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(i)):r},c.prototype.listeners=function(r){var i=s?s+r:r,t=this._events[i];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,a=t.length,o=new Array(a);n{t=t||{},t.frag=this.frag,t.id=this.id,i===rt.ERROR&&(this.error=t.error),this.hls.trigger(i,t)};this.observer=new Dd,this.observer.on(rt.FRAG_DECRYPTED,l),this.observer.on(rt.ERROR,l);const c=ua(A.preferManagedMediaSource)||{isTypeSupported:()=>!1},p={mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:c.isTypeSupported('audio/mp4; codecs="ac-3"')},r=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(A.workerPath||O5())){try{A.workerPath?(Ft.log(`loading Web Worker ${A.workerPath} for "${s}"`),this.workerContext=P5(A.workerPath)):(Ft.log(`injecting Web Worker for "${s}"`),this.workerContext=M5()),this.onwmsg=n=>this.onWorkerMessage(n);const{worker:t}=this.workerContext;t.addEventListener("message",this.onwmsg),t.onerror=n=>{const a=new Error(`${n.message} (${n.filename}:${n.lineno})`);A.enableWorker=!1,Ft.warn(`Error in "${s}" Web Worker, fallback to inline`),this.hls.trigger(rt.ERROR,{type:Wi.OTHER_ERROR,details:qt.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:a})},t.postMessage({cmd:"init",typeSupported:p,vendor:r,id:s,config:JSON.stringify(A)})}catch(t){Ft.warn(`Error setting up "${s}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new $h(this.observer,p,A,r,s)}return}this.transmuxer=new $h(this.observer,p,A,r,s)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:s}=this.workerContext;s&&self.URL.revokeObjectURL(s),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,s,u,y,A,l,c,p,r,i){var t,n;r.transmuxing.start=self.performance.now();const{transmuxer:a}=this,o=l?l.start:A.start,d=A.decryptdata,g=this.frag,m=!(g&&A.cc===g.cc),v=!(g&&r.level===g.level),b=g?r.sn-g.sn:-1,w=this.part?r.part-this.part.index:-1,C=b===0&&r.id>1&&r.id===(g==null?void 0:g.stats.chunkCount),D=!v&&(b===1||b===0&&(w===1||C&&w<=0)),R=self.performance.now();(v||b||A.stats.parsing.start===0)&&(A.stats.parsing.start=R),l&&(w||!D)&&(l.stats.parsing.start=R);const T=!(g&&((t=A.initSegment)==null?void 0:t.url)===((n=g.initSegment)==null?void 0:n.url)),P=new u4(m,D,p,v,o,T);if(!D||m||T){Ft.log(`[transmuxer-interface, ${A.type}]: Starting new transmux session for sn: ${r.sn} p: ${r.part} level: ${r.level} id: ${r.id} + Switching to level ${I} @ ${x|0} bps`),A.trigger(rt.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:u,stats:p})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(Ft.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new o5(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rt.FRAG_LOADING,this.onFragLoading,this),e.on(rt.FRAG_LOADED,this.onFragLoaded,this),e.on(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rt.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(rt.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rt.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rt.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(rt.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(rt.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rt.FRAG_LOADING,this.onFragLoading,this),e.off(rt.FRAG_LOADED,this.onFragLoaded,this),e.off(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rt.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(rt.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rt.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rt.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(rt.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,s){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,s){const u=s.frag;if(!this.ignoreFragment(u)){if(!u.bitrateTest){var A;this.fragCurrent=u,this.partCurrent=(A=s.part)!=null?A:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,s){this.clearTimer()}onError(e,s){if(!s.fatal)switch(s.details){case qt.BUFFER_ADD_CODEC_ERROR:case qt.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case qt.FRAG_LOAD_TIMEOUT:{const u=s.frag,{fragCurrent:A,partCurrent:y}=this;if(u&&A&&u.sn===A.sn&&u.level===A.level){const l=performance.now(),c=y?y.stats:u.stats,p=l-c.loading.start,r=c.loading.first?c.loading.first-c.loading.start:-1;if(c.loaded&&r>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(p-Math.min(t,r),c.loaded)}else this.bwEstimator.sampleTTFB(p)}break}}}getTimeToLoadFrag(e,s,u,A){const y=e+u/s,l=A?this.lastLevelLoadSec:0;return y+l}onLevelLoaded(e,s){const u=this.hls.config,{loading:A}=s.stats,y=A.end-A.start;Ci(y)&&(this.lastLevelLoadSec=y/1e3),s.details.live?this.bwEstimator.update(u.abrEwmaSlowLive,u.abrEwmaFastLive):this.bwEstimator.update(u.abrEwmaSlowVoD,u.abrEwmaFastVoD)}onFragLoaded(e,{frag:s,part:u}){const A=u?u.stats:s.stats;if(s.type===Hi.MAIN&&this.bwEstimator.sampleTTFB(A.loading.first-A.loading.start),!this.ignoreFragment(s)){if(this.clearTimer(),s.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const y=u?u.duration:s.duration,l=this.hls.levels[s.level],c=(l.loaded?l.loaded.bytes:0)+A.loaded,p=(l.loaded?l.loaded.duration:0)+y;l.loaded={bytes:c,duration:p},l.realBitrate=Math.round(8*c/p)}if(s.bitrateTest){const y={stats:A,frag:s,part:u,id:s.type};this.onFragBuffered(rt.FRAG_BUFFERED,y),s.bitrateTest=!1}else this.lastLoadedFragLevel=s.level}}onFragBuffered(e,s){const{frag:u,part:A}=s,y=A!=null&&A.stats.loaded?A.stats:u.stats;if(y.aborted||this.ignoreFragment(u))return;const l=y.parsing.end-y.loading.start-Math.min(y.loading.first-y.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,y.loaded),y.bwEstimate=this.getBwEstimate(),u.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Hi.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:s}=this.hls,u=this.getBwEstimate(),A=this.hls.config.maxStarvationDelay,y=this.findBestLevel(u,s,e,0,A,1,1);if(y>-1)return y;const l=this.hls.firstLevel,c=Math.min(Math.max(l,s),e);return Ft.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${l} clamped to ${c}`),c}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,u=this.bwEstimator.canEstimate(),A=this.lastLoadedFragLevel>-1;if(e!==-1&&(!u||!A||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const y=u&&A?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const l=this.hls.levels;if(l.length>Math.max(e,y)&&l[e].loadError<=l[y].loadError)return e}return this._nextAutoLevel=y,this.nextAutoLevelKey=this.getAutoLevelKey(),y}getAutoLevelKey(){var e;return`${this.getBwEstimate()}_${(e=this.hls.mainForwardBufferInfo)==null?void 0:e.len}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:s,hls:u}=this,{maxAutoLevel:A,config:y,minAutoLevel:l,media:c}=u,p=s?s.duration:e?e.duration:0,r=c&&c.playbackRate!==0?Math.abs(c.playbackRate):1,i=this.getBwEstimate(),t=u.mainForwardBufferInfo,n=(t?t.len:0)/r;let a=y.abrBandWidthFactor,o=y.abrBandWidthUpFactor;if(n){const b=this.findBestLevel(i,l,A,n,0,a,o);if(b>=0)return b}let d=p?Math.min(p,y.maxStarvationDelay):y.maxStarvationDelay;if(!n){const b=this.bitrateTestDelay;b&&(d=(p?Math.min(p,y.maxLoadingDelay):y.maxLoadingDelay)-b,Ft.info(`[abr] bitrate test took ${Math.round(1e3*b)}ms, set first fragment max fetchDuration to ${Math.round(1e3*d)} ms`),a=o=1)}const g=this.findBestLevel(i,l,A,n,d,a,o);if(Ft.info(`[abr] ${n?"rebuffering expected":"buffer is empty"}, optimal quality level ${g}`),g>-1)return g;const m=u.levels[l],v=u.levels[u.loadLevel];return(m==null?void 0:m.bitrate)<(v==null?void 0:v.bitrate)?l:u.loadLevel}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,s,u,A,y,l,c){var p;const r=A+y,i=this.lastLoadedFragLevel,t=i===-1?this.hls.firstLevel:i,{fragCurrent:n,partCurrent:a}=this,{levels:o,allAudioTracks:d,loadLevel:g,config:m}=this.hls;if(o.length===1)return 0;const v=o[t],b=!!(v!=null&&(p=v.details)!=null&&p.live),w=g===-1||i===-1;let C,D="SDR",R=(v==null?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:P}=m,L=this.audioTracksByGroup||(this.audioTracksByGroup=p5(d));if(w){if(this.firstSelection!==-1)return this.firstSelection;const te=this.codecTiers||(this.codecTiers=m5(o,L,s,u)),le=f5(te,D,e,T,P),{codecSet:ne,videoRanges:ee,minFramerate:M,minBitrate:Y,preferHDR:j}=le;C=ne,D=j?ee[ee.length-1]:ee[0],R=M,e=Math.max(e,Y),Ft.log(`[abr] picked start tier ${JSON.stringify(le)}`)}else C=v==null?void 0:v.codecSet,D=v==null?void 0:v.videoRange;const I=a?a.duration:n?n.duration:0,x=this.bwEstimator.getEstimateTTFB()/1e3,O=[];for(let te=u;te>=s;te--){var G,J;const le=o[te],ne=te>t;if(!le)continue;if(m.useMediaCapabilities&&!le.supportedResult&&!le.supportedPromise){const Z=navigator.mediaCapabilities;typeof(Z==null?void 0:Z.decodingInfo)=="function"&&l5(le,L,D,R,e,T)?(le.supportedPromise=c5(le,L,Z),le.supportedPromise.then(X=>{le.supportedResult=X;const oe=this.hls.levels,he=oe.indexOf(le);X.error?Ft.warn(`[abr] MediaCapabilities decodingInfo error: "${X.error}" for level ${he} ${JSON.stringify(X)}`):X.supported||(Ft.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${he} ${JSON.stringify(X)}`),he>-1&&oe.length>1&&(Ft.log(`[abr] Removing unsupported level ${he}`),this.hls.removeLevel(he)))})):le.supportedResult=Hp}if(C&&le.codecSet!==C||D&&le.videoRange!==D||ne&&R>le.frameRate||!ne&&R>0&&R =I*2&&y===0?o[te].averageBitrate:o[te].maxBitrate,z=this.getTimeToLoadFrag(x,Y,j*M,ee===void 0);if(Y>=j&&(te===i||le.loadError===0&&le.fragmentError===0)&&(z<=x||!Ci(z)||b&&!this.bitrateTestDelay||z ${te} adjustedbw(${Math.round(Y)})-bitrate=${Math.round(Y-j)} ttfb:${x.toFixed(1)} avgDuration:${M.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${z.toFixed(1)} firstSelection:${w} codecSet:${C} videoRange:${D} hls.loadLevel:${g}`)),w&&(this.firstSelection=te),te}}return-1}set nextAutoLevel(e){const s=Math.max(this.hls.minAutoLevel,e);this._nextAutoLevel!=s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}class v5{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var Fn={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class b5{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(rt.BUFFER_APPENDED,this.onBufferAppended,this),e.on(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rt.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(rt.BUFFER_APPENDED,this.onBufferAppended,this),e.off(rt.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rt.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,s){const u=this.activePartLists[s];if(u)for(let A=u.length;A--;){const y=u[A];if(!y)break;const l=y.end;if(y.start<=e&&l!==null&&e<=l)return y}return this.getBufferedFrag(e,s)}getBufferedFrag(e,s){const{fragments:u}=this,A=Object.keys(u);for(let y=A.length;y--;){const l=u[A[y]];if((l==null?void 0:l.body.type)===s&&l.buffered){const c=l.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,s,u,A){this.timeRanges&&(this.timeRanges[e]=s);const y=(A==null?void 0:A.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const c=this.fragments[l];if(!c||y>=c.body.sn)return;if(!c.buffered&&!c.loaded){c.body.type===u&&this.removeFragment(c.body);return}const p=c.range[e];p&&p.time.some(r=>{const i=!this.isTimeBuffered(r.startPTS,r.endPTS,s);return i&&this.removeFragment(c.body),i})})}detectPartialFragments(e){const s=this.timeRanges,{frag:u,part:A}=e;if(!s||u.sn==="initSegment")return;const y=Hs(u),l=this.fragments[y];if(!l||l.buffered&&u.gap)return;const c=!u.relurl;Object.keys(s).forEach(p=>{const r=u.elementaryStreams[p];if(!r)return;const i=s[p],t=c||r.partial===!0;l.range[p]=this.getBufferedTimes(u,A,t,i)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=u.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),eo(l)||this.removeParts(u.sn-1,u.type)):this.removeFragment(l.body)}removeParts(e,s){const u=this.activePartLists[s];u&&(this.activePartLists[s]=u.filter(A=>A.fragment.sn>=e))}fragBuffered(e,s){const u=Hs(e);let A=this.fragments[u];!A&&s&&(A=this.fragments[u]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),A&&(A.loaded=null,A.buffered=!0)}getBufferedTimes(e,s,u,A){const y={time:[],partial:u},l=e.start,c=e.end,p=e.minEndPTS||c,r=e.maxStartPTS||l;for(let i=0;i =t&&p<=n){y.time.push({startPTS:Math.max(l,A.start(i)),endPTS:Math.min(c,A.end(i))});break}else if(l t){const a=Math.max(l,A.start(i)),o=Math.min(c,A.end(i));o>a&&(y.partial=!0,y.time.push({startPTS:a,endPTS:o}))}else if(c<=t)break}return y}getPartialFragment(e){let s=null,u,A,y,l=0;const{bufferPadding:c,fragments:p}=this;return Object.keys(p).forEach(r=>{const i=p[r];i&&eo(i)&&(A=i.body.start-c,y=i.body.end+c,e>=A&&e<=y&&(u=Math.min(e-A,y-e),l<=u&&(s=i.body,l=u)))}),s}isEndListAppended(e){const s=this.endListFragments[e];return s!==void 0&&(s.buffered||eo(s))}getState(e){const s=Hs(e),u=this.fragments[s];return u?u.buffered?eo(u)?Fn.PARTIAL:Fn.OK:Fn.APPENDING:Fn.NOT_LOADED}isTimeBuffered(e,s,u){let A,y;for(let l=0;l =A&&s<=y)return!0;if(s<=A)return!1}return!1}onFragLoaded(e,s){const{frag:u,part:A}=s;if(u.sn==="initSegment"||u.bitrateTest)return;const y=A?null:s,l=Hs(u);this.fragments[l]={body:u,appendedPTS:null,loaded:y,buffered:!1,range:Object.create(null)}}onBufferAppended(e,s){const{frag:u,part:A,timeRanges:y}=s;if(u.sn==="initSegment")return;const l=u.type;if(A){let c=this.activePartLists[l];c||(this.activePartLists[l]=c=[]),c.push(A)}this.timeRanges=y,Object.keys(y).forEach(c=>{const p=y[c];this.detectEvictedFragments(c,p,l,A)})}onFragBuffered(e,s){this.detectPartialFragments(s)}hasFragment(e){const s=Hs(e);return!!this.fragments[s]}hasParts(e){var s;return!!((s=this.activePartLists[e])!=null&&s.length)}removeFragmentsInRange(e,s,u,A,y){A&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const c=this.fragments[l];if(!c)return;const p=c.body;p.type!==u||A&&!p.gap||p.start e&&(c.buffered||y)&&this.removeFragment(p)})}removeFragment(e){const s=Hs(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const u=this.activePartLists[e.type];if(u){const A=e.sn;this.activePartLists[e.type]=u.filter(y=>y.fragment.sn!==A)}delete this.fragments[s],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function eo(_){var e,s,u;return _.buffered&&(_.body.gap||((e=_.range.video)==null?void 0:e.partial)||((s=_.range.audio)==null?void 0:s.partial)||((u=_.range.audiovideo)==null?void 0:u.partial))}function Hs(_){return`${_.type}_${_.level}_${_.sn}`}const _5={length:0,start:()=>0,end:()=>0};class mn{static isBuffered(e,s){try{if(e){const u=mn.getBuffered(e);for(let A=0;A=u.start(A)&&s<=u.end(A))return!0}}catch{}return!1}static bufferInfo(e,s,u){try{if(e){const A=mn.getBuffered(e),y=[];let l;for(l=0;l t&&(A[i-1].end=e[r].end):A.push(e[r])}else A.push(e[r])}else A=e;let y=0,l,c=s,p=s;for(let r=0;r =i&&s s.startCC||_&&_.cc {if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(a=>a[0]==="GAP")){p(Kh(e));return}else e.gap=!1;const r=this.loader=e.loader=y?new y(A):new l(A),i=Wh(e),t=Gh(A.fragLoadPolicy.default),n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:zh};e.stats=r.stats,r.load(i,n,{onSuccess:(a,o,d,g)=>{this.resetLoader(e,r);let m=a.data;d.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(m.slice(0,16)),m=m.slice(16)),c({frag:e,part:null,payload:m,networkDetails:g})},onError:(a,o,d,g)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Dn({url:u,data:void 0},a),error:new Error(`HTTP Error ${a.code} ${a.text}`),networkDetails:d,stats:g}))},onAbort:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:d,stats:a}))},onTimeout:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:d,stats:a}))},onProgress:(a,o,d,g)=>{s&&s({frag:e,part:null,payload:d,networkDetails:g})}})})}loadPart(e,s,u){this.abort();const A=this.config,y=A.fLoader,l=A.loader;return new Promise((c,p)=>{if(this.loader&&this.loader.destroy(),e.gap||s.gap){p(Kh(e,s));return}const r=this.loader=e.loader=y?new y(A):new l(A),i=Wh(e,s),t=Gh(A.fragLoadPolicy.default),n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:zh};s.stats=r.stats,r.load(i,n,{onSuccess:(a,o,d,g)=>{this.resetLoader(e,r),this.updateStatsFromPart(e,s);const m={frag:e,part:s,payload:a.data,networkDetails:g};u(m),c(m)},onError:(a,o,d,g)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:s,response:Dn({url:i.url,data:void 0},a),error:new Error(`HTTP Error ${a.code} ${a.text}`),networkDetails:d,stats:g}))},onAbort:(a,o,d)=>{e.stats.aborted=s.stats.aborted,this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.INTERNAL_ABORTED,fatal:!1,frag:e,part:s,error:new Error("Aborted"),networkDetails:d,stats:a}))},onTimeout:(a,o,d)=>{this.resetLoader(e,r),p(new Qr({type:Wi.NETWORK_ERROR,details:qt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:s,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:d,stats:a}))}})})}updateStatsFromPart(e,s){const u=e.stats,A=s.stats,y=A.total;if(u.loaded+=A.loaded,y){const p=Math.round(e.duration/s.duration),r=Math.min(Math.round(u.loaded/y),p),t=(p-r)*Math.round(u.loaded/r);u.total=u.loaded+t}else u.total=Math.max(u.loaded,u.total);const l=u.loading,c=A.loading;l.start?l.first+=c.first-c.start:(l.start=c.start,l.first=c.first),l.end=c.end}resetLoader(e,s){e.loader=null,this.loader===s&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),s.destroy()}}function Wh(_,e=null){const s=e||_,u={frag:_,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},A=s.byteRangeStartOffset,y=s.byteRangeEndOffset;if(Ci(A)&&Ci(y)){var l;let c=A,p=y;if(_.sn==="initSegment"&&((l=_.decryptdata)==null?void 0:l.method)==="AES-128"){const r=y-A;r%16&&(p=y+(16-r%16)),A!==0&&(u.resetIV=!0,c=A-16)}u.rangeStart=c,u.rangeEnd=p}return u}function Kh(_,e){const s=new Error(`GAP ${_.gap?"tag":"attribute"} found`),u={type:Wi.MEDIA_ERROR,details:qt.FRAG_GAP,fatal:!1,frag:_,error:s,networkDetails:null};return e&&(u.part=e),(e||_).stats.aborted=!0,new Qr(u)}class Qr extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class x5{constructor(e,s){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=s}decrypt(e,s){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},s,e)}}class k5{constructor(e,s){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=s}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function R5(_){const e=_.byteLength,s=e&&new DataView(_.buffer).getUint8(e-1);return s?Ts(_,0,e-s):_}class I5{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const s=new DataView(e),u=new Uint32Array(4);for(let A=0;A<4;A++)u[A]=s.getUint32(A*4);return u}initTable(){const e=this.sBox,s=this.invSBox,u=this.subMix,A=u[0],y=u[1],l=u[2],c=u[3],p=this.invSubMix,r=p[0],i=p[1],t=p[2],n=p[3],a=new Uint32Array(256);let o=0,d=0,g=0;for(g=0;g<256;g++)g<128?a[g]=g<<1:a[g]=g<<1^283;for(g=0;g<256;g++){let m=d^d<<1^d<<2^d<<3^d<<4;m=m>>>8^m&255^99,e[o]=m,s[m]=o;const v=a[o],b=a[v],w=a[b];let C=a[m]*257^m*16843008;A[o]=C<<24|C>>>8,y[o]=C<<16|C>>>16,l[o]=C<<8|C>>>24,c[o]=C,C=w*16843009^b*65537^v*257^o*16843008,r[m]=C<<24|C>>>8,i[m]=C<<16|C>>>16,t[m]=C<<8|C>>>24,n[m]=C,o?(o=v^a[a[a[w^v]]],d^=a[a[d]]):o=d=1}}expandKey(e){const s=this.uint8ArrayToUint32Array_(e);let u=!0,A=0;for(;A A?(this.logOnce("WebCrypto AES decrypt"),new x5(A,new Uint8Array(u)).decrypt(e.buffer,y)):Promise.reject(new Error("web crypto not initialized"))).catch(y=>(Ft.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${y.name}: ${y.message}`),this.onWebCryptoError(e,s,u)))}onWebCryptoError(e,s,u){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,s,u);const A=this.flush();if(A)return A.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let s=e;const u=e.length-e.length%L5;return u!==e.length&&(s=Ts(e,0,u),this.remainderData=Ts(e,u)),s}logOnce(e){this.logEnabled&&(Ft.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const D5={toString:function(_){let e="";const s=_.length;for(let u=0;u c.end){const t=l>i;(l{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${y.part?" p: "+y.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(y)};this._doFragLoad(e,s,u,A).then(y=>{if(!y)return;const l=this.state;if(this.fragContextChanged(e)){(l===ni.FRAG_LOADING||!this.fragCurrent&&l===ni.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=ni.IDLE);return}"payload"in y&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(rt.FRAG_LOADED,y)),this._handleFragmentLoadComplete(y)}).catch(y=>{this.state===ni.STOPPED||this.state===ni.ERROR||(this.warn(y),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var s;const{fragmentTracker:u}=this;if(u.getState(e)===Fn.APPENDING){const y=e.type,l=this.getFwdBufferInfo(this.mediaBuffer,y),c=Math.max(e.duration,l?l.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&u.removeFragment(e)}else((s=this.mediaBuffer)==null?void 0:s.buffered.length)===0?u.removeAllFragments():u.hasParts(e.type)&&(u.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),u.getState(e)===Fn.PARTIAL&&u.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const s=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:s,part:null,stats:s.stats,id:s.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,s,u=null){if(!(e-s))return;const A={startOffset:e,endOffset:s,type:u};this.hls.trigger(rt.BUFFER_FLUSHING,A)}_loadInitSegment(e,s){this._doFragLoad(e,s).then(u=>{if(!u||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return u}).then(u=>{const{hls:A}=this,{payload:y}=u,l=e.decryptdata;if(y&&y.byteLength>0&&l!=null&&l.key&&l.iv&&l.method==="AES-128"){const c=self.performance.now();return this.decrypter.decrypt(new Uint8Array(y),l.key.buffer,l.iv.buffer).catch(p=>{throw A.trigger(rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_DECRYPT_ERROR,fatal:!1,error:p,reason:p.message,frag:e}),p}).then(p=>{const r=self.performance.now();return A.trigger(rt.FRAG_DECRYPTED,{frag:e,payload:p,stats:{tstart:c,tdecrypt:r}}),u.payload=p,this.completeInitSegmentLoad(u)})}return this.completeInitSegmentLoad(u)}).catch(u=>{this.state===ni.STOPPED||this.state===ni.ERROR||(this.warn(u),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:s}=this;if(!s)throw new Error("init load aborted, missing levels");const u=e.frag.stats;this.state=ni.IDLE,e.frag.data=new Uint8Array(e.payload),u.parsing.start=u.buffering.start=self.performance.now(),u.parsing.end=u.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:s}=this;return!e||!s||e.sn!==s.sn||e.level!==s.level}fragBufferedComplete(e,s){var u,A,y,l;const c=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${s?" part: "+s.index:""} of ${this.playlistType===Hi.MAIN?"level":"track"} ${e.level} (frag:[${((u=e.startPTS)!=null?u:NaN).toFixed(3)}-${((A=e.endPTS)!=null?A:NaN).toFixed(3)}] > buffer:${c?D5.toString(mn.getBuffered(c)):"(detached)"})`),e.sn!=="initSegment"){var p;if(e.type!==Hi.SUBTITLE){const i=e.elementaryStreams;if(!Object.keys(i).some(t=>!!i[t])){this.state=ni.IDLE;return}}const r=(p=this.levels)==null?void 0:p[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=ni.IDLE,c&&(!this.loadedmetadata&&e.type==Hi.MAIN&&c.buffered.length&&((y=this.fragCurrent)==null?void 0:y.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:s}=this;if(!s)return;const{frag:u,part:A,partsLoaded:y}=e,l=!y||y.length===0||y.some(p=>!p),c=new Td(u.level,u.sn,u.stats.chunkCount+1,0,A?A.index:-1,!l);s.flush(c)}_handleFragmentLoadProgress(e){}_doFragLoad(e,s,u=null,A){var y;const l=s==null?void 0:s.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let c=null;if(e.encrypted&&!((y=e.decryptdata)!=null&&y.key)?(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=ni.KEY_LOADING,this.fragCurrent=e,c=this.keyLoader.load(e).then(i=>{if(!this.fragContextChanged(i.frag))return this.hls.trigger(rt.KEY_LOADED,i),this.state===ni.KEY_LOADING&&(this.state=ni.IDLE),i}),this.hls.trigger(rt.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(c=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(e,l.encryptedFragments),u=Math.max(e.start,u||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const i=l.partList;if(i&&A){u>e.end&&l.fragmentHint&&(e=l.fragmentHint);const t=this.getNextPart(i,e,u);if(t>-1){const n=i[t];this.log(`Loading part sn: ${e.sn} p: ${n.index} cc: ${e.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${t}-${i.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(u.toFixed(3))}`),this.nextLoadPosition=n.start+n.duration,this.state=ni.FRAG_LOADING;let a;return c?a=c.then(o=>!o||this.fragContextChanged(o.frag)?null:this.doFragPartsLoad(e,n,s,A)).catch(o=>this.handleFragLoadError(o)):a=this.doFragPartsLoad(e,n,s,A).catch(o=>this.handleFragLoadError(o)),this.hls.trigger(rt.FRAG_LOADING,{frag:e,part:n,targetBufferTime:u}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):a}else if(!e.url||this.loadedEndOfParts(i,u))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(u.toFixed(3))}`),Ci(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ni.FRAG_LOADING;const p=this.config.progressive;let r;return p&&c?r=c.then(i=>!i||this.fragContextChanged(i==null?void 0:i.frag)?null:this.fragmentLoader.load(e,A)).catch(i=>this.handleFragLoadError(i)):r=Promise.all([this.fragmentLoader.load(e,p?A:void 0),c]).then(([i])=>(!p&&i&&A&&A(i),i)).catch(i=>this.handleFragLoadError(i)),this.hls.trigger(rt.FRAG_LOADING,{frag:e,targetBufferTime:u}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):r}doFragPartsLoad(e,s,u,A){return new Promise((y,l)=>{var c;const p=[],r=(c=u.details)==null?void 0:c.partList,i=t=>{this.fragmentLoader.loadPart(e,t,A).then(n=>{p[t.index]=n;const a=n.part;this.hls.trigger(rt.FRAG_LOADED,n);const o=Fh(u,e.sn,t.index+1)||Gp(r,e.sn,t.index+1);if(o)i(o);else return y({frag:e,part:a,partsLoaded:p})}).catch(l)};i(s)})}handleFragLoadError(e){if("data"in e){const s=e.data;e.data&&s.details===qt.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(rt.ERROR,s)}else this.hls.trigger(rt.ERROR,{type:Wi.OTHER_ERROR,details:qt.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const s=this.getCurrentContext(e);if(!s||this.state!==ni.PARSING){!this.fragCurrent&&this.state!==ni.STOPPED&&this.state!==ni.ERROR&&(this.state=ni.IDLE);return}const{frag:u,part:A,level:y}=s,l=self.performance.now();u.stats.parsing.end=l,A&&(A.stats.parsing.end=l),this.updateLevelTiming(u,A,y,e.partial)}getCurrentContext(e){const{levels:s,fragCurrent:u}=this,{level:A,sn:y,part:l}=e;if(!(s!=null&&s[A]))return this.warn(`Levels object was unset while buffering fragment ${y} of level ${A}. The current chunk will not be buffered.`),null;const c=s[A],p=l>-1?Fh(c,y,l):null,r=p?p.fragment:t5(c,y,u);return r?(u&&u!==r&&(r.stats=u.stats),{frag:r,part:p,level:c}):null}bufferFragmentData(e,s,u,A,y){var l;if(!e||this.state!==ni.PARSING)return;const{data1:c,data2:p}=e;let r=c;if(c&&p&&(r=Ar(c,p)),!((l=r)!=null&&l.length))return;const i={type:e.type,frag:s,part:u,chunkMeta:A,parent:s.type,data:r};if(this.hls.trigger(rt.BUFFER_APPENDING,i),e.dropped&&e.independent&&!u){if(y)return;this.flushBufferGap(s)}}flushBufferGap(e){const s=this.media;if(!s)return;if(!mn.isBuffered(s,s.currentTime)){this.flushMainBuffer(0,e.start);return}const u=s.currentTime,A=mn.bufferInfo(s,u,0),y=e.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,y*.25),c=Math.max(Math.min(e.start-l,A.end-l),u+l);e.start-c>l&&this.flushMainBuffer(c,e.start)}getFwdBufferInfo(e,s){const u=this.getLoadPosition();return Ci(u)?this.getFwdBufferInfoAtPos(e,u,s):null}getFwdBufferInfoAtPos(e,s,u){const{config:{maxBufferHole:A}}=this,y=mn.bufferInfo(e,s,A);if(y.len===0&&y.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(s,u);if(l&&y.nextStart =u?(s.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${s.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,s=Hi.MAIN){const u=this.fragmentTracker.getAppendedFrag(e,Hi.MAIN);return u&&"fragment"in u?u.fragment:u}getNextFragment(e,s){const u=s.fragments,A=u.length;if(!A)return null;const{config:y}=this,l=u[0].start;let c;if(s.live){const p=y.initialLiveManifestSize;if(A s}getNextFragmentLoopLoading(e,s,u,A,y){const l=e.gap,c=this.getNextFragment(this.nextLoadPosition,s);if(c===null)return c;if(e=c,l&&e&&!e.gap&&u.nextStart){const p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,u.nextStart,A);if(p!==null&&u.len+p.len>=y)return this.log(`buffer full after gaps in "${A}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,s,u){let A=-1,y=!1,l=!0;for(let c=0,p=e.length;c
-1&&u
u.start&&u.loaded}getInitialLiveFragment(e,s){const u=this.fragPrevious;let A=null;if(u){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${u.programDateTime}`),A=n5(s,u.endProgramDateTime,this.config.maxFragLookUpTolerance)),!A){const y=u.sn+1;if(y>=e.startSN&&y<=e.endSN){const l=s[y-e.startSN];u.cc===l.cc&&(A=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${A.sn}`))}A||(A=s5(s,u.cc),A&&this.log(`Live playlist, switching playlist, load frag with same CC: ${A.sn}`))}}else{const y=this.hls.liveSyncPosition;y!==null&&(A=this.getFragmentAtPosition(y,this.bitrateTest?e.fragmentEnd:e.edge,e))}return A}getFragmentAtPosition(e,s,u){const{config:A}=this;let{fragPrevious:y}=this,{fragments:l,endSN:c}=u;const{fragmentHint:p}=u,r=A.maxFragLookUpTolerance,i=u.partList,t=!!(A.lowLatencyMode&&i!=null&&i.length&&p);t&&p&&!this.bitrateTest&&(l=l.concat(p),c=p.sn);let n;if(e s-r?0:r;n=Po(y,l,e,a)}else n=l[l.length-1];if(n){const a=n.sn-u.startSN,o=this.fragmentTracker.getState(n);if((o===Fn.OK||o===Fn.PARTIAL&&n.gap)&&(y=n),y&&n.sn===y.sn&&(!t||i[0].fragment.sn>n.sn)&&y&&n.level===y.level){const g=l[a+1];n.sn=l-s.maxFragLookUpTolerance&&y<=c;if(A!==null&&u.duration>A&&(y${e.startSN} prev-sn: ${p?p.sn:"na"} fragments: ${A}`),r}return y}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,s){let u=this.startPosition;if(u ${(A=this.fragCurrent)==null?void 0:A.url}`);return}const y=s.details===qt.FRAG_GAP;y&&this.fragmentTracker.fragBuffered(u,!0);const l=s.errorAction,{action:c,retryCount:p=0,retryConfig:r}=l||{};if(l&&c===Vn.RetryRequest&&r){this.resetStartWhenNotLoaded(this.levelLastLoaded);const i=wd(r,p);this.warn(`Fragment ${u.sn} of ${e} ${u.level} errored with ${s.details}, retrying loading ${p+1}/${r.maxNumRetry} in ${i}ms`),l.resolved=!0,this.retryDate=self.performance.now()+i,this.state=ni.FRAG_LOADING_WAITING_RETRY}else if(r&&l)if(this.resetFragmentErrors(e),p.5;A&&this.reduceMaxBufferLength(u.len);const y=!A;return y&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${s} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),y}return!1}resetFragmentErrors(e){e===Hi.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ni.STOPPED&&(this.state=ni.IDLE)}afterBufferFlushed(e,s,u){if(!e)return;const A=mn.getBuffered(e);this.fragmentTracker.detectEvictedFragments(s,A,u),this.state===ni.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ni.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const s=e?e.details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,s,u,A){var y;const l=u.details;if(!l){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((p,r)=>{const i=e.elementaryStreams[r];if(i){const t=i.endPTS-i.startPTS;if(t<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${t})`),p||!1;const n=A?0:Fp(l,e,i.startPTS,i.endPTS,i.startDTS,i.endDTS);return this.hls.trigger(rt.LEVEL_PTS_UPDATED,{details:l,level:u,drift:n,type:r,frag:e,start:i.startPTS,end:i.endPTS}),!0}return p},!1)&&((y=this.transmuxer)==null?void 0:y.error)===null){const p=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(u.fragmentError===0&&(u.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(p.message),this.hls.trigger(rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!1,error:p,frag:e,reason:`Found no media in msn ${e.sn} of level "${u.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=ni.PARSED,this.hls.trigger(rt.FRAG_PARSED,{frag:e,part:s})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const s=this._state;s!==e&&(this._state=e,this.log(`${s}->${e}`))}get state(){return this._state}}class Wp{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:s}=this;let u;if(e.length)e.length===1?u=e[0]:u=O5(e,s);else return new Uint8Array(0);return this.reset(),u}reset(){this.chunks.length=0,this.dataLength=0}}function O5(_,e){const s=new Uint8Array(e);let u=0;for(let A=0;A<_.length;A++){const y=_[A];s.set(y,u),u+=y.length}return s}function M5(){return typeof __HLS_WORKER_BUNDLE__=="function"}function P5(){const _=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(_);return{worker:new self.Worker(e),objectURL:e}}function B5(_){const e=new self.URL(_,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Ur(_="",e=9e4){return{type:_,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class kd{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,s,u,A){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,s){return!1}appendFrame(e,s,u){}demux(e,s){this.cachedData&&(e=Ar(this.cachedData,e),this.cachedData=null);let u=Ra(e,0),A=u?u.length:0,y;const l=this._audioTrack,c=this._id3Track,p=u?_d(u):void 0,r=e.length;for((this.basePTS===null||this.frameIndex===0&&Ci(p))&&(this.basePTS=N5(p,s,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),u&&u.length>0&&c.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:xr.audioId3,duration:Number.POSITIVE_INFINITY});A {if(Ci(_))return _*90;const u=s?s.baseTime*9e4/s.timescale:0;return e*9e4+u};function F5(_,e,s,u){let A,y,l,c;const p=navigator.userAgent.toLowerCase(),r=u,i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];A=((e[s+2]&192)>>>6)+1;const t=(e[s+2]&60)>>>2;if(t>i.length-1){const n=new Error(`invalid ADTS sampling index:${t}`);_.emit(rt.ERROR,rt.ERROR,{type:Wi.MEDIA_ERROR,details:qt.FRAG_PARSING_ERROR,fatal:!0,error:n,reason:n.message});return}return l=(e[s+2]&1)<<2,l|=(e[s+3]&192)>>>6,Ft.log(`manifest codec:${u}, ADTS type:${A}, samplingIndex:${t}`),/firefox/i.test(p)?t>=6?(A=5,c=new Array(4),y=t-3):(A=2,c=new Array(2),y=t):p.indexOf("android")!==-1?(A=2,c=new Array(2),y=t):(A=5,c=new Array(4),u&&(u.indexOf("mp4a.40.29")!==-1||u.indexOf("mp4a.40.5")!==-1)||!u&&t>=6?y=t-3:((u&&u.indexOf("mp4a.40.2")!==-1&&(t>=6&&l===1||/vivaldi/i.test(p))||!u&&l===1)&&(A=2,c=new Array(2)),y=t)),c[0]=A<<3,c[0]|=(t&14)>>1,c[1]|=(t&1)<<7,c[1]|=l<<3,A===5&&(c[1]|=(y&14)>>1,c[2]=(y&1)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:i[t],channelCount:l,codec:"mp4a.40."+A,manifestCodec:r}}function Kp(_,e){return _[e]===255&&(_[e+1]&246)===240}function qp(_,e){return _[e+1]&1?7:9}function Rd(_,e){return(_[e+3]&3)<<11|_[e+4]<<3|(_[e+5]&224)>>>5}function U5(_,e){return e+5<_.length}function No(_,e){return e+1<_.length&&Kp(_,e)}function G5(_,e){return U5(_,e)&&Kp(_,e)&&Rd(_,e)<=_.length-e}function j5(_,e){if(No(_,e)){const s=qp(_,e);if(e+s>=_.length)return!1;const u=Rd(_,e);if(u<=s)return!1;const A=e+u;return A===_.length||No(_,A)}return!1}function Yp(_,e,s,u,A){if(!_.samplerate){const y=F5(e,s,u,A);if(!y)return;_.config=y.config,_.samplerate=y.samplerate,_.channelCount=y.channelCount,_.codec=y.codec,_.manifestCodec=y.manifestCodec,Ft.log(`parsed codec:${_.codec}, rate:${y.samplerate}, channels:${y.channelCount}`)}}function Jp(_){return 1024*9e4/_}function V5(_,e){const s=qp(_,e);if(e+s<=_.length){const u=Rd(_,e)-s;if(u>0)return{headerLength:s,frameLength:u}}}function Qp(_,e,s,u,A){const y=Jp(_.samplerate),l=u+A*y,c=V5(e,s);let p;if(c){const{frameLength:t,headerLength:n}=c,a=n+t,o=Math.max(0,s+a-e.length);o?(p=new Uint8Array(a-n),p.set(e.subarray(s+n,e.length),0)):p=e.subarray(s+n,s+a);const d={unit:p,pts:l};return o||_.samples.push(d),{sample:d,length:a,missing:o}}const r=e.length-s;return p=new Uint8Array(r),p.set(e.subarray(s,e.length),0),{sample:{unit:p,pts:l},length:r,missing:-1}}let io=null;const H5=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],z5=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],W5=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],K5=[0,1,1,4];function Zp(_,e,s,u,A){if(s+24>e.length)return;const y=Xp(e,s);if(y&&s+y.frameLength<=e.length){const l=y.samplesPerFrame*9e4/y.sampleRate,c=u+A*l,p={unit:e.subarray(s,s+y.frameLength),pts:c,dts:c};return _.config=[],_.channelCount=y.channelCount,_.samplerate=y.sampleRate,_.samples.push(p),{sample:p,length:y.frameLength,missing:0}}}function Xp(_,e){const s=_[e+1]>>3&3,u=_[e+1]>>1&3,A=_[e+2]>>4&15,y=_[e+2]>>2&3;if(s!==1&&A!==0&&A!==15&&y!==3){const l=_[e+2]>>1&1,c=_[e+3]>>6,p=s===3?3-u:u===3?3:4,r=H5[p*14+A-1]*1e3,t=z5[(s===3?0:s===2?1:2)*3+y],n=c===3?1:2,a=W5[s][u],o=K5[u],d=a*8*o,g=Math.floor(a*r/t+l)*o;if(io===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);io=b?parseInt(b[1]):0}return!!io&&io<=87&&u===2&&r>=224e3&&c===0&&(_[e+3]=_[e+3]|128),{sampleRate:t,channelCount:n,frameLength:g,samplesPerFrame:d}}}function Id(_,e){return _[e]===255&&(_[e+1]&224)===224&&(_[e+1]&6)!==0}function $p(_,e){return e+1<_.length&&Id(_,e)}function q5(_,e){return Id(_,e)&&4<=_.length-e}function e0(_,e){if(e+1<_.length&&Id(_,e)){const u=Xp(_,e);let A=4;u!=null&&u.frameLength&&(A=u.frameLength);const y=e+A;return y===_.length||$p(_,y)}return!1}class Y5 extends kd{constructor(e,s){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=s}resetInitSegment(e,s,u,A){super.resetInitSegment(e,s,u,A),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:s,duration:A,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const s=Ra(e,0);let u=(s==null?void 0:s.length)||0;if(e0(e,u))return!1;for(let A=e.length;u{const l=C_(y);if(J5.test(l.schemeIdUri)){const c=Ci(l.presentationTime)?l.presentationTime/l.timeScale:s+l.presentationTimeDelta/l.timeScale;let p=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;p<=.001&&(p=Number.POSITIVE_INFINITY);const r=l.payload;u.samples.push({data:r,len:r.byteLength,dts:c,pts:c,type:xr.emsg,duration:p})}})}return u}demuxSampleAes(e,s,u){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const t0=(_,e)=>{let s=0,u=5;e+=u;const A=new Uint32Array(1),y=new Uint32Array(1),l=new Uint8Array(1);for(;u>0;){l[0]=_[e];const c=Math.min(u,8),p=8-c;y[0]=4278190080>>>24+p< >p,s=s?s<
e.length||e[s]!==11||e[s+1]!==119)return-1;const y=e[s+4]>>6;if(y>=3)return-1;const c=[48e3,44100,32e3][y],p=e[s+4]&63,i=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][p*3+y]*2;if(s+i>e.length)return-1;const t=e[s+6]>>5;let n=0;t===2?n+=2:(t&1&&t!==1&&(n+=2),t&4&&(n+=2));const a=(e[s+6]<<8|e[s+7])>>12-n&1,d=[2,1,2,3,3,4,4,5][t]+a,g=e[s+5]>>3,m=e[s+5]&7,v=new Uint8Array([y<<6|g<<1|m>>2,(m&3)<<6|t<<3|a<<2|p>>4,p<<4&224]),b=1536/c*9e4,w=u+A*b,C=e.subarray(s,s+i);return _.config=v,_.channelCount=d,_.samplerate=c,_.samples.push({unit:C,pts:w}),i}class n0{constructor(){this.VideoSample=null}createVideoSample(e,s,u,A){return{key:e,frame:!1,pts:s,dts:u,units:[],debug:A,length:0}}getLastNalUnit(e){var s;let u=this.VideoSample,A;if((!u||u.units.length===0)&&(u=e[e.length-1]),(s=u)!=null&&s.units){const y=u.units;A=y[y.length-1]}return A}pushAccessUnit(e,s){if(e.units.length&&e.frame){if(e.pts===void 0){const u=s.samples,A=u.length;if(A){const y=u[A-1];e.pts=y.pts,e.dts=y.dts}else{s.dropped++;return}}s.samples.push(e)}e.debug.length&&Ft.log(e.pts+"/"+e.dts+":"+e.debug)}parseNALu(e,s){const u=s.byteLength;let A=e.naluState||0;const y=A,l=[];let c=0,p,r,i,t=-1,n=0;for(A===-1&&(t=0,n=this.getNALuType(s,0),A=0,c=1);c