xgplayer-mp4-loader 3.0.25-rc.2 → 3.0.25
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/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/loader.js +2 -2
- package/package.json +4 -4
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/esnext.typed-array.at.js"),require("core-js/modules/es.typed-array.copy-within.js"),require("core-js/modules/es.typed-array.every.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.filter.js"),require("core-js/modules/es.typed-array.find.js"),require("core-js/modules/es.typed-array.find-index.js"),require("core-js/modules/esnext.typed-array.find-last.js"),require("core-js/modules/esnext.typed-array.find-last-index.js"),require("core-js/modules/es.typed-array.for-each.js"),require("core-js/modules/es.typed-array.includes.js"),require("core-js/modules/es.typed-array.index-of.js"),require("core-js/modules/es.typed-array.iterator.js"),require("core-js/modules/es.typed-array.join.js"),require("core-js/modules/es.typed-array.last-index-of.js"),require("core-js/modules/es.typed-array.map.js"),require("core-js/modules/es.typed-array.reduce.js"),require("core-js/modules/es.typed-array.reduce-right.js"),require("core-js/modules/es.typed-array.reverse.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.slice.js"),require("core-js/modules/es.typed-array.some.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.subarray.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/es.typed-array.to-string.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.math.hypot.js"),require("core-js/modules/es.string.from-code-point.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.array.concat.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.function.name.js","core-js/modules/es.array.map.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.join.js","core-js/modules/es.array.includes.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.filter.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/esnext.typed-array.at.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/esnext.typed-array.find-last.js","core-js/modules/esnext.typed-array.find-last-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.string.replace.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.constructor.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.symbol.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.string.includes.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.math.hypot.js","core-js/modules/es.string.from-code-point.js","core-js/modules/es.string.match.js","core-js/modules/es.array.sort.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).MP4Loader=t()}(this,(function(){"use strict";function e(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 t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.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(C){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,s=Object.create(a.prototype),o=new j(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(C){return{type:"throw",arg:C}}}e.wrap=l;var f={};function h(){}function p(){}function v(){}var m={};c(m,s,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(T([])));g&&g!==t&&n.call(g,s)&&(m=g);var _=v.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(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=w(s,r);if(o){if(o===f)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=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(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,w(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;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,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}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 j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:D}}function D(){return{value:void 0,done:!0}}return p.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(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(_),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(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"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=T,j.prototype={constructor:j,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)&&n.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 r(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 r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,f):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),f},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),f}},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:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e){return(n="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 i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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,j(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(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&&f(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(){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 p(e,t,r){return(p=h()?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&&f(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=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 p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},v(e)}function m(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}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(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 y(e)}function _(e){var t=h();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||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(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(e,t)||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.")}()}function w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(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 S(e,t){if(e){if("string"==typeof e)return E(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)?E(e,t):void 0}}function E(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 j(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var T,D=function(){function e(){s(this,e)}return u(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(t){}}},{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,d=e.buffers(t,n),f=0,h=d.length;f<h;f++){var p=d[f];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=f;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:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}},{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}(),C="undefined"!=typeof window,A="network",O="network_timeout",L="network_forbidden",B="network_notfound",P="network_range_not_satisfiable",R="demux",U="remux",I="media",M="drm",N="other",q="runtime",z={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"},F=(c(T={},"manifest",{HLS:1100,DASH:1200}),c(T,A,2100),c(T,O,2101),c(T,L,2103),c(T,B,2104),c(T,P,2116),c(T,R,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(T,U,{FMP4:4100,MP4:4200}),c(T,I,{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}),c(T,M,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(T,N,8e3),c(T,q,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),T),V=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===O?A:e,u.originError=i,u.ext=a,u.errorCode=F[e][n]||F[e],u.errorMessage=u.message,u.errorCode||(u.errorType=N,u.errorCode=F[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=N),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?O:A,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(v(Error)),G={DEBUG:1,LOG:2,WARN:3,ERROR:4},H=["Boolean","Number","String","Undefined","Null","Date","Object"],K=function(){function e(t,r){s(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 u(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,[G.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(Y(),"]"),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,[G.LOG].concat(n)),e.disabled||(t=console).log.apply(t,["[".concat(Y(),"]"),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,[G.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,["[".concat(Y(),"]"),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,[G.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,["[".concat(Y(),"]"),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 W(e)}));t="[".concat(Y(),"]")+this._prefix+JSON.stringify(a)}catch(o){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 Y(){return(new Date).toLocaleString()}function Q(e){if("object"!==n(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 W(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!H.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=Q(e[s]):"object"===n(e[s])?i[s]=W(e[s],t,r+1):i[s]=e[s]);return i}}function J(){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 X(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}c(K,"disabled",!0);var Z=function(e){try{return JSON.stringify(e)}catch(t){return""}};function $(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return C?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function ee(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var te="appendBuffer",re="removeBuffer",ne="updateDuration",ie=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",J()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),c(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==ne&&t.shift(),r){var i,a,s=X()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),Z(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)}}})),c(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 V(I,z.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new K("MSE"),this._config.openLog&&K.enable()}var t,i,o;return u(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!ee(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(r){}})),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))}),ne,{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=X()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=J()}return this._openPromise}},{key:"bindMedia",value:(o=a(r().mark((function e(t){var n,i,a,s,o=this;return r().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(n=$(this._config.preferMMS),t&&n){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new n,a=ee(i),this._st=X(),s=function e(){var r=X()-o._st;o._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),o._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",s),a&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=a,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"unbindMedia",value:(i=a(r().mark((function e(){var t,n,i,a=this;return r().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=a._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)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}})),ee(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(r){}this.media=null}this.mediaSource=null,this._openPromise=J(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.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(n){throw new V(I,z.MSE_ADD_SB,n)}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 V(I,z.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(i){throw new V(I,z.MSE_CHANGE_TYPE,i)}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=X(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),te,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=X(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),re,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,D.end(D.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 D.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return D.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return D.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:J(),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=a(r().mark((function e(t,n,i){var a,s,o=this;return r().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((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=J();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._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(s){var i,a;if(s&&s.message&&s.message.indexOf("SourceBuffer is full")>=0)this._mseFullFlag[e]=!0,r.context&&"object"===n(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),null==r||null===(i=r.promise)||void 0===i||i.reject(new V(I,z.MSE_FULL,s));else this._logger.error(s),null==r||null===(a=r.promise)||void 0===a||a.reject(s.constructor===V?s:new V(I,z.MSE_OTHER,s)),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=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=$(t);if(!r)return!1;try{return r.isTypeSupported(e)}catch(n){return this._logger.error(e,n),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();c(ie,"VIDEO","video"),c(ie,"AUDIO","audio");var ae="fetch",se="xhr",oe="arraybuffer",ue="text",ce="json",le=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(y(o=t.call(this,a)),"retryCount",0),c(y(o),"isTimeout",!1),c(y(o),"loaderType",ae),c(y(o),"startTime",0),c(y(o),"endTime",0),c(y(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(Error)),de=Object.prototype.toString;function fe(e){if("[object Object]"!==de.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function he(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 pe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ve(e,t){if(e){if(!t)return e;var r,i=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]"===de.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(pe(e),"=").concat(pe(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function me(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 ye(e,t){return Math.round(8*e*1e3/t/1024)}var ge="real_time_speed",_e={exports:{}};!function(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],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){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(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var f,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){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(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];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}(_e);var be=_e.exports,ke=2097152,xe=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(y(e=n.call(this)),"_abortController",null),c(y(e),"_timeoutTimer",null),c(y(e),"_reader",null),c(y(e),"_response",null),c(y(e),"_aborted",!1),c(y(e),"_index",-1),c(y(e),"_range",null),c(y(e),"_receivedLength",0),c(y(e),"_running",!1),c(y(e),"_logger",null),c(y(e),"_vid",""),c(y(e),"_firtstByte",0),c(y(e),"_onProcessMinLen",0),c(y(e),"_onCancel",null),c(y(e),"_priOptions",null),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,f=e.onCancel,h=e.range,p=e.transformResponse,v=e.request,m=e.params,y=e.logger,g=e.method,_=e.headers,b=e.body,k=e.mode,x=e.credentials,w=e.cache,S=e.redirect,E=e.referrer,j=e.referrerPolicy,T=e.onProcessMinLen,D=e.priOptions,C=e.streamRes,A=e.firstMaxChunkSize;this._logger=y,this._aborted=!1,this._onProcessMinLen=T,this._onCancel=f,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=l,this._range=h||[0,0],this._vid=s||i,this._priOptions=D||{},this._firstMaxChunkSize=A;var O={method:g,headers:_,body:b,mode:k,credentials:x,cache:w,redirect:S,referrer:E,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},L=!1;clearTimeout(this._timeoutTimer),i=ve(i,m);var B=he(h);B&&(_=v?v.headers:O.headers=O.headers||(Headers?new Headers:{}),Headers&&_ instanceof Headers?_.append("Range",B):_.Range=B),o&&(this._timeoutTimer=setTimeout((function(){if(L=!0,n.cancel(),d){var e=new le(i,O,null,"timeout");e.isTimeout=!0,d(e,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})}}),o));var P=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",h),new Promise((function(e,t){(C?new Promise((function(e){e(C)})):fetch(v||i,v?void 0:O)).then(function(){var s=a(r().mark((function a(s){var o,d,f,v;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(p&&(s=p(s,i)||s),s.ok){r.next=7;break}throw new le(i,O,s,"bad network response");case 7:if(o=Date.now(),u!==ue){r.next=15;break}return r.next=11,s.text();case 11:d=r.sent,n._running=!1,r.next=37;break;case 15:if(u!==ce){r.next=22;break}return r.next=18,s.json();case 18:d=r.sent,n._running=!1,r.next=37;break;case 22:if(!c){r.next=29;break}return n.resolve=e,n.reject=t,n._loadChunk(s,c,P,o),r.abrupt("return");case 29:return r.next=31,s.arrayBuffer();case 31:d=r.sent,d=new Uint8Array(d),n._running=!1,f=Date.now()-P,v=ye(d.byteLength,f),n.emit(ge,{speed:v,len:d.byteLength,time:f,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",l,",range,",h),e(me(d,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),P,o,l,h,n._vid,n._priOptions));case 39:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!L||((e=e instanceof le?e:new le(i,O,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=L,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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(t){}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 t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new le(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(ke),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),f=function(){var o=a(r().mark((function a(){var o,h,p,v,m,y,g,_,b,k;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(h=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=h+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[p,p],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:v=u.value?u.value.byteLength:0,s._receivedLength+=v,s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",p,", end,",h+s._receivedLength,", done,",u.done),s._onProcessMinLen>0?s._writeIdx+v>=s._onProcessMinLen||u.done?((m=new Uint8Array(s._writeIdx+v)).set(s._cache.slice(0,s._writeIdx),0),v>0&&m.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",m.byteLength,", writeIdx,",s._writeIdx)):v>0&&s._writeIdx+v<ke?(s._cache.set(u.value,s._writeIdx),s._writeIdx+=v,s._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",s._writeIdx)):v>0&&(y=new Uint8Array(s._writeIdx+v+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+v+2048,", datalen,",v,", writeIdx,",s._writeIdx),y.set(s._cache.slice(0,s._writeIdx),0),v>0&&y.set(u.value,s._writeIdx),s._writeIdx+=v,delete s._cache,s._cache=y,s._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",s._writeIdx)):m=u.value,(m&&m.byteLength>0||u.done)&&(s._firstMaxChunkSize&&(s._firtstByte?s._cacheData&&((_=new Uint8Array(s._cacheData.byteLength+m.byteLength)).set(s._cacheData,0),_.set(m,s._cacheData.byteLength),m=_,s._cacheData=null):(s._firtstByte++,g=m.slice(0,s._firstMaxChunkSize),s._cacheData=m.slice(s._firstMaxChunkSize),m=g)),t(m,u.done,{range:[s._range[0]+s._receivedLength-(m?m.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e)),u.done?(b=Date.now()-n,k=ye(s._receivedLength,b),s.emit(ge,{speed:k,len:s._receivedLength,time:b,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions}),s._running=!1,s._logger.debug("[fetchLoader onProgress end],task,",s._range,",done,",u.done),s.resolve(me(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,i,s._index,s._range,s._vid,s._priOptions))):s._firstMaxChunkSize?setTimeout((function(){f()}),0):f();case 25:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.apply(this,arguments)}}();f()}},{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)}}]),i}(be);var we=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(y(e=r.call(this)),"_xhr",null),c(y(e),"_aborted",!1),c(y(e),"_timeoutTimer",null),c(y(e),"_range",null),c(y(e),"_receivedLength",0),c(y(e),"_url",null),c(y(e),"_onProgress",null),c(y(e),"_index",-1),c(y(e),"_headers",null),c(y(e),"_currentChunkSizeKB",384),c(y(e),"_timeout",null),c(y(e),"_xhr",null),c(y(e),"_withCredentials",null),c(y(e),"_startTime",-1),c(y(e),"_loadCompleteResolve",null),c(y(e),"_loadCompleteReject",null),c(y(e),"_runing",!1),c(y(e),"_logger",!1),c(y(e),"_vid",""),c(y(e),"_responseType",void 0),c(y(e),"_credentials",void 0),c(y(e),"_method",void 0),c(y(e),"_transformResponse",void 0),c(y(e),"_firstRtt",void 0),c(y(e),"_onCancel",null),c(y(e),"_priOptions",null),e}return u(n,[{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=ve(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 le?e:new le(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===oe&&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 le(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 le(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=he(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(a){a.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new le(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===oe){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,f=ye(this._receivedLength,d);this.emit(ge,{speed:f,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var h={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(h=this._transformResponse(h,this._url)||h),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},h),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(me(this._onProgress?null:s,o,h,h.headers["content-length"],h.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,k(d(n.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=S(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(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(be),Se=["retry","retryDelay","onRetryError","transformError"],Ee=function(){function e(t,r){s(this,e),this.promise=J(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new K("Loader")),this._loaderType=t,this._loader=t===ae&&"undefined"!=typeof fetch?new xe:new we,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=m(t,Se),c=function(){var t=a(r().mark((function t(){var a,l,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:a=t.sent,e.promise.resolve(a),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,l=t.t0,o&&(l=o(l)||l),s&&e._retryCount>0&&s(l,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=n)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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}();function je(){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 Te(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var De=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(y(r=i.call(this,e)),"type",ae),c(y(r),"_queue",[]),c(y(r),"_alive",[]),c(y(r),"_currentTask",null),c(y(r),"_finnalUrl",""),c(y(r),"_config",void 0),r._config=function(e){return t({loaderType:ae,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:ue,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),r._config.loaderType!==se&&xe.isSupported()||(r.type=se),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===ae}},{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&&fe(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&fe(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Ee(this.type,r);return n.loader.on(ge,(function(e){t.emit(ge,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().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,Te();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 xe.isSupported()}}]),o}(be),Ce="video",Ae="audio",Oe="metadata",Le="av1",Be="avc",Pe="hevc",Re="aac",Ue="g7110a",Ie="g7110m",Me="opus",Ne="mp3",qe="LARGE_AV_SHIFT",ze="LARGE_VIDEO_GAP",Fe="LARGE_VIDEO_GAP_BETWEEN_CHUNK",Ve="LARGE_AUDIO_GAP",Ge="AUDIO_FILLED",He="AUDIO_DROPPED",Ke=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",Ce),c(this,"codecType",Be),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"lastKeyFrameDts",0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(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}(),Ye=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",Ae),c(this,"codecType",Re),c(this,"pid",-1),c(this,"codec",""),c(this,"container",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"parsedCodec",null),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(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.container||this.codecType!==Re&&this.codecType!==Ue&&this.codecType!==Ie&&this.codecType!==Me&&this.codecType!==Ne)}},{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}(),Qe=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(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}(),We=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),Je=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),Xe=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Je),Ze=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Je),$e=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",Oe),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(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}(),et=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(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(0!=(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}(),tt=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(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}();c(tt,"disabled",!0);var rt=function(){function e(){s(this,e)}return u(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}(),nt="undefined"!=typeof window,it=nt&&navigator.userAgent.toLocaleLowerCase(),at=nt&&/^((?!chrome|android).)*safari/.test(it),st=nt&&it.includes("firefox"),ot=nt&&it.includes("android");function ut(){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}var ct=Math.pow(2,32);function lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function dt(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 ft(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return dt(e,t)*ct+dt(e,t+4)}function ht(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 pt(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)}))}function vt(e,t){return Number(e+"."+t)}var mt=function(){function e(){s(this,e)}return u(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,d,f=1+((192&t[i+2])>>>6),h=(1&t[i+2])<<2|(192&t[i+3])>>>6,p=e._getConfig(o,h,f),v=p.config,m=p.codec,y=0,g=0,_=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=(1&~t[i+1])*e.ADTS_CRC_LEN,l-(d=e.ADTS_HEADER_LEN_NO_CRC+c)<=0?(g++,i+=Math.max(l,d)):(s.push({pts:r+y*_,data:t.subarray(i+d,i+l)}),y++,i+=l)}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,droppedFrames:g,samplingFrequencyIndex:o,sampleRate:u,objectType:f,channelCount:h,codec:m,config:v,originCodec:"mp4a.40.".concat(f)}}}},{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){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,a=[];return st?e>=6?(n=5,i=e-3):(n=2,i=e):ot?(n=2,i=e):(n=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}();c(mt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]),c(mt,"ADTS_HEADER_LEN_NO_CRC",7),c(mt,"ADTS_CRC_LEN",2);var yt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAnnexB",value:function(e){var t=e.byteLength-1,r=0;do{if(0!==e[t])break;r++,t--}while(t>0);r>=3&&(e=e.subarray(0,t+1));for(var n=e.length,i=2,a=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((a=++i+2)>=n)return[];for(var s=[];a<n;)switch(e[a]){case 0:if(0!==e[a-1]){a+=2;break}if(0!==e[a-2]){a++;break}if(a<n-1&&1!==e[a+1]){a++;break}i!==a-2&&s.push(e.subarray(i,a-2));do{a++}while(1!==e[a]&&a<n);a=(i=a+1)+2;break;case 1:if(0!==e[a-1]||0!==e[a-2]){a+=3;break}i!==a-2&&s.push(e.subarray(i,a-2)),a=(i=a+1)+2;break;default:a+=3}return i<n&&s.push(e.subarray(i)),s}},{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=dt(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}(),gt=function(){function e(){s(this,e)}return u(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(yt.removeEPB(l)))}var d,f=t[o];o++;for(var h=0;h<f;h++)d=t[o]<<8|t[o+1],o+=2,d&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new et(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(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var f=t.readUEG(),h=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,m,y,g,_,b=0,k=0,x=0,w=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),x=t.readUEG(),w=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);m=t.readBool(),_=(y=E)/(g=2*S)}}return{codec:ht(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(f+1)-2*(b+k)),height:(2-p)*(h+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:y,fpsDen:g,fps:_,fixedFrame:m}}}]),e}(),_t=function(){function e(){s(this,e)}return u(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=[],d=[],f=23,h=t[22],p=0;p<h;p++){a=63&t[f],s=t[f+1]<<8|t[f+2],f+=3;for(var v=0;v<s;v++)if(o=t[f]<<8|t[f+1],f+=2,o){switch(a){case 32:var m=t.subarray(f,f+o);n||(n=e.parseVPS(yt.removeEPB(m),r)),d.push(m);break;case 33:var y=t.subarray(f,f+o);i||(i=e.parseSPS(yt.removeEPB(y),r)),c.push(y);break;case 34:l.push(t.subarray(f,f+o))}f+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:d,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new et(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 et(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,d,f=n.readUEG(),h=n.readUEG(),p=n.readBits(1);if(1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),d=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p){var v=1!==a&&2!==a||0!==o?1:2,m=1===a&&0===o?2:1;f-=v*(c+u),h-=m*(d+l)}return{codec:"hev1.1.6.L93.B0",width:f,height:h,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}(),bt=function(){function e(){s(this,e)}return u(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}(),kt=1e3,xt=5e3,wt=function(){function e(t,r,n){s(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 u(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;!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);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}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=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var f;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:Fe,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(f=r[1])||void 0===f?void 0:f.dts,sampleDuration:d});this._videoTimestampBreak>=5?(this._videoNextDts=l.dts,this._videoTimestampBreak=0):(l.dts+=d,l.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var h=0;h<u;h++){var p=r[h].dts,v=r[h+1];((c=h<u-1?v.dts-p:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:ze,time:p/e.timescale,dts:p,originDts:r[h].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[h].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{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:qe,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 Re:e.sampleDuration=mt.getFrameDuration(e.timescale,r);break;case Me:e.sampleDuration=bt.getFrameDuration(e.samples,r);break;case Ue:case Ie:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===Me?20:e.codecType===Re?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<=kt&&!at){var l=this._getSilentFrame(e)||u.data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>xt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:Ge,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var f=0;f<d;f++){var h=new We(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);h.originPts=Math.floor(this._baseDts+o),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>xt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:He,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--;else{if(Math.abs(c)>kt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>xt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:Ve,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===Me){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===Re?mt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),St=function(){function e(){s(this,e)}return u(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}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var f=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),h=f.size,p=f.data;if(f.isEnd)break;r[p.name]=p.value,i+=h}if(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 m=0;m<v;m++){var y=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=y.data,_=y.size;r.push(g),i+=_}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=rt.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=rt.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}(),Et=7,jt=8,Tt=10,Dt=13,Ct=new tt("FlvDemuxer"),At=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Ke,this.audioTrack=r||new Ye,this.metadataTrack=n||new $e,this._fixer=new wt(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(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=ut(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=0!=(1&t[4]),this._headerParsed=!0,c=dt(t,5)+4}for(var l,d,f,h,p,v=t.length;c+15<v&&(l=t[c],!(c+15+(d=t[c+1]<<16|t[c+2]<<8|t[c+3])>v));)f=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,h=t.subarray(c,c+d),8===l?this._parseAudio(h,f):9===l?(a&&(this.seamlessLoadingSwitching=!0),this._parseVideo(h,f)):18===l?this._parseScript(h,f):Ct.warn("Invalid tag type: ".concat(l)),(p=dt(t,c+=d))!==11+d&&Ct.warn("Invalid PrevTagSize ".concat(p," (").concat(11+d,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),s.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,s.timescale=s.codecType===Me?1e3:s.sampleRate||0,!s.exist()&&s.hasSample()&&s.reset(),!o.exist()&&o.hasSample()&&o.reset();var m=u.flvScriptSamples[u.flvScriptSamples.length-1],y=null==m||null===(r=m.data)||void 0===r?void 0:r.onMetaData;return y&&(null!=o&&o.exist()&&(y.hasOwnProperty("duration")&&(o.duration=1e3*y.duration),!o.width&&y.hasOwnProperty("width")&&(o.width=y.width),!o.height&&y.hasOwnProperty("height")&&(o.height=y.height)),null!=s&&s.exist()&&y.hasOwnProperty("duration")&&(s.duration=1e3*y.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(n!==Tt&&n!==Et&&n!==jt&&n!==Dt)return Ct.warn("Unsupported sound format: ".concat(n)),void i.reset();if(n!==Tt&&n!==Dt){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 Et:case jt:this._parseG711(t,r,n);break;case Tt:this._parseAac(t,r);break;case Dt:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=Me,n){case 0:var i=bt.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=bt.getFrameDuration([],r.timescale)):(r.reset(),Ct.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var a=new We(t,e.subarray(2),r.sampleDuration);r.samples.push(a);break;default:Ct.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack,i=e.subarray(1);if(!(i.byteLength<1)){var a=new We(t,i);n.codecType=7===r?Ue:Ie,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(a)}}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=Re,0===e[1]){var n=mt.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(),Ct.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new We(t,e.subarray(2)))}else Ct.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 Ct.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?Pe:Be;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?_t.parseHEVCDecoderConfigurationRecord(c):gt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,f=l.sps,h=l.ppsArr,p=l.spsArr,v=l.vpsArr,m=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),f&&(a.codec=f.codec,a.width=f.width,a.height=f.height,a.sarRatio=f.sarRatio,a.fpsNum=f.fpsNum,a.fpsDen=f.fpsDen),p.length&&(a.sps=p),h.length&&(a.pps=h),v&&v.length&&(a.vps=v),m&&(a.nalUnitSize=m)}else Ct.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var y=yt.parseAvcC(e.subarray(5),a.nalUnitSize);if((y=this._checkAddMetaNalToUnits(s,y,a))&&y.length){var g=new Qe(t+u,t,y);if(this.seamlessLoadingSwitching&&t<a.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(g.setToKeyframe(),a.lastKeyFrameDts=t),a.samples.push(g),y.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;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Ze(yt.parseSEI(yt.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else Ct.warn("Cannot parse NALUs",e)}else 2===o||Ct.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 Xe(St.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&dt(e,5)>=9}}]),e}();c(At,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new tt("TsDemuxer");var Ot=function(){function e(t,r,n){s(this,e),this.dv=new DataView(t),this.start=this.offset=r||this.dv.byteOffset,this.end=n?this.start+n:this.start+this.dv.byteLength}return u(e,[{key:"buffer",get:function(){return this.dv.buffer}},{key:"unreadLength",get:function(){return Math.max(this.end-this.offset,0)}},{key:"size",get:function(){return this.end-this.start}},{key:"readFloat",value:function(e){var t=0;switch(e){case 4:t=this.dv.getFloat32(this.offset);break;case 8:t=this.dv.getFloat64(this.offset);break;default:throw new Error("read ".concat(e,"-byte float is not supported"))}return this.offset+=e,t}},{key:"back",value:function(e){this.offset-=e}},{key:"skip",value:function(e){this.offset+=e}},{key:"readInt",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getInt8(t);case 2:return this.dv.getInt16(t);case 4:return this.dv.getInt32(t);default:throw new Error("read ".concat(e,"-byte integers is not supported"))}}},{key:"read",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getUint8(t);case 2:return this.dv.getUint16(t);case 3:return(this.dv.getUint16(t)<<8)+this.dv.getUint8(t+2);case 4:return this.dv.getUint32(t);default:return this.back(e-4),this.read(e-4)+this.dv.getUint32(t)*Math.pow(256,e-4)}}},{key:"write",value:function(e,t){var r=this.offset;switch(this.offset+=e,e){case 1:return this.dv.setUint8(r,t);case 2:return this.dv.setUint16(r,t);case 3:return this.dv.setUint8(r,t>>>16),this.dv.setUint16(r+1,65535&t);case 4:return this.dv.setUint32(r,t);default:throw new Error("write ".concat(e,"-byte integers is not supported"))}}},{key:"readToBuffer",value:function(e){var t;return t=this.offset||e?this.dv.buffer.slice(this.offset,e?this.offset+e:this.end):this.dv.buffer,this.offset+=t.byteLength,t}},{key:"readToUint8",value:function(e){var t=new Uint8Array(this.dv.buffer,this.offset,e||this.unreadLength);return this.offset+=t.byteLength,t}},{key:"readString",value:function(e){for(var t=0,r="";t<e;t++)r+=String.fromCharCode(this.dv.getUint8(this.offset)),this.offset++;return r}}],[{key:"fromUint8",value:function(t){return new e(t.buffer,t.byteOffset,t.byteLength)}},{key:"concatUint8s",value:function(e){var t=new Uint8Array(e.reduce((function(e,t){return e+t.byteLength}),0)),r=0;return e.forEach((function(e){t.set(e,r),r+=e.byteLength})),t}},{key:"concatUint8",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.concatUint8s(t)}}]),e}(),Lt=function(){function e(t,r){s(this,e),this.offset=0,this.val=t,this.size=r}return u(e,[{key:"skip",value:function(e){this.offset+=e}},{key:"read",value:function(e){var t=this.size-this.offset-e;if(t>=0){var r=0,n=0;if(this.offset+=e,this.size>31){for(;n<e;n++)r+=Math.pow(2,n);return this.val/Math.pow(2,t)&r}for(;n<e;n++)r+=1<<n;return this.val>>>t&r}throw new Error("the number of the read operation exceeds the total length limit of bits")}}],[{key:"fromByte",value:function(t,r){return new e(t.read(r),r<<3)}}]),e}(),Bt=function(){function e(){s(this,e)}return u(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var a=0,s="",o=0;t.length>7;){if(a=dt(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=ft(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return It(e,!0,(function(e,t){e.trackId=dt(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=dt(t,r),r+=4),i&&(e.sampleDescriptionIndex=dt(t,r),r+=4),a&&(e.defaultSampleDuration=dt(t,r),r+=4),s&&(e.defaultSampleSize=dt(t,r),r+=4),o&&(e.defaultSampleFlags=dt(t,r))}))}},{key:"sidx",value:function(e){return It(e,!0,(function(e,t){var r=0;e.reference_ID=dt(t,r),r+=4,e.timescale=dt(t,r),r+=4,0===e.version?(e.earliest_presentation_time=dt(t,r),r+=4,e.first_offset=dt(t,r),r+=4):(e.earliest_presentation_time=ft(t,r),r+=8,e.first_offset=ft(t,r),r+=8),r+=2,e.references=[];var n=lt(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=dt(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=dt(t,r),s=dt(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return It(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return It(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=dt(t,16),e.duration=ft(t,20),r+=28):(e.timescale=dt(t,8),e.duration=dt(t,12),r+=16),e.nextTrackId=dt(t,r+76)}))}},{key:"trak",value:function(t){return It(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return It(e,!0,(function(e,t){var r=Ot.fromUint8(t);1===e.version?(r.read(8),r.read(8),e.trackId=r.read(4),r.read(4),e.duration=r.read(8)):(r.read(4),r.read(4),e.trackId=r.read(4),r.read(4),e.duration=r.read(4)),r.skip(16),e.matrix=[];for(var n=0;n<36;n++)e.matrix.push(r.read(1));r.back(36);for(var i,a=[],s=0;s<3;s++)a.push(vt(r.readInt(2),r.readInt(2))),a.push(vt(r.readInt(2),r.readInt(2))),i=r.readInt(4),a.push(vt(i>>30,1073741823&i));e.rotation=function(e){if(e.length<5)return 0;var t=Math.hypot(e[0],e[3]),r=Math.hypot(e[1],e[4]);return 0===t||0===r?0:180*Math.atan2(e[1]/r,e[0]/t)/Math.PI}(a),e.width=r.read(4),e.height=r.read(4)}))}},{key:"mdia",value:function(t){return It(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return It(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=dt(t,16),e.duration=ft(t,20),r+=28):(e.timescale=dt(t,8),e.duration=dt(t,12),r+=16);var n=lt(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return It(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return It(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return It(e,!0,(function(e,t){e.graphicsmode=lt(t),e.opcolor=[lt(t,2),lt(t,4),lt(t,6)]}))}},{key:"smhd",value:function(e){return It(e,!0,(function(e,t){e.balance=lt(t)}))}},{key:"stbl",value:function(t){return It(t,!1,(function(t,r,n){var i,a,s;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return It(e,!0,(function(e,r){var n=0,i=dt(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=lt(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=lt(r,n),n+=2,l.BytesOfProtectedData=dt(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return It(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(Nt(t[i+a]));if(i+=16,e.version>0){var s=dt(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(Nt(c))}}var l=dt(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return It(t,!0,(function(t,r,n){t.entryCount=dt(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"av01":return e.av01(t);case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return It(t,!1,(function(t,r,n){t.channelCount=lt(r,16),t.samplesize=lt(r,18),t.sampleRate=dt(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return It(t,!1,(function(t,r,n){t.width=lt(r,24),t.height=lt(r,26),t.horizresolution=dt(r,28),t.vertresolution=dt(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return It(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(Nt(t[r])),r+=1}))}},{key:"schi",value:function(t){return It(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return It(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return It(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"colr",value:function(e){return It(e,!1,(function(t,r){var n=Ot.fromUint8(r);t.data=e.data,t.colorType=n.readString(4),"nclx"===t.colorType?(t.colorPrimaries=n.read(2),t.transferCharacteristics=n.read(2),t.matrixCoefficients=n.read(2),t.fullRangeFlag=n.read(1)>>7):"rICC"!==t.colorType&&"prof"!==t.colorType||(t.iccProfile=r.readToUint8())}))}},{key:"av01",value:function(t){return It(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.av1C=e.av1C(e.findBox(a,["av1C"],n)[0]),t.colr=e.colr(e.findBox(a,["colr"],n)[0])}))}},{key:"av1C",value:function(e){return It(e,!1,(function(t,r){t.data=e.data;var n,i=Ot.fromUint8(r),a=Lt.fromByte(i,4);t.marker=a.read(1),t.version=a.read(7),t.seqProfile=a.read(3),t.seqLevelIdx0=a.read(5),t.seqTier0=a.read(1),t.highBitdepth=a.read(1),t.twelveBit=a.read(1),t.monochrome=a.read(1),t.chromaSubsamplingX=a.read(1),t.chromaSubsamplingY=a.read(1),t.chromaSamplePosition=a.read(2),t.reserved=a.read(3),t.initialPresentationDelayPresent=a.read(1),t.initialPresentationDelayPresent?t.initialPresentationDelayMinusOne=a.read(4):t.initialPresentationDelayMinusOne=0,t.configOBUs=i.readToUint8(),2===t.seqLevelIdx0&&1===t.highBitdepth?n=1===t.twelveBit?"12":"10":t.seqProfile<=2&&(n=1===t.highBitdepth?"10":"08"),t.codec=["av01",t.seqProfile,(t.seqLevelIdx0<10?"0"+t.seqLevelIdx0:t.seqLevelIdx0)+(t.seqTier0?"H":"M"),n].join(".")}))}},{key:"avc1",value:function(t){return It(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return It(e,!1,(function(t,r){t.data=e.data,t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=ht([r[1],r[2],r[3]]),t.lengthSizeMinusOne=3&r[4],t.spsLength=31&r[5],t.sps=[];for(var n=6,i=0;i<t.spsLength;i++){var a=lt(r,n);n+=2,t.sps.push(r.subarray(n,n+a)),n+=a}t.ppsLength=r[n],n+=1,t.pps=[];for(var s=0;s<t.ppsLength;s++){var o=lt(r,n);n+=2,t.pps.push(r.subarray(n,n+=o)),n+=o}}))}},{key:"hvc1",value:function(t){return It(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return It(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=dt(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=lt(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=lt(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=lt(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var f;(f=t.sps).push.apply(f,l)}else if(34===a){var h;(h=t.pps).push.apply(h,l)}}}))}},{key:"pasp",value:function(e){return It(e,!1,(function(e,t){e.hSpacing=dt(t),e.vSpacing=dt(t,4)}))}},{key:"mp4a",value:function(t){return It(t,!1,(function(t,r,n){var i=Ut(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return It(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;if(31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[1])>>5)),e.objectType=o,e.codec+=o.toString(16),/^mp4a/gi.test(e.codec)&&s.length>=2){var u=(7&s[0])<<1|(128&s[1])>>7;e.samplingFrequencyIndex=u,u<mt.FREQ.length&&(e.sampleRate=mt.FREQ[u])}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return It(e,!1,(function(e,t){Ut(e,t)}))}},{key:"stts",value:function(e){return It(e,!0,(function(e,t){for(var r=dt(t),n=[],i=4,a=0;a<r;a++)n.push({count:dt(t,i),delta:dt(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return It(e,!0,(function(e,t){var r=dt(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:dt(t,i),offset:dt(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:dt(t,i),offset:-(1+~dt(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return It(e,!0,(function(e,t){for(var r=dt(t),n=[],i=4,a=0;a<r;a++)n.push({firstChunk:dt(t,i),samplesPerChunk:dt(t,i+4),sampleDescriptionIndex:dt(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return It(e,!0,(function(e,t){var r=dt(t),n=dt(t,4),i=[];if(!r)for(var a=8,s=0;s<n;s++)i.push(dt(t,a)),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return It(e,!0,(function(e,t){for(var r=dt(t),n=[],i=4,a=0;a<r;a++)n.push(dt(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return It(e,!0,(function(e,t){for(var r=dt(t),n=[],i=4,a=0;a<r;a++)n.push(ft(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return It(e,!0,(function(e,t){for(var r=dt(t),n=[],i=4,a=0;a<r;a++)n.push(dt(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return It(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return It(e,!0,(function(e,t){e.sequenceNumber=dt(t)}))}},{key:"traf",value:function(t){return It(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return It(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=dt(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~dt(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=dt(t,s),s+=4),e.samples=[],i>s)for(var o,u=0;u<a;u++)o={},256&n&&(o.duration=dt(t,s),s+=4),512&n&&(o.size=dt(t,s),s+=4),1024&n&&(o.flags=dt(t,s),s+=4),2048&n&&(o.cts=r?-(1+~dt(t,s+4)):dt(t,s),s+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return It(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=ft(t):e.baseMediaDecodeTime=dt(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,a=e.trak;if(a&&a.length){var s=a.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=a.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(s&&t){var u,c,l,d,f,h,p,v=t,m=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(v.id=s.tkhd.trackId),v.tkhdDuration=s.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=s.mdia.mdhd.timescale,v.duration=s.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale,v.rotation=s.tkhd.rotation,v.matrix=s.tkhd.matrix;var y,g,_,b,k,x,w,S,E=s.mdia.minf.stbl.stsd.entries[0];if(v.width=E.width,v.height=E.height,E.pasp&&(v.sarRatio=[E.pasp.hSpacing,E.pasp.vSpacing]),E.av1C)v.codecType=Le,v.codec=E.av1C.codec,v.av1C=E.av1C.data,E.colr&&(v.colr=E.colr.data);else if(E.hvcC)v.codecType=Pe,v.codec=E.hvcC.codec,v.vps=E.hvcC.vps,v.sps=E.hvcC.sps,v.pps=E.hvcC.pps,v.hvcC=E.hvcC.data;else{if(!E.avcC)throw new Error("unknown video stsd entry");v.codec=E.avcC.codec,v.sps=E.avcC.sps,v.pps=E.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=s.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(f=s.mdia)||void 0===f||null===(h=f.minf)||void 0===h||null===(p=h.stbl)||void 0===p?void 0:p.ctts,E&&"encv"===E.type)v.isVideoEncryption=!0,E.default_KID=null===(y=E.sinf)||void 0===y||null===(g=y.schi)||void 0===g?void 0:g.tenc.default_KID,E.default_IsEncrypted=null===(_=E.sinf)||void 0===_||null===(b=_.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,E.default_IV_size=null===(k=E.sinf)||void 0===k||null===(x=k.schi)||void 0===x?void 0:x.tenc.default_IV_size,v.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,E.data_format=null===(w=E.sinf)||void 0===w||null===(S=w.frma)||void 0===S?void 0:S.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=E}if(o&&r){var j,T,D,C,A,O,L,B,P,R=r,U=null===(j=o.tkhd)||void 0===j?void 0:j.trackId;null!=U&&(R.id=o.tkhd.trackId),R.tkhdDuration=o.tkhd.duration,R.mvhdDurtion=e.mvhd.duration,R.mvhdTimecale=e.mvhd.timescale,R.timescale=R.formatTimescale=o.mdia.mdhd.timescale,R.duration=o.mdia.mdhd.duration||R.mvhdDurtion/R.mvhdTimecale*R.timescale;var I,M,N,q,z,F,V,G,H=o.mdia.minf.stbl.stsd.entries[0];switch(R.sampleSize=H.sampleSize,R.sampleRate=function(e){var t=0;t="mp4a"===e.type?e.sampleRate>0?e.sampleRate:e.esds.sampleRate:e.sampleRate;return t||0}(H),R.channelCount=H.channelCount,R.present=!0,H.type){case"alaw":R.codecType=R.codec=Ue,R.sampleRate=8e3;break;case"ulaw":R.codecType=R.codec=Ie,R.sampleRate=8e3;break;default:R.sampleDuration=mt.getFrameDuration(R.sampleRate,R.timescale),R.sampleRateIndex=mt.getRateIndexByRate(R.sampleRate),R.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(R.config=Array.from(H.esds.config)),R.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(R.sampleDuration=mt.getFrameDuration(R.sampleRate,R.timescale),R.objectType=(null===(T=H.esds)||void 0===T?void 0:T.objectType)||2,H.esds&&(H.esds.config?R.config=Array.from(H.esds.config):console.warn("esds config is null")),R.codec=(null===(D=H.esds)||void 0===D?void 0:D.codec)||"mp4a.40.2",R.sampleRateIndex=mt.getRateIndexByRate(R.sampleRate),R.ext={},R.ext.stss=null===(C=o.mdia)||void 0===C||null===(A=C.minf)||void 0===A||null===(O=A.stbl)||void 0===O?void 0:O.stss,R.ext.ctts=null===(L=o.mdia)||void 0===L||null===(B=L.minf)||void 0===B||null===(P=B.stbl)||void 0===P?void 0:P.ctts,R.present=!0,H&&"enca"===H.type)R.isAudioEncryption=!0,H.data_format=null===(I=H.sinf)||void 0===I||null===(M=I.frma)||void 0===M?void 0:M.data_format,H.default_KID=null===(N=H.sinf)||void 0===N||null===(q=N.schi)||void 0===q?void 0:q.tenc.default_KID,H.default_IsEncrypted=null===(z=H.sinf)||void 0===z||null===(F=z.schi)||void 0===F?void 0:F.tenc.default_IsEncrypted,H.default_IV_size=null===(V=H.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IV_size,R.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,R.useEME=e.useEME,R.kidValue=e.kidValue,R.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,Y,Q=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,W=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,J=Q||W?(Q||W).join(""):null;t&&(t.kid=J),r&&(r.kid=J)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,f=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=[];for(var h=0;h<o.sampleCount;h++)i[a.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[a.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:f,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(f++,e.gopId=f),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,f=u.stco,h=u.stss,p=u.ctts;if(!(c&&l&&d&&f&&h))return;i=Pt(c,l,d,f,p,h)}if(n){var v,m,y,g=null===(v=n.mdia)||void 0===v||null===(m=v.minf)||void 0===m?void 0:m.stbl;if(!g)return;var _=null===(y=n.mdia.mdhd)||void 0===y?void 0:y.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=Pt(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function Pt(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,f=n.entries,h=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,m=0,y=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:m,duration:n,size:h[y]||r.sampleSize,offset:f[g]+b,index:y},p&&(u.keyframe=s[y],u.keyframe&&v++,u.gopId=v),o&&y<o.length&&(u.pts=u.dts+o[y]),c.push(u),m+=n,++y<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function Rt(e,t){return e.dataReferenceIndex=lt(t,6),e.width=lt(t,24),e.height=lt(t,26),e.horizresolution=dt(t,28),e.vertresolution=dt(t,32),e.frameCount=lt(t,40),e.depth=lt(t,74),78}function Ut(e,t){return e.dataReferenceIndex=lt(t,6),e.channelCount=lt(t,16),e.sampleSize=lt(t,18),e.sampleRate=dt(t,24)/65536,28}function It(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var Mt=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},Nt=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(Mt(Number(t).toString(16),2,0))})),e[0]};function qt(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}var zt=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(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=qt(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}(),Ft=Math.pow(2,32)-1,Vt=function(){function e(){s(this,e)}return u(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===Ce&&e.codecType===Pe}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return ut(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],pt(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(w(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(w(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,n=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]));return n}},{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,a=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]));return a}},{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,n=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]));return n}},{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===Ce?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===Me?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]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),f=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),h=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,d),e.box(e.types.btrt,f),h,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(pt(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===Pe,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,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(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,w(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=x(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{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(w(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(w(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),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,f,h)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var m=e.trun1(t);return e.box(e.types.traf,r,n,m)}var y=e.sbgp(),g=e.saiz(t),_=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,y,g,_,b,k)}var x=e.sdtp(t);return e.box(e.types.traf,r,n,x,e.trun(t.samples,x.byteLength+76))}},{key:"sdtp",value:function(t){var r=new zt;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 zt,n=zt.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=zt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=zt.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=zt.writeUint32(s)}return t.samples.forEach((function(e){r.write(zt.writeUint32(e.duration)),r.write(zt.writeUint32(e.size)),r.write(zt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(zt.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 zt,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(zt.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(zt.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(zt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(zt.writeUint16(e.BytesOfClearData)),r.write(zt.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/(Ft+1)),i=Math.floor(r%(Ft+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,d=void 0===l?{}:l,f=o.cts,h=void 0===f?0:f;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,h>>>24&255,h>>>16&255,h>>>8&255,255&h],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(w(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===Ce?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,ut(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,ut(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,ut(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,ut(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,ut(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,ut(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}();c(Vt,"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))),c(Vt,"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])}),c(Vt,"FTYPAVC1",Vt.box(Vt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(Vt,"FTYPHEV1",Vt.box(Vt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(Vt,"DINF",Vt.box(Vt.types.dinf,Vt.box(Vt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(Vt,"VMHD",Vt.box(Vt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(Vt,"SMHD",Vt.box(Vt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(Vt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(Vt,"STTS",Vt.box(Vt.types.stts,Vt.StblTable)),c(Vt,"STSC",Vt.box(Vt.types.stsc,Vt.StblTable)),c(Vt,"STSZ",Vt.box(Vt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(Vt,"STCO",Vt.box(Vt.types.stco,Vt.StblTable));var Gt=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(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}();c(Gt,"disabled",!0);var Ht=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r})),Kt=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}();function Yt(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a=[],s=[];if(t){var o=[],u=0,c=t.start+t.size;t.references.forEach((function(e,r){o.push({index:r,startTime:u,endTime:u+e.subsegment_duration/t.timescale,duration:e.subsegment_duration/t.timescale,range:[c,c+e.referenced_size],frames:[]}),u+=e.subsegment_duration/t.timescale,c+=e.referenced_size})),a=o,s=o}else{var l,d,f=function(t){return t?[{index:0,startTime:0,endTime:t.duration/t.timescale,duration:t.duration/t.timescale,range:[e.start+e.size,""],frames:[]}]:[]};s=f(e.mvhd.duration?e.mvhd:null===(l=n.mdia)||void 0===l?void 0:l.mdhd),a=f(e.mvhd.duration?e.mvhd:null===(d=i.mdia)||void 0===d?void 0:d.mdhd)}return{videoSegments:s,audioSegments:a}}}}function Qt(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a,s=[],o=[];if(n){var u,c,l,d=null===(u=n.mdia)||void 0===u||null===(c=u.minf)||void 0===c?void 0:c.stbl;if(!d)return;var f=null===(l=n.mdia.mdhd)||void 0===l?void 0:l.timescale,h=d.stts,p=d.stsc,v=d.stsz,m=d.stco,y=d.stss,g=d.ctts;if(!(f&&h&&p&&v&&m&&y))return;a=(s=Wt(t,f,h,p,v,m,y,g)).map((function(e){return e.duration}))}if(i){var _,b,k,x=null===(_=i.mdia)||void 0===_||null===(b=_.minf)||void 0===b?void 0:b.stbl;if(!x)return;var w=null===(k=i.mdia.mdhd)||void 0===k?void 0:k.timescale,S=x.stts,E=x.stsc,j=x.stsz,T=x.stco;if(!(w&&S&&E&&j&&T))return;o=Wt(t,w,S,E,j,T,null,null,a)}return{videoSegments:s,audioSegments:o}}}}function Wt(e,t,r,n,i,a,s,o,u){var c,l,d,f,h,p=[],v=[],m=[],y=n.entries,g=a.entries,_=i.entrySizes,b=null==s?void 0:s.entries,k=null==o?void 0:o.entries;k&&(l=[],k.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)l.push(r)}))),b&&(d={},b.forEach((function(e){d[e-1]=!0})));var x=0,S=0,E=0,j=0,T=0,D=null===(c=y[0])||void 0===c?void 0:c.samplesPerChunk,C=y[1]?y[1].firstChunk-1:1/0,A=0,O=-1;r.entries.forEach((function(e){var t=e.count,r=e.delta;h=r;for(var n=0;n<t;n++)f={dts:A,startTime:x,duration:h,size:_[S]||i.sampleSize,offset:g[E]+T,index:S},b&&(f.keyframe=d[S],f.keyframe?(O++,v.push([f]),m.push(f.duration)):(v[v.length-1].push(f),m[v.length-1]+=f.duration),f.gopId=O),l&&S<l.length&&(f.pts=A+l[S]),0===S&&(f.pts=0),p.push(f),x+=h,A+=r,++S<D?T+=f.size:(E++,T=0,E>=C&&(j++,C=y[j+1]?y[j+1].firstChunk-1:1/0),D+=y[j].samplesPerChunk)}));var L=p.length;if(!L||s&&!p[0].keyframe)return[];var B,P=[],R=[],U=0,I=0,M=function(e){var r;B=R[R.length-1],P.push({index:P.length,startTime:(null===(r=P[P.length-1])||void 0===r?void 0:r.endTime)||R[0].startTime/t,endTime:(B.startTime+B.duration)/t,duration:e,range:[R[0].offset,B.offset+B.size],frames:R}),U=0,R=[]};if(s)for(var N=e*t,q=0,z=v.length;q<z;q++){var F;U+=m[q],(F=R).push.apply(F,w(v[q])),q+1<z?(0===q||U>N)&&M(U/t):M(U/t)}else for(var V=(u=u||[])[0]||e,G=0;G<L;G++){R.push(p[G]);var H=(U+=p[G].duration)/t;(G+1>=L||H+I>=V)&&(I+=H-V,M(H),V=u[P.length]||e)}return P}function Jt(e,t){var r="",n="",i=0,a=0,s=0,o=0,u=0,c=0,l=0;e.mvhd&&(u=e.mvhd.duration/e.mvhd.timescale);var d,f=e.trak;if(f){var h,p,v,m,y,g,_,b,k,x,w,S,E,j,T,D,C,A=f.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),O=f.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),L=null;if(A)if(L=null===(p=A.mdia)||void 0===p||null===(v=p.minf)||void 0===v||null===(m=v.stbl)||void 0===m?void 0:m.stsd.entries[0])if(i=L.width,a=L.height,c=null===(y=A.mdia)||void 0===y||null===(g=y.mdhd)||void 0===g?void 0:g.timescale,r=null===(_=L.avcC||L.hvcC||L.av1C)||void 0===_?void 0:_.codec,"encv"===L.type)h=null===(b=L.sinf)||void 0===b||null===(k=b.schi)||void 0===k?void 0:k.tenc.default_KID;if(O)if(L=null===(x=O.mdia)||void 0===x||null===(w=x.minf)||void 0===w||null===(S=w.stbl)||void 0===S?void 0:S.stsd.entries[0])if(s=L.channelCount,o=("mp4a"===(d=L).type?d.sampleRate>0?d.sampleRate:d.esds.sampleRate:d.sampleRate)||0,n=null===(E=L.esds)||void 0===E?void 0:E.codec,l=null===(j=O.mdia)||void 0===j||null===(T=j.mdhd)||void 0===T?void 0:T.timescale,"enca"===L.type)h=h||(null===(D=L.sinf)||void 0===D||null===(C=D.schi)||void 0===C?void 0:C.tenc.default_KID);return{kid:h?h.join(""):null,videoCodec:r,audioCodec:n,width:i,height:a,videoTimescale:c,audioChannelCount:s,audioSampleRate:o,duration:u,audioTimescale:l,moov:e,isFragmentMP4:t}}}function Xt(e){return"number"==typeof e&&!Number.isNaN(e)}var Zt=["vid","cache"],$t=function(e){l(S,e);var n,i,o,d,f,h,p,v,g,b,k,w=_(S);function S(e){var r;s(this,S),c(y(r=w.call(this)),"vid",""),c(y(r),"url",""),c(y(r),"meta",{}),c(y(r),"downloadInfo",[]),c(y(r),"videoSegments",[]),c(y(r),"audioSegments",[]),c(y(r),"cache",null),c(y(r),"_currentSegmentIndex",-1),c(y(r),"_currentLoadingSegmentIndex",-1),c(y(r),"buffer",void 0),c(y(r),"_error",void 0),c(y(r),"_transformError",(function(e){return e})),r._config=t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",cache:null},e);var n=r._config,i=n.vid,a=n.cache,o=m(n,Zt);return r.cache=a||new Kt,r.vid=i||o.url,r.url=o.url,o.transformError=r._transformError,r.logger=new K("MP4Loader_"+r.vid),e.openLog&&K.enable(),o.logger=r.logger,r._loader=new De(o),r._loader.on(ge,(function(e){r.emit(ge,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Xt(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Xt(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s,o){var u,c,l,d,f=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=x(i,2),c=u[0],l=u[1],this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[c,l]),d=function(){var e=a(r().mark((function e(t,i,u){var d,h,p,v,m,y,g,_,b,k,x,w,S;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f.meta&&null!=u&&u.range&&u.range.length>0&&u.range[1]>=l&&(i=!0,f.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=u&&u.range&&u.range.length>0&&u.range[1]<l&&(i=!1,f.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),f.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",u.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",f._error),!f._error&&t&&t.byteLength>0&&s(t,i,u),!f.meta.moov&&!f._error){e.next=6;break}return e.abrupt("return");case 6:if(!(t&&t.byteLength>0)){e.next=51;break}if(f.buffer=je(f.buffer,t),d=Bt.findBox(f.buffer,["moov"])[0]){e.next=23;break}if(h=Bt.findBox(f.buffer,["mdat"])[0],!i){e.next=23;break}if(h){e.next=18;break}return f._error=!0,s(null,i,u,{err:"cannot find moov or mdat box"}),e.abrupt("return");case 18:return p=h.start+h.size,e.next=21,f.loadData([p,""],n,o);case 21:(v=e.sent)&&(d=Bt.findBox(v.data,["moov"])[0]);case 23:if(!(d&&i&&d.size>d.data.length)){e.next=27;break}return f.logger.debug("[loadMetaProcess],moov not all, range,",u.range[1],",dataLen,",f.buffer.byteLength,", state,",i),e.next=27,f.loadMetaProcess(n,[u.range[1],d.start+d.size-1],s);case 27:if(!(d&&d.size<=d.data.length)||f.meta.moov){e.next=51;break}if(m=Bt.moov(d)){e.next=33;break}return f._error=!0,s(null,i,u,{err:"cannot parse moov box"}),e.abrupt("return");case 33:if(y=Qt(m,f._config.segmentDuration),g=function(){var e=a(r().mark((function e(t){var i,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=Bt.findBox(f.buffer,[t])[0])){e.next=11;break}if(!(i.size>i.data.length)){e.next=10;break}return e.next=5,f.loadData([i.start,i.start+i.size-1],n,o);case 5:if(!(a=e.sent)){e.next=8;break}return e.abrupt("return",Bt.findBox(a.data,[t])[0]);case 8:e.next=11;break;case 10:return e.abrupt("return",i);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_=!1,y&&y.videoSegments.length&&y.audioSegments.length){e.next=41;break}return e.next=39,g("sidx");case 39:(b=e.sent)&&(k=Bt.sidx(b))&&(y=Yt(m,k),_=!0);case 41:if(y){e.next=45;break}return f._error=!0,s(null,i,u,{err:"cannot parse segments"}),e.abrupt("return");case 45:f.meta=Jt(m,_),w=(x=y).videoSegments,S=x.audioSegments,f.videoSegments=w,f.audioSegments=S,f.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:f.meta,videoSegments:w,audioSegments:S}});case 51:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),e.next=6,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:d},o));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n,i){var a,s,o,u,c,l,d,f,h,p,v,m,y,g;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[],this.logger.debug("[loadMeta start]"),e.next=4,this.loadData([0,n||this._config.moovEnd],t,i);case 4:if(s=e.sent){e.next=7;break}return e.abrupt("return");case 7:if(a.push(s),o=Bt.findBox(s.data,["moov"])[0]){e.next=23;break}if(u=Bt.findBox(s.data,["mdat"])[0]){e.next=13;break}throw new Ht("cannot find moov or mdat box",s.data);case 13:return c=u.start+u.size,e.next=16,this.loadData([c],t,i);case 16:if(s=e.sent){e.next=19;break}return e.abrupt("return");case 19:if(a.push(s),o=Bt.findBox(s.data,["moov"],c)[0]){e.next=23;break}throw new Ht("cannot find moov box",s.data);case 23:if(!(o.size>o.data.length)){e.next=31;break}return e.next=26,this.loadData([s.data.length,o.start+o.size-1],t,i);case 26:if(s=e.sent){e.next=29;break}return e.abrupt("return");case 29:a.push(s),o.data=je(o.data,s.data);case 31:if(l=Bt.moov(o)){e.next=34;break}throw new Ht("cannot parse moov box",o.data);case 34:if(d=Qt(l,this._config.segmentDuration)){e.next=37;break}throw new Ht("cannot parse segments",o.data);case 37:return d.videoSegments.length&&d.audioSegments.length||(h=Bt.findBox(this.buffer,["moof"])[0],p=Bt.findBox(this.buffer,["sidx"])[0],h&&h.size<=h.data.length&&p&&(v=Bt.moof(h),f=Bt.sidx(p),v&&f&&(d=Yt(l,f)))),this.meta=Jt(l,f),y=(m=d).videoSegments,g=m.audioSegments,this.videoSegments=y,this.audioSegments=g,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:y,audioSegments:g,responses:a});case 44:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Qt(e.moov,this._config.segmentDuration),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(h=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"preload",value:(f=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length>0&&void 0!==t[0]&&t[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i,a){var s,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this._getCacheKey(n),e.next=3,this.cache.get(s);case 3:if(o=e.sent){e.next=11;break}return c=a&&a.url?a.url:this.url,e.next=8,this._loader.load(c,t({range:n,vid:this.vid},a));case 8:u=e.sent,e.next=12;break;case 11:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 12:if(u){e.next=14;break}return e.abrupt("return");case 14:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(be);return $t}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/esnext.typed-array.at.js"),require("core-js/modules/es.typed-array.copy-within.js"),require("core-js/modules/es.typed-array.every.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.filter.js"),require("core-js/modules/es.typed-array.find.js"),require("core-js/modules/es.typed-array.find-index.js"),require("core-js/modules/esnext.typed-array.find-last.js"),require("core-js/modules/esnext.typed-array.find-last-index.js"),require("core-js/modules/es.typed-array.for-each.js"),require("core-js/modules/es.typed-array.includes.js"),require("core-js/modules/es.typed-array.index-of.js"),require("core-js/modules/es.typed-array.iterator.js"),require("core-js/modules/es.typed-array.join.js"),require("core-js/modules/es.typed-array.last-index-of.js"),require("core-js/modules/es.typed-array.map.js"),require("core-js/modules/es.typed-array.reduce.js"),require("core-js/modules/es.typed-array.reduce-right.js"),require("core-js/modules/es.typed-array.reverse.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.slice.js"),require("core-js/modules/es.typed-array.some.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.subarray.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/es.typed-array.to-string.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.math.hypot.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.string.from-code-point.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.symbol.js","core-js/modules/es.array.concat.js","core-js/modules/es.function.name.js","core-js/modules/es.array.map.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.join.js","core-js/modules/es.array.includes.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.filter.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.constructor.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/esnext.typed-array.at.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/esnext.typed-array.find-last.js","core-js/modules/esnext.typed-array.find-last-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.string.replace.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.string.includes.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.math.hypot.js","core-js/modules/es.string.match.js","core-js/modules/es.string.from-code-point.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.array.sort.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).MP4Loader=t()}(this,(function(){"use strict";function e(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 t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.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(A){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,s=Object.create(a.prototype),o=new T(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=l;var f={};function h(){}function p(){}function v(){}var m={};c(m,s,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(j([])));g&&g!==t&&n.call(g,s)&&(m=g);var _=v.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(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=w(s,r);if(o){if(o===f)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=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(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,w(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;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,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}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 j(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:D}}function D(){return{value:void 0,done:!0}}return p.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(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(_),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(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"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=j,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)&&n.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 r(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 r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,f):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),f},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),f}},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:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e){return(n="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 i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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,T(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=T(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(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&&f(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(){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 p(e,t,r){return(p=h()?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&&f(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=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 p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},v(e)}function m(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}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(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 y(e)}function _(e){var t=h();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||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(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(e,t)||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.")}()}function w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(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 S(e,t){if(e){if("string"==typeof e)return E(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)?E(e,t):void 0}}function E(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 T(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var j={exports:{}};!function(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],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){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(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var f,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){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(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];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}(j);var D,A=j.exports,C=function(){function e(){s(this,e)}return u(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(t){}}},{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,d=e.buffers(t,n),f=0,h=d.length;f<h;f++){var p=d[f];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=f;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:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}},{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}(),O="network",L="network_timeout",B="network_forbidden",U="network_notfound",P="network_range_not_satisfiable",I="demux",R="remux",M="media",q="drm",z="other",N="runtime",F={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"},V=(c(D={},"manifest",{HLS:1100,DASH:1200}),c(D,O,2100),c(D,L,2101),c(D,B,2103),c(D,U,2104),c(D,P,2116),c(D,I,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(D,R,{FMP4:4100,MP4:4200}),c(D,M,{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}),c(D,q,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(D,z,8e3),c(D,N,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),D),G=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===L?O:e,u.originError=i,u.ext=a,u.errorCode=V[e][n]||V[e],u.errorMessage=u.message,u.errorCode||(u.errorType=z,u.errorCode=V[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=z),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?L:O,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(v(Error)),H="real_time_speed",K={DEBUG:1,LOG:2,WARN:3,ERROR:4},Y=["Boolean","Number","String","Undefined","Null","Date","Object"],Q=function(){function e(t,r){s(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 u(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,[K.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(W(),"]"),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,[K.LOG].concat(n)),e.disabled||(t=console).log.apply(t,["[".concat(W(),"]"),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,[K.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,["[".concat(W(),"]"),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,[K.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,["[".concat(W(),"]"),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 X(e)}));t="[".concat(W(),"]")+this._prefix+JSON.stringify(a)}catch(o){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 W(){return(new Date).toLocaleString()}function J(e){if("object"!==n(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 X(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!Y.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=J(e[s]):"object"===n(e[s])?i[s]=X(e[s],t,r+1):i[s]=e[s]);return i}}c(Q,"disabled",!0);var Z="undefined"!=typeof window;function $(){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 ee(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var te=function(e){try{return JSON.stringify(e)}catch(t){return""}};function re(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return Z?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function ne(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var ie="appendBuffer",ae="removeBuffer",se="updateDuration",oe=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",$()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),c(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==se&&t.shift(),r){var i,a,s=ee()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),te(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)}}})),c(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 G(M,F.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new Q("MSE"),this._config.openLog&&Q.enable()}var t,i,o;return u(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!ne(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(r){}})),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))}),se,{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=ee()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=$()}return this._openPromise}},{key:"bindMedia",value:(o=a(r().mark((function e(t){var n,i,a,s,o=this;return r().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(n=re(this._config.preferMMS),t&&n){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new n,a=ne(i),this._st=ee(),s=function e(){var r=ee()-o._st;o._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),o._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",s),a&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=a,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"unbindMedia",value:(i=a(r().mark((function e(){var t,n,i,a=this;return r().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=a._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)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}})),ne(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(r){}this.media=null}this.mediaSource=null,this._openPromise=$(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.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(n){throw new G(M,F.MSE_ADD_SB,n)}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 G(M,F.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(i){throw new G(M,F.MSE_CHANGE_TYPE,i)}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=ee(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),ie,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=ee(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),ae,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,C.end(C.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 C.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return C.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return C.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:$(),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=a(r().mark((function e(t,n,i){var a,s,o=this;return r().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((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=$();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._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(s){var i,a;if(s&&s.message&&s.message.indexOf("SourceBuffer is full")>=0)this._mseFullFlag[e]=!0,r.context&&"object"===n(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),null==r||null===(i=r.promise)||void 0===i||i.reject(new G(M,F.MSE_FULL,s));else this._logger.error(s),null==r||null===(a=r.promise)||void 0===a||a.reject(s.constructor===G?s:new G(M,F.MSE_OTHER,s)),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 t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=re(r);if(!n)return!1;try{return n.isTypeSupported(t)}catch(i){return e._logger.error(t,i),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();c(oe,"VIDEO","video"),c(oe,"AUDIO","audio");var ue=Object.prototype.toString;function ce(e){if("[object Object]"!==ue.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function le(){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 de(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var fe="fetch",he="xhr",pe="arraybuffer",ve="text",me="json";var ye=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(y(o=t.call(this,a)),"retryCount",0),c(y(o),"isTimeout",!1),c(y(o),"loaderType",fe),c(y(o),"startTime",0),c(y(o),"endTime",0),c(y(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(Error));function ge(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 _e(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function be(e,t){if(e){if(!t)return e;var r,i=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]"===ue.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(_e(e),"=").concat(_e(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function ke(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 xe(e,t){return Math.round(8*e*1e3/t/1024)}var we=2097152,Se=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(y(e=n.call(this)),"_abortController",null),c(y(e),"_timeoutTimer",null),c(y(e),"_reader",null),c(y(e),"_response",null),c(y(e),"_aborted",!1),c(y(e),"_index",-1),c(y(e),"_range",null),c(y(e),"_receivedLength",0),c(y(e),"_running",!1),c(y(e),"_logger",null),c(y(e),"_vid",""),c(y(e),"_firtstByte",0),c(y(e),"_onProcessMinLen",0),c(y(e),"_onCancel",null),c(y(e),"_priOptions",null),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.dynamicTimeoutIns,c=e.responseType,l=e.onProgress,d=e.index,f=e.onTimeout,h=e.onCancel,p=e.range,v=e.transformResponse,m=e.request,y=e.params,g=e.logger,_=e.method,b=e.headers,k=e.body,x=e.mode,w=e.credentials,S=e.cache,E=e.redirect,T=e.referrer,j=e.referrerPolicy,D=e.onProcessMinLen,A=e.priOptions,C=e.streamRes,O=e.firstMaxChunkSize;this._logger=g,this._aborted=!1,this._onProcessMinLen=D,this._onCancel=h,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=d,this._range=p||[0,0],this._vid=s||i,this._priOptions=A||{},this._firstMaxChunkSize=O;var L={method:_,headers:b,body:k,mode:x,credentials:w,cache:S,redirect:E,referrer:T,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},B=!1;clearTimeout(this._timeoutTimer);var U=u&&"function"==typeof u.getTimeout?u.getTimeout(o):o;i=be(i,y);var P=ge(p);P&&(b=m?m.headers:L.headers=L.headers||(Headers?new Headers:{}),Headers&&b instanceof Headers?b.append("Range",P):b.Range=P),U&&(this._timeoutTimer=setTimeout((function(){if(B=!0,n.cancel(),f){var e=new ye(i,L,null,"timeout");e.isTimeout=!0,f(e,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})}}),U));var I=Date.now();return this._logger.debug("[fetch load start], index,",d,",range,",p,",[dytimeout]",U),new Promise((function(e,t){(C?new Promise((function(e){e(C)})):fetch(m||i,m?void 0:L)).then(function(){var s=a(r().mark((function a(s){var o,f,h,m,y;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(v&&(s=v(s,i)||s),s.ok){r.next=7;break}throw new ye(i,L,s,"bad network response");case 7:if(o=Date.now(),u&&"function"==typeof u.update&&(f=o-I,n._logger.debug("[dytimeout] fetch update rtt,",f),u.update(f)),c!==ve){r.next=16;break}return r.next=12,s.text();case 12:h=r.sent,n._running=!1,r.next=38;break;case 16:if(c!==me){r.next=23;break}return r.next=19,s.json();case 19:h=r.sent,n._running=!1,r.next=38;break;case 23:if(!l){r.next=30;break}return n.resolve=e,n.reject=t,n._loadChunk(s,l,I,o),r.abrupt("return");case 30:return r.next=32,s.arrayBuffer();case 32:h=r.sent,h=new Uint8Array(h),n._running=!1,m=Date.now()-I,y=xe(h.byteLength,m),n.emit(H,{speed:y,len:h.byteLength,time:m,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 38:n._logger.debug("[fetch load end], index,",d,",range,",p),e(ke(h,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),I,o,d,p,n._vid,n._priOptions));case 40:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!B||((e=e instanceof ye?e:new ye(i,L,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=I,e.endTime=Date.now(),e.isTimeout=B,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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(t){}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 t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new ye(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(we),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),f=function(){var o=a(r().mark((function a(){var o,h,p,v,m,y,g,_,b,k;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(h=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=h+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[p,p],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:v=u.value?u.value.byteLength:0,s._receivedLength+=v,s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",p,", end,",h+s._receivedLength,", done,",u.done),s._onProcessMinLen>0?s._writeIdx+v>=s._onProcessMinLen||u.done?((m=new Uint8Array(s._writeIdx+v)).set(s._cache.slice(0,s._writeIdx),0),v>0&&m.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",m.byteLength,", writeIdx,",s._writeIdx)):v>0&&s._writeIdx+v<we?(s._cache.set(u.value,s._writeIdx),s._writeIdx+=v,s._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",s._writeIdx)):v>0&&(y=new Uint8Array(s._writeIdx+v+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+v+2048,", datalen,",v,", writeIdx,",s._writeIdx),y.set(s._cache.slice(0,s._writeIdx),0),v>0&&y.set(u.value,s._writeIdx),s._writeIdx+=v,delete s._cache,s._cache=y,s._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",s._writeIdx)):m=u.value,(m&&m.byteLength>0||u.done)&&(s._firstMaxChunkSize&&(s._firtstByte?s._cacheData&&((_=new Uint8Array(s._cacheData.byteLength+m.byteLength)).set(s._cacheData,0),_.set(m,s._cacheData.byteLength),m=_,s._cacheData=null):(s._firtstByte++,g=m.slice(0,s._firstMaxChunkSize),s._cacheData=m.slice(s._firstMaxChunkSize),m=g)),t(m,u.done,{range:[s._range[0]+s._receivedLength-(m?m.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e)),u.done?(b=Date.now()-n,k=xe(s._receivedLength,b),s.emit(H,{speed:k,len:s._receivedLength,time:b,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions}),s._running=!1,s._logger.debug("[fetchLoader onProgress end],task,",s._range,",done,",u.done),s.resolve(ke(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,i,s._index,s._range,s._vid,s._priOptions))):s._firstMaxChunkSize?setTimeout((function(){f()}),0):f();case 25:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.apply(this,arguments)}}();f()}},{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)}}]),i}(A),Ee=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(y(e=r.call(this)),"_xhr",null),c(y(e),"_aborted",!1),c(y(e),"_timeoutTimer",null),c(y(e),"_range",null),c(y(e),"_receivedLength",0),c(y(e),"_url",null),c(y(e),"_onProgress",null),c(y(e),"_index",-1),c(y(e),"_headers",null),c(y(e),"_currentChunkSizeKB",384),c(y(e),"_timeout",null),c(y(e),"_xhr",null),c(y(e),"_dynamicTimeoutIns",null),c(y(e),"_withCredentials",null),c(y(e),"_startTime",-1),c(y(e),"_loadCompleteResolve",null),c(y(e),"_loadCompleteReject",null),c(y(e),"_runing",!1),c(y(e),"_logger",!1),c(y(e),"_vid",""),c(y(e),"_responseType",void 0),c(y(e),"_credentials",void 0),c(y(e),"_method",void 0),c(y(e),"_transformResponse",void 0),c(y(e),"_firstRtt",void 0),c(y(e),"_onCancel",null),c(y(e),"_priOptions",null),e}return u(n,[{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._dynamicTimeoutIns=e.dynamicTimeoutIns,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=be(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 ye?e:new ye(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===pe&&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,n=this._dynamicTimeoutIns&&"function"==typeof this._dynamicTimeoutIns.getTimeout?this._dynamicTimeoutIns.getTimeout(this._timeout):this._timeout;n&&(r.timeout=n),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 ye(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 ye(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 i=this._headers||{},a=ge(e);a&&(i.Range=a),i&&Object.keys(i).forEach((function(e){r.setRequestHeader(e,i[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e,",[dytimeout],",n),r.send(this._body)}catch(s){s.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}}},{key:"_onReadyStatechange",value:function(e){if(2===e.target.readyState&&(this._firstRtt<0&&(this._firstRtt=Date.now()),this._dynamicTimeoutIns&&"function"==typeof this._dynamicTimeoutIns.update)){var t=Date.now()-this._startTime;this._logger.debug("[dytimeout] xhr update rtt,",t),this._dynamicTimeoutIns.update(t)}}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new ye(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===pe){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,f=xe(this._receivedLength,d);this.emit(H,{speed:f,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var h={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(h=this._transformResponse(h,this._url)||h),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},h),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(ke(this._onProgress?null:s,o,h,h.headers["content-length"],h.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,k(d(n.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=S(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(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(A),Te=["retry","retryDelay","onRetryError","transformError","changeUrlRetry"],je=function(){function e(t,r){s(this,e),this.promise=$(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new Q("Loader")),this._loaderType=t,this._loader=t===fe&&"undefined"!=typeof fetch?new Se:new Ee,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger,this._useUrlIdx=-1,this._changeUrl=!1}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=t.changeUrlRetry,c=m(t,Te),l=function(){var t=a(r().mark((function t(){var a,d,f,h,p,v;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,a=c,e._changeUrl&&(e._changeUrl=!1,null!==(d=e._config.urlList)&&void 0!==d&&d[e._useUrlIdx]&&(a=Object.assign({},a,{url:e._config.urlList[e._useUrlIdx]}),e._logger.debug("[task],changeUrlRetry,urlIdx:",e._useUrlIdx,a.url))),t.next=5,e._loader.load(a);case 5:f=t.sent,e.promise.resolve(f),t.next=30;break;case 9:if(t.prev=9,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=15;break}return t.abrupt("return");case 15:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,h=t.t0,o&&(h=o(h)||h),s&&e._retryCount>0&&s(h,e._retryCount,{index:c.index,vid:c.vid,range:c.range,priOptions:c.priOptions}),e._retryCount++,p=!0,e._retryCheckFunc&&(p=e._retryCheckFunc(t.t0)),!(p&&e._retryCount<=n)){t.next=29;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",c.range,e._useUrlIdx),u&&e._useUrlIdx<(null===(v=e._config.urlList)||void 0===v?void 0:v.length)-1&&(e._useUrlIdx++,e._changeUrl=!0,e._logger.debug("retry changeurl, urlIdx: ",e._useUrlIdx,",retry range,",c.range)),e._retryTimer=setTimeout(l,i),t.abrupt("return");case 29:e.promise.reject(h);case 30:case"end":return t.stop()}}),t,null,[[0,9]])})));return function(){return t.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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}(),De=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(y(r=i.call(this,e)),"type",fe),c(y(r),"_queue",[]),c(y(r),"_alive",[]),c(y(r),"_currentTask",null),c(y(r),"_finnalUrl",""),c(y(r),"_config",void 0),r._config=function(e){return t({loaderType:fe,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:ve,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),r._config.loaderType!==he&&Se.isSupported()||(r.type=he),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===fe}},{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&&ce(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&ce(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log,r.dynamicTimeoutIns=this._config.dynamicTimeoutIns;var n=new je(this.type,r);return n.loader.on(H,(function(e){t.emit(H,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().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,de();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 Se.isSupported()}}]),o}(A),Ae="undefined"!=typeof window,Ce=Ae&&navigator.userAgent.toLocaleLowerCase(),Oe=Ae&&/^((?!chrome|android).)*safari/.test(Ce),Le=Ae&&Ce.includes("firefox"),Be=Ae&&Ce.includes("android"),Ue=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(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(0!=(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}(),Pe=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(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}();c(Pe,"disabled",!0);var Ie=function(){function e(){s(this,e)}return u(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}();function Re(){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}var Me=Math.pow(2,32);function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function ze(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 Ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ze(e,t)*Me+ze(e,t+4)}function Fe(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 Ve(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)}))}function Ge(e,t){return Number(e+"."+t)}var He=function(){function e(){s(this,e)}return u(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,d=1+((192&t[i+2])>>>6),f=(1&t[i+2])<<2|(192&t[i+3])>>>6,h=e._getConfig(o,f,d),p=h.config,v=h.codec,m=0,y=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+m*y,data:t.subarray(i+7+c,i+l)}),m++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:f,codec:v,config:p,originCodec:"mp4a.40.".concat(d)}}}},{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){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,a=[];return Le?e>=6?(n=5,i=e-3):(n=2,i=e):Be?(n=2,i=e):(n=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}();c(He,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Ke=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAnnexB",value:function(e){var t=e.byteLength-1,r=0;do{if(0!==e[t])break;r++,t--}while(t>0);r>=3&&(e=e.subarray(0,t+1));for(var n=e.length,i=2,a=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((a=++i+2)>=n)return[];for(var s=[];a<n;)switch(e[a]){case 0:if(0!==e[a-1]){a+=2;break}if(0!==e[a-2]){a++;break}if(a<n-1&&1!==e[a+1]){a++;break}i!==a-2&&s.push(e.subarray(i,a-2));do{a++}while(1!==e[a]&&a<n);a=(i=a+1)+2;break;case 1:if(0!==e[a-1]||0!==e[a-2]){a+=3;break}i!==a-2&&s.push(e.subarray(i,a-2)),a=(i=a+1)+2;break;default:a+=3}return i<n&&s.push(e.subarray(i)),s}},{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=ze(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}(),Ye=function(){function e(){s(this,e)}return u(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(Ke.removeEPB(l)))}var d,f=t[o];o++;for(var h=0;h<f;h++)d=t[o]<<8|t[o+1],o+=2,d&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Ue(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(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var f=t.readUEG(),h=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,m,y,g,_,b=0,k=0,x=0,w=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),x=t.readUEG(),w=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);m=t.readBool(),_=(y=E)/(g=2*S)}}return{codec:Fe(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(f+1)-2*(b+k)),height:(2-p)*(h+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:y,fpsDen:g,fps:_,fixedFrame:m}}}]),e}(),Qe=function(){function e(){s(this,e)}return u(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=[],d=[],f=23,h=t[22],p=0;p<h;p++){a=63&t[f],s=t[f+1]<<8|t[f+2],f+=3;for(var v=0;v<s;v++)if(o=t[f]<<8|t[f+1],f+=2,o){switch(a){case 32:var m=t.subarray(f,f+o);n||(n=e.parseVPS(Ke.removeEPB(m),r)),d.push(m);break;case 33:var y=t.subarray(f,f+o);i||(i=e.parseSPS(Ke.removeEPB(y),r)),c.push(y);break;case 34:l.push(t.subarray(f,f+o))}f+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:d,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new Ue(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 Ue(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,d,f=n.readUEG(),h=n.readUEG(),p=n.readBits(1);if(1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),d=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p){var v=1!==a&&2!==a||0!==o?1:2,m=1===a&&0===o?2:1;f-=v*(c+u),h-=m*(d+l)}return{codec:"hev1.1.6.L93.B0",width:f,height:h,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}(),We=function(){function e(){s(this,e)}return u(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}(),Je=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),Xe="video",Ze="audio",$e="metadata",et="av1",tt="avc",rt="hevc",nt="aac",it="g7110a",at="g7110m",st="opus",ot="mp3",ut="LARGE_AV_SHIFT",ct="LARGE_VIDEO_GAP",lt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",dt="LARGE_AUDIO_GAP",ft="AUDIO_FILLED",ht="AUDIO_DROPPED",pt=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",Ze),c(this,"codecType",nt),c(this,"pid",-1),c(this,"codec",""),c(this,"container",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"parsedCodec",null),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(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.container||this.codecType!==nt&&this.codecType!==it&&this.codecType!==at&&this.codecType!==st&&this.codecType!==ot)}},{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}(),vt=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),mt=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(vt),yt=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(vt),gt=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",$e),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(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}(),_t=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(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}(),bt=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",Xe),c(this,"codecType",tt),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"lastKeyFrameDts",0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(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}(),kt=function(){function e(){s(this,e)}return u(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}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var f=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),h=f.size,p=f.data;if(f.isEnd)break;r[p.name]=p.value,i+=h}if(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 m=0;m<v;m++){var y=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=y.data,_=y.size;r.push(g),i+=_}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=Ie.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=Ie.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}(),xt=1e3,wt=5e3,St=function(){function e(t,r,n){s(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 u(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;!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);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}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=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var f;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:lt,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(f=r[1])||void 0===f?void 0:f.dts,sampleDuration:d});this._videoTimestampBreak>=5?(this._videoNextDts=l.dts,this._videoTimestampBreak=0):(l.dts+=d,l.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var h=0;h<u;h++){var p=r[h].dts,v=r[h+1];((c=h<u-1?v.dts-p:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:ct,time:p/e.timescale,dts:p,originDts:r[h].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[h].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{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:ut,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 nt:e.sampleDuration=He.getFrameDuration(e.timescale,r);break;case st:e.sampleDuration=We.getFrameDuration(e.samples,r);break;case it:case at:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===st?20:e.codecType===nt?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<=xt&&!Oe){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>wt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:ft,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var f=0;f<d;f++){var h=new Je(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);h.originPts=Math.floor(this._baseDts+o),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>wt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:ht,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--;else{if(Math.abs(c)>xt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>wt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:dt,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===st){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===nt?He.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),Et=7,Tt=8,jt=10,Dt=13,At=new Pe("FlvDemuxer"),Ct=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new bt,this.audioTrack=r||new pt,this.metadataTrack=n||new gt,this._fixer=new St(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(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=Re(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=0!=(1&t[4]),this._headerParsed=!0,c=ze(t,5)+4}for(var l,d,f,h,p,v=t.length;c+15<v&&(l=t[c],!(c+15+(d=t[c+1]<<16|t[c+2]<<8|t[c+3])>v));)f=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,h=t.subarray(c,c+d),8===l?this._parseAudio(h,f):9===l?(a&&(this.seamlessLoadingSwitching=!0),this._parseVideo(h,f)):18===l?this._parseScript(h,f):At.warn("Invalid tag type: ".concat(l)),(p=ze(t,c+=d))!==11+d&&At.warn("Invalid PrevTagSize ".concat(p," (").concat(11+d,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),s.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,s.timescale=s.codecType===st?1e3:s.sampleRate||0,!s.exist()&&s.hasSample()&&s.reset(),!o.exist()&&o.hasSample()&&o.reset();var m=u.flvScriptSamples[u.flvScriptSamples.length-1],y=null==m||null===(r=m.data)||void 0===r?void 0:r.onMetaData;return y&&(null!=o&&o.exist()&&(y.hasOwnProperty("duration")&&(o.duration=1e3*y.duration),!o.width&&y.hasOwnProperty("width")&&(o.width=y.width),!o.height&&y.hasOwnProperty("height")&&(o.height=y.height)),null!=s&&s.exist()&&y.hasOwnProperty("duration")&&(s.duration=1e3*y.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(n!==jt&&n!==Et&&n!==Tt&&n!==Dt)return At.warn("Unsupported sound format: ".concat(n)),void i.reset();if(n!==jt&&n!==Dt){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 Et:case Tt:this._parseG711(t,r,n);break;case jt:this._parseAac(t,r);break;case Dt:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=st,n){case 0:var i=We.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=We.getFrameDuration([],r.timescale)):(r.reset(),At.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var a=new Je(t,e.subarray(2),r.sampleDuration);r.samples.push(a);break;default:At.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack,i=e.subarray(1);if(!(i.byteLength<1)){var a=new Je(t,i);n.codecType=7===r?it:at,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(a)}}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=nt,0===e[1]){var n=He.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(),At.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Je(t,e.subarray(2)))}else At.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 At.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?rt:tt;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?Qe.parseHEVCDecoderConfigurationRecord(c):Ye.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,f=l.sps,h=l.ppsArr,p=l.spsArr,v=l.vpsArr,m=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),f&&(a.codec=f.codec,a.width=f.width,a.height=f.height,a.sarRatio=f.sarRatio,a.fpsNum=f.fpsNum,a.fpsDen=f.fpsDen),p.length&&(a.sps=p),h.length&&(a.pps=h),v&&v.length&&(a.vps=v),m&&(a.nalUnitSize=m)}else At.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var y=Ke.parseAvcC(e.subarray(5),a.nalUnitSize);if((y=this._checkAddMetaNalToUnits(s,y,a))&&y.length){var g=new _t(t+u,t,y);if(this.seamlessLoadingSwitching&&t<a.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(g.setToKeyframe(),a.lastKeyFrameDts=t),a.samples.push(g),y.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;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new yt(Ke.parseSEI(Ke.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else At.warn("Cannot parse NALUs",e)}else 2===o||At.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 mt(kt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&ze(e,5)>=9}}]),e}();function Ot(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}c(Ct,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var Lt=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(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=Ot(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}(),Bt=function(){function e(t,r){s(this,e),this.offset=0,this.val=t,this.size=r}return u(e,[{key:"skip",value:function(e){this.offset+=e}},{key:"read",value:function(e){var t=this.size-this.offset-e;if(t>=0){var r=0,n=0;if(this.offset+=e,this.size>31){for(;n<e;n++)r+=Math.pow(2,n);return this.val/Math.pow(2,t)&r}for(;n<e;n++)r+=1<<n;return this.val>>>t&r}throw new Error("the number of the read operation exceeds the total length limit of bits")}}],[{key:"fromByte",value:function(t,r){return new e(t.read(r),r<<3)}}]),e}(),Ut=function(){function e(t,r,n){s(this,e),this.dv=new DataView(t),this.start=this.offset=r||this.dv.byteOffset,this.end=n?this.start+n:this.start+this.dv.byteLength}return u(e,[{key:"buffer",get:function(){return this.dv.buffer}},{key:"unreadLength",get:function(){return Math.max(this.end-this.offset,0)}},{key:"size",get:function(){return this.end-this.start}},{key:"readFloat",value:function(e){var t=0;switch(e){case 4:t=this.dv.getFloat32(this.offset);break;case 8:t=this.dv.getFloat64(this.offset);break;default:throw new Error("read ".concat(e,"-byte float is not supported"))}return this.offset+=e,t}},{key:"back",value:function(e){this.offset-=e}},{key:"skip",value:function(e){this.offset+=e}},{key:"readInt",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getInt8(t);case 2:return this.dv.getInt16(t);case 4:return this.dv.getInt32(t);default:throw new Error("read ".concat(e,"-byte integers is not supported"))}}},{key:"read",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getUint8(t);case 2:return this.dv.getUint16(t);case 3:return(this.dv.getUint16(t)<<8)+this.dv.getUint8(t+2);case 4:return this.dv.getUint32(t);default:return this.back(e-4),this.read(e-4)+this.dv.getUint32(t)*Math.pow(256,e-4)}}},{key:"write",value:function(e,t){var r=this.offset;switch(this.offset+=e,e){case 1:return this.dv.setUint8(r,t);case 2:return this.dv.setUint16(r,t);case 3:return this.dv.setUint8(r,t>>>16),this.dv.setUint16(r+1,65535&t);case 4:return this.dv.setUint32(r,t);default:throw new Error("write ".concat(e,"-byte integers is not supported"))}}},{key:"readToBuffer",value:function(e){var t;return t=this.offset||e?this.dv.buffer.slice(this.offset,e?this.offset+e:this.end):this.dv.buffer,this.offset+=t.byteLength,t}},{key:"readToUint8",value:function(e){var t=new Uint8Array(this.dv.buffer,this.offset,e||this.unreadLength);return this.offset+=t.byteLength,t}},{key:"readString",value:function(e){for(var t=0,r="";t<e;t++)r+=String.fromCharCode(this.dv.getUint8(this.offset)),this.offset++;return r}}],[{key:"fromUint8",value:function(t){return new e(t.buffer,t.byteOffset,t.byteLength)}},{key:"concatUint8s",value:function(e){var t=new Uint8Array(e.reduce((function(e,t){return e+t.byteLength}),0)),r=0;return e.forEach((function(e){t.set(e,r),r+=e.byteLength})),t}},{key:"concatUint8",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.concatUint8s(r)}}]),e}(),Pt=function(){function e(){s(this,e)}return u(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var a=0,s="",o=0;t.length>7;){if(a=ze(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=Ne(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return qt(e,!0,(function(e,t){e.trackId=ze(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=ze(t,r),r+=4),i&&(e.sampleDescriptionIndex=ze(t,r),r+=4),a&&(e.defaultSampleDuration=ze(t,r),r+=4),s&&(e.defaultSampleSize=ze(t,r),r+=4),o&&(e.defaultSampleFlags=ze(t,r))}))}},{key:"sidx",value:function(e){return qt(e,!0,(function(e,t){var r=0;e.reference_ID=ze(t,r),r+=4,e.timescale=ze(t,r),r+=4,0===e.version?(e.earliest_presentation_time=ze(t,r),r+=4,e.first_offset=ze(t,r),r+=4):(e.earliest_presentation_time=Ne(t,r),r+=8,e.first_offset=Ne(t,r),r+=8),r+=2,e.references=[];var n=qe(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=ze(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=ze(t,r),s=ze(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return qt(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return qt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ze(t,16),e.duration=Ne(t,20),r+=28):(e.timescale=ze(t,8),e.duration=ze(t,12),r+=16),e.nextTrackId=ze(t,r+76)}))}},{key:"trak",value:function(t){return qt(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return qt(e,!0,(function(e,t){var r=Ut.fromUint8(t);1===e.version?(r.read(8),r.read(8),e.trackId=r.read(4),r.read(4),e.duration=r.read(8)):(r.read(4),r.read(4),e.trackId=r.read(4),r.read(4),e.duration=r.read(4)),r.skip(16),e.matrix=[];for(var n=0;n<36;n++)e.matrix.push(r.read(1));r.back(36);for(var i,a=[],s=0;s<3;s++)a.push(Ge(r.readInt(2),r.readInt(2))),a.push(Ge(r.readInt(2),r.readInt(2))),i=r.readInt(4),a.push(Ge(i>>30,1073741823&i));e.rotation=function(e){if(e.length<5)return 0;var t=Math.hypot(e[0],e[3]),r=Math.hypot(e[1],e[4]);return 0===t||0===r?0:180*Math.atan2(e[1]/r,e[0]/t)/Math.PI}(a),e.width=r.read(4),e.height=r.read(4)}))}},{key:"mdia",value:function(t){return qt(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return qt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ze(t,16),e.duration=Ne(t,20),r+=28):(e.timescale=ze(t,8),e.duration=ze(t,12),r+=16);var n=qe(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return qt(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return qt(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return qt(e,!0,(function(e,t){e.graphicsmode=qe(t),e.opcolor=[qe(t,2),qe(t,4),qe(t,6)]}))}},{key:"smhd",value:function(e){return qt(e,!0,(function(e,t){e.balance=qe(t)}))}},{key:"stbl",value:function(t){return qt(t,!1,(function(t,r,n){var i,a,s;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return qt(e,!0,(function(e,r){var n=0,i=ze(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=qe(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=qe(r,n),n+=2,l.BytesOfProtectedData=ze(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return qt(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(Nt(t[i+a]));if(i+=16,e.version>0){var s=ze(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(Nt(c))}}var l=ze(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return qt(t,!0,(function(t,r,n){t.entryCount=ze(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"av01":return e.av01(t);case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return qt(t,!1,(function(t,r,n){t.channelCount=qe(r,16),t.samplesize=qe(r,18),t.sampleRate=ze(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return qt(t,!1,(function(t,r,n){t.width=qe(r,24),t.height=qe(r,26),t.horizresolution=ze(r,28),t.vertresolution=ze(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return qt(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(Nt(t[r])),r+=1}))}},{key:"schi",value:function(t){return qt(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return qt(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return qt(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"colr",value:function(e){return qt(e,!1,(function(t,r){var n=Ut.fromUint8(r);t.data=e.data,t.colorType=n.readString(4),"nclx"===t.colorType?(t.colorPrimaries=n.read(2),t.transferCharacteristics=n.read(2),t.matrixCoefficients=n.read(2),t.fullRangeFlag=n.read(1)>>7):"rICC"!==t.colorType&&"prof"!==t.colorType||(t.iccProfile=r.readToUint8())}))}},{key:"av01",value:function(t){return qt(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.av1C=e.av1C(e.findBox(a,["av1C"],n)[0]),t.colr=e.colr(e.findBox(a,["colr"],n)[0])}))}},{key:"av1C",value:function(e){return qt(e,!1,(function(t,r){t.data=e.data;var n,i=Ut.fromUint8(r),a=Bt.fromByte(i,4);t.marker=a.read(1),t.version=a.read(7),t.seqProfile=a.read(3),t.seqLevelIdx0=a.read(5),t.seqTier0=a.read(1),t.highBitdepth=a.read(1),t.twelveBit=a.read(1),t.monochrome=a.read(1),t.chromaSubsamplingX=a.read(1),t.chromaSubsamplingY=a.read(1),t.chromaSamplePosition=a.read(2),t.reserved=a.read(3),t.initialPresentationDelayPresent=a.read(1),t.initialPresentationDelayPresent?t.initialPresentationDelayMinusOne=a.read(4):t.initialPresentationDelayMinusOne=0,t.configOBUs=i.readToUint8(),2===t.seqLevelIdx0&&1===t.highBitdepth?n=1===t.twelveBit?"12":"10":t.seqProfile<=2&&(n=1===t.highBitdepth?"10":"08"),t.codec=["av01",t.seqProfile,(t.seqLevelIdx0<10?"0"+t.seqLevelIdx0:t.seqLevelIdx0)+(t.seqTier0?"H":"M"),n].join(".")}))}},{key:"avc1",value:function(t){return qt(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return qt(e,!1,(function(t,r){t.data=e.data,t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=Fe([r[1],r[2],r[3]]),t.lengthSizeMinusOne=3&r[4],t.spsLength=31&r[5],t.sps=[];for(var n=6,i=0;i<t.spsLength;i++){var a=qe(r,n);n+=2,t.sps.push(r.subarray(n,n+a)),n+=a}t.ppsLength=r[n],n+=1,t.pps=[];for(var s=0;s<t.ppsLength;s++){var o=qe(r,n);n+=2,t.pps.push(r.subarray(n,n+=o)),n+=o}}))}},{key:"hvc1",value:function(t){return qt(t,!1,(function(t,r,n){var i=Rt(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return qt(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=ze(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=qe(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=qe(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=qe(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var f;(f=t.sps).push.apply(f,l)}else if(34===a){var h;(h=t.pps).push.apply(h,l)}}}))}},{key:"pasp",value:function(e){return qt(e,!1,(function(e,t){e.hSpacing=ze(t),e.vSpacing=ze(t,4)}))}},{key:"mp4a",value:function(t){return qt(t,!1,(function(t,r,n){var i=Mt(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return qt(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;if(31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[1])>>5)),e.objectType=o,e.codec+=o.toString(16),/^mp4a/gi.test(e.codec)&&s.length>=2){var u=(7&s[0])<<1|(128&s[1])>>7;e.samplingFrequencyIndex=u,u<He.FREQ.length&&(e.sampleRate=He.FREQ[u])}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return qt(e,!1,(function(e,t){Mt(e,t)}))}},{key:"stts",value:function(e){return qt(e,!0,(function(e,t){for(var r=ze(t),n=[],i=4,a=0;a<r;a++)n.push({count:ze(t,i),delta:ze(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return qt(e,!0,(function(e,t){var r=ze(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:ze(t,i),offset:ze(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:ze(t,i),offset:-(1+~ze(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return qt(e,!0,(function(e,t){for(var r=ze(t),n=[],i=4,a=0;a<r;a++)n.push({firstChunk:ze(t,i),samplesPerChunk:ze(t,i+4),sampleDescriptionIndex:ze(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return qt(e,!0,(function(e,t){var r=ze(t),n=ze(t,4),i=[];if(!r)for(var a=8,s=0;s<n;s++)i.push(ze(t,a)),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return qt(e,!0,(function(e,t){for(var r=ze(t),n=[],i=4,a=0;a<r;a++)n.push(ze(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return qt(e,!0,(function(e,t){for(var r=ze(t),n=[],i=4,a=0;a<r;a++)n.push(Ne(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return qt(e,!0,(function(e,t){for(var r=ze(t),n=[],i=4,a=0;a<r;a++)n.push(ze(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return qt(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return qt(e,!0,(function(e,t){e.sequenceNumber=ze(t)}))}},{key:"traf",value:function(t){return qt(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return qt(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=ze(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~ze(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=ze(t,s),s+=4),e.samples=[],i>s)for(var o,u=0;u<a;u++)o={},256&n&&(o.duration=ze(t,s),s+=4),512&n&&(o.size=ze(t,s),s+=4),1024&n&&(o.flags=ze(t,s),s+=4),2048&n&&(o.cts=r?-(1+~ze(t,s+4)):ze(t,s),s+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return qt(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=Ne(t):e.baseMediaDecodeTime=ze(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,a=e.trak;if(a&&a.length){var s=a.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=a.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(s&&t){var u,c,l,d,f,h,p,v=t,m=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(v.id=s.tkhd.trackId),v.tkhdDuration=s.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=s.mdia.mdhd.timescale,v.duration=s.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale,v.rotation=s.tkhd.rotation,v.matrix=s.tkhd.matrix;var y,g,_,b,k,x,w,S,E=s.mdia.minf.stbl.stsd.entries[0];if(v.width=E.width,v.height=E.height,E.pasp&&(v.sarRatio=[E.pasp.hSpacing,E.pasp.vSpacing]),E.av1C)v.codecType=et,v.codec=E.av1C.codec,v.av1C=E.av1C.data,E.colr&&(v.colr=E.colr.data);else if(E.hvcC)v.codecType=rt,v.codec=E.hvcC.codec,v.vps=E.hvcC.vps,v.sps=E.hvcC.sps,v.pps=E.hvcC.pps,v.hvcC=E.hvcC.data;else{if(!E.avcC)throw new Error("unknown video stsd entry");v.codec=E.avcC.codec,v.sps=E.avcC.sps,v.pps=E.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=s.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(f=s.mdia)||void 0===f||null===(h=f.minf)||void 0===h||null===(p=h.stbl)||void 0===p?void 0:p.ctts,E&&"encv"===E.type)v.isVideoEncryption=!0,E.default_KID=null===(y=E.sinf)||void 0===y||null===(g=y.schi)||void 0===g?void 0:g.tenc.default_KID,E.default_IsEncrypted=null===(_=E.sinf)||void 0===_||null===(b=_.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,E.default_IV_size=null===(k=E.sinf)||void 0===k||null===(x=k.schi)||void 0===x?void 0:x.tenc.default_IV_size,v.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,E.data_format=null===(w=E.sinf)||void 0===w||null===(S=w.frma)||void 0===S?void 0:S.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=E}if(o&&r){var T,j,D,A,C,O,L,B,U,P=r,I=null===(T=o.tkhd)||void 0===T?void 0:T.trackId;null!=I&&(P.id=o.tkhd.trackId),P.tkhdDuration=o.tkhd.duration,P.mvhdDurtion=e.mvhd.duration,P.mvhdTimecale=e.mvhd.timescale,P.timescale=P.formatTimescale=o.mdia.mdhd.timescale,P.duration=o.mdia.mdhd.duration||P.mvhdDurtion/P.mvhdTimecale*P.timescale;var R,M,q,z,N,F,V,G,H=o.mdia.minf.stbl.stsd.entries[0];switch(P.sampleSize=H.sampleSize,P.sampleRate=function(e){var t=0;t="mp4a"===e.type?e.sampleRate>0?e.sampleRate:e.esds.sampleRate:e.sampleRate;return t||0}(H),P.channelCount=H.channelCount,P.present=!0,H.type){case"alaw":P.codecType=P.codec=it,P.sampleRate=8e3;break;case"ulaw":P.codecType=P.codec=at,P.sampleRate=8e3;break;default:P.sampleDuration=He.getFrameDuration(P.sampleRate,P.timescale),P.sampleRateIndex=He.getRateIndexByRate(P.sampleRate),P.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(P.config=Array.from(H.esds.config)),P.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(P.sampleDuration=He.getFrameDuration(P.sampleRate,P.timescale),P.objectType=(null===(j=H.esds)||void 0===j?void 0:j.objectType)||2,H.esds&&(H.esds.config?P.config=Array.from(H.esds.config):console.warn("esds config is null")),P.codec=(null===(D=H.esds)||void 0===D?void 0:D.codec)||"mp4a.40.2",P.sampleRateIndex=He.getRateIndexByRate(P.sampleRate),P.ext={},P.ext.stss=null===(A=o.mdia)||void 0===A||null===(C=A.minf)||void 0===C||null===(O=C.stbl)||void 0===O?void 0:O.stss,P.ext.ctts=null===(L=o.mdia)||void 0===L||null===(B=L.minf)||void 0===B||null===(U=B.stbl)||void 0===U?void 0:U.ctts,P.present=!0,H&&"enca"===H.type)P.isAudioEncryption=!0,H.data_format=null===(R=H.sinf)||void 0===R||null===(M=R.frma)||void 0===M?void 0:M.data_format,H.default_KID=null===(q=H.sinf)||void 0===q||null===(z=q.schi)||void 0===z?void 0:z.tenc.default_KID,H.default_IsEncrypted=null===(N=H.sinf)||void 0===N||null===(F=N.schi)||void 0===F?void 0:F.tenc.default_IsEncrypted,H.default_IV_size=null===(V=H.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IV_size,P.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,P.useEME=e.useEME,P.kidValue=e.kidValue,P.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,Y,Q=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,W=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,J=Q||W?(Q||W).join(""):null;t&&(t.kid=J),r&&(r.kid=J)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,f=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=[];for(var h=0;h<o.sampleCount;h++)i[a.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[a.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:f,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(f++,e.gopId=f),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,f=u.stco,h=u.stss,p=u.ctts;if(!(c&&l&&d&&f&&h))return;i=It(c,l,d,f,p,h)}if(n){var v,m,y,g=null===(v=n.mdia)||void 0===v||null===(m=v.minf)||void 0===m?void 0:m.stbl;if(!g)return;var _=null===(y=n.mdia.mdhd)||void 0===y?void 0:y.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=It(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function It(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,f=n.entries,h=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,m=0,y=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:m,duration:n,size:h[y]||r.sampleSize,offset:f[g]+b,index:y},p&&(u.keyframe=s[y],u.keyframe&&v++,u.gopId=v),o&&y<o.length&&(u.pts=u.dts+o[y]),c.push(u),m+=n,++y<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function Rt(e,t){return e.dataReferenceIndex=qe(t,6),e.width=qe(t,24),e.height=qe(t,26),e.horizresolution=ze(t,28),e.vertresolution=ze(t,32),e.frameCount=qe(t,40),e.depth=qe(t,74),78}function Mt(e,t){return e.dataReferenceIndex=qe(t,6),e.channelCount=qe(t,16),e.sampleSize=qe(t,18),e.sampleRate=ze(t,24)/65536,28}function qt(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var zt=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},Nt=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(zt(Number(t).toString(16),2,0))})),e[0]},Ft=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(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}();c(Ft,"disabled",!0);var Vt=Math.pow(2,32)-1,Gt=function(){function e(){s(this,e)}return u(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===Xe&&e.codecType===rt}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Re(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],Ve(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=e.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(w(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(w(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,n=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]));return n}},{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,a=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]));return a}},{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,n=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]));return n}},{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===Xe?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===st?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]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),f=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),h=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,d),e.box(e.types.btrt,f),h,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(Ve(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===rt,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,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(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,w(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=x(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{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(w(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(w(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),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,f,h)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var m=e.trun1(t);return e.box(e.types.traf,r,n,m)}var y=e.sbgp(),g=e.saiz(t),_=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,y,g,_,b,k)}var x=e.sdtp(t);return e.box(e.types.traf,r,n,x,e.trun(t.samples,x.byteLength+76))}},{key:"sdtp",value:function(t){var r=new Lt;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,e.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new Lt,n=Lt.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Lt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Lt.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=Lt.writeUint32(s)}return t.samples.forEach((function(e){r.write(Lt.writeUint32(e.duration)),r.write(Lt.writeUint32(e.size)),r.write(Lt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Lt.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,e.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new Lt,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(Lt.writeUint32(16+o),e.types.senc,e.extension(0,a)),r.write(Lt.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(Lt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Lt.writeUint16(e.BytesOfClearData)),r.write(Lt.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,e.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/(Vt+1)),i=Math.floor(r%(Vt+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,d=void 0===l?{}:l,f=o.cts,h=void 0===f?0:f;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,h>>>24&255,h>>>16&255,h>>>8&255,255&h],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(w(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===Xe?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,Re(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,Re(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,Re(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,Re(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,Re(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,Re(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}();c(Gt,"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))),c(Gt,"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])}),c(Gt,"FTYPAVC1",Gt.box(Gt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(Gt,"FTYPHEV1",Gt.box(Gt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(Gt,"DINF",Gt.box(Gt.types.dinf,Gt.box(Gt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(Gt,"VMHD",Gt.box(Gt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(Gt,"SMHD",Gt.box(Gt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(Gt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(Gt,"STTS",Gt.box(Gt.types.stts,Gt.StblTable)),c(Gt,"STSC",Gt.box(Gt.types.stsc,Gt.StblTable)),c(Gt,"STSZ",Gt.box(Gt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(Gt,"STCO",Gt.box(Gt.types.stco,Gt.StblTable)),new Pe("TsDemuxer");var Ht=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}();var Kt=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r}));function Yt(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a=[],s=[];if(t){var o=[],u=0,c=t.start+t.size;t.references.forEach((function(e,r){o.push({index:r,startTime:u,endTime:u+e.subsegment_duration/t.timescale,duration:e.subsegment_duration/t.timescale,range:[c,c+e.referenced_size],frames:[]}),u+=e.subsegment_duration/t.timescale,c+=e.referenced_size})),a=o,s=o}else{var l,d,f=function(t){return t?[{index:0,startTime:0,endTime:t.duration/t.timescale,duration:t.duration/t.timescale,range:[e.start+e.size,""],frames:[]}]:[]};s=f(e.mvhd.duration?e.mvhd:null===(l=n.mdia)||void 0===l?void 0:l.mdhd),a=f(e.mvhd.duration?e.mvhd:null===(d=i.mdia)||void 0===d?void 0:d.mdhd)}return{videoSegments:s,audioSegments:a}}}}function Qt(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a,s=[],o=[];if(n){var u,c,l,d=null===(u=n.mdia)||void 0===u||null===(c=u.minf)||void 0===c?void 0:c.stbl;if(!d)return;var f=null===(l=n.mdia.mdhd)||void 0===l?void 0:l.timescale,h=d.stts,p=d.stsc,v=d.stsz,m=d.stco,y=d.stss,g=d.ctts;if(!(f&&h&&p&&v&&m&&y))return;a=(s=Wt(t,f,h,p,v,m,y,g)).map((function(e){return e.duration}))}if(i){var _,b,k,x=null===(_=i.mdia)||void 0===_||null===(b=_.minf)||void 0===b?void 0:b.stbl;if(!x)return;var w=null===(k=i.mdia.mdhd)||void 0===k?void 0:k.timescale,S=x.stts,E=x.stsc,T=x.stsz,j=x.stco;if(!(w&&S&&E&&T&&j))return;o=Wt(t,w,S,E,T,j,null,null,a)}return{videoSegments:s,audioSegments:o}}}}function Wt(e,t,r,n,i,a,s,o,u){var c,l,d,f,h,p=[],v=[],m=[],y=n.entries,g=a.entries,_=i.entrySizes,b=null==s?void 0:s.entries,k=null==o?void 0:o.entries;k&&(l=[],k.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)l.push(r)}))),b&&(d={},b.forEach((function(e){d[e-1]=!0})));var x=0,S=0,E=0,T=0,j=0,D=null===(c=y[0])||void 0===c?void 0:c.samplesPerChunk,A=y[1]?y[1].firstChunk-1:1/0,C=0,O=-1;r.entries.forEach((function(e){var t=e.count,r=e.delta;h=r;for(var n=0;n<t;n++)f={dts:C,startTime:x,duration:h,size:_[S]||i.sampleSize,offset:g[E]+j,index:S},b&&(f.keyframe=d[S],f.keyframe?(O++,v.push([f]),m.push(f.duration)):(v[v.length-1].push(f),m[v.length-1]+=f.duration),f.gopId=O),l&&S<l.length&&(f.pts=C+l[S]),0===S&&(f.pts=0),p.push(f),x+=h,C+=r,++S<D?j+=f.size:(E++,j=0,E>=A&&(T++,A=y[T+1]?y[T+1].firstChunk-1:1/0),D+=y[T].samplesPerChunk)}));var L=p.length;if(!L||s&&!p[0].keyframe)return[];var B,U=[],P=[],I=0,R=0,M=function(e){var r;B=P[P.length-1],U.push({index:U.length,startTime:(null===(r=U[U.length-1])||void 0===r?void 0:r.endTime)||P[0].startTime/t,endTime:(B.startTime+B.duration)/t,duration:e,range:[P[0].offset,B.offset+B.size],frames:P}),I=0,P=[]};if(s)for(var q=e*t,z=0,N=v.length;z<N;z++){var F;I+=m[z],(F=P).push.apply(F,w(v[z])),z+1<N?(0===z||I>q)&&M(I/t):M(I/t)}else for(var V=(u=u||[])[0]||e,G=0;G<L;G++){P.push(p[G]);var H=(I+=p[G].duration)/t;(G+1>=L||H+R>=V)&&(R+=H-V,M(H),V=u[U.length]||e)}return U}function Jt(e,t){var r="",n="",i=0,a=0,s=0,o=0,u=0,c=0,l=0;e.mvhd&&(u=e.mvhd.duration/e.mvhd.timescale);var d,f=e.trak;if(f){var h,p,v,m,y,g,_,b,k,x,w,S,E,T,j,D,A,C=f.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),O=f.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),L=null;if(C)if(L=null===(p=C.mdia)||void 0===p||null===(v=p.minf)||void 0===v||null===(m=v.stbl)||void 0===m?void 0:m.stsd.entries[0])if(i=L.width,a=L.height,c=null===(y=C.mdia)||void 0===y||null===(g=y.mdhd)||void 0===g?void 0:g.timescale,r=null===(_=L.avcC||L.hvcC||L.av1C)||void 0===_?void 0:_.codec,"encv"===L.type)h=null===(b=L.sinf)||void 0===b||null===(k=b.schi)||void 0===k?void 0:k.tenc.default_KID;if(O)if(L=null===(x=O.mdia)||void 0===x||null===(w=x.minf)||void 0===w||null===(S=w.stbl)||void 0===S?void 0:S.stsd.entries[0])if(s=L.channelCount,o=("mp4a"===(d=L).type?d.sampleRate>0?d.sampleRate:d.esds.sampleRate:d.sampleRate)||0,n=null===(E=L.esds)||void 0===E?void 0:E.codec,l=null===(T=O.mdia)||void 0===T||null===(j=T.mdhd)||void 0===j?void 0:j.timescale,"enca"===L.type)h=h||(null===(D=L.sinf)||void 0===D||null===(A=D.schi)||void 0===A?void 0:A.tenc.default_KID);return{kid:h?h.join(""):null,videoCodec:r,audioCodec:n,width:i,height:a,videoTimescale:c,audioChannelCount:s,audioSampleRate:o,duration:u,audioTimescale:l,moov:e,isFragmentMP4:t}}}function Xt(e){return"number"==typeof e&&!Number.isNaN(e)}var Zt=["vid","cache"],$t=function(e){l(S,e);var n,i,o,d,f,h,p,v,g,b,k,w=_(S);function S(e){var r;s(this,S),c(y(r=w.call(this)),"vid",""),c(y(r),"url",""),c(y(r),"meta",{}),c(y(r),"downloadInfo",[]),c(y(r),"videoSegments",[]),c(y(r),"audioSegments",[]),c(y(r),"cache",null),c(y(r),"_currentSegmentIndex",-1),c(y(r),"_currentLoadingSegmentIndex",-1),c(y(r),"buffer",void 0),c(y(r),"_error",void 0),c(y(r),"_transformError",(function(e){return e})),r._config=t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",cache:null},e);var n=r._config,i=n.vid,a=n.cache,o=m(n,Zt);return r.cache=a||new Ht,r.vid=i||o.url,r.url=o.url,o.transformError=r._transformError,r.logger=new Q("MP4Loader_"+r.vid),e.openLog&&Q.enable(),o.logger=r.logger,r._loader=new De(o),r._loader.on(H,(function(e){r.emit(H,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Xt(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Xt(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s,o){var u,c,l,d,f=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=x(i,2),c=u[0],l=u[1],this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[c,l]),d=function(){var e=a(r().mark((function e(t,i,u){var d,h,p,v,m,y,g,_,b,k,x,w,S;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f.meta&&null!=u&&u.range&&u.range.length>0&&u.range[1]>=l&&(i=!0,f.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=u&&u.range&&u.range.length>0&&u.range[1]<l&&(i=!1,f.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),f.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",u.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",f._error),!f._error&&t&&t.byteLength>0&&s(t,i,u),!f.meta.moov&&!f._error){e.next=6;break}return e.abrupt("return");case 6:if(!(t&&t.byteLength>0)){e.next=51;break}if(f.buffer=le(f.buffer,t),d=Pt.findBox(f.buffer,["moov"])[0]){e.next=23;break}if(h=Pt.findBox(f.buffer,["mdat"])[0],!i){e.next=23;break}if(h){e.next=18;break}return f._error=!0,s(null,i,u,{err:"cannot find moov or mdat box"}),e.abrupt("return");case 18:return p=h.start+h.size,e.next=21,f.loadData([p,""],n,o);case 21:(v=e.sent)&&(d=Pt.findBox(v.data,["moov"])[0]);case 23:if(!(d&&i&&d.size>d.data.length)){e.next=27;break}return f.logger.debug("[loadMetaProcess],moov not all, range,",u.range[1],",dataLen,",f.buffer.byteLength,", state,",i),e.next=27,f.loadMetaProcess(n,[u.range[1],d.start+d.size-1],s);case 27:if(!(d&&d.size<=d.data.length)||f.meta.moov){e.next=51;break}if(m=Pt.moov(d)){e.next=33;break}return f._error=!0,s(null,i,u,{err:"cannot parse moov box"}),e.abrupt("return");case 33:if(y=Qt(m,f._config.segmentDuration),g=function(){var e=a(r().mark((function e(t){var i,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=Pt.findBox(f.buffer,[t])[0])){e.next=11;break}if(!(i.size>i.data.length)){e.next=10;break}return e.next=5,f.loadData([i.start,i.start+i.size-1],n,o);case 5:if(!(a=e.sent)){e.next=8;break}return e.abrupt("return",Pt.findBox(a.data,[t])[0]);case 8:e.next=11;break;case 10:return e.abrupt("return",i);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_=!1,y&&y.videoSegments.length&&y.audioSegments.length){e.next=41;break}return e.next=39,g("sidx");case 39:(b=e.sent)&&(k=Pt.sidx(b))&&(y=Yt(m,k),_=!0);case 41:if(y){e.next=45;break}return f._error=!0,s(null,i,u,{err:"cannot parse segments"}),e.abrupt("return");case 45:f.meta=Jt(m,_),w=(x=y).videoSegments,S=x.audioSegments,f.videoSegments=w,f.audioSegments=S,f.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:f.meta,videoSegments:w,audioSegments:S}});case 51:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),e.next=6,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:d},o));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n,i){var a,s,o,u,c,l,d,f,h,p,v,m,y,g;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[],this.logger.debug("[loadMeta start]"),e.next=4,this.loadData([0,n||this._config.moovEnd],t,i);case 4:if(s=e.sent){e.next=7;break}return e.abrupt("return");case 7:if(a.push(s),o=Pt.findBox(s.data,["moov"])[0]){e.next=23;break}if(u=Pt.findBox(s.data,["mdat"])[0]){e.next=13;break}throw new Kt("cannot find moov or mdat box",s.data);case 13:return c=u.start+u.size,e.next=16,this.loadData([c],t,i);case 16:if(s=e.sent){e.next=19;break}return e.abrupt("return");case 19:if(a.push(s),o=Pt.findBox(s.data,["moov"],c)[0]){e.next=23;break}throw new Kt("cannot find moov box",s.data);case 23:if(!(o.size>o.data.length)){e.next=31;break}return e.next=26,this.loadData([s.data.length,o.start+o.size-1],t,i);case 26:if(s=e.sent){e.next=29;break}return e.abrupt("return");case 29:a.push(s),o.data=le(o.data,s.data);case 31:if(l=Pt.moov(o)){e.next=34;break}throw new Kt("cannot parse moov box",o.data);case 34:if(d=Qt(l,this._config.segmentDuration)){e.next=37;break}throw new Kt("cannot parse segments",o.data);case 37:return d.videoSegments.length&&d.audioSegments.length||(h=Pt.findBox(this.buffer,["moof"])[0],p=Pt.findBox(this.buffer,["sidx"])[0],h&&h.size<=h.data.length&&p&&(v=Pt.moof(h),f=Pt.sidx(p),v&&f&&(d=Yt(l,f)))),this.meta=Jt(l,f),y=(m=d).videoSegments,g=m.audioSegments,this.videoSegments=y,this.audioSegments=g,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:y,audioSegments:g,responses:a});case 44:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Qt(e.moov,this._config.segmentDuration),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(h=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"preload",value:(f=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length>0&&void 0!==t[0]&&t[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i,a){var s,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this._getCacheKey(n),e.next=3,this.cache.get(s);case 3:if(o=e.sent){e.next=11;break}return c=a&&a.url?a.url:this.url,e.next=8,this._loader.load(c,t({range:n,vid:this.vid},a));case 8:u=e.sent,e.next=12;break;case 11:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 12:if(u){e.next=14;break}return e.abrupt("return");case 14:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(A);return $t}));
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|