lemon-mse 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/_hls.d.ts +3105 -0
- package/dist/es/flv.d.ts +410 -0
- package/dist/es/flv.js +1 -0
- package/dist/es/hls.d.ts +3 -0
- package/dist/es/hls.js +1 -0
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +1 -0
- package/dist/flv.js +1 -0
- package/dist/hls.js +1 -0
- package/dist/index.js +1 -0
- package/package.json +14 -9
- package/build.config.ts +0 -22
- package/dist/hls.d.mts +0 -7
- package/dist/hls.d.ts +0 -7
- package/dist/hls.mjs +0 -14
- package/dist/xg-flv-hls.d.mts +0 -9
- package/dist/xg-flv-hls.d.ts +0 -9
- package/dist/xg-flv-hls.mjs +0 -8
- package/dist/xg-flv.d.mts +0 -1
- package/dist/xg-flv.d.ts +0 -1
- package/dist/xg-flv.mjs +0 -6
- package/dist/xg-hls.d.mts +0 -1
- package/dist/xg-hls.d.ts +0 -1
- package/dist/xg-hls.mjs +0 -8
- package/src/hls.ts +0 -8
- package/src/xg-flv-hls.ts +0 -4
- package/src/xg-flv.ts +0 -2
- package/src/xg-hls.ts +0 -1
- package/tsconfig.json +0 -28
package/dist/xg-flv-hls.mjs
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
function lr(i,o){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);o&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),e.push.apply(e,r)}return e}function Pe(i){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?lr(Object(e),!0).forEach(function(r){$(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):lr(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function Q(){Q=function(){return i};var i={},o=Object.prototype,e=o.hasOwnProperty,r=Object.defineProperty||function(m,g,_){m[g]=_.value},t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",a=t.asyncIterator||"@@asyncIterator",s=t.toStringTag||"@@toStringTag";function u(m,g,_){return Object.defineProperty(m,g,{value:_,enumerable:!0,configurable:!0,writable:!0}),m[g]}try{u({},"")}catch{u=function(g,_,D){return g[_]=D}}function l(m,g,_,D){var w=g&&g.prototype instanceof v?g:v,P=Object.create(w.prototype),C=new G(D||[]);return r(P,"_invoke",{value:k(m,_,C)}),P}function f(m,g,_){try{return{type:"normal",arg:m.call(g,_)}}catch(D){return{type:"throw",arg:D}}}i.wrap=l;var c={};function v(){}function d(){}function p(){}var y={};u(y,n,function(){return this});var h=Object.getPrototypeOf,b=h&&h(h(M([])));b&&b!==o&&e.call(b,n)&&(y=b);var S=p.prototype=v.prototype=Object.create(y);function E(m){["next","throw","return"].forEach(function(g){u(m,g,function(_){return this._invoke(g,_)})})}function A(m,g){function _(w,P,C,H){var z=f(m[w],m,P);if(z.type!=="throw"){var R=z.arg,te=R.value;return te&&typeof te=="object"&&e.call(te,"__await")?g.resolve(te.__await).then(function(x){_("next",x,C,H)},function(x){_("throw",x,C,H)}):g.resolve(te).then(function(x){R.value=x,C(R)},function(x){return _("throw",x,C,H)})}H(z.arg)}var D;r(this,"_invoke",{value:function(w,P){function C(){return new g(function(H,z){_(w,P,H,z)})}return D=D?D.then(C,C):C()}})}function k(m,g,_){var D="suspendedStart";return function(w,P){if(D==="executing")throw new Error("Generator is already running");if(D==="completed"){if(w==="throw")throw P;return X()}for(_.method=w,_.arg=P;;){var C=_.delegate;if(C){var H=U(C,_);if(H){if(H===c)continue;return H}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(D==="suspendedStart")throw D="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);D="executing";var z=f(m,g,_);if(z.type==="normal"){if(D=_.done?"completed":"suspendedYield",z.arg===c)continue;return{value:z.arg,done:_.done}}z.type==="throw"&&(D="completed",_.method="throw",_.arg=z.arg)}}}function U(m,g){var _=g.method,D=m.iterator[_];if(D===void 0)return g.delegate=null,_==="throw"&&m.iterator.return&&(g.method="return",g.arg=void 0,U(m,g),g.method==="throw")||_!=="return"&&(g.method="throw",g.arg=new TypeError("The iterator does not provide a '"+_+"' method")),c;var w=f(D,m.iterator,g.arg);if(w.type==="throw")return g.method="throw",g.arg=w.arg,g.delegate=null,c;var P=w.arg;return P?P.done?(g[m.resultName]=P.value,g.next=m.nextLoc,g.method!=="return"&&(g.method="next",g.arg=void 0),g.delegate=null,c):P:(g.method="throw",g.arg=new TypeError("iterator result is not an object"),g.delegate=null,c)}function N(m){var g={tryLoc:m[0]};1 in m&&(g.catchLoc=m[1]),2 in m&&(g.finallyLoc=m[2],g.afterLoc=m[3]),this.tryEntries.push(g)}function F(m){var g=m.completion||{};g.type="normal",delete g.arg,m.completion=g}function G(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(N,this),this.reset(!0)}function M(m){if(m){var g=m[n];if(g)return g.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var _=-1,D=function w(){for(;++_<m.length;)if(e.call(m,_))return w.value=m[_],w.done=!1,w;return w.value=void 0,w.done=!0,w};return D.next=D}}return{next:X}}function X(){return{value:void 0,done:!0}}return d.prototype=p,r(S,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,s,"GeneratorFunction"),i.isGeneratorFunction=function(m){var g=typeof m=="function"&&m.constructor;return!!g&&(g===d||(g.displayName||g.name)==="GeneratorFunction")},i.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,p):(m.__proto__=p,u(m,s,"GeneratorFunction")),m.prototype=Object.create(S),m},i.awrap=function(m){return{__await:m}},E(A.prototype),u(A.prototype,a,function(){return this}),i.AsyncIterator=A,i.async=function(m,g,_,D,w){w===void 0&&(w=Promise);var P=new A(l(m,g,_,D),w);return i.isGeneratorFunction(g)?P:P.next().then(function(C){return C.done?C.value:P.next()})},E(S),u(S,s,"Generator"),u(S,n,function(){return this}),u(S,"toString",function(){return"[object Generator]"}),i.keys=function(m){var g=Object(m),_=[];for(var D in g)_.push(D);return _.reverse(),function w(){for(;_.length;){var P=_.pop();if(P in g)return w.value=P,w.done=!1,w}return w.done=!0,w}},i.values=M,G.prototype={constructor:G,reset:function(m){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!m)for(var g in this)g.charAt(0)==="t"&&e.call(this,g)&&!isNaN(+g.slice(1))&&(this[g]=void 0)},stop:function(){this.done=!0;var m=this.tryEntries[0].completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var g=this;function _(z,R){return P.type="throw",P.arg=m,g.next=z,R&&(g.method="next",g.arg=void 0),!!R}for(var D=this.tryEntries.length-1;D>=0;--D){var w=this.tryEntries[D],P=w.completion;if(w.tryLoc==="root")return _("end");if(w.tryLoc<=this.prev){var C=e.call(w,"catchLoc"),H=e.call(w,"finallyLoc");if(C&&H){if(this.prev<w.catchLoc)return _(w.catchLoc,!0);if(this.prev<w.finallyLoc)return _(w.finallyLoc)}else if(C){if(this.prev<w.catchLoc)return _(w.catchLoc,!0)}else{if(!H)throw new Error("try statement without catch or finally");if(this.prev<w.finallyLoc)return _(w.finallyLoc)}}}},abrupt:function(m,g){for(var _=this.tryEntries.length-1;_>=0;--_){var D=this.tryEntries[_];if(D.tryLoc<=this.prev&&e.call(D,"finallyLoc")&&this.prev<D.finallyLoc){var w=D;break}}w&&(m==="break"||m==="continue")&&w.tryLoc<=g&&g<=w.finallyLoc&&(w=null);var P=w?w.completion:{};return P.type=m,P.arg=g,w?(this.method="next",this.next=w.finallyLoc,c):this.complete(P)},complete:function(m,g){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&g&&(this.next=g),c},finish:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.finallyLoc===m)return this.complete(_.completion,_.afterLoc),F(_),c}},catch:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.tryLoc===m){var D=_.completion;if(D.type==="throw"){var w=D.arg;F(_)}return w}}throw new Error("illegal catch attempt")},delegateYield:function(m,g,_){return this.delegate={iterator:M(m),resultName:g,nextLoc:_},this.method==="next"&&(this.arg=void 0),c}},i}function fr(i,o,e,r,t,n,a){try{var s=i[n](a),u=s.value}catch(l){e(l);return}s.done?o(u):Promise.resolve(u).then(r,t)}function ve(i){return function(){var o=this,e=arguments;return new Promise(function(r,t){var n=i.apply(o,e);function a(u){fr(n,r,t,a,s,"next",u)}function s(u){fr(n,r,t,a,s,"throw",u)}a(void 0)})}}function cr(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function hr(i,o){for(var e=0;e<o.length;e++){var r=o[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,vr(r.key),r)}}function dr(i,o,e){return o&&hr(i.prototype,o),e&&hr(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function $(i,o,e){return o=vr(o),o in i?Object.defineProperty(i,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[o]=e,i}function wn(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),o&&Lt(i,o)}function ut(i){return ut=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ut(i)}function Lt(i,o){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},Lt(i,o)}function kn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function J(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Tn(i,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return J(i)}function An(i){var o=kn();return function(){var r=ut(i),t;if(o){var n=ut(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Tn(this,t)}}function Dn(i,o){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,o||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}function vr(i){var o=Dn(i,"string");return typeof o=="symbol"?o:String(o)}function Ot(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function pr(i,o){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);o&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),e.push.apply(e,r)}return e}function et(i){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?pr(Object(e),!0).forEach(function(r){L(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):pr(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function fe(){fe=function(){return i};var i={},o=Object.prototype,e=o.hasOwnProperty,r=Object.defineProperty||function(m,g,_){m[g]=_.value},t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",a=t.asyncIterator||"@@asyncIterator",s=t.toStringTag||"@@toStringTag";function u(m,g,_){return Object.defineProperty(m,g,{value:_,enumerable:!0,configurable:!0,writable:!0}),m[g]}try{u({},"")}catch{u=function(g,_,D){return g[_]=D}}function l(m,g,_,D){var w=g&&g.prototype instanceof v?g:v,P=Object.create(w.prototype),C=new G(D||[]);return r(P,"_invoke",{value:k(m,_,C)}),P}function f(m,g,_){try{return{type:"normal",arg:m.call(g,_)}}catch(D){return{type:"throw",arg:D}}}i.wrap=l;var c={};function v(){}function d(){}function p(){}var y={};u(y,n,function(){return this});var h=Object.getPrototypeOf,b=h&&h(h(M([])));b&&b!==o&&e.call(b,n)&&(y=b);var S=p.prototype=v.prototype=Object.create(y);function E(m){["next","throw","return"].forEach(function(g){u(m,g,function(_){return this._invoke(g,_)})})}function A(m,g){function _(w,P,C,H){var z=f(m[w],m,P);if(z.type!=="throw"){var R=z.arg,te=R.value;return te&&typeof te=="object"&&e.call(te,"__await")?g.resolve(te.__await).then(function(x){_("next",x,C,H)},function(x){_("throw",x,C,H)}):g.resolve(te).then(function(x){R.value=x,C(R)},function(x){return _("throw",x,C,H)})}H(z.arg)}var D;r(this,"_invoke",{value:function(w,P){function C(){return new g(function(H,z){_(w,P,H,z)})}return D=D?D.then(C,C):C()}})}function k(m,g,_){var D="suspendedStart";return function(w,P){if(D==="executing")throw new Error("Generator is already running");if(D==="completed"){if(w==="throw")throw P;return X()}for(_.method=w,_.arg=P;;){var C=_.delegate;if(C){var H=U(C,_);if(H){if(H===c)continue;return H}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(D==="suspendedStart")throw D="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);D="executing";var z=f(m,g,_);if(z.type==="normal"){if(D=_.done?"completed":"suspendedYield",z.arg===c)continue;return{value:z.arg,done:_.done}}z.type==="throw"&&(D="completed",_.method="throw",_.arg=z.arg)}}}function U(m,g){var _=g.method,D=m.iterator[_];if(D===void 0)return g.delegate=null,_==="throw"&&m.iterator.return&&(g.method="return",g.arg=void 0,U(m,g),g.method==="throw")||_!=="return"&&(g.method="throw",g.arg=new TypeError("The iterator does not provide a '"+_+"' method")),c;var w=f(D,m.iterator,g.arg);if(w.type==="throw")return g.method="throw",g.arg=w.arg,g.delegate=null,c;var P=w.arg;return P?P.done?(g[m.resultName]=P.value,g.next=m.nextLoc,g.method!=="return"&&(g.method="next",g.arg=void 0),g.delegate=null,c):P:(g.method="throw",g.arg=new TypeError("iterator result is not an object"),g.delegate=null,c)}function N(m){var g={tryLoc:m[0]};1 in m&&(g.catchLoc=m[1]),2 in m&&(g.finallyLoc=m[2],g.afterLoc=m[3]),this.tryEntries.push(g)}function F(m){var g=m.completion||{};g.type="normal",delete g.arg,m.completion=g}function G(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(N,this),this.reset(!0)}function M(m){if(m){var g=m[n];if(g)return g.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var _=-1,D=function w(){for(;++_<m.length;)if(e.call(m,_))return w.value=m[_],w.done=!1,w;return w.value=void 0,w.done=!0,w};return D.next=D}}return{next:X}}function X(){return{value:void 0,done:!0}}return d.prototype=p,r(S,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,s,"GeneratorFunction"),i.isGeneratorFunction=function(m){var g=typeof m=="function"&&m.constructor;return!!g&&(g===d||(g.displayName||g.name)==="GeneratorFunction")},i.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,p):(m.__proto__=p,u(m,s,"GeneratorFunction")),m.prototype=Object.create(S),m},i.awrap=function(m){return{__await:m}},E(A.prototype),u(A.prototype,a,function(){return this}),i.AsyncIterator=A,i.async=function(m,g,_,D,w){w===void 0&&(w=Promise);var P=new A(l(m,g,_,D),w);return i.isGeneratorFunction(g)?P:P.next().then(function(C){return C.done?C.value:P.next()})},E(S),u(S,s,"Generator"),u(S,n,function(){return this}),u(S,"toString",function(){return"[object Generator]"}),i.keys=function(m){var g=Object(m),_=[];for(var D in g)_.push(D);return _.reverse(),function w(){for(;_.length;){var P=_.pop();if(P in g)return w.value=P,w.done=!1,w}return w.done=!0,w}},i.values=M,G.prototype={constructor:G,reset:function(m){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!m)for(var g in this)g.charAt(0)==="t"&&e.call(this,g)&&!isNaN(+g.slice(1))&&(this[g]=void 0)},stop:function(){this.done=!0;var m=this.tryEntries[0].completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var g=this;function _(z,R){return P.type="throw",P.arg=m,g.next=z,R&&(g.method="next",g.arg=void 0),!!R}for(var D=this.tryEntries.length-1;D>=0;--D){var w=this.tryEntries[D],P=w.completion;if(w.tryLoc==="root")return _("end");if(w.tryLoc<=this.prev){var C=e.call(w,"catchLoc"),H=e.call(w,"finallyLoc");if(C&&H){if(this.prev<w.catchLoc)return _(w.catchLoc,!0);if(this.prev<w.finallyLoc)return _(w.finallyLoc)}else if(C){if(this.prev<w.catchLoc)return _(w.catchLoc,!0)}else{if(!H)throw new Error("try statement without catch or finally");if(this.prev<w.finallyLoc)return _(w.finallyLoc)}}}},abrupt:function(m,g){for(var _=this.tryEntries.length-1;_>=0;--_){var D=this.tryEntries[_];if(D.tryLoc<=this.prev&&e.call(D,"finallyLoc")&&this.prev<D.finallyLoc){var w=D;break}}w&&(m==="break"||m==="continue")&&w.tryLoc<=g&&g<=w.finallyLoc&&(w=null);var P=w?w.completion:{};return P.type=m,P.arg=g,w?(this.method="next",this.next=w.finallyLoc,c):this.complete(P)},complete:function(m,g){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&g&&(this.next=g),c},finish:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.finallyLoc===m)return this.complete(_.completion,_.afterLoc),F(_),c}},catch:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.tryLoc===m){var D=_.completion;if(D.type==="throw"){var w=D.arg;F(_)}return w}}throw new Error("illegal catch attempt")},delegateYield:function(m,g,_){return this.delegate={iterator:M(m),resultName:g,nextLoc:_},this.method==="next"&&(this.arg=void 0),c}},i}function Xe(i){"@babel/helpers - typeof";return Xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},Xe(i)}function mr(i,o,e,r,t,n,a){try{var s=i[n](a),u=s.value}catch(l){e(l);return}s.done?o(u):Promise.resolve(u).then(r,t)}function Re(i){return function(){var o=this,e=arguments;return new Promise(function(r,t){var n=i.apply(o,e);function a(u){mr(n,r,t,a,s,"next",u)}function s(u){mr(n,r,t,a,s,"throw",u)}a(void 0)})}}function ge(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function gr(i,o){for(var e=0;e<o.length;e++){var r=o[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,br(r.key),r)}}function ye(i,o,e){return o&&gr(i.prototype,o),e&&gr(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function L(i,o,e){return o=br(o),o in i?Object.defineProperty(i,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[o]=e,i}function tt(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),o&&rt(i,o)}function je(i){return je=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},je(i)}function rt(i,o){return rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},rt(i,o)}function yr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function lt(i,o,e){return yr()?lt=Reflect.construct.bind():lt=function(t,n,a){var s=[null];s.push.apply(s,n);var u=Function.bind.apply(t,s),l=new u;return a&&rt(l,a.prototype),l},lt.apply(null,arguments)}function Ln(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function ft(i){var o=typeof Map=="function"?new Map:void 0;return ft=function(r){if(r===null||!Ln(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o<"u"){if(o.has(r))return o.get(r);o.set(r,t)}function t(){return lt(r,arguments,je(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),rt(t,r)},ft(i)}function On(i,o){if(i==null)return{};var e={},r=Object.keys(i),t,n;for(n=0;n<r.length;n++)t=r[n],!(o.indexOf(t)>=0)&&(e[t]=i[t]);return e}function Pn(i,o){if(i==null)return{};var e=On(i,o),r,t;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);for(t=0;t<n.length;t++)r=n[t],!(o.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(i,r)&&(e[r]=i[r])}return e}function j(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Rn(i,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return j(i)}function nt(i){var o=yr();return function(){var r=je(i),t;if(o){var n=je(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Rn(this,t)}}function In(i,o){for(;!Object.prototype.hasOwnProperty.call(i,o)&&(i=je(i),i!==null););return i}function ct(){return typeof Reflect<"u"&&Reflect.get?ct=Reflect.get.bind():ct=function(o,e,r){var t=In(o,e);if(t){var n=Object.getOwnPropertyDescriptor(t,e);return n.get?n.get.call(arguments.length<3?o:r):n.value}},ct.apply(this,arguments)}function Cn(i,o){if(i){if(typeof i=="string")return _r(i,o);var e=Object.prototype.toString.call(i).slice(8,-1);if(e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set")return Array.from(i);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return _r(i,o)}}function _r(i,o){(o==null||o>i.length)&&(o=i.length);for(var e=0,r=new Array(o);e<o;e++)r[e]=i[e];return r}function Mn(i,o){var e=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!e){if(Array.isArray(i)||(e=Cn(i))||o&&i&&typeof i.length=="number"){e&&(i=e);var r=0,t=function(){};return{s:t,n:function(){return r>=i.length?{done:!0}:{done:!1,value:i[r++]}},e:function(u){throw u},f:t}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,a=!1,s;return{s:function(){e=e.call(i)},n:function(){var u=e.next();return n=u.done,u},e:function(u){a=!0,s=u},f:function(){try{!n&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function Bn(i,o){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,o||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}function br(i){var o=Bn(i,"string");return typeof o=="symbol"?o:String(o)}function qe(){var i,o,e=new Promise(function(r,t){i=r,o=t});return e.used=!1,e.resolve=function(){return e.used=!0,i.apply(void 0,arguments)},e.reject=function(){return e.used=!0,o.apply(void 0,arguments)},e}function Qe(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var oe=function(){function i(){ge(this,i)}return ye(i,null,[{key:"start",value:function(e){return!e||!e.length||e.length===1&&e.end(0)-e.start(0)<1e-6||e.length===1&&e.start(0)<0?0:e.start(0)}},{key:"end",value:function(e){return!e||!e.length||e.length===1&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1)}},{key:"get",value:function(e){if(e)try{return e.buffered}catch{}}},{key:"buffers",value:function(e,r){if(!e||!e.length)return[];for(var t=[],n=0,a=e.length;n<a;n++){var s=t.length;if(!s||!r)t.push([e.start(n),e.end(n)]);else{var u=t[s-1],l=u[1],f=e.start(n);if(f-l<=r){var c=e.end(n);c>l&&(u[1]=c)}else t.push([e.start(n),e.end(n)])}}return t}},{key:"totalLength",value:function(e){return!e||!e.length?0:e.reduce(function(r,t){return r+=t[1]-t[0]},0)}},{key:"info",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!e||!e.length)return{start:0,end:0,buffers:[]};for(var n=0,a=0,s=0,u=0,l=0,f=0,c=0,v=i.buffers(e,t),d=0,p=v.length;d<p;d++){var y=v[d];if(r+t>=y[0]&&r<=y[1])n=y[0],a=y[1],s=d;else if(r+t<y[0]){u=y[0],l=y[1];break}else r+t>y[1]&&(f=y[0],c=y[1])}return{start:n,end:a,index:s,buffers:v,nextStart:u,nextEnd:l,prevStart:f,prevEnd:c,currentTime:r,behind:r-n,remaining:a?a-r:0,length:i.totalLength&&i.totalLength(v)}}}]),i}(),_e,Y={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},Pt=(_e={},L(_e,Y.MANIFEST,{HLS:1100,DASH:1200}),L(_e,Y.NETWORK,2100),L(_e,Y.NETWORK_TIMEOUT,2101),L(_e,Y.NETWORK_FORBIDDEN,2103),L(_e,Y.NETWORK_NOTFOUND,2104),L(_e,Y.NETWROK_RANGE_NOT_SATISFIABLE,2116),L(_e,Y.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),L(_e,Y.REMUX,{FMP4:4100,MP4:4200}),L(_e,Y.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,EME_HIJACK:5301}),L(_e,Y.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),L(_e,Y.OTHER,8e3),L(_e,Y.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),_e),re=function(i){tt(e,i);var o=nt(e);function e(r,t,n,a,s){var u;return ge(this,e),u=o.call(this,s||n?.message),u.errorType=r===Y.NETWORK_TIMEOUT?Y.NETWORK:r,u.originError=n,u.ext=a,u.errorCode=Pt[r][t]||Pt[r],u.errorMessage=u.message,u.errorCode||(u.errorType=Y.OTHER,u.errorCode=Pt[u.errorType]),u}return ye(e,null,[{key:"create",value:function(t,n,a,s,u){return t instanceof e?t:(t instanceof Error&&(a=t,t=""),t||(t=Y.OTHER),new e(t,n,a,s,u))}},{key:"network",value:function(t){var n;return new e(t!=null&&t.isTimeout?Y.NETWORK_TIMEOUT:Y.NETWORK,null,t instanceof Error?t:null,{url:t?.url,response:t?.response,httpCode:t==null||(n=t.response)===null||n===void 0?void 0:n.status})}}]),e}(ft(Error)),xn=typeof window<"u",ht={DEBUG:1,LOG:2,WARN:3,ERROR:4},Un=200*1024,Nn=["Boolean","Number","String","Undefined","Null","Date","Object"],be=function(){function i(o,e){ge(this,i),this.name=o||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=e?.logCacheLevel||3,this.logMaxSize=e?.logMaxSize||Un,this.logSize=0,this.logTextArray=[]}return ye(i,[{key:"debug",value:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];this.logCache.apply(this,[ht.DEBUG].concat(t)),!i.disabled&&(e=console).debug.apply(e,[this._prefix,it()].concat(t))}},{key:"log",value:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];this.logCache.apply(this,[ht.LOG].concat(t)),!i.disabled&&(e=console).log.apply(e,[this._prefix,it()].concat(t))}},{key:"warn",value:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];this.logCache.apply(this,[ht.WARN].concat(t)),!i.disabled&&(e=console).warn.apply(e,[this._prefix,it()].concat(t))}},{key:"error",value:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];this.logCache.apply(this,[ht.ERROR].concat(t)),!i.disabled&&(e=console).error.apply(e,[this._prefix,it()].concat(t))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var r="";try{for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];var s=n.map(function(l){return Sr(l)});r=this._prefix+it()+JSON.stringify(s)}catch{return}if(e>=this.logCacheLevel&&(this.logSize+=r.length,this.logTextArray.push(r)),this.logSize>this.logMaxSize){var u=this.logTextArray.shift();this.logSize-=u.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join(`
|
3
|
-
`);return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var e;i.disabled||(console.group(this._prefix),(e=console).table.apply(e,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){i.disabled=!1}},{key:"disable",value:function(){i.disabled=!0}}]),i}();L(be,"disabled",!0);function it(){return new Date().toLocaleString()}function Fn(i){if(Xe(i)!=="object")return i;var o=Object.prototype.toString.call(i).slice(8,-1);switch(o){case"Array":case"Uint8Array":case"ArrayBuffer":return o+"["+i.length+"]";case"Object":return"{}";default:return o}}function Sr(i,o,e){e||(e=1),o||(o=2);var r={};if(!i||Xe(i)!=="object")return i;var t=Object.prototype.toString.call(i).slice(8,-1);if(!Nn.includes(t))return t;if(!(e>o)){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e===o?r[n]=Fn(i[n]):Xe(i[n])==="object"?r[n]=Sr(i[n],o,e+1):r[n]=i[n]);return r}}function Er(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return xn?i&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function Rt(i){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(i))}var dt={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"},pe=function(){function i(o,e){var r=this;ge(this,i),L(this,"media",null),L(this,"mediaSource",null),L(this,"_openPromise",qe()),L(this,"_queue",Object.create(null)),L(this,"_sourceBuffer",Object.create(null)),L(this,"_mseFullFlag",{}),L(this,"_st",0),L(this,"_opst",0),L(this,"_logger",null),L(this,"_config",null),L(this,"_url",null),L(this,"_onStartStreaming",function(){r._logger.debug("startstreaming")}),L(this,"_onEndStreaming",function(){r._logger.debug("endstreaming")}),L(this,"_onSBUpdateEnd",function(t){var n=r._queue[t];if(n){var a=n[0];if(a?.opName!==dt.UPDATE_DURATION&&n.shift(),a){var s=Qe()-r._opst;r._logger.debug("UpdateEnd",a.opName,s,a.context),a.promise.resolve({name:a.opName,context:a.context,costtime:s}),r._startQueue(t)}}}),L(this,"_onSBUpdateError",function(t,n){var a=r._queue[t];if(a){var s=a[0];s&&(r._logger.error("UpdateError",t,s.opName,s.context),s.promise.reject(new re(Y.MEDIA,Y.SUB_TYPES.MSE_APPEND_BUFFER,n)))}}),this._config=Object.assign(i.getDefaultConfig(),e),o&&this.bindMedia(o),this._logger=new be("MSE"),this._config.openLog&&be.enable()}return ye(i,[{key:"isOpened",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.readyState)==="open"}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return Rt(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(e){return e?this._mseFullFlag[e]:this._mseFullFlag[i.VIDEO]}},{key:"updateDuration",value:function(e){var r=this,t=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var n=0;if(Object.keys(this._sourceBuffer).forEach(function(a){try{n=Math.max(r.bufferEnd(a)||0,n)}catch{}}),e<n)return Promise.resolve()}return this._enqueueBlockingOp(function(){if(r.isEnded){r._logger.debug("setDuration but ended");return}r.mediaSource&&(r.mediaSource.duration=e,r._logger.debug("setDuration",e))},dt.UPDATE_DURATION,{isReduceDuration:t})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var r=this.mediaSource,t=function n(){var a=Qe()-e._st;e._logger.debug("sourceopen",a),r.removeEventListener("sourceopen",n),e._openPromise.resolve({costtime:a})};r.addEventListener("sourceopen",t),this._openPromise=qe()}return this._openPromise}},{key:"bindMedia",value:function(){var o=Re(fe().mark(function r(t){var n=this,a,s,u,l;return fe().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!(this.mediaSource||this.media)){c.next=3;break}return c.next=3,this.unbindMedia();case 3:if(a=Er(this._config.preferMMS),!(!t||!a)){c.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,s=this.mediaSource=new a,u=Rt(s),this._st=Qe(),l=function v(){var d=Qe()-n._st;n._logger.debug("sourceopen"),s.removeEventListener("sourceopen",v),URL.revokeObjectURL(t.src),n._openPromise.resolve({costtime:d})},s.addEventListener("sourceopen",l),u&&(s.addEventListener("startstreaming",this._onStartStreaming),s.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(s),t.src=this._url,t.disableRemotePlayback=u,c.abrupt("return",this._openPromise);case 17:case"end":return c.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"unbindMedia",value:function(){var o=Re(fe().mark(function r(){var t=this,n,a,s;return fe().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),n=this.mediaSource,n){if(Object.keys(this._queue).forEach(function(f){var c=t._queue[f];c&&c.forEach(function(v){var d,p;return(d=v.promise)===null||d===void 0||(p=d.resolve)===null||p===void 0?void 0:p.call(d)})}),a=!!this.media&&this.media.readyState>=1,s=n.readyState==="open",a&&s)try{n.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(f){try{n.removeSourceBuffer(t._sourceBuffer[f])}catch{}}),Rt(n)&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=qe(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return l.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"createSource",value:function(e,r){if(!(this._sourceBuffer[e]||!this.mediaSource)){var t;try{t=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(r)}catch(n){throw new re(Y.MEDIA,Y.SUB_TYPES.MSE_ADD_SB,n)}t.mimeType=r,t.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),t.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,r){var t=this,n=this._sourceBuffer[e];return!this.mediaSource||!n||n.mimeType===r?Promise.resolve():typeof n.changeType!="function"?Promise.reject():this._enqueueOp(e,function(){n.changeType(r),n.mimeType=r,t._onSBUpdateEnd(e)},"changeType",{mimeType:r})}},{key:"createOrChangeSource",value:function(e,r){return this.createSource(e,r),this.changeType(e,r)}},{key:"append",value:function(e,r,t){var n=this;return!r||!r.byteLength||!this._sourceBuffer[e]?Promise.resolve():this._enqueueOp(e,function(){var a;!n.mediaSource||n.media.error||(n._logger.debug("MSE APPEND START",t),n._opst=Qe(),(a=n._sourceBuffer[e])===null||a===void 0||a.appendBuffer(r))},dt.APPEND,t)}},{key:"remove",value:function(e,r,t,n){var a=this,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,function(){if(!(!a.mediaSource||a.media.error)){var u=a._sourceBuffer[e];if(r>=t||!u){a._onSBUpdateEnd(e);return}a._opst=Qe(),a._logger.debug("MSE REMOVE START",e,r,t,n),u.remove(r,t)}},dt.REMOVE,n,s)}},{key:"clearBuffer",value:function(e,r){var t=this,n;return Object.keys(this._sourceBuffer).forEach(function(a){n=t.remove(a,e,r)}),n||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e=this,r;return Object.keys(this._sourceBuffer).forEach(function(t){var n=e._sourceBuffer[t];r=e.remove(t,0,oe.end(oe.get(n)))}),r}},{key:"clearOpQueues",value:function(e,r){var t;this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(r&&n){this._queue[e]=[];return}if(!(!n||!n[e]||n.length<5)){var a=[];n.forEach(function(s){s.context&&s.context.isinit&&a.push(s)}),this._queue[e]=n.slice(0,2),a.length>0&&(t=this._queue[e]).push.apply(t,a)}}},{key:"endOfStream",value:function(e){var r=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var t=r.mediaSource;!t||t.readyState!=="open"||(r._logger.debug("MSE endOfStream START"),e?t.endOfStream(e):t.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(e,r){var t=this.mediaSource;e<0||r<e||!(t!=null&&t.setLiveSeekableRange)||t.readyState!=="open"||t.setLiveSeekableRange(e,r)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return oe.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return oe.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return oe.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,r,t,n,a){var s=this;if(!this.mediaSource)return Promise.resolve();var u=this._queue[e]=this._queue[e]||[],l={exec:r,promise:qe(),opName:t,context:n};return a?(u.splice(0,0,l),this._mseFullFlag[e]=!1,this._startQueue(e)):u.push(l),this.isOpened||this.isEnded?u.length===1&&this._startQueue(e):this._openPromise.then(function(){u.length===1&&s._startQueue(e)}),l.promise}},{key:"_enqueueBlockingOp",value:function(){var o=Re(fe().mark(function r(t,n,a){var s=this,u,l;return fe().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.mediaSource){c.next=2;break}return c.abrupt("return",Promise.resolve());case 2:if(u=Object.keys(this._sourceBuffer),u.length){c.next=5;break}return c.abrupt("return",t());case 5:return l=[],u.forEach(function(v){var d=s._queue[v],p=qe();l.push(p),d.push({exec:function(){p.resolve()},promise:p,opName:n,context:a}),d.length===1&&s._startQueue(v)}),c.abrupt("return",Promise.all(l).then(function(){try{return t()}finally{u.forEach(function(v){var d=s._queue[v],p=s._sourceBuffer[v];d?.shift(),(!p||!p.updating)&&s._startQueue(v)})}}));case 8:case"end":return c.stop()}},r,this)}));function e(r,t,n){return o.apply(this,arguments)}return e}()},{key:"_startQueue",value:function(e){var r=this._queue[e];if(r){var t=r[0];if(t&&!this._mseFullFlag[e])try{t.exec()}catch(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,this._logger.error("[MSE error], context,",t.context," ,name,",t.opName,",err,SourceBuffer is full"),t.promise.reject(new re(Y.MEDIA,Y.SUB_TYPES.MSE_FULL,n))):(this._logger.error(n),t.promise.reject(new re(Y.MEDIA,Y.SUB_TYPES.MSE_OTHER,n)),r.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,r,t){var n=this;return this._enqueueOp(e,function(){r<0&&(r+=.001),n._sourceBuffer[e].timestampOffset=r,n._onSBUpdateEnd(e)},"setTimeoffset",t)}},{key:"abort",value:function(e,r){var t=this;return this.isOpened?this._enqueueOp(e,function(){t._sourceBuffer[e].abort(),t._onSBUpdateEnd(e)},"abort",r):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',r=Er();if(!r)return!1;try{return r.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),i}();L(pe,"VIDEO","video"),L(pe,"AUDIO","audio");var He={FETCH:"fetch",XHR:"xhr"},at={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"},Le=function(i){tt(e,i);var o=nt(e);function e(r,t,n,a){var s;return ge(this,e),s=o.call(this,a),L(j(s),"retryCount",0),L(j(s),"isTimeout",!1),L(j(s),"loaderType",He.FETCH),L(j(s),"startTime",0),L(j(s),"endTime",0),L(j(s),"options",{}),s.url=r,s.request=t,s.response=n,s}return ye(e)}(ft(Error)),wr=Object.prototype.toString;function Vn(i){return i!==null&&Xe(i)==="object"}function kr(i){if(wr.call(i)!=="[object Object]")return!1;var o=Object.getPrototypeOf(i);return o===null||o===Object.prototype}function Gn(i){return wr.call(i)==="[object Date]"}function Tr(i){if(!(!i||i[0]===null||i[0]===void 0||i[0]===0&&(i[1]===null||i[1]===void 0))){var o="bytes="+i[0]+"-";return i[1]&&(o+=i[1]),o}}function Ar(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Dr(i,o){if(i){if(!o)return i;var e,r=Object.keys(o).map(function(n){if(e=o[n],e!=null)return Array.isArray(e)?n=n+"[]":e=[e],e.map(function(a){return Gn(a)?a=a.toISOString():Vn(a)&&(a=JSON.stringify(a)),"".concat(Ar(n),"=").concat(Ar(a))}).join("&")}).filter(Boolean).join("&");if(r){var t=i.indexOf("#");t!==-1&&(i=i.slice(0,t)),i+=(i.indexOf("?")===-1?"?":"&")+r}return i}}function It(i,o,e,r,t,n,a,s,u,l,f){t=t!=null?parseFloat(t):null,r=parseInt(r||"0",10),Number.isNaN(r)&&(r=0);var c={range:u,vid:l,index:s,contentLength:r,age:t,startTime:n,firstByteTime:a,endTime:Date.now(),priOptions:f};return{data:i,done:o,options:c,response:e}}function Ct(i,o){return Math.round(i*8*1e3/o/1024)}var V={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"},Lr={exports:{}};(function(i){var o=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function t(u,l,f){this.fn=u,this.context=l,this.once=f||!1}function n(u,l,f,c,v){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new t(f,c||u,v),p=e?e+l:l;return u._events[p]?u._events[p].fn?u._events[p]=[u._events[p],d]:u._events[p].push(d):(u._events[p]=d,u._eventsCount++),u}function a(u,l){--u._eventsCount===0?u._events=new r:delete u._events[l]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var l=[],f,c;if(this._eventsCount===0)return l;for(c in f=this._events)o.call(f,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(f)):l},s.prototype.listeners=function(l){var f=e?e+l:l,c=this._events[f];if(!c)return[];if(c.fn)return[c.fn];for(var v=0,d=c.length,p=new Array(d);v<d;v++)p[v]=c[v].fn;return p},s.prototype.listenerCount=function(l){var f=e?e+l:l,c=this._events[f];return c?c.fn?1:c.length:0},s.prototype.emit=function(l,f,c,v,d,p){var y=e?e+l:l;if(!this._events[y])return!1;var h=this._events[y],b=arguments.length,S,E;if(h.fn){switch(h.once&&this.removeListener(l,h.fn,void 0,!0),b){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,f),!0;case 3:return h.fn.call(h.context,f,c),!0;case 4:return h.fn.call(h.context,f,c,v),!0;case 5:return h.fn.call(h.context,f,c,v,d),!0;case 6:return h.fn.call(h.context,f,c,v,d,p),!0}for(E=1,S=new Array(b-1);E<b;E++)S[E-1]=arguments[E];h.fn.apply(h.context,S)}else{var A=h.length,k;for(E=0;E<A;E++)switch(h[E].once&&this.removeListener(l,h[E].fn,void 0,!0),b){case 1:h[E].fn.call(h[E].context);break;case 2:h[E].fn.call(h[E].context,f);break;case 3:h[E].fn.call(h[E].context,f,c);break;case 4:h[E].fn.call(h[E].context,f,c,v);break;default:if(!S)for(k=1,S=new Array(b-1);k<b;k++)S[k-1]=arguments[k];h[E].fn.apply(h[E].context,S)}}return!0},s.prototype.on=function(l,f,c){return n(this,l,f,c,!1)},s.prototype.once=function(l,f,c){return n(this,l,f,c,!0)},s.prototype.removeListener=function(l,f,c,v){var d=e?e+l:l;if(!this._events[d])return this;if(!f)return a(this,d),this;var p=this._events[d];if(p.fn)p.fn===f&&(!v||p.once)&&(!c||p.context===c)&&a(this,d);else{for(var y=0,h=[],b=p.length;y<b;y++)(p[y].fn!==f||v&&!p[y].once||c&&p[y].context!==c)&&h.push(p[y]);h.length?this._events[d]=h.length===1?h[0]:h:a(this,d)}return this},s.prototype.removeAllListeners=function(l){var f;return l?(f=e?e+l:l,this._events[f]&&a(this,f)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=e,s.EventEmitter=s,i.exports=s})(Lr);var jn=Lr.exports;const Mt=Ot(jn);var Or=2*1024*1024,Bt=function(i){tt(e,i);var o=nt(e);function e(){var r;return ge(this,e),r=o.call(this),L(j(r),"_abortController",null),L(j(r),"_timeoutTimer",null),L(j(r),"_reader",null),L(j(r),"_response",null),L(j(r),"_aborted",!1),L(j(r),"_index",-1),L(j(r),"_range",null),L(j(r),"_receivedLength",0),L(j(r),"_running",!1),L(j(r),"_logger",null),L(j(r),"_vid",""),L(j(r),"_onProcessMinLen",0),L(j(r),"_onCancel",null),L(j(r),"_priOptions",null),r}return ye(e,[{key:"load",value:function(t){var n,a=this,s=t.url,u=t.vid,l=t.timeout,f=t.responseType,c=t.onProgress,v=t.index,d=t.onTimeout,p=t.onCancel,y=t.range,h=t.transformResponse,b=t.request,S=t.params,E=t.logger,A=t.method,k=t.headers,U=t.body,N=t.mode,F=t.credentials,G=t.cache,M=t.redirect,X=t.referrer,m=t.referrerPolicy,g=t.onProcessMinLen,_=t.priOptions;this._logger=E,this._aborted=!1,this._onProcessMinLen=g,this._onCancel=p,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=v,this._range=y||[0,0],this._vid=u||s,this._priOptions=_||{};var D={method:A,headers:k,body:U,mode:N,credentials:F,cache:G,redirect:M,referrer:X,referrerPolicy:m,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},w=!1;clearTimeout(this._timeoutTimer),s=Dr(s,S);var P=Tr(y);P&&(b?k=b.headers:k=D.headers=D.headers||(Headers?new Headers:{}),Headers&&k instanceof Headers?k.append("Range",P):k.Range=P),l&&(this._timeoutTimer=setTimeout(function(){if(w=!0,a.cancel(),d){var H=new Le(s,D,null,"timeout");H.isTimeout=!0,d(H,{index:a._index,range:a._range,vid:a._vid,priOptions:a._priOptions})}},l));var C=Date.now();return this._logger.debug("[fetch load start], index,",v,",range,",y),new Promise(function(H,z){fetch(b||s,b?void 0:D).then(function(){var R=Re(fe().mark(function te(x){var Ne,we,Fe,Ye;return fe().wrap(function(ue){for(;;)switch(ue.prev=ue.next){case 0:if(clearTimeout(a._timeoutTimer),a._response=x,!(a._aborted||!a._running)){ue.next=4;break}return ue.abrupt("return");case 4:if(h&&(x=h(x,s)||x),x.ok){ue.next=7;break}throw new Le(s,D,x,"bad network response");case 7:if(Ne=Date.now(),f!==at.TEXT){ue.next=15;break}return ue.next=11,x.text();case 11:we=ue.sent,a._running=!1,ue.next=37;break;case 15:if(f!==at.JSON){ue.next=22;break}return ue.next=18,x.json();case 18:we=ue.sent,a._running=!1,ue.next=37;break;case 22:if(!c){ue.next=29;break}return a.resolve=H,a.reject=z,a._loadChunk(x,c,C,Ne),ue.abrupt("return");case 29:return ue.next=31,x.arrayBuffer();case 31:we=ue.sent,we=new Uint8Array(we),a._running=!1,Fe=Date.now()-C,Ye=Ct(we.byteLength,Fe),a.emit(V.REAL_TIME_SPEED,{speed:Ye,len:we.byteLength,time:Fe,vid:a._vid,index:a._index,range:a._range,priOptions:a._priOptions});case 37:a._logger.debug("[fetch load end], index,",v,",range,",y),H(It(we,!0,x,x.headers.get("Content-Length"),x.headers.get("age"),C,Ne,v,y,a._vid,a._priOptions));case 39:case"end":return ue.stop()}},te)}));return function(te){return R.apply(this,arguments)}}()).catch(function(R){var te;clearTimeout(a._timeoutTimer),a._running=!1,!(a._aborted&&!w)&&(R=R instanceof Le?R:new Le(s,D,null,(te=R)===null||te===void 0?void 0:te.message),R.startTime=C,R.endTime=Date.now(),R.isTimeout=w,R.options={index:a._index,range:a._range,vid:a._vid,priOptions:a._priOptions},z(R))})})}},{key:"cancel",value:function(){var r=Re(fe().mark(function n(){return fe().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this._aborted){s.next=2;break}return s.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){s.next=14;break}if(s.prev=5,!this._reader){s.next=9;break}return s.next=9,this._reader.cancel();case 9:s.next=13;break;case 11:s.prev=11,s.t0=s.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return s.stop()}},n,this,[[5,11]])}));function t(){return r.apply(this,arguments)}return t}()},{key:"_loadChunk",value:function(t,n,a,s){var u=this;if(!t.body||!t.body.getReader){this._running=!1;var l=new Le(t.url,"",t,"onProgress of bad response.body.getReader");l.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(l);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Or),this._writeIdx=0);var f=this._reader=t.body.getReader(),c,v,d,p=function(){var y=Re(fe().mark(function h(){var b,S,E,A,k,U,N,F;return fe().wrap(function(M){for(;;)switch(M.prev=M.next){case 0:return v=Date.now(),M.prev=1,M.next=4,f.read();case 4:c=M.sent,d=Date.now(),M.next=13;break;case 8:return M.prev=8,M.t0=M.catch(1),d=Date.now(),u._aborted||(u._running=!1,M.t0.options={index:u._index,range:u._range,vid:u._vid,priOptions:u._priOptions},u.reject(M.t0)),M.abrupt("return");case 13:if(S=((b=u._range)===null||b===void 0?void 0:b.length)>0?u._range[0]:0,E=S+u._receivedLength,!u._aborted){M.next=19;break}return u._running=!1,n(void 0,!1,{range:[E,E],vid:u._vid,index:u._index,startTime:v,endTime:d,st:a,firstByteTime:s,priOptions:u._priOptions},t),M.abrupt("return");case 19:A=c.value?c.value.byteLength:0,u._receivedLength+=A,u._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",u._range,", start,",E,", end,",S+u._receivedLength,", done,",c.done),u._onProcessMinLen>0?u._writeIdx+A>=u._onProcessMinLen||c.done?(k=new Uint8Array(u._writeIdx+A),k.set(u._cache.slice(0,u._writeIdx),0),A>0&&k.set(c.value,u._writeIdx),u._writeIdx=0,u._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",c.done,",len,",k.byteLength,", writeIdx,",u._writeIdx)):A>0&&u._writeIdx+A<Or?(u._cache.set(c.value,u._writeIdx),u._writeIdx+=A,u._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",A,", writeIdx,",u._writeIdx)):A>0&&(U=new Uint8Array(u._writeIdx+A+2048),u._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",u._writeIdx+A+2048,", datalen,",A,", writeIdx,",u._writeIdx),U.set(u._cache.slice(0,u._writeIdx),0),A>0&&U.set(c.value,u._writeIdx),u._writeIdx+=A,delete u._cache,u._cache=U,u._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",A,", writeIdx,",u._writeIdx)):k=c.value,(k&&k.byteLength>0||c.done)&&n(k,c.done,{range:[u._range[0]+u._receivedLength-(k?k.byteLength:0),u._range[0]+u._receivedLength],vid:u._vid,index:u._index,startTime:v,endTime:d,st:a,firstByteTime:s,priOptions:u._priOptions},t),c.done?(N=Date.now()-a,F=Ct(u._receivedLength,N),u.emit(V.REAL_TIME_SPEED,{speed:F,len:u._receivedLength,time:N,vid:u._vid,index:u._index,range:u._range,priOptions:u._priOptions}),u._running=!1,u._logger.debug("[fetchLoader onProgress end],task,",u._range,",done,",c.done),u.resolve(It(c,!0,t,t.headers.get("Content-Length"),t.headers.get("age"),a,s,u._index,u._range,u._vid,u._priOptions))):p();case 25:case"end":return M.stop()}},h,null,[[1,8]])}));return function(){return y.apply(this,arguments)}}();p()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(t){this._running=t}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),e}(Mt);function Hn(i){return et({loaderType:He.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:at.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},i)}var zn=function(i){tt(e,i);var o=nt(e);function e(){var r;return ge(this,e),r=o.call(this),L(j(r),"_xhr",null),L(j(r),"_aborted",!1),L(j(r),"_timeoutTimer",null),L(j(r),"_range",null),L(j(r),"_receivedLength",0),L(j(r),"_url",null),L(j(r),"_onProgress",null),L(j(r),"_index",-1),L(j(r),"_headers",null),L(j(r),"_currentChunkSizeKB",384),L(j(r),"_timeout",null),L(j(r),"_xhr",null),L(j(r),"_withCredentials",null),L(j(r),"_startTime",-1),L(j(r),"_loadCompleteResolve",null),L(j(r),"_loadCompleteReject",null),L(j(r),"_runing",!1),L(j(r),"_logger",!1),L(j(r),"_vid",""),L(j(r),"_responseType",void 0),L(j(r),"_credentials",void 0),L(j(r),"_method",void 0),L(j(r),"_transformResponse",void 0),L(j(r),"_firstRtt",void 0),L(j(r),"_onCancel",null),L(j(r),"_priOptions",null),r}return ye(e,[{key:"load",value:function(t){var n=this;clearTimeout(this._timeoutTimer),this._logger=t.logger,this._range=t.range,this._onProgress=t.onProgress,this._index=t.index,this._headers=t.headers,this._withCredentials=t.credentials==="include"||t.credentials==="same-origin",this._body=t.body||null,t.method&&(this._method=t.method),this._timeout=t.timeout||null,this._runing=!0,this._vid=t.vid||t.url,this._responseType=t.responseType,this._firstRtt=-1,this._onTimeout=t.onTimeout,this._onCancel=t.onCancel,this._request=t.request,this._priOptions=t.priOptions||{},this._logger.debug("\u3010xhrLoader task\u3011, range",this._range),this._url=Dr(t.url,t.params);var a=Date.now();return new Promise(function(s,u){n._loadCompleteResolve=s,n._loadCompleteReject=u,n._startLoad()}).catch(function(s){if(clearTimeout(n._timeoutTimer),n._runing=!1,!n._aborted)throw s=s instanceof Le?s:new Le(n._url,n._request),s.startTime=a,s.endTime=Date.now(),s.options={index:n._index,vid:n._vid,priOptions:n._priOptions},s})}},{key:"_startLoad",value:function(){var t=null;if(this._responseType===at.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var n=this._currentChunkSizeKB*1024,a=this._range[0]+this._receivedLength,s=this._range[1];n<this._range[1]-a&&(s=a+n),t=[a,s],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",t)}else t=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",t);this._internalOpen(t)}},{key:"_internalOpen",value:function(t){var n=this;try{this._startTime=Date.now();var a=this._xhr=new XMLHttpRequest;a.open(this._method||"GET",this._url,!0),a.responseType=this._responseType,this._timeout&&(a.timeout=this._timeout),a.withCredentials=this._withCredentials,a.onload=this._onLoad.bind(this),a.onreadystatechange=this._onReadyStatechange.bind(this),a.onerror=function(l){var f,c,v;n._running=!1;var d=new Le(n._url,n._request,l==null||(f=l.currentTarget)===null||f===void 0?void 0:f.response,"xhr.onerror.status:"+(l==null||(c=l.currentTarget)===null||c===void 0?void 0:c.status)+",statusText,"+(l==null||(v=l.currentTarget)===null||v===void 0?void 0:v.statusText));d.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n._loadCompleteReject(d)},a.ontimeout=function(l){n.cancel();var f=new Le(n._url,n._request,{status:408},"timeout");n._onTimeout&&(f.isTimeout=!0,n._onTimeout(f,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})),f.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n._loadCompleteReject(f)};var s=this._headers||{},u=Tr(t);u&&(s.Range=u),s&&Object.keys(s).forEach(function(l){a.setRequestHeader(l,s[l])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",t),a.send(this._body)}catch(l){l.options={index:this._index,range:t,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(l)}}},{key:"_onReadyStatechange",value:function(t){var n=t.target;n.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(t){var n,a=t.target.status;if(a<200||a>299){var s=new Le(this._url,null,et(et({},t.target.response),{},{status:a}),"bad response,status:"+a);return s.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}var u=null,l=!1,f,c=((n=this._range)===null||n===void 0?void 0:n.length)>0?this._range[0]:0;if(this._responseType===at.ARRAY_BUFFER){var v,d=new Uint8Array(t.target.response);if(f=c+this._receivedLength,d&&d.byteLength>0){this._receivedLength+=d.byteLength;var p=Date.now()-this._startTime,y=Ct(this._receivedLength,p);this.emit(V.REAL_TIME_SPEED,{speed:y,len:this._receivedLength,time:p,vid:this._vid,index:this._index,range:[f,c+this._receivedLength],priOptions:this._priOptions})}u=d,((v=this._range)===null||v===void 0?void 0:v.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]?l=!1:l=!0,this._logger.debug("[xhr load done->], tast :",this._range,", start",f,"end ",c+this._receivedLength,",dataLen,",d?d.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",l)}else l=!0,u=t.target.response;var h={ok:a>=200&&a<300,status:a,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(h=this._transformResponse(h,this._url)||h),this._onProgress&&this._onProgress(u,l,{index:this._index,vid:this._vid,range:[f,c+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},h),l?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(It(this._onProgress?null:u,l,h,h.headers["content-length"],h.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,ct(je(e.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(t){this._running=t}},{key:"_getHeaders",value:function(t){var n=t.getAllResponseHeaders().trim().split(`\r
|
4
|
-
`),a={},s=Mn(n),u;try{for(s.s();!(u=s.n()).done;){var l=u.value,f=l.split(": ");a[f[0].toLowerCase()]=f.slice(1).join(": ")}}catch(c){s.e(c)}finally{s.f()}return a}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),e}(Mt),$n=["retry","retryDelay","onRetryError","transformError"],Wn=function(){function i(o,e){ge(this,i),this.promise=qe(),this.alive=!!e.onProgress,!e.logger&&(e.logger=new be("Loader")),this._loaderType=o,this._loader=o===He.FETCH&&typeof fetch<"u"?new Bt:new zn,this._config=e,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=e.retryCheckFunc,this._logger=e.logger}return ye(i,[{key:"exec",value:function(){var e=this,r=this._config,t=r.retry,n=r.retryDelay,a=r.onRetryError,s=r.transformError,u=Pn(r,$n),l=function(){var f=Re(fe().mark(function c(){var v,d,p;return fe().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.prev=0,h.next=3,e._loader.load(u);case 3:v=h.sent,e.promise.resolve(v),h.next=27;break;case 7:if(h.prev=7,h.t0=h.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",h.t0),!e._canceled){h.next=13;break}return h.abrupt("return");case 13:if(h.t0.loaderType=e._loaderType,h.t0.retryCount=e._retryCount,d=h.t0,s&&(d=s(d)||d),a&&e._retryCount>0&&a(d,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,p=!0,e._retryCheckFunc&&(p=e._retryCheckFunc(h.t0)),!(p&&e._retryCount<=t)){h.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(l,n),h.abrupt("return");case 26:e.promise.reject(d);case 27:case"end":return h.stop()}},c,null,[[0,7]])}));return function(){return f.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:function(){var o=Re(fe().mark(function r(){return fe().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,n.abrupt("return",this._loader.cancel());case 4:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),i}();function Pr(i){return i&&!i.paused&&!i.ended&&i.playbackRate!==0&&i.readyState!==0}function Rr(i){if(!i)return{};if(typeof i.getVideoPlaybackQuality=="function"){var o=i.getVideoPlaybackQuality();return{droppedVideoFrames:o.droppedVideoFrames||o.corruptedVideoFrames,totalVideoFrames:o.totalVideoFrames,creationTime:o.creationTime}}return{droppedVideoFrames:i.webkitDroppedFrameCount,totalVideoFrames:i.webkitDecodedFrameCount,creationTime:performance.now()}}function st(){for(var i=arguments.length,o=new Array(i),e=0;e<i;e++)o[e]=arguments[e];if(o=o.filter(Boolean),o.length<2)return o[0];var r=new Uint8Array(o.reduce(function(n,a){return n+a.byteLength},0)),t=0;return o.forEach(function(n){r.set(n,t),t+=n.byteLength}),r}function Kn(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(o){return setTimeout(o,i)})}var ze=function(i){tt(e,i);var o=nt(e);function e(r){var t;return ge(this,e),t=o.call(this,r),L(j(t),"type",He.FETCH),L(j(t),"_queue",[]),L(j(t),"_alive",[]),L(j(t),"_currentTask",null),L(j(t),"_finnalUrl",""),L(j(t),"_config",void 0),t._config=Hn(r),(t._config.loaderType===He.XHR||!Bt.isSupported())&&(t.type=He.XHR),t.log=r.logger,t}return ye(e,[{key:"isFetch",value:function(){return this.type===He.FETCH}},{key:"load",value:function(t){var n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof t=="string"||!t?a.url=t||a.url||this._config.url:a=t,a=Object.assign({},this._config,a),a.params&&(a.params=Object.assign({},a.params)),a.headers&&kr(a.headers)&&(a.headers=Object.assign({},a.headers)),a.body&&kr(a.body)&&(a.body=Object.assign({},a.body)),a.transformRequest&&(a=a.transformRequest(a)||a),a.logger=this.log;var s=new Wn(this.type,a);return s.loader.on(V.REAL_TIME_SPEED,function(u){n.emit(V.REAL_TIME_SPEED,u)}),this._queue.push(s),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),s.promise}},{key:"cancel",value:function(){var r=Re(fe().mark(function n(){var a;return fe().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return a=this._queue.map(function(l){return l.cancel()}).concat(this._alive.map(function(l){return l.cancel()})),this._currentTask&&a.push(this._currentTask.cancel()),this._queue=[],this._alive=[],u.next=6,Promise.all(a);case 6:return u.next=8,Kn();case 8:case"end":return u.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_processTask",value:function(){var t=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var n=this._currentTask.exec().catch(function(a){});n&&typeof n.finally=="function"&&n.finally(function(){var a,s;(a=t._currentTask)!==null&&a!==void 0&&a.alive&&((s=t._alive)===null||s===void 0?void 0:s.length)>0&&(t._alive=t._alive.filter(function(u){return u&&u!==t._currentTask})),t._processTask()})}}}],[{key:"isFetchSupport",value:function(){return Bt.isSupported()}}]),e}(Mt),Ir=function(){function i(){ge(this,i),L(this,"_prevCurrentTime",0)}return ye(i,[{key:"do",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(e){var a=e.currentTime,s=0;if(this._prevCurrentTime===a){var u=oe.info(oe.get(e),a);if(!u.buffers.length)return;t&&u.nextStart||u.nextStart&&u.nextStart-a<r?s=u.nextStart+.1:u.end&&u.end-a>n&&!e.seeking&&(s=a+.1)}this._prevCurrentTime=a,s&&a!==s&&(e.currentTime=s)}}}]),i}(),Cr=function(){function i(o){var e=this;ge(this,i),L(this,"_seiSet",new Set),this.emitter=o,o.on(V.SEI,function(r){r&&e._seiSet.add(r)})}return ye(i,[{key:"throw",value:function(e,r){var t=this;if(!(e==null||!this._seiSet.size)){var n=e-.2,a=e+.2,s=[];this._seiSet.forEach(function(u){u.time>=n&&u.time<=a&&s.push(u)}),s.forEach(function(u){t._seiSet.delete(u),t.emitter.emit(V.SEI_IN_TIME,u)}),r&&this._seiSet.forEach(function(u){u.time<e-5&&t._seiSet.delete(u)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),i}(),Mr=function(){function i(){ge(this,i),L(this,"_chunkSpeeds",[]),L(this,"_speeds",[])}return ye(i,[{key:"addRecord",value:function(e,r){!e||!r||(this._speeds.push(8e3*e/r),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,r){!e||!r||(this._chunkSpeeds.push(8e3*e/r),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}},{key:"getAvgSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds.reduce(function(e,r){return e+=r})/this._speeds.length:this._chunkSpeeds.reduce(function(e,r){return e+=r})/this._chunkSpeeds.length}},{key:"getLatestSpeed",value:function(){return!this._chunkSpeeds.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]}},{key:"reset",value:function(){this._chunkSpeeds=[],this._speeds=[]}}]),i}(),Br=function(){function i(o){ge(this,i),L(this,"encodeType",""),L(this,"audioCodec",""),L(this,"videoCodec",""),L(this,"domain",""),L(this,"fps",0),L(this,"bitrate",0),L(this,"width",0),L(this,"height",0),L(this,"samplerate",0),L(this,"channelCount",0),L(this,"gop",0),L(this,"_bitsAccumulateSize",0),L(this,"_bitsAccumulateDuration",0),L(this,"_startGopId",-1),this._timescale=o}return ye(i,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var r,t=e.data,n=t==null||(r=t.onMetaData)===null||r===void 0?void 0:r.framerate;n&&n>0&&n<100&&(this.fps=n)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var r=e.fpsNum/e.fpsDen;r>0&&r<100&&(this.fps=r)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var r=this;if((!this.fps||this.fps>=100)&&e.length){var t=e.reduce(function(n,a){return n+=a.duration},0)/e.length;this.fps=Math.round(this._timescale/t)}e.forEach(function(n){r._startGopId===-1&&(r._startGopId=n.gopId),n.gopId===r._startGopId&&r.gop++,r._bitsAccumulateDuration+=n.duration/(r._timescale/1e3),r._bitsAccumulateSize+=n.units.reduce(function(a,s){return a+=s.length},0),r._bitsAccumulateDuration>=1e3&&(r.bitrate=r._bitsAccumulateSize*8,r._bitsAccumulateDuration=0,r._bitsAccumulateSize=0)})}}]),i}(),xr=function(){function i(o){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;ge(this,i),L(this,"_core",null),L(this,"_samples",[]),this._core=o,this._timescale=e,this._stats=new Br(e),this._bindEvents()}return ye(i,[{key:"getStats",value:function(){var e,r,t,n,a,s,u,l=((e=this._core)===null||e===void 0?void 0:e.media)||{},f=l.currentTime,c=f===void 0?0:f,v=l.decodeFps,d=v===void 0?0:v;return et(et({},this._stats.getStats()),{},{downloadSpeed:((r=this._core)===null||r===void 0||(t=r.speedInfo)===null||t===void 0?void 0:t.call(r).speed)||0,avgSpeed:((n=this._core)===null||n===void 0||(a=n.speedInfo)===null||a===void 0?void 0:a.call(n).avgSpeed)||0,currentTime:c,bufferEnd:((s=this._core)===null||s===void 0||(u=s.bufferInfo())===null||u===void 0?void 0:u.remaining)||0,decodeFps:d})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(V.DEMUXED_TRACK,function(r){var t=r.videoTrack;return e._stats.updateBitrate(t.samples)}),this._core.on(V.FLV_SCRIPT_DATA,function(r){e._stats.setFpsFromScriptData(r)}),this._core.on(V.METADATA_PARSED,function(r){r.type==="video"?e._stats.setVideoMeta(r.track):e._stats.setAudioMeta(r.track)}),this._core.on(V.TTFB,function(r){e._stats.setDomain(r.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Br(this._timescale)}}]),i}(),Ur={exports:{}};(function(i){var o=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function t(u,l,f){this.fn=u,this.context=l,this.once=f||!1}function n(u,l,f,c,v){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new t(f,c||u,v),p=e?e+l:l;return u._events[p]?u._events[p].fn?u._events[p]=[u._events[p],d]:u._events[p].push(d):(u._events[p]=d,u._eventsCount++),u}function a(u,l){--u._eventsCount===0?u._events=new r:delete u._events[l]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var l=[],f,c;if(this._eventsCount===0)return l;for(c in f=this._events)o.call(f,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(f)):l},s.prototype.listeners=function(l){var f=e?e+l:l,c=this._events[f];if(!c)return[];if(c.fn)return[c.fn];for(var v=0,d=c.length,p=new Array(d);v<d;v++)p[v]=c[v].fn;return p},s.prototype.listenerCount=function(l){var f=e?e+l:l,c=this._events[f];return c?c.fn?1:c.length:0},s.prototype.emit=function(l,f,c,v,d,p){var y=e?e+l:l;if(!this._events[y])return!1;var h=this._events[y],b=arguments.length,S,E;if(h.fn){switch(h.once&&this.removeListener(l,h.fn,void 0,!0),b){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,f),!0;case 3:return h.fn.call(h.context,f,c),!0;case 4:return h.fn.call(h.context,f,c,v),!0;case 5:return h.fn.call(h.context,f,c,v,d),!0;case 6:return h.fn.call(h.context,f,c,v,d,p),!0}for(E=1,S=new Array(b-1);E<b;E++)S[E-1]=arguments[E];h.fn.apply(h.context,S)}else{var A=h.length,k;for(E=0;E<A;E++)switch(h[E].once&&this.removeListener(l,h[E].fn,void 0,!0),b){case 1:h[E].fn.call(h[E].context);break;case 2:h[E].fn.call(h[E].context,f);break;case 3:h[E].fn.call(h[E].context,f,c);break;case 4:h[E].fn.call(h[E].context,f,c,v);break;default:if(!S)for(k=1,S=new Array(b-1);k<b;k++)S[k-1]=arguments[k];h[E].fn.apply(h[E].context,S)}}return!0},s.prototype.on=function(l,f,c){return n(this,l,f,c,!1)},s.prototype.once=function(l,f,c){return n(this,l,f,c,!0)},s.prototype.removeListener=function(l,f,c,v){var d=e?e+l:l;if(!this._events[d])return this;if(!f)return a(this,d),this;var p=this._events[d];if(p.fn)p.fn===f&&(!v||p.once)&&(!c||p.context===c)&&a(this,d);else{for(var y=0,h=[],b=p.length;y<b;y++)(p[y].fn!==f||v&&!p[y].once||c&&p[y].context!==c)&&h.push(p[y]);h.length?this._events[d]=h.length===1?h[0]:h:a(this,d)}return this},s.prototype.removeAllListeners=function(l){var f;return l?(f=e?e+l:l,this._events[f]&&a(this,f)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=e,s.EventEmitter=s,i.exports=s})(Ur);var Yn=Ur.exports;const Xn=Ot(Yn);function qn(i,o){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var r,t,n,a,s=[],u=!0,l=!1;try{if(n=(e=e.call(i)).next,o===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=n.call(e)).done)&&(s.push(r.value),s.length!==o);u=!0);}catch(f){l=!0,t=f}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw t}}return s}}function ne(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function Nr(i,o){for(var e=0;e<o.length;e++){var r=o[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,jr(r.key),r)}}function ie(i,o,e){return o&&Nr(i.prototype,o),e&&Nr(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function O(i,o,e){return o=jr(o),o in i?Object.defineProperty(i,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[o]=e,i}function Fr(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),o&&xt(i,o)}function vt(i){return vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},vt(i)}function xt(i,o){return xt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},xt(i,o)}function Qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Jn(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Zn(i,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Jn(i)}function Vr(i){var o=Qn();return function(){var r=vt(i),t;if(o){var n=vt(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Zn(this,t)}}function ei(i,o){return ri(i)||qn(i,o)||Gr(i,o)||ai()}function Se(i){return ti(i)||ni(i)||Gr(i)||ii()}function ti(i){if(Array.isArray(i))return Ut(i)}function ri(i){if(Array.isArray(i))return i}function ni(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function Gr(i,o){if(i){if(typeof i=="string")return Ut(i,o);var e=Object.prototype.toString.call(i).slice(8,-1);if(e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set")return Array.from(i);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Ut(i,o)}}function Ut(i,o){(o==null||o>i.length)&&(o=i.length);for(var e=0,r=new Array(o);e<o;e++)r[e]=i[e];return r}function ii(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ai(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
6
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function si(i,o){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,o||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}function jr(i){var o=si(i,"string");return typeof o=="symbol"?o:String(o)}var Je={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},Ie={AVC:"avc",HEVC:"hevc"},Oe={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m"},se={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"},Nt=function(){function i(){ne(this,i),O(this,"id",1),O(this,"type",Je.VIDEO),O(this,"codecType",Ie.AVC),O(this,"pid",-1),O(this,"hvcC",void 0),O(this,"codec",""),O(this,"timescale",0),O(this,"formatTimescale",0),O(this,"sequenceNumber",0),O(this,"baseMediaDecodeTime",0),O(this,"baseDts",0),O(this,"duration",0),O(this,"warnings",[]),O(this,"samples",[]),O(this,"pps",[]),O(this,"sps",[]),O(this,"vps",[]),O(this,"fpsNum",0),O(this,"fpsDen",0),O(this,"sarRatio",[]),O(this,"width",0),O(this,"height",0),O(this,"nalUnitSize",4),O(this,"present",!1),O(this,"isVideoEncryption",!1),O(this,"isAudioEncryption",!1),O(this,"isVideo",!0),O(this,"kid",null),O(this,"pssh",null),O(this,"ext",void 0)}return ie(i,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),i}(),Ft=function(){function i(){ne(this,i),O(this,"id",2),O(this,"type",Je.AUDIO),O(this,"codecType",Oe.AAC),O(this,"pid",-1),O(this,"codec",""),O(this,"sequenceNumber",0),O(this,"sampleDuration",0),O(this,"timescale",0),O(this,"formatTimescale",0),O(this,"baseMediaDecodeTime",0),O(this,"duration",0),O(this,"warnings",[]),O(this,"samples",[]),O(this,"baseDts",0),O(this,"sampleSize",16),O(this,"sampleRate",0),O(this,"channelCount",0),O(this,"objectType",0),O(this,"sampleRateIndex",0),O(this,"config",[]),O(this,"present",!1),O(this,"isVideoEncryption",!1),O(this,"isAudioEncryption",!1),O(this,"kid",null),O(this,"ext",void 0)}return ie(i,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===Oe.AAC)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),i}(),Vt=function(){function i(o,e,r){ne(this,i),O(this,"flag",{}),O(this,"keyframe",!1),O(this,"gopId",0),O(this,"duration",0),O(this,"size",0),O(this,"units",[]),O(this,"chromaFormat",420),this.originPts=this.pts=o,this.originDts=this.dts=e,r&&(this.units=r)}return ie(i,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),i}(),$e=ie(function i(o,e,r,t){ne(this,i),O(this,"duration",1024),O(this,"flag",{dependsOn:2,isNonSyncSample:0}),O(this,"keyframe",!0),this.originPts=this.pts=this.dts=o,this.data=e,this.size=e.byteLength,this.sampleOffset=t,r&&(this.duration=r)}),Hr=ie(function i(o,e){ne(this,i),O(this,"time",0),this.data=o,this.originPts=this.pts=e}),oi=function(i){Fr(e,i);var o=Vr(e);function e(){return ne(this,e),o.apply(this,arguments)}return ie(e)}(Hr),zr=function(i){Fr(e,i);var o=Vr(e);function e(){return ne(this,e),o.apply(this,arguments)}return ie(e)}(Hr),Gt=function(){function i(){ne(this,i),O(this,"id",3),O(this,"type",Je.METADATA),O(this,"timescale",0),O(this,"flvScriptSamples",[]),O(this,"seiSamples",[])}return ie(i,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),i}(),We=function(){function i(o){ne(this,i),this.name=o||"",this._prefix="[".concat(this.name,"]")}return ie(i,[{key:"warn",value:function(){var e;if(!i.disabled){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];(e=console).warn.apply(e,[this._prefix].concat(t))}}}],[{key:"enable",value:function(){i.disabled=!1}},{key:"disable",value:function(){i.disabled=!0}}]),i}();O(We,"disabled",!0);var pt=typeof window<"u",jt=pt&&navigator.userAgent.toLocaleLowerCase(),$r=pt&&/^((?!chrome|android).)*safari/.test(jt),ui=pt&&jt.includes("firefox"),li=pt&&jt.includes("android"),ke=function(){function i(){ne(this,i)}return ie(i,null,[{key:"getRateIndexByRate",value:function(e){return i.FREQ.indexOf(e)}},{key:"parseADTS",value:function(e,r){for(var t=e.length,n=0;n+2<t&&!(e[n]===255&&(e[n+1]&246)===240);)n++;if(!(n>=t)){var a=n,s=[],u=(e[n+2]&60)>>>2,l=i.FREQ[u];if(!l)throw new Error("Invalid sampling index: ".concat(u));for(var f=((e[n+2]&192)>>>6)+1,c=(e[n+2]&1)<<2|(e[n+3]&192)>>>6,v=i._getConfig(u,c,f),d=v.config,p=v.codec,y,h,b=0,S=i.getFrameDuration(l);n+7<t;){if(e[n]!==255||(e[n+1]&246)!==240){n++;continue}if(h=(e[n+3]&3)<<11|e[n+4]<<3|(e[n+5]&224)>>5,t-n<h)break;y=(~e[n+1]&1)*2,s.push({pts:r+b*S,data:e.subarray(n+7+y,n+h)}),b++,n+=h}return{skip:a,remaining:n>=t?void 0:e.subarray(n),frames:s,samplingFrequencyIndex:u,sampleRate:l,objectType:f,channelCount:c,codec:p,config:d,originCodec:"mp4a.40.".concat(f)}}}},{key:"parseAudioSpecificConfig",value:function(e){if(e.length){var r=e[0]>>>3,t=(e[0]&7)<<1|e[1]>>>7,n=(e[1]&120)>>>3,a=i.FREQ[t];if(a){var s=i._getConfig(t,n,r),u=s.config,l=s.codec;return{samplingFrequencyIndex:t,sampleRate:a,objectType:r,channelCount:n,config:u,codec:l,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*r/e}},{key:"_getConfig",value:function(e,r,t){var n=[],a,s;return ui?e>=6?(a=5,s=e-3):(a=2,s=e):li?(a=2,s=e):(a=t===2||t===5?t:5,s=e,e>=6?s=e-3:r===1&&(a=2,s=e)),n[0]=a<<3,n[0]|=(e&14)>>1,n[1]=(e&1)<<7,n[1]|=r<<3,a===5&&(n[1]|=(s&14)>>1,n[2]=(s&1)<<7,n[2]|=8,n[3]=0),{config:n,codec:"mp4a.40.".concat(a)}}},{key:"getSilentFrame",value:function(e,r){switch(e){case"mp4a.40.2":if(r===1)return new Uint8Array([0,200,0,128,35,128]);if(r===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(r===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(r===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(r===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(r===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(r===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(r===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(r===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),i}();O(ke,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var fi=500,Wr=3,Ht=1e3,zt=5e3,ci=1e3,hi=200,Kr=5e3,Yr=5,di=function(){function i(o,e,r){ne(this,i),this.videoTrack=o,this.audioTrack=e,this.metadataTrack=r,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return ie(i,[{key:"fix",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;r=Math.round(r*1e3);var a=this.videoTrack,s=this.audioTrack;(t||!n)&&(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),t&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(s,a),!n&&r&&(this._audioNextPts=this._videoNextDts=r);var u=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(u&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._keyFrameInNextChunk=!1,this._fixVideo(a),this.metadataTrack.exist()){var l=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(f){f.pts=f.originPts-e._baseDts,f.time=Math.max(0,f.pts)/l}),this.metadataTrack.flvScriptSamples.forEach(function(f){f.pts=f.originPts-e._baseDts,f.time=Math.max(0,f.pts)/l})}a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/1e3)}},{key:"_fixVideo",value:function(e){var r=this,t=e.samples;if(t.length){t.forEach(function(S){S.dts-=r._baseDts,S.pts-=r._baseDts,S.keyframe&&(r._keyFrameInNextChunk=!0)});var n;if(e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var a=e.samples[0],s=e.samples[t.length-1];n=Math.floor((s.dts-a.dts)/(t.length-1))}else n=this._lastVideoDuration||40;var u=t.pop();if(this._videoLastSample&&t.unshift(this._videoLastSample),this._videoLastSample=u,!!t.length){if(this._videoNextDts===void 0){var l=t[0];this._videoNextDts=l.dts}var f=t.length,c=0,v=t[0],d=this._videoNextDts-v.dts;if(Math.abs(d)>hi){if(Math.abs(v.dts-this._lastVideoExceptionChunkFirstDtsDot)>Kr){var p;this._lastVideoExceptionChunkFirstDtsDot=v.dts,e.warnings.push({type:se.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:v.dts,nextSampleDts:(p=t[1])===null||p===void 0?void 0:p.dts,sampleDuration:d})}this._videoTimestampBreak>=Yr?(this._videoNextDts=v.dts,this._videoTimestampBreak=0):(v.dts+=d,v.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var y=0;y<f;y++){var h=t[y].dts,b=t[y+1];y<f-1?c=b.dts-h:u?c=u.dts-h:c=n,(c>ci||c<0)&&(this._videoTimestampBreak++,Math.abs(h-this._lastVideoExceptionLargeGapDot)>Kr&&(this._lastVideoExceptionLargeGapDot=h,e.warnings.push({type:se.LARGE_VIDEO_GAP,time:h/e.timescale,dts:h,originDts:t[y].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),t[y].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{key:"_fixAudio",value:function(e){var r=this,t=e.samples;t.length&&(t.forEach(function(n){n.dts=n.pts-=r._baseDts}),this._doFixAudioInternal(e,t,1e3))}},{key:"_calculateBaseDts",value:function(e,r){var t=e.samples,n=r.samples;if(!t.length&&!n.length)return!1;var a=1/0,s=1/0;t.length&&(e.baseDts=a=t[0].pts),n.length&&(r.baseDts=s=n[0].dts),this._baseDts=Math.min(a,s);var u=s-a;return Number.isFinite(u)&&Math.abs(u)>fi&&r.warnings.push({type:se.LARGE_AV_SHIFT,videoBaseDts:s,audioBasePts:a,baseDts:this._baseDts,delta:u}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var e=this._calculateBaseDts(this.audioTrack,this.videoTrack);e&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,r,t){e.sampleDuration||(e.sampleDuration=e.codecType===Oe.AAC?ke.getFrameDuration(e.timescale,t):this._getG711Duration(e));var n=e.sampleDuration,a=e.codecType===Oe.AAC?1024:n*e.timescale/1e3;if(this._audioNextPts===void 0){var s=r[0];this._audioNextPts=s.pts}for(var u=0;u<r.length;u++){var l=this._audioNextPts,f=r[u],c=f.pts-l;if(u===0&&this._audioTimestampBreak>=Yr&&this._keyFrameInNextChunk&&(l=this._audioNextPts=f.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=Wr*n&&c<=Ht&&!$r){var v=this._getSilentFrame(e)||r[0].data.subarray(),d=Math.floor(c/n);Math.abs(f.pts-this._lastAudioExceptionGapDot)>zt&&(this._lastAudioExceptionGapDot=f.pts,e.warnings.push({type:se.AUDIO_FILLED,pts:f.pts,originPts:f.originPts,count:d,nextPts:l,refSampleDuration:n}));for(var p=0;p<d;p++){var y=new $e(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),v,a);y.originPts=Math.floor(this._baseDts+l),r.splice(u,0,y),this._audioNextPts+=n,u++}u--}else c<=-Wr*n&&c>=-1*Ht?(Math.abs(f.pts-this._lastAudioExceptionOverlapDot)>zt&&(this._lastAudioExceptionOverlapDot=f.pts,e.warnings.push({type:se.AUDIO_DROPPED,pts:f.pts,originPts:f.originPts,nextPts:l,refSampleDuration:n})),r.splice(u,1),u--):(Math.abs(c)>Ht&&(this._audioTimestampBreak++,Math.abs(f.pts-this._lastAudioExceptionLargeGapDot)>zt&&(this._lastAudioExceptionLargeGapDot=f.pts,e.warnings.push({type:se.LARGE_AUDIO_GAP,time:f.pts/1e3,pts:f.pts,originPts:f.originPts,nextPts:l,sampleDuration:c,refSampleDuration:n}))),f.dts=f.pts=l,f.duration=a,this._audioNextPts+=n)}}},{key:"_getG711Duration",value:function(e){var r=e.sampleSize,t=e.channelCount,n=e.sampleRate,a=e.samples[0];if(a)return a.data.byteLength*2/t/(r/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===Oe.AAC?ke.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),i}();function Ee(){for(var i=arguments.length,o=new Array(i),e=0;e<i;e++)o[e]=arguments[e];o=o.filter(Boolean);var r=new Uint8Array(o.reduce(function(n,a){return n+a.byteLength},0)),t=0;return o.forEach(function(n){r.set(n,t),t+=n.byteLength}),r}var vi=Math.pow(2,32);function ae(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[o]<<8)+(i[o+1]||0)}function pi(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[o]<<16)+(i[o+1]<<8)+(i[o+2]||0)}function I(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[o]<<24>>>0)+(i[o+1]<<16)+(i[o+2]<<8)+(i[o+3]||0)}function Ue(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return I(i,o)*vi+I(i,o+4)}function Xr(i){for(var o="avc1.",e,r=0;r<3;r++)e=i[r].toString(16),e.length<2&&(e="0".concat(e)),o+=e;return o}function qr(i){if(!Array.isArray(i)){for(var o=[],e="",r=0;r<i.length;r++)r%2&&(e=i[r-1]+i[r],o.push(parseInt(e,16)),e="");return o}return i.map(function(t){return parseInt(t,16)})}var Te=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseAnnexB",value:function(e){for(var r=e.length,t=2,n=0;e[t]!==null&&e[t]!==void 0&&e[t]!==1;)t++;if(t++,n=t+2,n>=r)return[];for(var a=[];n<r;)switch(e[n]){case 0:if(e[n-1]!==0){n+=2;break}else if(e[n-2]!==0){n++;break}t!==n-2&&a.push(e.subarray(t,n-2));do n++;while(e[n]!==1&&n<r);t=n+1,n=t+2;break;case 1:if(e[n-1]!==0||e[n-2]!==0){n+=3;break}t!==n-2&&a.push(e.subarray(t,n-2)),t=n+1,n=t+2;break;default:n+=3;break}return t<r&&a.push(e.subarray(t)),a}},{key:"parseAvcC",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;if(!(e.length<4)){for(var t=e.length,n=[],a=0,s;a+r<t;)if(s=I(e,a),r===3&&(s>>>=8),a+=r,!!s){if(a+s>t)break;n.push(e.subarray(a,a+s)),a+=s}return n}}},{key:"parseSEI",value:function(e,r){for(var t=e.length,n=r?2:1,a=0,s=0,u="";e[n]===255;)a+=255,n++;for(a+=e[n++];e[n]===255;)s+=255,n++;if(s+=e[n++],a===5&&t>n+16)for(var l=0;l<16;l++)u+=e[n].toString(16),n++;return{payload:e.subarray(n,n+s),type:a,size:s,uuid:u}}},{key:"removeEPB",value:function(e){for(var r=e.byteLength,t=[],n=1;n<r-2;)e[n]===0&&e[n+1]===0&&e[n+2]===3?(t.push(n+2),n+=2):n++;if(!t.length)return e;var a=r-t.length,s=new Uint8Array(a),u=0;for(n=0;n<a;u++,n++)u===t[0]&&(u++,t.shift()),s[n]=e[u];return s}}]),i}(),$t=function(){function i(o){if(ne(this,i),O(this,"_bytesAvailable",void 0),O(this,"_bitsAvailable",0),O(this,"_word",0),!o)throw new Error("ExpGolomb data params is required");this._data=o,this._bytesAvailable=o.byteLength,this._bytesAvailable&&this._loadWord()}return ie(i,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,r=Math.min(4,this._bytesAvailable);if(r===0)throw new Error("No bytes available");var t=new Uint8Array(4);t.set(this._data.subarray(e,e+r)),this._word=new DataView(t.buffer).getUint32(0),this._bitsAvailable=r*8,this._bytesAvailable-=r}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var r=Math.floor(e/8);e-=r*8,this._bytesAvailable-=r,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var r=Math.min(this._bitsAvailable,e),t=this._word>>>32-r;return this._bitsAvailable-=r,this._bitsAvailable>0?this._word<<=r:this._bytesAvailable>0&&this._loadWord(),r=e-r,r>0&&this._bitsAvailable?t<<r|this.readBits(r):t}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(this._word&2147483648>>>e)return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var r=8,t=8,n,a=0;a<e;a++)t!==0&&(n=this.readEG(),t=(r+n+256)%256),r=t===0?r:t}}]),i}(),Qr=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(e){if(!(e.length<7)){for(var r=(e[4]&3)+1,t,n=[],a=[],s=6,u=e[5]&31,l,f=0;f<u;f++)if(l=e[s]<<8|e[s+1],s+=2,!!l){var c=e.subarray(s,s+l);s+=l,n.push(c),t||(t=i.parseSPS(Te.removeEPB(c)))}var v=e[s];s++;for(var d,p=0;p<v;p++)d=e[s]<<8|e[s+1],s+=2,d&&(a.push(e.subarray(s,s+d)),s+=d);return{sps:t,spsArr:n,ppsArr:a,nalUnitSize:r}}}},{key:"parseSPS",value:function(e){var r=new $t(e);r.readUByte();var t=r.readUByte(),n=r.readUByte(),a=r.readUByte();r.skipUEG();var s=420;if(t===100||t===110||t===122||t===244||t===44||t===83||t===86||t===118||t===128||t===138||t===144){var u=r.readUEG();if(u<=3&&(s=[0,420,422,444][u]),u===3&&r.skipBits(1),r.skipUEG(),r.skipUEG(),r.skipBits(1),r.readBool())for(var l=u!==3?8:12,f=0;f<l;f++)r.readBool()&&(f<6?r.skipScalingList(16):r.skipScalingList(64))}r.skipUEG();var c=r.readUEG();if(c===0)r.readUEG();else if(c===1){r.skipBits(1),r.skipUEG(),r.skipUEG();for(var v=r.readUEG(),d=0;d<v;d++)r.skipUEG()}r.skipUEG(),r.skipBits(1);var p=r.readUEG(),y=r.readUEG(),h=r.readBits(1);h===0&&r.skipBits(1),r.skipBits(1);var b=0,S=0,E=0,A=0;r.readBool()&&(b=r.readUEG(),S=r.readUEG(),E=r.readUEG(),A=r.readUEG());var k,U,N,F,G;if(r.readBool()){if(r.readBool()){var M=r.readUByte();switch(M){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:{k=[r.readUByte()<<8|r.readUByte(),r.readUByte()<<8|r.readUByte()];break}}}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){var X=r.readBits(32),m=r.readBits(32);U=r.readBool(),N=m,F=X*2,G=N/F}}return{codec:Xr(e.subarray(1,4)),profileIdc:t,profileCompatibility:n,levelIdc:a,chromaFormat:s,width:Math.ceil((p+1)*16-2*(b+S)),height:(2-h)*(y+1)*16-(h?2:4)*(E+A),sarRatio:k,fpsNum:N,fpsDen:F,fps:G,fixedFrame:U}}}]),i}(),Wt=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(e.length<23)){r=r||{};for(var t=(e[21]&3)+1,n,a,s=[],u=[],l=[],f=23,c=e[22],v,d,p,y=0;y<c;y++){v=e[f]&63,d=e[f+1]<<8|e[f+2],f+=3;for(var h=0;h<d;h++)if(p=e[f]<<8|e[f+1],f+=2,!!p){switch(v){case 32:{var b=e.subarray(f,f+p);n||(n=i.parseVPS(Te.removeEPB(b),r)),l.push(b)}break;case 33:{var S=e.subarray(f,f+p);a||(a=i.parseSPS(Te.removeEPB(S),r)),s.push(S)}break;case 34:u.push(e.subarray(f,f+p));break}f+=p}}return{hvcC:r,sps:a,spsArr:s,ppsArr:u,vpsArr:l,nalUnitSize:t}}}},{key:"parseVPS",value:function(e,r){r=r||{};var t=new $t(e);t.readUByte(),t.readUByte(),t.readBits(12);var n=t.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,n+1),t.readBits(17),i._parseProfileTierLevel(t,n,r),r}},{key:"parseSPS",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};r=r||{};var t=new $t(e);t.readUByte(),t.readUByte(),t.readBits(4);var n=t.readBits(3);r.numTemporalLayers=Math.max(n+1,r.numTemporalLayers||0),r.temporalIdNested=t.readBits(1),i._parseProfileTierLevel(t,n,r),t.readUEG();var a=r.chromaFormatIdc=t.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var u=0;a===3&&(u=t.readBits(1));var l=t.readUEG(),f=t.readUEG(),c=t.readBits(1),v,d,p,y;if(c===1&&(v=t.readUEG(),d=t.readUEG(),p=t.readUEG(),y=t.readUEG()),r.bitDepthLumaMinus8=t.readUEG(),r.bitDepthChromaMinus8=t.readUEG(),c===1){var h=(a===1||a===2)&&u===0?2:1,b=a===1&&u===0?2:1;l-=h*(d+v),f-=b*(y+p)}return{codec:"hev1.1.6.L93.B0",width:l,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,r,t){var n=t.generalTierFlag||0;t.generalProfileSpace=e.readBits(2),t.generalTierFlag=Math.max(e.readBits(1),n),t.generalProfileIdc=Math.max(e.readBits(5),t.generalProfileIdc||0),t.generalProfileCompatibilityFlags=e.readBits(32),t.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var a=e.readBits(8);n<t.generalTierFlag?t.generalLevelIdc=a:t.generalLevelIdc=Math.max(a,t.generalLevelIdc||0);var s=[],u=[];if(r>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(r));for(var l=0;l<r;l++)s[l]=e.readBits(1),u[l]=e.readBits(1);r>0&&e.readBits((8-r)*2);for(var f=0;f<r;f++)s[f]!==0&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),u[f]!==0&&e.readBits(8)}}]),i}(),Jr=function(){function i(){ne(this,i)}return ie(i,null,[{key:"decode",value:function(e){for(var r=[],t=e,n=0,a=e.length;n<a;){if(t[n]<128){r.push(String.fromCharCode(t[n])),++n;continue}else if(!(t[n]<192)){if(t[n]<224){if(i._checkContinuation(t,n,1)){var s=(t[n]&31)<<6|t[n+1]&63;if(s>=128){r.push(String.fromCharCode(s&65535)),n+=2;continue}}}else if(t[n]<240){if(i._checkContinuation(t,n,2)){var u=(t[n]&15)<<12|(t[n+1]&63)<<6|t[n+2]&63;if(u>=2048&&(u&63488)!==55296){r.push(String.fromCharCode(u&65535)),n+=3;continue}}}else if(t[n]<248&&i._checkContinuation(t,n,3)){var l=(t[n]&7)<<18|(t[n+1]&63)<<12|(t[n+2]&63)<<6|t[n+3]&63;if(l>65536&&l<1114112){l-=65536,r.push(String.fromCharCode(l>>>10|55296)),r.push(String.fromCharCode(l&1023|56320)),n+=4;continue}}}r.push("\uFFFD"),++n}return r.join("")}},{key:"_checkContinuation",value:function(e,r,t){var n=e;if(r+t<n.length){for(;t--;)if((n[++r]&192)!==128)return!1;return!0}else return!1}}]),i}(),mi=function(){function i(){ne(this,i)}return ie(i,null,[{key:"parse",value:function(e){if(!(e.length<3)){var r={},t=i._parseValue(new DataView(e.buffer,e.byteOffset,e.byteLength)),n=i._parseValue(new DataView(e.buffer,e.byteOffset+t.size,e.byteLength-t.size));return r[t.data]=n.data,r}}},{key:"_parseValue",value:function(e){var r=e.byteLength,t=e.getUint8(0),n=1,a=!1,s;switch(t){case 0:s=e.getFloat64(1),n+=8;break;case 1:{s=!!e.getUint8(1),n+=1;break}case 2:{var u=i._parseString(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n)),l=u.data,f=u.size;s=l,n+=f}break;case 3:{s={};var c=0;for((e.getUint32(r-4)&16777215)===9&&(c=3);n<r-4;){var v=i._parseObject(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n-c)),d=v.size,p=v.data,y=v.isEnd;if(y)break;s[p.name]=p.value,n+=d}if(n<=r-3){var h=e.getUint32(n-1)&16777215;h===9&&(n+=3)}}break;case 8:{s={},n+=4;var b=0;for((e.getUint32(r-4)&16777215)===9&&(b=3);n<r-8;){var S=i._parseObject(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n-b)),E=S.size,A=S.data,k=S.isEnd;if(k)break;s[A.name]=A.value,n+=E}if(n<=r-3){var U=e.getUint32(n-1)&16777215;U===9&&(n+=3)}}break;case 9:s=void 0,n=1,a=!0;break;case 10:{s=[];var N=e.getUint32(1);n+=4;for(var F=0;F<N;F++){var G=i._parseValue(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n)),M=G.data,X=G.size;s.push(M),n+=X}}break;case 11:{var m=e.getFloat64(n)+e.getInt16(n+8)*6e4;s=new Date(m),n+=10}break;case 12:{var g=e.getUint32(1);n+=4,s="",g>0&&(s=Jr.decode(new Uint8Array(e.buffer,e.byteOffset+n,g))),n+=g}break;default:n=r;break}return{data:s,size:n,isEnd:a}}},{key:"_parseString",value:function(e){var r=e.getUint16(0),t="";return r>0&&(t=Jr.decode(new Uint8Array(e.buffer,e.byteOffset+2,r))),{data:t,size:2+r}}},{key:"_parseObject",value:function(e){if(!(e.byteLength<3)){var r=i._parseString(e),t=i._parseValue(new DataView(e.buffer,e.byteOffset+r.size,e.byteLength-r.size));return{data:{name:r.data,value:t.data},size:r.size+t.size,isEnd:t.isEnd}}}}]),i}(),Ce=new We("FlvDemuxer"),Zr=function(){function i(o,e,r){ne(this,i),O(this,"_headerParsed",!1),O(this,"_remainingData",null),O(this,"_gopId",0),O(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=o||new Nt,this.audioTrack=e||new Ft,this.metadataTrack=r||new Gt,this._fixer=new di(this.videoTrack,this.audioTrack,this.metadataTrack)}return ie(i,[{key:"demux",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=this.audioTrack,a=this.videoTrack,s=this.metadataTrack;if((r||!t)&&(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),n.reset(),s.reset()):(a.samples=[],n.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],n.warnings=[],this._remainingData&&(e=Ee(this._remainingData,e),this._remainingData=null)),!e.length)return{videoTrack:a,audioTrack:n,metadataTrack:s};var u=0;if(!this._headerParsed){if(!i.probe(e))throw new Error("Invalid flv file");n.present=(e[4]&4)>>>2!==0,a.present=(e[4]&1)!==0,this._headerParsed=!0,u=I(e,5)+4}for(var l=e.length,f,c,v,d,p;u+15<l&&(f=e[u],c=e[u+1]<<16|e[u+2]<<8|e[u+3],!(u+15+c>l));)v=(e[u+7]<<24>>>0)+(e[u+4]<<16)+(e[u+5]<<8)+e[u+6],u+=11,d=e.subarray(u,u+c),f===8?this._parseAudio(d,v):f===9?this._parseVideo(d,v):f===18?this._parseScript(d,v):Ce.warn("Invalid tag type: ".concat(f)),u+=c,p=I(e,u),p!==11+c&&Ce.warn("Invalid PrevTagSize ".concat(p," (").concat(11+c,")")),u+=4;return u<l&&(this._remainingData=e.subarray(u)),n.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,n.timescale=n.sampleRate||0,!n.exist()&&n.hasSample()&&n.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:n,metadataTrack:s}}},{key:"fix",value:function(e,r,t){return this._fixer.fix(e,r,t),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,r,t,n){return this.demux(e,r,t),this.fix(n,r,t)}},{key:"_parseAudio",value:function(e,r){if(e.length){var t=(e[0]&240)>>>4,n=this.audioTrack;if(t!==10&&t!==7&&t!==8){Ce.warn("Unsupported sound format: ".concat(t)),n.reset();return}if(t!==10){var a=(e[0]&12)>>2,s=(e[0]&2)>>1,u=e[0]&1;n.sampleRate=i.AUDIO_RATE[a],n.sampleSize=s?16:8,n.channelCount=u+1}t===10?this._parseAac(e,r):this._parseG711(e,r,t)}}},{key:"_parseG711",value:function(e,r,t){var n=this.audioTrack;n.codecType=t===7?Oe.G711PCMA:Oe.G711PCMU,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new $e(r,e.subarray(1)))}},{key:"_parseAac",value:function(e,r){var t=this.audioTrack;if(t.codecType=Oe.AAC,e[1]===0){var n=ke.parseAudioSpecificConfig(e.subarray(2));n?(t.codec=n.codec,t.channelCount=n.channelCount,t.sampleRate=n.sampleRate,t.config=n.config,t.objectType=n.objectType,t.sampleRateIndex=n.samplingFrequencyIndex):(t.reset(),Ce.warn("Cannot parse AudioSpecificConfig",e))}else if(e[1]===1){if(r==null)return;t.samples.push(new $e(r,e.subarray(2)))}else Ce.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,r){var t=this;if(!(e.length<6)){var n=(e[0]&240)>>>4,a=e[0]&15,s=this.videoTrack;if(a!==7&&a!==12){s.reset(),Ce.warn("Unsupported codecId: ".concat(a));return}var u=a===12;s.codecType=u?Ie.HEVC:Ie.AVC;var l=e[1],f=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(l===0){var c=e.subarray(5),v=u?Wt.parseHEVCDecoderConfigurationRecord(c):Qr.parseAVCDecoderConfigurationRecord(c);if(v){var d=v.hvcC,p=v.sps,y=v.ppsArr,h=v.spsArr,b=v.vpsArr,S=v.nalUnitSize;d&&(s.hvcC=s.hvcC||d),p&&(s.codec=p.codec,s.width=p.width,s.height=p.height,s.sarRatio=p.sarRatio,s.fpsNum=p.fpsNum,s.fpsDen=p.fpsDen),h.length&&(s.sps=h),y.length&&(s.pps=y),b&&b.length&&(s.vps=b),S&&(s.nalUnitSize=S)}else Ce.warn("Cannot parse ".concat(u?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(l===1){var E=Te.parseAvcC(e.subarray(5),s.nalUnitSize);if(E=this._checkAddMetaNalToUnits(u,E,s),E&&E.length){var A=new Vt(r+f,r,E);n===1&&A.setToKeyframe(),s.samples.push(A),E.forEach(function(k){var U=u?k[0]>>>1&63:k[0]&31;switch(U){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!u&&U!==5||u&&U===5)break;A.setToKeyframe();break;case 6:case 39:case 40:if(!u&&U!==6||u&&U===6)break;t.metadataTrack.seiSamples.push(new zr(Te.parseSEI(Te.removeEPB(k),u),r+f));break}}),A.keyframe&&this._gopId++,A.gopId=this._gopId}else Ce.warn("Cannot parse NALUs",e)}else l===2||Ce.warn("Unknown AVCPacketType: ".concat(l))}}},{key:"_checkAddMetaNalToUnits",value:function(e,r,t){if(!e||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,r;var n=r.map(function(a){return a[0]>>>1&63});return n.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,r):(r.unshift(t.pps[0]),r.unshift(t.sps[0]),r.unshift(t.vps[0]),r.filter(Boolean))}},{key:"_parseScript",value:function(e,r){this.metadataTrack.flvScriptSamples.push(new oi(mi.parse(e),r))}}],[{key:"probe",value:function(e){return e[0]!==70||e[1]!==76||e[2]!==86||e[3]!==1?!1:I(e,5)>=9}}]),i}();O(Zr,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var gi=9e4/2,en=3,Kt=9e4,Yt=5*9e4,Xt=9e4,yi=9e4/2,_i=function(){function i(o,e,r){ne(this,i),this.videoTrack=o,this.audioTrack=e,this.metadataTrack=r,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0}return ie(i,[{key:"fix",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;r=Math.round(r*9e4);var a=this.videoTrack,s=this.audioTrack,u=a.samples,l=s.samples;if(!(!u.length&&!l.length)){var f=u[0],c=l[0],v=0;if(u.length&&l.length&&(v=f.dts-c.pts),this._baseDtsInited||this._calculateBaseDts(this.audioTrack,this.videoTrack),t&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=r),!n){this._videoNextDts=v>0?r+v:r,this._audioNextPts=v>0?r:r-v;var d=f?f.dts-this._baseDts-this._videoNextDts:0,p=c?c.pts-this._baseDts-this._audioNextPts:0;Math.abs(d||p)>Xt&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=r)}if(this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(a),this.metadataTrack.exist()){var y=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(h){h.pts=h.originPts-e._baseDts,h.time=Math.max(0,h.pts)/y})}a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/9e4)}}},{key:"_fixVideo",value:function(e){var r=this,t=e.samples;if(t.length){if(t.forEach(function(N){N.dts-=r._baseDts,N.pts-=r._baseDts}),this._videoNextDts===void 0){var n=t[0];this._videoNextDts=n.dts}var a=t.length,s=0,u=t[0],l=t[1],f=this._videoNextDts-u.dts;if(Math.abs(f)>yi){var c;if(e.warnings.push({type:se.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts/90,firstSampleDts:u.dts/90,nextSampleDts:(((c=t[1])===null||c===void 0?void 0:c.dts)||0)/90,sampleDuration:f/90}),u.dts+=f,u.pts+=f,l&&Math.abs(l.dts-u.dts)>Xt)this._videoTimestampBreak=!0,t.forEach(function(N,F){F!==0&&(N.dts+=f,N.pts+=f)});else for(var v=1;v<a-1;v++){var d,p=(d=t[v])===null||d===void 0?void 0:d.dts,y=t[v-1].dts;p&&p-y<0&&(t[v].dts+=f,t[v].pts+=f)}}var h;if(e.fpsNum&&e.fpsDen)h=e.timescale*(e.fpsDen/e.fpsNum);else{var b=e.samples[0],S=e.samples[1];h=a===1?9e3:Math.floor(S.dts-b.dts)}for(var E=0;E<a;E++){var A=t[E].dts,k=t[E+1];if(E<a-1?s=k.dts-A:t[E-1]?s=Math.min(A-t[E-1].dts,h):s=h,s>Xt||s<0){this._videoTimestampBreak=!0,s=this._audioTimestampBreak?h:Math.max(s,30*90);var U=this._audioNextPts||0;k&&k.dts>U&&(s=h),e.warnings.push({type:se.LARGE_VIDEO_GAP,time:A/e.timescale,dts:A,originDts:t[E].originDts,nextDts:this._videoNextDts,sampleDuration:s,refSampleDuration:h})}t[E].duration=s,this._videoNextDts+=s}}}},{key:"_fixAudio",value:function(e){var r=this,t=e.samples;t.length&&(t.forEach(function(n){n.pts-=r._baseDts,n.dts=n.pts}),this._doFixAudioInternal(e,t,9e4))}},{key:"_calculateBaseDts",value:function(e,r){var t=e.samples,n=r.samples;if(!t.length&&!n.length)return!1;var a=1/0,s=1/0;t.length&&(e.baseDts=a=t[0].pts),n.length&&(r.baseDts=s=n[0].dts),this._baseDts=Math.min(a,s);var u=s-a;return Number.isFinite(u)&&Math.abs(u)>gi&&r.warnings.push({type:se.LARGE_AV_SHIFT,videoBaseDts:s,audioBasePts:a,baseDts:this._baseDts,delta:u}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){var e=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!e)return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}},{key:"_doFixAudioInternal",value:function(e,r,t){e.sampleDuration||(e.sampleDuration=ke.getFrameDuration(e.timescale,t));var n=e.sampleDuration;if(this._audioNextPts===void 0){var a=r[0];this._audioNextPts=a.pts}for(var s=0;s<r.length;s++){var u=this._audioNextPts,l=r[s],f=l.pts-u;if(!this._audioTimestampBreak&&f>=en*n&&f<=Kt&&!$r){var c=ke.getSilentFrame(e.codec,e.channelCount)||r[0].data.subarray(),v=Math.floor(f/n);Math.abs(l.pts-this._lastAudioExceptionGapDot)>Yt&&(this._lastAudioExceptionGapDot=l.pts),e.warnings.push({type:se.AUDIO_FILLED,pts:l.pts,originPts:l.originPts,count:v,nextPts:u,refSampleDuration:n});for(var d=0;d<v;d++){var p=new $e(Math.floor(u),c);p.originPts=Math.floor(this._baseDts+u),r.splice(s,0,p),this._audioNextPts+=n,s++}s--}else f<=-en*n&&f>=-1*Kt?(Math.abs(l.pts-this._lastAudioExceptionOverlapDot)>Yt&&(this._lastAudioExceptionOverlapDot=l.pts,e.warnings.push({type:se.AUDIO_DROPPED,pts:l.pts,originPts:l.originPts,nextPts:u,refSampleDuration:n})),r.splice(s,1),s--):(Math.abs(f)>=Kt&&(this._audioTimestampBreak=!0,Math.abs(l.pts-this._lastAudioExceptionLargeGapDot)>Yt&&(this._lastAudioExceptionLargeGapDot=l.pts,e.warnings.push({type:se.LARGE_AUDIO_GAP,time:l.pts/1e3,pts:l.pts,originPts:l.originPts,nextPts:u,sampleDuration:f,refSampleDuration:n}))),l.dts=l.pts=u,this._audioNextPts+=n)}}}]),i}(),Ae=new We("TsDemuxer"),tn=function(){function i(o,e,r){ne(this,i),O(this,"_pmtId",-1),O(this,"_remainingPacketData",null),O(this,"_videoPesData",[]),O(this,"_audioPesData",[]),O(this,"_gopId",0),this.videoTrack=o||new Nt,this.audioTrack=e||new Ft,this.metadataTrack=r||new Gt,this._fixer=new _i(this.videoTrack,this.audioTrack,this.metadataTrack)}return ie(i,[{key:"demux",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=this.audioTrack,a=this.videoTrack,s=this.metadataTrack;r&&(this._pmtId=-1,a.reset(),n.reset(),s.reset()),!t||r?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(a.samples=[],n.samples=[],s.seiSamples=[],a.warnings=[],n.warnings=[],this._remainingPacketData&&(e=Ee(this._remainingPacketData,e),this._remainingPacketData=null));var u=e.length,l=u%188;l&&(this._remainingPacketData=e.subarray(u-l),u-=l);for(var f=a.pid,c=n.pid,v=0;v<u;v+=188){if(e[v]!==71)throw new Error("TS packet did not start with 0x47");var d=!!(e[v+1]&64),p=((e[v+1]&31)<<8)+e[v+2],y=(e[v+3]&48)>>4,h=void 0;if(y>1){if(h=v+5+e[v+4],h===v+188)continue}else h=v+4;switch(p){case 0:d&&(h+=e[h]+1),this._pmtId=(e[h+10]&31)<<8|e[h+11];break;case this._pmtId:{d&&(h+=e[h]+1);var b=h+3+((e[h+1]&15)<<8|e[h+2])-4,S=(e[h+10]&15)<<8|e[h+11];for(h+=12+S;h<b;){var E=(e[h+1]&31)<<8|e[h+2];switch(e[h]){case 15:n.pid=c=E;break;case 27:if(f!==-1)break;a.codecType=Ie.AVC,a.pid=f=E;break;case 36:if(f!==-1)break;a.codecType=Ie.HEVC,a.pid=f=E;break;default:Ae.warn("Unsupported stream. type: ".concat(e[h],", pid: ").concat(E))}h+=((e[h+3]&15)<<8|e[h+4])+5}}break;case f:d&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(h,v+188));break;case c:d&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(h,v+188));break;case 17:case 8191:break;default:Ae.warn("Unknown pid: ".concat(p))}}return this._parseVideoData(),this._parseAudioData(),n.formatTimescale=a.formatTimescale=a.timescale=s.timescale=9e4,n.timescale=n.sampleRate||0,{videoTrack:a,audioTrack:n,metadataTrack:s}}},{key:"fix",value:function(e,r,t){return this._fixer.fix(e,r,t),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,r,t,n){return this.demux(e,r,t),this.fix(n,r,t)}},{key:"_parseVideoData",value:function(){if(this._videoPesData.length){var e=i._parsePES(Ee.apply(void 0,Se(this._videoPesData)));if(!e){Ae.warn("Cannot parse video pes",this._videoPesData);return}var r=Te.parseAnnexB(e.data);r?this._createVideoSample(r,e.pts,e.dts):Ae.warn("Cannot parse avc units",e),this._videoPesData=[]}}},{key:"_createVideoSample",value:function(e,r,t){var n=this;if(e.length){var a=this.videoTrack,s=a.codecType===Ie.HEVC,u=new Vt(r,t);e.forEach(function(l){var f=s?l[0]>>>1&63:l[0]&31;switch(f){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&f!==5||s&&f===5)break;u.setToKeyframe(),n._gopId++;break;case 6:case 39:case 40:if(!s&&f!==6||s&&f===6)break;n.metadataTrack.seiSamples.push(new zr(Te.parseSEI(Te.removeEPB(l),s),r));return;case 32:if(!s)break;if(!a.vps.length){var c=Wt.parseVPS(Te.removeEPB(l),a.hvcC);a.hvcC=a.hvcC||c,a.vps=[l]}break;case 7:case 33:if(!s&&f!==7||s&&f===7)break;if(!a.sps.length){var v=Te.removeEPB(l),d=s?Wt.parseSPS(v,a.hvcC):Qr.parseSPS(v);a.sps=[l],a.hvcC=a.hvcC||d.hvcC,a.codec=d.codec,a.width=d.width,a.height=d.height,a.sarRatio=d.sarRatio,a.fpsNum=d.fpsNum,a.fpsDen=d.fpsDen}break;case 8:case 34:if(!s&&f!==8||s&&f===8)break;a.pps.length||(a.pps=[l]);break;case 9:case 35:break;case 38:if(s){for(var p=!1,y=2;y<l.byteLength;y++)if(l[y]===255){p=!0;break}if(!p)return}break}u.units.push(l)}),u.gopId=this._gopId,this._pushVideoSample(a,u)}}},{key:"_pushVideoSample",value:function(e,r){if(r.units.length)if(r.pts===null||r.pts===void 0){Ae.warn("Video sample no pts",r);var t=e.samples[e.samples.length-1];t?(r.pts=t.pts,r.dts=t.dts):Ae.warn("Drop video sample",r)}else e.samples.push(r)}},{key:"_parseAudioData",value:function(){if(this._audioPesData.length){var e=i._parsePES(Ee.apply(void 0,Se(this._audioPesData)));if(!e){Ae.warn("Cannot parse audio pes",this._audioPesData);return}this._parseAacData(e),this._audioPesData=[]}}},{key:"_parseAacData",value:function(e){var r=this.audioTrack,t=e.pts;if(t==null){if(Ae.warn("AAC pes not pts",r),!r.samples.length||!r.sampleRate)return;t=r.samples[r.samples.length-1].pts+ke.getFrameDuration(r.sampleRate)}var n=ke.parseADTS(e.data,t);if(n){var a;r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.objectType=n.objectType,r.sampleRateIndex=n.samplingFrequencyIndex,r.config=n.config,(a=r.samples).push.apply(a,Se(n.frames.map(function(s){return new $e(s.pts,s.data)}))),n.skip&&Ae.warn("Skip aac adts ".concat(n.skip," bits")),n.remaining&&Ae.warn("Remaining aac adts ".concat(n.remaining," bits"))}else Ae.warn("Cannot parse aac adts",e)}}],[{key:"probe",value:function(e){return e.length?e[0]===71&&e[188]===71&&e[376]===71:!1}},{key:"_parsePES",value:function(e){var r=e[8];if(!(r==null||e.length<r+9)){var t=e[0]<<16|e[1]<<8|e[2];if(t===1){var n=(e[4]<<8)+e[5];if(!(n&&n>e.length-6)){var a,s,u=e[7];return u&192&&(a=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,u&64?(s=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,a-s>60*9e4&&(a=s)):s=a),{data:e.subarray(9+r),pts:a,dts:s}}}}}}]),i}(),ce=function(){function i(){ne(this,i)}return ie(i,null,[{key:"findBox",value:function(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=[];if(!e)return n;for(var a=0,s="",u=0;e.length>7;){if(a=I(e),s=String.fromCharCode.apply(null,e.subarray(4,8)),u=8,a===1?(a=Ue(e,8),u+=8):a||(a=e.length),!r[0]||s===r[0]){var l=e.subarray(0,a);if(r.length<2)n.push({start:t,size:a,headerSize:u,type:s,data:l});else return i.findBox(l.subarray(u),r.slice(1),t+u)}t+=a,e=e.subarray(a)}return n}},{key:"tfhd",value:function(e){return W(e,!0,function(r,t){r.trackId=I(t);var n=4,a=r.flags&255&1,s=r.flags&255&2,u=r.flags&255&8,l=r.flags&255&16,f=r.flags&255&32;a&&(n+=4,r.baseDataOffset=I(t,n),n+=4),s&&(r.sampleDescriptionIndex=I(t,n),n+=4),u&&(r.defaultSampleDuration=I(t,n),n+=4),l&&(r.defaultSampleSize=I(t,n),n+=4),f&&(r.defaultSampleFlags=I(t,n))})}},{key:"sidx",value:function(e){return W(e,!0,function(r,t){var n=0;r.reference_ID=I(t,n),n+=4,r.timescale=I(t,n),n+=4,r.version===0?(r.earliest_presentation_time=I(t,n),n+=4,r.first_offset=I(t,n),n+=4):(r.earliest_presentation_time=Ue(t,n),n+=8,r.first_offset=Ue(t,n),n+=8),n+=2,r.references=[];var a=ae(t,n);n+=2;for(var s=0;s<a;s++){var u={};r.references.push(u);var l=I(t,n);n+=4,u.reference_type=l>>31&1,u.referenced_size=l&2147483647,u.subsegment_duration=I(t,n),n+=4,l=I(t,n),n+=4,u.starts_with_SAP=l>>31&1,u.SAP_type=l>>28&7,u.SAP_delta_time=l&268435455}})}},{key:"moov",value:function(e){return W(e,!1,function(r,t,n){r.mvhd=i.mvhd(i.findBox(t,["mvhd"],n)[0]),r.trak=i.findBox(t,["trak"],n).map(function(a){return i.trak(a)}),r.pssh=i.pssh(i.findBox(t,["pssh"],n)[0])})}},{key:"mvhd",value:function(e){return W(e,!0,function(r,t){var n=0;r.version===1?(r.timescale=I(t,16),r.duration=Ue(t,20),n+=28):(r.timescale=I(t,8),r.duration=I(t,12),n+=16),r.nextTrackId=I(t,n+76)})}},{key:"trak",value:function(e){return W(e,!1,function(r,t,n){r.tkhd=i.tkhd(i.findBox(t,["tkhd"],n)[0]),r.mdia=i.mdia(i.findBox(t,["mdia"],n)[0])})}},{key:"tkhd",value:function(e){return W(e,!0,function(r,t){var n=0;r.version===1?(r.trackId=I(t,16),r.duration=Ue(t,24),n+=32):(r.trackId=I(t,8),r.duration=I(t,16),n+=20),r.width=I(t,n+52),r.height=I(t,n+56)})}},{key:"mdia",value:function(e){return W(e,!1,function(r,t,n){r.mdhd=i.mdhd(i.findBox(t,["mdhd"],n)[0]),r.hdlr=i.hdlr(i.findBox(t,["hdlr"],n)[0]),r.minf=i.minf(i.findBox(t,["minf"],n)[0])})}},{key:"mdhd",value:function(e){return W(e,!0,function(r,t){var n=0;r.version===1?(r.timescale=I(t,16),r.duration=Ue(t,20),n+=28):(r.timescale=I(t,8),r.duration=I(t,12),n+=16);var a=ae(t,n);r.language=String.fromCharCode((a>>10&31)+96,(a>>5&31)+96,(a&31)+96)})}},{key:"hdlr",value:function(e){return W(e,!0,function(r,t){r.version===0&&(r.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))})}},{key:"minf",value:function(e){return W(e,!1,function(r,t,n){r.vmhd=i.vmhd(i.findBox(t,["vmhd"],n)[0]),r.smhd=i.smhd(i.findBox(t,["smhd"],n)[0]),r.stbl=i.stbl(i.findBox(t,["stbl"],n)[0])})}},{key:"vmhd",value:function(e){return W(e,!0,function(r,t){r.graphicsmode=ae(t),r.opcolor=[ae(t,2),ae(t,4),ae(t,6)]})}},{key:"smhd",value:function(e){return W(e,!0,function(r,t){r.balance=ae(t)})}},{key:"stbl",value:function(e){return W(e,!1,function(r,t,n){var a,s,u;r.stsd=i.stsd(i.findBox(t,["stsd"],n)[0]),r.stts=i.stts(i.findBox(t,["stts"],n)[0]),r.ctts=i.ctts(i.findBox(t,["ctts"],n)[0]),r.stsc=i.stsc(i.findBox(t,["stsc"],n)[0]),r.stsz=i.stsz(i.findBox(t,["stsz"],n)[0]),r.stco=i.stco(i.findBox(t,["stco"],n)[0]),r.stco||(r.co64=i.co64(i.findBox(t,["co64"],n)[0]),r.stco=r.co64);var l=(a=r.stsd.entries[0])===null||a===void 0||(s=a.sinf)===null||s===void 0||(u=s.schi)===null||u===void 0?void 0:u.tenc.default_IV_size;r.stss=i.stss(i.findBox(t,["stss"],n)[0]),r.senc=i.senc(i.findBox(t,["senc"],n)[0],l)})}},{key:"senc",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return W(e,!0,function(t,n){var a=0,s=I(n,a);a+=4,t.samples=[];for(var u=0;u<s;u++){var l={};l.InitializationVector=[];for(var f=0;f<r;f++)l.InitializationVector[f]=n[a+f];if(a+=r,t.flags&2){l.subsamples=[];var c=ae(n,a);a+=2;for(var v=0;v<c;v++){var d={};d.BytesOfClearData=ae(n,a),a+=2,d.BytesOfProtectedData=I(n,a),a+=4,l.subsamples.push(d)}}t.samples.push(l)}})}},{key:"pssh",value:function(e){return W(e,!0,function(r,t){for(var n=[],a=[],s=0,u=0;u<16;u++)a.push(qt(t[s+u]));if(s+=16,r.version>0){var l=I(t,s);s+=4;for(var f=0;f<(""+l).length;f++)for(var c=0;c<16;c++){var v=t[s];s+=1,n.push(qt(v))}}var d=I(t,s);r.data_size=d,s+=4,r.kid=n,r.system_id=a,r.buffer=t})}},{key:"stsd",value:function(e){return W(e,!0,function(r,t,n){r.entryCount=I(t),r.entries=i.findBox(t.subarray(4),[],n+4).map(function(a){switch(a.type){case"avc1":case"avc2":case"avc3":case"avc4":return i.avc1(a);case"hvc1":case"hev1":return i.hvc1(a);case"mp4a":return i.mp4a(a);case"alaw":case"ulaw":return i.alaw(a);case"enca":return W(a,!1,function(s,u,l){s.channelCount=ae(u,16),s.samplesize=ae(u,18),s.sampleRate=I(u,24)/65536,u=u.subarray(28),s.sinf=i.sinf(i.findBox(u,["sinf"],l)[0]),s.esds=i.esds(i.findBox(u,["esds"],l)[0])});case"encv":return W(a,!1,function(s,u,l){s.width=ae(u,24),s.height=ae(u,26),s.horizresolution=I(u,28),s.vertresolution=I(u,32),u=u.subarray(78),s.sinf=i.sinf(i.findBox(u,["sinf"],l)[0]),s.avcC=i.avcC(i.findBox(u,["avcC"],l)[0]),s.hvcC=i.hvcC(i.findBox(u,["hvcC"],l)[0]),s.pasp=i.pasp(i.findBox(u,["pasp"],l)[0])})}}).filter(Boolean)})}},{key:"tenc",value:function(e){return W(e,!1,function(r,t){var n=6;r.default_IsEncrypted=t[n],n+=1,r.default_IV_size=t[n],n+=1,r.default_KID=[];for(var a=0;a<16;a++)r.default_KID.push(qt(t[n])),n+=1})}},{key:"schi",value:function(e){return W(e,!1,function(r,t,n){r.tenc=i.tenc(i.findBox(t,["tenc"],n)[0])})}},{key:"sinf",value:function(e){return W(e,!1,function(r,t,n){r.schi=i.schi(i.findBox(t,["schi"],n)[0]),r.frma=i.frma(i.findBox(t,["frma"],n)[0])})}},{key:"frma",value:function(e){return W(e,!1,function(r,t){r.data_format="";for(var n=0;n<4;n++)r.data_format+=String.fromCharCode(t[n])})}},{key:"avc1",value:function(e){return W(e,!1,function(r,t,n){var a=nn(r,t),s=t.subarray(a);n+=a,r.avcC=i.avcC(i.findBox(s,["avcC"],n)[0]),r.pasp=i.pasp(i.findBox(s,["pasp"],n)[0])})}},{key:"avcC",value:function(e){return W(e,!1,function(r,t){r.configurationVersion=t[0],r.AVCProfileIndication=t[1],r.profileCompatibility=t[2],r.AVCLevelIndication=t[3],r.codec=Xr([t[1],t[2],t[3]]),r.lengthSizeMinusOne=t[4]&3,r.spsLength=t[5]&31,r.sps=[];for(var n=6,a=0;a<r.spsLength;a++){var s=ae(t,n);n+=2,r.sps.push(t.subarray(n,n+s)),n+=s}r.ppsLength=t[n],n+=1,r.pps=[];for(var u=0;u<r.ppsLength;u++){var l=ae(t,n);n+=2,r.pps.push(t.subarray(n,n+=l)),n+=l}})}},{key:"hvc1",value:function(e){return W(e,!1,function(r,t,n){var a=nn(r,t),s=t.subarray(a);n+=a,r.hvcC=i.hvcC(i.findBox(s,["hvcC"],n)[0]),r.pasp=i.pasp(i.findBox(s,["pasp"],n)[0])})}},{key:"hvcC",value:function(e){return W(e,!1,function(r,t){r.data=e.data,r.codec="hev1.1.6.L93.B0",r.configurationVersion=t[0];var n=t[1];r.generalProfileSpace=n>>6,r.generalTierFlag=(n&32)>>5,r.generalProfileIdc=n&31,r.generalProfileCompatibility=I(t,2),r.generalConstraintIndicatorFlags=t.subarray(6,12),r.generalLevelIdc=t[12],r.avgFrameRate=ae(t,19),r.numOfArrays=t[22],r.vps=[],r.sps=[],r.pps=[];for(var a=23,s=0,u=0,l=0,f=0;f<r.numOfArrays;f++){s=t[a]&63,u=ae(t,a+1),a+=3;for(var c=[],v=0;v<u;v++)l=ae(t,a),a+=2,c.push(t.subarray(a,a+l)),a+=l;if(s===32){var d;(d=r.vps).push.apply(d,c)}else if(s===33){var p;(p=r.sps).push.apply(p,c)}else if(s===34){var y;(y=r.pps).push.apply(y,c)}}})}},{key:"pasp",value:function(e){return W(e,!1,function(r,t){r.hSpacing=I(t),r.vSpacing=I(t,4)})}},{key:"mp4a",value:function(e){return W(e,!1,function(r,t,n){var a=an(r,t);r.esds=i.esds(i.findBox(t.subarray(a),["esds"],n+a)[0])})}},{key:"esds",value:function(e){return W(e,!0,function(r,t){r.codec="mp4a.";for(var n=0,a=0,s=0,u=0;t.length;){for(n=0,u=t[n],a=t[n+1],n+=2;a&128;)s=(a&127)<<7,a=t[n],n+=1;if(s+=a&127,u===3)t=t.subarray(n+3);else if(u===4)r.codec+=(t[n].toString(16)+".").padStart(3,"0"),t=t.subarray(n+13);else if(u===5){var l=r.config=t.subarray(n,n+s),f=(l[0]&248)>>3;f===31&&l.length>=2&&(f=32+((l[0]&7)<<3)+((l[1]&224)>>5)),r.objectType=f,r.codec+=f.toString(16),r.codec[r.codec.length-1]==="."&&(r.codec=r.codec.substring(0,r.codec.length-1));return}else{r.codec[r.codec.length-1]==="."&&(r.codec=r.codec.substring(0,r.codec.length-1));return}}})}},{key:"alaw",value:function(e){return W(e,!1,function(r,t){an(r,t)})}},{key:"stts",value:function(e){return W(e,!0,function(r,t){for(var n=I(t),a=[],s=4,u=0;u<n;u++)a.push({count:I(t,s),delta:I(t,s+4)}),s+=8;r.entryCount=n,r.entries=a})}},{key:"ctts",value:function(e){return W(e,!0,function(r,t){var n=I(t),a=[],s=4;if(r.version===1)for(var u=0;u<n;u++)a.push({count:I(t,s),offset:I(t,s+4)}),s+=8;else for(var l=0;l<n;l++)a.push({count:I(t,s),offset:-(~I(t,s+4)+1)}),s+=8;r.entryCount=n,r.entries=a})}},{key:"stsc",value:function(e){return W(e,!0,function(r,t){for(var n=I(t),a=[],s=4,u=0;u<n;u++)a.push({firstChunk:I(t,s),samplesPerChunk:I(t,s+4),sampleDescriptionIndex:I(t,s+8)}),s+=12;r.entryCount=n,r.entries=a})}},{key:"stsz",value:function(e){return W(e,!0,function(r,t){var n=I(t),a=I(t,4),s=[];if(!n)for(var u=8,l=0;l<a;l++)s.push(I(t,u)),u+=4;r.sampleSize=n,r.sampleCount=a,r.entrySizes=s})}},{key:"stco",value:function(e){return W(e,!0,function(r,t){for(var n=I(t),a=[],s=4,u=0;u<n;u++)a.push(I(t,s)),s+=4;r.entryCount=n,r.entries=a})}},{key:"co64",value:function(e){return W(e,!0,function(r,t){for(var n=I(t),a=[],s=4,u=0;u<n;u++)a.push(Ue(t,s)),s+=8;r.entryCount=n,r.entries=a})}},{key:"stss",value:function(e){return W(e,!0,function(r,t){for(var n=I(t),a=[],s=4,u=0;u<n;u++)a.push(I(t,s)),s+=4;r.entryCount=n,r.entries=a})}},{key:"moof",value:function(e){return W(e,!1,function(r,t,n){r.mfhd=i.mfhd(i.findBox(t,["mfhd"],n)[0]),r.traf=i.findBox(t,["traf"],n).map(function(a){return i.traf(a)})})}},{key:"mfhd",value:function(e){return W(e,!0,function(r,t){r.sequenceNumber=I(t)})}},{key:"traf",value:function(e){return W(e,!1,function(r,t,n){r.tfhd=i.tfhd(i.findBox(t,["tfhd"],n)[0]),r.tfdt=i.tfdt(i.findBox(t,["tfdt"],n)[0]),r.trun=i.trun(i.findBox(t,["trun"],n)[0])})}},{key:"trun",value:function(e){return W(e,!0,function(r,t){var n=r.version,a=r.flags,s=t.length,u=r.sampleCount=I(t),l=4;if(s>l&&a&1&&(r.dataOffset=-(~I(t,l)+1),l+=4),s>l&&a&4&&(r.firstSampleFlags=I(t,l),l+=4),r.samples=[],s>l)for(var f,c=0;c<u;c++)f={},a&256&&(f.duration=I(t,l),l+=4),a&512&&(f.size=I(t,l),l+=4),a&1024&&(f.flags=I(t,l),l+=4),a&2048&&(n?f.cts=-(~I(t,l+4)+1):f.cts=I(t,l),l+=4),r.samples.push(f)})}},{key:"tfdt",value:function(e){return W(e,!0,function(r,t){r.version===1?r.baseMediaDecodeTime=Ue(t):r.baseMediaDecodeTime=I(t)})}},{key:"probe",value:function(e){return!!i.findBox(e,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(e[0]&12)>>>2,dependsOn:e[0]&3,isDependedOn:(e[1]&192)>>>6,hasRedundancy:(e[1]&48)>>>4,paddingValue:(e[1]&14)>>>1,isNonSyncSample:e[1]&1,degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,r,t){var n,a,s=e.trak;if(!(!s||!s.length)){var u=s.find(function(Dt){var Ve,Ge;return((Ve=Dt.mdia)===null||Ve===void 0||(Ge=Ve.hdlr)===null||Ge===void 0?void 0:Ge.handlerType)==="vide"}),l=s.find(function(Dt){var Ve,Ge;return((Ve=Dt.mdia)===null||Ve===void 0||(Ge=Ve.hdlr)===null||Ge===void 0?void 0:Ge.handlerType)==="soun"});if(u&&r){var f,c,v,d,p,y,h,b=r,S=(f=u.tkhd)===null||f===void 0?void 0:f.trackId;S!=null&&(b.id=u.tkhd.trackId),b.tkhdDuration=u.tkhd.duration,b.mvhdDurtion=e.mvhd.duration,b.mvhdTimecale=e.mvhd.timescale,b.timescale=b.formatTimescale=u.mdia.mdhd.timescale,b.duration=u.mdia.mdhd.duration||b.mvhdDurtion/b.mvhdTimecale*b.timescale;var E=u.mdia.minf.stbl.stsd.entries[0];if(b.width=E.width,b.height=E.height,E.pasp&&(b.sarRatio=[E.pasp.hSpacing,E.pasp.vSpacing]),E.hvcC)b.codecType=Ie.HEVC,b.codec=E.hvcC.codec,b.vps=E.hvcC.vps,b.sps=E.hvcC.sps,b.pps=E.hvcC.pps,b.hvcC=E.hvcC.data;else if(E.avcC)b.codec=E.avcC.codec,b.sps=E.avcC.sps,b.pps=E.avcC.pps;else throw new Error("unknown video stsd entry");if(b.present=!0,b.ext={},b.ext.stss=(c=u.mdia)===null||c===void 0||(v=c.minf)===null||v===void 0||(d=v.stbl)===null||d===void 0?void 0:d.stss,b.ext.ctts=(p=u.mdia)===null||p===void 0||(y=p.minf)===null||y===void 0||(h=y.stbl)===null||h===void 0?void 0:h.ctts,E&&E.type==="encv"){var A,k,U,N,F,G,M,X;b.isVideoEncryption=!0,E.default_KID=(A=E.sinf)===null||A===void 0||(k=A.schi)===null||k===void 0?void 0:k.tenc.default_KID,E.default_IsEncrypted=(U=E.sinf)===null||U===void 0||(N=U.schi)===null||N===void 0?void 0:N.tenc.default_IsEncrypted,E.default_IV_size=(F=E.sinf)===null||F===void 0||(G=F.schi)===null||G===void 0?void 0:G.tenc.default_IV_size,b.videoSenc=u.mdia.minf.stbl.senc&&u.mdia.minf.stbl.senc.samples,E.data_format=(M=E.sinf)===null||M===void 0||(X=M.frma)===null||X===void 0?void 0:X.data_format,b.useEME=e.useEME,b.kidValue=e.kidValue,b.pssh=e.pssh,b.encv=E}}if(l&&t){var m,g,_,D,w,P,C,H,z,R=t,te=(m=l.tkhd)===null||m===void 0?void 0:m.trackId;te!=null&&(R.id=l.tkhd.trackId),R.tkhdDuration=l.tkhd.duration,R.mvhdDurtion=e.mvhd.duration,R.mvhdTimecale=e.mvhd.timescale,R.timescale=R.formatTimescale=l.mdia.mdhd.timescale,R.duration=l.mdia.mdhd.duration||R.mvhdDurtion/R.mvhdTimecale*R.timescale;var x=l.mdia.minf.stbl.stsd.entries[0];switch(R.sampleSize=x.sampleSize,R.sampleRate=x.sampleRate,R.channelCount=x.channelCount,R.present=!0,x.type){case"alaw":R.codecType=R.codec=Oe.G711PCMA,R.sampleRate=8e3;break;case"ulaw":R.codecType=R.codec=Oe.G711PCMU,R.sampleRate=8e3;break;default:R.sampleDuration=ke.getFrameDuration(R.sampleRate,R.timescale),R.sampleRateIndex=ke.getRateIndexByRate(R.sampleRate),R.objectType=((n=x.esds)===null||n===void 0?void 0:n.objectType)||2,x.esds&&(R.config=Array.from(x.esds.config)),R.codec=((a=x.esds)===null||a===void 0?void 0:a.codec)||"mp4a.40.2";break}if(R.sampleDuration=ke.getFrameDuration(R.sampleRate,R.timescale),R.objectType=((g=x.esds)===null||g===void 0?void 0:g.objectType)||2,x.esds&&(x.esds.config?R.config=Array.from(x.esds.config):console.warn("esds config is null")),R.codec=((_=x.esds)===null||_===void 0?void 0:_.codec)||"mp4a.40.2",R.sampleRateIndex=ke.getRateIndexByRate(R.sampleRate),R.ext={},R.ext.stss=(D=l.mdia)===null||D===void 0||(w=D.minf)===null||w===void 0||(P=w.stbl)===null||P===void 0?void 0:P.stss,R.ext.ctts=(C=l.mdia)===null||C===void 0||(H=C.minf)===null||H===void 0||(z=H.stbl)===null||z===void 0?void 0:z.ctts,R.present=!0,x&&x.type==="enca"){var Ne,we,Fe,Ye,ot,ue,wt,kt;R.isAudioEncryption=!0,x.data_format=(Ne=x.sinf)===null||Ne===void 0||(we=Ne.frma)===null||we===void 0?void 0:we.data_format,x.default_KID=(Fe=x.sinf)===null||Fe===void 0||(Ye=Fe.schi)===null||Ye===void 0?void 0:Ye.tenc.default_KID,x.default_IsEncrypted=(ot=x.sinf)===null||ot===void 0||(ue=ot.schi)===null||ue===void 0?void 0:ue.tenc.default_IsEncrypted,x.default_IV_size=(wt=x.sinf)===null||wt===void 0||(kt=wt.schi)===null||kt===void 0?void 0:kt.tenc.default_IV_size,R.audioSenc=l.mdia.minf.stbl.senc&&l.mdia.minf.stbl.senc.samples,R.useEME=e.useEME,R.kidValue=e.kidValue,R.enca=x}}if(t&&(t.isVideoEncryption=r?r.isVideoEncryption:!1),r&&(r.isAudioEncryption=t?t.isAudioEncryption:!1),r!=null&&r.encv||t!=null&&t.enca){var Tt,At,sr=r==null||(Tt=r.encv)===null||Tt===void 0?void 0:Tt.default_KID,or=t==null||(At=t.enca)===null||At===void 0?void 0:At.default_KID,ur=sr||or?(sr||or).join(""):null;r&&(r.kid=ur),t&&(t.kid=ur)}return r&&(r.flags=3841),t&&(t.flags=1793),{videoTrack:r,audioTrack:t}}}},{key:"evaluateDefaultDuration",value:function(e,r,t){var n,a=r==null||(n=r.samples)===null||n===void 0?void 0:n.length;if(!a)return 1024;var s=1024*a/r.timescale;return s*e.timescale/t}},{key:"moofToSamples",value:function(e,r,t){var n={};return e.mfhd&&(r&&(r.sequenceNumber=e.mfhd.sequenceNumber),t&&(t.sequenceNumber=e.mfhd.sequenceNumber)),e.traf.forEach(function(a){var s=a.tfhd,u=a.tfdt,l=a.trun;if(!(!s||!l)){u&&(r&&r.id===s.trackId&&(r.baseMediaDecodeTime=u.baseMediaDecodeTime),t&&t.id===s.trackId&&(t.baseMediaDecodeTime=u.baseMediaDecodeTime));var f=s.defaultSampleSize||0,c=s.defaultSampleDuration||i.evaluateDefaultDuration(r,t,l.samples.length||l.sampleCount),v=l.dataOffset||0,d=0,p=-1;if(!l.samples.length&&l.sampleCount){n[s.trackId]=[];for(var y=0;y<l.sampleCount;y++)n[s.trackId].push({offset:v,dts:d,duration:c,size:f}),d+=c,v+=f}else n[s.trackId]=l.samples.map(function(h,b){return h={offset:v,dts:d,pts:d+(h.cts||0),duration:h.duration||c,size:h.size||f,gopId:p,keyframe:b===0||h.flags!==null&&h.flags!==void 0&&(h.flags&65536)>>>0!==65536},h.keyframe&&(p++,h.gopId=p),d+=h.duration,v+=h.size,h})}}),n}},{key:"moovToSamples",value:function(e){var r=e.trak;if(!(!r||!r.length)){var t=r.find(function(M){var X,m;return((X=M.mdia)===null||X===void 0||(m=X.hdlr)===null||m===void 0?void 0:m.handlerType)==="vide"}),n=r.find(function(M){var X,m;return((X=M.mdia)===null||X===void 0||(m=X.hdlr)===null||m===void 0?void 0:m.handlerType)==="soun"});if(!(!t&&!n)){var a,s;if(t){var u,l,f=(u=t.mdia)===null||u===void 0||(l=u.minf)===null||l===void 0?void 0:l.stbl;if(!f)return;var c=f.stts,v=f.stsc,d=f.stsz,p=f.stco,y=f.stss,h=f.ctts;if(!c||!v||!d||!p||!y)return;a=rn(c,v,d,p,h,y)}if(n){var b,S,E,A=(b=n.mdia)===null||b===void 0||(S=b.minf)===null||S===void 0?void 0:S.stbl;if(!A)return;var k=(E=n.mdia.mdhd)===null||E===void 0?void 0:E.timescale,U=A.stts,N=A.stsc,F=A.stsz,G=A.stco;if(!k||!U||!N||!F||!G)return;s=rn(U,N,F,G)}return{videoSamples:a,audioSamples:s}}}}}]),i}();function rn(i,o,e,r,t,n){var a=[],s=t?.entries,u=o.entries,l=r.entries,f=e.entrySizes,c=n?.entries,v;c&&(v={},c.forEach(function(N){v[N-1]=!0}));var d;s&&(d=[],s.forEach(function(N){for(var F=N.count,G=N.offset,M=0;M<F;M++)d.push(G)}));var p,y=-1,h=0,b=0,S=0,E=0,A=0,k=u[0].samplesPerChunk,U=u[1]?u[1].firstChunk-1:1/0;return i.entries.forEach(function(N){for(var F=N.count,G=N.delta,M=0;M<F;M++)p={dts:h,duration:G,size:f[b]||e.sampleSize,offset:l[S]+A,index:b},c&&(p.keyframe=v[b],p.keyframe&&y++,p.gopId=y),d&&b<d.length&&(p.pts=p.dts+d[b]),a.push(p),h+=G,b++,b<k?A+=p.size:(S++,A=0,S>=U&&(E++,U=u[E+1]?u[E+1].firstChunk-1:1/0),k+=u[E].samplesPerChunk)}),a}function nn(i,o){return i.dataReferenceIndex=ae(o,6),i.width=ae(o,24),i.height=ae(o,26),i.horizresolution=I(o,28),i.vertresolution=I(o,32),i.frameCount=ae(o,40),i.depth=ae(o,74),78}function an(i,o){return i.dataReferenceIndex=ae(o,6),i.channelCount=ae(o,16),i.sampleSize=ae(o,18),i.sampleRate=I(o,24)/65536,28}function W(i,o,e){if(i){if(i.size!==i.data.length)throw new Error("box ".concat(i.type," size !== data.length"));var r={start:i.start,size:i.size,headerSize:i.headerSize,type:i.type};return o&&(r.version=i.data[i.headerSize],r.flags=pi(i.data,i.headerSize+1),r.headerSize+=4),e(r,i.data.subarray(r.headerSize),r.start+r.headerSize),r}}var bi=function(o,e,r){for(var t=String(r),n=e>>0,a=Math.ceil(n/t.length),s=[],u=String(o);a--;)s.push(t);return s.join("").substring(0,n-u.length)+u},qt=function(){for(var o=[],e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.forEach(function(n){o.push(bi(Number(n).toString(16),2,0))}),o[0]},Si=function(){function i(o,e,r){ne(this,i),this.videoTrack=o||new Nt,this.audioTrack=e||new Ft,this.metadataTrack=r||new Gt}return ie(i,[{key:"demux",value:function(e,r){var t=this.videoTrack,n=this.audioTrack,a=t.exist(),s=n.exist();if(t.samples=[],n.samples=[],r){if(!s){var u=ce.findBox(r,["moov"])[0];if(!u)throw new Error("cannot found moov box");ce.moovToTrack(ce.moov(u),null,n)}var l=ce.findBox(r,["moof"])[0];if(l){var f=ce.moofToSamples(ce.moof(l),null,n)[n.id],c=n.baseMediaDecodeTime;if(f){var v=l.start;f.map(function(A){A.offset+=v;var k=r.subarray(A.offset,A.offset+A.size);n.samples.push(new $e(A.dts+c,k,A.duration))})}}}if(e){if(!a&&!s){var d=ce.findBox(e,["moov"])[0];if(!d)throw new Error("cannot found moov box");ce.moovToTrack(ce.moov(d),t,n)}var p=ce.findBox(e,["moof"])[0];if(p){var y=ce.moofToSamples(ce.moof(p),t,n),h=t.baseMediaDecodeTime,b=n.baseMediaDecodeTime,S=p.start,E;Object.keys(y).forEach(function(A){t.id==A?y[A].map(function(k){k.offset+=S;var U=new Vt((k.pts||k.dts)+h,k.dts+h);U.duration=k.duration,U.gopId=k.gopId,k.keyframe&&U.setToKeyframe();var N=e.subarray(k.offset,k.offset+k.size);U.data=N;for(var F=0,G=N.length-1;F<G;)E=I(N,F),F+=4,U.units.push(N.subarray(F,F+E)),F+=E;t.samples.push(U)}):n.id==A&&y[A].map(function(k){k.offset+=S;var U=e.subarray(k.offset,k.offset+k.size);n.samples.push(new $e(k.dts+b,U,k.duration))})})}}return{videoTrack:t,audioTrack:n,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}}],[{key:"probe",value:function(e){return ce.probe(e)}}]),i}();function Ei(i){for(var o=0,e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++)r[t-1]=arguments[t];r.forEach(function(s){o+=s.length});var n=new i(o),a=0;return r.forEach(function(s){n.set(s,a),a+=s.length}),n}var me=function(){function i(){ne(this,i),this.buffer=new Uint8Array(0)}return ie(i,[{key:"write",value:function(){for(var e=this,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];t.forEach(function(a){a?e.buffer=Ei(Uint8Array,e.buffer,a):window.console.warn(a)})}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,e&255])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,e&255])}}]),i}(),sn=Math.pow(2,32)-1,K=function(){function i(){ne(this,i)}return ie(i,null,[{key:"box",value:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];t=t.filter(Boolean);var a=8+t.reduce(function(l,f){return l+f.byteLength},0),s=new Uint8Array(a);s[0]=a>>24&255,s[1]=a>>16&255,s[2]=a>>8&255,s[3]=a&255,s.set(e,4);var u=8;return t.forEach(function(l){s.set(l,u),u+=l.byteLength}),s}},{key:"ftyp",value:function(e){var r=e.find(function(t){return t.type===Je.VIDEO&&t.codecType===Ie.HEVC});return r?i.FTYPHEV1:i.FTYPAVC1}},{key:"initSegment",value:function(e){var r=i.ftyp(e),t=Ee(r,i.moov(e));return t}},{key:"pssh",value:function(e){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],qr(e.kid),[0,0,0,0]));return i.box(i.types.pssh,r)}},{key:"moov",value:function(e){if(e[0].useEME&&(e[0].encv||e[0].enca)){e[0].pssh||(e[0].pssh={kid:e[0].kid});var r=this.pssh(e[0].pssh);return i.box.apply(i,[i.types.moov,i.mvhd(e[0].mvhdDurtion||e[0].duration,e[0].mvhdTimecale||e[0].timescale),i.mvex(e)].concat(Se(e.map(function(t){return i.trak(t)})),[r]))}else return i.box.apply(i,[i.types.moov,i.mvhd(e[0].mvhdDurtion||e[0].duration,e[0].mvhdTimecale||e[0].timescale)].concat(Se(e.map(function(t){return i.trak(t)})),[i.mvex(e)]))}},{key:"mvhd",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,t=i.box(i.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255,e>>24&255,e>>16&255,e>>8&255,e&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 t}},{key:"trak",value:function(e){var r=i.box(i.types.trak,i.tkhd(e.id,e.tkhdDuration||0,e.width,e.height),i.mdia(e));return r}},{key:"tkhd",value:function(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=i.box(i.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,t>>8&255,t&255,0,0,n>>8&255,n&255,0,0]));return a}},{key:"mdia",value:function(e){var r=i.box(i.types.mdia,i.mdhd(e.duration,e.timescale),i.hdlr(e.type),i.minf(e));return r}},{key:"mdhd",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,t=i.box(i.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255,e>>24&255,e>>16&255,e>>8&255,e&255,85,196,0,0]));return t}},{key:"hdlr",value:function(e){var r=i.box(i.types.hdlr,i.HDLR_TYPES[e]);return r}},{key:"minf",value:function(e){var r=i.box(i.types.minf,e.type===Je.VIDEO?i.VMHD:i.SMHD,i.DINF,i.stbl(e));return r}},{key:"stbl",value:function(e){var r=[];e&&e.ext&&e.ext.stss&&r.push(i.stss(e.ext.stss.entries));var t=i.box(i.types.stbl,i.stsd(e),i.STTS,r[0],i.STSC,i.STSZ,i.STCO);return t}},{key:"stsd",value:function(e){var r;e.type==="audio"?e.useEME&&e.enca?r=i.enca(e):r=i.mp4a(e):e.useEME&&e.encv?r=i.encv(e):r=i.avc1hev1(e);var t=i.box(i.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r);return t}},{key:"enca",value:function(e){var r=e.enca.channelCount,t=e.enca.sampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,t>>8&255,t&255,0,0]),a=i.esds(e.config),s=i.sinf(e.enca);return i.box(i.types.enca,n,a,s)}},{key:"encv",value:function(e){var r,t,n=e.sps.length>0?e.sps[0]:[],a=e.pps.length>0?e.pps[0]:[],s=e.width,u=e.height,l=e.sarRatio[0],f=e.sarRatio[1],c=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,s>>8&255,s&255,u>>8&255,u&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]),v=new Uint8Array((r=(t=[1,n[1],n[2],n[3],255,225,n.length>>>8&255,n.length&255]).concat.apply(t,Se(n)).concat([1,a.length>>>8&255,a.length&255])).concat.apply(r,Se(a))),d=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),p=i.sinf(e.encv),y=new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,f>>24,f>>16&255,f>>8&255,f&255]);return i.box(i.types.encv,c,i.box(i.types.avcC,v),i.box(i.types.btrt,d),p,i.box(i.types.pasp,y))}},{key:"schi",value:function(e){var r=new Uint8Array([]),t=i.tenc(e);return i.box(i.types.schi,r,t)}},{key:"tenc",value:function(e){var r=new Uint8Array([0,0,0,0,0,0,e.default_IsEncrypted&255,e.default_IV_size&255].concat(qr(e.default_KID)));return i.box(i.types.tenc,r)}},{key:"sinf",value:function(e){var r=new Uint8Array([]),t=new Uint8Array([e.data_format.charCodeAt(0),e.data_format.charCodeAt(1),e.data_format.charCodeAt(2),e.data_format.charCodeAt(3)]),n=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=i.schi(e);return i.box(i.types.sinf,r,i.box(i.types.frma,t),i.box(i.types.schm,n),a)}},{key:"avc1hev1",value:function(e){var r=e.codecType===Ie.HEVC,t=r?i.types.hvc1:i.types.avc1,n=r?i.hvcC(e):i.avcC(e),a=[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,e.width>>8&255,e.width&255,e.height>>8&255,e.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),n];return r?a.push(i.box(i.types.fiel,new Uint8Array([1,0]))):e.sarRatio&&e.sarRatio.length>1&&a.push(i.pasp(e.sarRatio)),i.box.apply(i,[t].concat(a))}},{key:"avcC",value:function(e){var r,t,n=[],a=[],s;return e.sps.forEach(function(u){s=u.byteLength,n.push(s>>>8&255),n.push(s&255),n.push.apply(n,Se(u))}),e.pps.forEach(function(u){s=u.byteLength,a.push(s>>>8&255),a.push(s&255),a.push.apply(a,Se(u))}),i.box(i.types.avcC,new Uint8Array((r=(t=[1,n[3],n[4],n[5],255,224|e.sps.length]).concat.apply(t,n).concat([e.pps.length])).concat.apply(r,a)))}},{key:"hvcC",value:function(e){var r=e.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var t=e.vps,n=e.sps,a=e.pps,s;if(r){var u=r.generalProfileCompatibilityFlags,l=r.generalConstraintIndicatorFlags,f=(t.length&&1)+(n.length&&1)+(a.length&&1);s=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,l[0],l[1],l[2],l[3],l[4],l[5],r.generalLevelIdc,240,0,252,r.chromaFormatIdc|252,r.bitDepthLumaMinus8|248,r.bitDepthChromaMinus8|248,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,f];var c=function(d){var p;s.push(d.length>>8,d.length),(p=s).push.apply(p,Se(d))};t.length&&(s.push(160,0,t.length),t.forEach(c)),n.length&&(s.push(161,0,n.length),n.forEach(c)),a.length&&(s.push(162,0,a.length),a.forEach(c))}else s=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return i.box(i.types.hvcC,new Uint8Array(s))}},{key:"pasp",value:function(e){var r=ei(e,2),t=r[0],n=r[1];return i.box(i.types.pasp,new Uint8Array([t>>24,t>>16&255,t>>8&255,t&255,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"mp4a",value:function(e){return i.box(i.types.mp4a,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,e.sampleRate>>8&255,e.sampleRate&255,0,0]),e.config.length?i.esds(e.config):void 0)}},{key:"esds",value:function(e){var r=e.length,t=i.box(i.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(e).concat([6,1,2])));return t}},{key:"mvex",value:function(e){var r=i.box.apply(i,[i.types.mvex].concat(Se(e.map(function(t){return i.trex(t.id)}))));return r}},{key:"trex",value:function(e){var r=i.box(i.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return r}},{key:"trex1",value:function(e){var r=i.box(i.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return r}},{key:"trex2",value:function(e){var r=i.box(i.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return r}},{key:"moof",value:function(e){var r=i.box.apply(i,[i.types.moof,i.mfhd(e[0].samples?e[0].samples[0].gopId:0)].concat(Se(e.map(function(t){return i.traf(t)}))));return r}},{key:"mfhd",value:function(e){var r=i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]));return r}},{key:"traf",value:function(e){var r=i.tfhd(e.id),t=i.tfdt(e,e.baseMediaDecodeTime),n=0,a;if(e.isVideo&&e.videoSenc&&(a=e.videoSenc,a.forEach(function(g){n=n+8,g.subsamples&&g.subsamples.length&&(n=n+2,n=n+g.subsamples.length*6)})),e.videoSencLength=n,!e.useEME||!e.isVideoEncryption&&!e.isAudioEncryption){var s=i.sdtp(e),u=76;return i.box(i.types.traf,r,t,s,i.trun(e.samples,s.byteLength+u))}else if(e.isVideoEncryption)if(e.isVideo){var l=i.saiz(e),f=i.saio(e),c=i.trun1(e),v=i.senc(e),d=i.box(i.types.traf,r,t,l,f,c,v);return d}else if(e.isAudioEncryption){var h=i.sbgp(),b=i.saiz(e),S=i.saio(e),E=i.senc(e),A=i.trun1(e),k=i.box(i.types.traf,r,t,h,b,S,E,A);return k}else{var p=i.sbgp(),y=i.trun1(e);return i.box(i.types.traf,r,t,p,y)}else if(e.isVideo){var U=i.trun1(e);return i.box(i.types.traf,r,t,U)}else{var N=i.sbgp(),F=i.saiz(e),G=i.saio(e),M=i.senc(e),X=i.trun1(e),m=i.box(i.types.traf,r,t,N,F,G,M,X);return m}}},{key:"sdtp",value:function(e){var r=new me;return e.samples.forEach(function(t){r.write(new Uint8Array(e.isVideo?[t.keyframe?32:16]:[16]))}),i.box(i.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(e){var r=new me,t=me.writeUint32(e.samples.length),n=null;if(e.isVideo){var a=e.videoSencLength;n=me.writeUint32(e.samples.length*16+a+149),!e.isVideoEncryption&&e.isAudioEncryption&&(n=me.writeUint32(e.samples.length*16+92))}else{var s=e.samples.length*12+124;e.isAudioEncryption&&(s=e.samples.length*12+8*e.audioSenc.length+177),n=me.writeUint32(s)}return e.samples.forEach(function(u){r.write(me.writeUint32(u.duration)),r.write(me.writeUint32(u.size)),r.write(me.writeUint32(u.keyframe?33554432:65536)),e.isVideo&&r.write(me.writeUint32(u.cts?u.cts:0))}),i.box(i.types.trun,this.extension(0,e.flags),t,n,r.buffer)}},{key:"senc",value:function(e){var r=new me,t=e.samples.length,n=e.isVideo?16:8,a=e.isVideo?2:0,s=[],u=0;return e.isVideo?(s=e.videoSenc,u=e.videoSencLength):s=e.audioSenc,u=u||n*t,r.write(me.writeUint32(16+u),i.types.senc,this.extension(0,a)),r.write(me.writeUint32(t)),s.forEach(function(l){for(var f=0;f<l.InitializationVector.length;f++)r.write(new Uint8Array([l.InitializationVector[f]]));l.subsamples&&l.subsamples.length&&(r.write(me.writeUint16(l.subsamples.length)),l.subsamples.forEach(function(c){r.write(me.writeUint16(c.BytesOfClearData)),r.write(me.writeUint32(c.BytesOfProtectedData))}))}),r.buffer}},{key:"saio",value:function(e){var r=e.samples.length*12+141;!e.isVideo&&e.isAudioEncryption&&(r=149);var t=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255]);return i.box(i.types.saio,t)}},{key:"saiz",value:function(e){var r=e.samples.length,t=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,r&255]);return i.box(i.types.saiz,t)}},{key:"sbgp",value:function(){var e=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return i.box(i.types.sbgp,this.extension(0,0),e)}},{key:"extension",value:function(e,r){return new Uint8Array([e,r>>16&255,r>>8&255,r&255])}},{key:"tfhd",value:function(e){return i.box(i.types.tfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}},{key:"tfdt",value:function(e,r){var t=Math.floor(r/(sn+1)),n=Math.floor(r%(sn+1));return e.useEME&&(e.isVideoEncryption||e.isAudioEncryption)?i.box(i.types.tfdt,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])):i.box(i.types.tfdt,new Uint8Array([1,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,n>>24,n>>16&255,n>>8&255,n&255]))}},{key:"trun",value:function(e,r){var t=e.length,n=12+16*t;r+=8+n;var a=new Uint8Array(n);a.set([0,0,15,1,t>>>24&255,t>>>16&255,t>>>8&255,t&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255],0);for(var s=0;s<t;s++){var u=e[s],l=u.duration,f=u.size,c=u.flag,v=c===void 0?{}:c,d=u.cts,p=d===void 0?0:d;a.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,v.isLeading<<2|(v.dependsOn===null||v.dependsOn===void 0?1:v.dependsOn),v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|(v.isNonSyncSample===null||v.isNonSyncSample===void 0?1:v.isNonSyncSample),v.degradationPriority&61440,v.degradationPriority&15,p>>>24&255,p>>>16&255,p>>>8&255,p&255],12+16*s)}return i.box(i.types.trun,a)}},{key:"moovMP4",value:function(e){return i.box.apply(i,[i.types.moov,i.mvhd(e[0].duration,e[0].timescale)].concat(Se(e.map(function(r){return i.trackMP4(r)}))))}},{key:"trackMP4",value:function(e){return i.box(i.types.trak,i.tkhd(e.id,e.duration,e.width,e.height),i.mdiaMP4(e))}},{key:"mdiaMP4",value:function(e){return i.box(i.types.mdia,i.mdhd(e.duration,e.timescale),i.hdlr(e.type),i.minfMP4(e))}},{key:"minfMP4",value:function(e){return i.box(i.types.minf,e.type===Je.VIDEO?i.VMHD:i.SMHD,i.DINF,i.stblMP4(e))}},{key:"stblMP4",value:function(e){var r=e.ext,t=[i.stsd(e),i.stts(r.stts),i.stsc(r.stsc),i.stsz(r.stsz),i.stco(r.stco)];return r.stss.length&&t.push(i.stss(r.stss)),r.ctts.length&&t.push(i.ctts(r.ctts)),i.box.apply(i,[i.types.stbl].concat(t))}},{key:"stts",value:function(e){var r=e.length,t=new Uint8Array(8*r),n=0;return e.forEach(function(a){var s=a.value,u=a.count;t.set([u>>24,u>>16&255,u>>8&255,u&255,s>>24,s>>16&255,s>>8&255,s&255],n),n+=8}),i.box(i.types.stts,Ee(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"stsc",value:function(e){var r=e.length,t=new Uint8Array(12*r),n=0;return e.forEach(function(a){var s=a.firstChunk,u=a.samplesPerChunk,l=a.sampleDescIndex;t.set([s>>24,s>>16&255,s>>8&255,s&255,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&255],n),n+=12}),i.box(i.types.stsc,Ee(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"stsz",value:function(e){var r=e.length,t=new Uint8Array(4*r),n=0;return e.forEach(function(a){t.set([a>>24,a>>16&255,a>>8&255,a&255],n),n+=4}),i.box(i.types.stsz,Ee(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"stco",value:function(e){var r=e.length,t=new Uint8Array(4*r),n=0;return e.forEach(function(a){t.set([a>>24,a>>16&255,a>>8&255,a&255],n),n+=4}),i.box(i.types.stco,Ee(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"stss",value:function(e){var r=e.length,t=new Uint8Array(4*r),n=0;return e.forEach(function(a){t.set([a>>24,a>>16&255,a>>8&255,a&255],n),n+=4}),i.box(i.types.stss,Ee(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"ctts",value:function(e){var r=e.length,t=new Uint8Array(8*r),n=0;return e.forEach(function(a){var s=a.value,u=a.count;t.set([u>>24,u>>16&255,u>>8&255,u&255,s>>24,s>>16&255,s>>8&255,s&255],n),n+=8}),i.box(i.types.ctts,Ee(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]),t))}},{key:"styp",value:function(){return i.box(i.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(e){var r=e.timescale,t=e.samples[0].duration,n=t*e.samples.length,a=e.samples[0].sampleOffset*t,s=8;e.samples.forEach(function(v){s+=v.size});var u=0;if(e.isVideo){var l=0,f;e.videoSenc&&(f=e.videoSenc),e.isVideo&&f.forEach(function(v){l=l+8,v.subsamples&&v.subsamples.length&&(l=l+2,l=l+v.subsamples.length*6)}),e.videoSencLength=l,u=s+141+e.samples.length*16+l,e.useEME&&e.isAudioEncryption&&!e.isVideoEncryption&&(u=s+e.samples.length*16+84)}else u=s+116+e.samples.length*12,e.useEME&&e.isAudioEncryption&&(u=s+169+e.samples.length*12+8*e.audioSenc.length);var c=new Uint8Array([0,0,0,0,0,0,0,e.id&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,0,0,0,0,0,0,0,1,0,u>>16&255,u>>8&255,u&255,n>>24&255,n>>16&255,n>>8&255,n&255,144,0,0,0]);return i.box(i.types.sidx,c)}},{key:"mdat",value:function(e){var r=i.box(i.types.mdat,e);return r}}]),i}();O(K,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(i,o){return i[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)],i},Object.create(null))),O(K,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),O(K,"FTYPAVC1",K.box(K.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),O(K,"FTYPHEV1",K.box(K.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),O(K,"DINF",K.box(K.types.dinf,K.box(K.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),O(K,"VMHD",K.box(K.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),O(K,"SMHD",K.box(K.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),O(K,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),O(K,"STTS",K.box(K.types.stts,K.StblTable)),O(K,"STSC",K.box(K.types.stsc,K.StblTable)),O(K,"STSZ",K.box(K.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),O(K,"STCO",K.box(K.types.stco,K.StblTable));var on=function(){function i(o,e){ne(this,i),this.name=o||"",this._prefix="[".concat(this.name,"]"),i.disabled=e}return ie(i,[{key:"debug",value:function(){var e;if(!i.disabled){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];(e=console).debug.apply(e,[this._prefix].concat(t))}}},{key:"log",value:function(){var e;if(!i.disabled){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];(e=console).log.apply(e,[this._prefix].concat(t))}}},{key:"warn",value:function(){var e;if(!i.disabled){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];(e=console).warn.apply(e,[this._prefix].concat(t))}}},{key:"error",value:function(){var e;if(!i.disabled){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];(e=console).error.apply(e,[this._prefix].concat(t))}}},{key:"table",value:function(){var e;i.disabled||(console.group(this._prefix),(e=console).table.apply(e,arguments),console.groupEnd())}}],[{key:"enable",value:function(){i.disabled=!1}},{key:"disable",value:function(){i.disabled=!0}}]),i}();O(on,"disabled",!0);var un=function(){function i(o,e,r){ne(this,i),this.videoTrack=o,this.audioTrack=e;var t=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=t&&Number(t[1])<50,this.log=new on("FMP4Remuxer",r&&r.openLog?!r.openLog:!0)}return ie(i,[{key:"remux",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=this.videoTrack,n=this.audioTrack,a=t.exist(),s=n.exist(),u,l,f,c=[];e&&(r&&r.initMerge?(a&&c.push(this.videoTrack),s&&c.push(this.audioTrack),f=K.initSegment(c)):(a&&(u=K.initSegment([this.videoTrack])),s&&(l=K.initSegment([this.audioTrack]))));var v,d;return a&&t.hasSample()&&(v=this._remuxVideo()),s&&n.hasSample()&&(d=this._remuxAudio()),t.samples=[],n.samples=[],{initSegment:f,videoInitSegment:u,audioInitSegment:l,videoSegment:v,audioSegment:d}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var r=e.samples,t=0;r.forEach(function(p){t+=p.units.reduce(function(y,h){return y+h.byteLength},0),t+=p.units.length*4});for(var n=new Uint8Array(t),a=new DataView(n.buffer),s=function(y,h){h=r[u];var b=0;h.units.forEach(function(S){a.setUint32(y,S.byteLength),y+=4,n.set(S,y),y+=S.byteLength,b+=4+S.byteLength}),h.size=b,f=y,c=h},u=0,l=r.length,f=0,c;u<l;u++)s(f,c);var v=K.mdat(n),d=K.moof([e]);return Ee(d,v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,r=new Uint8Array(e.samples.reduce(function(a,s){return a+s.size},0));e.samples.reduce(function(a,s){return r.set(s.data,a),a+s.size},0);var t=K.mdat(r),n=K.moof([e]);return Ee(n,t)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),i}(),Me=new be("BufferService"),wi=function(){function i(o,e,r){cr(this,i),$(this,"flv",null),$(this,"_demuxer",new Zr),$(this,"_remuxer",null),$(this,"_mse",null),$(this,"_softVideo",null),$(this,"_sourceCreated",!1),$(this,"_needInitSegment",!0),$(this,"_discontinuity",!0),$(this,"_contiguous",!1),$(this,"_initSegmentId",""),$(this,"_cachedBuffer",null),$(this,"_demuxStartTime",0),$(this,"_opts",null),this.flv=o,this._opts=r,e?this._softVideo=e:(this._remuxer=new un(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new pe(null,{preferMMS:typeof r.preferMMS=="boolean"?r.preferMMS:!!r.perferMMS}),this._mse.bindMedia(o.media))}return dr(i,[{key:"baseDts",get:function(){var e,r;return(e=this._demuxer)===null||e===void 0||(r=e._fixer)===null||r===void 0?void 0:r._baseDts}},{key:"blobUrl",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pe.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:function(){var o=ve(Q().mark(function r(){var t,n=arguments;return Q().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=n.length>0&&n[0]!==void 0?n[0]:!1,!(this._mse&&!t)){s.next=6;break}return s.next=4,this._mse.unbindMedia();case 4:return s.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="";case 11:case"end":return s.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"endOfStream",value:function(){var o=ve(Q().mark(function r(){return Q().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=7;break}if(!this._sourceCreated){n.next=5;break}return n.next=4,this._mse.endOfStream();case 4:this.flv.emit(V.BUFFEREOS);case 5:n.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"updateDuration",value:function(){var o=ve(Q().mark(function r(t){return Q().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._mse){a.next=7;break}if(this._mse.isOpened){a.next=4;break}return a.next=4,this._mse.open();case 4:return Me.debug("update duration",t),a.next=7,this._mse.updateDuration(t);case 7:case"end":return a.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var o=ve(Q().mark(function r(){return Q().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=3;break}return n.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"appendBuffer",value:function(){var o=ve(Q().mark(function r(t){var n,a,s,u,l,f,c,v,d,p,y,h,b,S;return Q().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(this._cachedBuffer&&(t=st(this._cachedBuffer,t),this._cachedBuffer=null),n=this._demuxer,!(!t||!t.length||!n)){A.next=4;break}return A.abrupt("return");case 4:A.prev=4,n.demuxAndFix(t,this._discontinuity,this._contiguous,this._demuxStartTime),A.next=11;break;case 8:throw A.prev=8,A.t0=A.catch(4),new re(Y.DEMUX,Y.SUB_TYPES.FLV,A.t0);case 11:if(a=n.videoTrack,s=n.audioTrack,u=n.metadataTrack,l=a.exist(),f=s.exist(),this._opts.onlyAudio&&(l=!1,a.present=!1),this._opts.onlyVideo&&(f=!1,s.present=!1),!(!l&&a.present||!f&&s.present)){A.next=29;break}if(c=0,v=l?a:f?s:void 0,v&&v.samples.length&&(c=(v.samples[v.samples.length-1].originPts-v.samples[0].originPts)/v.timescale*1e3),!(c>this._opts.analyzeDuration)){A.next=27;break}Me.warn("analyze duration exceeded, ".concat(c,"ms"),v),a.present=l,s.present=f,this.flv.emit(V.ANALYZE_DURATION_EXCEEDED,{duration:c}),A.next=29;break;case 27:return this._cachedBuffer=t,A.abrupt("return");case 29:if(d=a.type,p=s.type,this._fireEvents(a,s,u),this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0,y=this._mse,this.flv.emit(V.DEMUXED_TRACK,{videoTrack:a}),h="".concat(a.codec,"/").concat(a.width,"/").concat(a.height,"/").concat(s.codec,"/").concat(s.config),h!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=h,this._emitMetaParsedEvent(a,s)),!y){A.next=65;break}if(this._sourceCreated){A.next=47;break}return A.next=43,y.open();case 43:l&&(Me.log("codec: video/mp4;codecs=".concat(a.codec)),y.createSource(d,"video/mp4;codecs=".concat(a.codec))),f&&(Me.log("codec: audio/mp4;codecs=".concat(s.codec)),y.createSource(p,"audio/mp4;codecs=".concat(s.codec))),this._sourceCreated=!0,this.flv.emit(V.SOURCEBUFFER_CREATED);case 47:A.prev=47,b=this._remuxer.remux(this._needInitSegment),A.next=54;break;case 51:throw A.prev=51,A.t1=A.catch(47),new re(Y.REMUX,Y.SUB_TYPES.FMP4,A.t1);case 54:if(!(this._needInitSegment&&!b.videoInitSegment&&!b.audioInitSegment)){A.next=56;break}return A.abrupt("return");case 56:return this._needInitSegment=!1,S=[],b.videoInitSegment&&S.push(y.append(d,b.videoInitSegment)),b.audioInitSegment&&S.push(y.append(p,b.audioInitSegment)),b.videoSegment&&S.push(y.append(d,b.videoSegment)),b.audioSegment&&S.push(y.append(p,b.audioSegment)),A.abrupt("return",Promise.all(S));case 65:this._softVideo&&this._softVideo.appendBuffer(a,s);case 66:case"end":return A.stop()}},r,this,[[4,8],[47,51]])}));function e(r){return o.apply(this,arguments)}return e}()},{key:"evictBuffer",value:function(){var o=ve(Q().mark(function r(t){var n=this,a,s,u,l;return Q().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(a=this.flv.media,!(!this._mse||!this._demuxer||!a||!t||t<0)){c.next=3;break}return c.abrupt("return");case 3:if(s=a.currentTime,u=s-t,!(u<=0)){c.next=7;break}return c.abrupt("return");case 7:if(l=oe.start(oe.get(a)),!(l+1>=u)){c.next=10;break}return c.abrupt("return");case 10:return c.abrupt("return",this._mse.clearBuffer(0,u).then(function(){return n.flv.emit(V.REMOVE_BUFFER,{removeEnd:u})}));case 11:case"end":return c.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"_emitMetaParsedEvent",value:function(e,r){e.exist()&&this.flv.emit(V.METADATA_PARSED,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),r.exist()&&this.flv.emit(V.METADATA_PARSED,{type:"audio",track:r,meta:{codec:r.codec,channelCount:r.channelCount,sampleRate:r.sampleRate,timescale:r.timescale,baseDts:r.baseDts}}),Me.debug("track parsed",e,r)}},{key:"_fireEvents",value:function(e,r,t){var n=this;Me.debug(e.samples,r.samples),t.flvScriptSamples.forEach(function(a){n.flv.emit(V.FLV_SCRIPT_DATA,a),Me.debug("flvScriptData",a)}),e.samples.forEach(function(a){a.keyframe&&n.flv.emit(V.KEYFRAME,{pts:a.pts})}),e.warnings.forEach(function(a){var s;switch(a.type){case se.LARGE_AV_SHIFT:s=V.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case se.LARGE_VIDEO_GAP:s=V.LARGE_VIDEO_DTS_GAP_DETECT;break;case se.LARGE_VIDEO_GAP_BETWEEN_CHUNK:s=V.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}s&&n.flv.emit(V.STREAM_EXCEPTION,Pe(Pe({},a),{},{type:s})),Me.warn("video exception",a)}),r.warnings.forEach(function(a){var s;switch(a.type){case se.LARGE_AUDIO_GAP:s=V.LARGE_AUDIO_DTS_GAP_DETECT;break;case se.AUDIO_FILLED:s=V.AUDIO_GAP_DETECT;break;case se.AUDIO_DROPPED:s=V.AUDIO_OVERLAP_DETECT;break}s&&n.flv.emit(V.STREAM_EXCEPTION,Pe(Pe({},a),{},{type:s})),Me.warn("audio exception",a)}),t.seiSamples.forEach(function(a){n.flv.emit(V.SEI,Pe(Pe({},a),{},{sei:{code:a.data.type,content:a.data.payload,dts:a.pts}}))})}}]),i}();function ki(i){var o=Pe({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1},i);return o.isLive&&o.preloadTime&&(o.maxLatency||(o.maxLatency=o.preloadTime*2),o.targetLatency||(o.targetLatency=o.preloadTime),(o.disconnectTime===null||o.disconnectTime===void 0)&&(o.disconnectTime=o.maxLatency)),o}function ln(i,o){var e=0,r=i.length-1,t=0,n=0,a=r;for(o<i[0]&&(e=0,n=a+1);n<=a;)if(t=n+Math.floor((a-n)/2),t===r||o>=i[t]&&o<i[t+1]){e=t;break}else i[t]<o?n=t+1:a=t-1;return e}var Be=new be("flv"),mt=.1,Qt=function(i){wn(e,i);var o=An(e);function e(r){var t;return cr(this,e),t=o.call(this),$(J(t),"media",null),$(J(t),"_loading",!1),$(J(t),"_opts",null),$(J(t),"_bufferService",null),$(J(t),"_gapService",null),$(J(t),"_stats",null),$(J(t),"_mediaLoader",null),$(J(t),"_maxChunkWaitTimer",null),$(J(t),"_tickTimer",null),$(J(t),"_tickInterval",500),$(J(t),"_urlSwitching",!1),$(J(t),"_seamlessSwitching",!1),$(J(t),"_disconnectRetryCount",0),$(J(t),"_preLoadEndPoint",0),$(J(t),"_keyframes",null),$(J(t),"_acceptRanges",!0),$(J(t),"_onProgress",function(){var n=ve(Q().mark(function a(s,u,l,f){var c,v,d,p,y,h,b,S,E;return Q().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(c=l.startTime,v=l.endTime,d=l.st,p=l.firstByteTime,t._loading=!u,t._firstProgressEmit){k.next=11;break}if(t.media){k.next=6;break}return(y=t._mediaLoader)===null||y===void 0||y.cancel(),k.abrupt("return");case 6:h=f.headers,t.emit(V.TTFB,{url:t._opts.url,responseUrl:f.url,elapsed:d?p-d:v-c}),t.emit(V.LOAD_RESPONSE_HEADERS,{headers:h}),t._acceptRanges=!!(h!=null&&h.get("Accept-Ranges"))||!!(h!=null&&h.get("Content-Range")),t._firstProgressEmit=!0;case 11:if(t._bufferService){k.next=13;break}return k.abrupt("return");case 13:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(s?.byteLength,v-c),k.prev=15,k.next=18,t._bufferService.appendBuffer(s);case 18:(b=t._bufferService)===null||b===void 0||b.evictBuffer(t._opts.bufferBehind),k.next=31;break;case 21:if(k.prev=21,k.t0=k.catch(15),!(!t.isLive&&t._bufferService.isFull())){k.next=30;break}return k.next=26,t._mediaLoader.cancel();case 26:return t._loading=!1,S=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(S)/2,k.abrupt("return");case 30:return k.abrupt("return",t._emitError(re.create(k.t0)));case 31:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit(V.SWITCH_URL_SUCCESS,{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!(u&&!t.media.seeking)){k.next=38;break}return t.emit(V.LOAD_COMPLETE),Be.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),k.abrupt("return");case 38:if(t.isLive){k.next=40;break}return k.abrupt("return");case 40:E=t._opts.maxReaderInterval,E&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout(function(){if(t._disconnectRetryCount){t._disconnectRetryCount--,t.load();return}Be.debug("onMaxChunkWait",E),t._end()},E));case 42:case"end":return k.stop()}},a,null,[[15,21]])}));return function(a,s,u,l){return n.apply(this,arguments)}}()),$(J(t),"_onRetryError",function(n,a){Be.debug("load retry",n,a),t.emit(V.LOAD_RETRY,{error:re.network(n),retryTime:a})}),$(J(t),"_end",function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),Be.debug("end stream")}),$(J(t),"_resetDisconnectCount",function(){t._disconnectRetryCount=t._opts.disconnectRetryCount}),$(J(t),"_tick",function(){clearTimeout(t._tickTimer);var n=J(t),a=n.media;if(a){t._tickTimer=setTimeout(t._tick,t._tickInterval);var s=oe.end(oe.get(a));if(!(s<mt||!a.readyState)){var u=t._opts;if(Pr(a))t._gapService&&t._gapService.do(a,u.maxJumpDistance,t.isLive,3);else{if(!a.currentTime&&t._gapService){t._gapService.do(a,u.maxJumpDistance,t.isLive,3);return}u.isLive&&a.readyState===4&&s>u.disconnectTime&&t.disconnect()}}}}),$(J(t),"_onPlay",function(){var n,a,s=t._opts.softDecode||((n=t.media)===null||n===void 0||(a=n.buffered)===null||a===void 0?void 0:a.length);if(t.isLive){!t._loading&&s&&t.replay(void 0,!0);return}var u=t.bufferInfo();(u.start||u.nextStart)>mt&&t._tick()}),$(J(t),"_onSeeking",ve(Q().mark(function n(){return Q().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return s.stop()}},n)}))),$(J(t),"_onTimeupdate",function(){if(t.media){var n=t._opts,a=t.media.currentTime;if(n.isLive&&n.maxLatency&&n.targetLatency){var s=oe.end(oe.get(t.media)),u=s-a;u>=n.maxLatency&&(t.media.currentTime=s-n.targetLatency)}t._seiService.throw(a,!0),!(n.isLive||!t.seekable||t._loading)&&t._checkPreload()}}),$(J(t),"_onWaiting",function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())}),$(J(t),"_onBufferUpdate",function(){if(!t._opts.isLive){var n=t.bufferInfo(),a=n.end,s=n.nextEnd;Math.abs((a||s)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}}),$(J(t),"_checkPreload",ve(Q().mark(function n(){var a,s,u,l,f,c,v,d,p,y;return Q().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(a=t.bufferInfo(),s=a.remaining,u=s===void 0?0:s,l=t._opts,f=t._keyframes.filepositions,c=t._keyframes.times,v=t.media.currentTime,!(u<l.preloadTime)){b.next=19;break}if(d=ln(t._keyframes.times,v+u+mt),p=ln(t._keyframes.times,v+u+t._opts.preloadTime),p===d&&(p=d+1),t._preLoadEndPoint!==p){b.next=11;break}return b.abrupt("return");case 11:if(y=f[d],y!=null){b.next=14;break}return b.abrupt("return");case 14:return b.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[y,f[p]]),t._preLoadEndPoint=p,t._bufferService.unContiguous(c[d]);case 19:case"end":return b.stop()}},n)}))),$(J(t),"_onFlvScriptData",function(n){var a,s,u,l,f=(a=n.data)===null||a===void 0||(s=a.onMetaData)===null||s===void 0?void 0:s.keyframes,c=(u=n.data)===null||u===void 0||(l=u.onMetaData)===null||l===void 0?void 0:l.duration;f&&(t._keyframes=f),!t._opts.isLive&&c&&t._bufferService.updateDuration(c)}),t._opts=ki(r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new ze(Pe(Pe({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._disconnectRetryCount=t._opts.disconnectRetryCount,t._bufferService=new wi(J(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new Cr(J(t)),t._bandwidthService=new Mr,t._stats=new xr(J(t)),t._opts.softDecode||(t._gapService=new Ir),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.media.addEventListener("progress",t._onBufferUpdate),t.media.addEventListener("waiting",t._onWaiting),t.on(V.FLV_SCRIPT_DATA,t._onFlvScriptData),t}return dr(e,[{key:"version",get:function(){return"3.0.16"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var t;return(t=this._bufferService)===null||t===void 0?void 0:t.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var t;return(t=this._bufferService)===null||t===void 0?void 0:t.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mt;return oe.info(oe.get(this.media),(t=this.media)===null||t===void 0?void 0:t.currentTime,n)}},{key:"playbackQuality",value:function(){return Rr(this.media)}},{key:"load",value:function(){var r=ve(Q().mark(function n(a){var s,u=arguments;return Q().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(s=u.length>1&&u[1]!==void 0?u[1]:!1,this._bufferService){f.next=3;break}return f.abrupt("return");case 3:return f.next=5,this._reset(s);case 5:this._loadData(a,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return f.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"replay",value:function(){var r=ve(Q().mark(function n(){var a=this,s,u,l=arguments;return Q().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=l.length>0&&l[0]!==void 0?l[0]:this._opts.seamlesslyReload,u=l.length>1?l[1]:void 0,this.media){c.next=4;break}return c.abrupt("return");case 4:if(this._resetDisconnectCount(),!s){c.next=11;break}return c.next=8,this._clear();case 8:setTimeout(function(){a._loadData(a._opts.url),a._bufferService.seamlessSwitch(),a._seamlessSwitching=!0}),c.next=13;break;case 11:return c.next=13,this.load();case 13:return c.abrupt("return",this.media.play(!u).catch(function(){}));case 14:case"end":return c.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"disconnect",value:function(){return Be.debug("disconnect!"),this._clear()}},{key:"switchURL",value:function(){var r=ve(Q().mark(function n(a,s){var u=this;return Q().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this._bufferService){f.next=2;break}return f.abrupt("return");case 2:if(this._resetDisconnectCount(),!(!s||!this._opts.isLive)){f.next=8;break}return f.next=6,this.load(a);case 6:return this._urlSwitching=!0,f.abrupt("return",this.media.play(!0).catch(function(){}));case 8:return f.next=10,this._clear();case 10:setTimeout(function(){u._loadData(a),u._bufferService.seamlessSwitch(),u._urlSwitching=!0,u._seamlessSwitching=!0});case 11:case"end":return f.stop()}},n,this)}));function t(n,a){return r.apply(this,arguments)}return t}()},{key:"destroy",value:function(){var r=ve(Q().mark(function n(){return Q().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.media){s.next=2;break}return s.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),s.next=11,Promise.all([this._clear(),this._bufferService.destroy()]);case 11:this.media=null,this._bufferService=null;case 13:case"end":return s.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_emitError",value:function(t){var n,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Be.table(t),Be.error(t),Be.error((n=this.media)===null||n===void 0?void 0:n.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(V.SWITCH_URL_FAILED,t)),this.emit(V.ERROR,t),a&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var r=ve(Q().mark(function n(){var a,s=arguments;return Q().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return a=s.length>0&&s[0]!==void 0?s[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),l.next=6,this._clear();case 6:return l.next=8,this._bufferService.reset(a);case 8:case"end":return l.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_loadData",value:function(){var r=ve(Q().mark(function n(a,s){var u;return Q().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(a&&(this._opts.url=a),u=a=this._opts.url,a){f.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(u=this._opts.preProcessUrl(a).url),this._mediaLoader.finnalUrl=u,this.emit(V.LOAD_START,{url:u}),Be.debug("load data, loading:",this._loading,u),!this._loading){f.next=11;break}return f.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,f.prev=12,f.next=15,this._mediaLoader.load({url:u,range:s});case 15:f.next=21;break;case 17:return f.prev=17,f.t0=f.catch(12),this._loading=!1,f.abrupt("return",this._emitError(re.network(f.t0)));case 21:case"end":return f.stop()}},n,this,[[12,17]])}));function t(n,a){return r.apply(this,arguments)}return t}()},{key:"_clear",value:function(){var r=ve(Q().mark(function n(){return Q().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this._mediaLoader){s.next=3;break}return s.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return s.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()}],[{key:"isSupported",value:function(t){return!t||t==="video"||t==="audio"?pe.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){be.enable(),We.enable()}},{key:"disableLogger",value:function(){be.disable(),We.disable()}}]),e}(Xn);try{localStorage.getItem("xgd")?Qt.enableLogger():Qt.disableLogger()}catch{}function Ti(i,o){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var r,t,n,a,s=[],u=!0,l=!1;try{if(n=(e=e.call(i)).next,o===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=n.call(e)).done)&&(s.push(r.value),s.length!==o);u=!0);}catch(f){l=!0,t=f}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw t}}return s}}function fn(i,o){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);o&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),e.push.apply(e,r)}return e}function le(i){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?fn(Object(e),!0).forEach(function(r){T(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):fn(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function B(){B=function(){return i};var i={},o=Object.prototype,e=o.hasOwnProperty,r=Object.defineProperty||function(m,g,_){m[g]=_.value},t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",a=t.asyncIterator||"@@asyncIterator",s=t.toStringTag||"@@toStringTag";function u(m,g,_){return Object.defineProperty(m,g,{value:_,enumerable:!0,configurable:!0,writable:!0}),m[g]}try{u({},"")}catch{u=function(g,_,D){return g[_]=D}}function l(m,g,_,D){var w=g&&g.prototype instanceof v?g:v,P=Object.create(w.prototype),C=new G(D||[]);return r(P,"_invoke",{value:k(m,_,C)}),P}function f(m,g,_){try{return{type:"normal",arg:m.call(g,_)}}catch(D){return{type:"throw",arg:D}}}i.wrap=l;var c={};function v(){}function d(){}function p(){}var y={};u(y,n,function(){return this});var h=Object.getPrototypeOf,b=h&&h(h(M([])));b&&b!==o&&e.call(b,n)&&(y=b);var S=p.prototype=v.prototype=Object.create(y);function E(m){["next","throw","return"].forEach(function(g){u(m,g,function(_){return this._invoke(g,_)})})}function A(m,g){function _(w,P,C,H){var z=f(m[w],m,P);if(z.type!=="throw"){var R=z.arg,te=R.value;return te&&typeof te=="object"&&e.call(te,"__await")?g.resolve(te.__await).then(function(x){_("next",x,C,H)},function(x){_("throw",x,C,H)}):g.resolve(te).then(function(x){R.value=x,C(R)},function(x){return _("throw",x,C,H)})}H(z.arg)}var D;r(this,"_invoke",{value:function(w,P){function C(){return new g(function(H,z){_(w,P,H,z)})}return D=D?D.then(C,C):C()}})}function k(m,g,_){var D="suspendedStart";return function(w,P){if(D==="executing")throw new Error("Generator is already running");if(D==="completed"){if(w==="throw")throw P;return X()}for(_.method=w,_.arg=P;;){var C=_.delegate;if(C){var H=U(C,_);if(H){if(H===c)continue;return H}}if(_.method==="next")_.sent=_._sent=_.arg;else if(_.method==="throw"){if(D==="suspendedStart")throw D="completed",_.arg;_.dispatchException(_.arg)}else _.method==="return"&&_.abrupt("return",_.arg);D="executing";var z=f(m,g,_);if(z.type==="normal"){if(D=_.done?"completed":"suspendedYield",z.arg===c)continue;return{value:z.arg,done:_.done}}z.type==="throw"&&(D="completed",_.method="throw",_.arg=z.arg)}}}function U(m,g){var _=g.method,D=m.iterator[_];if(D===void 0)return g.delegate=null,_==="throw"&&m.iterator.return&&(g.method="return",g.arg=void 0,U(m,g),g.method==="throw")||_!=="return"&&(g.method="throw",g.arg=new TypeError("The iterator does not provide a '"+_+"' method")),c;var w=f(D,m.iterator,g.arg);if(w.type==="throw")return g.method="throw",g.arg=w.arg,g.delegate=null,c;var P=w.arg;return P?P.done?(g[m.resultName]=P.value,g.next=m.nextLoc,g.method!=="return"&&(g.method="next",g.arg=void 0),g.delegate=null,c):P:(g.method="throw",g.arg=new TypeError("iterator result is not an object"),g.delegate=null,c)}function N(m){var g={tryLoc:m[0]};1 in m&&(g.catchLoc=m[1]),2 in m&&(g.finallyLoc=m[2],g.afterLoc=m[3]),this.tryEntries.push(g)}function F(m){var g=m.completion||{};g.type="normal",delete g.arg,m.completion=g}function G(m){this.tryEntries=[{tryLoc:"root"}],m.forEach(N,this),this.reset(!0)}function M(m){if(m){var g=m[n];if(g)return g.call(m);if(typeof m.next=="function")return m;if(!isNaN(m.length)){var _=-1,D=function w(){for(;++_<m.length;)if(e.call(m,_))return w.value=m[_],w.done=!1,w;return w.value=void 0,w.done=!0,w};return D.next=D}}return{next:X}}function X(){return{value:void 0,done:!0}}return d.prototype=p,r(S,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,s,"GeneratorFunction"),i.isGeneratorFunction=function(m){var g=typeof m=="function"&&m.constructor;return!!g&&(g===d||(g.displayName||g.name)==="GeneratorFunction")},i.mark=function(m){return Object.setPrototypeOf?Object.setPrototypeOf(m,p):(m.__proto__=p,u(m,s,"GeneratorFunction")),m.prototype=Object.create(S),m},i.awrap=function(m){return{__await:m}},E(A.prototype),u(A.prototype,a,function(){return this}),i.AsyncIterator=A,i.async=function(m,g,_,D,w){w===void 0&&(w=Promise);var P=new A(l(m,g,_,D),w);return i.isGeneratorFunction(g)?P:P.next().then(function(C){return C.done?C.value:P.next()})},E(S),u(S,s,"Generator"),u(S,n,function(){return this}),u(S,"toString",function(){return"[object Generator]"}),i.keys=function(m){var g=Object(m),_=[];for(var D in g)_.push(D);return _.reverse(),function w(){for(;_.length;){var P=_.pop();if(P in g)return w.value=P,w.done=!1,w}return w.done=!0,w}},i.values=M,G.prototype={constructor:G,reset:function(m){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!m)for(var g in this)g.charAt(0)==="t"&&e.call(this,g)&&!isNaN(+g.slice(1))&&(this[g]=void 0)},stop:function(){this.done=!0;var m=this.tryEntries[0].completion;if(m.type==="throw")throw m.arg;return this.rval},dispatchException:function(m){if(this.done)throw m;var g=this;function _(z,R){return P.type="throw",P.arg=m,g.next=z,R&&(g.method="next",g.arg=void 0),!!R}for(var D=this.tryEntries.length-1;D>=0;--D){var w=this.tryEntries[D],P=w.completion;if(w.tryLoc==="root")return _("end");if(w.tryLoc<=this.prev){var C=e.call(w,"catchLoc"),H=e.call(w,"finallyLoc");if(C&&H){if(this.prev<w.catchLoc)return _(w.catchLoc,!0);if(this.prev<w.finallyLoc)return _(w.finallyLoc)}else if(C){if(this.prev<w.catchLoc)return _(w.catchLoc,!0)}else{if(!H)throw new Error("try statement without catch or finally");if(this.prev<w.finallyLoc)return _(w.finallyLoc)}}}},abrupt:function(m,g){for(var _=this.tryEntries.length-1;_>=0;--_){var D=this.tryEntries[_];if(D.tryLoc<=this.prev&&e.call(D,"finallyLoc")&&this.prev<D.finallyLoc){var w=D;break}}w&&(m==="break"||m==="continue")&&w.tryLoc<=g&&g<=w.finallyLoc&&(w=null);var P=w?w.completion:{};return P.type=m,P.arg=g,w?(this.method="next",this.next=w.finallyLoc,c):this.complete(P)},complete:function(m,g){if(m.type==="throw")throw m.arg;return m.type==="break"||m.type==="continue"?this.next=m.arg:m.type==="return"?(this.rval=this.arg=m.arg,this.method="return",this.next="end"):m.type==="normal"&&g&&(this.next=g),c},finish:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.finallyLoc===m)return this.complete(_.completion,_.afterLoc),F(_),c}},catch:function(m){for(var g=this.tryEntries.length-1;g>=0;--g){var _=this.tryEntries[g];if(_.tryLoc===m){var D=_.completion;if(D.type==="throw"){var w=D.arg;F(_)}return w}}throw new Error("illegal catch attempt")},delegateYield:function(m,g,_){return this.delegate={iterator:M(m),resultName:g,nextLoc:_},this.method==="next"&&(this.arg=void 0),c}},i}function Jt(i){"@babel/helpers - typeof";return Jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},Jt(i)}function cn(i,o,e,r,t,n,a){try{var s=i[n](a),u=s.value}catch(l){e(l);return}s.done?o(u):Promise.resolve(u).then(r,t)}function Z(i){return function(){var o=this,e=arguments;return new Promise(function(r,t){var n=i.apply(o,e);function a(u){cn(n,r,t,a,s,"next",u)}function s(u){cn(n,r,t,a,s,"throw",u)}a(void 0)})}}function he(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function hn(i,o){for(var e=0;e<o.length;e++){var r=o[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,vn(r.key),r)}}function de(i,o,e){return o&&hn(i.prototype,o),e&&hn(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function T(i,o,e){return o=vn(o),o in i?Object.defineProperty(i,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[o]=e,i}function Zt(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),o&&er(i,o)}function gt(i){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},gt(i)}function er(i,o){return er=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},er(i,o)}function Ai(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function q(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Di(i,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return q(i)}function tr(i){var o=Ai();return function(){var r=gt(i),t;if(o){var n=gt(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Di(this,t)}}function xe(i,o){return Pi(i)||Ti(i,o)||dn(i,o)||Ci()}function Li(i){return Oi(i)||Ri(i)||dn(i)||Ii()}function Oi(i){if(Array.isArray(i))return rr(i)}function Pi(i){if(Array.isArray(i))return i}function Ri(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function dn(i,o){if(i){if(typeof i=="string")return rr(i,o);var e=Object.prototype.toString.call(i).slice(8,-1);if(e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set")return Array.from(i);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return rr(i,o)}}function rr(i,o){(o==null||o>i.length)&&(o=i.length);for(var e=0,r=new Array(o);e<o;e++)r[e]=i[e];return r}function Ii(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
7
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ci(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mi(i,o){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,o||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}function vn(i){var o=Mi(i,"string");return typeof o=="symbol"?o:String(o)}var pn={exports:{}};(function(i){var o=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function t(u,l,f){this.fn=u,this.context=l,this.once=f||!1}function n(u,l,f,c,v){if(typeof f!="function")throw new TypeError("The listener must be a function");var d=new t(f,c||u,v),p=e?e+l:l;return u._events[p]?u._events[p].fn?u._events[p]=[u._events[p],d]:u._events[p].push(d):(u._events[p]=d,u._eventsCount++),u}function a(u,l){--u._eventsCount===0?u._events=new r:delete u._events[l]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var l=[],f,c;if(this._eventsCount===0)return l;for(c in f=this._events)o.call(f,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(f)):l},s.prototype.listeners=function(l){var f=e?e+l:l,c=this._events[f];if(!c)return[];if(c.fn)return[c.fn];for(var v=0,d=c.length,p=new Array(d);v<d;v++)p[v]=c[v].fn;return p},s.prototype.listenerCount=function(l){var f=e?e+l:l,c=this._events[f];return c?c.fn?1:c.length:0},s.prototype.emit=function(l,f,c,v,d,p){var y=e?e+l:l;if(!this._events[y])return!1;var h=this._events[y],b=arguments.length,S,E;if(h.fn){switch(h.once&&this.removeListener(l,h.fn,void 0,!0),b){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,f),!0;case 3:return h.fn.call(h.context,f,c),!0;case 4:return h.fn.call(h.context,f,c,v),!0;case 5:return h.fn.call(h.context,f,c,v,d),!0;case 6:return h.fn.call(h.context,f,c,v,d,p),!0}for(E=1,S=new Array(b-1);E<b;E++)S[E-1]=arguments[E];h.fn.apply(h.context,S)}else{var A=h.length,k;for(E=0;E<A;E++)switch(h[E].once&&this.removeListener(l,h[E].fn,void 0,!0),b){case 1:h[E].fn.call(h[E].context);break;case 2:h[E].fn.call(h[E].context,f);break;case 3:h[E].fn.call(h[E].context,f,c);break;case 4:h[E].fn.call(h[E].context,f,c,v);break;default:if(!S)for(k=1,S=new Array(b-1);k<b;k++)S[k-1]=arguments[k];h[E].fn.apply(h[E].context,S)}}return!0},s.prototype.on=function(l,f,c){return n(this,l,f,c,!1)},s.prototype.once=function(l,f,c){return n(this,l,f,c,!0)},s.prototype.removeListener=function(l,f,c,v){var d=e?e+l:l;if(!this._events[d])return this;if(!f)return a(this,d),this;var p=this._events[d];if(p.fn)p.fn===f&&(!v||p.once)&&(!c||p.context===c)&&a(this,d);else{for(var y=0,h=[],b=p.length;y<b;y++)(p[y].fn!==f||v&&!p[y].once||c&&p[y].context!==c)&&h.push(p[y]);h.length?this._events[d]=h.length===1?h[0]:h:a(this,d)}return this},s.prototype.removeAllListeners=function(l){var f;return l?(f=e?e+l:l,this._events[f]&&a(this,f)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=e,s.EventEmitter=s,i.exports=s})(pn);var Bi=pn.exports;const xi=Ot(Bi);var Ui=function(){function i(){he(this,i);var o=window.crypto||window.msCrypto;this.subtle=o&&(o.subtle||o.webkitSubtle),this.externalDecryptor=null}return de(i,[{key:"destroy",value:function(){var e;(e=this.externalDecryptor)!==null&&e!==void 0&&e.destroy&&this.externalDecryptor.destroy()}},{key:"decrypt",value:function(e,r){if(!(!e&&!r)){var t=[];return e&&(t[0]=this._decryptSegment(e)),r&&(t[1]=this._decryptSegment(r)),Promise.all(t)}}},{key:"_decryptSegment",value:function(){var o=Z(B().mark(function r(t){var n;return B().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=t.data,!t.key){s.next=5;break}return s.next=4,this._decryptData(t.data,t.key,t.keyIv);case 4:n=s.sent;case 5:if(t.map){s.next=7;break}return s.abrupt("return",n);case 7:return s.abrupt("return",st(t.map,n));case 8:case"end":return s.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"_decryptData",value:function(){var o=Z(B().mark(function r(t,n,a){var s;return B().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!this.externalDecryptor){l.next=6;break}return l.next=3,this.externalDecryptor.decrypt(t,n,a);case 3:return l.abrupt("return",l.sent);case 6:if(this.subtle){l.next=8;break}throw new Error("crypto is not defined");case 8:return l.next=10,this.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt","decrypt"]);case 10:return s=l.sent,l.t0=Uint8Array,l.next=14,this.subtle.decrypt({name:"AES-CBC",iv:a},s,t);case 14:return l.t1=l.sent,l.abrupt("return",new l.t0(l.t1));case 16:case"end":return l.stop()}},r,this)}));function e(r,t,n){return o.apply(this,arguments)}return e}()}]),i}(),ee=le(le({},V),{},{STREAM_PARSED:"core.streamparsed",NO_AUDIO_TRACK:"core.noaudiotrack",SUBTITLE_SEGMENTS:"core.subtitlesegments",SUBTITLE_PLAYLIST:"core.subtitleplaylist",SEI_PAYLOAD_TIME:"core.seipayloadtime",APPEND_COST:"core.appendcost"}),yt=new be("Transmuxer"),mn=function(){function i(o,e,r){he(this,i),T(this,"_initSegmentId",""),this.hls=o,this._demuxer=e?new Si:new tn,this._isMP4=e,r&&(this._remuxer=new un(this._demuxer.videoTrack,this._demuxer.audioTrack))}return de(i,[{key:"transmux",value:function(e,r,t,n,a,s){var u=this._demuxer;try{this._isMP4?u.demux(e,r):u.demuxAndFix(st(e,r),t,n,a)}catch(A){throw new re(Y.DEMUX,Y.SUB_TYPES.HLS,A)}var l=u.videoTrack,f=u.audioTrack,c=u.metadataTrack,v="".concat(l.codec,"/").concat(l.width,"/").concat(l.height,"/").concat(f.codec,"/").concat(f.config);if(v!==this._initSegmentId&&(this._initSegmentId=v,s=!0),this._fireEvents(l,f,c,t||s),this.hls.emit(ee.DEMUXED_TRACK,{videoTrack:l,audioTrack:f}),this._remuxer)try{var d=this._remuxer.remux(s),p=d.videoInitSegment,y=d.videoSegment,h=d.audioInitSegment,b=d.audioSegment,S=st(p,y),E=st(h,b);return[S?{codec:l.codec,data:S}:void 0,E?{codec:f.codec,data:E}:void 0]}catch(A){throw new re(Y.REMUX,Y.SUB_TYPES.FMP4,A)}else return[l,f]}},{key:"_fireEvents",value:function(e,r,t,n){var a=this;yt.debug(e.samples,r.samples),n&&(e.exist()&&this.hls.emit(ee.METADATA_PARSED,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),r.exist()&&this.hls.emit(ee.METADATA_PARSED,{type:"audio",track:r,meta:{codec:r.codec,channelCount:r.channelCount,sampleRate:r.sampleRate,timescale:r.timescale,baseDts:r.baseDts}}),yt.debug("discontinuity",e,r)),e.warnings.forEach(function(s){var u;switch(s.type){case se.LARGE_AV_SHIFT:u=ee.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case se.LARGE_VIDEO_GAP:u=ee.LARGE_VIDEO_DTS_GAP_DETECT;break;case se.LARGE_VIDEO_GAP_BETWEEN_CHUNK:u=ee.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}u&&a.hls.emit(ee.STREAM_EXCEPTION,le(le({},s),{},{type:u})),yt.warn("video exception",s)}),r.warnings.forEach(function(s){var u;switch(s.type){case se.LARGE_AUDIO_GAP:u=ee.LARGE_AUDIO_DTS_GAP_DETECT;break;case se.AUDIO_FILLED:u=ee.AUDIO_GAP_DETECT;break;case se.AUDIO_DROPPED:u=ee.AUDIO_OVERLAP_DETECT;break}u&&a.hls.emit(ee.STREAM_EXCEPTION,le(le({},s),{},{type:u})),yt.warn("audio exception",s)}),e.samples.forEach(function(s){s.keyframe&&a.hls.emit(ee.KEYFRAME,{pts:s.pts})}),t.seiSamples.forEach(function(s){a.hls.emit(ee.SEI,le(le({},s),{},{originPts:s.originPts/90,sei:{code:s.data.type,content:s.data.payload,dts:s.pts}}))})}}]),i}(),gn=new be("BufferService"),Ni=function(){function i(o){he(this,i),T(this,"_decryptor",new Ui),T(this,"_transmuxer",null),T(this,"_mse",null),T(this,"_softVideo",null),T(this,"_sourceCreated",!1),T(this,"_needInitSegment",!0),T(this,"_directAppend",!1),this.hls=o,o.config.softDecode?this._softVideo=o.media:(this._mse=new pe(null,{preferMMS:o.config.preferMMS}),o.config.url&&this._mse.bindMedia(o.media)),o.config.decryptor&&(this._decryptor.externalDecryptor=o.config.decryptor)}return de(i,[{key:"baseDts",get:function(){var e,r,t;return(e=this._transmuxer)===null||e===void 0||(r=e._demuxer)===null||r===void 0||(t=r._fixer)===null||t===void 0?void 0:t._baseDts}},{key:"nbSb",get:function(){var e;return(e=this._mse)!==null&&e!==void 0&&e._sourceBuffer?Object.keys(this._mse._sourceBuffer).length:0}},{key:"msIsOpend",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.isOpened}},{key:"msStreaming",get:function(){var e;return(e=this._mse)===null||e===void 0?void 0:e.streaming}},{key:"updateDuration",value:function(){var o=Z(B().mark(function r(t){return B().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(gn.debug("update duration",t),!this._mse){a.next=9;break}if(this._mse.isOpened){a.next=5;break}return a.next=5,this._mse.open();case 5:return a.next=7,this._mse.updateDuration(t);case 7:a.next=10;break;case 9:this._softVideo&&(this._softVideo.duration=t);case 10:case"end":return a.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"createSource",value:function(e,r,t,n){if(!this._sourceCreated){var a=e||r;if(a){if(tn.probe(a))this._transmuxer||(this._transmuxer=new mn(this.hls,!1,!this._softVideo));else if(ce.probe(a))if(this._softVideo)this._transmuxer||(this._transmuxer=new mn(this.hls,!0));else{this._directAppend=!0;var s=!1;e&&!t&&ce.findBox(e,["moov","trak"]).forEach(function(u){var l=ce.findBox(u.data,["trak","mdia","minf","stbl","stsd"])[0];if(l){var f=ce.stsd(l).entries[0];if(f){if(f.hvcC)t=f.hvcC.codec||"hev1.1.6.L93.B0";else if(f.avcC)t=f.avcC.codec;else if(f.sampleRate||f.esds){var c;n=((c=f.esds)===null||c===void 0?void 0:c.codec)||"mp4a.40.2",s=!0}}}}),r&&!n&&ce.findBox(r,["moov","trak","mdia","minf","stbl","stsd"]).forEach(function(u){var l=ce.stsd(u).entries[0];l&&l.esds&&(n=l.esds.codec)}),e&&!t&&(t="avc1.42e01e"),r&&!n&&(n="mp4a.40.2"),s&&(t+=", ".concat(n),n=""),this._createMseSource(t,n)}else throw new re(Y.OTHER,null,null,null,"unsupported stream");this._softVideo&&(this._sourceCreated=!0)}}}},{key:"appendBuffer",value:function(){var o=Z(B().mark(function r(t,n,a,s,u,l,f){var c,v,d,p,y,h,b,S,E;return B().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(!(!(a!=null&&a.length)&&!(s!=null&&s.length))){k.next=2;break}return k.abrupt("return");case 2:if(!this._directAppend){k.next=7;break}return c=[],a&&c.push(this._mse.append(pe.VIDEO,a)),s&&c.push(this._mse.append(pe.AUDIO,s)),k.abrupt("return",Promise.all(c));case 7:if(v=this._needInitSegment||u,d=this._transmuxer.transmux(a,s,u,l,f,this._needInitSegment||u),p=xe(d,2),y=p[0],h=p[1],s&&n&&n?.setTrackExist(!1,!0),s&&t&&t?.setTrackExist(!0,!1),n||t?.setTrackExist(!!y,!!h),y&&!h&&this.hls.emit(ee.NO_AUDIO_TRACK),!this._softVideo){k.next=18;break}this._softVideo.appendBuffer(y,h),this._needInitSegment=!1,k.next=28;break;case 18:if(!this._mse){k.next=28;break}return b=!this._sourceCreated,b&&this._createMseSource(y?.codec,h?.codec),this._needInitSegment=!1,S=this._mse,E=[],v&&!b&&this._handleCodecChange(y,h),y&&E.push(S.append(pe.VIDEO,y.data)),h&&E.push(S.append(pe.AUDIO,h.data)),k.abrupt("return",Promise.all(E));case 28:case"end":return k.stop()}},r,this)}));function e(r,t,n,a,s,u,l){return o.apply(this,arguments)}return e}()},{key:"removeBuffer",value:function(){var o=Z(B().mark(function r(){var t=this,n,a,s,u=arguments;return B().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(n=u.length>0&&u[0]!==void 0?u[0]:0,a=u.length>1&&u[1]!==void 0?u[1]:1/0,s=this.hls.media,!(!this._mse||!s||n<0||a<n||n>=this._mse.duration)){f.next=5;break}return f.abrupt("return");case 5:return f.abrupt("return",this._mse.clearBuffer(n,a).then(function(){return t.hls.emit(V.REMOVE_BUFFER,{start:n,end:a,removeEnd:a})}));case 6:case"end":return f.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"evictBuffer",value:function(){var o=Z(B().mark(function r(t){var n,a,s,u;return B().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(n=this.hls.media,!(!this._mse||!n||!t||t<0)){f.next=3;break}return f.abrupt("return");case 3:if(a=n.currentTime,s=a-t,!(s<=0)){f.next=7;break}return f.abrupt("return");case 7:if(u=oe.start(oe.get(n)),!(u+1>=s)){f.next=10;break}return f.abrupt("return");case 10:return f.abrupt("return",this.removeBuffer(0,s));case 11:case"end":return f.stop()}},r,this)}));function e(r){return o.apply(this,arguments)}return e}()},{key:"clearAllBuffer",value:function(){var o=Z(B().mark(function r(){return B().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=2;break}return n.abrupt("return",this._mse.clearAllBuffer());case 2:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"decryptBuffer",value:function(e,r){return this._decryptor.decrypt(e,r)}},{key:"reset",value:function(){var o=Z(B().mark(function r(){var t,n=arguments;return B().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=n.length>0&&n[0]!==void 0?n[0]:!1,!(this._mse&&!t)){s.next=8;break}return this._transmuxer=null,this._sourceCreated=!1,s.next=6,this._mse.unbindMedia();case 6:return s.next=8,this._mse.bindMedia(this.hls.media);case 8:this._needInitSegment=!0,this._directAppend=!1;case 10:case"end":return s.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"endOfStream",value:function(){var o=Z(B().mark(function r(){return B().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=5;break}if(!this._sourceCreated){n.next=5;break}return n.next=4,this._mse.endOfStream();case 4:this.hls.emit(V.BUFFEREOS);case 5:this._softVideo&&this._softVideo.endOfStream();case 6:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"setLiveSeekableRange",value:function(){var o=Z(B().mark(function r(t,n){return B().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:this._mse&&this._mse.setLiveSeekableRange(t,n);case 1:case"end":return s.stop()}},r,this)}));function e(r,t){return o.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var o=Z(B().mark(function r(){var t;return B().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if((t=this._decryptor)===null||t===void 0||t.destroy(),!this._mse){a.next=4;break}return a.next=4,this._mse.unbindMedia();case 4:this._decryptor=null,this._mse=null,this._softVideo=null;case 7:case"end":return a.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()},{key:"_createMseSource",value:function(e,r){gn.debug("create mse source, videoCodec=".concat(e,", audioCodec=").concat(r));var t=this._mse;t&&(e&&(t.createSource(pe.VIDEO,"video/mp4;codecs=".concat(e)),this._sourceCreated=!0),r&&(t.createSource(pe.AUDIO,"audio/mp4;codecs=".concat(r)),this._sourceCreated=!0),this.hls.emit(V.SOURCEBUFFER_CREATED))}},{key:"_handleCodecChange",value:function(e,r){var t=this._mse,n=[{type:pe.VIDEO,codecs:e?.codec},{type:pe.AUDIO,codecs:r?.codec}];n.filter(function(a){return!!a.codecs}).forEach(function(a){var s=a.type,u=a.codecs,l=t.getSourceBuffer(s);if(l){var f=u.split(",")[0];new RegExp(f,"ig").test(l.mimeType)||t.changeType(s,"".concat(s,"/mp4;codecs=").concat(u))}})}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0}},{key:"isFull",value:function(){var e,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pe.VIDEO;return(e=this._mse)===null||e===void 0?void 0:e.isFull(r)}}]),i}();function Fi(i){var o=i?.media||document.createElement("video");return le(le({maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,manifestLoadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,useLowLatency:!0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,seiInTime:!1,manifestList:[],minSegmentsStartPlay:3,preferMMS:!1,preferMMSStreaming:!1},i),{},{media:o})}var Vi=de(function i(){he(this,i),T(this,"version",0),T(this,"streams",[]),T(this,"isMaster",!0)}),yn={Audio:"AUDIO",Video:"VIDEO",SubTitle:"SUBTITLE",ClosedCaptions:"CLOSED-CAPTIONS"},_t={CLEAR_KEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",PLAYREADY:"com.microsoft.playready"},nr=de(function i(){he(this,i),T(this,"id",0),T(this,"url",""),T(this,"default",!1),T(this,"autoSelect",!1),T(this,"forced",!1),T(this,"group",""),T(this,"name",""),T(this,"lang",""),T(this,"segments",[]),T(this,"endSN",0)}),Gi=function(i){Zt(e,i);var o=tr(e);function e(){var r;he(this,e);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return r=o.call.apply(o,[this].concat(n)),T(q(r),"mediaType",yn.Audio),T(q(r),"channels",0),r}return de(e)}(nr),ji=function(i){Zt(e,i);var o=tr(e);function e(){var r;he(this,e);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return r=o.call.apply(o,[this].concat(n)),T(q(r),"mediaType",yn.SubTitle),r}return de(e)}(nr),Hi=de(function i(){he(this,i),T(this,"id",0),T(this,"bitrate",0),T(this,"width",0),T(this,"height",0),T(this,"name",""),T(this,"url",""),T(this,"audioCodec",""),T(this,"videoCodec",""),T(this,"textCodec",""),T(this,"audioGroup",""),T(this,"audioStreams",[]),T(this,"subtitleStreams",[]),T(this,"closedCaptionsStream",[])}),zi=de(function i(){he(this,i),T(this,"version",0),T(this,"url",""),T(this,"type",""),T(this,"startCC",0),T(this,"endCC",0),T(this,"startSN",0),T(this,"endSN",0),T(this,"totalDuration",0),T(this,"targetDuration",0),T(this,"partTargetDuration",0),T(this,"canSkipUntil",0),T(this,"canSkipDateRanges",!1),T(this,"skippedSegments",0),T(this,"canBlockReload",!1),T(this,"partHoldBack",0),T(this,"live",!0),T(this,"lowLatency",!1),T(this,"endPartIndex",0),T(this,"segments",[])}),bt=function(){function i(){he(this,i),T(this,"sn",0),T(this,"cc",0),T(this,"url",""),T(this,"title",""),T(this,"start",0),T(this,"duration",0),T(this,"dataTime",""),T(this,"key",null),T(this,"byteRange",null),T(this,"isInitSegment",!1),T(this,"initSegment",null),T(this,"isLast",!1),T(this,"hasAudio",!1),T(this,"hasVideo",!1),T(this,"independent",!1),T(this,"partIndex",0)}return de(i,[{key:"end",get:function(){return this.start+this.duration}},{key:"setTrackExist",value:function(e,r){this.hasVideo=e,this.hasAudio=r}},{key:"setByteRange",value:function(e,r){this.byteRange=[0];var t=e.split("@");t.length===1&&r&&r.byteRange?(this.byteRange[0]=r.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(t[1]),this.byteRange[1]=this.byteRange[0]+parseInt(t[0])-1}}]),i}(),$i=function(){function i(o){he(this,i),T(this,"method",""),T(this,"url",""),T(this,"iv",null),T(this,"keyFormat",""),T(this,"keyFormatVersions",""),o instanceof i&&(this.method=o.method,this.url=o.url,this.keyFormat=o.keyFormat,this.keyFormatVersions=o.keyFormatVersions,o.iv&&(this.iv=new Uint8Array(o.iv)))}return de(i,[{key:"clone",value:function(e){var r=new i(this);return e!=null&&r.setIVFromSN(e),r}},{key:"setIVFromSN",value:function(e){if(!this.iv&&this.method==="AES-128"&&typeof e=="number"&&this.url){this.iv=new Uint8Array(16);for(var r=12;r<16;r++)this.iv[r]=e>>8*(15-r)&255}}},{key:"isSegmentEncrypted",value:function(){var e=this.method;return e==="AES-128"}},{key:"isValidKeySystem",value:function(){var e=[_t.CLEAR_KEY,_t.FAIRPLAY,_t.WIDEVINE,_t.PLAYREADY].indexOf(this.keyFormat)>-1;if(!e)return!1;var r=["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)>-1;return!!r}},{key:"isSupported",value:function(){return this.method?this.isSegmentEncrypted()?!0:!!this.isValidKeySystem():!1}}]),i}(),Wi=/^#(EXT[^:]*)(?::(.*))?$/,_n=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,Ki=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,Yi=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Xi(i){return i.split(/[\r\n]/).map(function(o){return o.trim()}).filter(Boolean)}function bn(i){var o=i.match(Wi);if(!(!o||!o[1]))return[o[1].replace("EXT-X-",""),o[2]]}function Ke(i){for(var o={},e=_n.exec(i);e;)o[e[1]]=e[2]||e[3],e=_n.exec(i);return o}function Ze(i,o){if(!o||!i||Ki.test(i))return i;var e=Yi.exec(o);return e?i[0]==="/"?e[1]+i:e[1]+e[2]+i:i}var qi={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function ir(i,o){var e=qi[i];if(!(!e||!o||!o.length)){for(var r=0;r<e.length;r++)for(var t=0;t<o.length;t++)if(e[r].test(o[t]))return o[t]}}function Qi(i,o){for(var e=new Vi,r=0,t,n=[],a=[];t=i[r++];){var s=bn(t);if(s){var u=xe(s,2),l=u[0],f=u[1];if(l==="VERSION")e.version=parseInt(f);else if(l==="MEDIA"&&f){var c=Ke(f),v=void 0;switch(c.TYPE){case"AUDIO":v=new Gi;break;case"SUBTITLES":v=new ji;break;default:v=new nr}v.url=Ze(c.URI,o),v.default=c.DEFAULT==="YES",v.autoSelect=c.AUTOSELECT==="YES",v.group=c["GROUP-ID"],v.name=c.NAME,v.lang=c.LANGUAGE,c.CHANNELS&&(v.channels=Number(c.CHANNELS.split("/")[0]),Number.isNaN(v.channels)&&(v.channels=0)),c.TYPE==="AUDIO"&&c.URI&&n.push(v),c.TYPE==="SUBTITLES"&&a.push(v)}else if(l==="STREAM-INF"&&f){var d=new Hi,p=Ke(f);if(d.bitrate=parseInt(p["AVERAGE-BANDWIDTH"]||p.BANDWIDTH),d.name=p.NAME,d.url=Ze(i[r++],o),p.RESOLUTION){var y=p.RESOLUTION.split("x"),h=xe(y,2),b=h[0],S=h[1];d.width=parseInt(b),d.height=parseInt(S)}if(p.CODECS){var E=p.CODECS.split(/[ ,]+/).filter(Boolean);d.videoCodec=ir("video",E),d.audioCodec=ir("audio",E),d.textCodec=ir("text",E)}d.audioGroup=p.AUDIO,d.subtitleGroup=p.SUBTITLES,e.streams.push(d)}}}return e.streams.forEach(function(A,k){A.id=k}),n.length&&(n.forEach(function(A,k){A.id=k}),e.streams.forEach(function(A){A.audioGroup&&(A.audioStreams=n.filter(function(k){return k.group===A.audioGroup}))})),a.length&&(a.forEach(function(A,k){A.id=k}),e.streams.forEach(function(A){A.subtitleGroup&&(A.subtitleStreams=a.filter(function(k){return k.group===A.subtitleGroup}))})),e}function Ji(i,o,e){var r=new zi;r.url=o;for(var t=new bt,n=null,a=null,s=0,u=0,l=0,f=0,c,v=!1,d=0;(c=i[f++])&&!v;){if(c[0]!=="#"){if(r.lowLatency){u++;continue}t.sn=u,t.cc=l,t.url=Ze(c,o),a&&(t.key=a.clone(u)),n&&(t.initSegment=n),r.segments.push(t),t=new bt,u++;continue}var p=bn(c);if(p){var y=xe(p,2),h=y[0],b=y[1];switch(h){case"VERSION":r.version=parseInt(b);break;case"PLAYLIST-TYPE":r.type=b?.toUpperCase();break;case"TARGETDURATION":r.targetDuration=parseFloat(b);break;case"PART-INF":{e&&(r.lowLatency=!0);var S=Ke(b);S["PART-TARGET"]&&(r.partTargetDuration=parseFloat(S["PART-TARGET"]))}break;case"SERVER-CONTROL":{var E=Ke(b);r.canBlockReload=E["CAN-BLOCK-RELOAD"]==="YES",r.partHoldBack=parseFloat(E["PART-HOLD-BACK"]||0),r.canSkipUntil=parseFloat(E["CAN-SKIP-UNTIL"]||0),r.canSkipDateRanges=E["CAN-SKIP-DATERANGES"]==="YES"}break;case"ENDLIST":{var A=r.segments[r.segments.length-1];A&&(A.isLast=!0),r.live=!1,v=!0}break;case"MEDIA-SEQUENCE":u=r.startSN=parseInt(b);break;case"DISCONTINUITY-SEQUENCE":l=r.startCC=parseInt(b);break;case"DISCONTINUITY":l++;break;case"BYTERANGE":t.setByteRange(b,r.segments[r.segments.length-1]);break;case"PART":{if(!r.lowLatency)break;var k=Ke(b);t.duration=parseFloat(k.DURATION),t.independent=k.INDEPENDENT==="YES",t.sn=u,t.cc=l,t.partIndex=d,t.start=s,t.duration=parseFloat(k.DURATION),s+=t.duration,t.url=Ze(k.URI,o),a&&(t.key=a.clone(u)),n&&(t.initSegment=n),r.segments.push(t),t=new bt,d++}break;case"PRELOAD-HINT":break;case"PROGRAM-DATE-TIME":t.dataTime=b;break;case"EXTINF":{if(r.lowLatency){d=0;break}var U=b.split(","),N=xe(U,2),F=N[0],G=N[1];t.start=s,t.duration=parseFloat(F),s+=t.duration,t.title=G}break;case"KEY":{var M=Ke(b);if(M.METHOD==="NONE"){a=null;break}if(a=new $i,a.method=M.METHOD,a.url=/^blob:/.test(M.URI)?M.URI:Ze(M.URI,o),a.keyFormat=M.KEYFORMAT||"identity",a.keyFormatVersions=M.KEYFORMATVERSIONS,!a.isSupported())throw new Error("encrypt ".concat(M.METHOD,"/").concat(M.KEYFORMAT," is not supported"));if(M.IV){var X=M.IV.slice(2);X=(X.length&1?"0":"")+X,a.iv=new Uint8Array(X.length/2);for(var m=0,g=X.length/2;m<g;m++)a.iv[m]=parseInt(X.slice(m*2,m*2+2),16)}}break;case"MAP":{var _=Ke(b);t.url=Ze(_.URI,o),_.BYTERANGE&&t.setByteRange(_.BYTERANGE),t.isInitSegment=!0,t.sn=0,a&&(t.key=a.clone(0)),n=t,t=new bt}break}}}r.segments=r.segments.filter(function(w){return w.duration!==0});var D=r.segments[r.segments.length-1];return D&&(r.endSN=D.sn,r.endPartIndex=D.partIndex),r.totalDuration=s,r.endCC=l,r}var St=function(){function i(){he(this,i)}return de(i,null,[{key:"parse",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0;if(!e.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var n=Xi(e);return i.isMediaPlaylist(e)?Ji(n,r,t):Qi(n,r)}},{key:"isMediaPlaylist",value:function(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}]),i}(),Zi=function(){function i(o){var e=this;he(this,i),T(this,"_emitOnLoaded",function(u,l){var f=u.response,c=u.options,v=c||{},d=v.firstByteTime,p=v.startTime,y=v.endTime,h=v.contentLength,b=y-p;e.hls.emit(V.SPEED,{time:b,byteLength:h,url:l}),e.hls.emit(V.LOAD_COMPLETE,{url:l,elapsed:b||0}),e.hls.emit(V.TTFB,{url:l,responseUrl:f.url,elapsed:d-p}),e.hls.emit(V.LOAD_RESPONSE_HEADERS,{headers:f.headers,url:l})}),T(this,"_onLoaderRetry",function(u,l){e.hls.emit(ee.LOAD_RETRY,{error:re.network(u),retryTime:l})}),this.hls=o,this._timer=null,this._useLowLatency=o.config.useLowLatency;var r=this.hls.config,t=r.retryCount,n=r.retryDelay,a=r.manifestLoadTimeout,s=r.fetchOptions;this._loader=new ze(le(le({},s),{},{responseType:"text",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry})),this._audioLoader=new ze(le(le({},s),{},{responseType:"text",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry})),this._subtitleLoader=new ze(le(le({},s),{},{responseType:"text",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry}))}return de(i,[{key:"load",value:function(){var o=Z(B().mark(function r(t,n,a){var s,u,l,f,c,v,d,p,y,h,b,S,E,A,k,U,N,F,G,M;return B().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=[this._loader.load(t)],n&&s.push(this._audioLoader.load(n)),a&&s.push(this._subtitleLoader.load(a)),m.prev=3,m.next=6,Promise.all(s);case 6:if(p=m.sent,y=xe(p,3),h=y[0],b=y[1],S=y[2],h){m.next=13;break}return m.abrupt("return",[]);case 13:this._emitOnLoaded(h,t),u=h.data,c=h.response.url||t,n?(l=b?.data,f=S?.data,v=(b==null||(E=b.response)===null||E===void 0?void 0:E.url)||n,d=(S==null||(A=S.response)===null||A===void 0?void 0:A.url)||a,l&&this._emitOnLoaded(b,n),f&&this._emitOnLoaded(S,a)):(f=b?.data,d=(b==null||(k=b.response)===null||k===void 0?void 0:k.url)||a,f&&this._emitOnLoaded(b,a)),m.next=22;break;case 19:throw m.prev=19,m.t0=m.catch(3),re.network(m.t0);case 22:if(U=this.hls.config.onPreM3U8Parse,m.prev=23,U&&(u=U(u)||u,l&&(l=U(l,!0)||l),f&&(f=U(f,!0)||f)),N=St.parse(u,c,this._useLowLatency),!(((M=N)===null||M===void 0?void 0:M.live)===!1&&N.segments&&!N.segments.length)){m.next=28;break}throw new Error("empty segments list");case 28:l&&(F=St.parse(l,v,this._useLowLatency)),f&&(G=St.parse(f,d,this._useLowLatency)),m.next=35;break;case 32:throw m.prev=32,m.t1=m.catch(23),new re(Y.MANIFEST,Y.SUB_TYPES.HLS,m.t1);case 35:return N&&(N.isMaster?this.hls.emit(ee.HLS_MANIFEST_LOADED,{playlist:N}):this.hls.emit(ee.HLS_LEVEL_LOADED,{playlist:N})),m.abrupt("return",[N,F,G]);case 37:case"end":return m.stop()}},r,this,[[3,19],[23,32]])}));function e(r,t,n){return o.apply(this,arguments)}return e}()},{key:"parseText",value:function(e,r){var t=this.hls.config.onPreM3U8Parse,n;try{var a;if(t&&(e=t(e)||e),n=St.parse(e,r,this._useLowLatency),((a=n)===null||a===void 0?void 0:a.live)===!1&&n.segments&&!n.segments.length)throw new Error("empty segments list")}catch(s){throw new re(Y.MANIFEST,Y.SUB_TYPES.HLS,s)}return n&&(n.isMaster?this.hls.emit(ee.HLS_MANIFEST_LOADED,{playlist:n}):this.hls.emit(ee.HLS_LEVEL_LOADED,{playlist:n})),[n]}},{key:"poll",value:function(e,r,t,n,a,s){var u=this;clearTimeout(this._timer),s=s||3e3;var l=this.hls.config.pollRetryCount,f=function(){var c=Z(B().mark(function v(){var d;return B().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return clearTimeout(u._timer),y.prev=1,y.next=4,u.load(e,r,t);case 4:if(d=y.sent,d[0]){y.next=7;break}return y.abrupt("return");case 7:l=u.hls.config.pollRetryCount,n(d[0],d[1],d[2]),y.next=15;break;case 11:y.prev=11,y.t0=y.catch(1),l--,l<=0&&a(y.t0);case 15:u._timer=setTimeout(f,s);case 16:case"end":return y.stop()}},v,null,[[1,11]])}));return function(){return c.apply(this,arguments)}}();this._timer=setTimeout(f,s)}},{key:"stopPoll",value:function(){return clearTimeout(this._timer),this.cancel()}},{key:"cancel",value:function(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}]),i}();function Sn(i,o,e){return o>e&&(e=o),Math.min(Math.max(i,o),e)}var ar=new be("playlist"),En=function(){function i(o,e,r){he(this,i),T(this,"live",void 0),T(this,"id",0),T(this,"bitrate",0),T(this,"width",0),T(this,"height",0),T(this,"name",""),T(this,"url",""),T(this,"audioCodec",""),T(this,"videoCodec",""),T(this,"textCodec",""),T(this,"startCC",0),T(this,"endCC",0),T(this,"startSN",0),T(this,"endSN",-1),T(this,"totalDuration",0),T(this,"targetDuration",0),T(this,"partTargetDuration",0),T(this,"canSkipUntil",0),T(this,"canSkipDateRanges",!1),T(this,"skippedSegments",0),T(this,"canBlockReload",!1),T(this,"partHoldBack",0),T(this,"lowLatency",!1),T(this,"endPartIndex",0),T(this,"snDiff",null),T(this,"segments",[]),T(this,"audioStreams",[]),T(this,"subtitleStreams",[]),T(this,"closedCaptions",[]),T(this,"currentAudioStream",null),T(this,"currentSubtitleStream",null),this.update(this._setLLPlaybackPoint(o),e,r)}return de(i,[{key:"lastSegment",get:function(){return this.segments.length?this.segments[this.segments.length-1]:null}},{key:"segmentDuration",get:function(){var e;return this.targetDuration||((e=this.segments[0])===null||e===void 0?void 0:e.duration)||0}},{key:"liveEdge",get:function(){return this.endTime}},{key:"endTime",get:function(){var e;return((e=this.lastSegment)===null||e===void 0?void 0:e.end)||0}},{key:"currentSubtitleEndSn",get:function(){var e;return((e=this.currentSubtitleStream)===null||e===void 0?void 0:e.endSN)||0}},{key:"clearOldSegment",value:function(e,r){return this.currentAudioStream&&this._clearSegments(e,r),this._clearSegments(e,r)}},{key:"getAudioSegment",value:function(e){if(!(!e||!this.currentAudioStream)){var r=e.sn-this.snDiff;return this.currentAudioStream.segments.find(function(t){return t.sn===r})}}},{key:"update",value:function(e,r){this.url=e.url,Array.isArray(e.segments)?((this.live===null||this.live===void 0)&&(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,this.lowLatency=e.lowLatency,this.canBlockReload=e.canBlockReload,this.canSkipDateRanges=e.canSkipDateRanges,this.canSkipUntil=e.canSkipUntil,this.partHoldBack=e.partHoldBack,this.partTargetDuration=e.partTargetDuration,this.skippedSegments=e.skippedSegments,this.endPartIndex=e.endPartIndex,r&&this.currentAudioStream&&Array.isArray(r.segments)&&(this._updateSegments(r,this.currentAudioStream),(this.snDiff===null||this.snDiff===void 0)&&e.segments.length&&r.segments.length&&(this.snDiff=e.segments[0].sn-r.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find(function(t){return t.default})||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find(function(t){return t.default})||this.subtitleStreams[0]))}},{key:"updateSubtitle",value:function(e){var r=this;if(e&&this.currentSubtitleStream&&Array.isArray(e.segments)){var t=this._updateSegments(e,this.currentSubtitleStream),n=this.currentSubtitleStream.segments;if(n.length>100&&(this.currentSubtitleStream.segments=n.slice(100)),!!t)return t.map(function(a){return{sn:a.sn,url:a.url,duration:a.duration,start:a.start,end:a.end,lang:r.currentSubtitleStream.lang}})}}},{key:"switchSubtitle",value:function(e){var r=this.subtitleStreams.find(function(n){return n.lang===e}),t=this.currentSubtitleStream;r&&(this.currentSubtitleStream=r,t.segments=[])}},{key:"_setLLPlaybackPoint",value:function(e){if(!e.lowLatency||!e.segments.length)return e;for(var r=e.totalDuration-e.partHoldBack,t=e.segments,n=0,a=0,s=t.length;a<s;a++)t[a].start<=r&&t[a].independent&&(n=a);var u=t.slice(n),l=0;return u.forEach(function(f){f.start=l,l=f.end}),e.segments=u,e.totalDuration=l,e.startSN=u[0].sn,e.startCC=u[0].cc,ar.log("set ll-hls playback point: SN=".concat(e.startSN," partIndex=").concat(u[0].partIndex,", duration=").concat(l)),e}},{key:"_clearSegments",value:function(e,r){for(var t=0,n=this.segments,a=0,s=n.length;a<s;a++)if(n[a].end>=e){t=a;break}return t>r&&(t=r),t&&(this.segments=this.segments.slice(t),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(t))),r-t}},{key:"_updateSegments",value:function(e,r){var t=r.segments;if(this.live){var n,a=e.lowLatency,s=t[t.length-1],u=(n=s?.sn)!==null&&n!==void 0?n:-1,l=s?.partIndex||0,f=u<e.endSN&&e.segments.length;if(a&&(f=f||l<e.endPartIndex),f){ar.log("update segments: endSN:".concat(u,", partIndex:").concat(l," --> endSN:").concat(e.endSN,", partIndex:").concat(e.endPartIndex));var c=e.segments.findIndex(function(h){return h.sn===u&&h.partIndex===l}),v=c<0?e.segments:e.segments.slice(c+1);if(t.length&&v.length){var d=s.end,p=d;v.forEach(function(h){h.start=d,d=h.end}),ar.log("liveEdge: ".concat(p," -> ").concat(d));var y=s?.cc||-1;y>v[0].cc&&v.forEach(function(h){return h.cc+=y})}return r.endSN=e.endSN,r.segments=t.concat(v),v}}else r.segments=e.segments}}]),i}(),ea=function(){function i(o){he(this,i),T(this,"streams",[]),T(this,"currentStream",null),T(this,"dvrWindow",0),T(this,"_segmentPointer",-1),this.hls=o}return de(i,[{key:"lowLatency",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.lowLatency}},{key:"lastSegment",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.lastSegment}},{key:"currentSegment",get:function(){var e;return(e=this.currentSegments)===null||e===void 0?void 0:e[this._segmentPointer]}},{key:"nextSegment",get:function(){var e;return(e=this.currentSegments)===null||e===void 0?void 0:e[this._segmentPointer+1]}},{key:"currentSegments",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.segments}},{key:"currentSubtitleEndSn",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.currentSubtitleEndSn}},{key:"liveEdge",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.liveEdge}},{key:"totalDuration",get:function(){var e;return((e=this.currentStream)===null||e===void 0?void 0:e.totalDuration)||0}},{key:"seekRange",get:function(){var e=this.currentSegments;if(!(!e||!e.length))return[e[0].start,e[e.length-1].end]}},{key:"nbSegments",get:function(){var e;return((e=this.currentSegments)===null||e===void 0?void 0:e.length)||0}},{key:"isEmpty",get:function(){var e;return!((e=this.currentSegments)!==null&&e!==void 0&&e.length)}},{key:"isLive",get:function(){var e;return(e=this.currentStream)===null||e===void 0?void 0:e.live}},{key:"hadSegmentLoaded",get:function(){return this._segmentPointer!==-1}},{key:"hasSubtitle",get:function(){var e;return!!((e=this.currentStream)!==null&&e!==void 0&&e.currentSubtitleStream)}},{key:"getAudioSegment",value:function(e){var r;return(r=this.currentStream)===null||r===void 0?void 0:r.getAudioSegment(e)}},{key:"moveSegmentPointer",value:function(e){var r;e==null&&(e=this._segmentPointer+1),this._segmentPointer=Sn(e,-1,(r=this.currentSegments)===null||r===void 0?void 0:r.length)}},{key:"reset",value:function(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}},{key:"getSegmentByIndex",value:function(e){var r;return(r=this.currentSegments)===null||r===void 0?void 0:r[e]}},{key:"setNextSegmentByIndex",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this._segmentPointer=e-1}},{key:"findSegmentIndexByTime",value:function(e){var r=this.currentSegments;if(r){for(var t=0,n=r.length,a;t<n;t++)if(a=r[t],e>=a.start&&e<a.end)return t;var s=r[r.length-1];if(Math.abs(e-s?.end)<.2)return r.length-1}}},{key:"upsertPlaylist",value:function(e,r,t){var n=this;if(e){if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter(function(l){return l.url}).forEach(function(l,f){n.streams[f]?n.streams[f].update(l):n.streams[f]=new En(l)}),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){var a=this.currentStream;if(a){a.update(e,r,t);var s=a.updateSubtitle(t);s&&this.hls.emit(ee.SUBTITLE_SEGMENTS,{list:s})}else this.reset(),this.currentStream=this.streams[0]=new En(e,r,t)}var u=this.currentStream;u&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce(function(l,f){return l+=f.duration,l},0))}}},{key:"switchSubtitle",value:function(e){var r;(r=this.currentStream)===null||r===void 0||r.switchSubtitle(e)}},{key:"clearOldSegment",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:50,r=this.currentStream;if(!(!this.dvrWindow||!r)){var t=r.endTime-this.dvrWindow;if(!(t<=0)){var n=r.segments;n.length<=e||(this._segmentPointer=r.clearOldSegment(t,this._segmentPointer))}}}},{key:"checkSegmentTrackChange",value:function(e,r){var t=this.findSegmentIndexByTime(e),n=this.getSegmentByIndex(t);if(n&&!(!n.hasAudio&&!n.hasVideo)){if(r!==2&&n.hasAudio&&n.hasVideo)return n;if(!(n.end-e>.3)){var a=this.getSegmentByIndex(t+1);if(a&&!(!a.hasAudio&&!a.hasVideo)&&(a.hasAudio!==n.hasAudio||a.hasVideo!==n.hasVideo))return a}}}}]),i}(),ta=function(){function i(o){var e=this;he(this,i),T(this,"error",null),T(this,"_emitOnLoaded",function(u,l){var f=u.data,c=u.response,v=u.options,d=v||{},p=d.firstByteTime,y=d.startTime,h=d.endTime,b=d.contentLength,S=h-y;e._bandwidthService.addRecord(b||f.byteLength,S),e.hls.emit(V.SPEED,{time:S,byteLength:b,url:l}),e.hls.emit(V.LOAD_COMPLETE,{url:l,elapsed:S||0}),e.hls.emit(V.TTFB,{url:l,responseUrl:c.url,elapsed:p-y}),e.hls.emit(V.LOAD_RESPONSE_HEADERS,{headers:c.headers,url:l})}),T(this,"_onLoaderRetry",function(u,l){e.hls.emit(V.LOAD_RETRY,{error:re.network(u),retryTime:l})}),this.hls=o,this._bandwidthService=new Mr,this._mapCache={},this._keyCache={};var r=this.hls.config,t=r.retryCount,n=r.retryDelay,a=r.loadTimeout,s=r.fetchOptions;this._segmentLoader=new ze(le(le({},s),{},{responseType:"arraybuffer",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry})),this._audioSegmentLoader=new ze(le(le({},s),{},{responseType:"arraybuffer",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry})),this._keyLoader=new ze(le(le({},s),{},{responseType:"arraybuffer",retry:t,retryDelay:n,timeout:a,onRetryError:this._onLoaderRetry}))}return de(i,[{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"load",value:function(e,r,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:t,a=[];return e&&(a[0]=this.loadVideoSegment(e,t)),r&&(a[1]=this.loadAudioSegment(r,n)),Promise.all(a)}},{key:"loadVideoSegment",value:function(e,r){return this._loadSegment(this._segmentLoader,e,r)}},{key:"loadAudioSegment",value:function(e,r){return this._loadSegment(this._audioSegmentLoader,e,r)}},{key:"_loadSegment",value:function(){var o=Z(B().mark(function r(t,n,a){var s=this,u,l,f,c,v,d,p,y,h,b,S,E,A,k,U;return B().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return p=[],this.hls.emit(V.LOAD_START,{url:n.url}),p[0]=t.load(n.url),a&&n.initSegment&&(h=n.initSegment.url,l=this._mapCache[h],l||(this.hls.emit(V.LOAD_START,{url:h}),p[1]=t.load(h).then(function(G){if(G){var M=Object.keys(s._mapCache);M>30&&(s._mapCache={}),l=s._mapCache[h]=G.data,s._emitOnLoaded(G,h)}})),b=(y=n.initSegment.key)===null||y===void 0?void 0:y.url,b&&(d=n.initSegment.key.iv,v=this._keyCache[b],v||(this.hls.emit(V.LOAD_START,{url:b}),p[2]=this._keyLoader.load(b).then(function(G){G&&(v=s._keyCache[b]=G.data,s._emitOnLoaded(G,b))})))),S=(u=n.key)===null||u===void 0?void 0:u.url,S&&n.key.isSegmentEncrypted()&&(c=n.key.iv,f=this._keyCache[S],f||(this.hls.emit(V.LOAD_START,{url:S}),p[3]=this._keyLoader.load(S).then(function(G){G&&(f=s._keyCache[S]=G.data,s._emitOnLoaded(G,S))}))),F.next=8,Promise.all(p);case 8:if(E=F.sent,A=xe(E,1),k=A[0],k){F.next=13;break}return F.abrupt("return");case 13:return U=k.data,this._emitOnLoaded(k,n.url),F.abrupt("return",{data:U,map:l,key:f,mapKey:v,keyIv:c,mapKeyIv:d});case 16:case"end":return F.stop()}},r,this)}));function e(r,t,n){return o.apply(this,arguments)}return e}()},{key:"reset",value:function(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}},{key:"cancel",value:function(){var o=Z(B().mark(function r(){return B().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()]);case 2:case"end":return n.stop()}},r,this)}));function e(){return o.apply(this,arguments)}return e}()}]),i}(),De=new be("hls"),Et=function(i){Zt(e,i);var o=tr(e);function e(r){var t;return he(this,e),t=o.call(this),T(q(t),"version",e.version),T(q(t),"media",null),T(q(t),"config",null),T(q(t),"_manifestLoader",null),T(q(t),"_segmentLoader",null),T(q(t),"_playlist",null),T(q(t),"_bufferService",null),T(q(t),"_gapService",null),T(q(t),"_seiService",null),T(q(t),"_stats",null),T(q(t),"_prevSegSn",null),T(q(t),"_prevSegCc",null),T(q(t),"_tickTimer",null),T(q(t),"_tickInterval",500),T(q(t),"_segmentProcessing",!1),T(q(t),"_reloadOnPlay",!1),T(q(t),"_switchUrlOpts",null),T(q(t),"_isProcessQuotaExceeded",!1),T(q(t),"_loadSegment",Z(B().mark(function n(){var a,s,u,l,f;return B().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!(t._segmentProcessing||!t.media)){v.next=2;break}return v.abrupt("return");case 2:if(a=t._playlist.nextSegment,s=q(t),u=s.config,a){v.next=6;break}return v.abrupt("return");case 6:if(t.isLive){v.next=16;break}if(l=t.bufferInfo(),t.media.paused&&!t.media.currentTime&&(l=t.bufferInfo(l.nextStart||.5)),f=Math.abs(l.end-t.media.duration)<.1,!(l.remaining>=u.preloadTime||f)){v.next=13;break}return f&&t._bufferService.msIsOpend&&t._bufferService.endOfStream(),v.abrupt("return");case 13:if(!(u.preferMMSStreaming&&!t._bufferService.msStreaming)){v.next=15;break}return v.abrupt("return");case 15:!t._urlSwitching&&t._prevSegSn!==a.sn-1&&l.end&&Math.abs(a.start-l.end)>1&&t._playlist.setNextSegmentByIndex(t._playlist.findSegmentIndexByTime(l.end+.1));case 16:return v.abrupt("return",t._loadSegmentDirect());case 17:case"end":return v.stop()}},n)}))),T(q(t),"_onPlay",Z(B().mark(function n(){return B().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(t.media.seeking&&t.media.currentTime===0)){s.next=3;break}return De.debug("replay currentTime 0, return"),s.abrupt("return");case 3:if(clearTimeout(t._disconnectTimer),!t._reloadOnPlay){s.next=9;break}t._reloadOnPlay=!1,t.replay(!0),s.next=12;break;case 9:return s.next=11,t._loadSegment();case 11:t._startTick();case 12:case"end":return s.stop()}},n)}))),T(q(t),"_onPause",function(){if(t.isLive){if(!t._reloadOnPlay){var n=t.config.disconnectTime;if(n==null&&(n=t._playlist.dvrWindow),!Number.isFinite(n))return;clearTimeout(t._disconnectTimer),t._disconnectTimer=setTimeout(function(){t._reloadOnPlay=!0,t._clear()},n||0)}}else t._stopTick()}),T(q(t),"_onSeeking",Z(B().mark(function n(){var a,s,u,l,f,c,v;return B().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(t.media){p.next=2;break}return p.abrupt("return");case 2:if(t._onCheckQuotaExceeded(),a=t.media.currentTime,s=t._playlist.seekRange,!s){p.next=10;break}if(u=Sn(a,s[0],t.isLive?s[1]:t.media.duration),!(u>=0&&Math.abs(a-u)>=.1)){p.next=10;break}return t.media.currentTime=u,p.abrupt("return");case 10:if(l=t._playlist.currentSegment,f=oe.info(oe.get(t.media),a,.1),!l){p.next=15;break}if(!(f.end&&Math.abs(f.end-l.end)<.2)){p.next=15;break}return p.abrupt("return");case 15:if(c=t._playlist.findSegmentIndexByTime(a),v=t._playlist.getSegmentByIndex(c),!(c==null||!v||t._segmentProcessing&&v===t._playlist.nextSegment)){p.next=19;break}return p.abrupt("return");case 19:return De.debug("seek to",a,v),t._playlist.setNextSegmentByIndex(c),t._stopTick(),p.next=24,t._segmentLoader.cancel();case 24:if(t._segmentProcessing=!1,!(!f.end||t.isLive)){p.next=28;break}return p.next=28,t._loadSegmentDirect(!0);case 28:t._startTick();case 29:case"end":return p.stop()}},n)}))),T(q(t),"_onTimeupdate",function(){if(t.media){var n=t.config;if(n.isLive&&n.maxLatency&&n.targetLatency&&t.media){var a=t._playlist.liveEdge;if(!a)return;var s=a-t.media.currentTime;s>=n.maxLatency&&(De.debug("latency jump, currentTime:".concat(t.media.currentTime,", liveEdge:").concat(a,", latency=").concat(s)),t.media.currentTime=a-n.targetLatency)}if(n.seiInTime){var u;(u=t._seiService)===null||u===void 0||u.throw(t.media.currentTime)}t.config.allowedStreamTrackChange&&!t.config.softDecode&&t._checkStreamTrackChange(t.media.currentTime)}}),T(q(t),"_tick",function(){if(t.media){t._startTick();var n=t.media,a=oe.get(n),s=t._segmentLoader.error;if(t._onCheckQuotaExceeded(),t._isProcessQuotaExceeded&&(t._bufferService.isFull()||(t._isProcessQuotaExceeded=!1,t._segmentProcessing=!1)),s){var u=.5;(!n.readyState||t.bufferInfo(u).remaining<1)&&(s.fatal=!0,t._emitError(re.network(s)));return}oe.end(a)<.1||!n.readyState||(Pr(n)?(t._loadSegment(),t._gapService&&t._gapService.do(n,t.config.maxJumpDistance,t.isLive)):n.readyState<2&&t._gapService&&t._gapService.do(n,t.config.maxJumpDistance,n.currentTime?t.isLive:!0))}}),t.config=r=Fi(r),t.media=t.config.media,t._manifestLoader=new Zi(q(t)),t._segmentLoader=new ta(q(t)),t._playlist=new ea(q(t)),t._bufferService=new Ni(q(t)),r.seiInTime&&(t._seiService=new Cr(q(t))),r.softDecode||(t._gapService=new Ir),t._stats=new xr(q(t),9e4),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("pause",t._onPause),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t}return de(e,[{key:"isLive",get:function(){return this._playlist.isLive}},{key:"streams",get:function(){return this._playlist.streams}},{key:"currentStream",get:function(){return this._playlist.currentStream}},{key:"hasSubtitle",get:function(){return this._playlist.hasSubtitle}},{key:"baseDts",get:function(){var t;return(t=this._bufferService)===null||t===void 0?void 0:t.baseDts}},{key:"speedInfo",value:function(){return this._segmentLoader.speedInfo()}},{key:"bufferInfo",value:function(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.1;return oe.info(oe.get(this.media),(t=this.media)===null||t===void 0?void 0:t.currentTime,n)}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"playbackQuality",value:function(){return Rr(this.media)}},{key:"load",value:function(){var r=Z(B().mark(function n(a){var s,u=arguments;return B().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return s=u.length>1&&u[1]!==void 0?u[1]:!1,a&&(this.config.url=a),a=this.config.url,f.next=5,this._reset(s);case 5:return f.next=7,this._loadData(a);case 7:this._startTick();case 8:case"end":return f.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"_loadData",value:function(){var r=Z(B().mark(function n(a){var s,u,l,f,c,v,d,p,y,h;return B().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:try{a&&(a=a.trim())}catch{}if(a){S.next=3;break}throw this._emitError(new re(Y.OTHER,Y.SUB_TYPES.OPTION,null,null,"m3u8 url is missing"));case 3:return S.next=5,this._loadM3U8(a);case 5:if(s=S.sent,u=this._playlist.currentStream,!this._urlSwitching){S.next=17;break}if(u.bitrate===0&&(l=this._switchUrlOpts)!==null&&l!==void 0&&l.bitrate&&(u.bitrate=(f=this._switchUrlOpts)===null||f===void 0?void 0:f.bitrate),c=this._getSeamlessSwitchPoint(),this.config.startTime=c,v=this._playlist.findSegmentIndexByTime(c),d=this._playlist.getSegmentByIndex(v+1),!d){S.next=17;break}return p=d.start,S.next=17,this._bufferService.removeBuffer(p);case 17:if(s){S.next=19;break}return S.abrupt("return");case 19:if(!this.isLive){S.next=30;break}if(this._bufferService.setLiveSeekableRange(0,4294967295),De.log("totalDuration first time got:",this._playlist.totalDuration),De.log("nb segments got:",this._playlist.nbSegments),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),s.isMaster||this._pollM3U8(a),!(this._playlist.nbSegments<this.config.minSegmentsStartPlay)){S.next=27;break}return S.abrupt("return");case 27:return S.next=29,this._loadSegment();case 29:return S.abrupt("return");case 30:return S.next=32,this._bufferService.updateDuration(u.totalDuration);case 32:return y=this.config.startTime,y&&((h=this._switchUrlOpts)!==null&&h!==void 0&&h.seamless||(this.media.currentTime=y),this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(y)||0)),S.next=36,this._loadSegment();case 36:case"end":return S.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"replay",value:function(){var r=Z(B().mark(function n(a){return B().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.config.startTime=0,u.next=3,this.load();case 3:return this._reloadOnPlay=!1,u.abrupt("return",this.media.play(!a));case 5:case"end":return u.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"switchURL",value:function(){var r=Z(B().mark(function n(a){var s,u,l,f,c,v,d,p=arguments;return B().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:s=p.length>1&&p[1]!==void 0?p[1]:{},u={seamless:!1,startTime:0,bitrate:0},h.t0=Jt(s),h.next=h.t0==="number"?5:h.t0==="boolean"?7:h.t0==="object"?9:11;break;case 5:return s={startTime:s},h.abrupt("break",12);case 7:return s={seamless:s},h.abrupt("break",12);case 9:for(l in s)(s[l]===void 0||s[l]===null)&&delete s[l];return h.abrupt("break",12);case 11:throw"unsupported switchURL args: ".concat(s);case 12:if(s=Object.assign({},u,s),f=s,c=f.seamless,v=f.startTime,this.config.url=a,this.config.startTime=v,this._switchUrlOpts=s,c){h.next=38;break}if(h.prev=18,!this.config.softDecode){h.next=23;break}h.t1=this.load(a),h.next=26;break;case 23:return h.next=25,this.load(a);case 25:h.t1=h.sent;case 26:d=h.t1,h.next=33;break;case 29:throw h.prev=29,h.t2=h.catch(18),this.emit(ee.SWITCH_URL_FAILED,h.t2),h.t2;case 33:return this._reloadOnPlay=!1,d&&this.emit(ee.SWITCH_URL_SUCCESS,{url:a}),h.abrupt("return",this.media.play(!0));case 38:return this._urlSwitching=!0,this._prevSegSn=null,this._prevSegCc=null,this._playlist.reset(),this._bufferService.seamlessSwitch(),h.next=45,this._clear();case 45:return h.next=47,this._loadData(a);case 47:this._startTick();case 48:this._switchUrlOpts=null;case 49:case"end":return h.stop()}},n,this,[[18,29]])}));function t(n){return r.apply(this,arguments)}return t}()},{key:"switchStream",value:function(){var r=Z(B().mark(function n(a){var s,u,l,f,c,v=arguments;return B().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(s=v.length>1&&v[1]!==void 0?v[1]:!0,u=this.currentStream,l=this.streams,!(!u||u.id===a||!l||l.length<2)){p.next=5;break}return p.abrupt("return");case 5:if(f=l.find(function(y){return y.id===a}),f){p.next=8;break}return p.abrupt("return");case 8:return p.prev=8,p.next=11,this._clear();case 11:if(!s){p.next=14;break}return p.next=14,this._bufferService.clearAllBuffer();case 14:p.next=19;break;case 16:throw p.prev=16,p.t0=p.catch(8),this._emitError(re.create(p.t0));case 19:if(u.currentAudioStream&&f.audioStreams.length>2&&(c=u.currentAudioStream.id,f.currentAudioStream=f.audioStreams.find(function(y){return y.id===c})||f.currentAudioStream),this._playlist.currentStream=f,p.prev=21,!(this.isLive||!f.segments.length)){p.next=25;break}return p.next=25,this._refreshM3U8();case 25:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,p.next=29,this._loadSegmentDirect();case 29:p.next=35;break;case 31:throw p.prev=31,p.t1=p.catch(21),this._playlist.currentStream=u,p.t1;case 35:return this._startTick(),p.abrupt("return",f);case 37:case"end":return p.stop()}},n,this,[[8,16],[21,31]])}));function t(n){return r.apply(this,arguments)}return t}()},{key:"switchAudioStream",value:function(){var r=Z(B().mark(function n(a){var s,u,l,f,c=arguments;return B().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(s=c.length>1&&c[1]!==void 0?c[1]:!0,u=this.currentStream,u){d.next=4;break}return d.abrupt("return");case 4:if(l=u.currentAudioStream,!(!l||l.id===a||u.audioStreams.length<2)){d.next=7;break}return d.abrupt("return");case 7:if(f=u.audioStreams.find(function(p){return p.id===a}),f){d.next=10;break}return d.abrupt("return");case 10:return d.prev=10,d.next=13,this._clear();case 13:if(!s){d.next=16;break}return d.next=16,this._bufferService.clearAllBuffer();case 16:d.next=21;break;case 18:throw d.prev=18,d.t0=d.catch(10),this._emitError(re.create(d.t0));case 21:if(u.currentAudioStream=f,d.prev=22,!(this.isLive||!f.segments.length)){d.next=26;break}return d.next=26,this._refreshM3U8();case 26:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,d.next=30,this._loadSegmentDirect();case 30:d.next=36;break;case 32:throw d.prev=32,d.t1=d.catch(22),u.currentAudioStream=l,d.t1;case 36:return this._startTick(),d.abrupt("return",f);case 38:case"end":return d.stop()}},n,this,[[10,18],[22,32]])}));function t(n){return r.apply(this,arguments)}return t}()},{key:"switchSubtitleStream",value:function(){var r=Z(B().mark(function n(a){return B().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this._playlist.switchSubtitle(a),u.next=3,this._manifestLoader.stopPoll();case 3:return u.next=5,this._refreshM3U8();case 5:case"end":return u.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"destroy",value:function(){var r=Z(B().mark(function n(){var a;return B().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.media){u.next=2;break}return u.abrupt("return");case 2:return this.removeAllListeners(),this._playlist.reset(),this._segmentLoader.reset(),(a=this._seiService)===null||a===void 0||a.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("pause",this._onPause),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),u.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null;case 13:case"end":return u.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_loadM3U8",value:function(){var r=Z(B().mark(function n(a){var s,u,l,f,c,v,d;return B().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(y.prev=0,f=(u=this.config.manifestList)===null||u===void 0||(l=u.filter(function(h){return h.url===a})[0])===null||l===void 0?void 0:l.manifest,!f){y.next=6;break}y.t0=this._manifestLoader.parseText(f,a),y.next=9;break;case 6:return y.next=8,this._manifestLoader.load(a);case 8:y.t0=y.sent;case 9:c=y.t0,v=xe(c,1),s=v[0],y.next=17;break;case 14:throw y.prev=14,y.t1=y.catch(0),this._emitError(re.create(y.t1));case 17:if(s){y.next=19;break}return y.abrupt("return");case 19:if(this._playlist.upsertPlaylist(s),!s.isMaster){y.next=24;break}return(d=this._playlist.currentStream.subtitleStreams)!==null&&d!==void 0&&d.length&&this.emit(ee.SUBTITLE_PLAYLIST,{list:this._playlist.currentStream.subtitleStreams}),y.next=24,this._refreshM3U8();case 24:return this.emit(ee.STREAM_PARSED),y.abrupt("return",s);case 26:case"end":return y.stop()}},n,this,[[0,14]])}));function t(n){return r.apply(this,arguments)}return t}()},{key:"_refreshM3U8",value:function(){var t,n,a=this,s=this._playlist.currentStream;if(!s||!s.url)throw this._emitError(re.create(null,null,new Error("m3u8 url is not defined")));var u=s.url,l=(t=s.currentAudioStream)===null||t===void 0?void 0:t.url,f=(n=s.currentSubtitleStream)===null||n===void 0?void 0:n.url;return this._manifestLoader.load(u,l,f).then(function(c){var v=xe(c,3),d=v[0],p=v[1],y=v[2];d&&(a._playlist.upsertPlaylist(d,p,y),a.isLive&&a._pollM3U8(u,l,f))}).catch(function(c){throw a._emitError(re.create(c))})}},{key:"_pollM3U8",value:function(t,n,a){var s=this,u=this._playlist.isEmpty,l;if(this._playlist.lowLatency)l=(this._playlist.currentStream.partTargetDuration*2||0)*1e3;else{var f;l=(((f=this._playlist.lastSegment)===null||f===void 0?void 0:f.duration)||0)*1e3}this._manifestLoader.poll(t,n,a,function(c,v,d){s._playlist.upsertPlaylist(c,v,d),s._playlist.clearOldSegment();var p=c&&u&&!s._playlist.isEmpty;(p||!s._playlist.hadSegmentLoaded&&s._playlist.nbSegments>=s.config.minSegmentsStartPlay)&&s._loadSegment(),u&&(u=s._playlist.isEmpty)},function(c){s._emitError(re.create(c))},l)}},{key:"_loadSegmentDirect",value:function(){var r=Z(B().mark(function n(a){var s,u,l;return B().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=this._playlist.nextSegment,s){c.next=3;break}return c.abrupt("return");case 3:return u=!1,l=null,c.prev=5,this._segmentProcessing=!0,De.log("load segment, sn:".concat(s.sn,", partIndex:").concat(s.partIndex)),c.next=10,this._reqAndBufferSegment(s,this._playlist.getAudioSegment(s));case 10:u=c.sent,c.next=16;break;case 13:c.prev=13,c.t0=c.catch(5),l=c.t0;case 16:return c.prev=16,this._segmentProcessing=!1,c.finish(16);case 19:if(!l){c.next=26;break}if(!this._bufferService.isFull()){c.next=25;break}return De.log("load segment, sn:".concat(s.sn,", partIndex:").concat(s.partIndex)),this._segmentProcessing=!0,this._isProcessQuotaExceeded=!0,c.abrupt("return",!1);case 25:return c.abrupt("return",this._emitError(re.create(l)));case 26:return u&&(this._urlSwitching&&(this._urlSwitching=!1,this.emit(ee.SWITCH_URL_SUCCESS,{url:this.config.url})),this._playlist.moveSegmentPointer(),s.isLast?this._end():a||this._loadSegment()),c.abrupt("return",u);case 28:case"end":return c.stop()}},n,this,[[5,13,16,19]])}));function t(n){return r.apply(this,arguments)}return t}()},{key:"_reqAndBufferSegment",value:function(){var r=Z(B().mark(function n(a,s){var u,l,f,c,v,d,p,y,h;return B().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return l=a?a.cc:s.cc,f=this._prevSegCc!==l,c=[],S.prev=3,S.next=6,this._segmentLoader.load(a,s,f);case 6:c=S.sent,S.next=14;break;case 9:throw S.prev=9,S.t0=S.catch(3),S.t0.fatal=!1,this._segmentLoader.error=S.t0,S.t0;case 14:if(c[0]){S.next=16;break}return S.abrupt("return");case 16:return S.next=18,(u=this._bufferService).decryptBuffer.apply(u,Li(c));case 18:if(v=S.sent,v){S.next=21;break}return S.abrupt("return");case 21:return d=a?a.sn:s.sn,p=a?a.start:s.start,y=this._playlist.currentStream,this._bufferService.createSource(v[0],v[1],y?.videoCodec,y?.audioCodec),h=Date.now(),S.next=28,this._bufferService.appendBuffer(a,s,v[0],v[1],f,this._prevSegSn===d-1,p);case 28:return this.emit(ee.APPEND_COST,{elapsed:Date.now()-h,url:a.url}),S.next=31,this._bufferService.evictBuffer(this.config.bufferBehind);case 31:return this._prevSegCc=l,this._prevSegSn=d,S.abrupt("return",!0);case 34:case"end":return S.stop()}},n,this,[[3,9]])}));function t(n,a){return r.apply(this,arguments)}return t}()},{key:"_onCheckQuotaExceeded",value:function(){var r=Z(B().mark(function n(){var a,s,u,l,f,c;return B().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:a=this.media.currentTime,s=this.media.buffered,u=!1,l=0;case 4:if(!(l<s.length)){d.next=11;break}if(!(s.start(0)>=a&&a<s.end(l))){d.next=8;break}return u=!0,d.abrupt("break",11);case 8:l++,d.next=4;break;case 11:if(!this._bufferService.isFull()){d.next=17;break}if(f=u?this.config.bufferBehind:5,c=this.media.currentTime,!(c-f>0)){d.next=17;break}return d.next=17,this._bufferService.removeBuffer(0,c-f);case 17:case"end":return d.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_checkStreamTrackChange",value:function(t){var n=this._playlist.checkSegmentTrackChange(t,this._bufferService.nbSb);n&&this.switchURL(this.config.url,n.start+.2)}},{key:"_clear",value:function(){var r=Z(B().mark(function n(){return B().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return clearTimeout(this._disconnectTimer),this._stopTick(),s.next=4,Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]);case 4:this._segmentProcessing=!1;case 5:case"end":return s.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_reset",value:function(){var r=Z(B().mark(function n(){var a,s,u=arguments;return B().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return s=u.length>0&&u[0]!==void 0?u[0]:!1,this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),(a=this._seiService)===null||a===void 0||a.reset(),this._stats.reset(),f.next=11,this._clear();case 11:return f.abrupt("return",this._bufferService.reset(s));case 12:case"end":return f.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_end",value:function(){this._clear(),this._bufferService.endOfStream(),(this.media.readyState<=2||this.media.buffered.length>1)&&this._startTick()}},{key:"_stopTick",value:function(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}},{key:"_startTick",value:function(){this._stopTick(),this._tickTimer=setTimeout(this._tick,this._tickInterval)}},{key:"_emitError",value:function(t){var n,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(((n=t.originError)===null||n===void 0?void 0:n.fatal)===!1)De.warn(t);else{var s,u,l;De.table(t),De.error(t),De.error((s=this.media)===null||s===void 0?void 0:s.error),(u=this.media)!==null&&u!==void 0&&u.readyState&&this.media.pause(),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(ee.SWITCH_URL_FAILED,t)),this.emit(ee.ERROR,t),a&&this._end(),(l=this._seiService)===null||l===void 0||l.reset()}return t}},{key:"_getSeamlessSwitchPoint",value:function(){var t=this.media,n=t.currentTime;if(!t.paused){var a,s=this._playlist.findSegmentIndexByTime(t.currentTime),u=this._playlist.getSegmentByIndex(s),l=(a=this._stats)===null||a===void 0?void 0:a.getStats().downloadSpeed;if(l&&u){var f=u.duration*this._playlist.currentStream.bitrate/l+1;n+=f}else n+=5}return n}}],[{key:"isSupported",value:function(t){return!t||t==="video"||t==="audio"?pe.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){be.enable(),We.enable()}},{key:"disableLogger",value:function(){be.disable(),We.disable()}}]),e}(xi);T(Et,"version","3.0.16");try{localStorage.getItem("xgd")?Et.enableLogger():Et.disableLogger()}catch{}const ra={Flv:Qt,Hls:Et};export{ra as default};
|