@volcengine/veplayer 1.14.2-rc.0 → 1.14.2-rc.1

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/plugin/flv.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.concat.js"),require("xgplayer"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.object.to-string.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.slice.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.regexp.exec.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.regexp.test.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.typed-array.int8-array.js"),require("core-js/modules/es.typed-array.uint8-clamped-array.js"),require("core-js/modules/es.typed-array.int16-array.js"),require("core-js/modules/es.typed-array.uint16-array.js"),require("core-js/modules/es.typed-array.int32-array.js"),require("core-js/modules/es.typed-array.uint32-array.js"),require("core-js/modules/es.typed-array.float32-array.js"),require("core-js/modules/es.typed-array.float64-array.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","xgplayer","core-js/modules/es.object.assign.js","core-js/modules/es.object.to-string.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.slice.js","core-js/modules/es.array.splice.js","core-js/modules/es.regexp.exec.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.regexp.test.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.find.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.int16-array.js","core-js/modules/es.typed-array.uint16-array.js","core-js/modules/es.typed-array.int32-array.js","core-js/modules/es.typed-array.uint32-array.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.float64-array.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).FlvPlayer=t(null,e.Player)}(this,(function(e,t){"use strict";function r(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 n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(){i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.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(D){c=function(e,t,r){return e[t]=r}}function l(e,t,r,i){var s=t&&t.prototype instanceof f?t:f,a=Object.create(s.prototype),o=new j(i||[]);return n(a,"_invoke",{value:x(e,r,o)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(D){return{type:"throw",arg:D}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,_=m&&m(m(T([])));_&&_!==t&&r.call(_,a)&&(y=_);var g=v.prototype=f.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,s,a,o){var u=d(e[n],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,o)}),(function(e){i("throw",e,a,o)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,o)}))}o(u.arg)}var s;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return s=s?s.then(n,n):n()}})}function x(e,t,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return{value:void 0,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var o=w(a,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function 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")),h;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var a=new k(l(t,r,n,i),s);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=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)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.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 s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function s(e){return(s="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 a(e,t,r,n,i,s,a){try{var o=e[s](a),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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,A(n.key),n)}}function l(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=A(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(){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 y(e,t,r){return(y=v()?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&&p(i,r.prototype),i}).apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=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 y(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,e)},m(e)}function _(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(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 g(e)}function k(e){var t=v();return function(){var r,n=f(e);if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return b(this,r)}}function x(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}function w(){return w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=x(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},w.apply(this,arguments)}function S(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,s,a,o=[],u=!0,c=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=s.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&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}(e,t)||j(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 E(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(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 j(e,t){if(e){if("string"==typeof e)return T(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)?T(e,t):void 0}}function T(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 A(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)}function D(){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 O(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var L,C=function(){function e(){u(this,e)}return l(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var s=r.length;if(s&&t){var a=r[s-1],o=a[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(a[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,s=0,a=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],s=p[1],a=h;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:s,index:a,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:s?s-r:0,length:e.totalLength&&e.totalLength(d)}}}]),e}(),R="network",B="network_timeout",P="network_forbidden",U="network_notfound",M="network_range_not_satisfiable",I="demux",F="remux",N="media",q="drm",V="other",z="runtime",G={FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"},H=(d(L={},"manifest",{HLS:1100,DASH:1200}),d(L,R,2100),d(L,B,2101),d(L,P,2103),d(L,U,2104),d(L,M,2116),d(L,I,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),d(L,F,{FMP4:4100,MP4:4200}),d(L,N,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,EME_HIJACK:5301}),d(L,q,{LICENSE:7100,CUSTOM_LICENSE:7200}),d(L,V,8e3),d(L,z,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),L),K=function(e){h(r,e);var t=k(r);function r(e,n,i,s,a){var o;return u(this,r),(o=t.call(this,a||(null==i?void 0:i.message))).errorType=e===B?R:e,o.originError=i,o.ext=s,o.errorCode=H[e][n]||H[e],o.errorMessage=o.message,o.errorCode||(o.errorType=V,o.errorCode=H[o.errorType]),o}return l(r,null,[{key:"create",value:function(e,t,n,i,s){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=V),new r(e,t,n,i,s))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?B:R,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}(m(Error)),W="undefined"!=typeof window,Q={DEBUG:1,LOG:2,WARN:3,ERROR:4},Y=["Boolean","Number","String","Undefined","Null","Date","Object"],X=function(){function e(t,r){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return l(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[Q.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,[this._prefix,J()].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,[Q.LOG].concat(n)),e.disabled||(t=console).log.apply(t,[this._prefix,J()].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,[Q.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,[this._prefix,J()].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,[Q.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,[this._prefix,J()].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 s=n.map((function(e){return $(e)}));t=this._prefix+J()+JSON.stringify(s)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var a=this.logTextArray.shift();this.logSize-=a.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 J(){return(new Date).toLocaleString()}function Z(e){if("object"!==s(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 $(e,t,r){r||(r=1),t||(t=2);var n={};if(!e||"object"!==s(e))return e;var i=Object.prototype.toString.call(e).slice(8,-1);if(!Y.includes(i))return i;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?n[a]=Z(e[a]):"object"===s(e[a])?n[a]=$(e[a],t,r+1):n[a]=e[a]);return n}}d(X,"disabled",!0);var ee=function(){try{return W?window.MediaSource:null}catch(e){}}(),te="appendBuffer",re="removeBuffer",ne="updateDuration",ie=function(){function e(t,r){var n=this;u(this,e),d(this,"media",null),d(this,"mediaSource",null),d(this,"_openPromise",D()),d(this,"_queue",Object.create(null)),d(this,"_sourceBuffer",Object.create(null)),d(this,"_mseFullFlag",{}),d(this,"_st",0),d(this,"_opst",0),d(this,"_logger",null),d(this,"_config",null),d(this,"_url",null),d(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=O()-n._opst;n._logger.debug("UpdateEnd",r.opName,i,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:i}),n._startQueue(e)}}})),d(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 K(N,G.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new X("MSE"),this._config.openLog&&X.enable()}var t,r,n;return l(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"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:"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("[debug mse] setDuration ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("[debug mse] setDuration"))}),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=O()-e._st;e._logger.debug("MSE OPEN",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=D()}return this._openPromise}},{key:"bindMedia",value:(n=o(i().mark((function e(t){var r,n,s=this;return i().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(t&&ee){e.next=5;break}throw new Error("Param media or MediaSource does not exist");case 5:return this.media=t,r=this.mediaSource=new ee,this._st=O(),n=function e(){var n=O()-s._st;s._logger.debug("MSE OPEN"),r.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:n})},r.addEventListener("sourceopen",n),this._url=URL.createObjectURL(r),t.src=this._url,e.abrupt("return",this._openPromise);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unbindMedia",value:(r=o(i().mark((function e(){var t,r,n,s=this;return i().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=s._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,n="open"===t.readyState,r&&n)try{t.endOfStream()}catch(i){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(s._sourceBuffer[e])}catch(i){}}))}if(this.media){this.media.removeAttribute("src");try{this.media.load()}catch(i){}this.media=null}this.mediaSource=null,this._openPromise=D(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new K(N,G.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():this._enqueueOp(e,(function(){n.changeType(t),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=O(),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,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var s=i._sourceBuffer[e];t>=r||!s?i._onSBUpdateEnd(e):(i._opst=O(),i._logger.debug("MSE REMOVE START",e,t,r,n),s.remove(t,r))}}),re,n,s)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n._enqueueOp(i,(function(){if(n.mediaSource&&!n.media.error){var r=n._sourceBuffer[i];n._logger.debug("MSE clearBuffer START",i,e,t),r.remove(e,t)}}),re)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){e=t._enqueueOp(r,(function(){if(t.mediaSource&&!t.media.error){var e=t._sourceBuffer[r];t._logger.debug("MSE clearAllBuffer START",r),e.remove(0,C.end(C.get(e)))}}))})),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 s=this;if(!this.mediaSource)return Promise.resolve();var a=this._queue[e]=this._queue[e]||[],o={exec:t,promise:D(),opName:r,context:n};return i?(a.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):a.push(o),this.isOpened||this.isEnded?1===a.length&&this._startQueue(e):this._openPromise.then((function(){1===a.length&&s._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=o(i().mark((function e(t,r,n){var s,a,o=this;return i().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((s=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],s.forEach((function(e){var t=o._queue[e],i=D();a.push(i),t.push({exec:function(){i.resolve()},promise:i,opName:r,context:n}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{s.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(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new K(N,G.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new K(N,G.MSE_OTHER,n)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var n=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"getDefaultConfig",value:function(){return{openLog:!1}}},{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if(!ee)return!1;try{return ee.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}}]),e}();d(ie,"VIDEO","video"),d(ie,"AUDIO","audio");var se="fetch",ae="xhr",oe="arraybuffer",ue="text",ce="json",le=function(e){h(r,e);var t=k(r);function r(e,n,i,s){var a;return u(this,r),d(g(a=t.call(this,s)),"retryCount",0),d(g(a),"isTimeout",!1),d(g(a),"loaderType",se),d(g(a),"startTime",0),d(g(a),"endTime",0),d(g(a),"options",{}),a.url=e,a.request=n,a.response=i,a}return l(r)}(m(Error)),de=Object.prototype.toString;function he(e){if("[object Object]"!==de.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function fe(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,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===de.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===s(e)}(t)&&(t=JSON.stringify(t)),"".concat(pe(e),"=").concat(pe(t))})).join("&")})).filter(Boolean).join("&");if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function ye(e,t,r,n,i,s,a,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:s,firstByteTime:a,endTime:Date.now(),priOptions:l},response:r}}function me(e,t){return Math.round(8*e*1e3/t/1024)}var _e="error",ge="core.ttfb",be="core.loadstart",ke="core.loadresponseheaders",xe="core.loadcomplete",we="core.loadretry",Se="core.sourcebuffercreated",Ee="core.analyzedurationexceeded",je="core.removebuffer",Te="core.buffereos",Ae="core.keyframe",De="core.metadataparsed",Oe="core.sei",Le="core.seiintime",Ce="core.flvscriptdata",Re="core.lowdecode",Be="core.switchurlsuccess",Pe="core.switchurlfailed",Ue="core.demuxedtrack",Me="core.streamexception",Ie="LARGE_AV_FIRST_FRAME_GAP_DETECT",Fe="LARGE_VIDEO_DTS_GAP_DETECT",Ne="LARGE_AUDIO_DTS_GAP_DETECT",qe="AUDIO_GAP_DETECT",Ve="AUDIO_OVERLAP_DETECT",ze="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",Ge="real_time_speed",He={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 s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||e,a),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 a(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,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a},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,s,a){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,s),!0;case 6:return l.fn.call(l.context,t,n,i,s,a),!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 h,f=l.length;for(c=0;c<f;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(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||a(this,s);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[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(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}(He);var Ke=He.exports,We=2097152,Qe=function(e){h(n,e);var t,r=k(n);function n(){var e;return u(this,n),d(g(e=r.call(this)),"_abortController",null),d(g(e),"_timeoutTimer",null),d(g(e),"_reader",null),d(g(e),"_response",null),d(g(e),"_aborted",!1),d(g(e),"_index",-1),d(g(e),"_range",null),d(g(e),"_receivedLength",0),d(g(e),"_running",!1),d(g(e),"_logger",null),d(g(e),"_vid",""),d(g(e),"_onProcessMinLen",0),d(g(e),"_onCancel",null),d(g(e),"_priOptions",null),e}return l(n,[{key:"load",value:function(e){var t,r=this,n=e.url,s=e.vid,a=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,h=e.onCancel,f=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,_=e.method,g=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,A=e.priOptions;this._logger=m,this._aborted=!1,this._onProcessMinLen=T,this._onCancel=h,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=l,this._range=f||[0,0],this._vid=s||n,this._priOptions=A||{};var D={method:_,headers:g,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},O=!1;clearTimeout(this._timeoutTimer),n=ve(n,y);var L=fe(f);L&&(g=v?v.headers:D.headers=D.headers||(Headers?new Headers:{}),Headers&&g instanceof Headers?g.append("Range",L):g.Range=L),a&&(this._timeoutTimer=setTimeout((function(){if(O=!0,r.cancel(),d){var e=new le(n,D,null,"timeout");e.isTimeout=!0,d(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var C=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",f),new Promise((function(e,t){fetch(v||n,v?void 0:D).then(function(){var s=o(i().mark((function s(a){var o,d,h,v;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){i.next=4;break}return i.abrupt("return");case 4:if(p&&(a=p(a,n)||a),a.ok){i.next=7;break}throw new le(n,D,a,"bad network response");case 7:if(o=Date.now(),u!==ue){i.next=15;break}return i.next=11,a.text();case 11:d=i.sent,r._running=!1,i.next=37;break;case 15:if(u!==ce){i.next=22;break}return i.next=18,a.json();case 18:d=i.sent,r._running=!1,i.next=37;break;case 22:if(!c){i.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,c,C,o),i.abrupt("return");case 29:return i.next=31,a.arrayBuffer();case 31:d=i.sent,d=new Uint8Array(d),r._running=!1,h=Date.now()-C,v=me(d.byteLength,h),r.emit(Ge,{speed:v,len:d.byteLength,time:h,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",l,",range,",f),e(ye(d,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),C,o,l,f,r._vid,r._priOptions));case 39:case"end":return i.stop()}}),s)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var i;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!O||((e=e instanceof le?e:new le(n,D,null,null===(i=e)||void 0===i?void 0:i.message)).startTime=C,e.endTime=Date.now(),e.isTimeout=O,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(t=o(i().mark((function e(){return i().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,r,n){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new le(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(We),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),h=function(){var a=o(i().mark((function a(){var o,f,p,v,y,m,_,g;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return c=Date.now(),i.prev=1,i.next=4,d.read();case 4:u=i.sent,l=Date.now(),i.next=13;break;case 8:return i.prev=8,i.t0=i.catch(1),l=Date.now(),s._aborted||(s._running=!1,i.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(i.t0)),i.abrupt("return");case 13:if(f=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=f+s._receivedLength,!s._aborted){i.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:r,firstByteTime:n,priOptions:s._priOptions},e),i.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,",f+s._receivedLength,", done,",u.done),s._onProcessMinLen>0?s._writeIdx+v>=s._onProcessMinLen||u.done?((y=new Uint8Array(s._writeIdx+v)).set(s._cache.slice(0,s._writeIdx),0),v>0&&y.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",y.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&&(m=new Uint8Array(s._writeIdx+v+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+v+2048,", datalen,",v,", writeIdx,",s._writeIdx),m.set(s._cache.slice(0,s._writeIdx),0),v>0&&m.set(u.value,s._writeIdx),s._writeIdx+=v,delete s._cache,s._cache=m,s._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",s._writeIdx)):y=u.value,(y&&y.byteLength>0||u.done)&&t(y,u.done,{range:[s._range[0]+s._receivedLength-(y?y.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:r,firstByteTime:n,priOptions:s._priOptions},e),u.done?(_=Date.now()-r,g=me(s._receivedLength,_),s.emit(Ge,{speed:g,len:s._receivedLength,time:_,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(ye(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,n,s._index,s._range,s._vid,s._priOptions))):h();case 25:case"end":return i.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();h()}},{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)}}]),n}(Ke);var Ye=function(e){h(r,e);var t=k(r);function r(){var e;return u(this,r),d(g(e=t.call(this)),"_xhr",null),d(g(e),"_aborted",!1),d(g(e),"_timeoutTimer",null),d(g(e),"_range",null),d(g(e),"_receivedLength",0),d(g(e),"_url",null),d(g(e),"_onProgress",null),d(g(e),"_index",-1),d(g(e),"_headers",null),d(g(e),"_currentChunkSizeKB",384),d(g(e),"_timeout",null),d(g(e),"_xhr",null),d(g(e),"_withCredentials",null),d(g(e),"_startTime",-1),d(g(e),"_loadCompleteResolve",null),d(g(e),"_loadCompleteReject",null),d(g(e),"_runing",!1),d(g(e),"_logger",!1),d(g(e),"_vid",""),d(g(e),"_responseType",void 0),d(g(e),"_credentials",void 0),d(g(e),"_method",void 0),d(g(e),"_transformResponse",void 0),d(g(e),"_firstRtt",void 0),d(g(e),"_onCancel",null),d(g(e),"_priOptions",null),e}return l(r,[{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 s=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));s.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(s)},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=fe(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(s){s.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var i=new le(this._url,null,n(n({},e.target.response),{},{status:r}),"bad response,status:"+r);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var s,a=null,o=!1,u=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===oe){var c,l=new Uint8Array(e.target.response);if(s=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=me(this._receivedLength,d);this.emit(Ge,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[s,u+this._receivedLength],priOptions:this._priOptions})}a=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",s,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,a=e.target.response;var f={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(a,o,{index:this._index,vid:this._vid,range:[s,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(ye(this._onProgress?null:a,o,f,f.headers["content-length"],f.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,w(f(r.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=j(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 s,a=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}(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(s){n.e(s)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),r}(Ke),Xe=["retry","retryDelay","onRetryError","transformError"],Je=function(){function e(t,r){u(this,e),this.promise=D(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new X("Loader")),this._loaderType=t,this._loader=t===se&&window.fetch?new Qe:new Ye,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return l(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,s=t.onRetryError,a=t.transformError,u=_(t,Xe),c=function(){var t=o(i().mark((function t(){var o,l,d;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:o=t.sent,e.promise.resolve(o),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,a&&(l=a(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<=r)){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,n),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=o(i().mark((function e(){return i().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 Ze(){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 $e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var et=function(e){h(s,e);var t,r=k(s);function s(e){var t;return u(this,s),d(g(t=r.call(this,e)),"type",se),d(g(t),"_queue",[]),d(g(t),"_alive",[]),d(g(t),"_currentTask",null),d(g(t),"_finnalUrl",""),d(g(t),"_config",void 0),t._config=function(e){return n({loaderType:se,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),t._config.loaderType!==ae&&Qe.isSupported()||(t.type=ae),t.log=e.logger,t}return l(s,[{key:"isFetch",value:function(){return this.type===se}},{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&&he(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&he(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Je(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:(t=o(i().mark((function e(){var t;return i().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,$e();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.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 Qe.isSupported()}}]),s}(Ke),tt=function(){function e(){u(this,e),d(this,"_prevCurrentTime",0)}return l(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var i=e.currentTime,s=0;if(this._prevCurrentTime===i){var a=C.info(C.get(e),i);if(!a.buffers.length)return;r&&a.nextStart||a.nextStart&&a.nextStart-i<t?s=a.nextStart+.1:a.end&&a.end-i>n&&!e.seeking&&(s=i+.1)}this._prevCurrentTime=i,s&&i!==s&&(e.currentTime=s)}}}]),e}(),rt=function(){function e(t){var r=this;u(this,e),d(this,"_seiSet",new Set),this.emitter=t,t.on(Oe,(function(e){e&&r._seiSet.add(e)}))}return l(e,[{key:"throw",value:function(e){var t=this;if(null!=e&&this._seiSet.size){var r=e-.2,n=e+.2,i=[];this._seiSet.forEach((function(e){e.time>=r&&e.time<=n&&i.push(e)})),i.forEach((function(e){t._seiSet.delete(e),t.emitter.emit(Le,e)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),nt=function(){function e(){u(this,e),d(this,"_chunkSpeeds",[]),d(this,"_speeds",[])}return l(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){e&&t&&(this._chunkSpeeds.push(8e3*e/t),this._chunkSpeeds=this._chunkSpeeds.slice(-100))}},{key:"getAvgSpeed",value:function(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length:this._chunkSpeeds.reduce((function(e,t){return e+t}))/this._chunkSpeeds.length:0}},{key:"getLatestSpeed",value:function(){return this._chunkSpeeds.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeeds[this._chunkSpeeds.length-1]:0}},{key:"reset",value:function(){this._chunkSpeeds=[],this._speeds=[]}}]),e}(),it=function(){function e(t){u(this,e),d(this,"encodeType",""),d(this,"audioCodec",""),d(this,"videoCodec",""),d(this,"domain",""),d(this,"fps",0),d(this,"bitrate",0),d(this,"width",0),d(this,"height",0),d(this,"samplerate",0),d(this,"channelCount",0),d(this,"gop",0),d(this,"_bitsAccumulateSize",0),d(this,"_bitsAccumulateDuration",0),this._timescale=t}return l(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,n=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;n&&n>0&&n<100&&(this.fps=n)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){1===e.gopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),st=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;u(this,e),d(this,"_core",null),d(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new it(r),this._bindEvents()}return l(e,[{key:"getStats",value:function(){var e,t,r,i,s,a,o,u=(null===(e=this._core)||void 0===e?void 0:e.media)||{},c=u.currentTime,l=void 0===c?0:c,d=u.decodeFps,h=void 0===d?0:d;return n(n({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(i=this._core)||void 0===i||null===(s=i.speedInfo)||void 0===s?void 0:s.call(i).avgSpeed)||0,currentTime:l,bufferEnd:(null===(a=this._core)||void 0===a||null===(o=a.bufferInfo())||void 0===o?void 0:o.remaining)||0,decodeFps:h})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(Ue,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Ce,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(De,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(ge,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new it(this._timescale)}}]),e}(),at="video",ot="audio",ut="metadata",ct="avc",lt="hevc",dt="aac",ht="g7110a",ft="g7110m",pt="LARGE_AV_SHIFT",vt="LARGE_VIDEO_GAP",yt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",mt="LARGE_AUDIO_GAP",_t="AUDIO_FILLED",gt="AUDIO_DROPPED",bt=function(){function e(){u(this,e),d(this,"id",1),d(this,"type",at),d(this,"codecType",ct),d(this,"pid",-1),d(this,"hvcC",void 0),d(this,"codec",""),d(this,"timescale",0),d(this,"formatTimescale",0),d(this,"sequenceNumber",0),d(this,"baseMediaDecodeTime",0),d(this,"baseDts",0),d(this,"duration",0),d(this,"warnings",[]),d(this,"samples",[]),d(this,"pps",[]),d(this,"sps",[]),d(this,"vps",[]),d(this,"fpsNum",0),d(this,"fpsDen",0),d(this,"sarRatio",[]),d(this,"width",0),d(this,"height",0),d(this,"nalUnitSize",4),d(this,"present",!1),d(this,"isVideoEncryption",!1),d(this,"isAudioEncryption",!1),d(this,"isVideo",!0),d(this,"kid",null),d(this,"pssh",null),d(this,"ext",void 0)}return l(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:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),kt=function(){function e(){u(this,e),d(this,"id",2),d(this,"type",ot),d(this,"codecType",dt),d(this,"pid",-1),d(this,"codec",""),d(this,"sequenceNumber",0),d(this,"sampleDuration",0),d(this,"timescale",0),d(this,"formatTimescale",0),d(this,"baseMediaDecodeTime",0),d(this,"duration",0),d(this,"warnings",[]),d(this,"samples",[]),d(this,"baseDts",0),d(this,"sampleSize",16),d(this,"sampleRate",0),d(this,"channelCount",0),d(this,"objectType",0),d(this,"sampleRateIndex",0),d(this,"config",[]),d(this,"present",!1),d(this,"isVideoEncryption",!1),d(this,"isAudioEncryption",!1),d(this,"kid",null),d(this,"ext",void 0)}return l(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===dt)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),e}(),xt=function(){function e(t,r,n){u(this,e),d(this,"flag",{}),d(this,"keyframe",!1),d(this,"gopId",0),d(this,"duration",0),d(this,"size",0),d(this,"units",[]),d(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return l(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}(),wt=l((function e(t,r,n,i){u(this,e),d(this,"duration",1024),d(this,"flag",{dependsOn:2,isNonSyncSample:0}),d(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),St=l((function e(t,r){u(this,e),d(this,"time",0),this.data=t,this.originPts=this.pts=r})),Et=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(St),jt=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(St),Tt=function(){function e(){u(this,e),d(this,"id",3),d(this,"type",ut),d(this,"timescale",0),d(this,"flvScriptSamples",[]),d(this,"seiSamples",[])}return l(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}(),At=function(){function e(t){if(u(this,e),d(this,"_bytesAvailable",void 0),d(this,"_bitsAvailable",0),d(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return l(e,[{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}(),Dt=function(){function e(t){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return l(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}();d(Dt,"disabled",!0);var Ot=function(){function e(){u(this,e)}return l(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,s=t.length;i<s;)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 a=(31&n[i])<<6|63&n[i+1];if(a>=128){r.push(String.fromCharCode(65535&a)),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}(),Lt="undefined"!=typeof window,Ct=Lt&&navigator.userAgent.toLocaleLowerCase(),Rt=Lt&&/^((?!chrome|android).)*safari/.test(Ct),Bt=Lt&&Ct.includes("firefox"),Pt=Lt&&Ct.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}function Mt(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 It(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 Ft(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)}))}var Nt=function(){function e(){u(this,e)}return l(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((n=++r+2)>=t)return[];for(var i=[];n<t;)switch(e[n]){case 0:if(0!==e[n-1]){n+=2;break}if(0!==e[n-2]){n++;break}r!==n-2&&i.push(e.subarray(r,n-2));do{n++}while(1!==e[n]&&n<t);n=(r=n+1)+2;break;case 1:if(0!==e[n-1]||0!==e[n-2]){n+=3;break}r!==n-2&&i.push(e.subarray(r,n-2)),n=(r=n+1)+2;break;default:n+=3}return r<t&&i.push(e.subarray(r)),i}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,n=e.length,i=[],s=0;s+t<n;)if(r=Mt(e,s),3===t&&(r>>>=8),s+=t,r){if(s+r>n)break;i.push(e.subarray(s,s+r)),s+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,s=0,a="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)s+=255,n++;if(s+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)a+=e[n].toString(16),n++;return{payload:e.subarray(n),type:i,size:s,uuid:a}}},{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,s=new Uint8Array(i),a=0;for(n=0;n<i;a++,n++)a===r[0]&&(a++,r.shift()),s[n]=e[a];return s}}]),e}(),qt=function(){function e(){u(this,e)}return l(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),s=[],a=[],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,s.push(l),r||(r=e.parseSPS(Nt.removeEPB(l)))}var d,h=t[o];o++;for(var f=0;f<h;f++)d=t[o]<<8|t[o+1],o+=2,d&&(a.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:s,ppsArr:a,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new At(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var s=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 a=t.readUEG();if(a<=3&&(s=[0,420,422,444][a]),3===a&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==a?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 h=t.readUEG(),f=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,y,m,_,g,b=0,k=0,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);y=t.readBool(),g=(m=E)/(_=2*S)}}return{codec:It(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:s,width:Math.ceil(16*(h+1)-2*(b+k)),height:(2-p)*(f+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:m,fpsDen:_,fps:g,fixedFrame:y}}}]),e}(),Vt=function(){function e(){u(this,e)}return l(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 s=i,a=[],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),h=(1&t[i+2])<<2|(192&t[i+3])>>>6,f=e._getConfig(o,h,d),p=f.config,v=f.codec,y=0,m=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(n-i<(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5))break;c=2*(1&~t[i+1]),a.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:s,remaining:i>=n?void 0:t.subarray(i),frames:a,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:h,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,s=e.FREQ[n];if(s){var a=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:s,objectType:r,channelCount:i,config:a.config,codec:a.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,s=[];return Bt?e>=6?(n=5,i=e-3):(n=2,i=e):Pt?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),s[0]=n<<3,s[0]|=(14&e)>>1,s[1]=(1&e)<<7,s[1]|=t<<3,5===n&&(s[1]|=(14&i)>>1,s[2]=(1&i)<<7,s[2]|=8,s[3]=0),{config:s,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}();d(Vt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var zt=function(){function e(){u(this,e)}return l(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,s,a,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){s=63&t[h],a=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<a;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(s){case 32:var y=t.subarray(h,h+o);n||(n=e.parseVPS(Nt.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(h,h+o);i||(i=e.parseSPS(Nt.removeEPB(m),r)),c.push(m);break;case 34:l.push(t.subarray(h,h+o))}h+=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 At(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 At(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 s=r.chromaFormatIdc=n.readUEG(),a=420;s<=3&&(a=[0,420,422,444][s]);var o=0;3===s&&(o=n.readBits(1));var u,c,l,d,h=n.readUEG(),f=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!==s&&2!==s||0!==o?1:2,y=1===s&&0===o?2:1;h-=v*(c+u),f-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:a,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);for(var s=[],a=[],o=0;o<t;o++)s[o]=e.readBits(1),a[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==s[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!==a[u]&&e.readBits(8)}}]),e}(),Gt=1e3,Ht=5e3,Kt=function(){function e(t,r,n){u(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 l(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,s=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(s,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var a=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(a&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),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),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.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],s=e.samples[r.length-1];n=Math.floor((s.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var a=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=a,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 h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:yt,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(h=r[1])||void 0===h?void 0:h.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 f=0;f<u;f++){var p=r[f].dts,v=r[f+1];((c=f<u-1?v.dts-p:a?a.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:vt,time:p/e.timescale,dts:p,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[f].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,s=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=s=n[0].dts),this._baseDts=Math.min(i,s);var a=s-i;return Number.isFinite(a)&&Math.abs(a)>500&&t.warnings.push({type:pt,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),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){e.sampleDuration||(e.sampleDuration=e.codecType===dt?Vt.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===dt?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var s=t[0];this._audioNextPts=s.pts}for(var a=0;a<t.length;a++){var o=this._audioNextPts,u=t[a],c=u.pts-o;if(0===a&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=Gt&&!Rt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Ht&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:_t,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new wt(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(a,0,f),this._audioNextPts+=n,a++}a--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Ht&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:gt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(a,1),a--):(Math.abs(c)>Gt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Ht&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:mt,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),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===dt?Vt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),Wt=function(){function e(){u(this,e)}return l(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,s=!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 a=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=a.data,i+=a.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 h=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),f=h.size,p=h.data;if(h.isEnd)break;r[p.name]=p.value,i+=f}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,s=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),_=m.data,g=m.size;r.push(_),i+=g}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=Ot.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Ot.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}(),Qt=new Dt("FlvDemuxer"),Yt=function(){function e(t,r,n){u(this,e),d(this,"_headerParsed",!1),d(this,"_remainingData",null),d(this,"_gopId",0),d(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new bt,this.audioTrack=r||new kt,this.metadataTrack=n||new Tt,this._fixer=new Kt(this.videoTrack,this.audioTrack,this.metadataTrack)}return l(e,[{key:"demux",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.audioTrack,s=this.videoTrack,a=this.metadataTrack;if(!r&&n||(this._remainingData=null,this._headerParsed=!1),r?(s.reset(),i.reset(),a.reset()):(s.samples=[],i.samples=[],a.seiSamples=[],a.flvScriptSamples=[],s.warnings=[],i.warnings=[],this._remainingData&&(t=Ut(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:s,audioTrack:i,metadataTrack:a};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");i.present=(4&t[4])>>>2!=0,s.present=0!=(1&t[4]),this._headerParsed=!0,o=Mt(t,5)+4}for(var u,c,l,d,h,f=t.length;o+15<f&&(u=t[o],!(o+15+(c=t[o+1]<<16|t[o+2]<<8|t[o+3])>f));)l=(t[o+7]<<24>>>0)+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6],o+=11,d=t.subarray(o,o+c),8===u?this._parseAudio(d,l):9===u?this._parseVideo(d,l):18===u?this._parseScript(d,l):Qt.warn("Invalid tag type: ".concat(u)),(h=Mt(t,o+=c))!==11+c&&Qt.warn("Invalid PrevTagSize ".concat(h," (").concat(11+c,")")),o+=4;return o<f&&(this._remainingData=t.subarray(o)),i.formatTimescale=s.formatTimescale=s.timescale=a.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!s.exist()&&s.hasSample()&&s.reset(),{videoTrack:s,audioTrack:i,metadataTrack:a}}},{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){return this.demux(e,t,r),this.fix(n,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(10!==n&&7!==n&&8!==n)return Qt.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n){var s=(12&t[0])>>2,a=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[s],i.sampleSize=a?16:8,i.channelCount=o+1}10===n?this._parseAac(t,r):this._parseG711(t,r,n)}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack;n.codecType=7===r?ht:ft,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new wt(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=dt,0===e[1]){var n=Vt.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(),Qt.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new wt(t,e.subarray(2)))}else Qt.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],s=this.videoTrack;if(7!==i&&12!==i)return s.reset(),void Qt.warn("Unsupported codecId: ".concat(i));var a=12===i;s.codecType=a?lt:ct;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=a?zt.parseHEVCDecoderConfigurationRecord(c):qt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(s.hvcC=s.hvcC||d),h&&(s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen),p.length&&(s.sps=p),f.length&&(s.pps=f),v&&v.length&&(s.vps=v),y&&(s.nalUnitSize=y)}else Qt.warn("Cannot parse ".concat(a?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Nt.parseAvcC(e.subarray(5),s.nalUnitSize);if((m=this._checkAddMetaNalToUnits(a,m,s))&&m.length){var _=new xt(t+u,t,m);1===n&&_.setToKeyframe(),s.samples.push(_),m.forEach((function(e){var n=a?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(!a&&5!==n||a&&5===n)break;_.setToKeyframe();break;case 6:case 39:case 40:if(!a&&6!==n||a&&6===n)break;r.metadataTrack.seiSamples.push(new jt(Nt.parseSEI(Nt.removeEPB(e),a),t+u))}})),_.keyframe&&this._gopId++,_.gopId=this._gopId}else Qt.warn("Cannot parse NALUs",e)}else 2===o||Qt.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 Et(Wt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Mt(e,5)>=9}}]),e}();function Xt(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 s=new e(t),a=0;return n.forEach((function(e){s.set(e,a),a+=e.length})),s}d(Yt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Dt("TsDemuxer");var Jt=function(){function e(){u(this,e),this.buffer=new Uint8Array(0)}return l(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=Xt(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}(),Zt=Math.pow(2,32)-1,$t=function(){function e(){u(this,e)}return l(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),s=new Uint8Array(i);s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4);var a=8;return r.forEach((function(e){s.set(e,a),a+=e.byteLength})),s}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===at&&e.codecType===lt}))?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],Ft(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(E(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(E(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,s=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 s}},{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===at?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):e.mp4a(t):t.useEME&&t.encv?e.encv(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]),s=e.esds(t.config),a=e.sinf(t.enca);return e.box(e.types.enca,i,s,a)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],s=t.pps.length>0?t.pps[0]:[],a=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,a>>8&255,255&a,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,E(i)).concat([1,s.length>>>8&255,255&s.length])).concat.apply(r,E(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),p=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c]);return e.box(e.types.encv,l,e.box(e.types.avcC,d),e.box(e.types.btrt,h),f,e.box(e.types.pasp,p))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Ft(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]),s=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),s)}},{key:"avc1hev1",value:function(t){var r=t.codecType===lt,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),s=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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?s.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&s.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(s))}},{key:"avcC",value:function(t){var r,n,i,s=[],a=[];return t.sps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,E(e))})),t.pps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,E(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,s[3],s[4],s[5],255,224|t.sps.length]).concat.apply(n,s).concat([t.pps.length])).concat.apply(r,a)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,s=t.sps,a=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(s.length&&1)+(a.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,E(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),s.length&&(n.push(161,0,s.length),s.forEach(l)),a.length&&(n.push(162,0,a.length),a.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=S(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:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(E(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(E(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 s=e.saiz(t),a=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,s,a,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),h=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,h,f)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var y=e.trun1(t);return e.box(e.types.traf,r,n,y)}var m=e.sbgp(),_=e.saiz(t),g=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,m,_,g,b,k)}var 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 Jt;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 Jt,n=Jt.writeUint32(t.samples.length),i=null;if(t.isVideo){var s=t.videoSencLength;i=Jt.writeUint32(16*t.samples.length+s+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Jt.writeUint32(16*t.samples.length+92))}else{var a=12*t.samples.length+124;t.isAudioEncryption&&(a=12*t.samples.length+8*t.audioSenc.length+177),i=Jt.writeUint32(a)}return t.samples.forEach((function(e){r.write(Jt.writeUint32(e.duration)),r.write(Jt.writeUint32(e.size)),r.write(Jt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Jt.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 Jt,n=t.samples.length,i=t.isVideo?16:8,s=t.isVideo?2:0,a=[],o=0;return t.isVideo?(a=t.videoSenc,o=t.videoSencLength):a=t.audioSenc,o=o||i*n,r.write(Jt.writeUint32(16+o),e.types.senc,this.extension(0,s)),r.write(Jt.writeUint32(n)),a.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(Jt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Jt.writeUint16(e.BytesOfClearData)),r.write(Jt.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/(Zt+1)),i=Math.floor(r%(Zt+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 s=new Uint8Array(i);s.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 a=0;a<n;a++){var o=t[a],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;s.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,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*a)}return e.box(e.types.trun,s)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(E(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===at?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,s=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s],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,s=t.samples[0].sampleOffset*n,a=8;t.samples.forEach((function(e){a+=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=a+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=a+16*t.samples.length+84)}else o=a+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=a+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,s>>24&255,s>>16&255,s>>8&255,255&s,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}();d($t,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),d($t,"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])}),d($t,"FTYPAVC1",$t.box($t.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),d($t,"FTYPHEV1",$t.box($t.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),d($t,"DINF",$t.box($t.types.dinf,$t.box($t.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),d($t,"VMHD",$t.box($t.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),d($t,"SMHD",$t.box($t.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),d($t,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),d($t,"STTS",$t.box($t.types.stts,$t.StblTable)),d($t,"STSC",$t.box($t.types.stsc,$t.StblTable)),d($t,"STSZ",$t.box($t.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),d($t,"STCO",$t.box($t.types.stco,$t.StblTable));var er=function(){function e(t,r){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return l(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}();d(er,"disabled",!0);for(var tr=function(){function e(t,r,n){u(this,e),this.videoTrack=t,this.audioTrack=r;var i=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=i&&Number(i[1])<50,this.log=new er("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return l(e,[{key:"remux",value:function(){var e,t,r,n,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,c=o.exist(),l=u.exist(),d=[];return s&&(a&&a.initMerge?(c&&d.push(this.videoTrack),l&&d.push(this.audioTrack),r=$t.initSegment(d)):(c&&(e=$t.initSegment([this.videoTrack])),l&&(t=$t.initSegment([this.audioTrack])))),c&&o.hasSample()&&(n=this._remuxVideo()),l&&u.hasSample()&&(i=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:i}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=0;t.forEach((function(e){r+=e.units.reduce((function(e,t){return e+t.byteLength}),0),r+=4*e.units.length}));for(var n,i=new Uint8Array(r),s=new DataView(i.buffer),a=function(e,r){r=t[o];var a=0;r.units.forEach((function(t){s.setUint32(e,t.byteLength),e+=4,i.set(t,e),e+=t.byteLength,a+=4+t.byteLength})),r.size=a,c=e,n=r},o=0,u=t.length,c=0;o<u;o++)a(c,n);var l=$t.mdat(i);return Ut($t.moof([e]),l)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=$t.mdat(t);return Ut($t.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),rr=function(){function e(){u(this,e)}return l(e,[{key:"mixIn",value:function(e){return Object.assign(this,e)}},{key:"clone",value:function(){var e=new this.constructor;return Object.assign(e,this),e}}],[{key:"create",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return y(this,t)}}]),e}(),nr=function(e){h(r,e);var t=k(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4*n.length;u(this,r),e=t.call(this);var s=n;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),(s instanceof Int8Array||s instanceof Uint8ClampedArray||s instanceof Int16Array||s instanceof Uint16Array||s instanceof Int32Array||s instanceof Uint32Array||s instanceof Float32Array||s instanceof Float64Array)&&(s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),s instanceof Uint8Array){for(var a=s.byteLength,o=[],c=0;c<a;c+=1)o[c>>>2]|=s[c]<<24-c%4*8;e.words=o,e.sigBytes=a}else e.words=n,e.sigBytes=i;return e}return l(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ir;return e.stringify(this)}},{key:"concat",value:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s+=1){var a=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=a<<24-(n+s)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this}},{key:"clamp",value:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=Math.ceil(t/4)}},{key:"clone",value:function(){var e=w(f(r.prototype),"clone",this).call(this);return e.words=this.words.slice(0),e}}],[{key:"random",value:function(e){for(var t,n=[],i=function(e){var t=e,r=987654321,n=4294967295;return function(){var e=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return e/=4294967296,(e+=.5)*(Math.random()>.5?1:-1)}},s=0;s<e;s+=4){var a=i(4294967296*(t||Math.random()));t=987654071*a(),n.push(4294967296*a()|0)}return new r(n,e)}}]),r}(rr),ir={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new nr(r,t/2)}},sr=function(e){for(var t=e.length,r=[],n=0;n<t;n+=1)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new nr(r,t)},ar=function(e){return sr(unescape(encodeURIComponent(e)))},or=function(e){h(r,e);var t=k(r);function r(){var e;return u(this,r),(e=t.call(this))._minBufferSize=0,e}return l(r,[{key:"reset",value:function(){this._data=new nr,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=ar(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}},{key:"_process",value:function(e){var t,r=this._data,n=this.blockSize,i=r.words,s=r.sigBytes,a=s/(4*n),o=(a=e?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0))*n,u=Math.min(4*o,s);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new nr(t,u)}},{key:"clone",value:function(){var e=w(f(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(rr),ur=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new rr,e),n.reset(),n}return l(r,[{key:"reset",value:function(){w(f(r.prototype),"reset",this).call(this),this._doReset()}},{key:"update",value:function(e){return this._append(e),this._process(),this}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"_createHelper",value:function(e){return function(t,r){return new e(r).finalize(t)}}},{key:"_createHmacHelper",value:function(e){return function(t,r){return new cr(e,r).finalize(t)}}}]),r}(or),cr=function(e){h(r,e);var t=k(r);function r(e,n){var i;u(this,r),i=t.call(this);var s=new e;i._hasher=s;var a=n;"string"==typeof a&&(a=ar(a));var o=s.blockSize,c=4*o;a.sigBytes>c&&(a=s.finalize(n)),a.clamp();var l=a.clone();i._oKey=l;var d=a.clone();i._iKey=d;for(var h=l.words,f=d.words,p=0;p<o;p+=1)h[p]^=1549556828,f[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return l(r,[{key:"reset",value:function(){var e=this._hasher;e.reset(),e.update(this._iKey)}},{key:"update",value:function(e){return this._hasher.update(e),this}},{key:"finalize",value:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}}]),r}(rr),lr={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var a=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;o<4&&s+.75*o<r;o+=1)i.push(n.charAt(a>>>6*(3-o)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){this._reverseMap=[],n=this._reverseMap;for(var i=0;i<r.length;i+=1)n[r.charCodeAt(i)]=i}var s=r.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,s=0;s<t;s+=1)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2|r[e.charCodeAt(s)]>>>6-s%4*2;n[i>>>2]|=a<<24-i%4*8,i+=1}return nr.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},dr=[],hr=0;hr<64;hr+=1)dr[hr]=4294967296*Math.abs(Math.sin(hr+1))|0;var fr=function(e,t,r,n,i,s,a){var o=e+(t&r|~t&n)+i+a;return(o<<s|o>>>32-s)+t},pr=function(e,t,r,n,i,s,a){var o=e+(t&n|r&~n)+i+a;return(o<<s|o>>>32-s)+t},vr=function(e,t,r,n,i,s,a){var o=e+(t^r^n)+i+a;return(o<<s|o>>>32-s)+t},yr=function(e,t,r,n,i,s,a){var o=e+(r^(t|~n))+i+a;return(o<<s|o>>>32-s)+t},mr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"_doReset",value:function(){this._hash=new nr([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,s=e[i];r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],h=r[t+5],f=r[t+6],p=r[t+7],v=r[t+8],y=r[t+9],m=r[t+10],_=r[t+11],g=r[t+12],b=r[t+13],k=r[t+14],x=r[t+15],w=a[0],S=a[1],E=a[2],j=a[3];w=fr(w,S,E,j,o,7,dr[0]),j=fr(j,w,S,E,u,12,dr[1]),E=fr(E,j,w,S,c,17,dr[2]),S=fr(S,E,j,w,l,22,dr[3]),w=fr(w,S,E,j,d,7,dr[4]),j=fr(j,w,S,E,h,12,dr[5]),E=fr(E,j,w,S,f,17,dr[6]),S=fr(S,E,j,w,p,22,dr[7]),w=fr(w,S,E,j,v,7,dr[8]),j=fr(j,w,S,E,y,12,dr[9]),E=fr(E,j,w,S,m,17,dr[10]),S=fr(S,E,j,w,_,22,dr[11]),w=fr(w,S,E,j,g,7,dr[12]),j=fr(j,w,S,E,b,12,dr[13]),E=fr(E,j,w,S,k,17,dr[14]),S=fr(S,E,j,w,x,22,dr[15]),w=pr(w,S,E,j,u,5,dr[16]),j=pr(j,w,S,E,f,9,dr[17]),E=pr(E,j,w,S,_,14,dr[18]),S=pr(S,E,j,w,o,20,dr[19]),w=pr(w,S,E,j,h,5,dr[20]),j=pr(j,w,S,E,m,9,dr[21]),E=pr(E,j,w,S,x,14,dr[22]),S=pr(S,E,j,w,d,20,dr[23]),w=pr(w,S,E,j,y,5,dr[24]),j=pr(j,w,S,E,k,9,dr[25]),E=pr(E,j,w,S,l,14,dr[26]),S=pr(S,E,j,w,v,20,dr[27]),w=pr(w,S,E,j,b,5,dr[28]),j=pr(j,w,S,E,c,9,dr[29]),E=pr(E,j,w,S,p,14,dr[30]),S=pr(S,E,j,w,g,20,dr[31]),w=vr(w,S,E,j,h,4,dr[32]),j=vr(j,w,S,E,v,11,dr[33]),E=vr(E,j,w,S,_,16,dr[34]),S=vr(S,E,j,w,k,23,dr[35]),w=vr(w,S,E,j,u,4,dr[36]),j=vr(j,w,S,E,d,11,dr[37]),E=vr(E,j,w,S,p,16,dr[38]),S=vr(S,E,j,w,m,23,dr[39]),w=vr(w,S,E,j,b,4,dr[40]),j=vr(j,w,S,E,o,11,dr[41]),E=vr(E,j,w,S,l,16,dr[42]),S=vr(S,E,j,w,f,23,dr[43]),w=vr(w,S,E,j,y,4,dr[44]),j=vr(j,w,S,E,g,11,dr[45]),E=vr(E,j,w,S,x,16,dr[46]),S=vr(S,E,j,w,c,23,dr[47]),w=yr(w,S,E,j,o,6,dr[48]),j=yr(j,w,S,E,p,10,dr[49]),E=yr(E,j,w,S,k,15,dr[50]),S=yr(S,E,j,w,h,21,dr[51]),w=yr(w,S,E,j,g,6,dr[52]),j=yr(j,w,S,E,l,10,dr[53]),E=yr(E,j,w,S,m,15,dr[54]),S=yr(S,E,j,w,u,21,dr[55]),w=yr(w,S,E,j,v,6,dr[56]),j=yr(j,w,S,E,x,10,dr[57]),E=yr(E,j,w,S,f,15,dr[58]),S=yr(S,E,j,w,b,21,dr[59]),w=yr(w,S,E,j,d,6,dr[60]),j=yr(j,w,S,E,_,10,dr[61]),E=yr(E,j,w,S,c,15,dr[62]),S=yr(S,E,j,w,y,21,dr[63]),a[0]=a[0]+w|0,a[1]=a[1]+S|0,a[2]=a[2]+E|0,a[3]=a[3]+j|0}},{key:"_doFinalize",value:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var i=Math.floor(r/4294967296),s=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var a=this._hash,o=a.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return a}},{key:"clone",value:function(){var e=w(f(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(ur);ur._createHelper(mr),ur._createHmacHelper(mr);var _r=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).cfg=Object.assign(new rr,{keySize:4,hasher:mr,iterations:1},e),n}return l(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),s=nr.create(),a=s.words,o=n.keySize,u=n.iterations;a.length<o;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var c=1;c<u;c+=1)r=i.finalize(r),i.reset();s.concat(r)}return s.sigBytes=4*o,s}}]),r}(rr),gr=function(e){h(r,e);var t=k(r);function r(e,n,i){var s;return u(this,r),(s=t.call(this)).cfg=Object.assign(new rr,i),s._xformMode=e,s._key=n,s.reset(),s}return l(r,[{key:"reset",value:function(){w(f(r.prototype),"reset",this).call(this),this._doReset()}},{key:"process",value:function(e){return this._append(e),this._process()}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"createEncryptor",value:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)}},{key:"createDecryptor",value:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)}},{key:"_createHelper",value:function(e){var t=function(e){return"string"==typeof e?Dr:Tr};return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}]),r}(or);gr._ENC_XFORM_MODE=1,gr._DEC_XFORM_MODE=2,gr.keySize=4,gr.ivSize=4;var br=function(e){h(r,e);var t=k(r);function r(e,n){var i;return u(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return l(r,null,[{key:"createEncryptor",value:function(e,t){return this.Encryptor.create(e,t)}},{key:"createDecryptor",value:function(e,t){return this.Decryptor.create(e,t)}}]),r}(rr);function kr(e,t,r){var n,i=e,s=this._iv;s?(n=s,this._iv=void 0):n=this._prevBlock;for(var a=0;a<r;a+=1)i[t+a]^=n[a]}var xr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(br);xr.Encryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;kr.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(xr),xr.Decryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),kr.call(this,e,t,n),this._prevBlock=i}}]),r}(xr);var wr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);var o=nr.create(s,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},Sr=function(e){h(r,e);var t=k(r);function r(e,n,i){var s;return u(this,r),(s=t.call(this,e,n,Object.assign({mode:xr,padding:wr},i))).blockSize=4,s}return l(r,[{key:"reset",value:function(){var e;w(f(r.prototype),"reset",this).call(this);var t=this.cfg,n=t.iv,i=t.mode;this._xformMode===this.constructor._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode=e.call(i,this,n&&n.words),this._mode.__creator=e}},{key:"_doProcessBlock",value:function(e,t){this._mode.processBlock(e,t)}},{key:"_doFinalize",value:function(){var e,t=this.cfg.padding;return this._xformMode===this.constructor._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e}}]),r}(gr),Er=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).mixIn(e),n}return l(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(rr),jr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?nr.create([1398893684,1701076831]).concat(r).concat(t):t).toString(lr)},parse:function(e){var t,r=lr.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=nr.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),Er.create({ciphertext:r,salt:t})}},Tr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new rr,this.cfg,n),s=e.createEncryptor(r,i),a=s.finalize(t),o=s.cfg;return Er.create({ciphertext:a,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:s.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new rr,this.cfg,n);return i=this._parse(i,s.format),e.createDecryptor(r,s).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(rr);Tr.cfg=Object.assign(new rr,{format:jr});var Ar={execute:function(e,t,r,n){var i=n;i||(i=nr.random(8));var s=_r.create({keySize:t+r}).compute(e,i),a=nr.create(s.words.slice(t),4*r);return s.sigBytes=4*t,Er.create({key:s,iv:a,salt:i})}},Dr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new rr,this.cfg,n),s=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=s.iv;var a=Tr.encrypt.call(this,e,t,s.key,i);return a.mixIn(s),a}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new rr,this.cfg,n);i=this._parse(i,s.format);var a=s.kdf.execute(r,e.keySize,e.ivSize,i.salt);return s.iv=a.iv,Tr.decrypt.call(this,e,i,a.key,s)}}]),r}(Tr);Dr.cfg=Object.assign(Tr.cfg,{kdf:Ar});for(var Or=[],Lr=[],Cr=[],Rr=[],Br=[],Pr=[],Ur=[],Mr=[],Ir=[],Fr=[],Nr=[],qr=0;qr<256;qr+=1)Nr[qr]=qr<128?qr<<1:qr<<1^283;for(var Vr=0,zr=0,Gr=0;Gr<256;Gr+=1){var Hr=zr^zr<<1^zr<<2^zr<<3^zr<<4;Hr=Hr>>>8^255&Hr^99,Or[Vr]=Hr,Lr[Hr]=Vr;var Kr=Nr[Vr],Wr=Nr[Kr],Qr=Nr[Wr],Yr=257*Nr[Hr]^16843008*Hr;Cr[Vr]=Yr<<24|Yr>>>8,Rr[Vr]=Yr<<16|Yr>>>16,Br[Vr]=Yr<<8|Yr>>>24,Pr[Vr]=Yr,Yr=16843009*Qr^65537*Wr^257*Kr^16843008*Vr,Ur[Hr]=Yr<<24|Yr>>>8,Mr[Hr]=Yr<<16|Yr>>>16,Ir[Hr]=Yr<<8|Yr>>>24,Fr[Hr]=Yr,Vr?(Vr=Kr^Nr[Nr[Nr[Qr^Kr]]],zr^=Nr[Nr[zr]]):Vr=zr=1}var Xr=[0,1,2,4,8,16,32,64,128,27,54],Jr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"_doReset",value:function(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){this._keyPriorReset=this._key;var t=this._keyPriorReset,r=t.words,n=t.sigBytes/4;this._nRounds=n+6;var i=4*(this._nRounds+1);this._keySchedule=[];for(var s=this._keySchedule,a=0;a<i;a+=1)a<n?s[a]=r[a]:(e=s[a-1],a%n?n>6&&a%n==4&&(e=Or[e>>>24]<<24|Or[e>>>16&255]<<16|Or[e>>>8&255]<<8|Or[255&e]):(e=Or[(e=e<<8|e>>>24)>>>24]<<24|Or[e>>>16&255]<<16|Or[e>>>8&255]<<8|Or[255&e],e^=Xr[a/n|0]<<24),s[a]=s[a-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?s[c]:s[c-4],o[u]=u<4||c<=4?e:Ur[Or[e>>>24]]^Mr[Or[e>>>16&255]]^Ir[Or[e>>>8&255]]^Fr[Or[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,Cr,Rr,Br,Pr,Or)}},{key:"decryptBlock",value:function(e,t){var r=e,n=r[t+1];r[t+1]=r[t+3],r[t+3]=n,this._doCryptBlock(r,t,this._invKeySchedule,Ur,Mr,Ir,Fr,Lr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,s,a,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],h=u[t+2]^r[2],f=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var y=n[l>>>24]^i[d>>>16&255]^s[h>>>8&255]^a[255&f]^r[p];p+=1;var m=n[d>>>24]^i[h>>>16&255]^s[f>>>8&255]^a[255&l]^r[p];p+=1;var _=n[h>>>24]^i[f>>>16&255]^s[l>>>8&255]^a[255&d]^r[p];p+=1;var g=n[f>>>24]^i[l>>>16&255]^s[d>>>8&255]^a[255&h]^r[p];p+=1,l=y,d=m,h=_,f=g}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&f])^r[p];p+=1;var k=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[f>>>8&255]<<8|o[255&l])^r[p];p+=1;var x=(o[h>>>24]<<24|o[f>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var w=(o[f>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=x,u[t+3]=w}}]),r}(Sr);Jr.keySize=8,Sr._createHelper(Jr);var Zr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(br);Zr.Encryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,s=this._iv,a=this._counter;s&&(this._counter=s.slice(0),a=this._counter,this._iv=void 0);var o=a.slice(0);n.encryptBlock(o,0),a[i-1]=a[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(Zr),Zr.Decryptor=Zr.Encryptor;var $r=new X("BufferService"),en=function(){function e(t,r,n){u(this,e),d(this,"flv",null),d(this,"_demuxer",new Yt),d(this,"_remuxer",null),d(this,"_mse",null),d(this,"_softVideo",null),d(this,"_sourceCreated",!1),d(this,"_needInitSegment",!0),d(this,"_discontinuity",!0),d(this,"_contiguous",!1),d(this,"_initSegmentId",""),d(this,"_cachedBuffer",null),d(this,"_demuxStartTime",0),d(this,"_opts",null),this.flv=t,this._opts=n,r?this._softVideo=r:(this._remuxer=new tr(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new ie,this._mse.bindMedia(t.media))}var t,r,s,a,c,h;return l(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:(h=o(i().mark((function e(){var t,r=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="";case 11:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"endOfStream",value:(c=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit(Te);case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"updateDuration",value:(a=o(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return $r.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"destroy",value:(s=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"appendBuffer",value:(r=o(i().mark((function e(t){var r,n,s,a,o,u,c,l,d,h,f,p,v,y;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._cachedBuffer&&(t=Ze(this._cachedBuffer,t),this._cachedBuffer=null),r=this._demuxer,t&&t.length&&r){e.next=4;break}return e.abrupt("return");case 4:e.prev=4,r.demuxAndFix(t,this._discontinuity,this._contiguous,this._demuxStartTime),e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(4),new K(I,G.FLV,e.t0);case 11:if(n=r.videoTrack,s=r.audioTrack,a=r.metadataTrack,o=n.exist(),u=s.exist(),this._opts.onlyAudio&&(o=!1,n.present=!1),this._opts.onlyVideo&&(u=!1,s.present=!1),!(!o&&n.present||!u&&s.present)){e.next=29;break}if(c=0,(l=o?n:u?s:void 0)&&l.samples.length&&(c=(l.samples[l.samples.length-1].originPts-l.samples[0].originPts)/l.timescale*1e3),!(c>this._opts.analyzeDuration)){e.next=27;break}$r.warn("analyze duration exceeded, ".concat(c,"ms"),l),n.present=o,s.present=u,this.flv.emit(Ee,{duration:c}),e.next=29;break;case 27:return this._cachedBuffer=t,e.abrupt("return");case 29:if(d=n.type,h=s.type,this._fireEvents(n,s,a),this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0,f=this._mse,this.flv.emit(Ue,{videoTrack:n}),(p="".concat(n.codec,"/").concat(n.width,"/").concat(n.height,"/").concat(s.codec,"/").concat(s.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=p,this._emitMetaParsedEvent(n,s)),!f){e.next=65;break}if(this._sourceCreated){e.next=47;break}return e.next=43,f.open();case 43:o&&($r.log("codec: video/mp4;codecs=".concat(n.codec)),f.createSource(d,"video/mp4;codecs=".concat(n.codec))),u&&($r.log("codec: audio/mp4;codecs=".concat(s.codec)),f.createSource(h,"audio/mp4;codecs=".concat(s.codec))),this._sourceCreated=!0,this.flv.emit(Se);case 47:e.prev=47,v=this._remuxer.remux(this._needInitSegment),e.next=54;break;case 51:throw e.prev=51,e.t1=e.catch(47),new K(F,G.FMP4,e.t1);case 54:if(!this._needInitSegment||v.videoInitSegment||v.audioInitSegment){e.next=56;break}return e.abrupt("return");case 56:return this._needInitSegment=!1,y=[],v.videoInitSegment&&y.push(f.append(d,v.videoInitSegment)),v.audioInitSegment&&y.push(f.append(h,v.audioInitSegment)),v.videoSegment&&y.push(f.append(d,v.videoSegment)),v.audioSegment&&y.push(f.append(h,v.audioSegment)),e.abrupt("return",Promise.all(y));case 65:this._softVideo&&this._softVideo.appendBuffer(n,s);case 66:case"end":return e.stop()}}),e,this,[[4,8],[47,51]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=o(i().mark((function e(t){var r,n,s,a=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(n=r.currentTime,!((s=n-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(C.start(C.get(r))+1>=s)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,s).then((function(){return a.flv.emit(je,{removeEnd:s})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(De,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(De,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),$r.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i=this;$r.debug(e.samples,t.samples),r.flvScriptSamples.forEach((function(e){i.flv.emit(Ce,e),$r.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&i.flv.emit(Ae,{pts:e.pts})})),e.warnings.forEach((function(e){var t;switch(e.type){case pt:t=Ie;break;case vt:t=Fe;break;case yt:t=ze}t&&i.flv.emit(Me,n(n({},e),{},{type:t})),$r.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case mt:t=Ne;break;case _t:t=qe;break;case gt:t=Ve}t&&i.flv.emit(Me,n(n({},e),{},{type:t})),$r.warn("audio exception",e)})),r.seiSamples.forEach((function(e){i.flv.emit(Oe,n(n({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function tn(e,t){var r=0,n=e.length-1,i=0,s=0,a=n;for(t<e[0]&&(r=0,s=a+1);s<=a;){if((i=s+Math.floor((a-s)/2))===n||t>=e[i]&&t<e[i+1]){r=i;break}e[i]<t?s=i+1:a=i-1}return r}var rn=new X("flv"),nn=function(e){h(y,e);var t,r,s,a,c,f,p,v=k(y);function y(e){var t,r;return u(this,y),d(g(t=v.call(this)),"media",null),d(g(t),"_loading",!1),d(g(t),"_opts",null),d(g(t),"_bufferService",null),d(g(t),"_gapService",null),d(g(t),"_stats",null),d(g(t),"_mediaLoader",null),d(g(t),"_maxChunkWaitTimer",null),d(g(t),"_tickTimer",null),d(g(t),"_tickInterval",500),d(g(t),"_urlSwitching",!1),d(g(t),"_seamlessSwitching",!1),d(g(t),"_keyframes",null),d(g(t),"_acceptRanges",!0),d(g(t),"_onProgress",function(){var e=o(i().mark((function e(r,n,s,a){var o,u,c,l,d,h,f,p;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.startTime,u=s.endTime,c=s.st,l=s.firstByteTime,t._loading=!n,t._firstProgressEmit){e.next=11;break}if(t.media){e.next=6;break}return null===(d=t._mediaLoader)||void 0===d||d.cancel(),e.abrupt("return");case 6:h=a.headers,t.emit(ge,{url:t._opts.url,responseUrl:a.url,elapsed:c?l-c:u-o}),t.emit(ke,{headers:h}),t._acceptRanges=!(null==h||!h.get("Accept-Ranges"))||!(null==h||!h.get("Content-Range")),t._firstProgressEmit=!0;case 11:if(t._bufferService){e.next=13;break}return e.abrupt("return");case 13:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=15,e.next=18,t._bufferService.appendBuffer(r);case 18:null===(f=t._bufferService)||void 0===f||f.evictBuffer(t._opts.bufferBehind),e.next=24;break;case 21:return e.prev=21,e.t0=e.catch(15),e.abrupt("return",t._emitError(K.create(e.t0)));case 24:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit(Be,{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!n||t.media.seeking){e.next=32;break}return t.emit(xe),rn.debug("load done"),t._end(),!t.isLive&&t.media.readyState<=2&&t._tick(),e.abrupt("return");case 32:(p=t._opts.maxReaderInterval)&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){rn.debug("onMaxChunkWait",p),t._end()}),p));case 34:case"end":return e.stop()}}),e,null,[[15,21]])})));return function(t,r,n,i){return e.apply(this,arguments)}}()),d(g(t),"_onRetryError",(function(e,r){rn.debug("load retry",e,r),t.emit(we,{error:K.network(e),retryTime:r})})),d(g(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),rn.debug("end stream")})),d(g(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=g(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=C.end(C.get(e));if(!(r<.1)&&e.readyState){var n=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e))t._gapService&&t._gapService.do(e,n.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService)return void t._gapService.do(e,n.maxJumpDistance,t.isLive,3);n.isLive&&r>n.disconnectTime&&t.disconnect()}}}})),d(g(t),"_onPlay",(function(){var e,r,n=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);t.isLive&&!t._loading&&n&&t.replay(void 0,!0)})),d(g(t),"_onSeeking",o(i().mark((function e(){var r,n,s,a,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.isLive||!t.seekable){e.next=14;break}if(r=t._keyframes.times,n=t._keyframes.filepositions,null!=r&&r.length&&null!=n&&n.length){e.next=5;break}return e.abrupt("return");case 5:if(s=t.media.currentTime,a=tn(t._keyframes.times,s),null!=(o=n[a])){e.next=10;break}return e.abrupt("return");case 10:return e.next=12,t._mediaLoader.cancel();case 12:t._loadData(null,[o]),t._bufferService.unContiguous(r[a]);case 14:case"end":return e.stop()}}),e)})))),d(g(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var n=C.end(C.get(t.media));n-r>=e.maxLatency&&(t.media.currentTime=n-e.targetLatency)}t._seiService.throw(r)}})),d(g(t),"_onFlvScriptData",(function(e){var r,n,i,s,a=null===(r=e.data)||void 0===r||null===(n=r.onMetaData)||void 0===n?void 0:n.keyframes,o=null===(i=e.data)||void 0===i||null===(s=i.onMetaData)||void 0===s?void 0:s.duration;a&&(t._keyframes=a),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=n({retryCount:3,retryDelay:1e3,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new et(n(n({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._bufferService=new en(g(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new rt(g(t)),t._bandwidthService=new nt,t._stats=new st(g(t)),t._opts.softDecode||(t._gapService=new tt),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.on(Ce,t._onFlvScriptData),t}return l(y,[{key:"version",get:function(){return"3.0.10-alpha.4"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1;return C.info(C.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(p=o(i().mark((function e(t){var r,n=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.length>1&&void 0!==n[1]&&n[1],this._bufferService){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._reset(r);case 5:this._loadData(t),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"replay",value:(f=o(i().mark((function e(){var t,r,n=this,s=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:this._opts.seamlesslyReload,r=s.length>1?s[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(!t){e.next=10;break}return e.next=7,this._clear();case 7:setTimeout((function(){n._loadData(n._opts.url),n._bufferService.seamlessSwitch(),n._seamlessSwitching=!0})),e.next=12;break;case 10:return e.next=12,this.load();case 12:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 13:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"disconnect",value:function(){return rn.debug("disconnect!"),this._clear()}},{key:"switchURL",value:(c=o(i().mark((function e(t,r){var n=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(r&&this._opts.isLive){e.next=7;break}return e.next=5,this.load(t);case 5:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 7:return e.next=9,this._clear();case 9:setTimeout((function(){n._loadData(t),n._bufferService.seamlessSwitch(),n._urlSwitching=!0,n._seamlessSwitching=!0}));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"destroy",value:(a=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),e.next=9,Promise.all([this._clear(),this._bufferService.destroy()]);case 9:this.media=null,this._bufferService=null;case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];rn.table(e),rn.error(e),rn.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(Pe,e)),this.emit(_e,e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(s=o(i().mark((function e(){var t,r=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"_loadData",value:(r=o(i().mark((function e(t,r){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),n=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(n=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=n,this.emit(be,{url:n}),rn.debug("load data, loading:",this._loading,n),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:n,range:r});case 15:e.next=20;break;case 17:return e.prev=17,e.t0=e.catch(12),e.abrupt("return",this._emitError(K.network(e.t0)));case 20:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,t){return r.apply(this,arguments)})},{key:"_clear",value:(t=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:ie.isSupported()}},{key:"enableLogger",value:function(){X.enable(),Dt.enable()}},{key:"disableLogger",value:function(){X.disable(),Dt.disable()}}]),y}(Ke);try{localStorage.getItem("xgd")?nn.enableLogger():nn.disableLogger()}catch(on){}var sn=function(){function e(t,r){var i=this;u(this,e),d(this,"_onLowDecode",(function(){var e,t,r,s,a=i._opts,o=a.media,u=a.innerDegrade,c=a.backupURL;null===(e=i._plugin)||void 0===e||null===(t=e.player)||void 0===t||t.emit("lowdecode",o.degradeInfo),null===(r=i._plugin)||void 0===r||null===(s=r.player)||void 0===s||s.emit("core_event",n(n({},o.degradeInfo),{},{eventName:Re})),1!==u&&3!==u||!c||i._degrade(c)})),d(this,"_degrade",(function(e){var t=i._plugin.player,r=t.video;if("MVideo"===(null==r?void 0:r.TAG)){var n=t.video.degradeVideo;t.video=n,r.degrade(e),e&&(t.config.url=e);var s=t.root.firstChild;"MVideo"===s.TAG&&t.root.replaceChild(n,s);var a=i._plugin.constructor.pluginName.toLowerCase();t.unRegisterPlugin(a),t.once("canplay",(function(){t.play()}))}})),d(this,"forceDegradeToVideo",(function(e){var t=i._opts.innerDegrade;1!==t&&3!==t||i._degrade(e)})),this._opts=t,this._plugin=r,this._init()}return l(e,[{key:"_init",value:function(){var e=this._opts,t=e.media,r=e.preloadTime,n=e.innerDegrade,i=e.decodeMode;t&&(n&&t.setAttribute("innerdegrade",n),r&&t.setAttribute("preloadtime",r),t.setDecodeMode&&t.setDecodeMode(i),this._bindEvents())}},{key:"_bindEvents",value:function(){this._opts.media.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var e,t;null===(e=this._opts)||void 0===e||null===(t=e.media)||void 0===t||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),e}(),an=function(e){h(i,e);var r=k(i);function i(){var e;u(this,i);for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return d(g(e=r.call.apply(r,[this].concat(n))),"flv",null),d(g(e),"pluginExtension",null),d(g(e),"getStats",(function(){var t;return null===(t=e.flv)||void 0===t?void 0:t.getStats()})),d(g(e),"destroy",(function(){var t;e.flv&&(e.flv.destroy(),e.flv=null),null===(t=e.pluginExtension)||void 0===t||t.destroy(),e.pluginExtension=null})),d(g(e),"_onSwitchURL",(function(t,r){var n,i;e.flv&&(e.player.config.url=t,e.flv.switchURL(t,r),!r&&null!==(n=e.player.config)&&void 0!==n&&null!==(i=n.flv)&&void 0!==i&&i.keepStatusAfterSwitch&&e._keepPauseStatus())})),d(g(e),"_keepPauseStatus",(function(){e.player.paused&&e.player.once("canplay",(function(){e.player.pause()}))})),d(g(e),"_onDefinitionChange",(function(t){var r=t.to;e.flv&&e.flv.switchURL(r)})),e}return l(i,[{key:"core",get:function(){return this.flv}},{key:"version",get:function(){var e;return null===(e=this.flv)||void 0===e?void 0:e.version}},{key:"softDecode",get:function(){var e,t,r=null===(e=this.player)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mediaType;return!!r&&"video"!==r&&"audio"!==r}},{key:"loader",get:function(){var e;return null===(e=this.flv)||void 0===e?void 0:e.loader}},{key:"beforePlayerInit",value:function(){var e=this,r=this.player.config;if(r.url){this.flv&&this.flv.destroy(),this.player.switchURL=this._onSwitchURL;var i,s=r.flv||{};if(null!==s.disconnectTime&&void 0!==s.disconnectTime||(s.disconnectTime=0),this.flv=new nn(n({softDecode:this.softDecode,isLive:r.isLive,media:this.player.video,preProcessUrl:function(t,r){var n,i;return(null===(n=(i=e.player).preProcessUrl)||void 0===n?void 0:n.call(i,t,r))||{url:t,ext:r}}},s)),this.softDecode||t.BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){var t,r;return null===(t=e.flv)||void 0===t||null===(r=t.media)||void 0===r?void 0:r.src},configurable:!0}}),this.softDecode&&(this.pluginExtension=new sn(n({media:this.player.video},r.flv),this),this.player.forceDegradeToVideo=function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return null===(t=e.pluginExtension)||void 0===t?void 0:t.forceDegradeToVideo.apply(t,n)}),r.isLive)null===(i=this.player)||void 0===i||i.useHooks("replay",(function(){var t;return null===(t=e.flv)||void 0===t?void 0:t.replay()}));this.on(t.Events.URL_CHANGE,this._onSwitchURL),this.on(t.Events.DESTROY,this.destroy),this._transError(),this._transCoreEvent(ge),this._transCoreEvent(be),this._transCoreEvent(ke),this._transCoreEvent(xe),this._transCoreEvent(we),this._transCoreEvent(Se),this._transCoreEvent(Ee),this._transCoreEvent(je),this._transCoreEvent(Te),this._transCoreEvent(Ae),this._transCoreEvent(De),this._transCoreEvent(Oe),this._transCoreEvent(Le),this._transCoreEvent(Ce),this._transCoreEvent(Me),this._transCoreEvent(Be),this._transCoreEvent(Pe),this.flv.load(r.url,!0)}}},{key:"_transError",value:function(){var e=this;this.flv.on(_e,(function(r){e.player&&e.player.emit(t.Events.ERROR,new t.Errors(e.player,r))}))}},{key:"_transCoreEvent",value:function(e){var t=this;this.flv.on(e,(function(r){t.player&&t.player.emit("core_event",n(n({},r),{},{eventName:e}))}))}}],[{key:"pluginName",get:function(){return"flv"}},{key:"isSupported",value:function(e,t){return nn.isSupported(e,t)}}]),i}(t.BasePlugin);return d(an,"Flv",nn),an}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.concat.js"),require("xgplayer"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.object.to-string.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.slice.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.find.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.typed-array.int8-array.js"),require("core-js/modules/es.typed-array.uint8-clamped-array.js"),require("core-js/modules/es.typed-array.int16-array.js"),require("core-js/modules/es.typed-array.uint16-array.js"),require("core-js/modules/es.typed-array.int32-array.js"),require("core-js/modules/es.typed-array.uint32-array.js"),require("core-js/modules/es.typed-array.float32-array.js"),require("core-js/modules/es.typed-array.float64-array.js"),require("core-js/modules/es.array.find-index.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","xgplayer","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.object.to-string.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.slice.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.find.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.int16-array.js","core-js/modules/es.typed-array.uint16-array.js","core-js/modules/es.typed-array.int32-array.js","core-js/modules/es.typed-array.uint32-array.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.float64-array.js","core-js/modules/es.array.find-index.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).FlvPlayer=t(null,e.Player)}(this,(function(e,t){"use strict";function r(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 n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(){i=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.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(D){c=function(e,t,r){return e[t]=r}}function l(e,t,r,i){var s=t&&t.prototype instanceof f?t:f,a=Object.create(s.prototype),o=new T(i||[]);return n(a,"_invoke",{value:w(e,r,o)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(D){return{type:"throw",arg:D}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,_=m&&m(m(j([])));_&&_!==t&&r.call(_,a)&&(y=_);var g=v.prototype=f.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,s,a,o){var u=d(e[n],e,s);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,o)}),(function(e){i("throw",e,a,o)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,o)}))}o(u.arg)}var s;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return s=s?s.then(n,n):n()}})}function w(e,t,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return{value:void 0,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var o=x(a,r);if(o){if(o===h)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function x(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var a=new k(l(t,r,n,i),s);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=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)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.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 s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function s(e){return(s="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 a(e,t,r,n,i,s,a){try{var o=e[s](a),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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,C(n.key),n)}}function l(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=C(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(){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 y(e,t,r){return(y=v()?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&&p(i,r.prototype),i}).apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=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 y(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,e)},m(e)}function _(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(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 g(e)}function k(e){var t=v();return function(){var r,n=f(e);if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return b(this,r)}}function w(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}function x(){return x="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=w(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},x.apply(this,arguments)}function S(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,s,a,o=[],u=!0,c=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=s.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&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}(e,t)||T(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 E(e){return function(e){if(Array.isArray(e))return j(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||T(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 T(e,t){if(e){if("string"==typeof e)return j(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?j(e,t):void 0}}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function C(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 D,A=function(){function e(){u(this,e)}return l(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var s=r.length;if(s&&t){var a=r[s-1],o=a[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(a[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,s=0,a=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],s=p[1],a=h;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:s,index:a,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:s?s-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}(),L="undefined"!=typeof window,O="network",R="network_timeout",P="network_forbidden",B="network_notfound",U="network_range_not_satisfiable",M="demux",I="remux",F="media",N="drm",q="other",z="runtime",V={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"},G=(d(D={},"manifest",{HLS:1100,DASH:1200}),d(D,O,2100),d(D,R,2101),d(D,P,2103),d(D,B,2104),d(D,U,2116),d(D,M,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),d(D,I,{FMP4:4100,MP4:4200}),d(D,F,{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}),d(D,N,{LICENSE:7100,CUSTOM_LICENSE:7200}),d(D,q,8e3),d(D,z,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),D),H=function(e){h(r,e);var t=k(r);function r(e,n,i,s,a){var o;return u(this,r),(o=t.call(this,a||(null==i?void 0:i.message))).errorType=e===R?O:e,o.originError=i,o.ext=s,o.errorCode=G[e][n]||G[e],o.errorMessage=o.message,o.errorCode||(o.errorType=q,o.errorCode=G[o.errorType]),o}return l(r,null,[{key:"create",value:function(e,t,n,i,s){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=q),new r(e,t,n,i,s))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?R: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}(m(Error)),K={DEBUG:1,LOG:2,WARN:3,ERROR:4},W=["Boolean","Number","String","Undefined","Null","Date","Object"],Y=function(){function e(t,r){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return l(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[K.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(Q(),"]"),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(Q(),"]"),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(Q(),"]"),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(Q(),"]"),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 s=n.map((function(e){return X(e)}));t="[".concat(Q(),"]")+this._prefix+JSON.stringify(s)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var a=this.logTextArray.shift();this.logSize-=a.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 Q(){return(new Date).toLocaleString()}function J(e){if("object"!==s(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 n={};if(!e||"object"!==s(e))return e;var i=Object.prototype.toString.call(e).slice(8,-1);if(!W.includes(i))return i;if(!(r>t)){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r===t?n[a]=J(e[a]):"object"===s(e[a])?n[a]=X(e[a],t,r+1):n[a]=e[a]);return n}}function Z(){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 $(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}d(Y,"disabled",!0);var ee=function(e){try{return JSON.stringify(e)}catch(t){return""}};function te(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return L?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function re(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var ne="appendBuffer",ie="removeBuffer",se="updateDuration",ae=function(){function e(t,r){var n=this;u(this,e),d(this,"media",null),d(this,"mediaSource",null),d(this,"_openPromise",Z()),d(this,"_queue",Object.create(null)),d(this,"_sourceBuffer",Object.create(null)),d(this,"_mseFullFlag",{}),d(this,"_st",0),d(this,"_opst",0),d(this,"_logger",null),d(this,"_config",null),d(this,"_url",null),d(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),d(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),d(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,s,a=$()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),ee(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)),a,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:a});var o=null===(s=r.context)||void 0===s?void 0:s.callback;o&&"function"==typeof o&&o(r.context),n._startQueue(e)}}})),d(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 H(F,V.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new Y("MSE"),this._config.openLog&&Y.enable()}var t,r,n;return l(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var n=e._queue[r];Array.isArray(n)&&(t||(t=n.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!re(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=$()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=Z()}return this._openPromise}},{key:"bindMedia",value:(n=o(i().mark((function e(t){var r,n,s,a,o=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=te(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,n=this.mediaSource=new r,s=re(n),this._st=$(),a=function e(){var r=$()-o._st;o._logger.debug("sourceopen"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),o._openPromise.resolve({costtime:r})},n.addEventListener("sourceopen",a),s&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(n),t.src=this._url,t.disableRemotePlayback=s,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unbindMedia",value:(r=o(i().mark((function e(){var t,r,n,s=this;return i().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=s._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,n="open"===t.readyState,r&&n)try{t.endOfStream()}catch(i){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(s._sourceBuffer[e])}catch(i){}})),re(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(i){}this.media=null}this.mediaSource=null,this._openPromise=Z(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new H(F,V.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 H(F,V.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(i){throw new H(F,V.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=$(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),ne,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var s=i._sourceBuffer[e];t>=r||!s?i._onSBUpdateEnd(e):(i._opst=$(),i._logger.debug("MSE REMOVE START",e,t,r,n),s.remove(t,r))}}),ie,n,s)}},{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,A.end(A.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 A.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return A.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return A.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var s=this;if(!this.mediaSource)return Promise.resolve();var a=this._queue[e]=this._queue[e]||[],o={exec:t,promise:Z(),opName:r,context:n};return i?(a.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):a.push(o),this.isOpened||this.isEnded?1===a.length&&this._startQueue(e):this._openPromise.then((function(){1===a.length&&s._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=o(i().mark((function e(t,r,n){var s,a,o=this;return i().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((s=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return a=[],s.forEach((function(e){var t=o._queue[e],i=Z();a.push(i),t.push({exec:function(){i.resolve()},promise:i,opName:r,context:n}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(a).then((function(){try{return t()}finally{s.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(a){var n,i;if(a&&a.message&&a.message.indexOf("SourceBuffer is full")>=0)this._mseFullFlag[e]=!0,r.context&&"object"===s(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),null==r||null===(n=r.promise)||void 0===n||n.reject(new H(F,V.MSE_FULL,a));else this._logger.error(a),null==r||null===(i=r.promise)||void 0===i||i.reject(a.constructor===H?a:new H(F,V.MSE_OTHER,a)),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=te(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}();d(ae,"VIDEO","video"),d(ae,"AUDIO","audio");var oe="fetch",ue="xhr",ce="arraybuffer",le="text",de="json",he=function(e){h(r,e);var t=k(r);function r(e,n,i,s){var a;return u(this,r),d(g(a=t.call(this,s)),"retryCount",0),d(g(a),"isTimeout",!1),d(g(a),"loaderType",oe),d(g(a),"startTime",0),d(g(a),"endTime",0),d(g(a),"options",{}),a.url=e,a.request=n,a.response=i,a}return l(r)}(m(Error)),fe=Object.prototype.toString;function pe(e){if("[object Object]"!==fe.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ve(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 ye(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function me(e,t){if(e){if(!t)return e;var r,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===fe.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===s(e)}(t)&&(t=JSON.stringify(t)),"".concat(ye(e),"=").concat(ye(t))})).join("&")})).filter(Boolean).join("&");if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function _e(e,t,r,n,i,s,a,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:s,firstByteTime:a,endTime:Date.now(),priOptions:l},response:r}}function ge(e,t){return Math.round(8*e*1e3/t/1024)}var be="error",ke="core.ttfb",we="core.loadstart",xe="core.loadresponseheaders",Se="core.loadcomplete",Ee="core.loadretry",Te="core.sourcebuffercreated",je="core.analyzedurationexceeded",Ce="core.appendbuffer",De="core.removebuffer",Ae="core.buffereos",Le="core.keyframe",Oe="core.chaseframe",Re="core.metadataparsed",Pe="core.sei",Be="core.seiintime",Ue="core.flvscriptdata",Me="core.lowdecode",Ie="core.switchurlsuccess",Fe="core.switchurlfailed",Ne="core.demuxedtrack",qe="core.streamexception",ze="LARGE_AV_FIRST_FRAME_GAP_DETECT",Ve="LARGE_VIDEO_DTS_GAP_DETECT",Ge="LARGE_AUDIO_DTS_GAP_DETECT",He="AUDIO_GAP_DETECT",Ke="AUDIO_OVERLAP_DETECT",We="MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",Ye="real_time_speed",Qe="core.audio_sample",Je={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 s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||e,a),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 a(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,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a},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,s,a){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,s),!0;case 6:return l.fn.call(l.context,t,n,i,s,a),!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 h,f=l.length;for(c=0;c<f;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(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||a(this,s);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[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(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}(Je);var Xe=Je.exports,Ze=2097152,$e=function(e){h(n,e);var t,r=k(n);function n(){var e;return u(this,n),d(g(e=r.call(this)),"_abortController",null),d(g(e),"_timeoutTimer",null),d(g(e),"_reader",null),d(g(e),"_response",null),d(g(e),"_aborted",!1),d(g(e),"_index",-1),d(g(e),"_range",null),d(g(e),"_receivedLength",0),d(g(e),"_running",!1),d(g(e),"_logger",null),d(g(e),"_vid",""),d(g(e),"_firtstByte",0),d(g(e),"_onProcessMinLen",0),d(g(e),"_onCancel",null),d(g(e),"_priOptions",null),e}return l(n,[{key:"load",value:function(e){var t,r=this,n=e.url,s=e.vid,a=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,h=e.onCancel,f=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,_=e.method,g=e.headers,b=e.body,k=e.mode,w=e.credentials,x=e.cache,S=e.redirect,E=e.referrer,T=e.referrerPolicy,j=e.onProcessMinLen,C=e.priOptions,D=e.streamRes,A=e.firstMaxChunkSize;this._logger=m,this._aborted=!1,this._onProcessMinLen=j,this._onCancel=h,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=l,this._range=f||[0,0],this._vid=s||n,this._priOptions=C||{},this._firstMaxChunkSize=A;var L={method:_,headers:g,body:b,mode:k,credentials:w,cache:x,redirect:S,referrer:E,referrerPolicy:T,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},O=!1;clearTimeout(this._timeoutTimer),n=me(n,y);var R=ve(f);R&&(g=v?v.headers:L.headers=L.headers||(Headers?new Headers:{}),Headers&&g instanceof Headers?g.append("Range",R):g.Range=R),a&&(this._timeoutTimer=setTimeout((function(){if(O=!0,r.cancel(),d){var e=new he(n,L,null,"timeout");e.isTimeout=!0,d(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),a));var P=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",f),new Promise((function(e,t){(D?new Promise((function(e){e(D)})):fetch(v||n,v?void 0:L)).then(function(){var s=o(i().mark((function s(a){var o,d,h,v;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=a,!r._aborted&&r._running){i.next=4;break}return i.abrupt("return");case 4:if(p&&(a=p(a,n)||a),a.ok){i.next=7;break}throw new he(n,L,a,"bad network response");case 7:if(o=Date.now(),u!==le){i.next=15;break}return i.next=11,a.text();case 11:d=i.sent,r._running=!1,i.next=37;break;case 15:if(u!==de){i.next=22;break}return i.next=18,a.json();case 18:d=i.sent,r._running=!1,i.next=37;break;case 22:if(!c){i.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(a,c,P,o),i.abrupt("return");case 29:return i.next=31,a.arrayBuffer();case 31:d=i.sent,d=new Uint8Array(d),r._running=!1,h=Date.now()-P,v=ge(d.byteLength,h),r.emit(Ye,{speed:v,len:d.byteLength,time:h,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",l,",range,",f),e(_e(d,!0,a,a.headers.get("Content-Length"),a.headers.get("age"),P,o,l,f,r._vid,r._priOptions));case 39:case"end":return i.stop()}}),s)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var i;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!O||((e=e instanceof he?e:new he(n,L,null,null===(i=e)||void 0===i?void 0:i.message)).startTime=P,e.endTime=Date.now(),e.isTimeout=O,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(t=o(i().mark((function e(){return i().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,r,n){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var a=new he(e.url,"",e,"onProgress of bad response.body.getReader");return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(a)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ze),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),h=function(){var a=o(i().mark((function a(){var o,f,p,v,y,m,_,g,b,k;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return c=Date.now(),i.prev=1,i.next=4,d.read();case 4:u=i.sent,l=Date.now(),i.next=13;break;case 8:return i.prev=8,i.t0=i.catch(1),l=Date.now(),s._aborted||(s._running=!1,i.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(i.t0)),i.abrupt("return");case 13:if(f=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=f+s._receivedLength,!s._aborted){i.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:r,firstByteTime:n,priOptions:s._priOptions},e),i.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,",f+s._receivedLength,", done,",u.done),s._onProcessMinLen>0?s._writeIdx+v>=s._onProcessMinLen||u.done?((y=new Uint8Array(s._writeIdx+v)).set(s._cache.slice(0,s._writeIdx),0),v>0&&y.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",y.byteLength,", writeIdx,",s._writeIdx)):v>0&&s._writeIdx+v<Ze?(s._cache.set(u.value,s._writeIdx),s._writeIdx+=v,s._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",s._writeIdx)):v>0&&(m=new Uint8Array(s._writeIdx+v+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+v+2048,", datalen,",v,", writeIdx,",s._writeIdx),m.set(s._cache.slice(0,s._writeIdx),0),v>0&&m.set(u.value,s._writeIdx),s._writeIdx+=v,delete s._cache,s._cache=m,s._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",s._writeIdx)):y=u.value,(y&&y.byteLength>0||u.done)&&(s._firstMaxChunkSize&&(s._firtstByte?s._cacheData&&((g=new Uint8Array(s._cacheData.byteLength+y.byteLength)).set(s._cacheData,0),g.set(y,s._cacheData.byteLength),y=g,s._cacheData=null):(s._firtstByte++,_=y.slice(0,s._firstMaxChunkSize),s._cacheData=y.slice(s._firstMaxChunkSize),y=_)),t(y,u.done,{range:[s._range[0]+s._receivedLength-(y?y.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:r,firstByteTime:n,priOptions:s._priOptions},e)),u.done?(b=Date.now()-r,k=ge(s._receivedLength,b),s.emit(Ye,{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(_e(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,n,s._index,s._range,s._vid,s._priOptions))):s._firstMaxChunkSize?setTimeout((function(){h()}),0):h();case 25:case"end":return i.stop()}}),a,null,[[1,8]])})));return function(){return a.apply(this,arguments)}}();h()}},{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)}}]),n}(Xe);var et=function(e){h(r,e);var t=k(r);function r(){var e;return u(this,r),d(g(e=t.call(this)),"_xhr",null),d(g(e),"_aborted",!1),d(g(e),"_timeoutTimer",null),d(g(e),"_range",null),d(g(e),"_receivedLength",0),d(g(e),"_url",null),d(g(e),"_onProgress",null),d(g(e),"_index",-1),d(g(e),"_headers",null),d(g(e),"_currentChunkSizeKB",384),d(g(e),"_timeout",null),d(g(e),"_xhr",null),d(g(e),"_withCredentials",null),d(g(e),"_startTime",-1),d(g(e),"_loadCompleteResolve",null),d(g(e),"_loadCompleteReject",null),d(g(e),"_runing",!1),d(g(e),"_logger",!1),d(g(e),"_vid",""),d(g(e),"_responseType",void 0),d(g(e),"_credentials",void 0),d(g(e),"_method",void 0),d(g(e),"_transformResponse",void 0),d(g(e),"_firstRtt",void 0),d(g(e),"_onCancel",null),d(g(e),"_priOptions",null),e}return l(r,[{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=me(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 he?e:new he(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===ce&&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 s=new he(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));s.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(s)},r.ontimeout=function(e){t.cancel();var r=new he(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=ve(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(s){s.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var i=new he(this._url,null,n(n({},e.target.response),{},{status:r}),"bad response,status:"+r);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var s,a=null,o=!1,u=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===ce){var c,l=new Uint8Array(e.target.response);if(s=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=ge(this._receivedLength,d);this.emit(Ye,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[s,u+this._receivedLength],priOptions:this._priOptions})}a=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",s,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,a=e.target.response;var f={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(a,o,{index:this._index,vid:this._vid,range:[s,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(_e(this._onProgress?null:a,o,f,f.headers["content-length"],f.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,x(f(r.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=T(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 s,a=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}(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(s){n.e(s)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),r}(Xe),tt=["retry","retryDelay","onRetryError","transformError"],rt=function(){function e(t,r){u(this,e),this.promise=Z(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new Y("Loader")),this._loaderType=t,this._loader=t===oe&&"undefined"!=typeof fetch?new $e:new et,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return l(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,s=t.onRetryError,a=t.transformError,u=_(t,tt),c=function(){var t=o(i().mark((function t(){var o,l,d;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:o=t.sent,e.promise.resolve(o),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,a&&(l=a(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<=r)){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,n),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=o(i().mark((function e(){return i().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 nt(){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 it(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var st=function(e){h(s,e);var t,r=k(s);function s(e){var t;return u(this,s),d(g(t=r.call(this,e)),"type",oe),d(g(t),"_queue",[]),d(g(t),"_alive",[]),d(g(t),"_currentTask",null),d(g(t),"_finnalUrl",""),d(g(t),"_config",void 0),t._config=function(e){return n({loaderType:oe,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:le,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),t._config.loaderType!==ue&&$e.isSupported()||(t.type=ue),t.log=e.logger,t}return l(s,[{key:"isFetch",value:function(){return this.type===oe}},{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&&pe(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&pe(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new rt(this.type,r);return n.loader.on(Ye,(function(e){t.emit(Ye,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(t=o(i().mark((function e(){var t;return i().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,it();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.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 $e.isSupported()}}]),s}(Xe),at=function(){function e(){u(this,e),d(this,"_prevCurrentTime",0)}return l(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var i=e.currentTime,s=0;if(this._prevCurrentTime===i){var a=A.info(A.get(e),i);if(!a.buffers.length)return;r&&a.nextStart||a.nextStart&&a.nextStart-i<t?s=a.nextStart+.1:a.end&&a.end-i>n&&!e.seeking&&(s=i+.1)}this._prevCurrentTime=i,s&&i!==s&&(e.currentTime=s)}}}]),e}(),ot=function(){function e(t){var r=this;u(this,e),d(this,"_seiSet",new Set),this.emitter=t,t.on(Pe,(function(e){e&&r._seiSet.add(e)}))}return l(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var n=e-.2,i=e+.2,s=[];this._seiSet.forEach((function(e){e.time>=n&&e.time<=i&&s.push(e)})),s.forEach((function(e){r._seiSet.delete(e),r.emitter.emit(Be,e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),ut=function(){function e(t){u(this,e),d(this,"_chunkSpeed",0),d(this,"_chunkCache",[]),d(this,"_speeds",[]),d(this,"_totalSize",0),d(this,"_totalCost",0),this._opts=t||{}}return l(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,n;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var i=(null===(n=this._opts)||void 0===n?void 0:n.chunkCountForSpeed)||50;this._chunkCache.length>i&&(this._chunkCache=this._chunkCache.slice(-i))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),ct=function(){function e(t){u(this,e),d(this,"encodeType",""),d(this,"audioCodec",""),d(this,"videoCodec",""),d(this,"domain",""),d(this,"fps",0),d(this,"bitrate",0),d(this,"width",0),d(this,"height",0),d(this,"samplerate",0),d(this,"channelCount",0),d(this,"gop",0),d(this,"_bitsAccumulateSize",0),d(this,"_bitsAccumulateDuration",0),d(this,"_startGopId",-1),this._timescale=t}return l(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,n=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;n&&n>0&&n<100&&(this.fps=n)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),lt=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;u(this,e),d(this,"_core",null),d(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new ct(r),this._bindEvents()}return l(e,[{key:"getStats",value:function(){var e,t,r,i,s,a,o,u,c,l,d,h=(null===(e=this._core)||void 0===e?void 0:e.media)||{},f=h.currentTime,p=void 0===f?0:f,v=h.decodeFps,y=void 0===v?0:v;return n(n({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(i=this._core)||void 0===i||null===(s=i.speedInfo)||void 0===s?void 0:s.call(i).avgSpeed)||0,totalReceivedByte:(null===(a=this._core)||void 0===a||null===(o=a.speedInfo)||void 0===o?void 0:o.call(a).totalSize)||0,totalReceivedCost:(null===(u=this._core)||void 0===u||null===(c=u.speedInfo)||void 0===c?void 0:c.call(u).totalCost)||0,currentTime:p,bufferEnd:(null===(l=this._core)||void 0===l||null===(d=l.bufferInfo())||void 0===d?void 0:d.remaining)||0,decodeFps:y})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(Ne,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Ue,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Re,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(ke,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new ct(this._timescale)}}]),e}(),dt="video",ht="audio",ft="metadata",pt="avc",vt="hevc",yt="aac",mt="g7110a",_t="g7110m",gt="opus",bt="mp3",kt="LARGE_AV_SHIFT",wt="LARGE_VIDEO_GAP",xt="LARGE_VIDEO_GAP_BETWEEN_CHUNK",St="LARGE_AUDIO_GAP",Et="AUDIO_FILLED",Tt="AUDIO_DROPPED",jt=function(){function e(){u(this,e),d(this,"id",1),d(this,"type",dt),d(this,"codecType",pt),d(this,"pid",-1),d(this,"hvcC",void 0),d(this,"codec",""),d(this,"timescale",0),d(this,"formatTimescale",0),d(this,"sequenceNumber",0),d(this,"baseMediaDecodeTime",0),d(this,"baseDts",0),d(this,"duration",0),d(this,"warnings",[]),d(this,"samples",[]),d(this,"pps",[]),d(this,"sps",[]),d(this,"vps",[]),d(this,"fpsNum",0),d(this,"fpsDen",0),d(this,"sarRatio",[]),d(this,"width",0),d(this,"height",0),d(this,"nalUnitSize",4),d(this,"present",!1),d(this,"isVideoEncryption",!1),d(this,"isAudioEncryption",!1),d(this,"isVideo",!0),d(this,"lastKeyFrameDts",0),d(this,"kid",null),d(this,"pssh",null),d(this,"ext",void 0)}return l(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}(),Ct=function(){function e(){u(this,e),d(this,"id",2),d(this,"type",ht),d(this,"codecType",yt),d(this,"pid",-1),d(this,"codec",""),d(this,"container",""),d(this,"sequenceNumber",0),d(this,"sampleDuration",0),d(this,"timescale",0),d(this,"formatTimescale",0),d(this,"baseMediaDecodeTime",0),d(this,"duration",0),d(this,"warnings",[]),d(this,"samples",[]),d(this,"baseDts",0),d(this,"sampleSize",16),d(this,"sampleRate",0),d(this,"channelCount",0),d(this,"objectType",0),d(this,"sampleRateIndex",0),d(this,"config",[]),d(this,"present",!1),d(this,"isVideoEncryption",!1),d(this,"isAudioEncryption",!1),d(this,"kid",null),d(this,"ext",void 0)}return l(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!==yt&&this.codecType!==mt&&this.codecType!==_t&&this.codecType!==gt&&this.codecType!==bt)}},{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}(),Dt=function(){function e(t,r,n){u(this,e),d(this,"flag",{}),d(this,"keyframe",!1),d(this,"gopId",0),d(this,"duration",0),d(this,"size",0),d(this,"units",[]),d(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return l(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}(),At=l((function e(t,r,n,i){u(this,e),d(this,"duration",1024),d(this,"flag",{dependsOn:2,isNonSyncSample:0}),d(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),Lt=l((function e(t,r){u(this,e),d(this,"time",0),this.data=t,this.originPts=this.pts=r})),Ot=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(Lt),Rt=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(Lt),Pt=function(){function e(){u(this,e),d(this,"id",3),d(this,"type",ft),d(this,"timescale",0),d(this,"flvScriptSamples",[]),d(this,"seiSamples",[])}return l(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}(),Bt=function(){function e(t){if(u(this,e),d(this,"_bytesAvailable",void 0),d(this,"_bitsAvailable",0),d(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return l(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}(),Ut=function(){function e(t){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return l(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}();d(Ut,"disabled",!0);var Mt=function(){function e(){u(this,e)}return l(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,s=t.length;i<s;)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 a=(31&n[i])<<6|63&n[i+1];if(a>=128){r.push(String.fromCharCode(65535&a)),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}(),It="undefined"!=typeof window,Ft=It&&navigator.userAgent.toLocaleLowerCase(),Nt=It&&/^((?!chrome|android).)*safari/.test(Ft),qt=It&&Ft.includes("firefox"),zt=It&&Ft.includes("android");function Vt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function Gt(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 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 Kt(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)}))}var Wt=function(){function e(){u(this,e)}return l(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 s=i,a=[],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),h=(1&t[i+2])<<2|(192&t[i+3])>>>6,f=e._getConfig(o,h,d),p=f.config,v=f.codec,y=0,m=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(!(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5)||n-i<l)break;c=2*(1&~t[i+1]),a.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:s,remaining:i>=n?void 0:t.subarray(i),frames:a,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:h,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,s=e.FREQ[n];if(s){var a=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:s,objectType:r,channelCount:i,config:a.config,codec:a.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,s=[];return qt?e>=6?(n=5,i=e-3):(n=2,i=e):zt?(n=2,i=e):(n=5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),s[0]=n<<3,s[0]|=(14&e)>>1,s[1]=(1&e)<<7,s[1]|=t<<3,5===n&&(s[1]|=(14&i)>>1,s[2]=(1&i)<<7,s[2]|=8,s[3]=0),{config:s,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}();d(Wt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Yt=function(){function e(){u(this,e)}return l(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,s=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((s=++i+2)>=n)return[];for(var a=[];s<n;)switch(e[s]){case 0:if(0!==e[s-1]){s+=2;break}if(0!==e[s-2]){s++;break}if(s<n-1&&1!==e[s+1]){s++;break}i!==s-2&&a.push(e.subarray(i,s-2));do{s++}while(1!==e[s]&&s<n);s=(i=s+1)+2;break;case 1:if(0!==e[s-1]||0!==e[s-2]){s+=3;break}i!==s-2&&a.push(e.subarray(i,s-2)),s=(i=s+1)+2;break;default:s+=3}return i<n&&a.push(e.subarray(i)),a}},{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=[],s=0;s+t<n;)if(r=Gt(e,s),3===t&&(r>>>=8),s+=t,r){if(s+r>n)break;i.push(e.subarray(s,s+r)),s+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,s=0,a="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)s+=255,n++;if(s+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)a+=e[n].toString(16),n++;return{payload:e.subarray(n,n+s),type:i,size:s,uuid:a}}},{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,s=new Uint8Array(i),a=0;for(n=0;n<i;a++,n++)a===r[0]&&(a++,r.shift()),s[n]=e[a];return s}}]),e}(),Qt=function(){function e(){u(this,e)}return l(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),s=[],a=[],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,s.push(l),r||(r=e.parseSPS(Yt.removeEPB(l)))}var d,h=t[o];o++;for(var f=0;f<h;f++)d=t[o]<<8|t[o+1],o+=2,d&&(a.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:s,ppsArr:a,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Bt(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var s=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 a=t.readUEG();if(a<=3&&(s=[0,420,422,444][a]),3===a&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==a?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 h=t.readUEG(),f=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,y,m,_,g,b=0,k=0,w=0,x=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),w=t.readUEG(),x=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:v=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var S=t.readBits(32),E=t.readBits(32);y=t.readBool(),g=(m=E)/(_=2*S)}}return{codec:Ht(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:s,width:Math.ceil(16*(h+1)-2*(b+k)),height:(2-p)*(f+1)*16-(p?2:4)*(w+x),sarRatio:v,fpsNum:m,fpsDen:_,fps:g,fixedFrame:y}}}]),e}(),Jt=function(){function e(){u(this,e)}return l(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,s,a,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){s=63&t[h],a=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<a;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(s){case 32:var y=t.subarray(h,h+o);n||(n=e.parseVPS(Yt.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(h,h+o);i||(i=e.parseSPS(Yt.removeEPB(m),r)),c.push(m);break;case 34:l.push(t.subarray(h,h+o))}h+=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 Bt(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 Bt(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 s=r.chromaFormatIdc=n.readUEG(),a=420;s<=3&&(a=[0,420,422,444][s]);var o=0;3===s&&(o=n.readBits(1));var u,c,l,d,h=n.readUEG(),f=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!==s&&2!==s||0!==o?1:2,y=1===s&&0===o?2:1;h-=v*(c+u),f-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:a,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 s=[],a=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)s[o]=e.readBits(1),a[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==s[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!==a[u]&&e.readBits(8)}}]),e}(),Xt=function(){function e(){u(this,e)}return l(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 s=t.getUint32(12,!0),a=t.getInt16(16,!0);if(s){return{outputGain:a,sampleRate:s,channelCount:i,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}}]),e}(),Zt=1e3,$t=5e3,er=function(){function e(t,r,n){u(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 l(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,s=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(s,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var a=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(a&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),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),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.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],s=e.samples[r.length-1];n=Math.floor((s.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var a=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=a,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 h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:xt,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(h=r[1])||void 0===h?void 0:h.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 f=0;f<u;f++){var p=r[f].dts,v=r[f+1];((c=f<u-1?v.dts-p:a?a.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:wt,time:p/e.timescale,dts:p,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[f].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,s=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=s=n[0].dts),this._baseDts=Math.min(i,s);var a=s-i;return Number.isFinite(a)&&Math.abs(a)>500&&t.warnings.push({type:kt,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),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 yt:e.sampleDuration=Wt.getFrameDuration(e.timescale,r);break;case gt:e.sampleDuration=Xt.getFrameDuration(e.samples,r);break;case mt:case _t:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===gt?20:e.codecType===yt?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var s=t[0];this._audioNextPts=s.pts}for(var a=0;a<t.length;a++){var o=this._audioNextPts,u=t[a],c=u.pts-o;if(0===a&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=Zt&&!Nt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>$t&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:Et,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new At(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(a,0,f),this._audioNextPts+=n,a++}a--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>$t&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:Tt,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(a,1),a--;else{if(Math.abs(c)>Zt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>$t&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:St,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===gt){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===yt?Wt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),tr=function(){function e(){u(this,e)}return l(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,s=!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 a=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=a.data,i+=a.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 h=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),f=h.size,p=h.data;if(h.isEnd)break;r[p.name]=p.value,i+=f}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,s=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),_=m.data,g=m.size;r.push(_),i+=g}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=Mt.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Mt.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}(),rr=7,nr=8,ir=10,sr=13,ar=new Ut("FlvDemuxer"),or=function(){function e(t,r,n){u(this,e),d(this,"_headerParsed",!1),d(this,"_remainingData",null),d(this,"_gopId",0),d(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new jt,this.audioTrack=r||new Ct,this.metadataTrack=n||new Pt,this._fixer=new er(this.videoTrack,this.audioTrack,this.metadataTrack)}return l(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],s=arguments.length>3?arguments[3]:void 0,a=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!n&&i||(this._remainingData=null),n&&(this._headerParsed=!1),n?(o.reset(),a.reset(),u.reset()):(o.samples=[],a.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],a.warnings=[],this._remainingData&&(t=Vt(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:a,metadataTrack:u};var c=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");a.present=(4&t[4])>>>2!=0,o.present=0!=(1&t[4]),this._headerParsed=!0,c=Gt(t,5)+4}for(var l,d,h,f,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));)h=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,f=t.subarray(c,c+d),8===l?this._parseAudio(f,h):9===l?(s&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,h)):18===l?this._parseScript(f,h):ar.warn("Invalid tag type: ".concat(l)),(p=Gt(t,c+=d))!==11+d&&ar.warn("Invalid PrevTagSize ".concat(p," (").concat(11+d,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),a.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,a.timescale=a.codecType===gt?1e3:a.sampleRate||0,!a.exist()&&a.hasSample()&&a.reset(),!o.exist()&&o.hasSample()&&o.reset();var y=u.flvScriptSamples[u.flvScriptSamples.length-1],m=null==y||null===(r=y.data)||void 0===r?void 0:r.onMetaData;return m&&(null!=o&&o.exist()&&(m.hasOwnProperty("duration")&&(o.duration=1e3*m.duration),!o.width&&m.hasOwnProperty("width")&&(o.width=m.width),!o.height&&m.hasOwnProperty("height")&&(o.height=m.height)),null!=a&&a.exist()&&m.hasOwnProperty("duration")&&(a.duration=1e3*m.duration)),{videoTrack:o,audioTrack:a,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!==ir&&n!==rr&&n!==nr&&n!==sr)return ar.warn("Unsupported sound format: ".concat(n)),void i.reset();if(n!==ir&&n!==sr){var s=(12&t[0])>>2,a=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[s],i.sampleSize=a?16:8,i.channelCount=o+1}switch(n){case rr:case nr:this._parseG711(t,r,n);break;case ir:this._parseAac(t,r);break;case sr:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=gt,n){case 0:var i=Xt.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=Xt.getFrameDuration([],r.timescale)):(r.reset(),ar.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var s=new At(t,e.subarray(2),r.sampleDuration);r.samples.push(s);break;default:ar.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 s=new At(t,i);n.codecType=7===r?mt:_t,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(s)}}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=yt,0===e[1]){var n=Wt.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(),ar.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new At(t,e.subarray(2)))}else ar.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],s=this.videoTrack;if(7!==i&&12!==i)return s.reset(),void ar.warn("Unsupported codecId: ".concat(i));var a=12===i;s.codecType=a?vt:pt;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=a?Jt.parseHEVCDecoderConfigurationRecord(c):Qt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(s.hvcC=s.hvcC||d),h&&(s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen),p.length&&(s.sps=p),f.length&&(s.pps=f),v&&v.length&&(s.vps=v),y&&(s.nalUnitSize=y)}else ar.warn("Cannot parse ".concat(a?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=Yt.parseAvcC(e.subarray(5),s.nalUnitSize);if((m=this._checkAddMetaNalToUnits(a,m,s))&&m.length){var _=new Dt(t+u,t,m);if(this.seamlessLoadingSwitching&&t<s.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(_.setToKeyframe(),s.lastKeyFrameDts=t),s.samples.push(_),m.forEach((function(e){var n=a?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(!a&&5!==n||a&&5===n)break;_.setToKeyframe();break;case 6:case 39:case 40:if(!a&&6!==n||a&&6===n)break;r.metadataTrack.seiSamples.push(new Rt(Yt.parseSEI(Yt.removeEPB(e),a),t+u))}})),_.keyframe&&this._gopId++,_.gopId=this._gopId}else ar.warn("Cannot parse NALUs",e)}else 2===o||ar.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 Ot(tr.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Gt(e,5)>=9}}]),e}();function ur(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 s=new e(t),a=0;return n.forEach((function(e){s.set(e,a),a+=e.length})),s}d(or,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Ut("TsDemuxer");var cr=function(){function e(){u(this,e),this.buffer=new Uint8Array(0)}return l(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=ur(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}(),lr=Math.pow(2,32)-1,dr=function(){function e(){u(this,e)}return l(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),s=new Uint8Array(i);s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4);var a=8;return r.forEach((function(e){s.set(e,a),a+=e.byteLength})),s}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===dt&&e.codecType===vt}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Vt(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],Kt(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(E(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(E(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,s=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 s}},{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===dt?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===gt?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]),s=e.esds(t.config),a=e.sinf(t.enca);return e.box(e.types.enca,i,s,a)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],s=t.pps.length>0?t.pps[0]:[],a=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,a>>8&255,255&a,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,E(i)).concat([1,s.length>>>8&255,255&s.length])).concat.apply(r,E(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),p=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c]);return e.box(e.types.encv,l,e.box(e.types.avcC,d),e.box(e.types.btrt,h),f,e.box(e.types.pasp,p))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Kt(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]),s=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),s)}},{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===vt,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),s=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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?s.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&s.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(s))}},{key:"avcC",value:function(t){var r,n,i,s=[],a=[];return t.sps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,E(e))})),t.pps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,E(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,s[3],s[4],s[5],255,224|t.sps.length]).concat.apply(n,s).concat([t.pps.length])).concat.apply(r,a)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,s=t.sps,a=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(s.length&&1)+(a.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,E(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),s.length&&(n.push(161,0,s.length),s.forEach(l)),a.length&&(n.push(162,0,a.length),a.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=S(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(E(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(E(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 s=e.saiz(t),a=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,s,a,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),h=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,h,f)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var y=e.trun1(t);return e.box(e.types.traf,r,n,y)}var m=e.sbgp(),_=e.saiz(t),g=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,m,_,g,b,k)}var w=e.sdtp(t);return e.box(e.types.traf,r,n,w,e.trun(t.samples,w.byteLength+76))}},{key:"sdtp",value:function(t){var r=new cr;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 cr,n=cr.writeUint32(t.samples.length),i=null;if(t.isVideo){var s=t.videoSencLength;i=cr.writeUint32(16*t.samples.length+s+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=cr.writeUint32(16*t.samples.length+92))}else{var a=12*t.samples.length+124;t.isAudioEncryption&&(a=12*t.samples.length+8*t.audioSenc.length+177),i=cr.writeUint32(a)}return t.samples.forEach((function(e){r.write(cr.writeUint32(e.duration)),r.write(cr.writeUint32(e.size)),r.write(cr.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(cr.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 cr,n=t.samples.length,i=t.isVideo?16:8,s=t.isVideo?2:0,a=[],o=0;return t.isVideo?(a=t.videoSenc,o=t.videoSencLength):a=t.audioSenc,o=o||i*n,r.write(cr.writeUint32(16+o),e.types.senc,this.extension(0,s)),r.write(cr.writeUint32(n)),a.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(cr.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(cr.writeUint16(e.BytesOfClearData)),r.write(cr.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/(lr+1)),i=Math.floor(r%(lr+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 s=new Uint8Array(i);s.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 a=0;a<n;a++){var o=t[a],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;s.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,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*a)}return e.box(e.types.trun,s)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(E(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===dt?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,Vt(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,s=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s],i),i+=12})),e.box(e.types.stsc,Vt(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,Vt(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,Vt(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,Vt(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,Vt(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,s=t.samples[0].sampleOffset*n,a=8;t.samples.forEach((function(e){a+=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=a+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=a+16*t.samples.length+84)}else o=a+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=a+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,s>>24&255,s>>16&255,s>>8&255,255&s,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}();d(dr,"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))),d(dr,"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])}),d(dr,"FTYPAVC1",dr.box(dr.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),d(dr,"FTYPHEV1",dr.box(dr.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),d(dr,"DINF",dr.box(dr.types.dinf,dr.box(dr.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),d(dr,"VMHD",dr.box(dr.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),d(dr,"SMHD",dr.box(dr.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),d(dr,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),d(dr,"STTS",dr.box(dr.types.stts,dr.StblTable)),d(dr,"STSC",dr.box(dr.types.stsc,dr.StblTable)),d(dr,"STSZ",dr.box(dr.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),d(dr,"STCO",dr.box(dr.types.stco,dr.StblTable));var hr=function(){function e(t,r){u(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return l(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}();d(hr,"disabled",!0);for(var fr=function(){function e(t,r,n){u(this,e),this.videoTrack=t,this.audioTrack=r;var i=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=i&&Number(i[1])<50,this.log=new hr("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return l(e,[{key:"remux",value:function(){var e,t,r,n,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,c=o.exist(),l=u.exist(),d=[];return s&&(a&&a.initMerge?(c&&d.push(this.videoTrack),l&&d.push(this.audioTrack),r=dr.initSegment(d)):(c&&(e=dr.initSegment([this.videoTrack])),l&&(t=dr.initSegment([this.audioTrack])))),c&&o.hasSample()&&(n=this._remuxVideo()),l&&u.hasSample()&&(i=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:i}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),n=0;r?t.forEach((function(e){n+=e.data.byteLength})):t.forEach((function(e){n+=e.units.reduce((function(e,t){return e+t.byteLength}),0),n+=4*e.units.length}));var i=new Uint8Array(n);if(r)for(var s,a=0,o=t.length,u=0;a<o;a++)s=t[a],i.set(s.data,u),s.size=s.data.byteLength,u+=s.size;else for(var c,l=new DataView(i.buffer),d=function(e,r){r=t[h];var n=0;r.units.forEach((function(t){l.setUint32(e,t.byteLength),e+=4,i.set(t,e),e+=t.byteLength,n+=4+t.byteLength})),r.size=n,p=e,c=r},h=0,f=t.length,p=0;h<f;h++)d(p,c);var v=dr.mdat(i);return Vt(dr.moof([e]),v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=dr.mdat(t);return Vt(dr.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),pr=function(){function e(){u(this,e)}return l(e,[{key:"mixIn",value:function(e){return Object.assign(this,e)}},{key:"clone",value:function(){var e=new this.constructor;return Object.assign(e,this),e}}],[{key:"create",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return y(this,t)}}]),e}(),vr=function(e){h(r,e);var t=k(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4*n.length;u(this,r),e=t.call(this);var s=n;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),(s instanceof Int8Array||s instanceof Uint8ClampedArray||s instanceof Int16Array||s instanceof Uint16Array||s instanceof Int32Array||s instanceof Uint32Array||s instanceof Float32Array||s instanceof Float64Array)&&(s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),s instanceof Uint8Array){for(var a=s.byteLength,o=[],c=0;c<a;c+=1)o[c>>>2]|=s[c]<<24-c%4*8;e.words=o,e.sigBytes=a}else e.words=n,e.sigBytes=i;return e}return l(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yr;return e.stringify(this)}},{key:"concat",value:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s+=1){var a=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=a<<24-(n+s)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this}},{key:"clamp",value:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=Math.ceil(t/4)}},{key:"clone",value:function(){var e=x(f(r.prototype),"clone",this).call(this);return e.words=this.words.slice(0),e}}],[{key:"random",value:function(e){for(var t,n=[],i=function(e){var t=e,r=987654321,n=4294967295;return function(){var e=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return e/=4294967296,(e+=.5)*(Math.random()>.5?1:-1)}},s=0;s<e;s+=4){var a=i(4294967296*(t||Math.random()));t=987654071*a(),n.push(4294967296*a()|0)}return new r(n,e)}}]),r}(pr),yr={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new vr(r,t/2)}},mr=function(e){for(var t=e.length,r=[],n=0;n<t;n+=1)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new vr(r,t)},_r=function(e){return mr(unescape(encodeURIComponent(e)))},gr=function(e){h(r,e);var t=k(r);function r(){var e;return u(this,r),(e=t.call(this))._minBufferSize=0,e}return l(r,[{key:"reset",value:function(){this._data=new vr,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=_r(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}},{key:"_process",value:function(e){var t,r=this._data,n=this.blockSize,i=r.words,s=r.sigBytes,a=s/(4*n),o=(a=e?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0))*n,u=Math.min(4*o,s);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new vr(t,u)}},{key:"clone",value:function(){var e=x(f(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(pr),br=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new pr,e),n.reset(),n}return l(r,[{key:"reset",value:function(){x(f(r.prototype),"reset",this).call(this),this._doReset()}},{key:"update",value:function(e){return this._append(e),this._process(),this}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"_createHelper",value:function(e){return function(t,r){return new e(r).finalize(t)}}},{key:"_createHmacHelper",value:function(e){return function(t,r){return new kr(e,r).finalize(t)}}}]),r}(gr),kr=function(e){h(r,e);var t=k(r);function r(e,n){var i;u(this,r),i=t.call(this);var s=new e;i._hasher=s;var a=n;"string"==typeof a&&(a=_r(a));var o=s.blockSize,c=4*o;a.sigBytes>c&&(a=s.finalize(n)),a.clamp();var l=a.clone();i._oKey=l;var d=a.clone();i._iKey=d;for(var h=l.words,f=d.words,p=0;p<o;p+=1)h[p]^=1549556828,f[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return l(r,[{key:"reset",value:function(){var e=this._hasher;e.reset(),e.update(this._iKey)}},{key:"update",value:function(e){return this._hasher.update(e),this}},{key:"finalize",value:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}}]),r}(pr),wr={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var a=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;o<4&&s+.75*o<r;o+=1)i.push(n.charAt(a>>>6*(3-o)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){this._reverseMap=[],n=this._reverseMap;for(var i=0;i<r.length;i+=1)n[r.charCodeAt(i)]=i}var s=r.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,s=0;s<t;s+=1)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2|r[e.charCodeAt(s)]>>>6-s%4*2;n[i>>>2]|=a<<24-i%4*8,i+=1}return vr.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},xr=[],Sr=0;Sr<64;Sr+=1)xr[Sr]=4294967296*Math.abs(Math.sin(Sr+1))|0;var Er=function(e,t,r,n,i,s,a){var o=e+(t&r|~t&n)+i+a;return(o<<s|o>>>32-s)+t},Tr=function(e,t,r,n,i,s,a){var o=e+(t&n|r&~n)+i+a;return(o<<s|o>>>32-s)+t},jr=function(e,t,r,n,i,s,a){var o=e+(t^r^n)+i+a;return(o<<s|o>>>32-s)+t},Cr=function(e,t,r,n,i,s,a){var o=e+(r^(t|~n))+i+a;return(o<<s|o>>>32-s)+t},Dr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"_doReset",value:function(){this._hash=new vr([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,s=e[i];r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],h=r[t+5],f=r[t+6],p=r[t+7],v=r[t+8],y=r[t+9],m=r[t+10],_=r[t+11],g=r[t+12],b=r[t+13],k=r[t+14],w=r[t+15],x=a[0],S=a[1],E=a[2],T=a[3];x=Er(x,S,E,T,o,7,xr[0]),T=Er(T,x,S,E,u,12,xr[1]),E=Er(E,T,x,S,c,17,xr[2]),S=Er(S,E,T,x,l,22,xr[3]),x=Er(x,S,E,T,d,7,xr[4]),T=Er(T,x,S,E,h,12,xr[5]),E=Er(E,T,x,S,f,17,xr[6]),S=Er(S,E,T,x,p,22,xr[7]),x=Er(x,S,E,T,v,7,xr[8]),T=Er(T,x,S,E,y,12,xr[9]),E=Er(E,T,x,S,m,17,xr[10]),S=Er(S,E,T,x,_,22,xr[11]),x=Er(x,S,E,T,g,7,xr[12]),T=Er(T,x,S,E,b,12,xr[13]),E=Er(E,T,x,S,k,17,xr[14]),S=Er(S,E,T,x,w,22,xr[15]),x=Tr(x,S,E,T,u,5,xr[16]),T=Tr(T,x,S,E,f,9,xr[17]),E=Tr(E,T,x,S,_,14,xr[18]),S=Tr(S,E,T,x,o,20,xr[19]),x=Tr(x,S,E,T,h,5,xr[20]),T=Tr(T,x,S,E,m,9,xr[21]),E=Tr(E,T,x,S,w,14,xr[22]),S=Tr(S,E,T,x,d,20,xr[23]),x=Tr(x,S,E,T,y,5,xr[24]),T=Tr(T,x,S,E,k,9,xr[25]),E=Tr(E,T,x,S,l,14,xr[26]),S=Tr(S,E,T,x,v,20,xr[27]),x=Tr(x,S,E,T,b,5,xr[28]),T=Tr(T,x,S,E,c,9,xr[29]),E=Tr(E,T,x,S,p,14,xr[30]),S=Tr(S,E,T,x,g,20,xr[31]),x=jr(x,S,E,T,h,4,xr[32]),T=jr(T,x,S,E,v,11,xr[33]),E=jr(E,T,x,S,_,16,xr[34]),S=jr(S,E,T,x,k,23,xr[35]),x=jr(x,S,E,T,u,4,xr[36]),T=jr(T,x,S,E,d,11,xr[37]),E=jr(E,T,x,S,p,16,xr[38]),S=jr(S,E,T,x,m,23,xr[39]),x=jr(x,S,E,T,b,4,xr[40]),T=jr(T,x,S,E,o,11,xr[41]),E=jr(E,T,x,S,l,16,xr[42]),S=jr(S,E,T,x,f,23,xr[43]),x=jr(x,S,E,T,y,4,xr[44]),T=jr(T,x,S,E,g,11,xr[45]),E=jr(E,T,x,S,w,16,xr[46]),S=jr(S,E,T,x,c,23,xr[47]),x=Cr(x,S,E,T,o,6,xr[48]),T=Cr(T,x,S,E,p,10,xr[49]),E=Cr(E,T,x,S,k,15,xr[50]),S=Cr(S,E,T,x,h,21,xr[51]),x=Cr(x,S,E,T,g,6,xr[52]),T=Cr(T,x,S,E,l,10,xr[53]),E=Cr(E,T,x,S,m,15,xr[54]),S=Cr(S,E,T,x,u,21,xr[55]),x=Cr(x,S,E,T,v,6,xr[56]),T=Cr(T,x,S,E,w,10,xr[57]),E=Cr(E,T,x,S,f,15,xr[58]),S=Cr(S,E,T,x,b,21,xr[59]),x=Cr(x,S,E,T,d,6,xr[60]),T=Cr(T,x,S,E,_,10,xr[61]),E=Cr(E,T,x,S,c,15,xr[62]),S=Cr(S,E,T,x,y,21,xr[63]),a[0]=a[0]+x|0,a[1]=a[1]+S|0,a[2]=a[2]+E|0,a[3]=a[3]+T|0}},{key:"_doFinalize",value:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var i=Math.floor(r/4294967296),s=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var a=this._hash,o=a.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return a}},{key:"clone",value:function(){var e=x(f(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(br);br._createHelper(Dr),br._createHmacHelper(Dr);var Ar=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).cfg=Object.assign(new pr,{keySize:4,hasher:Dr,iterations:1},e),n}return l(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),s=vr.create(),a=s.words,o=n.keySize,u=n.iterations;a.length<o;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var c=1;c<u;c+=1)r=i.finalize(r),i.reset();s.concat(r)}return s.sigBytes=4*o,s}}]),r}(pr),Lr=function(e){h(r,e);var t=k(r);function r(e,n,i){var s;return u(this,r),(s=t.call(this)).cfg=Object.assign(new pr,i),s._xformMode=e,s._key=n,s.reset(),s}return l(r,[{key:"reset",value:function(){x(f(r.prototype),"reset",this).call(this),this._doReset()}},{key:"process",value:function(e){return this._append(e),this._process()}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"createEncryptor",value:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)}},{key:"createDecryptor",value:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)}},{key:"_createHelper",value:function(e){var t=function(e){return"string"==typeof e?qr:Fr};return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}]),r}(gr);Lr._ENC_XFORM_MODE=1,Lr._DEC_XFORM_MODE=2,Lr.keySize=4,Lr.ivSize=4;var Or=function(e){h(r,e);var t=k(r);function r(e,n){var i;return u(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return l(r,null,[{key:"createEncryptor",value:function(e,t){return this.Encryptor.create(e,t)}},{key:"createDecryptor",value:function(e,t){return this.Decryptor.create(e,t)}}]),r}(pr);function Rr(e,t,r){var n,i=e,s=this._iv;s?(n=s,this._iv=void 0):n=this._prevBlock;for(var a=0;a<r;a+=1)i[t+a]^=n[a]}var Pr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(Or);Pr.Encryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;Rr.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(Pr),Pr.Decryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),Rr.call(this,e,t,n),this._prevBlock=i}}]),r}(Pr);var Br={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);var o=vr.create(s,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},Ur=function(e){h(r,e);var t=k(r);function r(e,n,i){var s;return u(this,r),(s=t.call(this,e,n,Object.assign({mode:Pr,padding:Br},i))).blockSize=4,s}return l(r,[{key:"reset",value:function(){var e;x(f(r.prototype),"reset",this).call(this);var t=this.cfg,n=t.iv,i=t.mode;this._xformMode===this.constructor._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode=e.call(i,this,n&&n.words),this._mode.__creator=e}},{key:"_doProcessBlock",value:function(e,t){this._mode.processBlock(e,t)}},{key:"_doFinalize",value:function(){var e,t=this.cfg.padding;return this._xformMode===this.constructor._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e}}]),r}(Lr),Mr=function(e){h(r,e);var t=k(r);function r(e){var n;return u(this,r),(n=t.call(this)).mixIn(e),n}return l(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(pr),Ir={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?vr.create([1398893684,1701076831]).concat(r).concat(t):t).toString(wr)},parse:function(e){var t,r=wr.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=vr.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),Mr.create({ciphertext:r,salt:t})}},Fr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new pr,this.cfg,n),s=e.createEncryptor(r,i),a=s.finalize(t),o=s.cfg;return Mr.create({ciphertext:a,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:s.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new pr,this.cfg,n);return i=this._parse(i,s.format),e.createDecryptor(r,s).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(pr);Fr.cfg=Object.assign(new pr,{format:Ir});var Nr={execute:function(e,t,r,n){var i=n;i||(i=vr.random(8));var s=Ar.create({keySize:t+r}).compute(e,i),a=vr.create(s.words.slice(t),4*r);return s.sigBytes=4*t,Mr.create({key:s,iv:a,salt:i})}},qr=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new pr,this.cfg,n),s=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=s.iv;var a=Fr.encrypt.call(this,e,t,s.key,i);return a.mixIn(s),a}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new pr,this.cfg,n);i=this._parse(i,s.format);var a=s.kdf.execute(r,e.keySize,e.ivSize,i.salt);return s.iv=a.iv,Fr.decrypt.call(this,e,i,a.key,s)}}]),r}(Fr);qr.cfg=Object.assign(Fr.cfg,{kdf:Nr});for(var zr=[],Vr=[],Gr=[],Hr=[],Kr=[],Wr=[],Yr=[],Qr=[],Jr=[],Xr=[],Zr=[],$r=0;$r<256;$r+=1)Zr[$r]=$r<128?$r<<1:$r<<1^283;for(var en=0,tn=0,rn=0;rn<256;rn+=1){var nn=tn^tn<<1^tn<<2^tn<<3^tn<<4;nn=nn>>>8^255&nn^99,zr[en]=nn,Vr[nn]=en;var sn=Zr[en],an=Zr[sn],on=Zr[an],un=257*Zr[nn]^16843008*nn;Gr[en]=un<<24|un>>>8,Hr[en]=un<<16|un>>>16,Kr[en]=un<<8|un>>>24,Wr[en]=un,un=16843009*on^65537*an^257*sn^16843008*en,Yr[nn]=un<<24|un>>>8,Qr[nn]=un<<16|un>>>16,Jr[nn]=un<<8|un>>>24,Xr[nn]=un,en?(en=sn^Zr[Zr[Zr[on^sn]]],tn^=Zr[Zr[tn]]):en=tn=1}var cn=[0,1,2,4,8,16,32,64,128,27,54],ln=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"_doReset",value:function(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){this._keyPriorReset=this._key;var t=this._keyPriorReset,r=t.words,n=t.sigBytes/4;this._nRounds=n+6;var i=4*(this._nRounds+1);this._keySchedule=[];for(var s=this._keySchedule,a=0;a<i;a+=1)a<n?s[a]=r[a]:(e=s[a-1],a%n?n>6&&a%n==4&&(e=zr[e>>>24]<<24|zr[e>>>16&255]<<16|zr[e>>>8&255]<<8|zr[255&e]):(e=zr[(e=e<<8|e>>>24)>>>24]<<24|zr[e>>>16&255]<<16|zr[e>>>8&255]<<8|zr[255&e],e^=cn[a/n|0]<<24),s[a]=s[a-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?s[c]:s[c-4],o[u]=u<4||c<=4?e:Yr[zr[e>>>24]]^Qr[zr[e>>>16&255]]^Jr[zr[e>>>8&255]]^Xr[zr[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,Gr,Hr,Kr,Wr,zr)}},{key:"decryptBlock",value:function(e,t){var r=e,n=r[t+1];r[t+1]=r[t+3],r[t+3]=n,this._doCryptBlock(r,t,this._invKeySchedule,Yr,Qr,Jr,Xr,Vr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,s,a,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],h=u[t+2]^r[2],f=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var y=n[l>>>24]^i[d>>>16&255]^s[h>>>8&255]^a[255&f]^r[p];p+=1;var m=n[d>>>24]^i[h>>>16&255]^s[f>>>8&255]^a[255&l]^r[p];p+=1;var _=n[h>>>24]^i[f>>>16&255]^s[l>>>8&255]^a[255&d]^r[p];p+=1;var g=n[f>>>24]^i[l>>>16&255]^s[d>>>8&255]^a[255&h]^r[p];p+=1,l=y,d=m,h=_,f=g}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&f])^r[p];p+=1;var k=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[f>>>8&255]<<8|o[255&l])^r[p];p+=1;var w=(o[h>>>24]<<24|o[f>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var x=(o[f>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=w,u[t+3]=x}}]),r}(Ur);ln.keySize=8,Ur._createHelper(ln);var dn=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r)}(Or);dn.Encryptor=function(e){h(r,e);var t=k(r);function r(){return u(this,r),t.apply(this,arguments)}return l(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,s=this._iv,a=this._counter;s&&(this._counter=s.slice(0),a=this._counter,this._iv=void 0);var o=a.slice(0);n.encryptBlock(o,0),a[i-1]=a[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(dn),dn.Decryptor=dn.Encryptor;var hn=function(){function e(){u(this,e),d(this,"_ttfb",0),d(this,"_demuxStart",0),d(this,"_demuxEnd",0),d(this,"_demuxCost",0),d(this,"_remuxStart",0),d(this,"_remuxEnd",0),d(this,"_remuxCost",0),d(this,"_appendStart",0),d(this,"_appendEnd",0),d(this,"_appendCost",0)}return l(e,[{key:"set",value:function(e,t){this["_".concat(e)]=t}},{key:"start",value:function(e){this["_".concat(e,"Start")]=Date.now()}},{key:"end",value:function(e){this["_".concat(e,"End")]=Date.now(),this["_".concat(e,"Cost")]=this["_".concat(e,"Cost")]+(this["_".concat(e,"End")]-this["_".concat(e,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),e}(),fn="ttfb",pn="demux",vn="remux",yn="append",mn=new Y("BufferService"),_n=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),d(this,"flv",null),d(this,"_demuxer",new or),d(this,"_remuxer",null),d(this,"_mse",null),d(this,"_softVideo",null),d(this,"_sourceCreated",!1),d(this,"_needInitSegment",!0),d(this,"_discontinuity",!0),d(this,"_contiguous",!1),d(this,"_initSegmentId",""),d(this,"_cachedBuffer",null),d(this,"_demuxStartTime",0),d(this,"_opts",null),this.flv=t,this._opts=n,r?this._softVideo=r:(this._remuxer=new fr(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new ae(null,{preferMMS:"boolean"==typeof n.preferMMS?n.preferMMS:!!n.perferMMS}),this._mse.bindMedia(t.media))}var t,r,s,a,c,h;return l(e,[{key:"baseDts",get:function(){var e,t;return null===(e=this._demuxer)||void 0===e||null===(t=e._fixer)||void 0===t?void 0:t._baseDts}},{key:"blobUrl",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.url}},{key:"isFull",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ae.VIDEO;return this._mse.isFull(e)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(e){this._contiguous=!1,this._demuxStartTime=e}},{key:"reset",value:(h=o(i().mark((function e(){var t,r=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=6;break}return e.next=4,this._mse.unbindMedia();case 4:return e.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:(c=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.flv.emit(Ae);case 5:e.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"updateDuration",value:(a=o(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return mn.debug("update duration",t),e.next=7,this._mse.updateDuration(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"destroy",value:(s=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"appendBuffer",value:(r=o(i().mark((function e(t){var r,n,s,a,o,u,c,l,d,h,f,p,v,y,m,_,g,b,k=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!1,this._cachedBuffer&&(t=nt(this._cachedBuffer,t),this._cachedBuffer=null),n=this._demuxer,t&&t.length&&n){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,this.flv._transferCost.start(pn),n.demuxAndFix(t,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(pn),e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(5),new H(M,V.FLV,e.t0);case 15:if(s=n.videoTrack,a=n.audioTrack,o=n.metadataTrack,!this.seamlessLoadingSwitch){e.next=25;break}if(!((u=s.samples.findIndex((function(e){return e.originDts===s.lastKeyFrameDts})))>=0)){e.next=25;break}return s.samples.splice(u),e.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,t=null,r=!0;case 25:if(c=s.exist(),l=a.exist(),this._opts.onlyAudio&&(c=!1,s.present=!1),this._opts.onlyVideo&&(l=!1,a.present=!1),!(!c&&s.present||!l&&a.present)){e.next=42;break}if(d=0,(h=c?s:l?a:void 0)&&h.samples.length&&(d=(h.samples[h.samples.length-1].originPts-h.samples[0].originPts)/h.timescale*1e3),!(d>this._opts.analyzeDuration)){e.next=40;break}mn.warn("analyze duration exceeded, ".concat(d,"ms"),h),s.present=c,a.present=l,this.flv.emit(je,{duration:d}),e.next=42;break;case 40:return this._cachedBuffer=t,e.abrupt("return");case 42:if(f=s.type,p=a.type,this._fireEvents(s,a,o),r||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),v=this._mse,y=function(){var e,t;null!==(e=k.flv)&&void 0!==e&&e.emit&&(null===(t=k.flv)||void 0===t||t.emit(Ce,{}))},this.flv.emit(Ne,{videoTrack:s}),(m="".concat(s.codec,"/").concat(s.width,"/").concat(s.height,"/").concat(a.codec,"/").concat(a.config))!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=m,this._emitMetaParsedEvent(s,a)),!v){e.next=83;break}if(this._sourceCreated){e.next=59;break}return e.next=55,v.open();case 55:c&&(mn.log("codec: video/mp4;codecs=".concat(s.codec)),v.createSource(f,"video/mp4;codecs=".concat(s.codec))),l&&(mn.log("codec: audio/mp4;codecs=".concat(a.codec)),v.createSource(p,"audio/mp4;codecs=".concat(a.codec))),this._sourceCreated=!0,this.flv.emit(Te);case 59:e.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(s.duration=this._opts.durationForMSELowLatencyOff*s.timescale,a.duration=this._opts.durationForMSELowLatencyOff*l.timescale),this.flv._transferCost.start(vn),_=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(vn),e.next=69;break;case 66:throw e.prev=66,e.t1=e.catch(59),new H(I,V.FMP4,e.t1);case 69:if(!this._needInitSegment||_.videoInitSegment||_.audioInitSegment){e.next=71;break}return e.abrupt("return");case 71:return this._needInitSegment=!1,g=[],_.videoInitSegment&&g.push(v.append(f,_.videoInitSegment)),_.audioInitSegment&&g.push(v.append(p,_.audioInitSegment)),_.videoSegment&&g.push(v.append(f,_.videoSegment)),_.audioSegment&&g.push(v.append(p,_.audioSegment)),this.flv._transferCost.start(yn),(b=Promise.all(g)).then(y).then((function(){k.flv._transferCost.end(yn),y()})),e.abrupt("return",b);case 83:this._softVideo&&(this._softVideo.appendBuffer(s,a),y());case 84:case"end":return e.stop()}}),e,this,[[5,12],[59,66]])}))),function(e){return r.apply(this,arguments)})},{key:"evictBuffer",value:(t=o(i().mark((function e(t){var r,n,s,a=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.flv.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(n=r.currentTime,!((s=n-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(A.start(A.get(r))+1>=s)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this._mse.clearBuffer(0,s).then((function(){return a.flv.emit(De,{removeEnd:s})})));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_emitMetaParsedEvent",value:function(e,t){e.exist()&&this.flv.emit(Re,{type:"video",track:e,meta:{codec:e.codec,timescale:e.timescale,width:e.width,height:e.height,sarRatio:e.sarRatio,baseDts:e.baseDts}}),t.exist()&&this.flv.emit(Re,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),mn.debug("track parsed",e,t)}},{key:"_fireEvents",value:function(e,t,r){var i,s=this;mn.debug("videoTrack samples count: ".concat(e.samples.length,", audioTrack samples count: ").concat(t.samples.length)),r.flvScriptSamples.forEach((function(e){s.flv.emit(Ue,e),mn.debug("flvScriptData",e)})),e.samples.forEach((function(e){e.keyframe&&s.flv.emit(Le,{pts:e.originPts})})),null!==(i=this._opts)&&void 0!==i&&i.canEmitAudioSampleInfo&&t.samples&&this.flv.emit(Qe,{samples:t.samples}),e.warnings.forEach((function(e){var t;switch(e.type){case kt:t=ze;break;case wt:t=Ve;break;case xt:t=We}t&&s.flv.emit(qe,n(n({},e),{},{type:t})),mn.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case St:t=Ge;break;case Et:t=He;break;case Tt:t=Ke}t&&s.flv.emit(qe,n(n({},e),{},{type:t})),mn.warn("audio exception",e)})),r.seiSamples.forEach((function(e){s.flv.emit(Pe,n(n({},e),{},{sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}();function gn(e,t){var r=0,n=e.length-1,i=0,s=0,a=n;for(t<e[0]&&(r=0,s=a+1);s<=a;){if((i=s+Math.floor((a-s)/2))===n||t>=e[i]&&t<e[i+1]){r=i;break}e[i]<t?s=i+1:a=i-1}return r}var bn=new Y("flv"),kn=.1,wn=function(e){h(y,e);var t,r,s,a,c,f,p,v=k(y);function y(e){var t,r;return u(this,y),d(g(t=v.call(this)),"media",null),d(g(t),"_loading",!1),d(g(t),"_opts",null),d(g(t),"_bufferService",null),d(g(t),"_gapService",null),d(g(t),"_stats",null),d(g(t),"_mediaLoader",null),d(g(t),"_maxChunkWaitTimer",null),d(g(t),"_tickTimer",null),d(g(t),"_tickInterval",500),d(g(t),"_urlSwitching",!1),d(g(t),"_seamlessSwitching",!1),d(g(t),"_disconnectRetryCount",0),d(g(t),"_preLoadEndPoint",0),d(g(t),"_keyframes",null),d(g(t),"_acceptRanges",!0),d(g(t),"_onProgress",function(){var e=o(i().mark((function e(r,n,s,a){var o,u,c,l,d,h,f,p,v,y;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.startTime,u=s.endTime,c=s.st,l=s.firstByteTime,t._loading=!n,t._firstProgressEmit){e.next=13;break}if(t.media){e.next=6;break}return null===(d=t._mediaLoader)||void 0===d||d.cancel(),e.abrupt("return");case 6:h=a.headers,f=c?l-c:u-o,t.emit(ke,{url:t._opts.url,responseUrl:a.url,elapsed:f}),t.emit(xe,{headers:h}),t._transferCost.set(fn,f),t._acceptRanges=!(null==h||!h.get("Accept-Ranges"))||!(null==h||!h.get("Content-Range")),t._firstProgressEmit=!0;case 13:if(t._bufferService){e.next=15;break}return e.abrupt("return");case 15:return clearTimeout(t._maxChunkWaitTimer),t._bandwidthService.addChunkRecord(null==r?void 0:r.byteLength,u-o),e.prev=17,e.next=20,t._bufferService.appendBuffer(r);case 20:null===(p=t._bufferService)||void 0===p||p.evictBuffer(t._opts.bufferBehind),e.next=33;break;case 23:if(e.prev=23,e.t0=e.catch(17),t.isLive||!t._bufferService.isFull()){e.next=32;break}return e.next=28,t._mediaLoader.cancel();case 28:return t._loading=!1,v=t.bufferInfo().remaining,t._opts.preloadTime=parseInt(v)/2,e.abrupt("return");case 32:return e.abrupt("return",t._emitError(H.create(e.t0)));case 33:if(t._urlSwitching&&(t._urlSwitching=!1,t.emit(Ie,{url:t._opts.url})),t._seamlessSwitching&&(t._seamlessSwitching=!1,t._tick()),!n||t.media.seeking){e.next=40;break}return t.emit(Se),bn.debug("load done"),t.isLive&&t._disconnectRetryCount<=0&&t._end(),e.abrupt("return");case 40:if(t.isLive){e.next=42;break}return e.abrupt("return");case 42:(y=t._opts.maxReaderInterval)&&t._firstProgressEmit&&(clearTimeout(t._maxChunkWaitTimer),t._maxChunkWaitTimer=setTimeout((function(){if(t._disconnectRetryCount)return t._disconnectRetryCount--,void t.load();bn.debug("onMaxChunkWait",y),t._end()}),y));case 44:case"end":return e.stop()}}),e,null,[[17,23]])})));return function(t,r,n,i){return e.apply(this,arguments)}}()),d(g(t),"_onRetryError",(function(e,r){bn.debug("load retry",e,r),t.emit(Ee,{error:H.network(e),retryTime:r})})),d(g(t),"_end",(function(){t._clear(),t._bufferService&&t._bufferService.endOfStream(),bn.debug("end stream")})),d(g(t),"_resetDisconnectCount",(function(){t._disconnectRetryCount=t._opts.disconnectRetryCount})),d(g(t),"_tick",(function(){clearTimeout(t._tickTimer);var e=g(t).media;if(e){t._tickTimer=setTimeout(t._tick,t._tickInterval);var r=A.end(A.get(e));if(!(r<kn)&&e.readyState){var n=t._opts;if(function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)&&e.currentTime)t._gapService&&t._gapService.do(e,n.maxJumpDistance,t.isLive,3);else{if(!e.currentTime&&t._gapService&&n.enableStartGapJump)return void((t._opts.mseLowLatency||!1===t._opts.mseLowLatency&&t.bufferInfo(.3).nextStart)&&t._gapService.do(e,n.maxJumpDistance,t.isLive,3));n.isLive&&4===e.readyState&&r-e.currentTime>n.disconnectTime&&t.disconnect()}}}})),d(g(t),"_onPlay",(function(){var e,r,n=t._opts.softDecode||(null===(e=t.media)||void 0===e||null===(r=e.buffered)||void 0===r?void 0:r.length);if(t.isLive)!t._loading&&n&&t.replay(void 0,!0);else{var i=t.bufferInfo();(i.start||i.nextStart)>kn&&t._tick()}})),d(g(t),"_onLoadeddata",(function(){t.isLive&&!t._opts.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),d(g(t),"_onSeeking",o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!t.isLive&&t.seekable&&(t._preLoadEndPoint=-1,t._checkPreload());case 1:case"end":return e.stop()}}),e)})))),d(g(t),"_onTimeupdate",(function(){if(t.media){var e=t._opts,r=t.media.currentTime;if(e.isLive&&e.maxLatency&&e.targetLatency){var n=A.end(A.get(t.media));n-r>=e.maxLatency&&(t.media.currentTime=n-e.targetLatency,t.emit(Oe,{currentTime:t.media.currentTime,latency:e.targetLatency}))}t._seiService.throw(r,!0),e.isLive||!t.seekable||t._loading||t._checkPreload()}})),d(g(t),"_onWaiting",(function(){t.isLive&&!t._loading&&t._disconnectRetryCount&&(t._disconnectRetryCount--,t.load())})),d(g(t),"_onBufferUpdate",(function(){if(!t._opts.isLive){var e=t.bufferInfo(),r=e.end,n=e.nextEnd;Math.abs((r||n)-t.media.duration)<1&&(t._end(),t.media.readyState<=2&&t._tick())}})),d(g(t),"_checkPreload",o(i().mark((function e(){var r,n,s,a,o,u,c,l,d,h;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.bufferInfo(),n=r.remaining,s=void 0===n?0:n,a=t._opts,o=t._keyframes.filepositions,u=t._keyframes.times,c=t.media.currentTime,!(s<a.preloadTime)){e.next=19;break}if(l=gn(t._keyframes.times,c+s+kn),(d=gn(t._keyframes.times,c+s+t._opts.preloadTime))===l&&(d=l+1),t._preLoadEndPoint!==d){e.next=11;break}return e.abrupt("return");case 11:if(null!=(h=o[l])){e.next=14;break}return e.abrupt("return");case 14:return e.next=16,t._mediaLoader.cancel();case 16:t._loadData(null,[h,o[d]]),t._preLoadEndPoint=d,t._bufferService.unContiguous(u[l]);case 19:case"end":return e.stop()}}),e)})))),d(g(t),"_onFlvScriptData",(function(e){var r,n,i,s,a=null===(r=e.data)||void 0===r||null===(n=r.onMetaData)||void 0===n?void 0:n.keyframes,o=null===(i=e.data)||void 0===i||null===(s=i.onMetaData)||void 0===s?void 0:s.duration;a&&(t._keyframes=a),!t._opts.isLive&&o&&t._bufferService.updateDuration(o)})),t._opts=((r=n({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},e)).isLive&&r.preloadTime&&(r.maxLatency||(r.maxLatency=2*r.preloadTime),r.targetLatency||(r.targetLatency=r.preloadTime),null!==r.disconnectTime&&void 0!==r.disconnectTime||(r.disconnectTime=r.maxLatency)),r),t.media=t._opts.media||document.createElement("video"),t._opts.media=null,t._firstProgressEmit=!1,t._mediaLoader=new st(n(n({},t._opts.fetchOptions),{},{retry:t._opts.retryCount,retryDelay:t._opts.retryDelay,timeout:t._opts.loadTimeout,onRetryError:t._onRetryError,onProgress:t._onProgress,responseType:"arraybuffer"})),t._disconnectRetryCount=t._opts.disconnectRetryCount,t._transferCost=new hn,t._bufferService=new _n(g(t),t._opts.softDecode?t.media:void 0,t._opts),t._seiService=new ot(g(t)),t._bandwidthService=new ut({chunkCountForSpeed:t._opts.chunkCountForSpeed,skipChunkSize:t._opts.skipChunkSize,longtimeNoReceived:t._opts.longtimeNoReceived}),t._stats=new lt(g(t)),t._opts.softDecode||(t._gapService=new at),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t.media.addEventListener("progress",t._onBufferUpdate),t.media.addEventListener("waiting",t._onWaiting),t.on(Ue,t._onFlvScriptData),t}return l(y,[{key:"version",get:function(){return"3.0.23"}},{key:"isLive",get:function(){return this._opts.isLive}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"seekable",get:function(){return!!this._keyframes&&this._acceptRanges}},{key:"loader",get:function(){return this._mediaLoader}},{key:"blobUrl",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.blobUrl}},{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed(),totalSize:this._bandwidthService.getTotalSize(),totalCost:this._bandwidthService.getTotalCost()}}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kn;return A.info(A.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(p=o(i().mark((function e(t){var r,n,s=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],n=s.length>2?s[2]:void 0,this._bufferService){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,this._reset(r);case 6:this._loadData(t,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize],n),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"replay",value:(f=o(i().mark((function e(){var t,r,n=this,s=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:this._opts.seamlesslyReload,r=s.length>1?s[1]:void 0,this.media){e.next=4;break}return e.abrupt("return");case 4:if(this._resetDisconnectCount(),!t){e.next=11;break}return e.next=8,this._clear();case 8:setTimeout((function(){n._seamlessSwitching=!0,n._loadData(n._opts.url),n._bufferService.seamlessSwitch()})),e.next=13;break;case 11:return e.next=13,this.load();case 13:return e.abrupt("return",this.media.play(!r).catch((function(){})));case 14:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"disconnect",value:function(){var e;return bn.debug("disconnect!"),null===(e=this._bufferService)||void 0===e||e.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:(c=o(i().mark((function e(t,r){var n=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._bufferService){e.next=2;break}return e.abrupt("return");case 2:if(this._resetDisconnectCount(),!this._loading||!r){e.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var e=o(i().mark((function e(r){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n._clear();case 2:n._bufferService.seamlessLoadingSwitching=!0,n._urlSwitching=!0,n._seamlessSwitching=!0,n._bufferService.seamlessSwitch(),n._loadData(t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return");case 6:if(r&&this._opts.isLive){e.next=11;break}return e.next=9,this.load(t);case 9:return this._urlSwitching=!0,e.abrupt("return",this.media.play(!0).catch((function(){})));case 11:return e.next=13,this._clear();case 13:setTimeout((function(){n._urlSwitching=!0,n._seamlessSwitching=!0,n._loadData(t),n._bufferService.seamlessSwitch()}));case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"destroy",value:(a=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),e.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_emitError",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];bn.table(e),bn.error(e),bn.error(null===(t=this.media)||void 0===t?void 0:t.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(Fe,e)),this.emit(be,e),r&&(this._seiService.reset(),this._end())}},{key:"_reset",value:(s=o(i().mark((function e(){var t,r=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]&&r[0],this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),e.next=6,this._clear();case 6:return e.next=8,this._bufferService.reset(t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"_loadData",value:(r=o(i().mark((function e(t,r,n){var s;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&(this._opts.url=t),s=t=this._opts.url,t){e.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(s=this._opts.preProcessUrl(t).url),this._mediaLoader.finnalUrl=s,this.emit(we,{url:s,seamlessSwitching:this._seamlessSwitching}),bn.debug("load data, loading:",this._loading,s),!this._loading){e.next=11;break}return e.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,e.prev=12,e.next=15,this._mediaLoader.load({url:s,range:r,streamRes:n,firstMaxChunkSize:this._opts.firstMaxChunkSize});case 15:e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(12),this._loading=!1,e.abrupt("return",this._emitError(H.network(e.t0),!1));case 21:case"end":return e.stop()}}),e,this,[[12,17]])}))),function(e,t,n){return r.apply(this,arguments)})},{key:"_clear",value:(t=o(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mediaLoader){e.next=3;break}return e.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:ae.isSupported()}},{key:"enableLogger",value:function(){Y.enable(),Ut.enable()}},{key:"disableLogger",value:function(){Y.disable(),Ut.disable()}}]),y}(Xe);try{localStorage.getItem("xgd")?wn.enableLogger():wn.disableLogger()}catch(En){}var xn=function(){function e(t,r){var i=this;u(this,e),d(this,"_onLowDecode",(function(){var e,t,r,s,a=i._opts,o=a.media,u=a.innerDegrade,c=a.backupURL;null===(e=i._plugin)||void 0===e||null===(t=e.player)||void 0===t||t.emit("lowdecode",o.degradeInfo),null===(r=i._plugin)||void 0===r||null===(s=r.player)||void 0===s||s.emit("core_event",n(n({},o.degradeInfo),{},{eventName:Me})),1!==u&&3!==u||!c||i._degrade(c)})),d(this,"_degrade",(function(e){var t=i._plugin.player,r=t.video;if("MVideo"===(null==r?void 0:r.TAG)){var n=t.video.degradeVideo;t.video=n,r.degrade(e),e&&(t.config.url=e);var s=t.root.firstChild;"MVideo"===s.TAG&&t.root.replaceChild(n,s);var a=i._plugin.constructor.pluginName.toLowerCase();t.unRegisterPlugin(a),t.once("canplay",(function(){t.play()}))}})),d(this,"forceDegradeToVideo",(function(e){var t=i._opts.innerDegrade;1!==t&&3!==t||i._degrade(e)})),this._opts=t,this._plugin=r,this._init()}return l(e,[{key:"_init",value:function(){var e=this._opts,t=e.media,r=e.isLive,n=e.preloadTime,i=e.innerDegrade,s=e.decodeMode;t&&(r||!t.setPlayMode?(i&&t.setAttribute("innerdegrade",i),n&&t.setAttribute("preloadtime",n),t.setDecodeMode&&t.setDecodeMode(s),this._bindEvents()):t.setPlayMode("VOD"))}},{key:"_bindEvents",value:function(){this._opts.media.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var e,t;null===(e=this._opts)||void 0===e||null===(t=e.media)||void 0===t||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),e}(),Sn=function(e){h(i,e);var r=k(i);function i(){var e;u(this,i);for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return d(g(e=r.call.apply(r,[this].concat(n))),"logger",bn),d(g(e),"flv",null),d(g(e),"pluginExtension",null),d(g(e),"getStats",(function(){var t;return null===(t=e.flv)||void 0===t?void 0:t.getStats()})),d(g(e),"loadSource",(function(){var t;arguments.length>0&&void 0!==arguments[0]||e.player.config.url;var r=arguments.length>1?arguments[1]:void 0;null===(t=e.flv)||void 0===t||t.load(e.player.config.url,!0,r)})),d(g(e),"destroy",(function(){var t;e.flv&&(e.flv.destroy(),e.flv=null),null===(t=e.pluginExtension)||void 0===t||t.destroy(),e.pluginExtension=null})),d(g(e),"_onSwitchURL",(function(t,r){var n,i;e.flv&&(e.player.config.url=t,"object"===s(r)&&(r=r.seamless),e.flv.switchURL(t,r),!r&&null!==(n=e.player.config)&&void 0!==n&&null!==(i=n.flv)&&void 0!==i&&i.keepStatusAfterSwitch&&e._keepPauseStatus())})),d(g(e),"_keepPauseStatus",(function(){e.player.paused&&e.player.once("canplay",(function(){e.player.pause()}))})),d(g(e),"_onDefinitionChange",(function(t){var r=t.to;e.flv&&e.flv.switchURL(r)})),e}return l(i,[{key:"core",get:function(){return this.flv}},{key:"version",get:function(){var e;return null===(e=this.flv)||void 0===e?void 0:e.version}},{key:"softDecode",get:function(){var e,t,r=null===(e=this.player)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mediaType;return!!r&&"video"!==r&&"audio"!==r&&"offscreen-video"!==r}},{key:"loader",get:function(){var e;return null===(e=this.flv)||void 0===e?void 0:e.loader}},{key:"transferCost",get:function(){return this.flv._transferCost.transferCost}},{key:"beforePlayerInit",value:function(){var e=this,r=this.player.config,i=this.player.media||this.player.video;if(r.url){this.flv&&this.flv.destroy(),this.player.switchURL=this._onSwitchURL;var s,a=r.flv||{};if(null!==a.disconnectTime&&void 0!==a.disconnectTime||(a.disconnectTime=0),this.flv=new wn(n({softDecode:this.softDecode,isLive:r.isLive,media:i,preProcessUrl:function(t,r){var n,i;return(null===(n=e.player)||void 0===n||null===(i=n.preProcessUrl)||void 0===i?void 0:i.call(n,t,r))||{url:t,ext:r}}},a)),this.softDecode||t.BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){var t;return null===(t=e.flv)||void 0===t?void 0:t.blobUrl},configurable:!0}}),this.softDecode&&(this.pluginExtension=new xn(n({media:this.player.video,isLive:r.isLive},r.flv),this),this.player.forceDegradeToVideo=function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return null===(t=e.pluginExtension)||void 0===t?void 0:t.forceDegradeToVideo.apply(t,n)}),r.isLive)null===(s=this.player)||void 0===s||s.useHooks("replay",(function(){var t;return null===(t=e.flv)||void 0===t?void 0:t.replay()}));this.on(t.Events.URL_CHANGE,this._onSwitchURL),this.on(t.Events.DESTROY,this.destroy),this._transError(),this._transCoreEvent(ke),this._transCoreEvent(we),this._transCoreEvent(xe),this._transCoreEvent(Se),this._transCoreEvent(Ee),this._transCoreEvent(Te),this._transCoreEvent(je),this._transCoreEvent(Ce),this._transCoreEvent(De),this._transCoreEvent(Ae),this._transCoreEvent(Le),this._transCoreEvent(Oe),this._transCoreEvent(Re),this._transCoreEvent(Pe),this._transCoreEvent(Be),this._transCoreEvent(Ue),this._transCoreEvent(qe),this._transCoreEvent(Ie),this._transCoreEvent(Fe),this._transCoreEvent(Qe),a.manualLoad||this.loadSource(r.url,a.streamRes)}}},{key:"_transError",value:function(){var e=this;this.flv.on(be,(function(r){e.player&&e.player.emit(t.Events.ERROR,new t.Errors(e.player,r))}))}},{key:"_transCoreEvent",value:function(e){var t=this;this.flv.on(e,(function(r){t.player&&t.player.emit("core_event",n(n({},r),{},{eventName:e}))}))}}],[{key:"pluginName",get:function(){return"flv"}},{key:"isSupported",value:function(e,t){return wn.isSupported(e,t)}},{key:"isSupportedMMS",value:function(){return"undefined"!=typeof ManagedMediaSource}}]),i}(t.BasePlugin);return d(Sn,"Flv",wn),Sn}));
2
2
  //# sourceMappingURL=index.min.js.map