xgplayer-mp4-loader 3.0.17-alpha.0 → 3.0.17-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/loader.d.ts +1 -1
- package/es/loader.js +14 -14
- package/package.json +4 -4
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.concat.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.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),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.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.function.name.js","core-js/modules/es.array.concat.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.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","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).MP4Loader=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(D){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new j(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(D){return{type:"throw",arg:D}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var y={};c(y,s,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(T([])));g&&g!==t&&n.call(g,s)&&(y=g);var _=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 r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=w(s,r);if(o){if(o===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 a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(l(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=T,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,j(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=f()?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&&h(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},v(e)}function y(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function _(e){var t=f();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,s,o=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function j(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function T(){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 A(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var D,O=function(){function e(){s(this,e)}return u(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(s[1]=u)}else r.push([e.start(n),e.end(n)])}else r.push([e.start(n),e.end(n)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,a=0,s=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=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:a,index:s,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}}]),e}(),C="network",B="network_timeout",L="network_forbidden",R="network_notfound",P="network_range_not_satisfiable",M="demux",I="remux",U="media",z="drm",N="other",q="runtime",F={FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"},V=(c(D={},"manifest",{HLS:1100,DASH:1200}),c(D,C,2100),c(D,B,2101),c(D,L,2103),c(D,R,2104),c(D,P,2116),c(D,M,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(D,I,{FMP4:4100,MP4:4200}),c(D,U,{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}),c(D,z,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(D,N,8e3),c(D,q,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),D),G=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===B?C:e,u.originError=i,u.ext=a,u.errorCode=V[e][n]||V[e],u.errorMessage=u.message,u.errorCode||(u.errorType=N,u.errorCode=V[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=N),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?B:C,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(v(Error)),H="undefined"!=typeof window,K={DEBUG:1,LOG:2,WARN:3,ERROR:4},W=["Boolean","Number","String","Undefined","Null","Date","Object"],Q=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return u(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[K.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,[this._prefix,Y()].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,[this._prefix,Y()].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,[this._prefix,Y()].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,[this._prefix,Y()].concat(n))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=n.map((function(e){return J(e)}));t=this._prefix+Y()+JSON.stringify(a)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function Y(){return(new Date).toLocaleString()}function X(e){if("object"!==n(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function J(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!W.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=X(e[s]):"object"===n(e[s])?i[s]=J(e[s],t,r+1):i[s]=e[s]);return i}}function Z(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return H?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function $(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}c(Q,"disabled",!0);var ee="appendBuffer",te="removeBuffer",re="updateDuration",ne=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",T()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),c(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==re&&t.shift(),r){var i=A()-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)}}})),c(this,"_onSBUpdateError",(function(e,t){var r=n._queue[e];if(r){var i=r[0];i&&(n._logger.error("UpdateError",e,i.opName,i.context),i.promise.reject(new G(U,F.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new Q("MSE"),this._config.openLog&&Q.enable()}var t,n,i;return u(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:"streaming",get:function(){return!$(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))}),re,{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=A()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=T()}return this._openPromise}},{key:"bindMedia",value:(i=a(r().mark((function e(t){var n,i,a,s,o=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(n=Z(this._config.preferMMS),t&&n){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new n,a=$(i),this._st=A(),s=function e(){var r=A()-o._st;o._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),o._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",s),a&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=a,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(n=a(r().mark((function e(){var t,n,i,a=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=a._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}})),$(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(r){}this.media=null}this.mediaSource=null,this._openPromise=T(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new G(U,F.MSE_ADD_SB,n)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,n=this._sourceBuffer[e];return this.mediaSource&&n&&n.mimeType!==t?"function"!=typeof n.changeType?Promise.reject():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=A(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),ee,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var a=i._sourceBuffer[e];t>=r||!a?i._onSBUpdateEnd(e):(i._opst=A(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),te,n,a)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n.remove(i,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var n=t._sourceBuffer[r];e=t.remove(r,0,O.end(O.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 O.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return O.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return O.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:T(),opName:r,context:n};return i?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=a(r().mark((function e(t,n,i){var a,s,o=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=T();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(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 G(U,F.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new G(U,F.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:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=Z();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();c(ne,"VIDEO","video"),c(ne,"AUDIO","audio");var ie="fetch",ae="xhr",se="arraybuffer",oe="text",ue="json",ce=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(m(o=t.call(this,a)),"retryCount",0),c(m(o),"isTimeout",!1),c(m(o),"loaderType",ie),c(m(o),"startTime",0),c(m(o),"endTime",0),c(m(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(Error)),le=Object.prototype.toString;function de(e){if("[object Object]"!==le.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function he(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function fe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function pe(e,t){if(e){if(!t)return e;var r,i=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===le.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(fe(e),"=").concat(fe(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function ve(e,t,r,n,i,a,s,o,u,c,l){return i=null!=i?parseFloat(i):null,n=parseInt(n||"0",10),Number.isNaN(n)&&(n=0),{data:e,done:t,options:{range:u,vid:c,index:o,contentLength:n,age:i,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:l},response:r}}function ye(e,t){return Math.round(8*e*1e3/t/1024)}var me="real_time_speed",ge={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var 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 a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(ge);var _e=ge.exports,be=2097152,ke=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(m(e=n.call(this)),"_abortController",null),c(m(e),"_timeoutTimer",null),c(m(e),"_reader",null),c(m(e),"_response",null),c(m(e),"_aborted",!1),c(m(e),"_index",-1),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_running",!1),c(m(e),"_logger",null),c(m(e),"_vid",""),c(m(e),"_onProcessMinLen",0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,h=e.onCancel,f=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,g=e.method,_=e.headers,b=e.body,k=e.mode,x=e.credentials,w=e.cache,S=e.redirect,E=e.referrer,j=e.referrerPolicy,T=e.onProcessMinLen,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||i,this._priOptions=A||{};var D={method:g,headers:_,body:b,mode:k,credentials:x,cache:w,redirect:S,referrer:E,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},O=!1;clearTimeout(this._timeoutTimer),i=pe(i,y);var C=he(f);C&&(_=v?v.headers:D.headers=D.headers||(Headers?new Headers:{}),Headers&&_ instanceof Headers?_.append("Range",C):_.Range=C),o&&(this._timeoutTimer=setTimeout((function(){if(O=!0,n.cancel(),d){var e=new ce(i,D,null,"timeout");e.isTimeout=!0,d(e,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})}}),o));var B=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",f),new Promise((function(e,t){fetch(v||i,v?void 0:D).then(function(){var s=a(r().mark((function a(s){var o,d,h,v;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(p&&(s=p(s,i)||s),s.ok){r.next=7;break}throw new ce(i,D,s,"bad network response");case 7:if(o=Date.now(),u!==oe){r.next=15;break}return r.next=11,s.text();case 11:d=r.sent,n._running=!1,r.next=37;break;case 15:if(u!==ue){r.next=22;break}return r.next=18,s.json();case 18:d=r.sent,n._running=!1,r.next=37;break;case 22:if(!c){r.next=29;break}return n.resolve=e,n.reject=t,n._loadChunk(s,c,B,o),r.abrupt("return");case 29:return r.next=31,s.arrayBuffer();case 31:d=r.sent,d=new Uint8Array(d),n._running=!1,h=Date.now()-B,v=ye(d.byteLength,h),n.emit(me,{speed:v,len:d.byteLength,time:h,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",l,",range,",f),e(ve(d,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),B,o,l,f,n._vid,n._priOptions));case 39:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!O||((e=e instanceof ce?e:new ce(i,D,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=B,e.endTime=Date.now(),e.isTimeout=O,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(t){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new ce(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(be),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),h=function(){var o=a(r().mark((function a(){var o,f,p,v,y,m,g,_;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(f=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=f+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[p,p],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:v=u.value?u.value.byteLength:0,s._receivedLength+=v,s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",p,", end,",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<be?(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:n,firstByteTime:i,priOptions:s._priOptions},e),u.done?(g=Date.now()-n,_=ye(s._receivedLength,g),s.emit(me,{speed:_,len:s._receivedLength,time:g,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(ve(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,i,s._index,s._range,s._vid,s._priOptions))):h();case 25:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.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)}}]),i}(_e);var xe=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(m(e=r.call(this)),"_xhr",null),c(m(e),"_aborted",!1),c(m(e),"_timeoutTimer",null),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_url",null),c(m(e),"_onProgress",null),c(m(e),"_index",-1),c(m(e),"_headers",null),c(m(e),"_currentChunkSizeKB",384),c(m(e),"_timeout",null),c(m(e),"_xhr",null),c(m(e),"_withCredentials",null),c(m(e),"_startTime",-1),c(m(e),"_loadCompleteResolve",null),c(m(e),"_loadCompleteReject",null),c(m(e),"_runing",!1),c(m(e),"_logger",!1),c(m(e),"_vid",""),c(m(e),"_responseType",void 0),c(m(e),"_credentials",void 0),c(m(e),"_method",void 0),c(m(e),"_transformResponse",void 0),c(m(e),"_firstRtt",void 0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(n,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=pe(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 ce?e:new ce(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===se&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,n=this._range[1];t<this._range[1]-r&&(n=r+t),e=[r,n],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,n,i;t._running=!1;var a=new ce(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.status)+",statusText,"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new ce(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var n=this._headers||{},i=he(e);i&&(n.Range=i),n&&Object.keys(n).forEach((function(e){r.setRequestHeader(e,n[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(a){a.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new ce(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===se){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=ye(this._receivedLength,d);this.emit(me,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var f={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(ve(this._onProgress?null:s,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,k(d(n.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value.split(": ");r[i[0].toLowerCase()]=i.slice(1).join(": ")}}catch(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(_e),we=["retry","retryDelay","onRetryError","transformError"],Se=function(){function e(t,r){s(this,e),this.promise=T(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new Q("Loader")),this._loaderType=t,this._loader=t===ie&&"undefined"!=typeof fetch?new ke:new xe,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=y(t,we),c=function(){var t=a(r().mark((function t(){var a,l,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:a=t.sent,e.promise.resolve(a),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,o&&(l=o(l)||l),s&&e._retryCount>0&&s(l,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=n)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}();function Ee(){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 je(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Te=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(m(r=i.call(this,e)),"type",ie),c(m(r),"_queue",[]),c(m(r),"_alive",[]),c(m(r),"_currentTask",null),c(m(r),"_finnalUrl",""),c(m(r),"_config",void 0),r._config=function(e){return t({loaderType:ie,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:oe,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),r._config.loaderType!==ae&&ke.isSupported()||(r.type=ae),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===ie}},{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&&de(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&de(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Se(this.type,r);return n.loader.on(me,(function(e){t.emit(me,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,je();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return ke.isSupported()}}]),o}(_e),Ae="video",De="audio",Oe="metadata",Ce="avc",Be="hevc",Le="aac",Re="g7110a",Pe="g7110m",Me="LARGE_AV_SHIFT",Ie="LARGE_VIDEO_GAP",Ue="LARGE_VIDEO_GAP_BETWEEN_CHUNK",ze="LARGE_AUDIO_GAP",Ne="AUDIO_FILLED",qe="AUDIO_DROPPED",Fe=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",Ae),c(this,"codecType",Ce),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"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}(),Ve=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",De),c(this,"codecType",Le),c(this,"pid",-1),c(this,"codec",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===Le)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),e}(),Ge=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),He=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),Ke=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),We=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Ke),Qe=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Ke),Ye=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",Oe),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),Xe=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(0!=(this._word&2147483648>>>e))return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Je=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();c(Je,"disabled",!0);var Ze=function(){function e(){s(this,e)}return u(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,a=t.length;i<a;)if(n[i]<128)r.push(String.fromCharCode(n[i])),++i;else{if(n[i]<192);else if(n[i]<224){if(e._checkContinuation(n,i,1)){var s=(31&n[i])<<6|63&n[i+1];if(s>=128){r.push(String.fromCharCode(65535&s)),i+=2;continue}}}else if(n[i]<240){if(e._checkContinuation(n,i,2)){var o=(15&n[i])<<12|(63&n[i+1])<<6|63&n[i+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),i+=3;continue}}}else if(n[i]<248&&e._checkContinuation(n,i,3)){var u=(7&n[i])<<18|(63&n[i+1])<<12|(63&n[i+2])<<6|63&n[i+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),i+=4;continue}}r.push(String.fromCharCode(65533)),++i}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var n=e;if(t+r<n.length){for(;r--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),$e="undefined"!=typeof window,et=$e&&navigator.userAgent.toLocaleLowerCase(),tt=$e&&/^((?!chrome|android).)*safari/.test(et),rt=$e&&et.includes("firefox"),nt=$e&&et.includes("android");function it(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}var at=Math.pow(2,32);function st(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function ot(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 ut(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ot(e,t)*at+ot(e,t+4)}function ct(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 lt(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 dt=function(){function e(){s(this,e)}return u(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=[],a=0;a+t<n;)if(r=ot(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>n)break;i.push(e.subarray(a,a+r)),a+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,a=0,s="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)a+=255,n++;if(a+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)s+=e[n].toString(16),n++;return{payload:e.subarray(n,n+a),type:i,size:a,uuid:s}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}}]),e}(),ht=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,a.push(l),r||(r=e.parseSPS(dt.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&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Xe(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var 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(),_=(m=E)/(g=2*S)}}return{codec:ct(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,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:g,fps:_,fixedFrame:y}}}]),e}(),ft=function(){function e(){s(this,e)}return u(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var a=i,s=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,d=1+((192&t[i+2])>>>6),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]),s.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType: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,a=e.FREQ[n];if(a){var s=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,a=[];return rt?e>=6?(n=5,i=e-3):(n=2,i=e):nt?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),a[0]=n<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===n&&(a[1]|=(14&i)>>1,a[2]=(1&i)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();c(ft,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var pt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){a=63&t[h],s=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<s;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(a){case 32:var y=t.subarray(h,h+o);n||(n=e.parseVPS(dt.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(h,h+o);i||(i=e.parseSPS(dt.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 Xe(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 Xe(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,d,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!==a&&2!==a||0!==o?1:2,y=1===a&&0===o?2:1;h-=v*(c+u),f-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==s[u]&&e.readBits(8)}}]),e}(),vt=1e3,yt=5e3,mt=function(){function e(t,r,n){s(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return u(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,a=this.audioTrack;!r&&n||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var i=e.samples[0],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:Ue,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:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:Ie,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,a=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=a=n[0].dts),this._baseDts=Math.min(i,a);var s=a-i;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:Me,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=e.codecType===Le?ft.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===Le?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],c=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=vt&&!tt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>yt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:Ne,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new He(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=n,s++}s--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>yt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:qe,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(c)>vt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>yt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:ze,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===Le?ft.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),gt=function(){function e(){s(this,e)}return u(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var 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,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=m.data,_=m.size;r.push(g),i+=_}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=Ze.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=Ze.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}(),_t=new Je("FlvDemuxer"),bt=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Fe,this.audioTrack=r||new Ve,this.metadataTrack=n||new Ye,this._fixer=new mt(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(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,a=this.videoTrack,s=this.metadataTrack;if(!r&&n||(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),i.reset(),s.reset()):(a.samples=[],i.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],i.warnings=[],this._remainingData&&(t=it(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:a,audioTrack:i,metadataTrack:s};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");i.present=(4&t[4])>>>2!=0,a.present=0!=(1&t[4]),this._headerParsed=!0,o=ot(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):_t.warn("Invalid tag type: ".concat(u)),(h=ot(t,o+=c))!==11+c&&_t.warn("Invalid PrevTagSize ".concat(h," (").concat(11+c,")")),o+=4;return o<f&&(this._remainingData=t.subarray(o)),i.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:i,metadataTrack:s}}},{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 _t.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[a],i.sampleSize=s?16:8,i.channelCount=o+1}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?Re:Pe,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new He(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=Le,0===e[1]){var n=ft.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(),_t.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new He(t,e.subarray(2)))}else _t.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var n=(240&e[0])>>>4,i=15&e[0],a=this.videoTrack;if(7!==i&&12!==i)return a.reset(),void _t.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?Be:Ce;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=s?pt.parseHEVCDecoderConfigurationRecord(c):ht.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),h&&(a.codec=h.codec,a.width=h.width,a.height=h.height,a.sarRatio=h.sarRatio,a.fpsNum=h.fpsNum,a.fpsDen=h.fpsDen),p.length&&(a.sps=p),f.length&&(a.pps=f),v&&v.length&&(a.vps=v),y&&(a.nalUnitSize=y)}else _t.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=dt.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var g=new Ge(t+u,t,m);1===n&&g.setToKeyframe(),a.samples.push(g),m.forEach((function(e){var n=s?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==n||s&&5===n)break;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Qe(dt.parseSEI(dt.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else _t.warn("Cannot parse NALUs",e)}else 2===o||_t.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 We(gt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&ot(e,5)>=9}}]),e}();c(bt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Je("TsDemuxer");var kt=function(){function e(){s(this,e)}return u(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var a=0,s="",o=0;t.length>7;){if(a=ot(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=ut(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return Et(e,!0,(function(e,t){e.trackId=ot(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=ot(t,r),r+=4),i&&(e.sampleDescriptionIndex=ot(t,r),r+=4),a&&(e.defaultSampleDuration=ot(t,r),r+=4),s&&(e.defaultSampleSize=ot(t,r),r+=4),o&&(e.defaultSampleFlags=ot(t,r))}))}},{key:"sidx",value:function(e){return Et(e,!0,(function(e,t){var r=0;e.reference_ID=ot(t,r),r+=4,e.timescale=ot(t,r),r+=4,0===e.version?(e.earliest_presentation_time=ot(t,r),r+=4,e.first_offset=ot(t,r),r+=4):(e.earliest_presentation_time=ut(t,r),r+=8,e.first_offset=ut(t,r),r+=8),r+=2,e.references=[];var n=st(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=ot(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=ot(t,r),s=ot(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return Et(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return Et(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ot(t,16),e.duration=ut(t,20),r+=28):(e.timescale=ot(t,8),e.duration=ot(t,12),r+=16),e.nextTrackId=ot(t,r+76)}))}},{key:"trak",value:function(t){return Et(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return Et(e,!0,(function(e,t){var r=0;1===e.version?(e.trackId=ot(t,16),e.duration=ut(t,24),r+=32):(e.trackId=ot(t,8),e.duration=ot(t,16),r+=20),e.width=ot(t,r+52),e.height=ot(t,r+56)}))}},{key:"mdia",value:function(t){return Et(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return Et(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ot(t,16),e.duration=ut(t,20),r+=28):(e.timescale=ot(t,8),e.duration=ot(t,12),r+=16);var n=st(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return Et(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return Et(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return Et(e,!0,(function(e,t){e.graphicsmode=st(t),e.opcolor=[st(t,2),st(t,4),st(t,6)]}))}},{key:"smhd",value:function(e){return Et(e,!0,(function(e,t){e.balance=st(t)}))}},{key:"stbl",value:function(t){return Et(t,!1,(function(t,r,n){var i,a,s;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return Et(e,!0,(function(e,r){var n=0,i=ot(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=st(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=st(r,n),n+=2,l.BytesOfProtectedData=ot(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return Et(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(Tt(t[i+a]));if(i+=16,e.version>0){var s=ot(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(Tt(c))}}var l=ot(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return Et(t,!0,(function(t,r,n){t.entryCount=ot(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return Et(t,!1,(function(t,r,n){t.channelCount=st(r,16),t.samplesize=st(r,18),t.sampleRate=ot(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return Et(t,!1,(function(t,r,n){t.width=st(r,24),t.height=st(r,26),t.horizresolution=ot(r,28),t.vertresolution=ot(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return Et(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(Tt(t[r])),r+=1}))}},{key:"schi",value:function(t){return Et(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return Et(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return Et(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"avc1",value:function(t){return Et(t,!1,(function(t,r,n){var i=wt(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return Et(e,!1,(function(e,t){e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=ct([t[1],t[2],t[3]]),e.lengthSizeMinusOne=3&t[4],e.spsLength=31&t[5],e.sps=[];for(var r=6,n=0;n<e.spsLength;n++){var i=st(t,r);r+=2,e.sps.push(t.subarray(r,r+i)),r+=i}e.ppsLength=t[r],r+=1,e.pps=[];for(var a=0;a<e.ppsLength;a++){var s=st(t,r);r+=2,e.pps.push(t.subarray(r,r+=s)),r+=s}}))}},{key:"hvc1",value:function(t){return Et(t,!1,(function(t,r,n){var i=wt(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return Et(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=ot(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=st(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=st(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=st(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var h;(h=t.sps).push.apply(h,l)}else if(34===a){var f;(f=t.pps).push.apply(f,l)}}}))}},{key:"pasp",value:function(e){return Et(e,!1,(function(e,t){e.hSpacing=ot(t),e.vSpacing=ot(t,4)}))}},{key:"mp4a",value:function(t){return Et(t,!1,(function(t,r,n){var i=St(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return Et(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;return 31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[1])>>5)),e.objectType=o,e.codec+=o.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return Et(e,!1,(function(e,t){St(e,t)}))}},{key:"stts",value:function(e){return Et(e,!0,(function(e,t){for(var r=ot(t),n=[],i=4,a=0;a<r;a++)n.push({count:ot(t,i),delta:ot(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return Et(e,!0,(function(e,t){var r=ot(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:ot(t,i),offset:ot(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:ot(t,i),offset:-(1+~ot(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return Et(e,!0,(function(e,t){for(var r=ot(t),n=[],i=4,a=0;a<r;a++)n.push({firstChunk:ot(t,i),samplesPerChunk:ot(t,i+4),sampleDescriptionIndex:ot(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return Et(e,!0,(function(e,t){var r=ot(t),n=ot(t,4),i=[];if(!r)for(var a=8,s=0;s<n;s++)i.push(ot(t,a)),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return Et(e,!0,(function(e,t){for(var r=ot(t),n=[],i=4,a=0;a<r;a++)n.push(ot(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return Et(e,!0,(function(e,t){for(var r=ot(t),n=[],i=4,a=0;a<r;a++)n.push(ut(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return Et(e,!0,(function(e,t){for(var r=ot(t),n=[],i=4,a=0;a<r;a++)n.push(ot(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return Et(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return Et(e,!0,(function(e,t){e.sequenceNumber=ot(t)}))}},{key:"traf",value:function(t){return Et(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return Et(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=ot(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~ot(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=ot(t,s),s+=4),e.samples=[],i>s)for(var o,u=0;u<a;u++)o={},256&n&&(o.duration=ot(t,s),s+=4),512&n&&(o.size=ot(t,s),s+=4),1024&n&&(o.flags=ot(t,s),s+=4),2048&n&&(o.cts=r?-(1+~ot(t,s+4)):ot(t,s),s+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return Et(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=ut(t):e.baseMediaDecodeTime=ot(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,a=e.trak;if(a&&a.length){var s=a.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=a.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(s&&t){var u,c,l,d,h,f,p,v=t,y=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=y&&(v.id=s.tkhd.trackId),v.tkhdDuration=s.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=s.mdia.mdhd.timescale,v.duration=s.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale;var m,g,_,b,k,x,w,S,E=s.mdia.minf.stbl.stsd.entries[0];if(v.width=E.width,v.height=E.height,E.pasp&&(v.sarRatio=[E.pasp.hSpacing,E.pasp.vSpacing]),E.hvcC)v.codecType=Be,v.codec=E.hvcC.codec,v.vps=E.hvcC.vps,v.sps=E.hvcC.sps,v.pps=E.hvcC.pps,v.hvcC=E.hvcC.data;else{if(!E.avcC)throw new Error("unknown video stsd entry");v.codec=E.avcC.codec,v.sps=E.avcC.sps,v.pps=E.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=s.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(h=s.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.ctts,E&&"encv"===E.type)v.isVideoEncryption=!0,E.default_KID=null===(m=E.sinf)||void 0===m||null===(g=m.schi)||void 0===g?void 0:g.tenc.default_KID,E.default_IsEncrypted=null===(_=E.sinf)||void 0===_||null===(b=_.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,E.default_IV_size=null===(k=E.sinf)||void 0===k||null===(x=k.schi)||void 0===x?void 0:x.tenc.default_IV_size,v.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,E.data_format=null===(w=E.sinf)||void 0===w||null===(S=w.frma)||void 0===S?void 0:S.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=E}if(o&&r){var j,T,A,D,O,C,B,L,R,P=r,M=null===(j=o.tkhd)||void 0===j?void 0:j.trackId;null!=M&&(P.id=o.tkhd.trackId),P.tkhdDuration=o.tkhd.duration,P.mvhdDurtion=e.mvhd.duration,P.mvhdTimecale=e.mvhd.timescale,P.timescale=P.formatTimescale=o.mdia.mdhd.timescale,P.duration=o.mdia.mdhd.duration||P.mvhdDurtion/P.mvhdTimecale*P.timescale;var I,U,z,N,q,F,V,G,H=o.mdia.minf.stbl.stsd.entries[0];switch(P.sampleSize=H.sampleSize,P.sampleRate=H.sampleRate,P.channelCount=H.channelCount,P.present=!0,H.type){case"alaw":P.codecType=P.codec=Re,P.sampleRate=8e3;break;case"ulaw":P.codecType=P.codec=Pe,P.sampleRate=8e3;break;default:P.sampleDuration=ft.getFrameDuration(P.sampleRate,P.timescale),P.sampleRateIndex=ft.getRateIndexByRate(P.sampleRate),P.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(P.config=Array.from(H.esds.config)),P.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(P.sampleDuration=ft.getFrameDuration(P.sampleRate,P.timescale),P.objectType=(null===(T=H.esds)||void 0===T?void 0:T.objectType)||2,H.esds&&(H.esds.config?P.config=Array.from(H.esds.config):console.warn("esds config is null")),P.codec=(null===(A=H.esds)||void 0===A?void 0:A.codec)||"mp4a.40.2",P.sampleRateIndex=ft.getRateIndexByRate(P.sampleRate),P.ext={},P.ext.stss=null===(D=o.mdia)||void 0===D||null===(O=D.minf)||void 0===O||null===(C=O.stbl)||void 0===C?void 0:C.stss,P.ext.ctts=null===(B=o.mdia)||void 0===B||null===(L=B.minf)||void 0===L||null===(R=L.stbl)||void 0===R?void 0:R.ctts,P.present=!0,H&&"enca"===H.type)P.isAudioEncryption=!0,H.data_format=null===(I=H.sinf)||void 0===I||null===(U=I.frma)||void 0===U?void 0:U.data_format,H.default_KID=null===(z=H.sinf)||void 0===z||null===(N=z.schi)||void 0===N?void 0:N.tenc.default_KID,H.default_IsEncrypted=null===(q=H.sinf)||void 0===q||null===(F=q.schi)||void 0===F?void 0:F.tenc.default_IsEncrypted,H.default_IV_size=null===(V=H.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IV_size,P.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,P.useEME=e.useEME,P.kidValue=e.kidValue,P.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,W,Q=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,Y=null==r||null===(W=r.enca)||void 0===W?void 0:W.default_KID,X=Q||Y?(Q||Y).join(""):null;t&&(t.kid=X),r&&(r.kid=X)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,h=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=[];for(var f=0;f<o.sampleCount;f++)i[a.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[a.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:h,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(h++,e.gopId=h),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,h=u.stco,f=u.stss,p=u.ctts;if(!(c&&l&&d&&h&&f))return;i=xt(c,l,d,h,p,f)}if(n){var v,y,m,g=null===(v=n.mdia)||void 0===v||null===(y=v.minf)||void 0===y?void 0:y.stbl;if(!g)return;var _=null===(m=n.mdia.mdhd)||void 0===m?void 0:m.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=xt(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function xt(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,h=n.entries,f=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,y=0,m=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:y,duration:n,size:f[m]||r.sampleSize,offset:h[g]+b,index:m},p&&(u.keyframe=s[m],u.keyframe&&v++,u.gopId=v),o&&m<o.length&&(u.pts=u.dts+o[m]),c.push(u),y+=n,++m<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function wt(e,t){return e.dataReferenceIndex=st(t,6),e.width=st(t,24),e.height=st(t,26),e.horizresolution=ot(t,28),e.vertresolution=ot(t,32),e.frameCount=st(t,40),e.depth=st(t,74),78}function St(e,t){return e.dataReferenceIndex=st(t,6),e.channelCount=st(t,16),e.sampleSize=st(t,18),e.sampleRate=ot(t,24)/65536,28}function Et(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var jt=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},Tt=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(jt(Number(t).toString(16),2,0))})),e[0]};function At(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return n.forEach((function(e){a.set(e,s),s+=e.length})),a}var Dt=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){t?e.buffer=At(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}(),Ot=Math.pow(2,32)-1,Ct=function(){function e(){s(this,e)}return u(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===Ae&&e.codecType===Be}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return it(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],lt(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(w(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(w(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return n}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]));return a}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]));return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===Ae?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]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,i,a,s)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],c=t.sarRatio[1],l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),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(lt(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"avc1hev1",value:function(t){var r=t.codecType===Be,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),a=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),i];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(a))}},{key:"avcC",value:function(t){var r,n,i,a=[],s=[];return t.sps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(n,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(a.length&&1)+(s.length&&1);n=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,c];var l=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,w(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),a.length&&(n.push(161,0,a.length),a.forEach(l)),s.length&&(n.push(162,0,s.length),s.forEach(l))}else n=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(n))}},{key:"pasp",value:function(t){var r=x(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(w(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(w(t.map((function(t){return e.traf(t)})))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2,i+=6*e.subsamples.length)})),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,a,s,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),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(),g=e.saiz(t),_=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 Dt;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 Dt,n=Dt.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Dt.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Dt.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),i=Dt.writeUint32(s)}return t.samples.forEach((function(e){r.write(Dt.writeUint32(e.duration)),r.write(Dt.writeUint32(e.size)),r.write(Dt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Dt.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 Dt,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||i*n,r.write(Dt.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Dt.writeUint32(n)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(Dt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Dt.writeUint16(e.BytesOfClearData)),r.write(Dt.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/(Ot+1)),i=Math.floor(r%(Ot+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(w(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===Ae?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,it(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12})),e.box(e.types.stsc,it(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,it(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,it(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,it(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,it(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,a=t.samples[0].sampleOffset*n,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,c=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){c+=8,e.subsamples&&e.subsamples.length&&(c+=2,c+=6*e.subsamples.length)})),t.videoSencLength=c,o=s+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var l=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,l)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();c(Ct,"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))),c(Ct,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),c(Ct,"FTYPAVC1",Ct.box(Ct.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(Ct,"FTYPHEV1",Ct.box(Ct.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(Ct,"DINF",Ct.box(Ct.types.dinf,Ct.box(Ct.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(Ct,"VMHD",Ct.box(Ct.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(Ct,"SMHD",Ct.box(Ct.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(Ct,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(Ct,"STTS",Ct.box(Ct.types.stts,Ct.StblTable)),c(Ct,"STSC",Ct.box(Ct.types.stsc,Ct.StblTable)),c(Ct,"STSZ",Ct.box(Ct.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(Ct,"STCO",Ct.box(Ct.types.stco,Ct.StblTable));var Bt=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[this._prefix].concat(n))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();c(Bt,"disabled",!0);for(var Lt=function(){function e(){s(this,e)}return u(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 p(this,t)}}]),e}(),Rt=function(e){l(r,e);var t=_(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;s(this,r),e=t.call(this);var a=n;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var o=a.byteLength,u=[],c=0;c<o;c+=1)u[c>>>2]|=a[c]<<24-c%4*8;e.words=u,e.sigBytes=o}else e.words=n,e.sigBytes=i;return e}return u(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Pt;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 a=0;a<i;a+=1){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%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=k(d(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)}},a=0;a<e;a+=4){var s=i(4294967296*(t||Math.random()));t=987654071*s(),n.push(4294967296*s()|0)}return new r(n,e)}}]),r}(Lt),Pt={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).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 Rt(r,t/2)}},Mt=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 Rt(r,t)},It=function(e){return Mt(unescape(encodeURIComponent(e)))},Ut=function(e){l(r,e);var t=_(r);function r(){var e;return s(this,r),(e=t.call(this))._minBufferSize=0,e}return u(r,[{key:"reset",value:function(){this._data=new Rt,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=It(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,a=r.sigBytes,s=a/(4*n),o=(s=e?Math.ceil(s):Math.max((0|s)-this._minBufferSize,0))*n,u=Math.min(4*o,a);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new Rt(t,u)}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(Lt),zt=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new Lt,e),n.reset(),n}return u(r,[{key:"reset",value:function(){k(d(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 Nt(e,r).finalize(t)}}}]),r}(Ut),Nt=function(e){l(r,e);var t=_(r);function r(e,n){var i;s(this,r),i=t.call(this);var a=new e;i._hasher=a;var o=n;"string"==typeof o&&(o=It(o));var u=a.blockSize,c=4*u;o.sigBytes>c&&(o=a.finalize(n)),o.clamp();var l=o.clone();i._oKey=l;var d=o.clone();i._iKey=d;for(var h=l.words,f=d.words,p=0;p<u;p+=1)h[p]^=1549556828,f[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return u(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}(Lt),qt={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o+=1)i.push(n.charAt(s>>>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 a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var n=[],i=0,a=0;a<t;a+=1)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=s<<24-i%4*8,i+=1}return Rt.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Ft=[],Vt=0;Vt<64;Vt+=1)Ft[Vt]=4294967296*Math.abs(Math.sin(Vt+1))|0;var Gt=function(e,t,r,n,i,a,s){var o=e+(t&r|~t&n)+i+s;return(o<<a|o>>>32-a)+t},Ht=function(e,t,r,n,i,a,s){var o=e+(t&n|r&~n)+i+s;return(o<<a|o>>>32-a)+t},Kt=function(e,t,r,n,i,a,s){var o=e+(t^r^n)+i+s;return(o<<a|o>>>32-a)+t},Wt=function(e,t,r,n,i,a,s){var o=e+(r^(t|~n))+i+s;return(o<<a|o>>>32-a)+t},Qt=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"_doReset",value:function(){this._hash=new Rt([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,a=e[i];r[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var s=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],g=r[t+11],_=r[t+12],b=r[t+13],k=r[t+14],x=r[t+15],w=s[0],S=s[1],E=s[2],j=s[3];w=Gt(w,S,E,j,o,7,Ft[0]),j=Gt(j,w,S,E,u,12,Ft[1]),E=Gt(E,j,w,S,c,17,Ft[2]),S=Gt(S,E,j,w,l,22,Ft[3]),w=Gt(w,S,E,j,d,7,Ft[4]),j=Gt(j,w,S,E,h,12,Ft[5]),E=Gt(E,j,w,S,f,17,Ft[6]),S=Gt(S,E,j,w,p,22,Ft[7]),w=Gt(w,S,E,j,v,7,Ft[8]),j=Gt(j,w,S,E,y,12,Ft[9]),E=Gt(E,j,w,S,m,17,Ft[10]),S=Gt(S,E,j,w,g,22,Ft[11]),w=Gt(w,S,E,j,_,7,Ft[12]),j=Gt(j,w,S,E,b,12,Ft[13]),E=Gt(E,j,w,S,k,17,Ft[14]),S=Gt(S,E,j,w,x,22,Ft[15]),w=Ht(w,S,E,j,u,5,Ft[16]),j=Ht(j,w,S,E,f,9,Ft[17]),E=Ht(E,j,w,S,g,14,Ft[18]),S=Ht(S,E,j,w,o,20,Ft[19]),w=Ht(w,S,E,j,h,5,Ft[20]),j=Ht(j,w,S,E,m,9,Ft[21]),E=Ht(E,j,w,S,x,14,Ft[22]),S=Ht(S,E,j,w,d,20,Ft[23]),w=Ht(w,S,E,j,y,5,Ft[24]),j=Ht(j,w,S,E,k,9,Ft[25]),E=Ht(E,j,w,S,l,14,Ft[26]),S=Ht(S,E,j,w,v,20,Ft[27]),w=Ht(w,S,E,j,b,5,Ft[28]),j=Ht(j,w,S,E,c,9,Ft[29]),E=Ht(E,j,w,S,p,14,Ft[30]),S=Ht(S,E,j,w,_,20,Ft[31]),w=Kt(w,S,E,j,h,4,Ft[32]),j=Kt(j,w,S,E,v,11,Ft[33]),E=Kt(E,j,w,S,g,16,Ft[34]),S=Kt(S,E,j,w,k,23,Ft[35]),w=Kt(w,S,E,j,u,4,Ft[36]),j=Kt(j,w,S,E,d,11,Ft[37]),E=Kt(E,j,w,S,p,16,Ft[38]),S=Kt(S,E,j,w,m,23,Ft[39]),w=Kt(w,S,E,j,b,4,Ft[40]),j=Kt(j,w,S,E,o,11,Ft[41]),E=Kt(E,j,w,S,l,16,Ft[42]),S=Kt(S,E,j,w,f,23,Ft[43]),w=Kt(w,S,E,j,y,4,Ft[44]),j=Kt(j,w,S,E,_,11,Ft[45]),E=Kt(E,j,w,S,x,16,Ft[46]),S=Kt(S,E,j,w,c,23,Ft[47]),w=Wt(w,S,E,j,o,6,Ft[48]),j=Wt(j,w,S,E,p,10,Ft[49]),E=Wt(E,j,w,S,k,15,Ft[50]),S=Wt(S,E,j,w,h,21,Ft[51]),w=Wt(w,S,E,j,_,6,Ft[52]),j=Wt(j,w,S,E,l,10,Ft[53]),E=Wt(E,j,w,S,m,15,Ft[54]),S=Wt(S,E,j,w,u,21,Ft[55]),w=Wt(w,S,E,j,v,6,Ft[56]),j=Wt(j,w,S,E,x,10,Ft[57]),E=Wt(E,j,w,S,f,15,Ft[58]),S=Wt(S,E,j,w,b,21,Ft[59]),w=Wt(w,S,E,j,d,6,Ft[60]),j=Wt(j,w,S,E,g,10,Ft[61]),E=Wt(E,j,w,S,c,15,Ft[62]),S=Wt(S,E,j,w,y,21,Ft[63]),s[0]=s[0]+w|0,s[1]=s[1]+S|0,s[2]=s[2]+E|0,s[3]=s[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),a=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,o=s.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return s}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(zt);zt._createHelper(Qt),zt._createHmacHelper(Qt);var Yt=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).cfg=Object.assign(new Lt,{keySize:4,hasher:Qt,iterations:1},e),n}return u(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=Rt.create(),s=a.words,o=n.keySize,u=n.iterations;s.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();a.concat(r)}return a.sigBytes=4*o,a}}]),r}(Lt),Xt=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this)).cfg=Object.assign(new Lt,i),a._xformMode=e,a._key=n,a.reset(),a}return u(r,[{key:"reset",value:function(){k(d(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?sr:ir};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}(Ut);Xt._ENC_XFORM_MODE=1,Xt._DEC_XFORM_MODE=2,Xt.keySize=4,Xt.ivSize=4;var Jt=function(e){l(r,e);var t=_(r);function r(e,n){var i;return s(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return u(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}(Lt);function Zt(e,t,r){var n,i=e,a=this._iv;a?(n=a,this._iv=void 0):n=this._prevBlock;for(var s=0;s<r;s+=1)i[t+s]^=n[s]}var $t=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Jt);$t.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;Zt.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}($t),$t.Decryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),Zt.call(this,e,t,n),this._prevBlock=i}}]),r}($t);var er={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var o=Rt.create(a,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},tr=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this,e,n,Object.assign({mode:$t,padding:er},i))).blockSize=4,a}return u(r,[{key:"reset",value:function(){var e;k(d(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}(Xt),rr=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).mixIn(e),n}return u(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(Lt),nr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?Rt.create([1398893684,1701076831]).concat(r).concat(t):t).toString(qt)},parse:function(e){var t,r=qt.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=Rt.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),rr.create({ciphertext:r,salt:t})}},ir=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Lt,this.cfg,n),a=e.createEncryptor(r,i),s=a.finalize(t),o=a.cfg;return rr.create({ciphertext:s,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:a.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new Lt,this.cfg,n);return i=this._parse(i,a.format),e.createDecryptor(r,a).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(Lt);ir.cfg=Object.assign(new Lt,{format:nr});var ar={execute:function(e,t,r,n){var i=n;i||(i=Rt.random(8));var a=Yt.create({keySize:t+r}).compute(e,i),s=Rt.create(a.words.slice(t),4*r);return a.sigBytes=4*t,rr.create({key:a,iv:s,salt:i})}},sr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Lt,this.cfg,n),a=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=a.iv;var s=ir.encrypt.call(this,e,t,a.key,i);return s.mixIn(a),s}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new Lt,this.cfg,n);i=this._parse(i,a.format);var s=a.kdf.execute(r,e.keySize,e.ivSize,i.salt);return a.iv=s.iv,ir.decrypt.call(this,e,i,s.key,a)}}]),r}(ir);sr.cfg=Object.assign(ir.cfg,{kdf:ar});for(var or=[],ur=[],cr=[],lr=[],dr=[],hr=[],fr=[],pr=[],vr=[],yr=[],mr=[],gr=0;gr<256;gr+=1)mr[gr]=gr<128?gr<<1:gr<<1^283;for(var _r=0,br=0,kr=0;kr<256;kr+=1){var xr=br^br<<1^br<<2^br<<3^br<<4;xr=xr>>>8^255&xr^99,or[_r]=xr,ur[xr]=_r;var wr=mr[_r],Sr=mr[wr],Er=mr[Sr],jr=257*mr[xr]^16843008*xr;cr[_r]=jr<<24|jr>>>8,lr[_r]=jr<<16|jr>>>16,dr[_r]=jr<<8|jr>>>24,hr[_r]=jr,jr=16843009*Er^65537*Sr^257*wr^16843008*_r,fr[xr]=jr<<24|jr>>>8,pr[xr]=jr<<16|jr>>>16,vr[xr]=jr<<8|jr>>>24,yr[xr]=jr,_r?(_r=wr^mr[mr[mr[Er^wr]]],br^=mr[mr[br]]):_r=br=1}var Tr=[0,1,2,4,8,16,32,64,128,27,54],Ar=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(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 a=this._keySchedule,s=0;s<i;s+=1)s<n?a[s]=r[s]:(e=a[s-1],s%n?n>6&&s%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^=Tr[s/n|0]<<24),a[s]=a[s-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?a[c]:a[c-4],o[u]=u<4||c<=4?e:fr[or[e>>>24]]^pr[or[e>>>16&255]]^vr[or[e>>>8&255]]^yr[or[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,cr,lr,dr,hr,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,fr,pr,vr,yr,ur),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,a,s,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]^a[h>>>8&255]^s[255&f]^r[p];p+=1;var m=n[d>>>24]^i[h>>>16&255]^a[f>>>8&255]^s[255&l]^r[p];p+=1;var g=n[h>>>24]^i[f>>>16&255]^a[l>>>8&255]^s[255&d]^r[p];p+=1;var _=n[f>>>24]^i[l>>>16&255]^a[d>>>8&255]^s[255&h]^r[p];p+=1,l=y,d=m,h=g,f=_}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}(tr);Ar.keySize=8,tr._createHelper(Ar);var Dr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Jt);Dr.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,a=this._iv,s=this._counter;a&&(this._counter=a.slice(0),s=this._counter,this._iv=void 0);var o=s.slice(0);n.encryptBlock(o,0),s[i-1]=s[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(Dr),Dr.Decryptor=Dr.Encryptor;var Or=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r})),Cr=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}();function Br(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a,s=[],o=[];if(n){var u,c,l,d=null===(u=n.mdia)||void 0===u||null===(c=u.minf)||void 0===c?void 0:c.stbl;if(!d)return;var h=null===(l=n.mdia.mdhd)||void 0===l?void 0:l.timescale,f=d.stts,p=d.stsc,v=d.stsz,y=d.stco,m=d.stss,g=d.ctts;if(!(h&&f&&p&&v&&y&&m))return;a=(s=Lr(t,h,f,p,v,y,m,g)).map((function(e){return e.duration}))}if(i){var _,b,k,x=null===(_=i.mdia)||void 0===_||null===(b=_.minf)||void 0===b?void 0:b.stbl;if(!x)return;var w=null===(k=i.mdia.mdhd)||void 0===k?void 0:k.timescale,S=x.stts,E=x.stsc,j=x.stsz,T=x.stco;if(!(w&&S&&E&&j&&T))return;o=Lr(t,w,S,E,j,T,null,null,a)}return{videoSegments:s,audioSegments:o}}}}function Lr(e,t,r,n,i,a,s,o,u){var c,l,d,h,f=[],p=[],v=[],y=n.entries,m=a.entries,g=i.entrySizes,_=null==s?void 0:s.entries,b=null==o?void 0:o.entries;b&&(c=[],b.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)c.push(r)}))),_&&(l={},_.forEach((function(e){l[e-1]=!0})));var k=0,x=0,S=0,E=0,j=0,T=y[0].samplesPerChunk,A=y[1]?y[1].firstChunk-1:1/0,D=0,O=-1;r.entries.forEach((function(e){var t=e.count,r=e.delta;h=r;for(var n=0;n<t;n++)d={dts:D,startTime:k,duration:h,size:g[x]||i.sampleSize,offset:m[S]+j,index:x},_&&(d.keyframe=l[x],d.keyframe?(O++,p.push([d]),v.push(d.duration)):(p[p.length-1].push(d),v[p.length-1]+=d.duration),d.gopId=O),c&&x<c.length&&(d.pts=D+c[x]),0===x&&(d.pts=0),f.push(d),k+=h,D+=r,++x<T?j+=d.size:(S++,j=0,S>=A&&(E++,A=y[E+1]?y[E+1].firstChunk-1:1/0),T+=y[E].samplesPerChunk)}));var C=f.length;if(C&&(!s||f[0].keyframe)){var B,L=[],R=[],P=0,M=0,I=function(e){var r;B=R[R.length-1],L.push({index:L.length,startTime:(null===(r=L[L.length-1])||void 0===r?void 0:r.endTime)||R[0].startTime/t,endTime:(B.startTime+B.duration)/t,duration:e,range:[R[0].offset,B.offset+B.size],frames:R}),P=0,R=[]};if(s)for(var U=e*t,z=0,N=p.length;z<N;z++){var q;P+=v[z],(q=R).push.apply(q,w(p[z])),z+1<N?(0===z||P>U)&&I(P/t):I(P/t)}else for(var F=(u=u||[])[0]||e,V=0;V<C;V++){R.push(f[V]);var G=(P+=f[V].duration)/t;(V+1>=C||G+M>=F)&&(M+=G-F,I(G),F=u[L.length]||e)}return L}}function Rr(e){var t="",r="",n=0,i=0,a=0,s=0,o=0,u=0,c=0;e.mvhd&&(o=e.mvhd.duration/e.mvhd.timescale);var l=e.trak;if(l){var d,h,f,p,v,y,m,g,_,b,k,x,w,S,E,j,T,A=l.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),D=l.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),O=null;if(A)if(O=null===(h=A.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.stsd.entries[0])if(n=O.width,i=O.height,u=null===(v=A.mdia)||void 0===v||null===(y=v.mdhd)||void 0===y?void 0:y.timescale,t=null===(m=O.avcC||O.hvcC)||void 0===m?void 0:m.codec,"encv"===O.type)d=null===(g=O.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID;if(D)if(O=null===(b=D.mdia)||void 0===b||null===(k=b.minf)||void 0===k||null===(x=k.stbl)||void 0===x?void 0:x.stsd.entries[0])if(a=O.channelCount,s=O.sampleRate,r=null===(w=O.esds)||void 0===w?void 0:w.codec,c=null===(S=D.mdia)||void 0===S||null===(E=S.mdhd)||void 0===E?void 0:E.timescale,"enca"===O.type)d=d||(null===(j=O.sinf)||void 0===j||null===(T=j.schi)||void 0===T?void 0:T.tenc.default_KID);return{kid:d?d.join(""):null,videoCodec:t,audioCodec:r,width:n,height:i,videoTimescale:u,audioChannelCount:a,audioSampleRate:s,duration:o,audioTimescale:c,moov:e}}}function Pr(e){return"number"==typeof e&&!Number.isNaN(e)}var Mr=["vid","cache"],Ir=function(e){l(S,e);var n,i,o,d,h,f,p,v,g,b,k,w=_(S);function S(e){var r;s(this,S),c(m(r=w.call(this)),"vid",""),c(m(r),"url",""),c(m(r),"meta",{}),c(m(r),"downloadInfo",[]),c(m(r),"videoSegments",[]),c(m(r),"audioSegments",[]),c(m(r),"cache",null),c(m(r),"_currentSegmentIndex",-1),c(m(r),"_currentLoadingSegmentIndex",-1),c(m(r),"buffer",void 0),c(m(r),"_error",void 0),c(m(r),"_transformError",(function(e){return e})),r._config=t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",cache:null},e);var n=r._config,i=n.vid,a=n.cache,o=y(n,Mr);return r.cache=a||new Cr,r.vid=i||o.url,r.url=o.url,o.transformError=r._transformError,r.logger=new Q("MP4Loader_"+r.vid),e.openLog&&Q.enable(),o.logger=r.logger,r._loader=new Te(o),r._loader.on(me,(function(e){r.emit(me,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Pr(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Pr(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s,o){var u,c,l,d,h=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=x(i,2),c=u[0],l=u[1],this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[c,l]),d=function(){var e=a(r().mark((function e(t,i,a){var u,d,f,p,v,y,m,g;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h.meta&&null!=a&&a.range&&a.range.length>0&&a.range[1]>=l&&(i=!0,h.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=a&&a.range&&a.range.length>0&&a.range[1]<l&&(i=!1,h.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),h.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",a.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",h._error),!h._error&&t&&t.byteLength>0&&s(t,i,a),!h.meta.moov&&!h._error){e.next=6;break}return e.abrupt("return");case 6:if(!(t&&t.byteLength>0)){e.next=44;break}if(h.buffer=Ee(h.buffer,t),u=kt.findBox(h.buffer,["moov"])[0]){e.next=23;break}if(d=kt.findBox(h.buffer,["mdat"])[0],!i){e.next=23;break}if(d){e.next=18;break}return h._error=!0,s(null,i,a,{err:"cannot find moov or mdat box"}),e.abrupt("return");case 18:return f=d.start+d.size,e.next=21,h.loadData([f,""],n,o);case 21:(p=e.sent)&&(u=kt.findBox(p.data,["moov"])[0]);case 23:if(!(u&&i&&u.size>u.data.length)){e.next=27;break}return h.logger.debug("[loadMetaProcess],moov not all, range,",a.range[1],",dataLen,",h.buffer.byteLength,", state,",i),e.next=27,h.loadMetaProcess(n,[a.range[1],u.start+u.size-1],s);case 27:if(!(u&&u.size<=u.data.length)||h.meta.moov){e.next=44;break}if(v=kt.moov(u)){e.next=33;break}return h._error=!0,s(null,i,a,{err:"cannot parse moov box"}),e.abrupt("return");case 33:if(y=Br(v,h._config.segmentDuration)){e.next=38;break}return h._error=!0,s(null,i,a,{err:"cannot parse segments"}),e.abrupt("return");case 38:h.meta=Rr(v),m=y.videoSegments,g=y.audioSegments,h.videoSegments=m,h.audioSegments=g,h.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:h.meta,videoSegments:m,audioSegments:g}});case 44:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),e.next=6,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:d},o));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n,i){var a,s,o,u,c,l,d,h,f;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[],this.logger.debug("[loadMeta start]"),e.next=4,this.loadData([0,n||this._config.moovEnd],t,i);case 4:if(s=e.sent){e.next=7;break}return e.abrupt("return");case 7:if(a.push(s),o=kt.findBox(s.data,["moov"])[0]){e.next=23;break}if(u=kt.findBox(s.data,["mdat"])[0]){e.next=13;break}throw new Or("cannot find moov or mdat box",s.data);case 13:return c=u.start+u.size,e.next=16,this.loadData([c],t,i);case 16:if(s=e.sent){e.next=19;break}return e.abrupt("return");case 19:if(a.push(s),o=kt.findBox(s.data,["moov"],c)[0]){e.next=23;break}throw new Or("cannot find moov box",s.data);case 23:if(!(o.size>o.data.length)){e.next=31;break}return e.next=26,this.loadData([s.data.length,o.start+o.size-1],t,i);case 26:if(s=e.sent){e.next=29;break}return e.abrupt("return");case 29:a.push(s),o.data=Ee(o.data,s.data);case 31:if(l=kt.moov(o)){e.next=34;break}throw new Or("cannot parse moov box",o.data);case 34:if(d=Br(l,this._config.segmentDuration)){e.next=37;break}throw new Or("cannot parse segments",o.data);case 37:return this.meta=Rr(l),h=d.videoSegments,f=d.audioSegments,this.videoSegments=h,this.audioSegments=f,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:h,audioSegments:f,responses:a});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Br(e.moov,this._config.segmentDuration),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(f=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"preload",value:(h=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length>0&&void 0!==t[0]&&t[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i,a){var s,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this._getCacheKey(n),e.next=3,this.cache.get(s);case 3:if(o=e.sent){e.next=11;break}return c=a&&a.url?a.url:this.url,e.next=8,this._loader.load(c,t({range:n,vid:this.vid},a));case 8:u=e.sent,e.next=12;break;case 11:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 12:if(u){e.next=14;break}return e.abrupt("return");case 14:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(_e);return Ir}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/esnext.typed-array.at.js"),require("core-js/modules/es.typed-array.copy-within.js"),require("core-js/modules/es.typed-array.every.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.filter.js"),require("core-js/modules/es.typed-array.find.js"),require("core-js/modules/es.typed-array.find-index.js"),require("core-js/modules/esnext.typed-array.find-last.js"),require("core-js/modules/esnext.typed-array.find-last-index.js"),require("core-js/modules/es.typed-array.for-each.js"),require("core-js/modules/es.typed-array.includes.js"),require("core-js/modules/es.typed-array.index-of.js"),require("core-js/modules/es.typed-array.iterator.js"),require("core-js/modules/es.typed-array.join.js"),require("core-js/modules/es.typed-array.last-index-of.js"),require("core-js/modules/es.typed-array.map.js"),require("core-js/modules/es.typed-array.reduce.js"),require("core-js/modules/es.typed-array.reduce-right.js"),require("core-js/modules/es.typed-array.reverse.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.slice.js"),require("core-js/modules/es.typed-array.some.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.subarray.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/es.typed-array.to-string.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),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.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.array.concat.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.function.name.js","core-js/modules/es.array.map.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.join.js","core-js/modules/es.array.includes.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.filter.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/esnext.typed-array.at.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/esnext.typed-array.find-last.js","core-js/modules/esnext.typed-array.find-last-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.string.replace.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.constructor.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.symbol.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.string.includes.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","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).MP4Loader=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(D){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof f?t:f,s=Object.create(a.prototype),o=new j(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(D){return{type:"throw",arg:D}}}e.wrap=l;var h={};function f(){}function p(){}function v(){}var y={};c(y,s,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(T([])));g&&g!==t&&n.call(g,s)&&(y=g);var _=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 r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=w(s,r);if(o){if(o===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 a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,c(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(l(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=T,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},e}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,j(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=f()?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&&h(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},v(e)}function y(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function _(e){var t=f();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,s,o=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function j(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var T,A=function(){function e(){s(this,e)}return u(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(s[1]=u)}else r.push([e.start(n),e.end(n)])}else r.push([e.start(n),e.end(n)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,a=0,s=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=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:a,index:s,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}}]),e}(),D="undefined"!=typeof window,O="network",C="network_timeout",B="network_forbidden",L="network_notfound",R="network_range_not_satisfiable",P="demux",M="remux",I="media",U="drm",z="other",N="runtime",q={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"},F=(c(T={},"manifest",{HLS:1100,DASH:1200}),c(T,O,2100),c(T,C,2101),c(T,B,2103),c(T,L,2104),c(T,R,2116),c(T,P,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(T,M,{FMP4:4100,MP4:4200}),c(T,I,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,EME_HIJACK:5301}),c(T,U,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(T,z,8e3),c(T,N,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),T),V=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===C?O:e,u.originError=i,u.ext=a,u.errorCode=F[e][n]||F[e],u.errorMessage=u.message,u.errorCode||(u.errorType=z,u.errorCode=F[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=z),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?C:O,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(v(Error)),G={DEBUG:1,LOG:2,WARN:3,ERROR:4},H=["Boolean","Number","String","Undefined","Null","Date","Object"],K=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return u(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[G.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,[this._prefix,W()].concat(n))}},{key:"log",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[G.LOG].concat(n)),e.disabled||(t=console).log.apply(t,[this._prefix,W()].concat(n))}},{key:"warn",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[G.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,[this._prefix,W()].concat(n))}},{key:"error",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[G.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,[this._prefix,W()].concat(n))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var a=n.map((function(e){return Y(e)}));t=this._prefix+W()+JSON.stringify(a)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function W(){return(new Date).toLocaleString()}function Q(e){if("object"!==n(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function Y(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!H.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=Q(e[s]):"object"===n(e[s])?i[s]=Y(e[s],t,r+1):i[s]=e[s]);return i}}function X(){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 J(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}c(K,"disabled",!0);var Z=function(e){try{return JSON.stringify(e)}catch(t){return""}};function $(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return D?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function ee(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var te="appendBuffer",re="removeBuffer",ne="updateDuration",ie=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",X()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),c(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==ne&&t.shift(),r){var i,a=J()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),Z(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(i=n._sourceBuffer[e])||void 0===i?void 0:i.buffered)),a,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:a}),n._startQueue(e)}}})),c(this,"_onSBUpdateError",(function(e,t){var r=n._queue[e];if(r){var i=r[0];i&&(n._logger.error("UpdateError",e,i.opName,i.context),i.promise.reject(new V(I,q.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new K("MSE"),this._config.openLog&&K.enable()}var t,n,i;return u(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var n=e._queue[r];Array.isArray(n)&&(t||(t=n.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!ee(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var n=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{n=Math.max(t.bufferEnd(e)||0,n)}catch(r){}})),e<n)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),ne,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var n=J()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=X()}return this._openPromise}},{key:"bindMedia",value:(i=a(r().mark((function e(t){var n,i,a,s,o=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(n=$(this._config.preferMMS),t&&n){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,i=this.mediaSource=new n,a=ee(i),this._st=J(),s=function e(){var r=J()-o._st;o._logger.debug("sourceopen"),i.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),o._openPromise.resolve({costtime:r})},i.addEventListener("sourceopen",s),a&&(i.addEventListener("startstreaming",this._onStartStreaming),i.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(i),t.src=this._url,t.disableRemotePlayback=a,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(n=a(r().mark((function e(){var t,n,i,a=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=a._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}})),ee(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(r){}this.media=null}this.mediaSource=null,this._openPromise=X(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new V(I,q.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=J(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),te,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var a=i._sourceBuffer[e];t>=r||!a?i._onSBUpdateEnd(e):(i._opst=J(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),re,n,a)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n.remove(i,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var n=t._sourceBuffer[r];e=t.remove(r,0,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 a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:X(),opName:r,context:n};return i?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=a(r().mark((function e(t,n,i){var a,s,o=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=X();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(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 V(I,q.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new V(I,q.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:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=$();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();c(ie,"VIDEO","video"),c(ie,"AUDIO","audio");var ae="fetch",se="xhr",oe="arraybuffer",ue="text",ce="json",le=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(m(o=t.call(this,a)),"retryCount",0),c(m(o),"isTimeout",!1),c(m(o),"loaderType",ae),c(m(o),"startTime",0),c(m(o),"endTime",0),c(m(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(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,i=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===de.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(pe(e),"=").concat(pe(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function ye(e,t,r,n,i,a,s,o,u,c,l){return i=null!=i?parseFloat(i):null,n=parseInt(n||"0",10),Number.isNaN(n)&&(n=0),{data:e,done:t,options:{range:u,vid:c,index:o,contentLength:n,age:i,startTime:a,firstByteTime:s,endTime:Date.now(),priOptions:l},response:r}}function me(e,t){return Math.round(8*e*1e3/t/1024)}var ge="real_time_speed",_e={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var 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 a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(_e);var be=_e.exports,ke=2097152,xe=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(m(e=n.call(this)),"_abortController",null),c(m(e),"_timeoutTimer",null),c(m(e),"_reader",null),c(m(e),"_response",null),c(m(e),"_aborted",!1),c(m(e),"_index",-1),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_running",!1),c(m(e),"_logger",null),c(m(e),"_vid",""),c(m(e),"_onProcessMinLen",0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,h=e.onCancel,f=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,g=e.method,_=e.headers,b=e.body,k=e.mode,x=e.credentials,w=e.cache,S=e.redirect,E=e.referrer,j=e.referrerPolicy,T=e.onProcessMinLen,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||i,this._priOptions=A||{};var D={method:g,headers:_,body:b,mode:k,credentials:x,cache:w,redirect:S,referrer:E,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},O=!1;clearTimeout(this._timeoutTimer),i=ve(i,y);var C=fe(f);C&&(_=v?v.headers:D.headers=D.headers||(Headers?new Headers:{}),Headers&&_ instanceof Headers?_.append("Range",C):_.Range=C),o&&(this._timeoutTimer=setTimeout((function(){if(O=!0,n.cancel(),d){var e=new le(i,D,null,"timeout");e.isTimeout=!0,d(e,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})}}),o));var B=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",f),new Promise((function(e,t){fetch(v||i,v?void 0:D).then(function(){var s=a(r().mark((function a(s){var o,d,h,v;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(p&&(s=p(s,i)||s),s.ok){r.next=7;break}throw new le(i,D,s,"bad network response");case 7:if(o=Date.now(),u!==ue){r.next=15;break}return r.next=11,s.text();case 11:d=r.sent,n._running=!1,r.next=37;break;case 15:if(u!==ce){r.next=22;break}return r.next=18,s.json();case 18:d=r.sent,n._running=!1,r.next=37;break;case 22:if(!c){r.next=29;break}return n.resolve=e,n.reject=t,n._loadChunk(s,c,B,o),r.abrupt("return");case 29:return r.next=31,s.arrayBuffer();case 31:d=r.sent,d=new Uint8Array(d),n._running=!1,h=Date.now()-B,v=me(d.byteLength,h),n.emit(ge,{speed:v,len:d.byteLength,time:h,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",l,",range,",f),e(ye(d,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),B,o,l,f,n._vid,n._priOptions));case 39:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!O||((e=e instanceof le?e:new le(i,D,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=B,e.endTime=Date.now(),e.isTimeout=O,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(t){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new le(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(ke),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),h=function(){var o=a(r().mark((function a(){var o,f,p,v,y,m,g,_;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(f=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,p=f+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[p,p],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:v=u.value?u.value.byteLength:0,s._receivedLength+=v,s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",p,", end,",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<ke?(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:n,firstByteTime:i,priOptions:s._priOptions},e),u.done?(g=Date.now()-n,_=me(s._receivedLength,g),s.emit(ge,{speed:_,len:s._receivedLength,time:g,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"),n,i,s._index,s._range,s._vid,s._priOptions))):h();case 25:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.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)}}]),i}(be);var we=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(m(e=r.call(this)),"_xhr",null),c(m(e),"_aborted",!1),c(m(e),"_timeoutTimer",null),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_url",null),c(m(e),"_onProgress",null),c(m(e),"_index",-1),c(m(e),"_headers",null),c(m(e),"_currentChunkSizeKB",384),c(m(e),"_timeout",null),c(m(e),"_xhr",null),c(m(e),"_withCredentials",null),c(m(e),"_startTime",-1),c(m(e),"_loadCompleteResolve",null),c(m(e),"_loadCompleteReject",null),c(m(e),"_runing",!1),c(m(e),"_logger",!1),c(m(e),"_vid",""),c(m(e),"_responseType",void 0),c(m(e),"_credentials",void 0),c(m(e),"_method",void 0),c(m(e),"_transformResponse",void 0),c(m(e),"_firstRtt",void 0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(n,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=ve(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof le?e:new le(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===oe&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,n=this._range[1];t<this._range[1]-r&&(n=r+t),e=[r,n],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,n,i;t._running=!1;var a=new le(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.status)+",statusText,"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.statusText));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new le(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var n=this._headers||{},i=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(a){a.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new le(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===oe){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,h=me(this._receivedLength,d);this.emit(ge,{speed:h,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var f={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(ye(this._onProgress?null:s,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,k(d(n.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(e.getAllResponseHeaders().trim().split("\r\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value.split(": ");r[i[0].toLowerCase()]=i.slice(1).join(": ")}}catch(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(be),Se=["retry","retryDelay","onRetryError","transformError"],Ee=function(){function e(t,r){s(this,e),this.promise=X(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new K("Loader")),this._loaderType=t,this._loader=t===ae&&"undefined"!=typeof fetch?new xe:new we,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=y(t,Se),c=function(){var t=a(r().mark((function t(){var a,l,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:a=t.sent,e.promise.resolve(a),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,o&&(l=o(l)||l),s&&e._retryCount>0&&s(l,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=n)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}();function je(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function Te(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Ae=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(m(r=i.call(this,e)),"type",ae),c(m(r),"_queue",[]),c(m(r),"_alive",[]),c(m(r),"_currentTask",null),c(m(r),"_finnalUrl",""),c(m(r),"_config",void 0),r._config=function(e){return t({loaderType:ae,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:ue,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),r._config.loaderType!==se&&xe.isSupported()||(r.type=se),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===ae}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&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 Ee(this.type,r);return n.loader.on(ge,(function(e){t.emit(ge,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,Te();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return xe.isSupported()}}]),o}(be),De="video",Oe="audio",Ce="metadata",Be="avc",Le="hevc",Re="aac",Pe="g7110a",Me="g7110m",Ie="LARGE_AV_SHIFT",Ue="LARGE_VIDEO_GAP",ze="LARGE_VIDEO_GAP_BETWEEN_CHUNK",Ne="LARGE_AUDIO_GAP",qe="AUDIO_FILLED",Fe="AUDIO_DROPPED",Ve=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",De),c(this,"codecType",Be),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),Ge=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",Oe),c(this,"codecType",Re),c(this,"pid",-1),c(this,"codec",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&this.codecType===Re)}},{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}(),He=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),Ke=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),We=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),Qe=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Ye=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Xe=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",Ce),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),Je=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(0!=(this._word&2147483648>>>e))return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Ze=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();c(Ze,"disabled",!0);var $e=function(){function e(){s(this,e)}return u(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,a=t.length;i<a;)if(n[i]<128)r.push(String.fromCharCode(n[i])),++i;else{if(n[i]<192);else if(n[i]<224){if(e._checkContinuation(n,i,1)){var s=(31&n[i])<<6|63&n[i+1];if(s>=128){r.push(String.fromCharCode(65535&s)),i+=2;continue}}}else if(n[i]<240){if(e._checkContinuation(n,i,2)){var o=(15&n[i])<<12|(63&n[i+1])<<6|63&n[i+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),i+=3;continue}}}else if(n[i]<248&&e._checkContinuation(n,i,3)){var u=(7&n[i])<<18|(63&n[i+1])<<12|(63&n[i+2])<<6|63&n[i+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),i+=4;continue}}r.push(String.fromCharCode(65533)),++i}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var n=e;if(t+r<n.length){for(;r--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),et="undefined"!=typeof window,tt=et&&navigator.userAgent.toLocaleLowerCase(),rt=et&&/^((?!chrome|android).)*safari/.test(tt),nt=et&&tt.includes("firefox"),it=et&&tt.includes("android");function at(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}var st=Math.pow(2,32);function ot(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function ut(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 ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ut(e,t)*st+ut(e,t+4)}function lt(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 dt(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 ht=function(){function e(){s(this,e)}return u(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=[],a=0;a+t<n;)if(r=ut(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>n)break;i.push(e.subarray(a,a+r)),a+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,a=0,s="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)a+=255,n++;if(a+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)s+=e[n].toString(16),n++;return{payload:e.subarray(n,n+a),type:i,size:a,uuid:s}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}}]),e}(),ft=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,a.push(l),r||(r=e.parseSPS(ht.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&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Je(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var 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(),_=(m=E)/(g=2*S)}}return{codec:lt(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,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:g,fps:_,fixedFrame:y}}}]),e}(),pt=function(){function e(){s(this,e)}return u(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var a=i,s=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,d=1+((192&t[i+2])>>>6),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]),s.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType: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,a=e.FREQ[n];if(a){var s=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s.config,codec:s.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,a=[];return nt?e>=6?(n=5,i=e-3):(n=2,i=e):it?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),a[0]=n<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===n&&(a[1]|=(14&i)>>1,a[2]=(1&i)<<7,a[2]|=8,a[3]=0),{config:a,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();c(pt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var vt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){a=63&t[h],s=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<s;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(a){case 32:var y=t.subarray(h,h+o);n||(n=e.parseVPS(ht.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(h,h+o);i||(i=e.parseSPS(ht.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 Je(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 Je(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,d,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!==a&&2!==a||0!==o?1:2,y=1===a&&0===o?2:1;h-=v*(c+u),f-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);var a=[],s=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==s[u]&&e.readBits(8)}}]),e}(),yt=1e3,mt=5e3,gt=function(){function e(t,r,n){s(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return u(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,a=this.audioTrack;!r&&n||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var i=e.samples[0],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:ze,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:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:Ue,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,a=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=a=n[0].dts),this._baseDts=Math.min(i,a);var s=a-i;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:Ie,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=e.codecType===Re?pt.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===Re?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],c=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=yt&&!rt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>mt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:qe,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new Ke(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(s,0,f),this._audioNextPts+=n,s++}s--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>mt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:Fe,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(c)>yt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>mt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:Ne,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===Re?pt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),_t=function(){function e(){s(this,e)}return u(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var 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,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=m.data,_=m.size;r.push(g),i+=_}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=$e.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=$e.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}(),bt=new Ze("FlvDemuxer"),kt=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Ve,this.audioTrack=r||new Ge,this.metadataTrack=n||new Xe,this._fixer=new gt(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(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,a=this.videoTrack,s=this.metadataTrack;if(!r&&n||(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),i.reset(),s.reset()):(a.samples=[],i.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],i.warnings=[],this._remainingData&&(t=at(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:a,audioTrack:i,metadataTrack:s};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");i.present=(4&t[4])>>>2!=0,a.present=0!=(1&t[4]),this._headerParsed=!0,o=ut(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):bt.warn("Invalid tag type: ".concat(u)),(h=ut(t,o+=c))!==11+c&&bt.warn("Invalid PrevTagSize ".concat(h," (").concat(11+c,")")),o+=4;return o<f&&(this._remainingData=t.subarray(o)),i.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:i,metadataTrack:s}}},{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 bt.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[a],i.sampleSize=s?16:8,i.channelCount=o+1}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?Pe:Me,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new Ke(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=Re,0===e[1]){var n=pt.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(),bt.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Ke(t,e.subarray(2)))}else bt.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var n=(240&e[0])>>>4,i=15&e[0],a=this.videoTrack;if(7!==i&&12!==i)return a.reset(),void bt.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?Le:Be;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=s?vt.parseHEVCDecoderConfigurationRecord(c):ft.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),h&&(a.codec=h.codec,a.width=h.width,a.height=h.height,a.sarRatio=h.sarRatio,a.fpsNum=h.fpsNum,a.fpsDen=h.fpsDen),p.length&&(a.sps=p),f.length&&(a.pps=f),v&&v.length&&(a.vps=v),y&&(a.nalUnitSize=y)}else bt.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=ht.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var g=new He(t+u,t,m);1===n&&g.setToKeyframe(),a.samples.push(g),m.forEach((function(e){var n=s?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==n||s&&5===n)break;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Ye(ht.parseSEI(ht.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else bt.warn("Cannot parse NALUs",e)}else 2===o||bt.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 Qe(_t.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&ut(e,5)>=9}}]),e}();c(kt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Ze("TsDemuxer");var xt=function(){function e(){s(this,e)}return u(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var a=0,s="",o=0;t.length>7;){if(a=ut(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=ct(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return jt(e,!0,(function(e,t){e.trackId=ut(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=ut(t,r),r+=4),i&&(e.sampleDescriptionIndex=ut(t,r),r+=4),a&&(e.defaultSampleDuration=ut(t,r),r+=4),s&&(e.defaultSampleSize=ut(t,r),r+=4),o&&(e.defaultSampleFlags=ut(t,r))}))}},{key:"sidx",value:function(e){return jt(e,!0,(function(e,t){var r=0;e.reference_ID=ut(t,r),r+=4,e.timescale=ut(t,r),r+=4,0===e.version?(e.earliest_presentation_time=ut(t,r),r+=4,e.first_offset=ut(t,r),r+=4):(e.earliest_presentation_time=ct(t,r),r+=8,e.first_offset=ct(t,r),r+=8),r+=2,e.references=[];var n=ot(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=ut(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=ut(t,r),s=ut(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return jt(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return jt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=ct(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16),e.nextTrackId=ut(t,r+76)}))}},{key:"trak",value:function(t){return jt(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return jt(e,!0,(function(e,t){var r=0;1===e.version?(e.trackId=ut(t,16),e.duration=ct(t,24),r+=32):(e.trackId=ut(t,8),e.duration=ut(t,16),r+=20),e.width=ut(t,r+52),e.height=ut(t,r+56)}))}},{key:"mdia",value:function(t){return jt(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return jt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=ct(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16);var n=ot(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return jt(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return jt(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return jt(e,!0,(function(e,t){e.graphicsmode=ot(t),e.opcolor=[ot(t,2),ot(t,4),ot(t,6)]}))}},{key:"smhd",value:function(e){return jt(e,!0,(function(e,t){e.balance=ot(t)}))}},{key:"stbl",value:function(t){return jt(t,!1,(function(t,r,n){var i,a,s;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return jt(e,!0,(function(e,r){var n=0,i=ut(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=ot(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=ot(r,n),n+=2,l.BytesOfProtectedData=ut(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return jt(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(At(t[i+a]));if(i+=16,e.version>0){var s=ut(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(At(c))}}var l=ut(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return jt(t,!0,(function(t,r,n){t.entryCount=ut(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return jt(t,!1,(function(t,r,n){t.channelCount=ot(r,16),t.samplesize=ot(r,18),t.sampleRate=ut(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return jt(t,!1,(function(t,r,n){t.width=ot(r,24),t.height=ot(r,26),t.horizresolution=ut(r,28),t.vertresolution=ut(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return jt(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(At(t[r])),r+=1}))}},{key:"schi",value:function(t){return jt(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return jt(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return jt(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"avc1",value:function(t){return jt(t,!1,(function(t,r,n){var i=St(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return jt(e,!1,(function(t,r){t.data=e.data,t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=lt([r[1],r[2],r[3]]),t.lengthSizeMinusOne=3&r[4],t.spsLength=31&r[5],t.sps=[];for(var n=6,i=0;i<t.spsLength;i++){var a=ot(r,n);n+=2,t.sps.push(r.subarray(n,n+a)),n+=a}t.ppsLength=r[n],n+=1,t.pps=[];for(var s=0;s<t.ppsLength;s++){var o=ot(r,n);n+=2,t.pps.push(r.subarray(n,n+=o)),n+=o}}))}},{key:"hvc1",value:function(t){return jt(t,!1,(function(t,r,n){var i=St(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return jt(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=ut(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=ot(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=ot(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=ot(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var h;(h=t.sps).push.apply(h,l)}else if(34===a){var f;(f=t.pps).push.apply(f,l)}}}))}},{key:"pasp",value:function(e){return jt(e,!1,(function(e,t){e.hSpacing=ut(t),e.vSpacing=ut(t,4)}))}},{key:"mp4a",value:function(t){return jt(t,!1,(function(t,r,n){var i=Et(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return jt(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;return 31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[1])>>5)),e.objectType=o,e.codec+=o.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return jt(e,!1,(function(e,t){Et(e,t)}))}},{key:"stts",value:function(e){return jt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push({count:ut(t,i),delta:ut(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return jt(e,!0,(function(e,t){var r=ut(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:ut(t,i),offset:ut(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:ut(t,i),offset:-(1+~ut(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return jt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push({firstChunk:ut(t,i),samplesPerChunk:ut(t,i+4),sampleDescriptionIndex:ut(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return jt(e,!0,(function(e,t){var r=ut(t),n=ut(t,4),i=[];if(!r)for(var a=8,s=0;s<n;s++)i.push(ut(t,a)),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return jt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push(ut(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return jt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push(ct(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return jt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push(ut(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return jt(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return jt(e,!0,(function(e,t){e.sequenceNumber=ut(t)}))}},{key:"traf",value:function(t){return jt(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return jt(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=ut(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~ut(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=ut(t,s),s+=4),e.samples=[],i>s)for(var o,u=0;u<a;u++)o={},256&n&&(o.duration=ut(t,s),s+=4),512&n&&(o.size=ut(t,s),s+=4),1024&n&&(o.flags=ut(t,s),s+=4),2048&n&&(o.cts=r?-(1+~ut(t,s+4)):ut(t,s),s+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return jt(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=ct(t):e.baseMediaDecodeTime=ut(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,a=e.trak;if(a&&a.length){var s=a.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=a.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(s&&t){var u,c,l,d,h,f,p,v=t,y=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=y&&(v.id=s.tkhd.trackId),v.tkhdDuration=s.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=s.mdia.mdhd.timescale,v.duration=s.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale;var m,g,_,b,k,x,w,S,E=s.mdia.minf.stbl.stsd.entries[0];if(v.width=E.width,v.height=E.height,E.pasp&&(v.sarRatio=[E.pasp.hSpacing,E.pasp.vSpacing]),E.hvcC)v.codecType=Le,v.codec=E.hvcC.codec,v.vps=E.hvcC.vps,v.sps=E.hvcC.sps,v.pps=E.hvcC.pps,v.hvcC=E.hvcC.data;else{if(!E.avcC)throw new Error("unknown video stsd entry");v.codec=E.avcC.codec,v.sps=E.avcC.sps,v.pps=E.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=s.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(h=s.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.ctts,E&&"encv"===E.type)v.isVideoEncryption=!0,E.default_KID=null===(m=E.sinf)||void 0===m||null===(g=m.schi)||void 0===g?void 0:g.tenc.default_KID,E.default_IsEncrypted=null===(_=E.sinf)||void 0===_||null===(b=_.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,E.default_IV_size=null===(k=E.sinf)||void 0===k||null===(x=k.schi)||void 0===x?void 0:x.tenc.default_IV_size,v.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,E.data_format=null===(w=E.sinf)||void 0===w||null===(S=w.frma)||void 0===S?void 0:S.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=E}if(o&&r){var j,T,A,D,O,C,B,L,R,P=r,M=null===(j=o.tkhd)||void 0===j?void 0:j.trackId;null!=M&&(P.id=o.tkhd.trackId),P.tkhdDuration=o.tkhd.duration,P.mvhdDurtion=e.mvhd.duration,P.mvhdTimecale=e.mvhd.timescale,P.timescale=P.formatTimescale=o.mdia.mdhd.timescale,P.duration=o.mdia.mdhd.duration||P.mvhdDurtion/P.mvhdTimecale*P.timescale;var I,U,z,N,q,F,V,G,H=o.mdia.minf.stbl.stsd.entries[0];switch(P.sampleSize=H.sampleSize,P.sampleRate=H.sampleRate,P.channelCount=H.channelCount,P.present=!0,H.type){case"alaw":P.codecType=P.codec=Pe,P.sampleRate=8e3;break;case"ulaw":P.codecType=P.codec=Me,P.sampleRate=8e3;break;default:P.sampleDuration=pt.getFrameDuration(P.sampleRate,P.timescale),P.sampleRateIndex=pt.getRateIndexByRate(P.sampleRate),P.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(P.config=Array.from(H.esds.config)),P.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(P.sampleDuration=pt.getFrameDuration(P.sampleRate,P.timescale),P.objectType=(null===(T=H.esds)||void 0===T?void 0:T.objectType)||2,H.esds&&(H.esds.config?P.config=Array.from(H.esds.config):console.warn("esds config is null")),P.codec=(null===(A=H.esds)||void 0===A?void 0:A.codec)||"mp4a.40.2",P.sampleRateIndex=pt.getRateIndexByRate(P.sampleRate),P.ext={},P.ext.stss=null===(D=o.mdia)||void 0===D||null===(O=D.minf)||void 0===O||null===(C=O.stbl)||void 0===C?void 0:C.stss,P.ext.ctts=null===(B=o.mdia)||void 0===B||null===(L=B.minf)||void 0===L||null===(R=L.stbl)||void 0===R?void 0:R.ctts,P.present=!0,H&&"enca"===H.type)P.isAudioEncryption=!0,H.data_format=null===(I=H.sinf)||void 0===I||null===(U=I.frma)||void 0===U?void 0:U.data_format,H.default_KID=null===(z=H.sinf)||void 0===z||null===(N=z.schi)||void 0===N?void 0:N.tenc.default_KID,H.default_IsEncrypted=null===(q=H.sinf)||void 0===q||null===(F=q.schi)||void 0===F?void 0:F.tenc.default_IsEncrypted,H.default_IV_size=null===(V=H.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IV_size,P.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,P.useEME=e.useEME,P.kidValue=e.kidValue,P.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,W,Q=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,Y=null==r||null===(W=r.enca)||void 0===W?void 0:W.default_KID,X=Q||Y?(Q||Y).join(""):null;t&&(t.kid=X),r&&(r.kid=X)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,h=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=[];for(var f=0;f<o.sampleCount;f++)i[a.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[a.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:h,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(h++,e.gopId=h),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,h=u.stco,f=u.stss,p=u.ctts;if(!(c&&l&&d&&h&&f))return;i=wt(c,l,d,h,p,f)}if(n){var v,y,m,g=null===(v=n.mdia)||void 0===v||null===(y=v.minf)||void 0===y?void 0:y.stbl;if(!g)return;var _=null===(m=n.mdia.mdhd)||void 0===m?void 0:m.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=wt(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function wt(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,h=n.entries,f=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,y=0,m=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:y,duration:n,size:f[m]||r.sampleSize,offset:h[g]+b,index:m},p&&(u.keyframe=s[m],u.keyframe&&v++,u.gopId=v),o&&m<o.length&&(u.pts=u.dts+o[m]),c.push(u),y+=n,++m<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function St(e,t){return e.dataReferenceIndex=ot(t,6),e.width=ot(t,24),e.height=ot(t,26),e.horizresolution=ut(t,28),e.vertresolution=ut(t,32),e.frameCount=ot(t,40),e.depth=ot(t,74),78}function Et(e,t){return e.dataReferenceIndex=ot(t,6),e.channelCount=ot(t,16),e.sampleSize=ot(t,18),e.sampleRate=ut(t,24)/65536,28}function jt(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var Tt=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},At=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(Tt(Number(t).toString(16),2,0))})),e[0]};function Dt(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.forEach((function(e){t+=e.length}));var a=new e(t),s=0;return n.forEach((function(e){a.set(e,s),s+=e.length})),a}var Ot=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){t?e.buffer=Dt(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}(),Ct=Math.pow(2,32)-1,Bt=function(){function e(){s(this,e)}return u(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===De&&e.codecType===Le}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return at(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],dt(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(w(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(w(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return n}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]));return a}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]));return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===De?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]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,i,a,s)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=t.width,o=t.height,u=t.sarRatio[0],c=t.sarRatio[1],l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),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(dt(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"avc1hev1",value:function(t){var r=t.codecType===Le,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),a=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),i];return r?a.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&a.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(a))}},{key:"avcC",value:function(t){var r,n,i,a=[],s=[];return t.sps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(n,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(a.length&&1)+(s.length&&1);n=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,c];var l=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,w(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),a.length&&(n.push(161,0,a.length),a.forEach(l)),s.length&&(n.push(162,0,s.length),s.forEach(l))}else n=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(n))}},{key:"pasp",value:function(t){var r=x(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(w(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(w(t.map((function(t){return e.traf(t)})))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2,i+=6*e.subsamples.length)})),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,a,s,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),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(),g=e.saiz(t),_=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 Ot;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 Ot,n=Ot.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Ot.writeUint32(16*t.samples.length+a+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Ot.writeUint32(16*t.samples.length+92))}else{var s=12*t.samples.length+124;t.isAudioEncryption&&(s=12*t.samples.length+8*t.audioSenc.length+177),i=Ot.writeUint32(s)}return t.samples.forEach((function(e){r.write(Ot.writeUint32(e.duration)),r.write(Ot.writeUint32(e.size)),r.write(Ot.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Ot.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 Ot,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||i*n,r.write(Ot.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Ot.writeUint32(n)),s.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(Ot.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Ot.writeUint16(e.BytesOfClearData)),r.write(Ot.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/(Ct+1)),i=Math.floor(r%(Ct+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(w(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===De?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,at(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12})),e.box(e.types.stsc,at(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,at(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,at(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,at(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,at(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,a=t.samples[0].sampleOffset*n,s=8;t.samples.forEach((function(e){s+=e.size}));var o=0;if(t.isVideo){var u,c=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){c+=8,e.subsamples&&e.subsamples.length&&(c+=2,c+=6*e.subsamples.length)})),t.videoSencLength=c,o=s+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+169+12*t.samples.length+8*t.audioSenc.length);var l=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,l)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();c(Bt,"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))),c(Bt,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),c(Bt,"FTYPAVC1",Bt.box(Bt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(Bt,"FTYPHEV1",Bt.box(Bt.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(Bt,"DINF",Bt.box(Bt.types.dinf,Bt.box(Bt.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(Bt,"VMHD",Bt.box(Bt.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(Bt,"SMHD",Bt.box(Bt.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(Bt,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(Bt,"STTS",Bt.box(Bt.types.stts,Bt.StblTable)),c(Bt,"STSC",Bt.box(Bt.types.stsc,Bt.StblTable)),c(Bt,"STSZ",Bt.box(Bt.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(Bt,"STCO",Bt.box(Bt.types.stco,Bt.StblTable));var Lt=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[this._prefix].concat(n))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();c(Lt,"disabled",!0);for(var Rt=function(){function e(){s(this,e)}return u(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 p(this,t)}}]),e}(),Pt=function(e){l(r,e);var t=_(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;s(this,r),e=t.call(this);var a=n;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var o=a.byteLength,u=[],c=0;c<o;c+=1)u[c>>>2]|=a[c]<<24-c%4*8;e.words=u,e.sigBytes=o}else e.words=n,e.sigBytes=i;return e}return u(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mt;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 a=0;a<i;a+=1){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%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=k(d(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)}},a=0;a<e;a+=4){var s=i(4294967296*(t||Math.random()));t=987654071*s(),n.push(4294967296*s()|0)}return new r(n,e)}}]),r}(Rt),Mt={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).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 Pt(r,t/2)}},It=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 Pt(r,t)},Ut=function(e){return It(unescape(encodeURIComponent(e)))},zt=function(e){l(r,e);var t=_(r);function r(){var e;return s(this,r),(e=t.call(this))._minBufferSize=0,e}return u(r,[{key:"reset",value:function(){this._data=new Pt,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=Ut(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,a=r.sigBytes,s=a/(4*n),o=(s=e?Math.ceil(s):Math.max((0|s)-this._minBufferSize,0))*n,u=Math.min(4*o,a);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new Pt(t,u)}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(Rt),Nt=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new Rt,e),n.reset(),n}return u(r,[{key:"reset",value:function(){k(d(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 qt(e,r).finalize(t)}}}]),r}(zt),qt=function(e){l(r,e);var t=_(r);function r(e,n){var i;s(this,r),i=t.call(this);var a=new e;i._hasher=a;var o=n;"string"==typeof o&&(o=Ut(o));var u=a.blockSize,c=4*u;o.sigBytes>c&&(o=a.finalize(n)),o.clamp();var l=o.clone();i._oKey=l;var d=o.clone();i._iKey=d;for(var h=l.words,f=d.words,p=0;p<u;p+=1)h[p]^=1549556828,f[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return u(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}(Rt),Ft={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o+=1)i.push(n.charAt(s>>>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 a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var n=[],i=0,a=0;a<t;a+=1)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=s<<24-i%4*8,i+=1}return Pt.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Vt=[],Gt=0;Gt<64;Gt+=1)Vt[Gt]=4294967296*Math.abs(Math.sin(Gt+1))|0;var Ht=function(e,t,r,n,i,a,s){var o=e+(t&r|~t&n)+i+s;return(o<<a|o>>>32-a)+t},Kt=function(e,t,r,n,i,a,s){var o=e+(t&n|r&~n)+i+s;return(o<<a|o>>>32-a)+t},Wt=function(e,t,r,n,i,a,s){var o=e+(t^r^n)+i+s;return(o<<a|o>>>32-a)+t},Qt=function(e,t,r,n,i,a,s){var o=e+(r^(t|~n))+i+s;return(o<<a|o>>>32-a)+t},Yt=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"_doReset",value:function(){this._hash=new Pt([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,a=e[i];r[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var s=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],g=r[t+11],_=r[t+12],b=r[t+13],k=r[t+14],x=r[t+15],w=s[0],S=s[1],E=s[2],j=s[3];w=Ht(w,S,E,j,o,7,Vt[0]),j=Ht(j,w,S,E,u,12,Vt[1]),E=Ht(E,j,w,S,c,17,Vt[2]),S=Ht(S,E,j,w,l,22,Vt[3]),w=Ht(w,S,E,j,d,7,Vt[4]),j=Ht(j,w,S,E,h,12,Vt[5]),E=Ht(E,j,w,S,f,17,Vt[6]),S=Ht(S,E,j,w,p,22,Vt[7]),w=Ht(w,S,E,j,v,7,Vt[8]),j=Ht(j,w,S,E,y,12,Vt[9]),E=Ht(E,j,w,S,m,17,Vt[10]),S=Ht(S,E,j,w,g,22,Vt[11]),w=Ht(w,S,E,j,_,7,Vt[12]),j=Ht(j,w,S,E,b,12,Vt[13]),E=Ht(E,j,w,S,k,17,Vt[14]),S=Ht(S,E,j,w,x,22,Vt[15]),w=Kt(w,S,E,j,u,5,Vt[16]),j=Kt(j,w,S,E,f,9,Vt[17]),E=Kt(E,j,w,S,g,14,Vt[18]),S=Kt(S,E,j,w,o,20,Vt[19]),w=Kt(w,S,E,j,h,5,Vt[20]),j=Kt(j,w,S,E,m,9,Vt[21]),E=Kt(E,j,w,S,x,14,Vt[22]),S=Kt(S,E,j,w,d,20,Vt[23]),w=Kt(w,S,E,j,y,5,Vt[24]),j=Kt(j,w,S,E,k,9,Vt[25]),E=Kt(E,j,w,S,l,14,Vt[26]),S=Kt(S,E,j,w,v,20,Vt[27]),w=Kt(w,S,E,j,b,5,Vt[28]),j=Kt(j,w,S,E,c,9,Vt[29]),E=Kt(E,j,w,S,p,14,Vt[30]),S=Kt(S,E,j,w,_,20,Vt[31]),w=Wt(w,S,E,j,h,4,Vt[32]),j=Wt(j,w,S,E,v,11,Vt[33]),E=Wt(E,j,w,S,g,16,Vt[34]),S=Wt(S,E,j,w,k,23,Vt[35]),w=Wt(w,S,E,j,u,4,Vt[36]),j=Wt(j,w,S,E,d,11,Vt[37]),E=Wt(E,j,w,S,p,16,Vt[38]),S=Wt(S,E,j,w,m,23,Vt[39]),w=Wt(w,S,E,j,b,4,Vt[40]),j=Wt(j,w,S,E,o,11,Vt[41]),E=Wt(E,j,w,S,l,16,Vt[42]),S=Wt(S,E,j,w,f,23,Vt[43]),w=Wt(w,S,E,j,y,4,Vt[44]),j=Wt(j,w,S,E,_,11,Vt[45]),E=Wt(E,j,w,S,x,16,Vt[46]),S=Wt(S,E,j,w,c,23,Vt[47]),w=Qt(w,S,E,j,o,6,Vt[48]),j=Qt(j,w,S,E,p,10,Vt[49]),E=Qt(E,j,w,S,k,15,Vt[50]),S=Qt(S,E,j,w,h,21,Vt[51]),w=Qt(w,S,E,j,_,6,Vt[52]),j=Qt(j,w,S,E,l,10,Vt[53]),E=Qt(E,j,w,S,m,15,Vt[54]),S=Qt(S,E,j,w,u,21,Vt[55]),w=Qt(w,S,E,j,v,6,Vt[56]),j=Qt(j,w,S,E,x,10,Vt[57]),E=Qt(E,j,w,S,f,15,Vt[58]),S=Qt(S,E,j,w,b,21,Vt[59]),w=Qt(w,S,E,j,d,6,Vt[60]),j=Qt(j,w,S,E,g,10,Vt[61]),E=Qt(E,j,w,S,c,15,Vt[62]),S=Qt(S,E,j,w,y,21,Vt[63]),s[0]=s[0]+w|0,s[1]=s[1]+S|0,s[2]=s[2]+E|0,s[3]=s[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),a=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,o=s.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return s}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(Nt);Nt._createHelper(Yt),Nt._createHmacHelper(Yt);var Xt=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).cfg=Object.assign(new Rt,{keySize:4,hasher:Yt,iterations:1},e),n}return u(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=Pt.create(),s=a.words,o=n.keySize,u=n.iterations;s.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();a.concat(r)}return a.sigBytes=4*o,a}}]),r}(Rt),Jt=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this)).cfg=Object.assign(new Rt,i),a._xformMode=e,a._key=n,a.reset(),a}return u(r,[{key:"reset",value:function(){k(d(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?or:ar};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}(zt);Jt._ENC_XFORM_MODE=1,Jt._DEC_XFORM_MODE=2,Jt.keySize=4,Jt.ivSize=4;var Zt=function(e){l(r,e);var t=_(r);function r(e,n){var i;return s(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return u(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}(Rt);function $t(e,t,r){var n,i=e,a=this._iv;a?(n=a,this._iv=void 0):n=this._prevBlock;for(var s=0;s<r;s+=1)i[t+s]^=n[s]}var er=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Zt);er.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;$t.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(er),er.Decryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),$t.call(this,e,t,n),this._prevBlock=i}}]),r}(er);var tr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var o=Pt.create(a,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},rr=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this,e,n,Object.assign({mode:er,padding:tr},i))).blockSize=4,a}return u(r,[{key:"reset",value:function(){var e;k(d(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}(Jt),nr=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).mixIn(e),n}return u(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(Rt),ir={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?Pt.create([1398893684,1701076831]).concat(r).concat(t):t).toString(Ft)},parse:function(e){var t,r=Ft.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=Pt.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),nr.create({ciphertext:r,salt:t})}},ar=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Rt,this.cfg,n),a=e.createEncryptor(r,i),s=a.finalize(t),o=a.cfg;return nr.create({ciphertext:s,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:a.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new Rt,this.cfg,n);return i=this._parse(i,a.format),e.createDecryptor(r,a).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(Rt);ar.cfg=Object.assign(new Rt,{format:ir});var sr={execute:function(e,t,r,n){var i=n;i||(i=Pt.random(8));var a=Xt.create({keySize:t+r}).compute(e,i),s=Pt.create(a.words.slice(t),4*r);return a.sigBytes=4*t,nr.create({key:a,iv:s,salt:i})}},or=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Rt,this.cfg,n),a=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=a.iv;var s=ar.encrypt.call(this,e,t,a.key,i);return s.mixIn(a),s}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new Rt,this.cfg,n);i=this._parse(i,a.format);var s=a.kdf.execute(r,e.keySize,e.ivSize,i.salt);return a.iv=s.iv,ar.decrypt.call(this,e,i,s.key,a)}}]),r}(ar);or.cfg=Object.assign(ar.cfg,{kdf:sr});for(var ur=[],cr=[],lr=[],dr=[],hr=[],fr=[],pr=[],vr=[],yr=[],mr=[],gr=[],_r=0;_r<256;_r+=1)gr[_r]=_r<128?_r<<1:_r<<1^283;for(var br=0,kr=0,xr=0;xr<256;xr+=1){var wr=kr^kr<<1^kr<<2^kr<<3^kr<<4;wr=wr>>>8^255&wr^99,ur[br]=wr,cr[wr]=br;var Sr=gr[br],Er=gr[Sr],jr=gr[Er],Tr=257*gr[wr]^16843008*wr;lr[br]=Tr<<24|Tr>>>8,dr[br]=Tr<<16|Tr>>>16,hr[br]=Tr<<8|Tr>>>24,fr[br]=Tr,Tr=16843009*jr^65537*Er^257*Sr^16843008*br,pr[wr]=Tr<<24|Tr>>>8,vr[wr]=Tr<<16|Tr>>>16,yr[wr]=Tr<<8|Tr>>>24,mr[wr]=Tr,br?(br=Sr^gr[gr[gr[jr^Sr]]],kr^=gr[gr[kr]]):br=kr=1}var Ar=[0,1,2,4,8,16,32,64,128,27,54],Dr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(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 a=this._keySchedule,s=0;s<i;s+=1)s<n?a[s]=r[s]:(e=a[s-1],s%n?n>6&&s%n==4&&(e=ur[e>>>24]<<24|ur[e>>>16&255]<<16|ur[e>>>8&255]<<8|ur[255&e]):(e=ur[(e=e<<8|e>>>24)>>>24]<<24|ur[e>>>16&255]<<16|ur[e>>>8&255]<<8|ur[255&e],e^=Ar[s/n|0]<<24),a[s]=a[s-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?a[c]:a[c-4],o[u]=u<4||c<=4?e:pr[ur[e>>>24]]^vr[ur[e>>>16&255]]^yr[ur[e>>>8&255]]^mr[ur[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,lr,dr,hr,fr,ur)}},{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,pr,vr,yr,mr,cr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,a,s,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]^a[h>>>8&255]^s[255&f]^r[p];p+=1;var m=n[d>>>24]^i[h>>>16&255]^a[f>>>8&255]^s[255&l]^r[p];p+=1;var g=n[h>>>24]^i[f>>>16&255]^a[l>>>8&255]^s[255&d]^r[p];p+=1;var _=n[f>>>24]^i[l>>>16&255]^a[d>>>8&255]^s[255&h]^r[p];p+=1,l=y,d=m,h=g,f=_}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}(rr);Dr.keySize=8,rr._createHelper(Dr);var Or=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(Zt);Or.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,a=this._iv,s=this._counter;a&&(this._counter=a.slice(0),s=this._counter,this._iv=void 0);var o=s.slice(0);n.encryptBlock(o,0),s[i-1]=s[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(Or),Or.Decryptor=Or.Encryptor;var Cr=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r})),Br=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}();function Lr(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a,s=[],o=[];if(n){var u,c,l,d=null===(u=n.mdia)||void 0===u||null===(c=u.minf)||void 0===c?void 0:c.stbl;if(!d)return;var h=null===(l=n.mdia.mdhd)||void 0===l?void 0:l.timescale,f=d.stts,p=d.stsc,v=d.stsz,y=d.stco,m=d.stss,g=d.ctts;if(!(h&&f&&p&&v&&y&&m))return;a=(s=Rr(t,h,f,p,v,y,m,g)).map((function(e){return e.duration}))}if(i){var _,b,k,x=null===(_=i.mdia)||void 0===_||null===(b=_.minf)||void 0===b?void 0:b.stbl;if(!x)return;var w=null===(k=i.mdia.mdhd)||void 0===k?void 0:k.timescale,S=x.stts,E=x.stsc,j=x.stsz,T=x.stco;if(!(w&&S&&E&&j&&T))return;o=Rr(t,w,S,E,j,T,null,null,a)}return{videoSegments:s,audioSegments:o}}}}function Rr(e,t,r,n,i,a,s,o,u){var c,l,d,h,f=[],p=[],v=[],y=n.entries,m=a.entries,g=i.entrySizes,_=null==s?void 0:s.entries,b=null==o?void 0:o.entries;b&&(c=[],b.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)c.push(r)}))),_&&(l={},_.forEach((function(e){l[e-1]=!0})));var k=0,x=0,S=0,E=0,j=0,T=y[0].samplesPerChunk,A=y[1]?y[1].firstChunk-1:1/0,D=0,O=-1;r.entries.forEach((function(e){var t=e.count,r=e.delta;h=r;for(var n=0;n<t;n++)d={dts:D,startTime:k,duration:h,size:g[x]||i.sampleSize,offset:m[S]+j,index:x},_&&(d.keyframe=l[x],d.keyframe?(O++,p.push([d]),v.push(d.duration)):(p[p.length-1].push(d),v[p.length-1]+=d.duration),d.gopId=O),c&&x<c.length&&(d.pts=D+c[x]),0===x&&(d.pts=0),f.push(d),k+=h,D+=r,++x<T?j+=d.size:(S++,j=0,S>=A&&(E++,A=y[E+1]?y[E+1].firstChunk-1:1/0),T+=y[E].samplesPerChunk)}));var C=f.length;if(C&&(!s||f[0].keyframe)){var B,L=[],R=[],P=0,M=0,I=function(e){var r;B=R[R.length-1],L.push({index:L.length,startTime:(null===(r=L[L.length-1])||void 0===r?void 0:r.endTime)||R[0].startTime/t,endTime:(B.startTime+B.duration)/t,duration:e,range:[R[0].offset,B.offset+B.size],frames:R}),P=0,R=[]};if(s)for(var U=e*t,z=0,N=p.length;z<N;z++){var q;P+=v[z],(q=R).push.apply(q,w(p[z])),z+1<N?(0===z||P>U)&&I(P/t):I(P/t)}else for(var F=(u=u||[])[0]||e,V=0;V<C;V++){R.push(f[V]);var G=(P+=f[V].duration)/t;(V+1>=C||G+M>=F)&&(M+=G-F,I(G),F=u[L.length]||e)}return L}}function Pr(e){var t="",r="",n=0,i=0,a=0,s=0,o=0,u=0,c=0;e.mvhd&&(o=e.mvhd.duration/e.mvhd.timescale);var l=e.trak;if(l){var d,h,f,p,v,y,m,g,_,b,k,x,w,S,E,j,T,A=l.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),D=l.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),O=null;if(A)if(O=null===(h=A.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.stsd.entries[0])if(n=O.width,i=O.height,u=null===(v=A.mdia)||void 0===v||null===(y=v.mdhd)||void 0===y?void 0:y.timescale,t=null===(m=O.avcC||O.hvcC)||void 0===m?void 0:m.codec,"encv"===O.type)d=null===(g=O.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID;if(D)if(O=null===(b=D.mdia)||void 0===b||null===(k=b.minf)||void 0===k||null===(x=k.stbl)||void 0===x?void 0:x.stsd.entries[0])if(a=O.channelCount,s=O.sampleRate,r=null===(w=O.esds)||void 0===w?void 0:w.codec,c=null===(S=D.mdia)||void 0===S||null===(E=S.mdhd)||void 0===E?void 0:E.timescale,"enca"===O.type)d=d||(null===(j=O.sinf)||void 0===j||null===(T=j.schi)||void 0===T?void 0:T.tenc.default_KID);return{kid:d?d.join(""):null,videoCodec:t,audioCodec:r,width:n,height:i,videoTimescale:u,audioChannelCount:a,audioSampleRate:s,duration:o,audioTimescale:c,moov:e}}}function Mr(e){return"number"==typeof e&&!Number.isNaN(e)}var Ir=["vid","cache"],Ur=function(e){l(S,e);var n,i,o,d,h,f,p,v,g,b,k,w=_(S);function S(e){var r;s(this,S),c(m(r=w.call(this)),"vid",""),c(m(r),"url",""),c(m(r),"meta",{}),c(m(r),"downloadInfo",[]),c(m(r),"videoSegments",[]),c(m(r),"audioSegments",[]),c(m(r),"cache",null),c(m(r),"_currentSegmentIndex",-1),c(m(r),"_currentLoadingSegmentIndex",-1),c(m(r),"buffer",void 0),c(m(r),"_error",void 0),c(m(r),"_transformError",(function(e){return e})),r._config=t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",cache:null},e);var n=r._config,i=n.vid,a=n.cache,o=y(n,Ir);return r.cache=a||new Br,r.vid=i||o.url,r.url=o.url,o.transformError=r._transformError,r.logger=new K("MP4Loader_"+r.vid),e.openLog&&K.enable(),o.logger=r.logger,r._loader=new Ae(o),r._loader.on(ge,(function(e){r.emit(ge,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Mr(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Mr(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s,o){var u,c,l,d,h=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=x(i,2),c=u[0],l=u[1],this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[c,l]),d=function(){var e=a(r().mark((function e(t,i,a,u){var d,f,p,v,y,m,g,_;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h.meta&&null!=a&&a.range&&a.range.length>0&&a.range[1]>=l&&(i=!0,h.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=a&&a.range&&a.range.length>0&&a.range[1]<l&&(i=!1,h.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),h.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",a.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",h._error),!h._error&&t&&t.byteLength>0&&s(t,i,a,null,u),!h.meta.moov&&!h._error){e.next=6;break}return e.abrupt("return");case 6:if(!(t&&t.byteLength>0)){e.next=44;break}if(h.buffer=je(h.buffer,t),d=xt.findBox(h.buffer,["moov"])[0]){e.next=23;break}if(f=xt.findBox(h.buffer,["mdat"])[0],!i){e.next=23;break}if(f){e.next=18;break}return h._error=!0,s(null,i,a,{err:"cannot find moov or mdat box"},u),e.abrupt("return");case 18:return p=f.start+f.size,e.next=21,h.loadData([p,""],n,o);case 21:(v=e.sent)&&(d=xt.findBox(v.data,["moov"])[0]);case 23:if(!(d&&i&&d.size>d.data.length)){e.next=27;break}return h.logger.debug("[loadMetaProcess],moov not all, range,",a.range[1],",dataLen,",h.buffer.byteLength,", state,",i),e.next=27,h.loadMetaProcess(n,[a.range[1],d.start+d.size-1],s);case 27:if(!(d&&d.size<=d.data.length)||h.meta.moov){e.next=44;break}if(y=xt.moov(d)){e.next=33;break}return h._error=!0,s(null,i,a,{err:"cannot parse moov box"},u),e.abrupt("return");case 33:if(m=Lr(y,h._config.segmentDuration)){e.next=38;break}return h._error=!0,s(null,i,a,{err:"cannot parse segments"},u),e.abrupt("return");case 38:h.meta=Pr(y),g=m.videoSegments,_=m.audioSegments,h.videoSegments=g,h.audioSegments=_,h.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:h.meta,videoSegments:g,audioSegments:_}},null,u);case 44:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),e.next=6,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:d},o));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n,i){var a,s,o,u,c,l,d,h,f;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=[],this.logger.debug("[loadMeta start]"),e.next=4,this.loadData([0,n||this._config.moovEnd],t,i);case 4:if(s=e.sent){e.next=7;break}return e.abrupt("return");case 7:if(a.push(s),o=xt.findBox(s.data,["moov"])[0]){e.next=23;break}if(u=xt.findBox(s.data,["mdat"])[0]){e.next=13;break}throw new Cr("cannot find moov or mdat box",s.data);case 13:return c=u.start+u.size,e.next=16,this.loadData([c],t,i);case 16:if(s=e.sent){e.next=19;break}return e.abrupt("return");case 19:if(a.push(s),o=xt.findBox(s.data,["moov"],c)[0]){e.next=23;break}throw new Cr("cannot find moov box",s.data);case 23:if(!(o.size>o.data.length)){e.next=31;break}return e.next=26,this.loadData([s.data.length,o.start+o.size-1],t,i);case 26:if(s=e.sent){e.next=29;break}return e.abrupt("return");case 29:a.push(s),o.data=je(o.data,s.data);case 31:if(l=xt.moov(o)){e.next=34;break}throw new Cr("cannot parse moov box",o.data);case 34:if(d=Lr(l,this._config.segmentDuration)){e.next=37;break}throw new Cr("cannot parse segments",o.data);case 37:return this.meta=Pr(l),h=d.videoSegments,f=d.audioSegments,this.videoSegments=h,this.audioSegments=f,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:h,audioSegments:f,responses:a});case 43:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Lr(e.moov,this._config.segmentDuration),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(f=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"preload",value:(h=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length>0&&void 0!==t[0]&&t[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i,a){var s,o,u,c;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this._getCacheKey(n),e.next=3,this.cache.get(s);case 3:if(o=e.sent){e.next=11;break}return c=a&&a.url?a.url:this.url,e.next=8,this._loader.load(c,t({range:n,vid:this.vid},a));case 8:u=e.sent,e.next=12;break;case 11:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 12:if(u){e.next=14;break}return e.abrupt("return");case 14:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(be);return Ur}));
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|