lemon-mse 0.2.7 → 0.2.9

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/flv.js CHANGED
@@ -1 +1,6 @@
1
- var e={228:e=>{var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!0}for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var d,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(d=1,u=new Array(h-1);d<h;d++)u[d-1]=arguments[d];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(){s=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,i){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new T(i||[]);return n(s,"_invoke",{value:w(e,r,o)}),s}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d={};function f(){}function p(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,_=m&&m(m(L([])));_&&_!==t&&r.call(_,a)&&(y=_);var g=v.prototype=f.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,a,s,o){var u=h(e[n],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,s,o)}),(function(e){i("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return i("throw",e,s,o)}))}o(u.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function w(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=x(s,r);if(o){if(o===d)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function x(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(l(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=L,T.prototype={constructor:T,reset:function(e){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(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:L(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function o(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function s(e){o(a,n,i,s,u,"next",e)}function u(e){o(a,n,i,s,u,"throw",e)}s(void 0)}))}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function h(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}r.d(n,{N:()=>or});var m=r(228),_=r.n(m);function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach((function(t){O(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(){k=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,i){var a=t&&t.prototype instanceof d?t:d,s=Object.create(a.prototype),o=new T(i||[]);return n(s,"_invoke",{value:w(e,r,o)}),s}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function f(){}function p(){}var v={};u(v,a,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(L([])));m&&m!==t&&r.call(m,a)&&(v=m);var _=p.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function i(n,a,s,o){var u=l(e[n],e,a);if("throw"!==u.type){var c=u.arg,h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,o)}),(function(e){i("throw",e,s,o)})):t.resolve(h).then((function(e){c.value=e,s(c)}),(function(e){return i("throw",e,s,o)}))}o(u.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function w(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=x(s,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function x(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function L(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return f.prototype=p,n(_,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:f,configurable:!0}),f.displayName=u(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,o,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},g(b.prototype),u(b.prototype,s,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new b(c(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(_),u(_,o,"Generator"),u(_,a,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=L,T.prototype={constructor:T,reset:function(e){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(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:L(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(n,i)}function S(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function s(e){x(a,n,i,s,o,"next",e)}function o(e){x(a,n,i,s,o,"throw",e)}s(void 0)}))}}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,F(n.key),n)}}function L(e,t,r){return t&&T(e.prototype,t),r&&T(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function O(e,t,r){return(t=F(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function A(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&D(e,t)}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function P(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function U(e,t,r){return(U=P()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&D(i,r.prototype),i}).apply(null,arguments)}function R(e){var t="function"==typeof Map?new Map:void 0;return R=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return U(e,arguments,C(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),D(n,e)},R(e)}function B(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(e){var t=P();return function(){var r,n=C(e);if(t){var i=C(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return B(e)}(this,r)}}function M(){return M="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=C(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},M.apply(this,arguments)}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function F(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var N={DEBUG:1,LOG:2,WARN:3,ERROR:4},V=["Boolean","Number","String","Undefined","Null","Date","Object"],G=function(){function e(t,r){E(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return L(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[N.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(z(),"]"),this._prefix].concat(n))}},{key:"log",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[N.LOG].concat(n)),e.disabled||(t=console).log.apply(t,["[".concat(z(),"]"),this._prefix].concat(n))}},{key:"warn",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[N.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,["[".concat(z(),"]"),this._prefix].concat(n))}},{key:"error",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[N.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,["[".concat(z(),"]"),this._prefix].concat(n))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=n.map((function(e){return H(e)}));t="[".concat(z(),"]")+this._prefix+JSON.stringify(a)}catch(e){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function z(){return(new Date).toLocaleString()}function q(e){if("object"!==w(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function H(e,t,r){r||(r=1),t||(t=2);var n={};if(!e||"object"!==w(e))return e;var i=Object.prototype.toString.call(e).slice(8,-1);if(!V.includes(i))return i;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?n[a]=q(e[a]):"object"===w(e[a])?n[a]=H(e[a],t,r+1):n[a]=e[a]);return n}}O(G,"disabled",!0);var W,K="core.ttfb",Q="core.metadataparsed",Y="core.sei",J="core.flvscriptdata",Z="core.demuxedtrack",X="core.streamexception",$="real_time_speed",ee="network",te="network_timeout",re="demux",ne="remux",ie="media",ae="other",se="FLV",oe="FMP4",ue="MSE_ADD_SB",ce="MSE_APPEND_BUFFER",le="MSE_OTHER",he="MSE_FULL",de="MSE_CHANGE_TYPE",fe=(O(W={},"manifest",{HLS:1100,DASH:1200}),O(W,ee,2100),O(W,te,2101),O(W,"network_forbidden",2103),O(W,"network_notfound",2104),O(W,"network_range_not_satisfiable",2116),O(W,re,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),O(W,ne,{FMP4:4100,MP4:4200}),O(W,ie,{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,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),O(W,"drm",{LICENSE:7100,CUSTOM_LICENSE:7200}),O(W,ae,8e3),O(W,"runtime",{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),W),pe=function(){A(t,R(Error));var e=I(t);function t(r,n,i,a,s){var o;return E(this,t),(o=e.call(this,s||(null==i?void 0:i.message))).errorType=r===te?ee:r,o.originError=i,o.ext=a,o.errorCode=fe[r][n]||fe[r],o.errorMessage=o.message,o.errorCode||(o.errorType=ae,o.errorCode=fe[o.errorType]),o}return L(t,null,[{key:"create",value:function(e,r,n,i,a){return e instanceof t?e:(e instanceof Error&&(n=e,e=""),e||(e=ae),new t(e,r,n,i,a))}},{key:"network",value:function(e){var r;return new t(null!=e&&e.isTimeout?te:ee,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(r=e.response)||void 0===r?void 0:r.status})}}]),t}(),ve=function(){function e(){E(this,e)}return L(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(e){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(s[1]=u)}else r.push([e.start(n),e.end(n)])}else r.push([e.start(n),e.end(n)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,a=0,s=0,o=0,u=0,c=0,l=0,h=e.buffers(t,n),d=0,f=h.length;d<f;d++){var p=h[d];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=d;else{if(r+n<p[0]){o=p[0],u=p[1];break}r+n>p[1]&&(c=p[0],l=p[1])}}return{start:i,end:a,index:s,buffers:h,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(h)}}},{key:"isBuffered",value:function(t,r){if(t){var n=e.get(t);if(null!=n&&n.length)for(var i=0;i<n.length;i++)if(r>=n.start(i)&&r<=n.end(i))return!0}return!1}}]),e}();function ye(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var _e="fetch",ge="arraybuffer",be="text",ke=function(){A(t,R(Error));var e=I(t);function t(r,n,i,a){var s;return E(this,t),O(B(s=e.call(this,a)),"retryCount",0),O(B(s),"isTimeout",!1),O(B(s),"loaderType",_e),O(B(s),"startTime",0),O(B(s),"endTime",0),O(B(s),"options",{}),s.url=r,s.request=n,s.response=i,s}return L(t)}(),we=Object.prototype.toString;function xe(e){if("[object Object]"!==we.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Se(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function Ee(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Te(e,t){if(e){if(!t)return e;var r,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===we.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===w(e)}(t)&&(t=JSON.stringify(t)),"".concat(Ee(e),"=").concat(Ee(t))})).join("&")})).filter(Boolean).join("&");if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function Le(e,t,r,n,i,a,s,o,u,c,l){return i=null!=i?parseFloat(i):null,n=parseInt(n||"0",10),Number.isNaN(n)&&(n=0),{data:e,done:t,options:{range:u,vid:c,index:o,contentLength:n,age:i,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:l},response:r}}function Oe(e,t){return Math.round(8*e*1e3/t/1024)}var Ae=2097152,Ce=function(){A(r,_());var e,t=I(r);function r(){var e;return E(this,r),O(B(e=t.call(this)),"_abortController",null),O(B(e),"_timeoutTimer",null),O(B(e),"_reader",null),O(B(e),"_response",null),O(B(e),"_aborted",!1),O(B(e),"_index",-1),O(B(e),"_range",null),O(B(e),"_receivedLength",0),O(B(e),"_running",!1),O(B(e),"_logger",null),O(B(e),"_vid",""),O(B(e),"_onProcessMinLen",0),O(B(e),"_onCancel",null),O(B(e),"_priOptions",null),e}return L(r,[{key:"load",value:function(e){var t,r=this,n=e.url,i=e.vid,a=e.timeout,s=e.responseType,o=e.onProgress,u=e.index,c=e.onTimeout,l=e.onCancel,h=e.range,d=e.transformResponse,f=e.request,p=e.params,v=e.logger,y=e.method,m=e.headers,_=e.body,g=e.mode,b=e.credentials,w=e.cache,x=e.redirect,E=e.referrer,T=e.referrerPolicy,L=e.onProcessMinLen,O=e.priOptions;this._logger=v,this._aborted=!1,this._onProcessMinLen=L,this._onCancel=l,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=h||[0,0],this._vid=i||n,this._priOptions=O||{};var A={method:y,headers:m,body:_,mode:g,credentials:b,cache:w,redirect:x,referrer:E,referrerPolicy:T,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},C=!1;clearTimeout(this._timeoutTimer),n=Te(n,p);var D=Se(h);D&&(m=f?f.headers:A.headers=A.headers||(Headers?new Headers:{}),Headers&&m instanceof Headers?m.append("Range",D):m.Range=D),a&&(this._timeoutTimer=setTimeout((function(){if(C=!0,r.cancel(),c){var e=new ke(n,A,null,"timeout");e.isTimeout=!0,c(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var P=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",h),new Promise((function(e,t){fetch(f||n,f?void 0:A).then(function(){var i=S(k().mark((function i(a){var c,l,f,p;return k().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){i.next=4;break}return i.abrupt("return");case 4:if(d&&(a=d(a,n)||a),a.ok){i.next=7;break}throw new ke(n,A,a,"bad network response");case 7:if(c=Date.now(),s!==be){i.next=15;break}return i.next=11,a.text();case 11:l=i.sent,r._running=!1,i.next=37;break;case 15:if("json"!==s){i.next=22;break}return i.next=18,a.json();case 18:l=i.sent,r._running=!1,i.next=37;break;case 22:if(!o){i.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,o,P,c),i.abrupt("return");case 29:return i.next=31,a.arrayBuffer();case 31:l=i.sent,l=new Uint8Array(l),r._running=!1,f=Date.now()-P,p=Oe(l.byteLength,f),r.emit($,{speed:p,len:l.byteLength,time:f,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",h),e(Le(l,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),P,c,u,h,r._vid,r._priOptions));case 39:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}()).catch((function(e){var i;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!C||((e=e instanceof ke?e:new ke(n,A,null,null===(i=e)||void 0===i?void 0:i.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=C,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(e=S(k().mark((function e(){return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(e){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return e.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,n){var i=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new ke(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ae),this._writeIdx=0);var s,o,u,c=this._reader=e.body.getReader(),l=function(){var a=S(k().mark((function a(){var h,d,f,p,v,y,m,_;return k().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return o=Date.now(),a.prev=1,a.next=4,c.read();case 4:s=a.sent,u=Date.now(),a.next=13;break;case 8:return a.prev=8,a.t0=a.catch(1),u=Date.now(),i._aborted||(i._running=!1,a.t0.options={index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions},i.reject(a.t0)),a.abrupt("return");case 13:if(d=(null===(h=i._range)||void 0===h?void 0:h.length)>0?i._range[0]:0,f=d+i._receivedLength,!i._aborted){a.next=19;break}return i._running=!1,t(void 0,!1,{range:[f,f],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),a.abrupt("return");case 19:p=s.value?s.value.byteLength:0,i._receivedLength+=p,i._logger.debug("【fetchLoader,onProgress call】,task,",i._range,", start,",f,", end,",d+i._receivedLength,", done,",s.done),i._onProcessMinLen>0?i._writeIdx+p>=i._onProcessMinLen||s.done?((v=new Uint8Array(i._writeIdx+p)).set(i._cache.slice(0,i._writeIdx),0),p>0&&v.set(s.value,i._writeIdx),i._writeIdx=0,i._logger.debug("【fetchLoader,onProgress enough】,done,",s.done,",len,",v.byteLength,", writeIdx,",i._writeIdx)):p>0&&i._writeIdx+p<Ae?(i._cache.set(s.value,i._writeIdx),i._writeIdx+=p,i._logger.debug("【fetchLoader,onProgress cache】,len,",p,", writeIdx,",i._writeIdx)):p>0&&(y=new Uint8Array(i._writeIdx+p+2048),i._logger.debug("【fetchLoader,onProgress extra start】,size,",i._writeIdx+p+2048,", datalen,",p,", writeIdx,",i._writeIdx),y.set(i._cache.slice(0,i._writeIdx),0),p>0&&y.set(s.value,i._writeIdx),i._writeIdx+=p,delete i._cache,i._cache=y,i._logger.debug("【fetchLoader,onProgress extra end】,len,",p,", writeIdx,",i._writeIdx)):v=s.value,(v&&v.byteLength>0||s.done)&&t(v,s.done,{range:[i._range[0]+i._receivedLength-(v?v.byteLength:0),i._range[0]+i._receivedLength],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),s.done?(m=Date.now()-r,_=Oe(i._receivedLength,m),i.emit($,{speed:_,len:i._receivedLength,time:m,vid:i._vid,index:i._index,range:i._range,priOptions:i._priOptions}),i._running=!1,i._logger.debug("[fetchLoader onProgress end],task,",i._range,",done,",s.done),i.resolve(Le(s,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,n,i._index,i._range,i._vid,i._priOptions))):l();case 25:case"end":return a.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();l()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),r}(),De=function(){A(t,_());var e=I(t);function t(){var r;return E(this,t),O(B(r=e.call(this)),"_xhr",null),O(B(r),"_aborted",!1),O(B(r),"_timeoutTimer",null),O(B(r),"_range",null),O(B(r),"_receivedLength",0),O(B(r),"_url",null),O(B(r),"_onProgress",null),O(B(r),"_index",-1),O(B(r),"_headers",null),O(B(r),"_currentChunkSizeKB",384),O(B(r),"_timeout",null),O(B(r),"_xhr",null),O(B(r),"_withCredentials",null),O(B(r),"_startTime",-1),O(B(r),"_loadCompleteResolve",null),O(B(r),"_loadCompleteReject",null),O(B(r),"_runing",!1),O(B(r),"_logger",!1),O(B(r),"_vid",""),O(B(r),"_responseType",void 0),O(B(r),"_credentials",void 0),O(B(r),"_method",void 0),O(B(r),"_transformResponse",void 0),O(B(r),"_firstRtt",void 0),O(B(r),"_onCancel",null),O(B(r),"_priOptions",null),r}return L(t,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=Te(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof ke?e:new ke(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===ge&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,n=this._range[1];t<this._range[1]-r&&(n=r+t),e=[r,n],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,n,i;t._running=!1;var a=new ke(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.status)+",statusText,"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new ke(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var n=this._headers||{},i=Se(e);i&&(n.Range=i),n&&Object.keys(n).forEach((function(e){r.setRequestHeader(e,n[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(t){t.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var n=new ke(this._url,null,b(b({},e.target.response),{},{status:r}),"bad response,status:"+r);return n.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(n)}var i,a=null,s=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===ge){var u,c=new Uint8Array(e.target.response);if(i=o+this._receivedLength,c&&c.byteLength>0){this._receivedLength+=c.byteLength;var l=Date.now()-this._startTime,h=Oe(this._receivedLength,l);this.emit($,{speed:h,len:this._receivedLength,time:l,vid:this._vid,index:this._index,range:[i,o+this._receivedLength],priOptions:this._priOptions})}a=c,s=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",i,"end ",o+this._receivedLength,",dataLen,",c?c.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",s)}else s=!0,a=e.target.response;var d={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(d=this._transformResponse(d,this._url)||d),this._onProgress&&this._onProgress(a,s,{index:this._index,vid:this._vid,range:[i,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},d),s?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Le(this._onProgress?null:a,s,d,d.headers["content-length"],d.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,M(C(t.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value.split(": ");r[i[0].toLowerCase()]=i.slice(1).join(": ")}}catch(e){n.e(e)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),t}();function Pe(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function Ue(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var Re=["retry","retryDelay","onRetryError","transformError"],Be=function(){function e(t,r){E(this,e),this.promise=Pe(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new G("Loader")),this._loaderType=t,this._loader=t===_e&&"undefined"!=typeof fetch?new Ce:new De,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return L(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,i=t.onRetryError,a=t.transformError,s=function(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(t,Re),o=function(){var t=S(k().mark((function t(){var u,c,l;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(s);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,c=t.t0,a&&(c=a(c)||c),i&&e._retryCount>0&&i(c,e._retryCount,{index:s.index,vid:s.vid,range:s.range,priOptions:s.priOptions}),e._retryCount++,l=!0,e._retryCheckFunc&&(l=e._retryCheckFunc(t.t0)),!(l&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",s.range),e._retryTimer=setTimeout(o,n),t.abrupt("return");case 26:e.promise.reject(c);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=S(k().mark((function e(){return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}(),Ie=function(){A(r,_());var e,t=I(r);function r(e){var n;return E(this,r),O(B(n=t.call(this,e)),"type",_e),O(B(n),"_queue",[]),O(B(n),"_alive",[]),O(B(n),"_currentTask",null),O(B(n),"_finnalUrl",""),O(B(n),"_config",void 0),n._config=function(e){return b({loaderType:_e,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:be,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},e)}(e),"xhr"!==n._config.loaderType&&Ce.isSupported()||(n.type="xhr"),n.log=e.logger,n}return L(r,[{key:"isFetch",value:function(){return this.type===_e}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&xe(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&xe(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Be(this.type,r);return n.loader.on($,(function(e){t.emit($,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(e=S(k().mark((function e(){var t;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,me();case 8:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return Ce.isSupported()}}]),r}(),Me=function(){function e(t){var r=this;E(this,e),O(this,"_seiSet",new Set),this.emitter=t,t.on(Y,(function(e){e&&r._seiSet.add(e)}))}return L(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var n=e-.2,i=e+.2,a=[];this._seiSet.forEach((function(e){e.time>=n&&e.time<=i&&a.push(e)})),a.forEach((function(e){r._seiSet.delete(e),r.emitter.emit("core.seiintime",e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),je=function(){function e(t){E(this,e),O(this,"_chunkSpeed",0),O(this,"_chunkCache",[]),O(this,"_speeds",[]),O(this,"_totalSize",0),O(this,"_totalCost",0),this._opts=t||{}}return L(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,n;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var i=(null===(n=this._opts)||void 0===n?void 0:n.chunkCountForSpeed)||50;this._chunkCache.length>i&&(this._chunkCache=this._chunkCache.slice(-i))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),Fe=function(){function e(t){E(this,e),O(this,"encodeType",""),O(this,"audioCodec",""),O(this,"videoCodec",""),O(this,"domain",""),O(this,"fps",0),O(this,"bitrate",0),O(this,"width",0),O(this,"height",0),O(this,"samplerate",0),O(this,"channelCount",0),O(this,"gop",0),O(this,"_bitsAccumulateSize",0),O(this,"_bitsAccumulateDuration",0),O(this,"_startGopId",-1),this._timescale=t}return L(e,[{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 t,r=e.data,n=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.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 t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{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 t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ne=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;E(this,e),O(this,"_core",null),O(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new Fe(r),this._bindEvents()}return L(e,[{key:"getStats",value:function(){var e,t,r,n,i,a,s,o,u,c,l,h=(null===(e=this._core)||void 0===e?void 0:e.media)||{},d=h.currentTime,f=void 0===d?0:d,p=h.decodeFps,v=void 0===p?0:p;return b(b({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(n=this._core)||void 0===n||null===(i=n.speedInfo)||void 0===i?void 0:i.call(n).avgSpeed)||0,totalReceivedByte:(null===(a=this._core)||void 0===a||null===(s=a.speedInfo)||void 0===s?void 0:s.call(a).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:f,bufferEnd:(null===(c=this._core)||void 0===c||null===(l=c.bufferInfo())||void 0===l?void 0:l.remaining)||0,decodeFps:v})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(Z,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(J,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Q,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(K,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new Fe(this._timescale)}}]),e}(),Ve=function(){function e(){E(this,e),O(this,"_prevCurrentTime",0)}return L(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var i=e.currentTime,a=0;if(this._prevCurrentTime===i){var s=ve.info(ve.get(e),i);if(!s.buffers.length)return;r&&s.nextStart||s.nextStart&&s.nextStart-i<t?a=s.nextStart+.1:s.end&&s.end-i>n&&!e.seeking&&(a=i+.1)}this._prevCurrentTime=i,a&&i!==a&&(e.currentTime=a)}}}]),e}(),Ge="undefined"!=typeof window;function ze(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return Ge?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(e){}}function qe(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var He="updateDuration",We=function(){function e(t,r){var n=this;E(this,e),O(this,"media",null),O(this,"mediaSource",null),O(this,"_openPromise",Pe()),O(this,"_queue",Object.create(null)),O(this,"_sourceBuffer",Object.create(null)),O(this,"_mseFullFlag",{}),O(this,"_st",0),O(this,"_opst",0),O(this,"_logger",null),O(this,"_config",null),O(this,"_url",null),O(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),O(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),O(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==He&&t.shift(),r){var i,a,s=Ue()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),function(e){try{return JSON.stringify(e)}catch(e){return""}}(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(i=n._sourceBuffer[e])||void 0===i?void 0:i.buffered)),s,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:s});var o=null===(a=r.context)||void 0===a?void 0:a.callback;o&&"function"==typeof o&&o(r.context),n._startQueue(e)}}})),O(this,"_onSBUpdateError",(function(e,t){var r=n._queue[e];if(r){var i=r[0];i&&(n._logger.error("UpdateError",e,i.opName,i.context),i.promise.reject(new pe(ie,ce,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new G("MSE"),this._config.openLog&&G.enable()}var t,r,n;return L(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var n=e._queue[r];Array.isArray(n)&&(t||(t=n.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!qe(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var n=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{n=Math.max(t.bufferEnd(e)||0,n)}catch(e){}})),e<n)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),He,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var n=Ue()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=Pe()}return this._openPromise}},{key:"bindMedia",value:(n=S(k().mark((function e(t){var r,n,i,a,s=this;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=ze(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,n=this.mediaSource=new r,i=qe(n),this._st=Ue(),a=function e(){var r=Ue()-s._st;s._logger.debug("sourceopen"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:r})},n.addEventListener("sourceopen",a),i&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(n),t.src=this._url,t.disableRemotePlayback=i,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unbindMedia",value:(r=S(k().mark((function e(){var t,r,n,i=this;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=i._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,n="open"===t.readyState,r&&n)try{t.endOfStream()}catch(e){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(i._sourceBuffer[e])}catch(e){}})),qe(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(e){}this.media=null}this.mediaSource=null,this._openPromise=Pe(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(e){throw new pe(ie,ue,e)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,n=this._sourceBuffer[e];return this.mediaSource&&n&&n.mimeType!==t?"function"!=typeof n.changeType?Promise.reject(new pe(ie,de,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(e){throw new pe(ie,de,e)}n.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var n=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var i;n.mediaSource&&!n.media.error&&(n._logger.debug("MSE APPEND START",r),n._opst=Ue(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),"appendBuffer",r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var a=i._sourceBuffer[e];t>=r||!a?i._onSBUpdateEnd(e):(i._opst=Ue(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),"removeBuffer",n,a)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n.remove(i,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var n=t._sourceBuffer[r];e=t.remove(r,0,ve.end(ve.get(n)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(t&&n)this._queue[e]=[];else if(n&&n[e]&&!(n.length<5)){var i=[];n.forEach((function(e){e.context&&e.context.isinit&&i.push(e)})),this._queue[e]=n.slice(0,2),i.length>0&&(r=this._queue[e]).push.apply(r,i)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return ve.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return ve.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return ve.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:Pe(),opName:r,context:n};return i?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=S(k().mark((function e(t,r,n){var i,a,s=this;return k().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((i=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],i.forEach((function(e){var t=s._queue[e],i=Pe();a.push(i),t.push({exec:function(){i.resolve()},promise:i,opName:r,context:n}),1===t.length&&s._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{i.forEach((function(e){var t=s._queue[e],r=s._sourceBuffer[e];null==t||t.shift(),r&&r.updating||s._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,r.context&&"object"===w(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new pe(ie,he,n))):(this._logger.error(n),r.promise.reject(n.constructor===pe?n:new pe(ie,le,n)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var n=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=ze();if(!t)return!1;try{return t.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,it(n.key),n)}}function Ye(e,t,r){return t&&Qe(e.prototype,t),r&&Qe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Je(e,t,r){return(t=it(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ze(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$e(e,t)}function Xe(e){return(Xe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $e(e,t){return($e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Xe(e);if(t){var i=Xe(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function tt(e){return function(e){if(Array.isArray(e))return nt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rt(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rt(e,t){if(e){if("string"==typeof e)return nt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nt(e,t):void 0}}function nt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function it(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}O(We,"VIDEO","video"),O(We,"AUDIO","audio");var at=function(){function e(t){Ke(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return Ye(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Je(at,"disabled",!0);var st="video",ot="hevc",ut="aac",ct="g7110a",lt="g7110m",ht="opus",dt="LARGE_AV_SHIFT",ft="LARGE_VIDEO_GAP",pt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",vt="LARGE_AUDIO_GAP",yt="AUDIO_FILLED",mt="AUDIO_DROPPED",_t=function(){function e(){Ke(this,e),Je(this,"id",1),Je(this,"type",st),Je(this,"codecType","avc"),Je(this,"pid",-1),Je(this,"hvcC",void 0),Je(this,"codec",""),Je(this,"timescale",0),Je(this,"formatTimescale",0),Je(this,"sequenceNumber",0),Je(this,"baseMediaDecodeTime",0),Je(this,"baseDts",0),Je(this,"duration",0),Je(this,"warnings",[]),Je(this,"samples",[]),Je(this,"pps",[]),Je(this,"sps",[]),Je(this,"vps",[]),Je(this,"fpsNum",0),Je(this,"fpsDen",0),Je(this,"sarRatio",[]),Je(this,"width",0),Je(this,"height",0),Je(this,"nalUnitSize",4),Je(this,"present",!1),Je(this,"isVideoEncryption",!1),Je(this,"isAudioEncryption",!1),Je(this,"isVideo",!0),Je(this,"lastKeyFrameDts",0),Je(this,"kid",null),Je(this,"pssh",null),Je(this,"ext",void 0)}return Ye(e,[{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:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),gt=function(){function e(){Ke(this,e),Je(this,"id",2),Je(this,"type","audio"),Je(this,"codecType",ut),Je(this,"pid",-1),Je(this,"codec",""),Je(this,"sequenceNumber",0),Je(this,"sampleDuration",0),Je(this,"timescale",0),Je(this,"formatTimescale",0),Je(this,"baseMediaDecodeTime",0),Je(this,"duration",0),Je(this,"warnings",[]),Je(this,"samples",[]),Je(this,"baseDts",0),Je(this,"sampleSize",16),Je(this,"sampleRate",0),Je(this,"channelCount",0),Je(this,"objectType",0),Je(this,"sampleRateIndex",0),Je(this,"config",[]),Je(this,"present",!1),Je(this,"isVideoEncryption",!1),Je(this,"isAudioEncryption",!1),Je(this,"kid",null),Je(this,"ext",void 0)}return Ye(e,[{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!==ut&&this.codecType!==ct&&this.codecType!==lt&&this.codecType!==ht)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),bt=function(){function e(t,r,n){Ke(this,e),Je(this,"flag",{}),Je(this,"keyframe",!1),Je(this,"gopId",0),Je(this,"duration",0),Je(this,"size",0),Je(this,"units",[]),Je(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return Ye(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),kt=Ye((function e(t,r,n,i){Ke(this,e),Je(this,"duration",1024),Je(this,"flag",{dependsOn:2,isNonSyncSample:0}),Je(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),wt=Ye((function e(t,r){Ke(this,e),Je(this,"time",0),this.data=t,this.originPts=this.pts=r})),xt=function(){Ze(t,wt);var e=et(t);function t(){return Ke(this,t),e.apply(this,arguments)}return Ye(t)}(),St=function(){Ze(t,wt);var e=et(t);function t(){return Ke(this,t),e.apply(this,arguments)}return Ye(t)}(),Et=function(){function e(){Ke(this,e),Je(this,"id",3),Je(this,"type","metadata"),Je(this,"timescale",0),Je(this,"flvScriptSamples",[]),Je(this,"seiSamples",[])}return Ye(e,[{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)}}]),e}(),Tt="undefined"!=typeof window,Lt=Tt&&navigator.userAgent.toLocaleLowerCase(),Ot=Tt&&/^((?!chrome|android).)*safari/.test(Lt),At=Tt&&Lt.includes("firefox"),Ct=Tt&&Lt.includes("android"),Dt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var a=i,s=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,h=1+((192&t[i+2])>>>6),d=(1&t[i+2])<<2|(192&t[i+3])>>>6,f=e._getConfig(o,d,h),p=f.config,v=f.codec,y=0,m=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(!(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5)||n-i<l)break;c=2*(1&~t[i+1]),s.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:h,channelCount:d,codec:v,config:p,originCodec:"mp4a.40.".concat(h)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,a=e.FREQ[n];if(a){var s=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){return 1024*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4)/e}},{key:"_getConfig",value:function(e,t,r){var n,i,a=[];return At?e>=6?(n=5,i=e-3):(n=2,i=e):Ct?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),a[0]=n<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===n&&(a[1]|=(14&i)>>1,a[2]=(1&i)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}]),e}();Je(Dt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Pt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),r="",n=0;n<8;n++)r+=String.fromCodePoint(e[n]);if("OpusHead"!==r)throw new Error("Invalid Opus MagicSignature");var i=e[9];console.log("Pre-skip",e[10],e[11]);var a=t.getUint32(12,!0),s=t.getInt16(16,!0);if(a)return{outputGain:s,sampleRate:a,channelCount:i,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}]),e}(),Ut=5e3,Rt=function(){function e(t,r,n){Ke(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,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 Ye(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,a=this.audioTrack;if(!r&&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),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t),this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist())&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var s=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var i=e.samples[0],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u,c=r.length,l=0,h=r[0],d=this._videoNextDts-h.dts;if(Math.abs(d)>200)Math.abs(h.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3&&(this._lastVideoExceptionChunkFirstDtsDot=h.dts,e.warnings.push({type:pt,nextDts:this._videoNextDts,firstSampleDts:h.dts,nextSampleDts:null===(u=r[1])||void 0===u?void 0:u.dts,sampleDuration:d})),this._videoTimestampBreak>=5?(this._videoNextDts=h.dts,this._videoTimestampBreak=0):(h.dts+=d,h.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1));for(var f=0;f<c;f++){var p=r[f].dts,v=r[f+1];((l=f<c-1?v.dts-p:s?s.dts-p:n)>1e3||l<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:ft,time:p/e.timescale,dts:p,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:l,refSampleDuration:n})),l=n),r[f].duration=l,this._videoNextDts+=l,this._lastVideoDuration=l}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var i=1/0,a=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=a=n[0].dts),this._baseDts=Math.min(i,a);var s=a-i;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:dt,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(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,t,r){if(!e.sampleDuration)switch(e.codecType){case ut:e.sampleDuration=Dt.getFrameDuration(e.timescale,r);break;case ht:e.sampleDuration=Pt.getFrameDuration(e.samples,r);break;case ct:case lt:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===ht?20:e.codecType===ut?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],c=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=1e3&&!Ot){var l=this._getSilentFrame(e)||t[0].data.subarray(),h=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Ut&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:yt,pts:u.pts,originPts:u.originPts,count:h,nextPts:o,refSampleDuration:n}));for(var d=0;d<h;d++){var f=new kt(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=n,s++}s--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Ut&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:mt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--;else{if(Math.abs(c)>1e3&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Ut&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:vt,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===ht){var p=t[t.length-1];p&&(p.duration=u.pts-p.pts)}else u.dts=u.pts=o,u.duration=i;this._audioNextPts+=n}}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,n=e.sampleRate,i=e.samples[0];if(i)return 2*i.data.byteLength/r/(t/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===ut?Dt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}();function Bt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function It(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Mt(e){for(var t,r="avc1.",n=0;n<3;n++)(t=e[n].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function jt(e){if(!Array.isArray(e)){for(var t=[],r="",n=0;n<e.length;n++)n%2&&(r=e[n-1]+e[n],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}Math.pow(2,32);var Ft=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((n=2+ ++r)>=t)return[];for(var i=[];n<t;)switch(e[n]){case 0:if(0!==e[n-1]){n+=2;break}if(0!==e[n-2]){n++;break}r!==n-2&&i.push(e.subarray(r,n-2));do{n++}while(1!==e[n]&&n<t);n=(r=n+1)+2;break;case 1:if(0!==e[n-1]||0!==e[n-2]){n+=3;break}r!==n-2&&i.push(e.subarray(r,n-2)),n=(r=n+1)+2;break;default:n+=3}return r<t&&i.push(e.subarray(r)),i}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,n=e.length,i=[],a=0;a+t<n;)if(r=It(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>n)break;i.push(e.subarray(a,a+r)),a+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,a=0,s="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)a+=255,n++;if(a+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)s+=e[n].toString(16),n++;return{payload:e.subarray(n,n+a),type:i,size:a,uuid:s}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}}]),e}(),Nt=function(){function e(t){if(Ke(this,e),Je(this,"_bytesAvailable",void 0),Je(this,"_bitsAvailable",0),Je(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return Ye(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,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 t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{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 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Vt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,a.push(l),r||(r=e.parseSPS(Ft.removeEPB(l)))}var h,d=t[o];o++;for(var f=0;f<d;f++)h=t[o]<<8|t[o+1],o+=2,h&&(s.push(t.subarray(o,o+h)),o+=h);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Nt(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),h=0;h<l;h++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var d=t.readUEG(),f=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,y,m,_,g,b=0,k=0,w=0,x=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),w=t.readUEG(),x=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:v=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var S=t.readBits(32),E=t.readBits(32);y=t.readBool(),g=(m=E)/(_=2*S)}}return{codec:Mt(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(d+1)-2*(b+k)),height:(2-p)*(f+1)*16-(p?2:4)*(w+x),sarRatio:v,fpsNum:m,fpsDen:_,fps:g,fixedFrame:y}}}]),e}(),Gt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,a,s,o,u=1+(3&t[21]),c=[],l=[],h=[],d=23,f=t[22],p=0;p<f;p++){a=63&t[d],s=t[d+1]<<8|t[d+2],d+=3;for(var v=0;v<s;v++)if(o=t[d]<<8|t[d+1],d+=2,o){switch(a){case 32:var y=t.subarray(d,d+o);n||(n=e.parseVPS(Ft.removeEPB(y),r)),h.push(y);break;case 33:var m=t.subarray(d,d+o);i||(i=e.parseSPS(Ft.removeEPB(m),r)),c.push(m);break;case 34:l.push(t.subarray(d,d+o))}d+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:h,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new Nt(t);n.readUByte(),n.readUByte(),n.readBits(12);var i=n.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,i+1),n.readBits(17),e._parseProfileTierLevel(n,i,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var n=new Nt(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,h,d=n.readUEG(),f=n.readUEG(),p=n.readBits(1);return 1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),h=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p&&(d-=(1!==a&&2!==a||0!==o?1:2)*(c+u),f-=(1===a&&0===o?2:1)*(h+l)),{codec:"hev1.1.6.L93.B0",width:d,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(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)),0!==s[u]&&e.readBits(8)}}]),e}(),zt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,a=t.length;i<a;)if(n[i]<128)r.push(String.fromCharCode(n[i])),++i;else{if(n[i]<192);else if(n[i]<224){if(e._checkContinuation(n,i,1)){var s=(31&n[i])<<6|63&n[i+1];if(s>=128){r.push(String.fromCharCode(65535&s)),i+=2;continue}}}else if(n[i]<240){if(e._checkContinuation(n,i,2)){var o=(15&n[i])<<12|(63&n[i+1])<<6|63&n[i+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),i+=3;continue}}}else if(n[i]<248&&e._checkContinuation(n,i,3)){var u=(7&n[i])<<18|(63&n[i+1])<<12|(63&n[i+2])<<6|63&n[i+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),i+=4;continue}}r.push(String.fromCharCode(65533)),++i}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var n=e;if(t+r<n.length){for(;r--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),qt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}i<=n-3&&9==(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var h=0;for(9==(16777215&t.getUint32(n-4))&&(h=3);i<n-8;){var d=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-h)),f=d.size,p=d.data;if(d.isEnd)break;r[p.name]=p.value,i+=f}i<=n-3&&9==(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),_=m.data,g=m.size;r.push(_),i+=g}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=zt.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=zt.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),n=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:n.data},size:r.size+n.size,isEnd:n.isEnd}}}}]),e}(),Ht=new at("FlvDemuxer"),Wt=function(){function e(t,r,n){Ke(this,e),Je(this,"_headerParsed",!1),Je(this,"_remainingData",null),Je(this,"_gopId",0),Je(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new _t,this.audioTrack=r||new gt,this.metadataTrack=n||new Et,this._fixer=new Rt(this.videoTrack,this.audioTrack,this.metadataTrack)}return Ye(e,[{key:"demux",value:function(t){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3?arguments[3]:void 0,s=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!n&&i||(this._remainingData=null),n&&(this._headerParsed=!1),n?(o.reset(),s.reset(),u.reset()):(o.samples=[],s.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],s.warnings=[],this._remainingData&&(t=Bt(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:s,metadataTrack:u};var c=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");s.present=(4&t[4])>>>2!=0,o.present=!!(1&t[4]),this._headerParsed=!0,c=It(t,5)+4}for(var l,h,d,f,p,v=t.length;c+15<v&&(l=t[c],!(c+15+(h=t[c+1]<<16|t[c+2]<<8|t[c+3])>v));)d=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,f=t.subarray(c,c+h),8===l?this._parseAudio(f,d):9===l?(a&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,d)):18===l?this._parseScript(f,d):Ht.warn("Invalid tag type: ".concat(l)),(p=It(t,c+=h))!==11+h&&Ht.warn("Invalid PrevTagSize ".concat(p," (").concat(11+h,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),s.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,s.timescale=s.codecType===ht?1e3:s.sampleRate||0,!s.exist()&&s.hasSample()&&s.reset(),!o.exist()&&o.hasSample()&&o.reset();var y=u.flvScriptSamples[u.flvScriptSamples.length-1],m=null==y||null===(r=y.data)||void 0===r?void 0:r.onMetaData;return m&&(null!=o&&o.exist()&&(m.hasOwnProperty("duration")&&(o.duration=1e3*m.duration),m.hasOwnProperty("width")&&m.hasOwnProperty("height")&&(o.width=m.width,o.height=m.height)),null!=s&&s.exist()&&m.hasOwnProperty("duration")&&(s.duration=1e3*m.duration)),{videoTrack:o,audioTrack:s,metadataTrack:u}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n,i){return this.demux(e,t,r,i),this.fix(n,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(10!==n&&7!==n&&8!==n&&13!==n)return Ht.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n&&13!==n){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[a],i.sampleSize=s?16:8,i.channelCount=o+1}switch(n){case 7:case 8:this._parseG711(t,r,n);break;case 10:this._parseAac(t,r);break;case 13:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=ht,n){case 0:var i=Pt.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=Pt.getFrameDuration([],r.timescale)):(r.reset(),Ht.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var a=new kt(t,e.subarray(2),r.sampleDuration);r.samples.push(a);break;default:Ht.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack;n.codecType=7===r?ct:lt,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new kt(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=ut,0===e[1]){var n=Dt.parseAudioSpecificConfig(e.subarray(2));n?(r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.config=n.config,r.objectType=n.objectType,r.sampleRateIndex=n.samplingFrequencyIndex):(r.reset(),Ht.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new kt(t,e.subarray(2)))}else Ht.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var n=(240&e[0])>>>4,i=15&e[0],a=this.videoTrack;if(7!==i&&12!==i)return a.reset(),void Ht.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?ot:"avc";var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=s?Gt.parseHEVCDecoderConfigurationRecord(c):Vt.parseAVCDecoderConfigurationRecord(c);if(l){var h=l.hvcC,d=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;h&&(a.hvcC=a.hvcC||h),d&&(a.codec=d.codec,a.width=d.width,a.height=d.height,a.sarRatio=d.sarRatio,a.fpsNum=d.fpsNum,a.fpsDen=d.fpsDen),p.length&&(a.sps=p),f.length&&(a.pps=f),v&&v.length&&(a.vps=v),y&&(a.nalUnitSize=y)}else Ht.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Ft.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var _=new bt(t+u,t,m);if(this.seamlessLoadingSwitching&&t<a.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(_.setToKeyframe(),a.lastKeyFrameDts=t),a.samples.push(_),m.forEach((function(e){var n=s?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==n||s&&5===n)break;_.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new St(Ft.parseSEI(Ft.removeEPB(e),s),t+u))}})),_.keyframe&&this._gopId++,_.gopId=this._gopId}else Ht.warn("Cannot parse NALUs",e)}else 2===o||Ht.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new xt(qt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&It(e,5)>=9}}]),e}();Je(Wt,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var Kt=function(){function e(){Ke(this,e),this.buffer=new Uint8Array(0)}return Ye(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){t?e.buffer=function(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return n.forEach((function(e){a.set(e,s),s+=e.length})),a}(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),Qt=Math.pow(2,32)-1,Yt=function(){function e(){Ke(this,e)}return Ye(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===st&&e.codecType===ot}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Bt(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){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],jt(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(tt(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(tt(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.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,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,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]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,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,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.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,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===ht?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,n=t.enca.sampleRate,i=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,n>>8&255,255&n,0,0]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,i,a,s)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],c=t.sarRatio[1],l=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,255&s,o>>8&255,255&o,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]),h=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,tt(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,tt(a))),d=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),p=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c]);return e.box(e.types.encv,l,e.box(e.types.avcC,h),e.box(e.types.btrt,d),f,e.box(e.types.pasp,p))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(jt(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,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]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===ot,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,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]),i];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(a))}},{key:"avcC",value:function(t){var r,n,i,a=[],s=[];return t.sps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,tt(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,tt(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(n,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(a.length&&1)+(s.length&&1);n=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,c];var l=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,tt(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),a.length&&(n.push(161,0,a.length),a.forEach(l)),s.length&&(n.push(162,0,s.length),s.forEach(l))}else n=[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 e.box(e.types.hvcC,new Uint8Array(n))}},{key:"pasp",value:function(t){var r,n,i=(n=2,function(e){if(Array.isArray(e))return e}(r=t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,s,o=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(r,n)||rt(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=i[0],s=i[1];return e.box(e.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.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(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),n=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,n)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(tt(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(tt(t.map((function(t){return e.traf(t)})))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2,i+=6*e.subsamples.length)})),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,a,s,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),h=e.saio(t),d=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,n,c,l,h,d,f)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var y=e.trun1(t);return e.box(e.types.traf,r,n,y)}var m=e.sbgp(),_=e.saiz(t),g=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,m,_,g,b,k)}var w=e.sdtp(t);return e.box(e.types.traf,r,n,w,e.trun(t.samples,w.byteLength+76))}},{key:"sdtp",value:function(t){var r=new Kt;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new Kt,n=Kt.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Kt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Kt.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),i=Kt.writeUint32(s)}return t.samples.forEach((function(e){r.write(Kt.writeUint32(e.duration)),r.write(Kt.writeUint32(e.size)),r.write(Kt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Kt.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new Kt,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||i*n,r.write(Kt.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Kt.writeUint32(n)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(Kt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Kt.writeUint16(e.BytesOfClearData)),r.write(Kt.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var n=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var r=t.samples.length,n=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,n)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var n=Math.floor(r/(Qt+1)),i=Math.floor(r%(Qt+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,h=void 0===l?{}:l,d=o.cts,f=void 0===d?0:d;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,h.isLeading<<2|(null===h.dependsOn||void 0===h.dependsOn?1:h.dependsOn),h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|(null===h.isNonSyncSample||void 0===h.isNonSyncSample?1:h.isNonSyncSample),61440&h.degradationPriority,15&h.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(tt(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===st?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,n=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&n.push(e.stss(r.stss)),r.ctts.length&&n.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.stts,Bt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12})),e.box(e.types.stsc,Bt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsz",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stsz,Bt(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stco",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stco,Bt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stss",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stss,Bt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"ctts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.ctts,Bt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,a=t.samples[0].sampleOffset*n,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,c=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){c+=8,e.subsamples&&e.subsamples.length&&(c+=2,c+=6*e.subsamples.length)})),t.videoSencLength=c,o=s+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var l=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,l)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();Je(Yt,"types",["Opus","dOps","av01","av1C","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(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),Je(Yt,"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])}),Je(Yt,"FTYPAVC1",Yt.box(Yt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),Je(Yt,"FTYPHEV1",Yt.box(Yt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),Je(Yt,"DINF",Yt.box(Yt.types.dinf,Yt.box(Yt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),Je(Yt,"VMHD",Yt.box(Yt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),Je(Yt,"SMHD",Yt.box(Yt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),Je(Yt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),Je(Yt,"STTS",Yt.box(Yt.types.stts,Yt.StblTable)),Je(Yt,"STSC",Yt.box(Yt.types.stsc,Yt.StblTable)),Je(Yt,"STSZ",Yt.box(Yt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),Je(Yt,"STCO",Yt.box(Yt.types.stco,Yt.StblTable));var Jt=function(){function e(t,r){Ke(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return Ye(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[this._prefix].concat(n))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();Je(Jt,"disabled",!0);var Zt=function(){function e(t,r,n){Ke(this,e),this.videoTrack=t,this.audioTrack=r;var i=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=i&&Number(i[1])<50,this.log=new Jt("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return Ye(e,[{key:"remux",value:function(){var e,t,r,n,i,a=arguments.length>0&&void 0!==arguments[0]&&arguments[0],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,c=o.exist(),l=u.exist(),h=[];return a&&(s&&s.initMerge?(c&&h.push(this.videoTrack),l&&h.push(this.audioTrack),r=Yt.initSegment(h)):(c&&(e=Yt.initSegment([this.videoTrack])),l&&(t=Yt.initSegment([this.audioTrack])))),c&&o.hasSample()&&(n=this._remuxVideo()),l&&u.hasSample()&&(i=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:i}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),n=0;r?t.forEach((function(e){n+=e.data.byteLength})):t.forEach((function(e){n+=e.units.reduce((function(e,t){return e+t.byteLength}),0),n+=4*e.units.length}));var i=new Uint8Array(n);if(r)for(var a,s=0,o=t.length,u=0;s<o;s++)a=t[s],i.set(a.data,u),a.size=a.data.byteLength,u+=a.size;else for(var c,l=new DataView(i.buffer),h=function(e,r){r=t[d];var n=0;r.units.forEach((function(t){l.setUint32(e,t.byteLength),e+=4,i.set(t,e),e+=t.byteLength,n+=4+t.byteLength})),r.size=n,p=e,c=r},d=0,f=t.length,p=0;d<f;d++)h(p,c);var v=Yt.mdat(i);return Bt(Yt.moof([e]),v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=Yt.mdat(t);return Bt(Yt.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Xt=function(){function e(){c(this,e),d(this,"_ttfb",0),d(this,"_demuxStart",0),d(this,"_demuxEnd",0),d(this,"_demuxCost",0),d(this,"_remuxStart",0),d(this,"_remuxEnd",0),d(this,"_remuxCost",0),d(this,"_appendStart",0),d(this,"_appendEnd",0),d(this,"_appendCost",0)}return h(e,[{key:"set",value:function(e,t){this["_".concat(e)]=t}},{key:"start",value:function(e){this["_".concat(e,"Start")]=Date.now()}},{key:"end",value:function(e){this["_".concat(e,"End")]=Date.now(),this["_".concat(e,"Cost")]=this["_".concat(e,"Cost")]+(this["_".concat(e,"End")]-this["_".concat(e,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),e}(),$t="demux",er="remux",tr="append",rr=new G("BufferService"),nr=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,e),d(this,"flv",null),d(this,"_demuxer",new Wt),d(this,"_remuxer",null),d(this,"_mse",null),d(this,"_softVideo",null),d(this,"_sourceCreated",!1),d(this,"_needInitSegment",!0),d(this,"_discontinuity",!0),d(this,"_contiguous",!1),d(this,"_initSegmentId",""),d(this,"_cachedBuffer",null),d(this,"_demuxStartTime",0),d(this,"_opts",null),this.flv=t,this._opts=n,r?this._softVideo=r:(this._remuxer=new Zt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new We(null,{preferMMS:"boolean"==typeof n.preferMMS?n.preferMMS:!!n.perferMMS}),this._mse.bindMedia(t.media))}var t,r,n,i,o,l;return h(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:We.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:(l=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:(o=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit("core.buffereos");case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"updateDuration",value:(i=u(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return rr.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"destroy",value:(n=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"appendBuffer",value:(r=u(s().mark((function e(t){var r,n,i,a,o,u,c,l,h,d,f,p,v,y,m,_,g,b=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!1,this._cachedBuffer&&(t=ye(this._cachedBuffer,t),this._cachedBuffer=null),n=this._demuxer,t&&t.length&&n){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,this.flv._transferCost.start($t),n.demuxAndFix(t,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end($t),e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(5),new pe(re,se,e.t0);case 15:if(i=n.videoTrack,a=n.audioTrack,o=n.metadataTrack,!this.seamlessLoadingSwitch){e.next=25;break}if(!((u=i.samples.findIndex((function(e){return e.originDts===i.lastKeyFrameDts})))>=0)){e.next=25;break}return i.samples.splice(u),e.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,t=null,r=!0;case 25:if(c=i.exist(),l=a.exist(),this._opts.onlyAudio&&(c=!1,i.present=!1),this._opts.onlyVideo&&(l=!1,a.present=!1),!(!c&&i.present||!l&&a.present)){e.next=42;break}if(h=0,(d=c?i:l?a:void 0)&&d.samples.length&&(h=(d.samples[d.samples.length-1].originPts-d.samples[0].originPts)/d.timescale*1e3),!(h>this._opts.analyzeDuration)){e.next=40;break}rr.warn("analyze duration exceeded, ".concat(h,"ms"),d),i.present=c,a.present=l,this.flv.emit("core.analyzedurationexceeded",{duration:h}),e.next=42;break;case 40:return this._cachedBuffer=t,e.abrupt("return");case 42:if(f=i.type,p=a.type,this._fireEvents(i,a,o),r||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),v=this._mse,y=function(){var e,t;null!==(e=b.flv)&&void 0!==e&&e.emit&&(null===(t=b.flv)||void 0===t||t.emit("core.appendbuffer",{}))},this.flv.emit(Z,{videoTrack:i}),(m="".concat(i.codec,"/").concat(i.width,"/").concat(i.height,"/").concat(a.codec,"/").concat(a.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=m,this._emitMetaParsedEvent(i,a)),!v){e.next=81;break}if(this._sourceCreated){e.next=59;break}return e.next=55,v.open();case 55:c&&(rr.log("codec: video/mp4;codecs=".concat(i.codec)),v.createSource(f,"video/mp4;codecs=".concat(i.codec))),l&&(rr.log("codec: audio/mp4;codecs=".concat(a.codec)),v.createSource(p,"audio/mp4;codecs=".concat(a.codec))),this._sourceCreated=!0,this.flv.emit("core.sourcebuffercreated");case 59:e.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(i.duration=this._opts.durationForMSELowLatencyOff*i.timescale,a.duration=this._opts.durationForMSELowLatencyOff*l.timescale),this.flv._transferCost.start(er),_=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(er),e.next=69;break;case 66:throw e.prev=66,e.t1=e.catch(59),new pe(ne,oe,e.t1);case 69:if(!this._needInitSegment||_.videoInitSegment||_.audioInitSegment){e.next=71;break}return e.abrupt("return");case 71:return this._needInitSegment=!1,g=[],_.videoInitSegment&&g.push(v.append(f,_.videoInitSegment)),_.audioInitSegment&&g.push(v.append(p,_.audioInitSegment)),_.videoSegment&&g.push(v.append(f,_.videoSegment)),_.audioSegment&&g.push(v.append(p,_.audioSegment)),this.flv._transferCost.start(tr),e.abrupt("return",Promise.all(g).then(y).then((function(){b.flv._transferCost.end(tr),y()})));case 81:this._softVideo&&(this._softVideo.appendBuffer(i,a),y());case 82:case"end":return e.stop()}}),e,this,[[5,12],[59,66]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=u(s().mark((function e(t){var r,n,i,a=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(n=r.currentTime,!((i=n-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(ve.start(ve.get(r))+1>=i)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,i).then((function(){return a.flv.emit("core.removebuffer",{removeEnd:i})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(Q,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(Q,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),rr.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var n=this;rr.debug("videoTrack samples count: ".concat(e.samples.length,", audioTrack samples count: ").concat(t.samples.length)),r.flvScriptSamples.forEach((function(e){n.flv.emit(J,e),rr.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&n.flv.emit("core.keyframe",{pts:e.originPts})})),e.warnings.forEach((function(e){var t;switch(e.type){case dt:t="LARGE_AV_FIRST_FRAME_GAP_DETECT";break;case ft:t="LARGE_VIDEO_DTS_GAP_DETECT";break;case pt:t="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT"}t&&n.flv.emit(X,a(a({},e),{},{type:t})),rr.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case vt:t="LARGE_AUDIO_DTS_GAP_DETECT";break;case yt:t="AUDIO_GAP_DETECT";break;case mt:t="AUDIO_OVERLAP_DETECT"}t&&n.flv.emit(X,a(a({},e),{},{type:t})),rr.warn("audio exception",e)})),r.seiSamples.forEach((function(e){n.flv.emit(Y,a(a({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function ir(e,t){var r=0,n=e.length-1,i=0,a=0,s=n;for(t<e[0]&&(r=0,a=s+1);a<=s;){if((i=a+Math.floor((s-a)/2))===n||t>=e[i]&&t<e[i+1]){r=i;break}e[i]<t?a=i+1:s=i-1}return r}var ar=new G("flv"),sr=.1,or=function(){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(b,_());var e,t,r,n,i,o,l,y,m,g=(y=b,m=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=f(y);if(m){var r=f(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return v(e)}(this,e)});function b(e){var t,r;return c(this,b),d(v(t=g.call(this)),"media",null),d(v(t),"_loading",!1),d(v(t),"_opts",null),d(v(t),"_bufferService",null),d(v(t),"_gapService",null),d(v(t),"_stats",null),d(v(t),"_mediaLoader",null),d(v(t),"_maxChunkWaitTimer",null),d(v(t),"_tickTimer",null),d(v(t),"_tickInterval",500),d(v(t),"_urlSwitching",!1),d(v(t),"_seamlessSwitching",!1),d(v(t),"_disconnectRetryCount",0),d(v(t),"_preLoadEndPoint",0),d(v(t),"_keyframes",null),d(v(t),"_acceptRanges",!0),d(v(t),"_onProgress",function(){var e=u(s().mark((function e(r,n,i,a){var o,u,c,l,h,d,f,p,v,y;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=i.startTime,u=i.endTime,c=i.st,l=i.firstByteTime,t._loading=!n,t._firstProgressEmit){e.next=13;break}if(t.media){e.next=6;break}return null===(h=t._mediaLoader)||void 0===h||h.cancel(),e.abrupt("return");case 6:d=a.headers,f=c?l-c:u-o,t.emit(K,{url:t._opts.url,responseUrl:a.url,elapsed:f}),t.emit("core.loadresponseheaders",{headers:d}),t._transferCost.set("ttfb",f),t._acceptRanges=!(null==d||!d.get("Accept-Ranges"))||!(null==d||!d.get("Content-Range")),t._firstProgressEmit=!0;case 13:if(t._bufferService){e.next=15;break}return e.abrupt("return");case 15:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=17,e.next=20,t._bufferService.appendBuffer(r);case 20:null===(p=t._bufferService)||void 0===p||p.evictBuffer(t._opts.bufferBehind),e.next=33;break;case 23:if(e.prev=23,e.t0=e.catch(17),t.isLive||!t._bufferService.isFull()){e.next=32;break}return e.next=28,t._mediaLoader.cancel();case 28:return t._loading=!1,v=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(v)/2,e.abrupt("return");case 32:return e.abrupt("return",t._emitError(pe.create(e.t0)));case 33:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit("core.switchurlsuccess",{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!n||t.media.seeking){e.next=40;break}return t.emit("core.loadcomplete"),ar.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),e.abrupt("return");case 40:if(t.isLive){e.next=42;break}return e.abrupt("return");case 42:(y=t._opts.maxReaderInterval)&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){if(t._disconnectRetryCount)return t._disconnectRetryCount--,void t.load();ar.debug("onMaxChunkWait",y),t._end()}),y));case 44:case"end":return e.stop()}}),e,null,[[17,23]])})));return function(t,r,n,i){return e.apply(this,arguments)}}()),d(v(t),"_onRetryError",(function(e,r){ar.debug("load retry",e,r),t.emit("core.loadretry",{error:pe.network(e),retryTime:r})})),d(v(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),ar.debug("end stream")})),d(v(t),"_resetDisconnectCount",(function(){t._disconnectRetryCount=t._opts.disconnectRetryCount})),d(v(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=v(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=ve.end(ve.get(e));if(!(r<sr)&&e.readyState){var n=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)&&e.currentTime)t._gapService&&t._gapService.do(e,n.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService&&n.enableStartGapJump)return void((t._opts.mseLowLatency||!1===t._opts.mseLowLatency&&t.bufferInfo(.3).nextStart)&&t._gapService.do(e,n.maxJumpDistance,t.isLive,3));n.isLive&&4===e.readyState&&r-e.currentTime>n.disconnectTime&&t.disconnect()}}}})),d(v(t),"_onPlay",(function(){var e,r,n=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);if(t.isLive)!t._loading&&n&&t.replay(void 0,!0);else{var i=t.bufferInfo();(i.start||i.nextStart)>sr&&t._tick()}})),d(v(t),"_onLoadeddata",(function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),d(v(t),"_onSeeking",u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return e.stop()}}),e)})))),d(v(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var n=ve.end(ve.get(t.media));n-r>=e.maxLatency&&(t.media.currentTime=n-e.targetLatency,t.emit("core.chaseframe",{currentTime:t.media.currentTime,latency:e.targetLatency}))}t._seiService.throw(r,!0),e.isLive||!t.seekable||t._loading||t._checkPreload()}})),d(v(t),"_onWaiting",(function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())})),d(v(t),"_onBufferUpdate",(function(){if(!t._opts.isLive){var e=t.bufferInfo(),r=e.end,n=e.nextEnd;Math.abs((r||n)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}})),d(v(t),"_checkPreload",u(s().mark((function e(){var r,n,i,a,o,u,c,l,h,d;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.bufferInfo(),n=r.remaining,i=void 0===n?0:n,a=t._opts,o=t._keyframes.filepositions,u=t._keyframes.times,c=t.media.currentTime,!(i<a.preloadTime)){e.next=19;break}if(l=ir(t._keyframes.times,c+i+sr),(h=ir(t._keyframes.times,c+i+t._opts.preloadTime))===l&&(h=l+1),t._preLoadEndPoint!==h){e.next=11;break}return e.abrupt("return");case 11:if(null!=(d=o[l])){e.next=14;break}return e.abrupt("return");case 14:return e.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[d,o[h]]),t._preLoadEndPoint=h,t._bufferService.unContiguous(u[l]);case 19:case"end":return e.stop()}}),e)})))),d(v(t),"_onFlvScriptData",(function(e){var r,n,i,a,s=null===(r=e.data)||void 0===r||null===(n=r.onMetaData)||void 0===n?void 0:n.keyframes,o=null===(i=e.data)||void 0===i||null===(a=i.onMetaData)||void 0===a?void 0:a.duration;s&&(t._keyframes=s),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=a({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,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new Ie(a(a({},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._transferCost=new Xt,t._bufferService=new nr(v(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new Me(v(t)),t._bandwidthService=new je({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new Ne(v(t)),t._opts.softDecode||(t._gapService=new Ve),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),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(J,t._onFlvScriptData),t}return h(b,[{key:"version",get:function(){return"3.0.20"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:sr;return ve.info(ve.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(l=u(s().mark((function e(t){var r,n=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.length>1&&void 0!==n[1]&&n[1],this._bufferService){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._reset(r);case 5:this._loadData(t,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"replay",value:(o=u(s().mark((function e(){var t,r,n=this,i=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:this._opts.seamlesslyReload,r=i.length>1?i[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(this._resetDisconnectCount(),!t){e.next=11;break}return e.next=8,this._clear();case 8:setTimeout((function(){n._seamlessSwitching=!0,n._loadData(n._opts.url),n._bufferService.seamlessSwitch()})),e.next=13;break;case 11:return e.next=13,this.load();case 13:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 14:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"disconnect",value:function(){var e;return ar.debug("disconnect!"),null===(e=this._bufferService)||void 0===e||e.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:(i=u(s().mark((function e(t,r){var n=this;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(this._resetDisconnectCount(),!this._loading||!r){e.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var e=u(s().mark((function e(r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n._clear();case 2:n._bufferService.seamlessLoadingSwitching=!0,n._urlSwitching=!0,n._seamlessSwitching=!0,n._bufferService.seamlessSwitch(),n._loadData(t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return");case 6:if(r&&this._opts.isLive){e.next=11;break}return e.next=9,this.load(t);case 9:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 11:return e.next=13,this._clear();case 13:setTimeout((function(){n._urlSwitching=!0,n._seamlessSwitching=!0,n._loadData(t),n._bufferService.seamlessSwitch()}));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"destroy",value:(n=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),e.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];ar.table(e),ar.error(e),ar.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit("core.switchurlfailed",e)),this.emit("error",e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(r=u(s().mark((function e(){var t,r=arguments;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_loadData",value:(t=u(s().mark((function e(t,r){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),n=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(n=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=n,this.emit("core.loadstart",{url:n,seamlessSwitching:this._seamlessSwitching}),ar.debug("load data, loading:",this._loading,n),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:n,range:r});case 15:e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(12),this._loading=!1,e.abrupt("return",this._emitError(pe.network(e.t0),!1));case 21:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,r){return t.apply(this,arguments)})},{key:"_clear",value:(e=u(s().mark((function e(){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:We.isSupported()}},{key:"enableLogger",value:function(){G.enable(),at.enable()}},{key:"disableLogger",value:function(){G.disable(),at.disable()}}]),b}();try{localStorage.getItem("xgd")?or.enableLogger():or.disableLogger()}catch(e){}var ur=n.N;export{ur as Flv};
1
+ var Wr=Object.create;var Gt=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Xr=Object.getPrototypeOf,qr=Object.prototype.hasOwnProperty;var Yr=(i,a)=>()=>(a||i((a={exports:{}}).exports,a),a.exports);var Qr=(i,a,e,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of Kr(a))!qr.call(i,t)&&t!==e&&Gt(i,t,{get:()=>a[t],enumerable:!(r=$r(a,t))||r.enumerable});return i};var He=(i,a,e)=>(e=i!=null?Wr(Xr(i)):{},Qr(a||!i||!i.__esModule?Gt(e,"default",{value:i,enumerable:!0}):e,i));var Fe=Yr((Ui,vt)=>{"use strict";var ti=Object.prototype.hasOwnProperty,oe="~";function ze(){}Object.create&&(ze.prototype=Object.create(null),new ze().__proto__||(oe=!1));function ri(i,a,e){this.fn=i,this.context=a,this.once=e||!1}function Kt(i,a,e,r,t){if(typeof e!="function")throw new TypeError("The listener must be a function");var n=new ri(e,r||i,t),s=oe?oe+a:a;return i._events[s]?i._events[s].fn?i._events[s]=[i._events[s],n]:i._events[s].push(n):(i._events[s]=n,i._eventsCount++),i}function tt(i,a){--i._eventsCount===0?i._events=new ze:delete i._events[a]}function ae(){this._events=new ze,this._eventsCount=0}ae.prototype.eventNames=function(){var a=[],e,r;if(this._eventsCount===0)return a;for(r in e=this._events)ti.call(e,r)&&a.push(oe?r.slice(1):r);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a};ae.prototype.listeners=function(a){var e=oe?oe+a:a,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var t=0,n=r.length,s=new Array(n);t<n;t++)s[t]=r[t].fn;return s};ae.prototype.listenerCount=function(a){var e=oe?oe+a:a,r=this._events[e];return r?r.fn?1:r.length:0};ae.prototype.emit=function(a,e,r,t,n,s){var u=oe?oe+a:a;if(!this._events[u])return!1;var o=this._events[u],l=arguments.length,c,f;if(o.fn){switch(o.once&&this.removeListener(a,o.fn,void 0,!0),l){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,r),!0;case 4:return o.fn.call(o.context,e,r,t),!0;case 5:return o.fn.call(o.context,e,r,t,n),!0;case 6:return o.fn.call(o.context,e,r,t,n,s),!0}for(f=1,c=new Array(l-1);f<l;f++)c[f-1]=arguments[f];o.fn.apply(o.context,c)}else{var v=o.length,m;for(f=0;f<v;f++)switch(o[f].once&&this.removeListener(a,o[f].fn,void 0,!0),l){case 1:o[f].fn.call(o[f].context);break;case 2:o[f].fn.call(o[f].context,e);break;case 3:o[f].fn.call(o[f].context,e,r);break;case 4:o[f].fn.call(o[f].context,e,r,t);break;default:if(!c)for(m=1,c=new Array(l-1);m<l;m++)c[m-1]=arguments[m];o[f].fn.apply(o[f].context,c)}}return!0};ae.prototype.on=function(a,e,r){return Kt(this,a,e,r,!1)};ae.prototype.once=function(a,e,r){return Kt(this,a,e,r,!0)};ae.prototype.removeListener=function(a,e,r,t){var n=oe?oe+a:a;if(!this._events[n])return this;if(!e)return tt(this,n),this;var s=this._events[n];if(s.fn)s.fn===e&&(!t||s.once)&&(!r||s.context===r)&&tt(this,n);else{for(var u=0,o=[],l=s.length;u<l;u++)(s[u].fn!==e||t&&!s[u].once||r&&s[u].context!==r)&&o.push(s[u]);o.length?this._events[n]=o.length===1?o[0]:o:tt(this,n)}return this};ae.prototype.removeAllListeners=function(a){var e;return a?(e=oe?oe+a:a,this._events[e]&&tt(this,e)):(this._events=new ze,this._eventsCount=0),this};ae.prototype.off=ae.prototype.removeListener;ae.prototype.addListener=ae.prototype.on;ae.prefixed=oe;ae.EventEmitter=ae;typeof vt<"u"&&(vt.exports=ae)});function Vt(i,a){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);a&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),e.push.apply(e,r)}return e}function pe(i){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?Vt(Object(e),!0).forEach(function(r){R(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Vt(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function F(){F=function(){return i};var i={},a=Object.prototype,e=a.hasOwnProperty,r=Object.defineProperty||function(p,h,d){p[h]=d.value},t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",s=t.asyncIterator||"@@asyncIterator",u=t.toStringTag||"@@toStringTag";function o(p,h,d){return Object.defineProperty(p,h,{value:d,enumerable:!0,configurable:!0,writable:!0}),p[h]}try{o({},"")}catch{o=function(h,d,T){return h[d]=T}}function l(p,h,d,T){var y=h&&h.prototype instanceof v?h:v,k=Object.create(y.prototype),I=new J(T||[]);return r(k,"_invoke",{value:w(p,d,I)}),k}function c(p,h,d){try{return{type:"normal",arg:p.call(h,d)}}catch(T){return{type:"throw",arg:T}}}i.wrap=l;var f={};function v(){}function m(){}function g(){}var E={};o(E,n,function(){return this});var S=Object.getPrototypeOf,C=S&&S(S(V([])));C&&C!==a&&e.call(C,n)&&(E=C);var A=g.prototype=v.prototype=Object.create(E);function N(p){["next","throw","return"].forEach(function(h){o(p,h,function(d){return this._invoke(h,d)})})}function O(p,h){function d(y,k,I,H){var z=c(p[y],p,k);if(z.type!=="throw"){var X=z.arg,te=X.value;return te&&typeof te=="object"&&e.call(te,"__await")?h.resolve(te.__await).then(function(W){d("next",W,I,H)},function(W){d("throw",W,I,H)}):h.resolve(te).then(function(W){X.value=W,I(X)},function(W){return d("throw",W,I,H)})}H(z.arg)}var T;r(this,"_invoke",{value:function(y,k){function I(){return new h(function(H,z){d(y,k,H,z)})}return T=T?T.then(I,I):I()}})}function w(p,h,d){var T="suspendedStart";return function(y,k){if(T==="executing")throw new Error("Generator is already running");if(T==="completed"){if(y==="throw")throw k;return ie()}for(d.method=y,d.arg=k;;){var I=d.delegate;if(I){var H=P(I,d);if(H){if(H===f)continue;return H}}if(d.method==="next")d.sent=d._sent=d.arg;else if(d.method==="throw"){if(T==="suspendedStart")throw T="completed",d.arg;d.dispatchException(d.arg)}else d.method==="return"&&d.abrupt("return",d.arg);T="executing";var z=c(p,h,d);if(z.type==="normal"){if(T=d.done?"completed":"suspendedYield",z.arg===f)continue;return{value:z.arg,done:d.done}}z.type==="throw"&&(T="completed",d.method="throw",d.arg=z.arg)}}}function P(p,h){var d=h.method,T=p.iterator[d];if(T===void 0)return h.delegate=null,d==="throw"&&p.iterator.return&&(h.method="return",h.arg=void 0,P(p,h),h.method==="throw")||d!=="return"&&(h.method="throw",h.arg=new TypeError("The iterator does not provide a '"+d+"' method")),f;var y=c(T,p.iterator,h.arg);if(y.type==="throw")return h.method="throw",h.arg=y.arg,h.delegate=null,f;var k=y.arg;return k?k.done?(h[p.resultName]=k.value,h.next=p.nextLoc,h.method!=="return"&&(h.method="next",h.arg=void 0),h.delegate=null,f):k:(h.method="throw",h.arg=new TypeError("iterator result is not an object"),h.delegate=null,f)}function Y(p){var h={tryLoc:p[0]};1 in p&&(h.catchLoc=p[1]),2 in p&&(h.finallyLoc=p[2],h.afterLoc=p[3]),this.tryEntries.push(h)}function L(p){var h=p.completion||{};h.type="normal",delete h.arg,p.completion=h}function J(p){this.tryEntries=[{tryLoc:"root"}],p.forEach(Y,this),this.reset(!0)}function V(p){if(p){var h=p[n];if(h)return h.call(p);if(typeof p.next=="function")return p;if(!isNaN(p.length)){var d=-1,T=function y(){for(;++d<p.length;)if(e.call(p,d))return y.value=p[d],y.done=!1,y;return y.value=void 0,y.done=!0,y};return T.next=T}}return{next:ie}}function ie(){return{value:void 0,done:!0}}return m.prototype=g,r(A,"constructor",{value:g,configurable:!0}),r(g,"constructor",{value:m,configurable:!0}),m.displayName=o(g,u,"GeneratorFunction"),i.isGeneratorFunction=function(p){var h=typeof p=="function"&&p.constructor;return!!h&&(h===m||(h.displayName||h.name)==="GeneratorFunction")},i.mark=function(p){return Object.setPrototypeOf?Object.setPrototypeOf(p,g):(p.__proto__=g,o(p,u,"GeneratorFunction")),p.prototype=Object.create(A),p},i.awrap=function(p){return{__await:p}},N(O.prototype),o(O.prototype,s,function(){return this}),i.AsyncIterator=O,i.async=function(p,h,d,T,y){y===void 0&&(y=Promise);var k=new O(l(p,h,d,T),y);return i.isGeneratorFunction(h)?k:k.next().then(function(I){return I.done?I.value:k.next()})},N(A),o(A,u,"Generator"),o(A,n,function(){return this}),o(A,"toString",function(){return"[object Generator]"}),i.keys=function(p){var h=Object(p),d=[];for(var T in h)d.push(T);return d.reverse(),function y(){for(;d.length;){var k=d.pop();if(k in h)return y.value=k,y.done=!1,y}return y.done=!0,y}},i.values=V,J.prototype={constructor:J,reset:function(p){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(L),!p)for(var h in this)h.charAt(0)==="t"&&e.call(this,h)&&!isNaN(+h.slice(1))&&(this[h]=void 0)},stop:function(){this.done=!0;var p=this.tryEntries[0].completion;if(p.type==="throw")throw p.arg;return this.rval},dispatchException:function(p){if(this.done)throw p;var h=this;function d(z,X){return k.type="throw",k.arg=p,h.next=z,X&&(h.method="next",h.arg=void 0),!!X}for(var T=this.tryEntries.length-1;T>=0;--T){var y=this.tryEntries[T],k=y.completion;if(y.tryLoc==="root")return d("end");if(y.tryLoc<=this.prev){var I=e.call(y,"catchLoc"),H=e.call(y,"finallyLoc");if(I&&H){if(this.prev<y.catchLoc)return d(y.catchLoc,!0);if(this.prev<y.finallyLoc)return d(y.finallyLoc)}else if(I){if(this.prev<y.catchLoc)return d(y.catchLoc,!0)}else{if(!H)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return d(y.finallyLoc)}}}},abrupt:function(p,h){for(var d=this.tryEntries.length-1;d>=0;--d){var T=this.tryEntries[d];if(T.tryLoc<=this.prev&&e.call(T,"finallyLoc")&&this.prev<T.finallyLoc){var y=T;break}}y&&(p==="break"||p==="continue")&&y.tryLoc<=h&&h<=y.finallyLoc&&(y=null);var k=y?y.completion:{};return k.type=p,k.arg=h,y?(this.method="next",this.next=y.finallyLoc,f):this.complete(k)},complete:function(p,h){if(p.type==="throw")throw p.arg;return p.type==="break"||p.type==="continue"?this.next=p.arg:p.type==="return"?(this.rval=this.arg=p.arg,this.method="return",this.next="end"):p.type==="normal"&&h&&(this.next=h),f},finish:function(p){for(var h=this.tryEntries.length-1;h>=0;--h){var d=this.tryEntries[h];if(d.finallyLoc===p)return this.complete(d.completion,d.afterLoc),L(d),f}},catch:function(p){for(var h=this.tryEntries.length-1;h>=0;--h){var d=this.tryEntries[h];if(d.tryLoc===p){var T=d.completion;if(T.type==="throw"){var y=T.arg;L(d)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(p,h,d){return this.delegate={iterator:V(p),resultName:h,nextLoc:d},this.method==="next"&&(this.arg=void 0),f}},i}function jt(i,a,e,r,t,n,s){try{var u=i[n](s),o=u.value}catch(l){e(l);return}u.done?a(o):Promise.resolve(o).then(r,t)}function ee(i){return function(){var a=this,e=arguments;return new Promise(function(r,t){var n=i.apply(a,e);function s(o){jt(n,r,t,s,u,"next",o)}function u(o){jt(n,r,t,s,u,"throw",o)}s(void 0)})}}function Be(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function Ht(i,a){for(var e=0;e<a.length;e++){var r=a[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,$t(r.key),r)}}function Ne(i,a,e){return a&&Ht(i.prototype,a),e&&Ht(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function R(i,a,e){return a=$t(a),a in i?Object.defineProperty(i,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[a]=e,i}function zt(i,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(a&&a.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),a&&dt(i,a)}function et(i){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},et(i)}function dt(i,a){return dt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},dt(i,a)}function Jr(){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 Zr(i,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return j(i)}function Wt(i){var a=Jr();return function(){var r=et(i),t;if(a){var n=et(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Zr(this,t)}}function ei(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,a||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function $t(i){var a=ei(i,"string");return typeof a=="symbol"?a:String(a)}function Xt(i,a){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);a&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),e.push.apply(e,r)}return e}function De(i){for(var a=1;a<arguments.length;a++){var e=arguments[a]!=null?arguments[a]:{};a%2?Xt(Object(e),!0).forEach(function(r){_(i,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Xt(Object(e)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r))})}return i}function Q(){Q=function(){return i};var i={},a=Object.prototype,e=a.hasOwnProperty,r=Object.defineProperty||function(p,h,d){p[h]=d.value},t=typeof Symbol=="function"?Symbol:{},n=t.iterator||"@@iterator",s=t.asyncIterator||"@@asyncIterator",u=t.toStringTag||"@@toStringTag";function o(p,h,d){return Object.defineProperty(p,h,{value:d,enumerable:!0,configurable:!0,writable:!0}),p[h]}try{o({},"")}catch{o=function(h,d,T){return h[d]=T}}function l(p,h,d,T){var y=h&&h.prototype instanceof v?h:v,k=Object.create(y.prototype),I=new J(T||[]);return r(k,"_invoke",{value:w(p,d,I)}),k}function c(p,h,d){try{return{type:"normal",arg:p.call(h,d)}}catch(T){return{type:"throw",arg:T}}}i.wrap=l;var f={};function v(){}function m(){}function g(){}var E={};o(E,n,function(){return this});var S=Object.getPrototypeOf,C=S&&S(S(V([])));C&&C!==a&&e.call(C,n)&&(E=C);var A=g.prototype=v.prototype=Object.create(E);function N(p){["next","throw","return"].forEach(function(h){o(p,h,function(d){return this._invoke(h,d)})})}function O(p,h){function d(y,k,I,H){var z=c(p[y],p,k);if(z.type!=="throw"){var X=z.arg,te=X.value;return te&&typeof te=="object"&&e.call(te,"__await")?h.resolve(te.__await).then(function(W){d("next",W,I,H)},function(W){d("throw",W,I,H)}):h.resolve(te).then(function(W){X.value=W,I(X)},function(W){return d("throw",W,I,H)})}H(z.arg)}var T;r(this,"_invoke",{value:function(y,k){function I(){return new h(function(H,z){d(y,k,H,z)})}return T=T?T.then(I,I):I()}})}function w(p,h,d){var T="suspendedStart";return function(y,k){if(T==="executing")throw new Error("Generator is already running");if(T==="completed"){if(y==="throw")throw k;return ie()}for(d.method=y,d.arg=k;;){var I=d.delegate;if(I){var H=P(I,d);if(H){if(H===f)continue;return H}}if(d.method==="next")d.sent=d._sent=d.arg;else if(d.method==="throw"){if(T==="suspendedStart")throw T="completed",d.arg;d.dispatchException(d.arg)}else d.method==="return"&&d.abrupt("return",d.arg);T="executing";var z=c(p,h,d);if(z.type==="normal"){if(T=d.done?"completed":"suspendedYield",z.arg===f)continue;return{value:z.arg,done:d.done}}z.type==="throw"&&(T="completed",d.method="throw",d.arg=z.arg)}}}function P(p,h){var d=h.method,T=p.iterator[d];if(T===void 0)return h.delegate=null,d==="throw"&&p.iterator.return&&(h.method="return",h.arg=void 0,P(p,h),h.method==="throw")||d!=="return"&&(h.method="throw",h.arg=new TypeError("The iterator does not provide a '"+d+"' method")),f;var y=c(T,p.iterator,h.arg);if(y.type==="throw")return h.method="throw",h.arg=y.arg,h.delegate=null,f;var k=y.arg;return k?k.done?(h[p.resultName]=k.value,h.next=p.nextLoc,h.method!=="return"&&(h.method="next",h.arg=void 0),h.delegate=null,f):k:(h.method="throw",h.arg=new TypeError("iterator result is not an object"),h.delegate=null,f)}function Y(p){var h={tryLoc:p[0]};1 in p&&(h.catchLoc=p[1]),2 in p&&(h.finallyLoc=p[2],h.afterLoc=p[3]),this.tryEntries.push(h)}function L(p){var h=p.completion||{};h.type="normal",delete h.arg,p.completion=h}function J(p){this.tryEntries=[{tryLoc:"root"}],p.forEach(Y,this),this.reset(!0)}function V(p){if(p){var h=p[n];if(h)return h.call(p);if(typeof p.next=="function")return p;if(!isNaN(p.length)){var d=-1,T=function y(){for(;++d<p.length;)if(e.call(p,d))return y.value=p[d],y.done=!1,y;return y.value=void 0,y.done=!0,y};return T.next=T}}return{next:ie}}function ie(){return{value:void 0,done:!0}}return m.prototype=g,r(A,"constructor",{value:g,configurable:!0}),r(g,"constructor",{value:m,configurable:!0}),m.displayName=o(g,u,"GeneratorFunction"),i.isGeneratorFunction=function(p){var h=typeof p=="function"&&p.constructor;return!!h&&(h===m||(h.displayName||h.name)==="GeneratorFunction")},i.mark=function(p){return Object.setPrototypeOf?Object.setPrototypeOf(p,g):(p.__proto__=g,o(p,u,"GeneratorFunction")),p.prototype=Object.create(A),p},i.awrap=function(p){return{__await:p}},N(O.prototype),o(O.prototype,s,function(){return this}),i.AsyncIterator=O,i.async=function(p,h,d,T,y){y===void 0&&(y=Promise);var k=new O(l(p,h,d,T),y);return i.isGeneratorFunction(h)?k:k.next().then(function(I){return I.done?I.value:k.next()})},N(A),o(A,u,"Generator"),o(A,n,function(){return this}),o(A,"toString",function(){return"[object Generator]"}),i.keys=function(p){var h=Object(p),d=[];for(var T in h)d.push(T);return d.reverse(),function y(){for(;d.length;){var k=d.pop();if(k in h)return y.value=k,y.done=!1,y}return y.done=!0,y}},i.values=V,J.prototype={constructor:J,reset:function(p){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(L),!p)for(var h in this)h.charAt(0)==="t"&&e.call(this,h)&&!isNaN(+h.slice(1))&&(this[h]=void 0)},stop:function(){this.done=!0;var p=this.tryEntries[0].completion;if(p.type==="throw")throw p.arg;return this.rval},dispatchException:function(p){if(this.done)throw p;var h=this;function d(z,X){return k.type="throw",k.arg=p,h.next=z,X&&(h.method="next",h.arg=void 0),!!X}for(var T=this.tryEntries.length-1;T>=0;--T){var y=this.tryEntries[T],k=y.completion;if(y.tryLoc==="root")return d("end");if(y.tryLoc<=this.prev){var I=e.call(y,"catchLoc"),H=e.call(y,"finallyLoc");if(I&&H){if(this.prev<y.catchLoc)return d(y.catchLoc,!0);if(this.prev<y.finallyLoc)return d(y.finallyLoc)}else if(I){if(this.prev<y.catchLoc)return d(y.catchLoc,!0)}else{if(!H)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return d(y.finallyLoc)}}}},abrupt:function(p,h){for(var d=this.tryEntries.length-1;d>=0;--d){var T=this.tryEntries[d];if(T.tryLoc<=this.prev&&e.call(T,"finallyLoc")&&this.prev<T.finallyLoc){var y=T;break}}y&&(p==="break"||p==="continue")&&y.tryLoc<=h&&h<=y.finallyLoc&&(y=null);var k=y?y.completion:{};return k.type=p,k.arg=h,y?(this.method="next",this.next=y.finallyLoc,f):this.complete(k)},complete:function(p,h){if(p.type==="throw")throw p.arg;return p.type==="break"||p.type==="continue"?this.next=p.arg:p.type==="return"?(this.rval=this.arg=p.arg,this.method="return",this.next="end"):p.type==="normal"&&h&&(this.next=h),f},finish:function(p){for(var h=this.tryEntries.length-1;h>=0;--h){var d=this.tryEntries[h];if(d.finallyLoc===p)return this.complete(d.completion,d.afterLoc),L(d),f}},catch:function(p){for(var h=this.tryEntries.length-1;h>=0;--h){var d=this.tryEntries[h];if(d.tryLoc===p){var T=d.completion;if(T.type==="throw"){var y=T.arg;L(d)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(p,h,d){return this.delegate={iterator:V(p),resultName:h,nextLoc:d},this.method==="next"&&(this.arg=void 0),f}},i}function Ee(i){"@babel/helpers - typeof";return Ee=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Ee(i)}function qt(i,a,e,r,t,n,s){try{var u=i[n](s),o=u.value}catch(l){e(l);return}u.done?a(o):Promise.resolve(o).then(r,t)}function ce(i){return function(){var a=this,e=arguments;return new Promise(function(r,t){var n=i.apply(a,e);function s(o){qt(n,r,t,s,u,"next",o)}function u(o){qt(n,r,t,s,u,"throw",o)}s(void 0)})}}function $(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function Yt(i,a){for(var e=0;e<a.length;e++){var r=a[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,tr(r.key),r)}}function K(i,a,e){return a&&Yt(i.prototype,a),e&&Yt(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function _(i,a,e){return a=tr(a),a in i?Object.defineProperty(i,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[a]=e,i}function ve(i,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(a&&a.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),a&&$e(i,a)}function Pe(i){return Pe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Pe(i)}function $e(i,a){return $e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},$e(i,a)}function Jt(){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 rt(i,a,e){return Jt()?rt=Reflect.construct.bind():rt=function(t,n,s){var u=[null];u.push.apply(u,n);var o=Function.bind.apply(t,u),l=new o;return s&&$e(l,s.prototype),l},rt.apply(null,arguments)}function ii(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function Ie(i){var a=typeof Map=="function"?new Map:void 0;return Ie=function(r){if(r===null||!ii(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a<"u"){if(a.has(r))return a.get(r);a.set(r,t)}function t(){return rt(r,arguments,Pe(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),$e(t,r)},Ie(i)}function ni(i,a){if(i==null)return{};var e={},r=Object.keys(i),t,n;for(n=0;n<r.length;n++)t=r[n],!(a.indexOf(t)>=0)&&(e[t]=i[t]);return e}function Zt(i,a){if(i==null)return{};var e=ni(i,a),r,t;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);for(t=0;t<n.length;t++)r=n[t],!(a.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(i,r)&&(e[r]=i[r])}return e}function D(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function ai(i,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return D(i)}function me(i){var a=Jt();return function(){var r=Pe(i),t;if(a){var n=Pe(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return ai(this,t)}}function si(i,a){for(;!Object.prototype.hasOwnProperty.call(i,a)&&(i=Pe(i),i!==null););return i}function We(){return typeof Reflect<"u"&&Reflect.get?We=Reflect.get.bind():We=function(a,e,r){var t=si(a,e);if(t){var n=Object.getOwnPropertyDescriptor(t,e);return n.get?n.get.call(arguments.length<3?a:r):n.value}},We.apply(this,arguments)}function oi(i,a){if(i){if(typeof i=="string")return Qt(i,a);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 Qt(i,a)}}function Qt(i,a){(a==null||a>i.length)&&(a=i.length);for(var e=0,r=new Array(a);e<a;e++)r[e]=i[e];return r}function er(i,a){var e=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!e){if(Array.isArray(i)||(e=oi(i))||a&&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(o){throw o},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,s=!1,u;return{s:function(){e=e.call(i)},n:function(){var o=e.next();return n=o.done,o},e:function(o){s=!0,u=o},f:function(){try{!n&&e.return!=null&&e.return()}finally{if(s)throw u}}}}function ui(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,a||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function tr(i){var a=ui(i,"string");return typeof a=="symbol"?a:String(a)}var Z=function(){function i(){$(this,i)}return K(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,s=e.length;n<s;n++){var u=t.length;if(!u||!r)t.push([e.start(n),e.end(n)]);else{var o=t[u-1],l=o[1],c=e.start(n);if(c-l<=r){var f=e.end(n);f>l&&(o[1]=f)}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,s=0,u=0,o=0,l=0,c=0,f=0,v=i.buffers(e,t),m=0,g=v.length;m<g;m++){var E=v[m];if(r+t>=E[0]&&r<=E[1])n=E[0],s=E[1],u=m;else if(r+t<E[0]){o=E[0],l=E[1];break}else r+t>E[1]&&(c=E[0],f=E[1])}return{start:n,end:s,index:u,buffers:v,nextStart:o,nextEnd:l,prevStart:c,prevEnd:f,currentTime:r,behind:r-n,remaining:s?s-r:0,length:i.totalLength&&i.totalLength(v)}}},{key:"isBuffered",value:function(e,r){if(e){var t=i.get(e);if(t!=null&&t.length){for(var n=0;n<t.length;n++)if(r>=t.start(n)&&r<=t.end(n))return!0}}return!1}}]),i}();var rr=typeof window<"u";var le,G={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",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",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"}},it=(le={},_(le,G.MANIFEST,{HLS:1100,DASH:1200}),_(le,G.NETWORK,2100),_(le,G.NETWORK_TIMEOUT,2101),_(le,G.NETWORK_FORBIDDEN,2103),_(le,G.NETWORK_NOTFOUND,2104),_(le,G.NETWROK_RANGE_NOT_SATISFIABLE,2116),_(le,G.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),_(le,G.REMUX,{FMP4:4100,MP4:4200}),_(le,G.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,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),_(le,G.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),_(le,G.OTHER,8e3),_(le,G.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),le),se=function(i){ve(e,i);var a=me(e);function e(r,t,n,s,u){var o;return $(this,e),o=a.call(this,u||n?.message),o.errorType=r===G.NETWORK_TIMEOUT?G.NETWORK:r,o.originError=n,o.ext=s,o.errorCode=it[r][t]||it[r],o.errorMessage=o.message,o.errorCode||(o.errorType=G.OTHER,o.errorCode=it[o.errorType]),o}return K(e,null,[{key:"create",value:function(t,n,s,u,o){return t instanceof e?t:(t instanceof Error&&(s=t,t=""),t||(t=G.OTHER),new e(t,n,s,u,o))}},{key:"network",value:function(t){var n;return new e(t!=null&&t.isTimeout?G.NETWORK_TIMEOUT:G.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}(Ie(Error));var Xe={DEBUG:1,LOG:2,WARN:3,ERROR:4},li=200*1024,ci=["Boolean","Number","String","Undefined","Null","Date","Object"],fe=function(){function i(a,e){$(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=e?.logCacheLevel||3,this.logMaxSize=e?.logMaxSize||li,this.logSize=0,this.logTextArray=[]}return K(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,[Xe.DEBUG].concat(t)),!i.disabled&&(e=console).debug.apply(e,["[".concat(Ke(),"]"),this._prefix].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,[Xe.LOG].concat(t)),!i.disabled&&(e=console).log.apply(e,["[".concat(Ke(),"]"),this._prefix].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,[Xe.WARN].concat(t)),!i.disabled&&(e=console).warn.apply(e,["[".concat(Ke(),"]"),this._prefix].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,[Xe.ERROR].concat(t)),!i.disabled&&(e=console).error.apply(e,["[".concat(Ke(),"]"),this._prefix].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),s=1;s<t;s++)n[s-1]=arguments[s];var u=n.map(function(l){return ir(l)});r="[".concat(Ke(),"]")+this._prefix+JSON.stringify(u)}catch{return}if(e>=this.logCacheLevel&&(this.logSize+=r.length,this.logTextArray.push(r)),this.logSize>this.logMaxSize){var o=this.logTextArray.shift();this.logSize-=o.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}();_(fe,"disabled",!0);function Ke(){return new Date().toLocaleString()}function fi(i){if(Ee(i)!=="object")return i;var a=Object.prototype.toString.call(i).slice(8,-1);switch(a){case"Array":case"Uint8Array":case"ArrayBuffer":return a+"["+i.length+"]";case"Object":return"{}";default:return a}}function ir(i,a,e){e||(e=1),a||(a=2);var r={};if(!i||Ee(i)!=="object")return i;var t=Object.prototype.toString.call(i).slice(8,-1);if(!ci.includes(t))return t;if(!(e>a)){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e===a?r[n]=fi(i[n]):Ee(i[n])==="object"?r[n]=ir(i[n],a,e+1):r[n]=i[n]);return r}}function Re(){var i,a,e=new Promise(function(r,t){i=r,a=t});return e.used=!1,e.resolve=function(){return e.used=!0,i.apply(void 0,arguments)},e.reject=function(){return e.used=!0,a.apply(void 0,arguments)},e}function Me(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var nr={stringify:function(a){try{return JSON.stringify(a)}catch{return""}},parse:function(a){try{return JSON.parse(a)}catch{return}}};function ar(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return rr?i&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function mt(i){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(i))}function hi(i){var a=[];if(i instanceof TimeRanges)for(var e=0;e<i.length;e++)a.push({start:i.start(e),end:i.end(e)});return a}var nt={APPEND:"appendBuffer",REMOVE:"removeBuffer",UPDATE_DURATION:"updateDuration"};var Le=function(){function i(a,e){var r=this;$(this,i),_(this,"media",null),_(this,"mediaSource",null),_(this,"_openPromise",Re()),_(this,"_queue",Object.create(null)),_(this,"_sourceBuffer",Object.create(null)),_(this,"_mseFullFlag",{}),_(this,"_st",0),_(this,"_opst",0),_(this,"_logger",null),_(this,"_config",null),_(this,"_url",null),_(this,"_onStartStreaming",function(){r._logger.debug("startstreaming")}),_(this,"_onEndStreaming",function(){r._logger.debug("endstreaming")}),_(this,"_onSBUpdateEnd",function(t){var n=r._queue[t];if(n){var s=n[0];if(s?.opName!==nt.UPDATE_DURATION&&n.shift(),s){var u,o,l=Me()-r._opst;r._logger.debug("UpdateEnd(".concat(t,"/").concat(s.opName,")"),nr.stringify(hi((u=r._sourceBuffer[t])===null||u===void 0?void 0:u.buffered)),l,s.context),s.promise.resolve({name:s.opName,context:s.context,costtime:l});var c=(o=s.context)===null||o===void 0?void 0:o.callback;c&&typeof c=="function"&&c(s.context),r._startQueue(t)}}}),_(this,"_onSBUpdateError",function(t,n){var s=r._queue[t];if(s){var u=s[0];u&&(r._logger.error("UpdateError",t,u.opName,u.context),u.promise.reject(new se(G.MEDIA,G.SUB_TYPES.MSE_APPEND_BUFFER,n)))}}),this._config=Object.assign(i.getDefaultConfig(),e),a&&this.bindMedia(a),this._logger=new fe("MSE"),this._config.openLog&&fe.enable()}return K(i,[{key:"isOpened",get:function(){var e;return((e=this.mediaSource)===null||e===void 0?void 0:e.readyState)==="open"}},{key:"hasOpTasks",get:function(){var e=this,r=!1;return Object.keys(this._queue).forEach(function(t){var n=e._queue[t];Array.isArray(n)&&(r||(r=n.length>0))}),r}},{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 mt(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(s){try{n=Math.max(r.bufferEnd(s)||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))},nt.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 s=Me()-e._st;e._logger.debug("sourceopen",s),r.removeEventListener("sourceopen",n),e._openPromise.resolve({costtime:s})};r.addEventListener("sourceopen",t),this._openPromise=Re()}return this._openPromise}},{key:"bindMedia",value:function(){var a=ce(Q().mark(function r(t){var n=this,s,u,o,l;return Q().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(!(this.mediaSource||this.media)){f.next=3;break}return f.next=3,this.unbindMedia();case 3:if(s=ar(this._config.preferMMS),!(!t||!s)){f.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,u=this.mediaSource=new s,o=mt(u),this._st=Me(),l=function v(){var m=Me()-n._st;n._logger.debug("sourceopen"),u.removeEventListener("sourceopen",v),URL.revokeObjectURL(t.src),n._openPromise.resolve({costtime:m})},u.addEventListener("sourceopen",l),o&&(u.addEventListener("startstreaming",this._onStartStreaming),u.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(u),t.src=this._url,t.disableRemotePlayback=o,f.abrupt("return",this._openPromise);case 17:case"end":return f.stop()}},r,this)}));function e(r){return a.apply(this,arguments)}return e}()},{key:"unbindMedia",value:function(){var a=ce(Q().mark(function r(){var t=this,n,s,u;return Q().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(c){var f=t._queue[c];f&&f.forEach(function(v){var m,g;return(m=v.promise)===null||m===void 0||(g=m.resolve)===null||g===void 0?void 0:g.call(m)})}),s=!!this.media&&this.media.readyState>=1,u=n.readyState==="open",s&&u)try{n.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(c){try{n.removeSourceBuffer(t._sourceBuffer[c])}catch{}}),mt(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=Re(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return l.stop()}},r,this)}));function e(){return a.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 se(G.MEDIA,G.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(new se(G.MEDIA,G.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,function(){try{n.changeType(r)}catch(s){throw new se(G.MEDIA,G.SUB_TYPES.MSE_CHANGE_TYPE,s)}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 s;!n.mediaSource||n.media.error||(n._logger.debug("MSE APPEND START",t),n._opst=Me(),(s=n._sourceBuffer[e])===null||s===void 0||s.appendBuffer(r))},nt.APPEND,t)}},{key:"remove",value:function(e,r,t,n){var s=this,u=!1;return this._mseFullFlag[e]&&(u=!0),this._enqueueOp(e,function(){if(!(!s.mediaSource||s.media.error)){var o=s._sourceBuffer[e];if(r>=t||!o){s._onSBUpdateEnd(e);return}s._opst=Me(),s._logger.debug("MSE REMOVE START",e,r,t,n),o.remove(r,t)}},nt.REMOVE,n,u)}},{key:"clearBuffer",value:function(e,r){var t=this,n;return Object.keys(this._sourceBuffer).forEach(function(s){n=t.remove(s,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,Z.end(Z.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 s=[];n.forEach(function(u){u.context&&u.context.isinit&&s.push(u)}),this._queue[e]=n.slice(0,2),s.length>0&&(t=this._queue[e]).push.apply(t,s)}}},{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 Z.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return Z.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return Z.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,r,t,n,s){var u=this;if(!this.mediaSource)return Promise.resolve();var o=this._queue[e]=this._queue[e]||[],l={exec:r,promise:Re(),opName:t,context:n};return s?(o.splice(0,0,l),this._mseFullFlag[e]=!1,this._startQueue(e)):o.push(l),this.isOpened||this.isEnded?o.length===1&&this._startQueue(e):this._openPromise.then(function(){o.length===1&&u._startQueue(e)}),l.promise}},{key:"_enqueueBlockingOp",value:function(){var a=ce(Q().mark(function r(t,n,s){var u=this,o,l;return Q().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.mediaSource){f.next=2;break}return f.abrupt("return",Promise.resolve());case 2:if(o=Object.keys(this._sourceBuffer),o.length){f.next=5;break}return f.abrupt("return",t());case 5:return l=[],o.forEach(function(v){var m=u._queue[v],g=Re();l.push(g),m.push({exec:function(){g.resolve()},promise:g,opName:n,context:s}),m.length===1&&u._startQueue(v)}),f.abrupt("return",Promise.all(l).then(function(){try{return t()}finally{o.forEach(function(v){var m=u._queue[v],g=u._sourceBuffer[v];m?.shift(),(!g||!g.updating)&&u._startQueue(v)})}}));case 8:case"end":return f.stop()}},r,this)}));function e(r,t,n){return a.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,t.context&&Ee(t.context)==="object"&&(t.context.isFull=!0),this._logger.error("[MSE error], context,",t.context," ,name,",t.opName,",err,SourceBuffer is full"),t.promise.reject(new se(G.MEDIA,G.SUB_TYPES.MSE_FULL,n))):(this._logger.error(n),t.promise.reject(n.constructor===se?n:new se(G.MEDIA,G.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=ar();if(!r)return!1;try{return r.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),i}();_(Le,"VIDEO","video");_(Le,"AUDIO","audio");var _e={FETCH:"fetch",XHR:"xhr"},xe={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"};var de=function(i){ve(e,i);var a=me(e);function e(r,t,n,s){var u;return $(this,e),u=a.call(this,s),_(D(u),"retryCount",0),_(D(u),"isTimeout",!1),_(D(u),"loaderType",_e.FETCH),_(D(u),"startTime",0),_(D(u),"endTime",0),_(D(u),"options",{}),u.url=r,u.request=t,u.response=n,u}return K(e)}(Ie(Error));var sr=Object.prototype.toString;function or(i){return i!==null&&Ee(i)==="object"}function _t(i){if(sr.call(i)!=="[object Object]")return!1;var a=Object.getPrototypeOf(i);return a===null||a===Object.prototype}function ur(i){return sr.call(i)==="[object Date]"}function at(i){if(!(!i||i[0]===null||i[0]===void 0||i[0]===0&&(i[1]===null||i[1]===void 0))){var a="bytes="+i[0]+"-";return i[1]&&(a+=i[1]),a}}function lr(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function st(i,a){if(i){if(!a)return i;var e,r=Object.keys(a).map(function(n){if(e=a[n],e!=null)return Array.isArray(e)?n=n+"[]":e=[e],e.map(function(s){return ur(s)?s=s.toISOString():or(s)&&(s=JSON.stringify(s)),"".concat(lr(n),"=").concat(lr(s))}).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 qe(i,a,e,r,t,n,s,u,o,l,c){t=t!=null?parseFloat(t):null,r=parseInt(r||"0",10),Number.isNaN(r)&&(r=0);var f={range:o,vid:l,index:u,contentLength:r,age:t,startTime:n,firstByteTime:s,endTime:Date.now(),priOptions:c};return{data:i,done:a,options:f,response:e}}function Ye(i,a){return Math.round(i*8*1e3/a/1024)}var x={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",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",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"};var fr=He(Fe()),cr=2*1024*1024,Qe=function(i){ve(e,i);var a=me(e);function e(){var r;return $(this,e),r=a.call(this),_(D(r),"_abortController",null),_(D(r),"_timeoutTimer",null),_(D(r),"_reader",null),_(D(r),"_response",null),_(D(r),"_aborted",!1),_(D(r),"_index",-1),_(D(r),"_range",null),_(D(r),"_receivedLength",0),_(D(r),"_running",!1),_(D(r),"_logger",null),_(D(r),"_vid",""),_(D(r),"_onProcessMinLen",0),_(D(r),"_onCancel",null),_(D(r),"_priOptions",null),r}return K(e,[{key:"load",value:function(t){var n,s=this,u=t.url,o=t.vid,l=t.timeout,c=t.responseType,f=t.onProgress,v=t.index,m=t.onTimeout,g=t.onCancel,E=t.range,S=t.transformResponse,C=t.request,A=t.params,N=t.logger,O=t.method,w=t.headers,P=t.body,Y=t.mode,L=t.credentials,J=t.cache,V=t.redirect,ie=t.referrer,p=t.referrerPolicy,h=t.onProcessMinLen,d=t.priOptions;this._logger=N,this._aborted=!1,this._onProcessMinLen=h,this._onCancel=g,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=v,this._range=E||[0,0],this._vid=o||u,this._priOptions=d||{};var T={method:O,headers:w,body:P,mode:Y,credentials:L,cache:J,redirect:V,referrer:ie,referrerPolicy:p,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},y=!1;clearTimeout(this._timeoutTimer),u=st(u,A);var k=at(E);k&&(C?w=C.headers:w=T.headers=T.headers||(Headers?new Headers:{}),Headers&&w instanceof Headers?w.append("Range",k):w.Range=k),l&&(this._timeoutTimer=setTimeout(function(){if(y=!0,s.cancel(),m){var H=new de(u,T,null,"timeout");H.isTimeout=!0,m(H,{index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions})}},l));var I=Date.now();return this._logger.debug("[fetch load start], index,",v,",range,",E),new Promise(function(H,z){fetch(C||u,C?void 0:T).then(function(){var X=ce(Q().mark(function te(W){var ht,Oe,pt,Ft;return Q().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(clearTimeout(s._timeoutTimer),s._response=W,!(s._aborted||!s._running)){re.next=4;break}return re.abrupt("return");case 4:if(S&&(W=S(W,u)||W),W.ok){re.next=7;break}throw new de(u,T,W,"bad network response");case 7:if(ht=Date.now(),c!==xe.TEXT){re.next=15;break}return re.next=11,W.text();case 11:Oe=re.sent,s._running=!1,re.next=37;break;case 15:if(c!==xe.JSON){re.next=22;break}return re.next=18,W.json();case 18:Oe=re.sent,s._running=!1,re.next=37;break;case 22:if(!f){re.next=29;break}return s.resolve=H,s.reject=z,s._loadChunk(W,f,I,ht),re.abrupt("return");case 29:return re.next=31,W.arrayBuffer();case 31:Oe=re.sent,Oe=new Uint8Array(Oe),s._running=!1,pt=Date.now()-I,Ft=Ye(Oe.byteLength,pt),s.emit(x.REAL_TIME_SPEED,{speed:Ft,len:Oe.byteLength,time:pt,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions});case 37:s._logger.debug("[fetch load end], index,",v,",range,",E),H(qe(Oe,!0,W,W.headers.get("Content-Length"),W.headers.get("age"),I,ht,v,E,s._vid,s._priOptions));case 39:case"end":return re.stop()}},te)}));return function(te){return X.apply(this,arguments)}}()).catch(function(X){var te;clearTimeout(s._timeoutTimer),s._running=!1,!(s._aborted&&!y)&&(X=X instanceof de?X:new de(u,T,null,(te=X)===null||te===void 0?void 0:te.message),X.startTime=I,X.endTime=Date.now(),X.isTimeout=y,X.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},z(X))})})}},{key:"cancel",value:function(){var r=ce(Q().mark(function n(){return Q().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!this._aborted){u.next=2;break}return u.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){u.next=14;break}if(u.prev=5,!this._reader){u.next=9;break}return u.next=9,this._reader.cancel();case 9:u.next=13;break;case 11:u.prev=11,u.t0=u.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 u.stop()}},n,this,[[5,11]])}));function t(){return r.apply(this,arguments)}return t}()},{key:"_loadChunk",value:function(t,n,s,u){var o=this;if(!t.body||!t.body.getReader){this._running=!1;var l=new de(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(cr),this._writeIdx=0);var c=this._reader=t.body.getReader(),f,v,m,g=function(){var E=ce(Q().mark(function S(){var C,A,N,O,w,P,Y,L;return Q().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return v=Date.now(),V.prev=1,V.next=4,c.read();case 4:f=V.sent,m=Date.now(),V.next=13;break;case 8:return V.prev=8,V.t0=V.catch(1),m=Date.now(),o._aborted||(o._running=!1,V.t0.options={index:o._index,range:o._range,vid:o._vid,priOptions:o._priOptions},o.reject(V.t0)),V.abrupt("return");case 13:if(A=((C=o._range)===null||C===void 0?void 0:C.length)>0?o._range[0]:0,N=A+o._receivedLength,!o._aborted){V.next=19;break}return o._running=!1,n(void 0,!1,{range:[N,N],vid:o._vid,index:o._index,startTime:v,endTime:m,st:s,firstByteTime:u,priOptions:o._priOptions},t),V.abrupt("return");case 19:O=f.value?f.value.byteLength:0,o._receivedLength+=O,o._logger.debug("\u3010fetchLoader,onProgress call\u3011,task,",o._range,", start,",N,", end,",A+o._receivedLength,", done,",f.done),o._onProcessMinLen>0?o._writeIdx+O>=o._onProcessMinLen||f.done?(w=new Uint8Array(o._writeIdx+O),w.set(o._cache.slice(0,o._writeIdx),0),O>0&&w.set(f.value,o._writeIdx),o._writeIdx=0,o._logger.debug("\u3010fetchLoader,onProgress enough\u3011,done,",f.done,",len,",w.byteLength,", writeIdx,",o._writeIdx)):O>0&&o._writeIdx+O<cr?(o._cache.set(f.value,o._writeIdx),o._writeIdx+=O,o._logger.debug("\u3010fetchLoader,onProgress cache\u3011,len,",O,", writeIdx,",o._writeIdx)):O>0&&(P=new Uint8Array(o._writeIdx+O+2048),o._logger.debug("\u3010fetchLoader,onProgress extra start\u3011,size,",o._writeIdx+O+2048,", datalen,",O,", writeIdx,",o._writeIdx),P.set(o._cache.slice(0,o._writeIdx),0),O>0&&P.set(f.value,o._writeIdx),o._writeIdx+=O,delete o._cache,o._cache=P,o._logger.debug("\u3010fetchLoader,onProgress extra end\u3011,len,",O,", writeIdx,",o._writeIdx)):w=f.value,(w&&w.byteLength>0||f.done)&&n(w,f.done,{range:[o._range[0]+o._receivedLength-(w?w.byteLength:0),o._range[0]+o._receivedLength],vid:o._vid,index:o._index,startTime:v,endTime:m,st:s,firstByteTime:u,priOptions:o._priOptions},t),f.done?(Y=Date.now()-s,L=Ye(o._receivedLength,Y),o.emit(x.REAL_TIME_SPEED,{speed:L,len:o._receivedLength,time:Y,vid:o._vid,index:o._index,range:o._range,priOptions:o._priOptions}),o._running=!1,o._logger.debug("[fetchLoader onProgress end],task,",o._range,",done,",f.done),o.resolve(qe(f,!0,t,t.headers.get("Content-Length"),t.headers.get("age"),s,u,o._index,o._range,o._vid,o._priOptions))):g();case 25:case"end":return V.stop()}},S,null,[[1,8]])}));return function(){return E.apply(this,arguments)}}();g()}},{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}(fr.default);function hr(i){return De({loaderType:_e.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:xe.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 pr=He(Fe()),dr=function(i){ve(e,i);var a=me(e);function e(){var r;return $(this,e),r=a.call(this),_(D(r),"_xhr",null),_(D(r),"_aborted",!1),_(D(r),"_timeoutTimer",null),_(D(r),"_range",null),_(D(r),"_receivedLength",0),_(D(r),"_url",null),_(D(r),"_onProgress",null),_(D(r),"_index",-1),_(D(r),"_headers",null),_(D(r),"_currentChunkSizeKB",384),_(D(r),"_timeout",null),_(D(r),"_xhr",null),_(D(r),"_withCredentials",null),_(D(r),"_startTime",-1),_(D(r),"_loadCompleteResolve",null),_(D(r),"_loadCompleteReject",null),_(D(r),"_runing",!1),_(D(r),"_logger",!1),_(D(r),"_vid",""),_(D(r),"_responseType",void 0),_(D(r),"_credentials",void 0),_(D(r),"_method",void 0),_(D(r),"_transformResponse",void 0),_(D(r),"_firstRtt",void 0),_(D(r),"_onCancel",null),_(D(r),"_priOptions",null),r}return K(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=st(t.url,t.params);var s=Date.now();return new Promise(function(u,o){n._loadCompleteResolve=u,n._loadCompleteReject=o,n._startLoad()}).catch(function(u){if(clearTimeout(n._timeoutTimer),n._runing=!1,!n._aborted)throw u=u instanceof de?u:new de(n._url,n._request),u.startTime=s,u.endTime=Date.now(),u.options={index:n._index,vid:n._vid,priOptions:n._priOptions},u})}},{key:"_startLoad",value:function(){var t=null;if(this._responseType===xe.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var n=this._currentChunkSizeKB*1024,s=this._range[0]+this._receivedLength,u=this._range[1];n<this._range[1]-s&&(u=s+n),t=[s,u],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 s=this._xhr=new XMLHttpRequest;s.open(this._method||"GET",this._url,!0),s.responseType=this._responseType,this._timeout&&(s.timeout=this._timeout),s.withCredentials=this._withCredentials,s.onload=this._onLoad.bind(this),s.onreadystatechange=this._onReadyStatechange.bind(this),s.onerror=function(l){var c,f,v;n._running=!1;var m=new de(n._url,n._request,l==null||(c=l.currentTarget)===null||c===void 0?void 0:c.response,"xhr.onerror.status:"+(l==null||(f=l.currentTarget)===null||f===void 0?void 0:f.status)+",statusText,"+(l==null||(v=l.currentTarget)===null||v===void 0?void 0:v.statusText));m.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n._loadCompleteReject(m)},s.ontimeout=function(l){n.cancel();var c=new de(n._url,n._request,{status:408},"timeout");n._onTimeout&&(c.isTimeout=!0,n._onTimeout(c,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})),c.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},n._loadCompleteReject(c)};var u=this._headers||{},o=at(t);o&&(u.Range=o),u&&Object.keys(u).forEach(function(l){s.setRequestHeader(l,u[l])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",t),s.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,s=t.target.status;if(s<200||s>299){var u=new de(this._url,null,De(De({},t.target.response),{},{status:s}),"bad response,status:"+s);return u.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(u)}var o=null,l=!1,c,f=((n=this._range)===null||n===void 0?void 0:n.length)>0?this._range[0]:0;if(this._responseType===xe.ARRAY_BUFFER){var v,m=new Uint8Array(t.target.response);if(c=f+this._receivedLength,m&&m.byteLength>0){this._receivedLength+=m.byteLength;var g=Date.now()-this._startTime,E=Ye(this._receivedLength,g);this.emit(x.REAL_TIME_SPEED,{speed:E,len:this._receivedLength,time:g,vid:this._vid,index:this._index,range:[c,f+this._receivedLength],priOptions:this._priOptions})}o=m,((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",c,"end ",f+this._receivedLength,",dataLen,",m?m.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",l)}else l=!0,o=t.target.response;var S={ok:s>=200&&s<300,status:s,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(S=this._transformResponse(S,this._url)||S),this._onProgress&&this._onProgress(o,l,{index:this._index,vid:this._vid,range:[c,f+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},S),l?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(qe(this._onProgress?null:o,l,S,S.headers["content-length"],S.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,We(Pe(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
+ `),s={},u=er(n),o;try{for(u.s();!(o=u.n()).done;){var l=o.value,c=l.split(": ");s[c[0].toLowerCase()]=c.slice(1).join(": ")}}catch(f){u.e(f)}finally{u.f()}return s}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),e}(pr.default);var pi=["retry","retryDelay","onRetryError","transformError"],vr=function(){function i(a,e){$(this,i),this.promise=Re(),this.alive=!!e.onProgress,!e.logger&&(e.logger=new fe("Loader")),this._loaderType=a,this._loader=a===_e.FETCH&&typeof fetch<"u"?new Qe:new dr,this._config=e,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=e.retryCheckFunc,this._logger=e.logger}return K(i,[{key:"exec",value:function(){var e=this,r=this._config,t=r.retry,n=r.retryDelay,s=r.onRetryError,u=r.transformError,o=Zt(r,pi),l=function(){var c=ce(Q().mark(function f(){var v,m,g;return Q().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.prev=0,S.next=3,e._loader.load(o);case 3:v=S.sent,e.promise.resolve(v),S.next=27;break;case 7:if(S.prev=7,S.t0=S.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",S.t0),!e._canceled){S.next=13;break}return S.abrupt("return");case 13:if(S.t0.loaderType=e._loaderType,S.t0.retryCount=e._retryCount,m=S.t0,u&&(m=u(m)||m),s&&e._retryCount>0&&s(m,e._retryCount,{index:o.index,vid:o.vid,range:o.range,priOptions:o.priOptions}),e._retryCount++,g=!0,e._retryCheckFunc&&(g=e._retryCheckFunc(S.t0)),!(g&&e._retryCount<=t)){S.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",o.range),e._retryTimer=setTimeout(l,n),S.abrupt("return");case 26:e.promise.reject(m);case 27:case"end":return S.stop()}},f,null,[[0,7]])}));return function(){return c.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:function(){var a=ce(Q().mark(function r(){return Q().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 a.apply(this,arguments)}return e}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),i}();function gt(i){return i&&!i.paused&&!i.ended&&i.playbackRate!==0&&i.readyState!==0}function yt(i){if(!i)return{};if(typeof i.getVideoPlaybackQuality=="function"){var a=i.getVideoPlaybackQuality();return{droppedVideoFrames:a.droppedVideoFrames||a.corruptedVideoFrames,totalVideoFrames:a.totalVideoFrames,creationTime:a.creationTime}}return{droppedVideoFrames:i.webkitDroppedFrameCount,totalVideoFrames:i.webkitDecodedFrameCount,creationTime:performance.now()}}function bt(){for(var i=arguments.length,a=new Array(i),e=0;e<i;e++)a[e]=arguments[e];if(a=a.filter(Boolean),a.length<2)return a[0];var r=new Uint8Array(a.reduce(function(n,s){return n+s.byteLength},0)),t=0;return a.forEach(function(n){r.set(n,t),t+=n.byteLength}),r}function St(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(a){return setTimeout(a,i)})}var mr=He(Fe()),Et=function(i){ve(e,i);var a=me(e);function e(r){var t;return $(this,e),t=a.call(this,r),_(D(t),"type",_e.FETCH),_(D(t),"_queue",[]),_(D(t),"_alive",[]),_(D(t),"_currentTask",null),_(D(t),"_finnalUrl",""),_(D(t),"_config",void 0),t._config=hr(r),(t._config.loaderType===_e.XHR||!Qe.isSupported())&&(t.type=_e.XHR),t.log=r.logger,t}return K(e,[{key:"isFetch",value:function(){return this.type===_e.FETCH}},{key:"load",value:function(t){var n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof t=="string"||!t?s.url=t||s.url||this._config.url:s=t,s=Object.assign({},this._config,s),s.params&&(s.params=Object.assign({},s.params)),s.headers&&_t(s.headers)&&(s.headers=Object.assign({},s.headers)),s.body&&_t(s.body)&&(s.body=Object.assign({},s.body)),s.transformRequest&&(s=s.transformRequest(s)||s),s.logger=this.log;var u=new vr(this.type,s);return u.loader.on(x.REAL_TIME_SPEED,function(o){n.emit(x.REAL_TIME_SPEED,o)}),this._queue.push(u),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),u.promise}},{key:"cancel",value:function(){var r=ce(Q().mark(function n(){var s;return Q().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return s=this._queue.map(function(l){return l.cancel()}).concat(this._alive.map(function(l){return l.cancel()})),this._currentTask&&s.push(this._currentTask.cancel()),this._queue=[],this._alive=[],o.next=6,Promise.all(s);case 6:return o.next=8,St();case 8:case"end":return o.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(s){});n&&typeof n.finally=="function"&&n.finally(function(){var s,u;(s=t._currentTask)!==null&&s!==void 0&&s.alive&&((u=t._alive)===null||u===void 0?void 0:u.length)>0&&(t._alive=t._alive.filter(function(o){return o&&o!==t._currentTask})),t._processTask()})}}}],[{key:"isFetchSupport",value:function(){return Qe.isSupported()}}]),e}(mr.default);var Tt=function(){function i(){$(this,i),_(this,"_prevCurrentTime",0)}return K(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 s=e.currentTime,u=0;if(this._prevCurrentTime===s){var o=Z.info(Z.get(e),s);if(!o.buffers.length)return;t&&o.nextStart||o.nextStart&&o.nextStart-s<r?u=o.nextStart+.1:o.end&&o.end-s>n&&!e.seeking&&(u=s+.1)}this._prevCurrentTime=s,u&&s!==u&&(e.currentTime=u)}}}]),i}();var wt=function(){function i(a){var e=this;$(this,i),_(this,"_seiSet",new Set),this.emitter=a,a.on(x.SEI,function(r){r&&e._seiSet.add(r)})}return K(i,[{key:"throw",value:function(e,r){var t=this;if(!(e==null||!this._seiSet.size)){var n=e-.2,s=e+.2,u=[];this._seiSet.forEach(function(o){o.time>=n&&o.time<=s&&u.push(o)}),u.forEach(function(o){t._seiSet.delete(o),t.emitter.emit(x.SEI_IN_TIME,o)}),r&&this._seiSet.forEach(function(o){o.time<e-5&&t._seiSet.delete(o)})}}},{key:"reset",value:function(){this._seiSet.clear()}}]),i}();var di=1e3,vi=50,mi=3,_i=3e3,Ct=function(){function i(a){$(this,i),_(this,"_chunkSpeed",0),_(this,"_chunkCache",[]),_(this,"_speeds",[]),_(this,"_totalSize",0),_(this,"_totalCost",0),this._opts=a||{}}return K(i,[{key:"addRecord",value:function(e,r){!e||!r||(this._speeds.push(8e3*e/r),this._speeds=this._speeds.slice(-mi))}},{key:"addChunkRecord",value:function(e,r){var t,n;if(!(!e||!r||e<(((t=this._opts)===null||t===void 0?void 0:t.skipChunkSize)||di))){this._totalSize+=e,this._totalCost+=r,this._chunkSpeed=8e3*e/r,this._chunkCache.push({size:e,duration:r,timestamp:performance.now()});var s=((n=this._opts)===null||n===void 0?void 0:n.chunkCountForSpeed)||vi;this._chunkCache.length>s&&(this._chunkCache=this._chunkCache.slice(-s))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(u,o){return u+=o})/this._speeds.length;var r=this._chunkCache[this._chunkCache.length-1],t=performance.now()-r.timestamp;t>(((e=this._opts)===null||e===void 0?void 0:e.longtimeNoReceived)||_i)&&this._chunkCache.push({size:0,duration:t,timestamp:performance.now()});var n=this._chunkCache.reduce(function(u,o){return u+=o.size},0),s=this._chunkCache.reduce(function(u,o){return u+=o.duration},0);return 8e3*n/s}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),i}();var Qn=He(Fe());var _r=function(){function i(a){$(this,i),_(this,"encodeType",""),_(this,"audioCodec",""),_(this,"videoCodec",""),_(this,"domain",""),_(this,"fps",0),_(this,"bitrate",0),_(this,"width",0),_(this,"height",0),_(this,"samplerate",0),_(this,"channelCount",0),_(this,"gop",0),_(this,"_bitsAccumulateSize",0),_(this,"_bitsAccumulateDuration",0),_(this,"_startGopId",-1),this._timescale=a}return K(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,s){return n+=s.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(s,u){return s+=u.length},0),r._bitsAccumulateDuration>=1e3&&(r.bitrate=r._bitsAccumulateSize*8,r._bitsAccumulateDuration=0,r._bitsAccumulateSize=0)})}}]),i}(),At=function(){function i(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;$(this,i),_(this,"_core",null),_(this,"_samples",[]),this._core=a,this._timescale=e,this._stats=new _r(e),this._bindEvents()}return K(i,[{key:"getStats",value:function(){var e,r,t,n,s,u,o,l,c,f,v,m=((e=this._core)===null||e===void 0?void 0:e.media)||{},g=m.currentTime,E=g===void 0?0:g,S=m.decodeFps,C=S===void 0?0:S;return De(De({},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||(s=n.speedInfo)===null||s===void 0?void 0:s.call(n).avgSpeed)||0,totalReceivedByte:((u=this._core)===null||u===void 0||(o=u.speedInfo)===null||o===void 0?void 0:o.call(u).totalSize)||0,totalReceivedCost:((l=this._core)===null||l===void 0||(c=l.speedInfo)===null||c===void 0?void 0:c.call(l).totalCost)||0,currentTime:E,bufferEnd:((f=this._core)===null||f===void 0||(v=f.bufferInfo())===null||v===void 0?void 0:v.remaining)||0,decodeFps:C})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(x.DEMUXED_TRACK,function(r){var t=r.videoTrack;return e._stats.updateBitrate(t.samples)}),this._core.on(x.FLV_SCRIPT_DATA,function(r){e._stats.setFpsFromScriptData(r)}),this._core.on(x.METADATA_PARSED,function(r){r.type==="video"?e._stats.setVideoMeta(r.track):e._stats.setAudioMeta(r.track)}),this._core.on(x.TTFB,function(r){e._stats.setDomain(r.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new _r(this._timescale)}}]),i}();var zr=He(Fe());function gi(i,a){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var r,t,n,s,u=[],o=!0,l=!1;try{if(n=(e=e.call(i)).next,a===0){if(Object(e)!==e)return;o=!1}else for(;!(o=(r=n.call(e)).done)&&(u.push(r.value),u.length!==a);o=!0);}catch(c){l=!0,t=c}finally{try{if(!o&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(l)throw t}}return u}}function M(i,a){if(!(i instanceof a))throw new TypeError("Cannot call a class as a function")}function gr(i,a){for(var e=0;e<a.length;e++){var r=a[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,Sr(r.key),r)}}function U(i,a,e){return a&&gr(i.prototype,a),e&&gr(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function b(i,a,e){return a=Sr(a),a in i?Object.defineProperty(i,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[a]=e,i}function Pt(i,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(a&&a.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),a&&kt(i,a)}function ot(i){return ot=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ot(i)}function kt(i,a){return kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},kt(i,a)}function yi(){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 bi(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Si(i,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return bi(i)}function Dt(i){var a=yi();return function(){var r=ot(i),t;if(a){var n=ot(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return Si(this,t)}}function yr(i,a){return Ti(i)||gi(i,a)||br(i,a)||Ai()}function ge(i){return Ei(i)||wi(i)||br(i)||Ci()}function Ei(i){if(Array.isArray(i))return Ot(i)}function Ti(i){if(Array.isArray(i))return i}function wi(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function br(i,a){if(i){if(typeof i=="string")return Ot(i,a);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 Ot(i,a)}}function Ot(i,a){(a==null||a>i.length)&&(a=i.length);for(var e=0,r=new Array(a);e<a;e++)r[e]=i[e];return r}function Ci(){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 ki(i,a){if(typeof i!="object"||i===null)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,a||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(i)}function Sr(i){var a=ki(i,"string");return typeof a=="symbol"?a:String(a)}var ye={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},we={AV1:"av1",AVC:"avc",HEVC:"hevc"},q={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus"},ue={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"};var Er=function(){function i(){M(this,i),b(this,"id",1),b(this,"type",ye.VIDEO),b(this,"codecType",we.AVC),b(this,"pid",-1),b(this,"hvcC",void 0),b(this,"codec",""),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"sequenceNumber",0),b(this,"baseMediaDecodeTime",0),b(this,"baseDts",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"pps",[]),b(this,"sps",[]),b(this,"vps",[]),b(this,"fpsNum",0),b(this,"fpsDen",0),b(this,"sarRatio",[]),b(this,"width",0),b(this,"height",0),b(this,"nalUnitSize",4),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"isVideo",!0),b(this,"lastKeyFrameDts",0),b(this,"kid",null),b(this,"pssh",null),b(this,"ext",void 0)}return U(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:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],r=this.samples[this.samples.length-1];return r.dts-e.dts+r.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),i}();var Tr=function(){function i(){M(this,i),b(this,"id",2),b(this,"type",ye.AUDIO),b(this,"codecType",q.AAC),b(this,"pid",-1),b(this,"codec",""),b(this,"sequenceNumber",0),b(this,"sampleDuration",0),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"baseMediaDecodeTime",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"baseDts",0),b(this,"sampleSize",16),b(this,"sampleRate",0),b(this,"channelCount",0),b(this,"objectType",0),b(this,"sampleRateIndex",0),b(this,"config",[]),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"kid",null),b(this,"ext",void 0)}return U(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===q.AAC||this.codecType===q.G711PCMA||this.codecType===q.G711PCMU||this.codecType===q.OPUS))}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],r=this.samples[this.samples.length-1];return r.dts-e.dts+r.duration}return 0}}]),i}();var wr=function(){function i(a,e,r){M(this,i),b(this,"flag",{}),b(this,"keyframe",!1),b(this,"gopId",0),b(this,"duration",0),b(this,"size",0),b(this,"units",[]),b(this,"chromaFormat",420),this.originPts=this.pts=a,this.originDts=this.dts=e,r&&(this.units=r)}return U(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}();var Ge=U(function i(a,e,r,t){M(this,i),b(this,"duration",1024),b(this,"flag",{dependsOn:2,isNonSyncSample:0}),b(this,"keyframe",!0),this.originPts=this.pts=this.dts=a,this.data=e,this.size=e.byteLength,this.sampleOffset=t,r&&(this.duration=r)});var Cr=U(function i(a,e){M(this,i),b(this,"time",0),this.data=a,this.originPts=this.pts=e}),Ar=function(i){Pt(e,i);var a=Dt(e);function e(){return M(this,e),a.apply(this,arguments)}return U(e)}(Cr),kr=function(i){Pt(e,i);var a=Dt(e);function e(){return M(this,e),a.apply(this,arguments)}return U(e)}(Cr),Or=function(){function i(){M(this,i),b(this,"id",3),b(this,"type",ye.METADATA),b(this,"timescale",0),b(this,"flvScriptSamples",[]),b(this,"seiSamples",[])}return U(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}();var Ue=function(){function i(a){M(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]")}return U(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}();b(Ue,"disabled",!0);var ut=typeof window<"u",Rt=ut&&navigator.userAgent.toLocaleLowerCase(),Pr=ut&&/^((?!chrome|android).)*safari/.test(Rt),Dr=ut&&Rt.includes("firefox"),Rr=ut&&Rt.includes("android");var Ve=function(){function i(){M(this,i)}return U(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 s=n,u=[],o=(e[n+2]&60)>>>2,l=i.FREQ[o];if(!l)throw new Error("Invalid sampling index: ".concat(o));for(var c=((e[n+2]&192)>>>6)+1,f=(e[n+2]&1)<<2|(e[n+3]&192)>>>6,v=i._getConfig(o,f,c),m=v.config,g=v.codec,E,S,C=0,A=i.getFrameDuration(l);n+7<t;){if(e[n]!==255||(e[n+1]&246)!==240){n++;continue}if(S=(e[n+3]&3)<<11|e[n+4]<<3|(e[n+5]&224)>>5,!S||t-n<S)break;E=(~e[n+1]&1)*2,u.push({pts:r+C*A,data:e.subarray(n+7+E,n+S)}),C++,n+=S}return{skip:s,remaining:n>=t?void 0:e.subarray(n),frames:u,samplingFrequencyIndex:o,sampleRate:l,objectType:c,channelCount:f,codec:g,config:m,originCodec:"mp4a.40.".concat(c)}}}},{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,s=i.FREQ[t];if(s){var u=i._getConfig(t,n,r),o=u.config,l=u.codec;return{samplingFrequencyIndex:t,sampleRate:s,objectType:r,channelCount:n,config:o,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=[],s,u;return Dr?e>=6?(s=5,u=e-3):(s=2,u=e):Rr?(s=2,u=e):(s=t===2||t===5?t:5,u=e,e>=6?u=e-3:r===1&&(s=2,u=e)),n[0]=s<<3,n[0]|=(e&14)>>1,n[1]=(e&1)<<7,n[1]|=r<<3,s===5&&(n[1]|=(u&14)>>1,n[2]=(u&1)<<7,n[2]|=8,n[3]=0),{config:n,codec:"mp4a.40.".concat(s)}}},{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}();b(Ve,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Je=function(){function i(){M(this,i)}return U(i,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength),t="",n=0;n<8;n++)t+=String.fromCodePoint(e[n]);if(t!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var s=e[9];console.log("Pre-skip",e[10],e[11]);var u=r.getUint32(12,!0),o=r.getInt16(16,!0);if(u){var l="opus",c="opus",f=new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8);return{outputGain:o,sampleRate:u,channelCount:s,config:f,codec:l,originCodec:c}}}}}]),i}();var Oi=500,Lr=3,Lt=1e3,xt=5e3,Pi=1e3,Di=200,xr=5e3,Ir=5,Mr=function(){function i(a,e,r){M(this,i),this.videoTrack=a,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 U(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 s=this.videoTrack,u=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(u,s),!n&&r&&(this._audioNextPts=this._videoNextDts=r);var o=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(o&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(u),this._keyFrameInNextChunk=!1,this._fixVideo(s),this.metadataTrack.exist()){var l=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(c){c.pts=c.originPts-e._baseDts,c.time=Math.max(0,c.pts)/l}),this.metadataTrack.flvScriptSamples.forEach(function(c){c.pts=c.originPts-e._baseDts,c.time=Math.max(0,c.pts)/l})}s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].dts),u.samples.length&&(u.baseMediaDecodeTime=u.samples[0].pts*u.timescale/1e3)}},{key:"_fixVideo",value:function(e){var r=this,t=e.samples;if(t.length){t.forEach(function(A){A.dts-=r._baseDts,A.pts-=r._baseDts,A.keyframe&&(r._keyFrameInNextChunk=!0)});var n;if(e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var s=e.samples[0],u=e.samples[t.length-1];n=Math.floor((u.dts-s.dts)/(t.length-1))}else n=this._lastVideoDuration||40;var o=t.pop();if(this._videoLastSample&&t.unshift(this._videoLastSample),this._videoLastSample=o,!!t.length){if(this._videoNextDts===void 0){var l=t[0];this._videoNextDts=l.dts}var c=t.length,f=0,v=t[0],m=this._videoNextDts-v.dts;if(Math.abs(m)>Di){if(Math.abs(v.dts-this._lastVideoExceptionChunkFirstDtsDot)>xr){var g;this._lastVideoExceptionChunkFirstDtsDot=v.dts,e.warnings.push({type:ue.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:v.dts,nextSampleDts:(g=t[1])===null||g===void 0?void 0:g.dts,sampleDuration:m})}this._videoTimestampBreak>=Ir?(this._videoNextDts=v.dts,this._videoTimestampBreak=0):(v.dts+=m,v.pts+=m,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var E=0;E<c;E++){var S=t[E].dts,C=t[E+1];E<c-1?f=C.dts-S:o?f=o.dts-S:f=n,(f>Pi||f<0)&&(this._videoTimestampBreak++,Math.abs(S-this._lastVideoExceptionLargeGapDot)>xr&&(this._lastVideoExceptionLargeGapDot=S,e.warnings.push({type:ue.LARGE_VIDEO_GAP,time:S/e.timescale,dts:S,originDts:t[E].originDts,nextDts:this._videoNextDts,sampleDuration:f,refSampleDuration:n})),f=n),t[E].duration=f,this._videoNextDts+=f,this._lastVideoDuration=f}}}}},{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 s=1/0,u=1/0;t.length&&(e.baseDts=s=t[0].pts),n.length&&(r.baseDts=u=n[0].dts),this._baseDts=Math.min(s,u);var o=u-s;return Number.isFinite(o)&&Math.abs(o)>Oi&&r.warnings.push({type:ue.LARGE_AV_SHIFT,videoBaseDts:u,audioBasePts:s,baseDts:this._baseDts,delta:o}),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){if(!e.sampleDuration)switch(e.codecType){case q.AAC:{e.sampleDuration=Ve.getFrameDuration(e.timescale,t);break}case q.OPUS:{e.sampleDuration=Je.getFrameDuration(e.samples,t);break}case q.G711PCMA:case q.G711PCMU:{e.sampleDuration=this._getG711Duration(e);break}default:console.error("can't fix audio codecType:",e.codecType);break}var n=e.sampleDuration,s=e.codecType===q.OPUS?20:e.codecType===q.AAC?1024:n*e.timescale/1e3;if(this._audioNextPts===void 0){var u=r[0];this._audioNextPts=u.pts}for(var o=0;o<r.length;o++){var l=this._audioNextPts,c=r[o],f=c.pts-l;if(o===0&&this._audioTimestampBreak>=Ir&&this._keyFrameInNextChunk&&(l=this._audioNextPts=c.dts,f=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&f>=Lr*n&&f<=Lt&&!Pr){var v=this._getSilentFrame(e)||r[0].data.subarray(),m=Math.floor(f/n);Math.abs(c.pts-this._lastAudioExceptionGapDot)>xt&&(this._lastAudioExceptionGapDot=c.pts,e.warnings.push({type:ue.AUDIO_FILLED,pts:c.pts,originPts:c.originPts,count:m,nextPts:l,refSampleDuration:n}));for(var g=0;g<m;g++){var E=new Ge(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),v,s);E.originPts=Math.floor(this._baseDts+l),r.splice(o,0,E),this._audioNextPts+=n,o++}o--}else if(f<=-Lr*n&&f>=-1*Lt)Math.abs(c.pts-this._lastAudioExceptionOverlapDot)>xt&&(this._lastAudioExceptionOverlapDot=c.pts,e.warnings.push({type:ue.AUDIO_DROPPED,pts:c.pts,originPts:c.originPts,nextPts:l,refSampleDuration:n})),r.splice(o,1),o--;else{if(Math.abs(f)>Lt&&(this._audioTimestampBreak++,Math.abs(c.pts-this._lastAudioExceptionLargeGapDot)>xt&&(this._lastAudioExceptionLargeGapDot=c.pts,e.warnings.push({type:ue.LARGE_AUDIO_GAP,time:c.pts/1e3,pts:c.pts,originPts:c.originPts,nextPts:l,sampleDuration:f,refSampleDuration:n}))),e.codecType===q.OPUS){var S=r[r.length-1];S&&(S.duration=c.pts-S.pts)}else c.dts=c.pts=l,c.duration=s;this._audioNextPts+=n}}}},{key:"_getG711Duration",value:function(e){var r=e.sampleSize,t=e.channelCount,n=e.sampleRate,s=e.samples[0];if(s)return s.data.byteLength*2/t/(r/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===q.AAC?Ve.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),i}();function he(){for(var i=arguments.length,a=new Array(i),e=0;e<i;e++)a[e]=arguments[e];a=a.filter(Boolean);var r=new Uint8Array(a.reduce(function(n,s){return n+s.byteLength},0)),t=0;return a.forEach(function(n){r.set(n,t),t+=n.byteLength}),r}var Ha=Math.pow(2,32);function je(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i[a]<<24>>>0)+(i[a+1]<<16)+(i[a+2]<<8)+(i[a+3]||0)}function Ur(i){for(var a="avc1.",e,r=0;r<3;r++)e=i[r].toString(16),e.length<2&&(e="0".concat(e)),a+=e;return a}function It(i){if(!Array.isArray(i)){for(var a=[],e="",r=0;r<i.length;r++)r%2&&(e=i[r-1]+i[r],a.push(parseInt(e,16)),e="");return a}return i.map(function(t){return parseInt(t,16)})}var Ce=function(){function i(){M(this,i)}return U(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 s=[];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&&s.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&&s.push(e.subarray(t,n-2)),t=n+1,n=t+2;break;default:n+=3;break}return t<r&&s.push(e.subarray(t)),s}},{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=[],s=0,u;s+r<t;)if(u=je(e,s),r===3&&(u>>>=8),s+=r,!!u){if(s+u>t)break;n.push(e.subarray(s,s+u)),s+=u}return n}}},{key:"parseSEI",value:function(e,r){for(var t=e.length,n=r?2:1,s=0,u=0,o="";e[n]===255;)s+=255,n++;for(s+=e[n++];e[n]===255;)u+=255,n++;if(u+=e[n++],s===5&&t>n+16)for(var l=0;l<16;l++)o+=e[n].toString(16),n++;return{payload:e.subarray(n,n+u),type:s,size:u,uuid:o}}},{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 s=r-t.length,u=new Uint8Array(s),o=0;for(n=0;n<s;o++,n++)o===t[0]&&(o++,t.shift()),u[n]=e[o];return u}}]),i}();var Ze=function(){function i(a){if(M(this,i),b(this,"_bytesAvailable",void 0),b(this,"_bitsAvailable",0),b(this,"_word",0),!a)throw new Error("ExpGolomb data params is required");this._data=a,this._bytesAvailable=a.byteLength,this._bytesAvailable&&this._loadWord()}return U(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,s=0;s<e;s++)t!==0&&(n=this.readEG(),t=(r+n+256)%256),r=t===0?r:t}}]),i}();var Br=function(){function i(){M(this,i)}return U(i,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(e){if(!(e.length<7)){for(var r=(e[4]&3)+1,t,n=[],s=[],u=6,o=e[5]&31,l,c=0;c<o;c++)if(l=e[u]<<8|e[u+1],u+=2,!!l){var f=e.subarray(u,u+l);u+=l,n.push(f),t||(t=i.parseSPS(Ce.removeEPB(f)))}var v=e[u];u++;for(var m,g=0;g<v;g++)m=e[u]<<8|e[u+1],u+=2,m&&(s.push(e.subarray(u,u+m)),u+=m);return{sps:t,spsArr:n,ppsArr:s,nalUnitSize:r}}}},{key:"parseSPS",value:function(e){var r=new Ze(e);r.readUByte();var t=r.readUByte(),n=r.readUByte(),s=r.readUByte();r.skipUEG();var u=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 o=r.readUEG();if(o<=3&&(u=[0,420,422,444][o]),o===3&&r.skipBits(1),r.skipUEG(),r.skipUEG(),r.skipBits(1),r.readBool())for(var l=o!==3?8:12,c=0;c<l;c++)r.readBool()&&(c<6?r.skipScalingList(16):r.skipScalingList(64))}r.skipUEG();var f=r.readUEG();if(f===0)r.readUEG();else if(f===1){r.skipBits(1),r.skipUEG(),r.skipUEG();for(var v=r.readUEG(),m=0;m<v;m++)r.skipUEG()}r.skipUEG(),r.skipBits(1);var g=r.readUEG(),E=r.readUEG(),S=r.readBits(1);S===0&&r.skipBits(1),r.skipBits(1);var C=0,A=0,N=0,O=0;r.readBool()&&(C=r.readUEG(),A=r.readUEG(),N=r.readUEG(),O=r.readUEG());var w,P,Y,L,J;if(r.readBool()){if(r.readBool()){var V=r.readUByte();switch(V){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:{w=[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 ie=r.readBits(32),p=r.readBits(32);P=r.readBool(),Y=p,L=ie*2,J=Y/L}}return{codec:Ur(e.subarray(1,4)),profileIdc:t,profileCompatibility:n,levelIdc:s,chromaFormat:u,width:Math.ceil((g+1)*16-2*(C+A)),height:(2-S)*(E+1)*16-(S?2:4)*(N+O),sarRatio:w,fpsNum:Y,fpsDen:L,fps:J,fixedFrame:P}}}]),i}();var Nr=function(){function i(){M(this,i)}return U(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,s,u=[],o=[],l=[],c=23,f=e[22],v,m,g,E=0;E<f;E++){v=e[c]&63,m=e[c+1]<<8|e[c+2],c+=3;for(var S=0;S<m;S++)if(g=e[c]<<8|e[c+1],c+=2,!!g){switch(v){case 32:{var C=e.subarray(c,c+g);n||(n=i.parseVPS(Ce.removeEPB(C),r)),l.push(C)}break;case 33:{var A=e.subarray(c,c+g);s||(s=i.parseSPS(Ce.removeEPB(A),r)),u.push(A)}break;case 34:o.push(e.subarray(c,c+g));break}c+=g}}return{hvcC:r,sps:s,spsArr:u,ppsArr:o,vpsArr:l,nalUnitSize:t}}}},{key:"parseVPS",value:function(e,r){r=r||{};var t=new Ze(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 Ze(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 s=r.chromaFormatIdc=t.readUEG(),u=420;s<=3&&(u=[0,420,422,444][s]);var o=0;s===3&&(o=t.readBits(1));var l=t.readUEG(),c=t.readUEG(),f=t.readBits(1),v,m,g,E;if(f===1&&(v=t.readUEG(),m=t.readUEG(),g=t.readUEG(),E=t.readUEG()),r.bitDepthLumaMinus8=t.readUEG(),r.bitDepthChromaMinus8=t.readUEG(),f===1){var S=(s===1||s===2)&&o===0?2:1,C=s===1&&o===0?2:1;l-=S*(m+v),c-=C*(E+g)}return{codec:"hev1.1.6.L93.B0",width:l,height:c,chromaFormat:u,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 s=e.readBits(8);n<t.generalTierFlag?t.generalLevelIdc=s:t.generalLevelIdc=Math.max(s,t.generalLevelIdc||0);var u=[],o=[];if(r>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(r));for(var l=0;l<r;l++)u[l]=e.readBits(1),o[l]=e.readBits(1);r>0&&e.readBits((8-r)*2);for(var c=0;c<r;c++)u[c]!==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)),o[c]!==0&&e.readBits(8)}}]),i}();var Mt=function(){function i(){M(this,i)}return U(i,null,[{key:"decode",value:function(e){for(var r=[],t=e,n=0,s=e.length;n<s;){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 u=(t[n]&31)<<6|t[n+1]&63;if(u>=128){r.push(String.fromCharCode(u&65535)),n+=2;continue}}}else if(t[n]<240){if(i._checkContinuation(t,n,2)){var o=(t[n]&15)<<12|(t[n+1]&63)<<6|t[n+2]&63;if(o>=2048&&(o&63488)!==55296){r.push(String.fromCharCode(o&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}();var Fr=function(){function i(){M(this,i)}return U(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,s=!1,u;switch(t){case 0:u=e.getFloat64(1),n+=8;break;case 1:{u=!!e.getUint8(1),n+=1;break}case 2:{var o=i._parseString(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n)),l=o.data,c=o.size;u=l,n+=c}break;case 3:{u={};var f=0;for((e.getUint32(r-4)&16777215)===9&&(f=3);n<r-4;){var v=i._parseObject(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n-f)),m=v.size,g=v.data,E=v.isEnd;if(E)break;u[g.name]=g.value,n+=m}if(n<=r-3){var S=e.getUint32(n-1)&16777215;S===9&&(n+=3)}}break;case 8:{u={},n+=4;var C=0;for((e.getUint32(r-4)&16777215)===9&&(C=3);n<r-8;){var A=i._parseObject(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n-C)),N=A.size,O=A.data,w=A.isEnd;if(w)break;u[O.name]=O.value,n+=N}if(n<=r-3){var P=e.getUint32(n-1)&16777215;P===9&&(n+=3)}}break;case 9:u=void 0,n=1,s=!0;break;case 10:{u=[];var Y=e.getUint32(1);n+=4;for(var L=0;L<Y;L++){var J=i._parseValue(new DataView(e.buffer,e.byteOffset+n,e.byteLength-n)),V=J.data,ie=J.size;u.push(V),n+=ie}}break;case 11:{var p=e.getFloat64(n)+e.getInt16(n+8)*6e4;u=new Date(p),n+=10}break;case 12:{var h=e.getUint32(1);n+=4,u="",h>0&&(u=Mt.decode(new Uint8Array(e.buffer,e.byteOffset+n,h))),n+=h}break;default:n=r;break}return{data:u,size:n,isEnd:s}}},{key:"_parseString",value:function(e){var r=e.getUint16(0),t="";return r>0&&(t=Mt.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}();var be={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13};var Se=new Ue("FlvDemuxer"),lt=function(){function i(a,e,r){M(this,i),b(this,"_headerParsed",!1),b(this,"_remainingData",null),b(this,"_gopId",0),b(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=a||new Er,this.audioTrack=e||new Tr,this.metadataTrack=r||new Or,this._fixer=new Mr(this.videoTrack,this.audioTrack,this.metadataTrack)}return U(i,[{key:"demux",value:function(e){var r,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3?arguments[3]:void 0,u=this.audioTrack,o=this.videoTrack,l=this.metadataTrack;if((t||!n)&&(this._remainingData=null),t&&(this._headerParsed=!1),t?(o.reset(),u.reset(),l.reset()):(o.samples=[],u.samples=[],l.seiSamples=[],l.flvScriptSamples=[],o.warnings=[],u.warnings=[],this._remainingData&&(e=he(this._remainingData,e),this._remainingData=null)),!e.length)return{videoTrack:o,audioTrack:u,metadataTrack:l};var c=0;if(!this._headerParsed){if(!i.probe(e))throw new Error("Invalid flv file");u.present=(e[4]&4)>>>2!==0,o.present=(e[4]&1)!==0,this._headerParsed=!0,c=je(e,5)+4}for(var f=e.length,v,m,g,E,S;c+15<f&&(v=e[c],m=e[c+1]<<16|e[c+2]<<8|e[c+3],!(c+15+m>f));)g=(e[c+7]<<24>>>0)+(e[c+4]<<16)+(e[c+5]<<8)+e[c+6],c+=11,E=e.subarray(c,c+m),v===8?this._parseAudio(E,g):v===9?(s&&(this.seamlessLoadingSwitching=!0),this._parseVideo(E,g)):v===18?this._parseScript(E,g):Se.warn("Invalid tag type: ".concat(v)),c+=m,S=je(e,c),S!==11+m&&Se.warn("Invalid PrevTagSize ".concat(S," (").concat(11+m,")")),c+=4;c<f&&(this._remainingData=e.subarray(c)),u.formatTimescale=o.formatTimescale=o.timescale=l.timescale=1e3,u.timescale=u.codecType===q.OPUS?1e3:u.sampleRate||0,!u.exist()&&u.hasSample()&&u.reset(),!o.exist()&&o.hasSample()&&o.reset();var C=l.flvScriptSamples[l.flvScriptSamples.length-1],A=C==null||(r=C.data)===null||r===void 0?void 0:r.onMetaData;return A&&(o!=null&&o.exist()&&(A.hasOwnProperty("duration")&&(o.duration=A.duration*1e3),A.hasOwnProperty("width")&&A.hasOwnProperty("height")&&(o.width=A.width,o.height=A.height)),u!=null&&u.exist()&&A.hasOwnProperty("duration")&&(u.duration=A.duration*1e3)),{videoTrack:o,audioTrack:u,metadataTrack:l}}},{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,s){return this.demux(e,r,t,s),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!==be.AAC&&t!==be.G711A&&t!==be.G711M&&t!==be.OPUS){Se.warn("Unsupported sound format: ".concat(t)),n.reset();return}if(t!==be.AAC&&t!==be.OPUS){var s=(e[0]&12)>>2,u=(e[0]&2)>>1,o=e[0]&1;n.sampleRate=i.AUDIO_RATE[s],n.sampleSize=u?16:8,n.channelCount=o+1}switch(t){case be.G711A:case be.G711M:this._parseG711(e,r,t);break;case be.AAC:this._parseAac(e,r);break;case be.OPUS:this._parseOpus(e,r);break}}}},{key:"_parseOpus",value:function(e,r){var t=this.audioTrack,n=e[1];switch(t.codecType=q.OPUS,n){case 0:{var s=Je.parseHeaderPackets(e.subarray(2));s?(t.codec=s.codec,t.channelCount=s.channelCount,t.sampleRate=s.sampleRate,t.config=s.config,t.sampleDuration=Je.getFrameDuration([],t.timescale)):(t.reset(),Se.warn("Cannot parse AudioSpecificConfig",e));break}case 1:{if(r==null)return;var u=new Ge(r,e.subarray(2),t.sampleDuration);t.samples.push(u);break}default:Se.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,r,t){var n=this.audioTrack;n.codecType=t===7?q.G711PCMA:q.G711PCMU,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new Ge(r,e.subarray(1)))}},{key:"_parseAac",value:function(e,r){var t=this.audioTrack;if(t.codecType=q.AAC,e[1]===0){var n=Ve.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(),Se.warn("Cannot parse AudioSpecificConfig",e))}else if(e[1]===1){if(r==null)return;t.samples.push(new Ge(r,e.subarray(2)))}else Se.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,s=e[0]&15,u=this.videoTrack;if(s!==7&&s!==12){u.reset(),Se.warn("Unsupported codecId: ".concat(s));return}var o=s===12;u.codecType=o?we.HEVC:we.AVC;var l=e[1],c=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(l===0){var f=e.subarray(5),v=o?Nr.parseHEVCDecoderConfigurationRecord(f):Br.parseAVCDecoderConfigurationRecord(f);if(v){var m=v.hvcC,g=v.sps,E=v.ppsArr,S=v.spsArr,C=v.vpsArr,A=v.nalUnitSize;m&&(u.hvcC=u.hvcC||m),g&&(u.codec=g.codec,u.width=g.width,u.height=g.height,u.sarRatio=g.sarRatio,u.fpsNum=g.fpsNum,u.fpsDen=g.fpsDen),S.length&&(u.sps=S),E.length&&(u.pps=E),C&&C.length&&(u.vps=C),A&&(u.nalUnitSize=A)}else Se.warn("Cannot parse ".concat(o?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(l===1){var N=Ce.parseAvcC(e.subarray(5),u.nalUnitSize);if(N=this._checkAddMetaNalToUnits(o,N,u),N&&N.length){var O=new wr(r+c,r,N);if(this.seamlessLoadingSwitching&&r<u.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,n===1&&(O.setToKeyframe(),u.lastKeyFrameDts=r),u.samples.push(O),N.forEach(function(w){var P=o?w[0]>>>1&63:w[0]&31;switch(P){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!o&&P!==5||o&&P===5)break;O.setToKeyframe();break;case 6:case 39:case 40:if(!o&&P!==6||o&&P===6)break;t.metadataTrack.seiSamples.push(new kr(Ce.parseSEI(Ce.removeEPB(w),o),r+c));break}}),O.keyframe&&this._gopId++,O.gopId=this._gopId}else Se.warn("Cannot parse NALUs",e)}else l===2||Se.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(s){return s[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 Ar(Fr.parse(e),r))}}],[{key:"probe",value:function(e){return e[0]!==70||e[1]!==76||e[2]!==86||e[3]!==1?!1:je(e,5)>=9}}]),i}();b(lt,"AUDIO_RATE",[5500,11e3,22e3,44e3]);function Ri(i){for(var a=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(u){a+=u.length});var n=new i(a),s=0;return r.forEach(function(u){n.set(u,s),s+=u.length}),n}var ne=function(){function i(){M(this,i),this.buffer=new Uint8Array(0)}return U(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(s){s?e.buffer=Ri(Uint8Array,e.buffer,s):window.console.warn(s)})}}],[{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}();var Gr=Math.pow(2,32)-1,B=function(){function i(){M(this,i)}return U(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 s=8+t.reduce(function(l,c){return l+c.byteLength},0),u=new Uint8Array(s);u[0]=s>>24&255,u[1]=s>>16&255,u[2]=s>>8&255,u[3]=s&255,u.set(e,4);var o=8;return t.forEach(function(l){u.set(l,o),o+=l.byteLength}),u}},{key:"ftyp",value:function(e){var r=e.find(function(t){return t.type===ye.VIDEO&&t.codecType===we.HEVC});return r?i.FTYPHEV1:i.FTYPAVC1}},{key:"initSegment",value:function(e){var r=i.ftyp(e),t=he(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],It(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(ge(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(ge(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,s=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 s}},{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===ye.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):e.codecType===q.OPUS?r=i.opus(e):r=i.mp4a(e):e.useEME&&e.encv?r=i.encv(e):e.av1C?r=i.av01(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]),s=i.esds(e.config),u=i.sinf(e.enca);return i.box(i.types.enca,n,s,u)}},{key:"encv",value:function(e){var r,t,n=e.sps.length>0?e.sps[0]:[],s=e.pps.length>0?e.pps[0]:[],u=e.width,o=e.height,l=e.sarRatio[0],c=e.sarRatio[1],f=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,u>>8&255,u&255,o>>8&255,o&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,ge(n)).concat([1,s.length>>>8&255,s.length&255])).concat.apply(r,ge(s))),m=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),g=i.sinf(e.encv),E=new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,c>>24,c>>16&255,c>>8&255,c&255]);return i.box(i.types.encv,f,i.box(i.types.avcC,v),i.box(i.types.btrt,m),g,i.box(i.types.pasp,E))}},{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(It(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]),s=i.schi(e);return i.box(i.types.sinf,r,i.box(i.types.frma,t),i.box(i.types.schm,n),s)}},{key:"av01",value:function(e){return i.box(i.types.av01,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]),e.av1C,e.colr)}},{key:"avc1hev1",value:function(e){var r=e.codecType===we.HEVC,t=r?i.types.hvc1:i.types.avc1,n=r?i.hvcC(e):i.avcC(e),s=[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?s.push(i.box(i.types.fiel,new Uint8Array([1,0]))):e.sarRatio&&e.sarRatio.length>1&&s.push(i.pasp(e.sarRatio)),i.box.apply(i,[t].concat(s))}},{key:"avcC",value:function(e){var r,t,n=[],s=[],u;return e.sps.forEach(function(o){u=o.byteLength,n.push(u>>>8&255),n.push(u&255),n.push.apply(n,ge(o))}),e.pps.forEach(function(o){u=o.byteLength,s.push(u>>>8&255),s.push(u&255),s.push.apply(s,ge(o))}),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,s)))}},{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,s=e.pps,u;if(r){var o=r.generalProfileCompatibilityFlags,l=r.generalConstraintIndicatorFlags,c=(t.length&&1)+(n.length&&1)+(s.length&&1);u=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,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,c];var f=function(m){var g;u.push(m.length>>8,m.length),(g=u).push.apply(g,ge(m))};t.length&&(u.push(160,0,t.length),t.forEach(f)),n.length&&(u.push(161,0,n.length),n.forEach(f)),s.length&&(u.push(162,0,s.length),s.forEach(f))}else u=[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(u))}},{key:"pasp",value:function(e){var r=yr(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:"opus",value:function(e){var r=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]),t=e.config.length?i.dOps(e):[];return i.box(i.types.Opus,r,t)}},{key:"dOps",value:function(e){if(e.config)return e.config[4]=e.sampleRate>>>24&255,e.config[5]=e.sampleRate>>>16&255,e.config[6]=e.sampleRate>>>8&255,e.config[7]=e.sampleRate&255,i.box(i.types.dOps,e.config)}},{key:"mvex",value:function(e){var r=i.box.apply(i,[i.types.mvex].concat(ge(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(ge(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,s;if(e.isVideo&&e.videoSenc&&(s=e.videoSenc,s.forEach(function(h){n=n+8,h.subsamples&&h.subsamples.length&&(n=n+2,n=n+h.subsamples.length*6)})),e.videoSencLength=n,!e.useEME||!e.isVideoEncryption&&!e.isAudioEncryption){var u=i.sdtp(e),o=76;return i.box(i.types.traf,r,t,u,i.trun(e.samples,u.byteLength+o))}else if(e.isVideoEncryption)if(e.isVideo){var l=i.saiz(e),c=i.saio(e),f=i.trun1(e),v=i.senc(e),m=i.box(i.types.traf,r,t,l,c,f,v);return m}else if(e.isAudioEncryption){var S=i.sbgp(),C=i.saiz(e),A=i.saio(e),N=i.senc(e),O=i.trun1(e),w=i.box(i.types.traf,r,t,S,C,A,N,O);return w}else{var g=i.sbgp(),E=i.trun1(e);return i.box(i.types.traf,r,t,g,E)}else if(e.isVideo){var P=i.trun1(e);return i.box(i.types.traf,r,t,P)}else{var Y=i.sbgp(),L=i.saiz(e),J=i.saio(e),V=i.senc(e),ie=i.trun1(e),p=i.box(i.types.traf,r,t,Y,L,J,V,ie);return p}}},{key:"sdtp",value:function(e){var r=new ne;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 ne,t=ne.writeUint32(e.samples.length),n=null;if(e.isVideo){var s=e.videoSencLength;n=ne.writeUint32(e.samples.length*16+s+149),!e.isVideoEncryption&&e.isAudioEncryption&&(n=ne.writeUint32(e.samples.length*16+92))}else{var u=e.samples.length*12+124;e.isAudioEncryption&&(u=e.samples.length*12+8*e.audioSenc.length+177),n=ne.writeUint32(u)}return e.samples.forEach(function(o){r.write(ne.writeUint32(o.duration)),r.write(ne.writeUint32(o.size)),r.write(ne.writeUint32(o.keyframe?33554432:65536)),e.isVideo&&r.write(ne.writeUint32(o.cts?o.cts:0))}),i.box(i.types.trun,this.extension(0,e.flags),t,n,r.buffer)}},{key:"senc",value:function(e){var r=new ne,t=e.samples.length,n=e.isVideo?16:8,s=e.isVideo?2:0,u=[],o=0;return e.isVideo?(u=e.videoSenc,o=e.videoSencLength):u=e.audioSenc,o=o||n*t,r.write(ne.writeUint32(16+o),i.types.senc,this.extension(0,s)),r.write(ne.writeUint32(t)),u.forEach(function(l){for(var c=0;c<l.InitializationVector.length;c++)r.write(new Uint8Array([l.InitializationVector[c]]));l.subsamples&&l.subsamples.length&&(r.write(ne.writeUint16(l.subsamples.length)),l.subsamples.forEach(function(f){r.write(ne.writeUint16(f.BytesOfClearData)),r.write(ne.writeUint32(f.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/(Gr+1)),n=Math.floor(r%(Gr+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 s=new Uint8Array(n);s.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 u=0;u<t;u++){var o=e[u],l=o.duration,c=o.size,f=o.flag,v=f===void 0?{}:f,m=o.cts,g=m===void 0?0:m;s.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&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,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*u)}return i.box(i.types.trun,s)}},{key:"moovMP4",value:function(e){return i.box.apply(i,[i.types.moov,i.mvhd(e[0].duration,e[0].timescale)].concat(ge(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===ye.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(s){var u=s.value,o=s.count;t.set([o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255],n),n+=8}),i.box(i.types.stts,he(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(s){var u=s.firstChunk,o=s.samplesPerChunk,l=s.sampleDescIndex;t.set([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255],n),n+=12}),i.box(i.types.stsc,he(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(s){t.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stsz,he(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(s){t.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stco,he(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(s){t.set([s>>24,s>>16&255,s>>8&255,s&255],n),n+=4}),i.box(i.types.stss,he(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(s){var u=s.value,o=s.count;t.set([o>>24,o>>16&255,o>>8&255,o&255,u>>24,u>>16&255,u>>8&255,u&255],n),n+=8}),i.box(i.types.ctts,he(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,s=e.samples[0].sampleOffset*t,u=8;e.samples.forEach(function(v){u+=v.size});var o=0;if(e.isVideo){var l=0,c;e.videoSenc&&(c=e.videoSenc),e.isVideo&&c.forEach(function(v){l=l+8,v.subsamples&&v.subsamples.length&&(l=l+2,l=l+v.subsamples.length*6)}),e.videoSencLength=l,o=u+141+e.samples.length*16+l,e.useEME&&e.isAudioEncryption&&!e.isVideoEncryption&&(o=u+e.samples.length*16+84)}else o=u+116+e.samples.length*12,e.useEME&&e.isAudioEncryption&&(o=u+169+e.samples.length*12+8*e.audioSenc.length);var f=new Uint8Array([0,0,0,0,0,0,0,e.id&255,r>>24&255,r>>16&255,r>>8&255,r&255,s>>24&255,s>>16&255,s>>8&255,s&255,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,o&255,n>>24&255,n>>16&255,n>>8&255,n&255,144,0,0,0]);return i.box(i.types.sidx,f)}},{key:"mdat",value:function(e){var r=i.box(i.types.mdat,e);return r}}]),i}();b(B,"types",["Opus","dOps","av01","av1C","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,a){return i[a]=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)],i},Object.create(null)));b(B,"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])});b(B,"FTYPAVC1",B.box(B.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));b(B,"FTYPHEV1",B.box(B.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));b(B,"DINF",B.box(B.types.dinf,B.box(B.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));b(B,"VMHD",B.box(B.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));b(B,"SMHD",B.box(B.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));b(B,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));b(B,"STTS",B.box(B.types.stts,B.StblTable));b(B,"STSC",B.box(B.types.stsc,B.StblTable));b(B,"STSZ",B.box(B.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));b(B,"STCO",B.box(B.types.stco,B.StblTable));var Ut=function(){function i(a,e){M(this,i),this.name=a||"",this._prefix="[".concat(this.name,"]"),i.disabled=e}return U(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}();b(Ut,"disabled",!0);var Bt=function(){function i(a,e,r){M(this,i),this.videoTrack=a,this.audioTrack=e;var t=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=t&&Number(t[1])<50,this.log=new Ut("FMP4Remuxer",r&&r.openLog?!r.openLog:!0)}return U(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,s=t.exist(),u=n.exist(),o,l,c,f=[];e&&(r&&r.initMerge?(s&&f.push(this.videoTrack),u&&f.push(this.audioTrack),c=B.initSegment(f)):(s&&(o=B.initSegment([this.videoTrack])),u&&(l=B.initSegment([this.audioTrack]))));var v,m;return s&&t.hasSample()&&(v=this._remuxVideo()),u&&n.hasSample()&&(m=this._remuxAudio()),t.samples=[],n.samples=[],{initSegment:c,videoInitSegment:o,audioInitSegment:l,videoSegment:v,audioSegment:m}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var r=e.samples,t=/av01/.test(e.codec),n=0;t?r.forEach(function(N){n+=N.data.byteLength}):r.forEach(function(N){n+=N.units.reduce(function(O,w){return O+w.byteLength},0),n+=N.units.length*4});var s=new Uint8Array(n);if(t)for(var u=0,o=r.length,l=0,c;u<o;u++)c=r[u],s.set(c.data,l),c.size=c.data.byteLength,l+=c.size;else for(var f=new DataView(s.buffer),v=function(O,w){w=r[m];var P=0;w.units.forEach(function(Y){f.setUint32(O,Y.byteLength),O+=4,s.set(Y,O),O+=Y.byteLength,P+=4+Y.byteLength}),w.size=P,E=O,S=w},m=0,g=r.length,E=0,S;m<g;m++)v(E,S);var C=B.mdat(s),A=B.moof([e]);return he(A,C)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,r=new Uint8Array(e.samples.reduce(function(s,u){return s+u.size},0));e.samples.reduce(function(s,u){return r.set(u.data,s),s+u.size},0);var t=B.mdat(r),n=B.moof([e]);return he(n,t)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),i}();var Vr=function(){function i(){Be(this,i),R(this,"_ttfb",0),R(this,"_demuxStart",0),R(this,"_demuxEnd",0),R(this,"_demuxCost",0),R(this,"_remuxStart",0),R(this,"_remuxEnd",0),R(this,"_remuxCost",0),R(this,"_appendStart",0),R(this,"_appendEnd",0),R(this,"_appendCost",0)}return Ne(i,[{key:"set",value:function(e,r){this["_".concat(e)]=r}},{key:"start",value:function(e){this["_".concat(e,"Start")]=Date.now()}},{key:"end",value:function(e){this["_".concat(e,"End")]=Date.now(),this["_".concat(e,"Cost")]=this["_".concat(e,"Cost")]+(this["_".concat(e,"End")]-this["_".concat(e,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),i}(),Ae={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"};var ke=new fe("BufferService"),jr=function(){function i(a,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Be(this,i),R(this,"flv",null),R(this,"_demuxer",new lt),R(this,"_remuxer",null),R(this,"_mse",null),R(this,"_softVideo",null),R(this,"_sourceCreated",!1),R(this,"_needInitSegment",!0),R(this,"_discontinuity",!0),R(this,"_contiguous",!1),R(this,"_initSegmentId",""),R(this,"_cachedBuffer",null),R(this,"_demuxStartTime",0),R(this,"_opts",null),this.flv=a,this._opts=r,e?this._softVideo=e:(this._remuxer=new Bt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new Le(null,{preferMMS:typeof r.preferMMS=="boolean"?r.preferMMS:!!r.perferMMS}),this._mse.bindMedia(a.media))}return Ne(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]:Le.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 a=ee(F().mark(function r(){var t,n=arguments;return F().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(t=n.length>0&&n[0]!==void 0?n[0]:!1,!(this._mse&&!t)){u.next=6;break}return u.next=4,this._mse.unbindMedia();case 4:return u.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return u.stop()}},r,this)}));function e(){return a.apply(this,arguments)}return e}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var a=ee(F().mark(function r(){return F().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(x.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 a.apply(this,arguments)}return e}()},{key:"updateDuration",value:function(){var a=ee(F().mark(function r(t){return F().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this._mse){s.next=7;break}if(this._mse.isOpened){s.next=4;break}return s.next=4,this._mse.open();case 4:return ke.debug("update duration",t),s.next=7,this._mse.updateDuration(t);case 7:case"end":return s.stop()}},r,this)}));function e(r){return a.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var a=ee(F().mark(function r(){return F().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 a.apply(this,arguments)}return e}()},{key:"appendBuffer",value:function(){var a=ee(F().mark(function r(t){var n=this,s,u,o,l,c,f,v,m,g,E,S,C,A,N,O,w,P;return F().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(s=!1,this._cachedBuffer&&(t=bt(this._cachedBuffer,t),this._cachedBuffer=null),u=this._demuxer,!(!t||!t.length||!u)){L.next=5;break}return L.abrupt("return");case 5:L.prev=5,this.flv._transferCost.start(Ae.DEMUX),u.demuxAndFix(t,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(Ae.DEMUX),L.next=15;break;case 12:throw L.prev=12,L.t0=L.catch(5),new se(G.DEMUX,G.SUB_TYPES.FLV,L.t0);case 15:if(o=u.videoTrack,l=u.audioTrack,c=u.metadataTrack,!this.seamlessLoadingSwitch){L.next=25;break}if(f=o.samples.findIndex(function(J){return J.originDts===o.lastKeyFrameDts}),!(f>=0)){L.next=25;break}return o.samples.splice(f),L.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,t=null,s=!0;case 25:if(v=o.exist(),m=l.exist(),this._opts.onlyAudio&&(v=!1,o.present=!1),this._opts.onlyVideo&&(m=!1,l.present=!1),!(!v&&o.present||!m&&l.present)){L.next=42;break}if(g=0,E=v?o:m?l:void 0,E&&E.samples.length&&(g=(E.samples[E.samples.length-1].originPts-E.samples[0].originPts)/E.timescale*1e3),!(g>this._opts.analyzeDuration)){L.next=40;break}ke.warn("analyze duration exceeded, ".concat(g,"ms"),E),o.present=v,l.present=m,this.flv.emit(x.ANALYZE_DURATION_EXCEEDED,{duration:g}),L.next=42;break;case 40:return this._cachedBuffer=t,L.abrupt("return");case 42:if(S=o.type,C=l.type,this._fireEvents(o,l,c),s||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),A=this._mse,N=function(){var V;if((V=n.flv)!==null&&V!==void 0&&V.emit){var ie;(ie=n.flv)===null||ie===void 0||ie.emit(x.APPEND_BUFFER,{})}},this.flv.emit(x.DEMUXED_TRACK,{videoTrack:o}),O="".concat(o.codec,"/").concat(o.width,"/").concat(o.height,"/").concat(l.codec,"/").concat(l.config),O!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=O,this._emitMetaParsedEvent(o,l)),!A){L.next=81;break}if(this._sourceCreated){L.next=59;break}return L.next=55,A.open();case 55:v&&(ke.log("codec: video/mp4;codecs=".concat(o.codec)),A.createSource(S,"video/mp4;codecs=".concat(o.codec))),m&&(ke.log("codec: audio/mp4;codecs=".concat(l.codec)),A.createSource(C,"audio/mp4;codecs=".concat(l.codec))),this._sourceCreated=!0,this.flv.emit(x.SOURCEBUFFER_CREATED);case 59:L.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(o.duration=this._opts.durationForMSELowLatencyOff*o.timescale,l.duration=this._opts.durationForMSELowLatencyOff*m.timescale),this.flv._transferCost.start(Ae.REMUX),w=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(Ae.REMUX),L.next=69;break;case 66:throw L.prev=66,L.t1=L.catch(59),new se(G.REMUX,G.SUB_TYPES.FMP4,L.t1);case 69:if(!(this._needInitSegment&&!w.videoInitSegment&&!w.audioInitSegment)){L.next=71;break}return L.abrupt("return");case 71:return this._needInitSegment=!1,P=[],w.videoInitSegment&&P.push(A.append(S,w.videoInitSegment)),w.audioInitSegment&&P.push(A.append(C,w.audioInitSegment)),w.videoSegment&&P.push(A.append(S,w.videoSegment)),w.audioSegment&&P.push(A.append(C,w.audioSegment)),this.flv._transferCost.start(Ae.APPEND),L.abrupt("return",Promise.all(P).then(N).then(function(){n.flv._transferCost.end(Ae.APPEND),N()}));case 81:this._softVideo&&(this._softVideo.appendBuffer(o,l),N());case 82:case"end":return L.stop()}},r,this,[[5,12],[59,66]])}));function e(r){return a.apply(this,arguments)}return e}()},{key:"evictBuffer",value:function(){var a=ee(F().mark(function r(t){var n=this,s,u,o,l;return F().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(s=this.flv.media,!(!this._mse||!this._demuxer||!s||!t||t<0)){f.next=3;break}return f.abrupt("return");case 3:if(u=s.currentTime,o=u-t,!(o<=0)){f.next=7;break}return f.abrupt("return");case 7:if(l=Z.start(Z.get(s)),!(l+1>=o)){f.next=10;break}return f.abrupt("return");case 10:return f.abrupt("return",this._mse.clearBuffer(0,o).then(function(){return n.flv.emit(x.REMOVE_BUFFER,{removeEnd:o})}));case 11:case"end":return f.stop()}},r,this)}));function e(r){return a.apply(this,arguments)}return e}()},{key:"_emitMetaParsedEvent",value:function(e,r){e.exist()&&this.flv.emit(x.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(x.METADATA_PARSED,{type:"audio",track:r,meta:{codec:r.codec,channelCount:r.channelCount,sampleRate:r.sampleRate,timescale:r.timescale,baseDts:r.baseDts}}),ke.debug("track parsed",e,r)}},{key:"_fireEvents",value:function(e,r,t){var n=this;ke.debug("videoTrack samples count: ".concat(e.samples.length,", audioTrack samples count: ").concat(r.samples.length)),t.flvScriptSamples.forEach(function(s){n.flv.emit(x.FLV_SCRIPT_DATA,s),ke.debug("flvScriptData",s)}),e.samples.forEach(function(s){s.keyframe&&n.flv.emit(x.KEYFRAME,{pts:s.originPts})}),e.warnings.forEach(function(s){var u;switch(s.type){case ue.LARGE_AV_SHIFT:u=x.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case ue.LARGE_VIDEO_GAP:u=x.LARGE_VIDEO_DTS_GAP_DETECT;break;case ue.LARGE_VIDEO_GAP_BETWEEN_CHUNK:u=x.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}u&&n.flv.emit(x.STREAM_EXCEPTION,pe(pe({},s),{},{type:u})),ke.warn("video exception",s)}),r.warnings.forEach(function(s){var u;switch(s.type){case ue.LARGE_AUDIO_GAP:u=x.LARGE_AUDIO_DTS_GAP_DETECT;break;case ue.AUDIO_FILLED:u=x.AUDIO_GAP_DETECT;break;case ue.AUDIO_DROPPED:u=x.AUDIO_OVERLAP_DETECT;break}u&&n.flv.emit(x.STREAM_EXCEPTION,pe(pe({},s),{},{type:u})),ke.warn("audio exception",s)}),t.seiSamples.forEach(function(s){n.flv.emit(x.SEI,pe(pe({},s),{},{sei:{code:s.data.type,content:s.data.payload,dts:s.pts}}))})}}]),i}();function Hr(i){var a=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,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},i);return a.isLive&&a.preloadTime&&(a.maxLatency||(a.maxLatency=a.preloadTime*2),a.targetLatency||(a.targetLatency=a.preloadTime),(a.disconnectTime===null||a.disconnectTime===void 0)&&(a.disconnectTime=a.maxLatency)),a}function Nt(i,a){var e=0,r=i.length-1,t=0,n=0,s=r;for(a<i[0]&&(e=0,n=s+1);n<=s;)if(t=n+Math.floor((s-n)/2),t===r||a>=i[t]&&a<i[t+1]){e=t;break}else i[t]<a?n=t+1:s=t-1;return e}var Te=new fe("flv"),ct=.1,Li=.3,ft=function(i){zt(e,i);var a=Wt(e);function e(r){var t;return Be(this,e),t=a.call(this),R(j(t),"media",null),R(j(t),"_loading",!1),R(j(t),"_opts",null),R(j(t),"_bufferService",null),R(j(t),"_gapService",null),R(j(t),"_stats",null),R(j(t),"_mediaLoader",null),R(j(t),"_maxChunkWaitTimer",null),R(j(t),"_tickTimer",null),R(j(t),"_tickInterval",500),R(j(t),"_urlSwitching",!1),R(j(t),"_seamlessSwitching",!1),R(j(t),"_disconnectRetryCount",0),R(j(t),"_preLoadEndPoint",0),R(j(t),"_keyframes",null),R(j(t),"_acceptRanges",!0),R(j(t),"_onProgress",function(){var n=ee(F().mark(function s(u,o,l,c){var f,v,m,g,E,S,C,A,N,O;return F().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(f=l.startTime,v=l.endTime,m=l.st,g=l.firstByteTime,t._loading=!o,t._firstProgressEmit){P.next=13;break}if(t.media){P.next=6;break}return(E=t._mediaLoader)===null||E===void 0||E.cancel(),P.abrupt("return");case 6:S=c.headers,C=m?g-m:v-f,t.emit(x.TTFB,{url:t._opts.url,responseUrl:c.url,elapsed:C}),t.emit(x.LOAD_RESPONSE_HEADERS,{headers:S}),t._transferCost.set(Ae.TTFB,C),t._acceptRanges=!!(S!=null&&S.get("Accept-Ranges"))||!!(S!=null&&S.get("Content-Range")),t._firstProgressEmit=!0;case 13:if(t._bufferService){P.next=15;break}return P.abrupt("return");case 15:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(u?.byteLength,v-f),P.prev=17,P.next=20,t._bufferService.appendBuffer(u);case 20:(A=t._bufferService)===null||A===void 0||A.evictBuffer(t._opts.bufferBehind),P.next=33;break;case 23:if(P.prev=23,P.t0=P.catch(17),!(!t.isLive&&t._bufferService.isFull())){P.next=32;break}return P.next=28,t._mediaLoader.cancel();case 28:return t._loading=!1,N=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(N)/2,P.abrupt("return");case 32:return P.abrupt("return",t._emitError(se.create(P.t0)));case 33:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit(x.SWITCH_URL_SUCCESS,{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!(o&&!t.media.seeking)){P.next=40;break}return t.emit(x.LOAD_COMPLETE),Te.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),P.abrupt("return");case 40:if(t.isLive){P.next=42;break}return P.abrupt("return");case 42:O=t._opts.maxReaderInterval,O&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout(function(){if(t._disconnectRetryCount){t._disconnectRetryCount--,t.load();return}Te.debug("onMaxChunkWait",O),t._end()},O));case 44:case"end":return P.stop()}},s,null,[[17,23]])}));return function(s,u,o,l){return n.apply(this,arguments)}}()),R(j(t),"_onRetryError",function(n,s){Te.debug("load retry",n,s),t.emit(x.LOAD_RETRY,{error:se.network(n),retryTime:s})}),R(j(t),"_end",function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),Te.debug("end stream")}),R(j(t),"_resetDisconnectCount",function(){t._disconnectRetryCount=t._opts.disconnectRetryCount}),R(j(t),"_tick",function(){clearTimeout(t._tickTimer);var n=j(t),s=n.media;if(s){t._tickTimer=setTimeout(t._tick,t._tickInterval);var u=Z.end(Z.get(s));if(!(u<ct||!s.readyState)){var o=t._opts;if(gt(s)&&s.currentTime)t._gapService&&t._gapService.do(s,o.maxJumpDistance,t.isLive,3);else{if(!s.currentTime&&t._gapService&&o.enableStartGapJump){var l=t._opts.mseLowLatency||t._opts.mseLowLatency===!1&&t.bufferInfo(Li).nextStart;l&&t._gapService.do(s,o.maxJumpDistance,t.isLive,3);return}o.isLive&&s.readyState===4&&u-s.currentTime>o.disconnectTime&&t.disconnect()}}}}),R(j(t),"_onPlay",function(){var n,s,u=t._opts.softDecode||((n=t.media)===null||n===void 0||(s=n.buffered)===null||s===void 0?void 0:s.length);if(t.isLive){!t._loading&&u&&t.replay(void 0,!0);return}var o=t.bufferInfo();(o.start||o.nextStart)>ct&&t._tick()}),R(j(t),"_onLoadeddata",function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch(function(n){})}),R(j(t),"_onSeeking",ee(F().mark(function n(){return F().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return u.stop()}},n)}))),R(j(t),"_onTimeupdate",function(){if(t.media){var n=t._opts,s=t.media.currentTime;if(n.isLive&&n.maxLatency&&n.targetLatency){var u=Z.end(Z.get(t.media)),o=u-s;o>=n.maxLatency&&(t.media.currentTime=u-n.targetLatency,t.emit(x.CHASEFRAME,{currentTime:t.media.currentTime,latency:n.targetLatency}))}t._seiService.throw(s,!0),!(n.isLive||!t.seekable||t._loading)&&t._checkPreload()}}),R(j(t),"_onWaiting",function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())}),R(j(t),"_onBufferUpdate",function(){if(!t._opts.isLive){var n=t.bufferInfo(),s=n.end,u=n.nextEnd;Math.abs((s||u)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}}),R(j(t),"_checkPreload",ee(F().mark(function n(){var s,u,o,l,c,f,v,m,g,E;return F().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(s=t.bufferInfo(),u=s.remaining,o=u===void 0?0:u,l=t._opts,c=t._keyframes.filepositions,f=t._keyframes.times,v=t.media.currentTime,!(o<l.preloadTime)){C.next=19;break}if(m=Nt(t._keyframes.times,v+o+ct),g=Nt(t._keyframes.times,v+o+t._opts.preloadTime),g===m&&(g=m+1),t._preLoadEndPoint!==g){C.next=11;break}return C.abrupt("return");case 11:if(E=c[m],E!=null){C.next=14;break}return C.abrupt("return");case 14:return C.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[E,c[g]]),t._preLoadEndPoint=g,t._bufferService.unContiguous(f[m]);case 19:case"end":return C.stop()}},n)}))),R(j(t),"_onFlvScriptData",function(n){var s,u,o,l,c=(s=n.data)===null||s===void 0||(u=s.onMetaData)===null||u===void 0?void 0:u.keyframes,f=(o=n.data)===null||o===void 0||(l=o.onMetaData)===null||l===void 0?void 0:l.duration;c&&(t._keyframes=c),!t._opts.isLive&&f&&t._bufferService.updateDuration(f)}),t._opts=Hr(r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new Et(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._transferCost=new Vr,t._bufferService=new jr(j(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new wt(j(t)),t._bandwidthService=new Ct({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new At(j(t)),t._opts.softDecode||(t._gapService=new Tt),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),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(x.FLV_SCRIPT_DATA,t._onFlvScriptData),t}return Ne(e,[{key:"version",get:function(){return"3.0.20"}},{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(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ct;return Z.info(Z.get(this.media),(t=this.media)===null||t===void 0?void 0:t.currentTime,n)}},{key:"playbackQuality",value:function(){return yt(this.media)}},{key:"load",value:function(){var r=ee(F().mark(function n(s){var u,o=arguments;return F().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(u=o.length>1&&o[1]!==void 0?o[1]:!1,this._bufferService){c.next=3;break}return c.abrupt("return");case 3:return c.next=5,this._reset(u);case 5:this._loadData(s,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return c.stop()}},n,this)}));function t(n){return r.apply(this,arguments)}return t}()},{key:"replay",value:function(){var r=ee(F().mark(function n(){var s=this,u,o,l=arguments;return F().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(u=l.length>0&&l[0]!==void 0?l[0]:this._opts.seamlesslyReload,o=l.length>1?l[1]:void 0,this.media){f.next=4;break}return f.abrupt("return");case 4:if(this._resetDisconnectCount(),!u){f.next=11;break}return f.next=8,this._clear();case 8:setTimeout(function(){s._seamlessSwitching=!0,s._loadData(s._opts.url),s._bufferService.seamlessSwitch()}),f.next=13;break;case 11:return f.next=13,this.load();case 13:return f.abrupt("return",this.media.play(!o).catch(function(){}));case 14:case"end":return f.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"disconnect",value:function(){var t;return Te.debug("disconnect!"),(t=this._bufferService)===null||t===void 0||t.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var r=ee(F().mark(function n(s,u){var o=this;return F().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this._bufferService){c.next=2;break}return c.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&u)){c.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var f=ee(F().mark(function v(m){return F().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.next=2,o._clear();case 2:o._bufferService.seamlessLoadingSwitching=!0,o._urlSwitching=!0,o._seamlessSwitching=!0,o._bufferService.seamlessSwitch(),o._loadData(s);case 7:case"end":return E.stop()}},v)}));return function(v){return f.apply(this,arguments)}}(),c.abrupt("return");case 6:if(!(!u||!this._opts.isLive)){c.next=11;break}return c.next=9,this.load(s);case 9:return this._urlSwitching=!0,c.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return c.next=13,this._clear();case 13:setTimeout(function(){o._urlSwitching=!0,o._seamlessSwitching=!0,o._loadData(s),o._bufferService.seamlessSwitch()});case 14:case"end":return c.stop()}},n,this)}));function t(n,s){return r.apply(this,arguments)}return t}()},{key:"destroy",value:function(){var r=ee(F().mark(function n(){return F().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._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),u.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return u.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_emitError",value:function(t){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Te.table(t),Te.error(t),Te.error((n=this.media)===null||n===void 0?void 0:n.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(x.SWITCH_URL_FAILED,t)),this.emit(x.ERROR,t),s&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var r=ee(F().mark(function n(){var s,u=arguments;return F().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=u.length>0&&u[0]!==void 0?u[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(s);case 8:case"end":return l.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()},{key:"_loadData",value:function(){var r=ee(F().mark(function n(s,u){var o;return F().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s&&(this._opts.url=s),o=s=this._opts.url,s){c.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(o=this._opts.preProcessUrl(s).url),this._mediaLoader.finnalUrl=o,this.emit(x.LOAD_START,{url:o,seamlessSwitching:this._seamlessSwitching}),Te.debug("load data, loading:",this._loading,o),!this._loading){c.next=11;break}return c.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,c.prev=12,c.next=15,this._mediaLoader.load({url:o,range:u});case 15:c.next=21;break;case 17:return c.prev=17,c.t0=c.catch(12),this._loading=!1,c.abrupt("return",this._emitError(se.network(c.t0),!1));case 21:case"end":return c.stop()}},n,this,[[12,17]])}));function t(n,s){return r.apply(this,arguments)}return t}()},{key:"_clear",value:function(){var r=ee(F().mark(function n(){return F().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!this._mediaLoader){u.next=3;break}return u.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return u.stop()}},n,this)}));function t(){return r.apply(this,arguments)}return t}()}],[{key:"isSupported",value:function(t){return!t||t==="video"||t==="audio"?Le.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){fe.enable(),Ue.enable()}},{key:"disableLogger",value:function(){fe.disable(),Ue.disable()}}]),e}(zr.default);try{localStorage.getItem("xgd")?ft.enableLogger():ft.disableLogger()}catch{}export{ft as Flv};