xgplayer-mp4 3.0.0-next.2 → 3.0.0-next.3
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/_virtual/_rollupPluginBabelHelpers.js +14 -0
- package/es/error.d.ts +5 -0
- package/es/error.js +9 -0
- package/es/fmp4/buffer.d.ts +6 -0
- package/es/fmp4/buffer.js +23 -0
- package/es/fmp4/m4a.d.ts +42 -0
- package/es/fmp4/m4a.js +928 -0
- package/es/fmp4/mp4.d.ts +42 -0
- package/es/fmp4/mp4.js +948 -0
- package/es/index.d.ts +3 -4
- package/es/index.js +2 -4
- package/es/index.umd.d.ts +2 -1
- package/es/index_backup.d.ts +1 -0
- package/es/m4a.d.ts +61 -0
- package/es/m4a.js +583 -0
- package/es/m4aPlugin.d.ts +48 -0
- package/es/m4aPlugin.js +385 -0
- package/es/media/mse.d.ts +17 -0
- package/es/media/mse.js +75 -0
- package/es/media/task.d.ts +19 -0
- package/es/media/task.js +103 -0
- package/es/mp4.d.ts +77 -0
- package/es/mp4.js +567 -0
- package/es/mp4Plugin.d.ts +49 -0
- package/es/mp4Plugin.js +332 -0
- package/es/parse/box.d.ts +17 -0
- package/es/parse/box.js +69 -0
- package/es/parse/boxParse/MP4DecConfigDescrTag.d.ts +2 -0
- package/es/parse/boxParse/MP4DecConfigDescrTag.js +25 -0
- package/es/parse/boxParse/MP4DecSpecificDescrTag.d.ts +2 -0
- package/es/parse/boxParse/MP4DecSpecificDescrTag.js +25 -0
- package/es/parse/boxParse/MP4ESDescrTag.d.ts +2 -0
- package/es/parse/boxParse/MP4ESDescrTag.js +23 -0
- package/es/parse/boxParse/SLConfigDescriptor.d.ts +2 -0
- package/es/parse/boxParse/SLConfigDescriptor.js +19 -0
- package/es/parse/boxParse/avc1.d.ts +10 -0
- package/es/parse/boxParse/avc1.js +30 -0
- package/es/parse/boxParse/avcC.d.ts +15 -0
- package/es/parse/boxParse/avcC.js +35 -0
- package/es/parse/boxParse/btrt.d.ts +6 -0
- package/es/parse/boxParse/btrt.js +11 -0
- package/es/parse/boxParse/co64.d.ts +7 -0
- package/es/parse/boxParse/co64.js +16 -0
- package/es/parse/boxParse/ctts.d.ts +7 -0
- package/es/parse/boxParse/ctts.js +19 -0
- package/es/parse/boxParse/dref.d.ts +6 -0
- package/es/parse/boxParse/dref.js +18 -0
- package/es/parse/boxParse/elst.d.ts +8 -0
- package/es/parse/boxParse/elst.js +35 -0
- package/es/parse/boxParse/esds.d.ts +5 -0
- package/es/parse/boxParse/esds.js +12 -0
- package/es/parse/boxParse/ftyp.d.ts +6 -0
- package/es/parse/boxParse/ftyp.js +15 -0
- package/es/parse/boxParse/hdlr.d.ts +7 -0
- package/es/parse/boxParse/hdlr.js +18 -0
- package/es/parse/boxParse/hmhd.d.ts +0 -0
- package/es/parse/boxParse/index.d.ts +32 -0
- package/es/parse/boxParse/index.js +31 -0
- package/es/parse/boxParse/iods.d.ts +6 -0
- package/es/parse/boxParse/iods.js +16 -0
- package/es/parse/boxParse/mdat.d.ts +1 -0
- package/es/parse/boxParse/mdat.js +4 -0
- package/es/parse/boxParse/mdhd.d.ts +12 -0
- package/es/parse/boxParse/mdhd.js +28 -0
- package/es/parse/boxParse/mfhd.d.ts +0 -0
- package/es/parse/boxParse/mp4a.d.ts +7 -0
- package/es/parse/boxParse/mp4a.js +19 -0
- package/es/parse/boxParse/mvhd.d.ts +15 -0
- package/es/parse/boxParse/mvhd.js +27 -0
- package/es/parse/boxParse/nmhd.d.ts +0 -0
- package/es/parse/boxParse/pasp.d.ts +4 -0
- package/es/parse/boxParse/pasp.js +9 -0
- package/es/parse/boxParse/sbgp.d.ts +0 -0
- package/es/parse/boxParse/sdtp.d.ts +0 -0
- package/es/parse/boxParse/smhd.d.ts +6 -0
- package/es/parse/boxParse/smhd.js +11 -0
- package/es/parse/boxParse/stco.d.ts +7 -0
- package/es/parse/boxParse/stco.js +16 -0
- package/es/parse/boxParse/stsc.d.ts +7 -0
- package/es/parse/boxParse/stsc.js +36 -0
- package/es/parse/boxParse/stsd.d.ts +6 -0
- package/es/parse/boxParse/stsd.js +15 -0
- package/es/parse/boxParse/stsh.d.ts +0 -0
- package/es/parse/boxParse/stss.d.ts +7 -0
- package/es/parse/boxParse/stss.js +16 -0
- package/es/parse/boxParse/stsz.d.ts +8 -0
- package/es/parse/boxParse/stsz.js +17 -0
- package/es/parse/boxParse/stts.d.ts +10 -0
- package/es/parse/boxParse/stts.js +19 -0
- package/es/parse/boxParse/stz2.d.ts +0 -0
- package/es/parse/boxParse/tfhd.d.ts +0 -0
- package/es/parse/boxParse/tkhd.d.ts +18 -0
- package/es/parse/boxParse/tkhd.js +40 -0
- package/es/parse/boxParse/traf.d.ts +0 -0
- package/es/parse/boxParse/trun.d.ts +0 -0
- package/es/parse/boxParse/udta.d.ts +1 -0
- package/es/parse/boxParse/udta.js +4 -0
- package/es/parse/boxParse/url.d.ts +6 -0
- package/es/parse/boxParse/url.js +16 -0
- package/es/parse/boxParse/vmhd.d.ts +7 -0
- package/es/parse/boxParse/vmhd.js +12 -0
- package/es/parse/date.d.ts +5 -0
- package/es/parse/date.js +17 -0
- package/es/parse/index.d.ts +8 -0
- package/es/parse/index.js +44 -0
- package/es/parse/stream.d.ts +23 -0
- package/es/parse/stream.js +106 -0
- package/es/util/download.d.ts +4 -0
- package/es/util/index.d.ts +46 -0
- package/es/util/index.js +174 -0
- package/es/write/box/MP4DecConfigDescrTag.d.ts +1 -0
- package/es/write/box/MP4DecSpecificDescrTag.d.ts +1 -0
- package/es/write/box/MP4ESDescrTag.d.ts +1 -0
- package/es/write/box/SLConfigDescriptor.d.ts +1 -0
- package/es/write/box/avc1.d.ts +1 -0
- package/es/write/box/avcC.d.ts +1 -0
- package/es/write/box/btrt.d.ts +1 -0
- package/es/write/box/co64.d.ts +1 -0
- package/es/write/box/ctts.d.ts +1 -0
- package/es/write/box/dref.d.ts +1 -0
- package/es/write/box/elst.d.ts +1 -0
- package/es/write/box/esds.d.ts +1 -0
- package/es/write/box/ftyp.d.ts +1 -0
- package/es/write/box/hdlr.d.ts +1 -0
- package/es/write/box/iods.d.ts +1 -0
- package/es/write/box/mdat.d.ts +1 -0
- package/es/write/box/mdhd.d.ts +1 -0
- package/es/write/box/mehd.d.ts +1 -0
- package/es/write/box/mfhd.d.ts +1 -0
- package/es/write/box/mfro.d.ts +1 -0
- package/es/write/box/mp4a.d.ts +1 -0
- package/es/write/box/mvhd.d.ts +1 -0
- package/es/write/box/pasp.d.ts +1 -0
- package/es/write/box/smhd.d.ts +1 -0
- package/es/write/box/stco.d.ts +1 -0
- package/es/write/box/stsc.d.ts +1 -0
- package/es/write/box/stsd.d.ts +1 -0
- package/es/write/box/stss.d.ts +1 -0
- package/es/write/box/stsz.d.ts +1 -0
- package/es/write/box/stts.d.ts +1 -0
- package/es/write/box/tfdt.d.ts +1 -0
- package/es/write/box/tfhd.d.ts +1 -0
- package/es/write/box/tfra.d.ts +1 -0
- package/es/write/box/tkhd.d.ts +1 -0
- package/es/write/box/trex.d.ts +1 -0
- package/es/write/box/trun.d.ts +1 -0
- package/es/write/box/udta.d.ts +1 -0
- package/es/write/box/url.d.ts +1 -0
- package/es/write/box/vmhd.d.ts +1 -0
- package/es/write/box/wide.d.ts +1 -0
- package/es/write/box.d.ts +15 -0
- package/es/write/buffer.d.ts +5 -0
- package/es/write/index.d.ts +5 -0
- package/es/write/stream.d.ts +20 -0
- package/package.json +24 -11
- package/es/mp4/buffer-service.d.ts +0 -16
- package/es/mp4/buffer-service.js +0 -139
- package/es/mp4/config.d.ts +0 -1
- package/es/mp4/config.js +0 -35
- package/es/mp4/index.d.ts +0 -23
- package/es/mp4/index.js +0 -144
- package/es/plugin.d.ts +0 -16
- package/es/plugin.js +0 -126
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("xgplayer")):"function"==typeof define&&define.amd?define(["xgplayer"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).MP4Player=t(e.Player)}(this,(function(e){"use strict";function t(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 r(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function n(){n=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(D){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i,a,s,o,u=t&&t.prototype instanceof f?t:f,c=Object.create(u.prototype),h=new S(n||[]);return c._invoke=(i=e,a=r,s=h,o="suspendedStart",function(e,t){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===e)throw t;return{value:void 0,done:!0}}for(s.method=e,s.arg=t;;){var r=s.delegate;if(r){var n=_(r,s);if(n){if(n===d)continue;return n}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if("suspendedStart"===o)throw o="completed",s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);o="executing";var u=l(i,a,s);if("normal"===u.type){if(o=s.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:s.done}}"throw"===u.type&&(o="completed",s.method="throw",s.arg=u.arg)}}),c}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(D){return{type:"throw",arg:D}}}e.wrap=c;var d={};function f(){}function h(){}function p(){}var v={};u(v,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(T([])));y&&y!==t&&r.call(y,a)&&(v=y);var g=p.prototype=f.prototype=Object.create(v);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function n(i,a,s,o){var u=l(e[i],e,a);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,o)}))}o(u.arg)}var i;this._invoke=function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}}function _(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,_(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(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 w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return h.prototype=p,u(g,"constructor",p),u(p,"constructor",h),h.displayName=u(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),u(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(c(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(g),u(g,o,"Generator"),u(g,a,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=T,S.prototype={constructor:S,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(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var o=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(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),d}},e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,r,n,i,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 s(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)}))}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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,n.key,n)}}function c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(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 f(e){return(f=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 p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function v(e,t,r){return(v=p()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&h(i,r.prototype),i}).apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return v(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)},m(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 g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function k(e){var t=p();return function(){var r,n=f(e);if(t){var i=f(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return b(this,r)}}function _(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)return;var n,i,a=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);s=!0);}catch(u){o=!0,i=u}finally{try{s||null==r.return||r.return()}finally{if(o)throw i}}return a}(e,t)||w(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 x(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(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 w(e,t){if(e){if("string"==typeof e)return S(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)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T(){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}var E,D=function(){function e(){o(this,e)}return c(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:"length",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,a=0,s=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),f=0,h=d.length;f<h;f++){var p=d[f];if(r+n>=p[0]&&r<p[1])i=p[0],a=p[1],s=f;else{if(r+n<p[0]){o=p[0],u=p[1];break}r+n>p[1]&&(c=p[0],l=p[1])}}return{start:i,end:a,index:s,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.length&&e.length(d)}}}]),e}(),B="network",C="network_timeout",A="demux",P="remux",L="media",O="other",U={FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",OPTION:"OPTION"},I=(l(E={},"manifest",{HLS:1100}),l(E,B,2100),l(E,C,2101),l(E,A,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400}),l(E,P,{FMP4:4100,MP4:4200}),l(E,L,{MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202}),l(E,O,8e3),E),M=function(e){d(r,e);var t=k(r);function r(e,n,i,a,s){var u;return o(this,r),(u=t.call(this,s||(null==i?void 0:i.message))).errorType=e===C?B:e,u.originError=i,u.ext=a,u.errorCode=I[e][n]||I[e],u.errorMessage=u.message,u.errorCode||(u.errorType=O,u.errorCode=I[u.errorType]),u}return c(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=O),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?C:B,e,null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(m(Error)),R="undefined"!=typeof window?window.MediaSource||window.WebKitMediaSource:null,j={UPDATE_ERROR:"updateError"},N=function(){function e(t){var r=this;o(this,e),l(this,"media",null),l(this,"mediaSource",null),l(this,"_openPromise",T()),l(this,"_queue",Object.create(null)),l(this,"_sourceBuffer",Object.create(null)),l(this,"_onSBUpdateEnd",(function(e){var t=r._queue[e];if(t){var n=t.shift();n&&(n.promise.resolve(),r._startQueue(e))}})),l(this,"_onSBUpdateError",(function(e,t){var n=r._queue[e];if(n){var i=n[0];i&&i.promise.reject(new M(L,U.MSE_APPEND_BUFFER,t))}})),t&&this.bindMedia(t)}var t,r,i;return c(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"updateDuration",value:function(e){var t=this;return this._enqueueBlockingOp((function(){t.mediaSource&&(t.mediaSource.duration=e)}))}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){t.removeEventListener("sourceopen",r),e._openPromise.resolve()})),this._openPromise=T()}return this._openPromise}},{key:"bindMedia",value:(i=s(n().mark((function e(t){var r,i,a=this;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(t&&R){e.next=5;break}throw new Error("Param media or MediaSource does not exist");case 5:return this.media=t,r=this.mediaSource=new R,t.src=URL.createObjectURL(r),i=function e(){r.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),a._openPromise.resolve()},r.addEventListener("sourceopen",i),e.abrupt("return",this._openPromise);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(r=s(n().mark((function e(){var t,r=this;return n().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=r._queue[e];t&&t.forEach((function(e){return e.promise.resolve}))})),"open"===t.readyState)try{t.endOfStream()}catch(n){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(r._sourceBuffer[e])}catch(n){}}))}if(this.media){this.media.removeAttribute("src");try{this.media.load()}catch(n){}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 r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new M(L,U.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._sourceBuffer[e];return this.mediaSource&&r&&r.mimeType!==t&&"function"==typeof r.changeType?this._enqueueOp((function(){r.changeType(t)})):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t){var r=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){r.mediaSource&&r._sourceBuffer[e].appendBuffer(t)})):Promise.resolve()}},{key:"remove",value:function(e,t,r){var n=this;return 1===Object.keys(this._sourceBuffer).length?Promise.resolve():this._enqueueOp(e,(function(){if(n.mediaSource){var i=n._sourceBuffer[e];t>=r||!i?n._onSBUpdateEnd(e):i.remove(t,r)}}))}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n._enqueueOp(i,(function(){n.mediaSource&&n._sourceBuffer[i].remove(e,t)}))})),r}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){e=t._enqueueOp(r,(function(){if(t.mediaSource){var e=t._sourceBuffer[r];e.remove(0,D.end(D.get(e)))}}))})),e}},{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&&(e?r.endOfStream(e):r.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:"buffered",value:function(e){return D.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return D.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return D.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t){if(!this.mediaSource)return Promise.resolve();var r=this._queue[e]=this._queue[e]||[],n={exec:t,promise:T()};return r.push(n),1===r.length&&this._startQueue(e),n.promise}},{key:"_enqueueBlockingOp",value:(t=s(n().mark((function e(t){var r,i,a=this;return n().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((r=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return i=[],r.forEach((function(e){var t=a._queue[e],r=T();i.push(r),t.push({exec:function(){return r.resolve()},promise:r}),1===t.length&&a._startQueue(e)})),e.abrupt("return",Promise.all(i).then((function(){try{return t()}finally{r.forEach((function(e){var t=a._queue[e],r=a._sourceBuffer[e];null==t||t.shift(),r&&r.updating||a._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r)try{r.exec()}catch(n){r.promise.reject(new M(L,U.MSE_OTHER,n)),t.shift(),this._startQueue(e)}}}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if(!R)return!1;try{return R.isTypeSupported(e)}catch(t){return!1}}}]),e}();l(N,"VIDEO","video"),l(N,"AUDIO","audio");var z="fetch",F="xhr",G="arraybuffer",V="text",q="json",H=function(e){d(r,e);var t=k(r);function r(e,n,i,a){var s;return o(this,r),l(g(s=t.call(this,a)),"retryCount",0),l(g(s),"isTimeout",!1),l(g(s),"loaderType",z),l(g(s),"startTime",0),l(g(s),"endTime",0),s.url=e,s.request=n,s.response=i,s}return c(r)}(m(Error)),K=Object.prototype.toString;function Q(e){if("[object Object]"!==K.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function W(e){if(e&&null!=e[0]&&(0!==e[0]||null!=e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function Y(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Z(e,t){if(e){if(!t)return e;var r,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===K.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===i(e)}(t)&&(t=JSON.stringify(t)),"".concat(Y(e),"=").concat(Y(t))})).join("&")})).filter(Boolean).join("&");if(n){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function X(e,t,r,n,i,a){return n=null!=n?parseFloat(n):null,r=parseInt(r||"0",10),isNaN(r)&&(r=0),{data:e,response:t,contentLength:r,age:n,startTime:i,firstByteTime:a,endTime:Date.now()}}var $=function(){function e(){o(this,e),l(this,"_abortController",null),l(this,"_timeoutTimer",null),l(this,"_reader",null),l(this,"_response",null),l(this,"_aborted",!1)}var t;return c(e,[{key:"load",value:function(e){var t,r=this,i=e.url,a=e.timeout,o=e.responseType,u=e.onProgress,c=e.onTimeout,l=e.range,d=e.transformResponse,f=e.request,h=e.params,p=e.method,v=e.headers,m=e.body,y=e.mode,g=e.credentials,b=e.cache,k=e.redirect,_=e.referrer,x=e.referrerPolicy;this._aborted=!1,this._abortController="undefined"!=typeof AbortController&&new AbortController;var w={method:p,headers:v,body:m,mode:y,credentials:g,cache:b,redirect:k,referrer:_,referrerPolicy:x,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},S=!1;clearTimeout(this._timeoutTimer),i=Z(i,h);var T=W(l);T&&((v=f?f.headers:w.headers=w.headers||new Headers)instanceof Headers?v.append("Range",T):v.Range=T),a&&(this._timeoutTimer=setTimeout((function(){if(S=!0,r.cancel(),c){var e=new H(i,w);e.isTimeout=!0,c(e)}}),a));var E=Date.now();return fetch(f||i,f?void 0:w).then(function(){var e=s(n().mark((function e(t){var a,s;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=t,!r._aborted){e.next=4;break}return e.abrupt("return");case 4:if(d&&(t=d(t,i)||t),t.ok){e.next=7;break}throw new H(i,w,t,"bad network response");case 7:if(a=Date.now(),o!==V){e.next=14;break}return e.next=11,t.text();case 11:s=e.sent,e.next=28;break;case 14:if(o!==q){e.next=20;break}return e.next=17,t.json();case 17:s=e.sent,e.next=28;break;case 20:if(!u){e.next=24;break}r._loadChunk(t,u),e.next=28;break;case 24:return e.next=26,t.arrayBuffer();case 26:s=e.sent,s=new Uint8Array(s);case 28:return e.abrupt("return",X(s,t,t.headers.get("Content-Length"),t.headers.get("age"),E,a));case 29:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){if(clearTimeout(r._timeoutTimer),!r._aborted||S)throw(e=e instanceof H?e:new H(i,w)).startTime=E,e.endTime=Date.now(),e.isTimeout=S,e}))}},{key:"cancel",value:(t=s(n().mark((function e(){return n().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._response){e.next=13;break}if(e.prev=4,!this._reader){e.next=8;break}return e.next=8,this._reader.cancel();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:this._response=this._reader=null;case 13:if(this._abortController){try{this._abortController.abort()}catch(t){}this._abortController=null}case 14:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t){var r,i,a,o=this,u=this._reader=e.body.getReader(),c=function(){var l=s(n().mark((function s(){return n().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=Date.now(),n.prev=1,n.next=4,u.read();case 4:r=n.sent,a=Date.now(),n.next=13;break;case 8:return n.prev=8,n.t0=n.catch(1),a=Date.now(),t(void 0,!0,{startTime:i,endTime:a},e),n.abrupt("return");case 13:if(!o._aborted){n.next=16;break}return t(void 0,!0,{startTime:i,endTime:a},e),n.abrupt("return");case 16:t(r.value,r.done,{startTime:i,endTime:a},e),r.done||c();case 18:case"end":return n.stop()}}),s,null,[[1,8]])})));return function(){return l.apply(this,arguments)}}();c()}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),e}();var J=function(){function e(){o(this,e),l(this,"_xhr",null),l(this,"_aborted",!1),l(this,"_timeoutTimer",null)}return c(e,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer);var r=e.url,n=e.params,i=e.timeout,a=e.responseType,s=e.onTimeout,o=e.transformResponse,u=e.onProgress,c=e.method,l=e.credentials,d=e.body,f=e.headers,h=e.range,p=e.request,v=!1;r=Z(r,n);var m=Date.now();return new Promise((function(e,n){var y=t._xhr=new XMLHttpRequest;y.open(c||"GET",r,!0),y.responseType=a,y.withCredentials="include"===l||"same-origin"===l;var g=W(h);g&&((f=f||{}).Range=g),f&&Object.keys(f).forEach((function(e){y.setRequestHeader(e,f[e])})),i&&(t._timeoutTimer=setTimeout((function(){if(v=!0,t.cancel(),s){var e=new H(r,p);e.isTimeout=!0,s(e)}}),i)),y.onerror=function(e){return n(e)},y.onreadystatechange=function(){if(y.readyState>=2){clearTimeout(t._timeoutTimer);var i=Date.now();if(4===y.readyState){if(y.onreadystatechange=null,t._aborted)return;var a=y.status,s={ok:a>=200&&a<300,status:a,statusText:y.statusText,url:y.responseURL,headers:t._getHeaders(y),body:y.response};if(o&&(s=o(s,r)||s),!s.ok)return n(new H(r,p,s,"bad network response"));var c=y.responseType===G,l=c?new Uint8Array(y.response):y.response;u&&u(c?l:void 0,!0,{startTime:m,endTime:Date.now()},s),e(X(l,s,s.headers["content-length"],s.headers.age,m,i))}}},y.send(d)})).catch((function(e){if(clearTimeout(t._timeoutTimer),!t._aborted||v)throw(e=e instanceof H?e:new H(r,p)).startTime=m,e.endTime=Date.now(),e.isTimeout=v,e}))}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._xhr?this._xhr.cancel():void 0}},{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=w(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}}]),e}(),ee=["retry","retryDelay","onRetryError","transformError"],te=function(){function e(t,r){o(this,e),this.promise=T(),this.alive=!!r.onProgress,this._loaderType=t,this._loader=t===z?new $:new J,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1}var t;return c(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,i=t.retryDelay,a=t.onRetryError,o=t.transformError,u=y(t,ee),c=function(){var t=s(n().mark((function t(){var s,l;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:s=t.sent,e.promise.resolve(s),t.next=22;break;case 7:if(t.prev=7,t.t0=t.catch(0),!e._canceled){t.next=11;break}return t.abrupt("return");case 11:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,l=t.t0,o&&(l=o(l)||l),a&&e._retryCount>0&&a(l,e._retryCount,r),e._retryCount++,!(e._retryCount<=r)){t.next=21;break}return clearTimeout(e._retryTimer),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 21:e.promise.reject(l);case 22:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,e.abrupt("return",this._loader.cancel());case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function re(){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 ne(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var ie=function(){function e(t){o(this,e),l(this,"type",z),l(this,"_queue",[]),l(this,"_alive",[]),l(this,"_currentTask",null),this._config=function(e){return r({loaderType:z,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:V,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},e)}(t),this._config.loaderType!==F&&$.isSupported()||(this.type=F)}var t;return c(e,[{key:"isFetch",value:function(){return this.type===z}},{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?t=e:t.url=e||t.url||this._config.url,(t=Object.assign({},this._config,t)).params&&(t.params=Object.assign({},t.params)),t.headers&&Q(t.headers)&&(t.headers=Object.assign({},t.headers)),t.body&&Q(t.body)&&(t.body=Object.assign({},t.body)),t.transformRequest&&(t=t.transformRequest(t)||t);var r=new te(this.type,t);return this._queue.push(r),1===this._queue.length&&this._processTask(),r.promise}},{key:"cancel",value:(t=s(n().mark((function e(){var t;return n().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,ne();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;this._currentTask=this._queue.shift(),this._currentTask&&(this._currentTask.alive&&this._alive.push(this._currentTask),this._currentTask.exec().catch((function(){})).finally((function(){e._processTask()})))}}],[{key:"isFetchSupport",value:function(){return $.isSupported()}}]),e}(),ae="error",se="core.lowdecode",oe=function(){function e(t){o(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return c(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}();l(oe,"disabled",!0);var ue={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var f,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(ue);var ce=ue.exports,le="video",de="audio",fe="metadata",he="avc",pe="hevc",ve="aac",me="g7110a",ye="g7110m",ge="LARGE_AV_SHIFT",be="LARGE_VIDEO_GAP",ke="LARGE_VIDEO_GAP_BETWEEN_CHUNK",_e="LARGE_AUDIO_GAP",xe="AUDIO_FILLED",we="AUDIO_DROPPED",Se=function(){function e(){o(this,e),l(this,"id",1),l(this,"type",le),l(this,"codecType",he),l(this,"pid",-1),l(this,"hvcC",void 0),l(this,"codec",""),l(this,"timescale",0),l(this,"formatTimescale",0),l(this,"sequenceNumber",0),l(this,"baseMediaDecodeTime",0),l(this,"baseDts",0),l(this,"duration",0),l(this,"warnings",[]),l(this,"samples",[]),l(this,"pps",[]),l(this,"sps",[]),l(this,"vps",[]),l(this,"fpsNum",0),l(this,"fpsDen",0),l(this,"sarRatio",[]),l(this,"width",0),l(this,"height",0),l(this,"nalUnitSize",4),l(this,"present",!1),l(this,"ext",void 0)}return c(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}}]),e}(),Te=function(){function e(){o(this,e),l(this,"id",2),l(this,"type",de),l(this,"codecType",ve),l(this,"pid",-1),l(this,"codec",""),l(this,"sequenceNumber",0),l(this,"sampleDuration",0),l(this,"timescale",0),l(this,"formatTimescale",0),l(this,"baseMediaDecodeTime",0),l(this,"duration",0),l(this,"warnings",[]),l(this,"samples",[]),l(this,"baseDts",0),l(this,"sampleSize",16),l(this,"sampleRate",0),l(this,"channelCount",0),l(this,"objectType",0),l(this,"sampleRateIndex",0),l(this,"config",[]),l(this,"present",!1),l(this,"ext",void 0)}return c(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===ve)}},{key:"hasSample",value:function(){return!!this.samples.length}}]),e}(),Ee=function(){function e(t,r,n){o(this,e),l(this,"flag",{}),l(this,"keyframe",!1),l(this,"gopId",0),l(this,"duration",0),l(this,"size",0),l(this,"units",[]),l(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return c(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}(),De=c((function e(t,r,n){o(this,e),l(this,"duration",1024),l(this,"flag",{dependsOn:2,isNonSyncSample:0}),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,n&&(this.duration=n)})),Be=c((function e(t,r){o(this,e),l(this,"time",0),this.data=t,this.originPts=this.pts=r})),Ce=function(e){d(r,e);var t=k(r);function r(){return o(this,r),t.apply(this,arguments)}return c(r)}(Be),Ae=function(e){d(r,e);var t=k(r);function r(){return o(this,r),t.apply(this,arguments)}return c(r)}(Be),Pe=function(){function e(){o(this,e),l(this,"id",3),l(this,"type",fe),l(this,"timescale",0),l(this,"flvScriptSamples",[]),l(this,"seiSamples",[])}return c(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}(),Le=function(){function e(t){if(o(this,e),l(this,"_bytesAvailable",void 0),l(this,"_bitsAvailable",0),l(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return c(e,[{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(t=e-t)>0&&this._bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this._bitsAvailable;++e)if(0!=(this._word&2147483648>>>e))return this._word<<=e,this._bitsAvailable-=e,e;return this._loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),Oe=function(){function e(t){o(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return c(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}();l(Oe,"disabled",!0);var Ue=function(){function e(){o(this,e)}return c(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}(),Ie="undefined"!=typeof window,Me=Ie&&navigator.userAgent.toLocaleLowerCase(),Re=Ie&&/^((?!chrome|android).)*safari/.test(Me),je=Ie&&Me.includes("firefox"),Ne=Ie&&Me.includes("android");function ze(){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 Fe=Math.pow(2,32);function Ge(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function Ve(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 qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Ve(e,t)*Fe+Ve(e,t+4)}function He(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}var Ke=function(){function e(){o(this,e)}return c(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;null!=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=Ve(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){for(var t=e.length,r=1,n=0,i=0,a="";255===e[r];)n+=255,r++;for(n+=e[r++];255===e[r];)i+=255,r++;if(i+=e[r++],5===n&&t>r+16)for(var s=0;s<16;s++)a+=e[r].toString(16),r++;return{payload:e.subarray(r),type:n,size:i,uuid:a}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,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}(),Qe=function(){function e(){o(this,e)}return c(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,a.push(l),r||(r=e.parseSPS(Ke.removeEPB(l)))}var d,f=t[o];o++;for(var h=0;h<f;h++)d=t[o]<<8|t[o+1],o+=2,d&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Le(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var f=t.readUEG(),h=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,m,y,g,b,k=0,_=0,x=0,w=0;if(t.readBool()&&(k=t.readUEG(),_=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),T=t.readBits(32);m=t.readBool(),b=(y=T)/(g=2*S)}}return{codec:He(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(f+1)-2*(k+_)),height:(2-p)*(h+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:y,fpsDen:g,fps:b,fixedFrame:m}}}]),e}(),We=function(){function e(){o(this,e)}return c(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var a=i,s=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,d=1+((192&t[i+2])>>>6),f=(1&t[i+2])<<2|(192&t[i+3])>>>6,h=e._getConfig(o,f,d),p=h.config,v=h.codec,m=0,y=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(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+m*y,data:t.subarray(i+7+c,i+l)}),m++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:f,codec:v,config:p,originCodec:"mp4a.40.".concat(d)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,a=e.FREQ[n];if(!a)throw new Error("Invalid sampling index: ".concat(n));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 je?e>=6?(n=5,i=e-3):(n=2,i=e):Ne?(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}();l(We,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Ye=function(){function e(){o(this,e)}return c(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],f=23,h=t[22],p=0;p<h;p++){a=63&t[f],s=t[f+1]<<8|t[f+2],f+=3;for(var v=0;v<s;v++)if(o=t[f]<<8|t[f+1],f+=2,o){switch(a){case 32:var m=t.subarray(f,f+o);n||(n=e.parseVPS(Ke.removeEPB(m),r)),d.push(m);break;case 33:var y=t.subarray(f,f+o);i||(i=e.parseSPS(Ke.removeEPB(y),r)),c.push(y);break;case 34:l.push(t.subarray(f,f+o))}f+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:d,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new Le(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 Le(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,d,f=n.readUEG(),h=n.readUEG(),p=n.readBits(1);if(1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),d=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p){var v=1!==a&&2!==a||0!==o?1:2,m=1===a&&0===o?2:1;f-=v*(c+u),h-=m*(d+l)}return{codec:"hev1.1.6.L93.B0",width:f,height:h,chromaFormat:s,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);for(var a=[],s=[],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}(),Ze=1e3,Xe=5e3,$e=function(){function e(t,r,n){o(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._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return c(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,a=this.audioTrack;if(!r&&n||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,i),this._baseDtsInited){if(!n&&t&&(this._audioNextPts=this._videoNextDts=t),this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._fixVideo(i),this.metadataTrack.exist()){var s=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/s}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else{var i=e.samples[0],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var f;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:ke,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(f=r[1])||void 0===f?void 0:f.dts,sampleDuration:d});this._videoTimestampBreak>=5?(this._videoNextDts=l.dts,this._videoTimestampBreak=0):(l.dts+=d,l.pts+=d)}for(var h=0;h<u;h++){var p=r[h].dts,v=r[h+1];((c=h<u-1?v.dts-p:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:be,time:p/e.timescale,dts:p,originDts:r[h].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[h].duration=c,this._videoNextDts+=c}}}}},{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:ge,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){if(!this._calculateBaseDts(this.audioTrack,this.videoTrack))return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._videoLastSample=null,this._videoTimestampBreak=0,this._audioTimestampBreak=0}}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=e.codecType===ve?We.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===ve?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&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=Ze&&!Re){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Xe&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:xe,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var f=0;f<d;f++){var h=new De(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);h.originPts=Math.floor(this._baseDts+o),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Xe&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:we,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(c)>Ze&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Xe&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:_e,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===ve?We.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),Je=function(){function e(){o(this,e)}return c(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,a=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var f=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),h=f.size,p=f.data;if(f.isEnd)break;r[p.name]=p.value,i+=h}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var m=0;m<v;m++){var y=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=y.data,b=y.size;r.push(g),i+=b}break;case 11:var k=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(k),i+=10;break;case 12:var _=t.getUint32(1);i+=4,r="",_>0&&(r=Ue.decode(new Uint8Array(t.buffer,t.byteOffset+i,_))),i+=_;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=Ue.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),n=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:n.data},size:r.size+n.size,isEnd:n.isEnd}}}}]),e}(),et=new Oe("FlvDemuxer"),tt=function(){function e(t,r,n){o(this,e),l(this,"_headerParsed",!1),l(this,"_remainingData",null),l(this,"_gopId",0),l(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Se,this.audioTrack=r||new Te,this.metadataTrack=n||new Pe,this._fixer=new $e(this.videoTrack,this.audioTrack,this.metadataTrack)}return c(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,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=ze(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=Ve(t,5)+4}for(var u,c,l,d,f,h=t.length;o+15<h&&(u=t[o],!(o+15+(c=t[o+1]<<16|t[o+2]<<8|t[o+3])>h));)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):et.warn("Invalid tag type: ".concat(u)),(f=Ve(t,o+=c))!==11+c&&et.warn("Invalid PrevTagSize ".concat(f," (").concat(11+c,")")),o+=4;return o<h&&(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 et.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?me:ye,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new De(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=ve,0===e[1]){var n=We.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(),et.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new De(t,e.subarray(2)))}else et.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 et.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?pe:he;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?Ye.parseHEVCDecoderConfigurationRecord(c):Qe.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,f=l.sps,h=l.ppsArr,p=l.spsArr,v=l.vpsArr,m=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),f&&(a.codec=f.codec,a.width=f.width,a.height=f.height,a.sarRatio=f.sarRatio,a.fpsNum=f.fpsNum,a.fpsDen=f.fpsDen),p.length&&(a.sps=p),h.length&&(a.pps=h),v&&v.length&&(a.vps=v),m&&(a.nalUnitSize=m)}else et.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var y=Ke.parseAvcC(e.subarray(5),a.nalUnitSize);if((y=this._checkAddMetaNalToUnits(s,y,a))&&y.length){var g=new Ee(t+u,t,y);1===n&&g.setToKeyframe(),a.samples.push(g),y.forEach((function(e){var n=s?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==n||s&&5===n)break;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Ae(Ke.parseSEI(Ke.removeEPB(e)),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else et.warn("Cannot parse NALUs",e)}else 2===o||et.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 Ce(Je.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Ve(e,5)>=9}}]),e}();l(tt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Oe("TsDemuxer");var rt=function(){function e(){o(this,e)}return c(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=Ve(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=qe(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:"moov",value:function(t){return st(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)}))}))}},{key:"mvhd",value:function(e){return st(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ve(t,16),e.duration=qe(t,20),r+=28):(e.timescale=Ve(t,8),e.duration=Ve(t,12),r+=16),e.nextTrackId=Ve(t,r+76)}))}},{key:"trak",value:function(t){return st(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 st(e,!0,(function(e,t){var r=0;1===e.version?(e.trackId=Ve(t,16),e.duration=qe(t,24),r+=32):(e.trackId=Ve(t,8),e.duration=Ve(t,16),r+=20),e.width=Ve(t,r+52),e.height=Ve(t,r+56)}))}},{key:"mdia",value:function(t){return st(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 st(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ve(t,16),e.duration=qe(t,20),r+=28):(e.timescale=Ve(t,8),e.duration=Ve(t,12),r+=16);var n=Ge(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return st(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return st(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 st(e,!0,(function(e,t){e.graphicsmode=Ge(t),e.opcolor=[Ge(t,2),Ge(t,4),Ge(t,6)]}))}},{key:"smhd",value:function(e){return st(e,!0,(function(e,t){e.balance=Ge(t)}))}},{key:"stbl",value:function(t){return st(t,!1,(function(t,r,n){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.stss=e.stss(e.findBox(r,["stss"],n)[0])}))}},{key:"stsd",value:function(t){return st(t,!0,(function(t,r,n){t.entryCount=Ve(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)}})).filter(Boolean)}))}},{key:"avc1",value:function(t){return st(t,!1,(function(t,r,n){var i=it(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 st(e,!1,(function(e,t){e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=He([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=Ge(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=Ge(t,r);r+=2,e.pps.push(t.subarray(r,r+=s)),r+=s}}))}},{key:"hvc1",value:function(t){return st(t,!1,(function(t,r,n){var i=it(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 st(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=Ve(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=Ge(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=Ge(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=Ge(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var f;(f=t.sps).push.apply(f,l)}else if(34===a){var h;(h=t.pps).push.apply(h,l)}}}))}},{key:"pasp",value:function(e){return st(e,!1,(function(e,t){e.hSpacing=Ve(t),e.vSpacing=Ve(t,4)}))}},{key:"mp4a",value:function(t){return st(t,!1,(function(t,r,n){var i=at(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return st(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,void(e.codec+=o.toString(16))}return}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return st(e,!1,(function(e,t){at(e,t)}))}},{key:"stts",value:function(e){return st(e,!0,(function(e,t){for(var r=Ve(t),n=[],i=4,a=0;a<r;a++)n.push({count:Ve(t,i),delta:Ve(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return st(e,!0,(function(e,t){var r=Ve(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:Ve(t,i),offset:Ve(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:Ve(t,i),offset:-(1+~Ve(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return st(e,!0,(function(e,t){for(var r=Ve(t),n=[],i=4,a=0;a<r;a++)n.push({firstChunk:Ve(t,i),samplesPerChunk:Ve(t,i+4),sampleDescriptionIndex:Ve(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return st(e,!0,(function(e,t){var r=Ve(t),n=Ve(t,4),i=[];if(!r)for(var a=8,s=0;s<n;s++)i.push(Ve(t,a)),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return st(e,!0,(function(e,t){for(var r=Ve(t),n=[],i=4,a=0;a<r;a++)n.push(Ve(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return st(e,!0,(function(e,t){for(var r=Ve(t),n=[],i=4,a=0;a<r;a++)n.push(Ve(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return st(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 st(e,!0,(function(e,t){e.sequenceNumber=Ve(t)}))}},{key:"traf",value:function(t){return st(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:"tfhd",value:function(e){return st(e,!0,(function(e,t){var r=e.flags,n=t.length;e.trackId=Ve(t);var i=4;n>i&&1&r&&(e.baseDataOffset=qe(t,i),i+=8),n>i&&2&r&&(e.sampleDescriptionIndex=Ve(t,i),i+=4),n>i&&8&r&&(e.defaultSampleDuration=Ve(t,i),i+=4),n>i&&10&r&&(e.defaultSampleSize=Ve(t,i),i+=4),n>i&&32&r&&(e.defaultSampleFlags=Ve(t,i),i+=4)}))}},{key:"trun",value:function(e){return st(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=Ve(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~Ve(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=Ve(t,s),s+=4),e.samples=[],i>s)for(var o,u=0;u<a;u++)o={},256&n&&(o.duration=Ve(t,s),s+=4),512&n&&(o.size=Ve(t,s),s+=4),1024&n&&(o.flags=Ve(t,s),s+=4),2048&n&&(o.cts=r?-(1+~Ve(t,s+4)):Ve(t,s),s+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return st(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=qe(t):e.baseMediaDecodeTime=Ve(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{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=t;null!=(null===(u=s.tkhd)||void 0===u?void 0:u.trackId)&&(c.id=s.tkhd.trackId),c.timescale=c.formatTimescale=s.mdia.mdhd.timescale,c.duration=s.mdia.mdhd.duration;var l=s.mdia.minf.stbl.stsd.entries[0];if(c.width=l.width,c.height=l.height,l.pasp&&(c.sarRatio=[l.pasp.hSpacing,l.pasp.vSpacing]),l.hvcC)c.codecType=pe,c.codec=l.hvcC.codec,c.vps=l.hvcC.vps,c.sps=l.hvcC.sps,c.pps=l.hvcC.pps,c.hvcC=l.hvcC.data;else{if(!l.avcC)throw new Error("unknown video stsd entry");c.codec=l.avcC.codec,c.sps=l.avcC.sps,c.pps=l.avcC.pps}c.present=!0}if(o&&r){var d,f=r;null!=(null===(d=o.tkhd)||void 0===d?void 0:d.trackId)&&(f.id=o.tkhd.trackId),f.timescale=f.formatTimescale=o.mdia.mdhd.timescale,f.duration=o.mdia.mdhd.duration;var h=o.mdia.minf.stbl.stsd.entries[0];switch(f.sampleSize=h.sampleSize,f.sampleRate=h.sampleRate,f.channelCount=h.channelCount,f.present=!0,h.type){case"alaw":f.codecType=f.codec=me,f.sampleRate=8e3;break;case"ulaw":f.codecType=f.codec=ye,f.sampleRate=8e3;break;default:f.sampleDuration=We.getFrameDuration(f.sampleRate,f.timescale),f.sampleRateIndex=We.getRateIndexByRate(f.sampleRate),f.objectType=(null===(n=h.esds)||void 0===n?void 0:n.objectType)||2,h.esds&&(f.config=Array.from(h.esds.config)),f.codec=(null===(i=h.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}}return{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,f=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=[];for(var h=0;h<o.sampleCount;h++)i[a.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[a.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:f,keyframe:0===t||null!=e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(f++,e.gopId=f),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,f=u.stco,h=u.stss,p=u.ctts;if(!(c&&l&&d&&f&&h))return;i=nt(c,l,d,f,p,h)}if(n){var v,m,y,g=null===(v=n.mdia)||void 0===v||null===(m=v.minf)||void 0===m?void 0:m.stbl;if(!g)return;var b=null===(y=n.mdia.mdhd)||void 0===y?void 0:y.timescale,k=g.stts,_=g.stsc,x=g.stsz,w=g.stco;if(!(b&&k&&_&&x&&w))return;a=nt(k,_,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function nt(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,f=n.entries,h=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,m=0,y=0,g=0,b=0,k=0,_=d[0].samplesPerChunk,x=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:m,duration:n,size:h[y]||r.sampleSize,offset:f[g]+k,index:y},p&&(u.keyframe=s[y],u.keyframe&&v++,u.gopId=v),o&&o[y]&&(u.pts=u.dts+o[y]),c.push(u),m+=n,++y<_?k+=u.size:(g++,k=0,g>=x&&(b++,x=d[b+1]?d[b+1].firstChunk-1:1/0),_+=d[b].samplesPerChunk)})),c}function it(e,t){return e.dataReferenceIndex=Ge(t,6),e.width=Ge(t,24),e.height=Ge(t,26),e.horizresolution=Ve(t,28),e.vertresolution=Ve(t,32),e.frameCount=Ge(t,40),e.depth=Ge(t,74),78}function at(e,t){return e.dataReferenceIndex=Ge(t,6),e.channelCount=Ge(t,16),e.sampleSize=Ge(t,18),e.sampleRate=Ve(t,24)/65536,28}function st(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 ot=Math.pow(2,32)-1,ut=function(){function e(){o(this,e)}return c(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===le&&e.codecType===pe}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return ze(e.ftyp(t),e.moov(t))}},{key:"moov",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(x(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===le?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.STTS,e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){return e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),t.type===le?e.avc1hev1(t):e.mp4a(t))}},{key:"avc1hev1",value:function(t){var r=t.codecType===pe,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),a=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),i];return 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=[];return t.sps.forEach((function(e){r=e.byteLength,n.push(r>>>8&255),n.push(255&r),n.push.apply(n,x(e))})),t.pps.forEach((function(e){r=e.byteLength,i.push(r>>>8&255),i.push(255&r),i.push.apply(i,x(e))})),e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(i)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer)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,x(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=_(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(x(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:"moof",value:function(t,r){return e.box.apply(e,[e.types.moof,e.mfhd(t)].concat(x(r.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){return e.box(e.types.traf,e.tfhd(t.id),e.tfdt(t.baseMediaDecodeTime),e.trun(t.samples,76))}},{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){var r=Math.floor(t/(ot+1)),n=Math.floor(t%(ot+1));return e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,f=o.cts,h=void 0===f?0:f;a.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null==d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null==d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*s)}return e.box(e.types.trun,a)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(x(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===le?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,ze(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,ze(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,ze(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,ze(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,ze(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,ze(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}}]),e}();l(ut,"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","trun","trex","tkhd","vmhd","smhd","ctts","stss"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),l(ut,"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])}),l(ut,"FTYPAVC1",ut.box(ut.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),l(ut,"FTYPHEV1",ut.box(ut.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),l(ut,"DINF",ut.box(ut.types.dinf,ut.box(ut.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),l(ut,"VMHD",ut.box(ut.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),l(ut,"SMHD",ut.box(ut.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),l(ut,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),l(ut,"STTS",ut.box(ut.types.stts,ut.StblTable)),l(ut,"STSC",ut.box(ut.types.stsc,ut.StblTable)),l(ut,"STSZ",ut.box(ut.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),l(ut,"STCO",ut.box(ut.types.stco,ut.StblTable));var ct=/Chrome\/([^.]+)/.exec(navigator.userAgent),lt=ct&&Number(ct[1])<50,dt=function(){function e(t,r){o(this,e),this.videoTrack=t,this.audioTrack=r}return c(e,[{key:"remux",value:function(){var e,t,r,n,i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=this.videoTrack,s=this.audioTrack,o=a.exist(),u=s.exist();return i&&(o&&(e=ut.initSegment([this.videoTrack])),u&&(t=ut.initSegment([this.audioTrack]))),o&&a.hasSample()&&(r=this._remuxVideo()),u&&s.hasSample()&&(n=this._remuxAudio()),a.samples=[],s.samples=[],{videoInitSegment:e,audioInitSegment:t,videoSegment:r,audioSegment:n}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack,t=e.samples;lt&&(t[0].flag={dependsOn:2,isNonSyncSample:0});var r=0;t.forEach((function(e){r+=e.units.reduce((function(e,t){return e+t.byteLength}),0),r+=4*e.units.length}));for(var n,i=new Uint8Array(r),a=new DataView(i.buffer),s=function(e,r,s,o){o=t[e];var u=0;o.units.forEach((function(e){a.setUint32(s,e.byteLength),s+=4,i.set(e,s),s+=e.byteLength,u+=4+e.byteLength})),o.size=u,c=s,n=o},o=0,u=t.length,c=0;o<u;o++)s(o,0,c,n);return ze(ut.moof(this.videoTrack.sequenceNumber++,[e]),ut.mdat(i))}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=ut.moof(this.audioTrack.sequenceNumber++,[e]),r=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));return e.samples.reduce((function(e,t){return r.set(t.data,e),e+t.size}),0),ze(t,ut.mdat(r))}}]),e}(),ft=function(){function e(t,r,n){o(this,e),l(this,"_videoSamples",[]),l(this,"_audioSamples",[]),this.videoTrack=t||new Se,this.audioTrack=r||new Te,this.metadataTrack=n||new Pe}return c(e,[{key:"demux",value:function(e,t,r,n,i){if(!this._audioSamples.length&&!this._videoSamples.length){if(!i)throw new Error("moov is required");rt.moovToTrack(i,this.videoTrack,this.audioTrack);var a=rt.moovToSamples(i);if(!a)throw new Error("cannot parse samples from moov box");this._videoSamples=a.videoSamples||[],this._audioSamples=a.audioSamples||[]}var s,o,u,c=this.videoTrack,l=this.audioTrack;if(c.samples=[],l.samples=[],r){for(var d,f=0,h=r[0],p=r[1];h<=p;h++){if(!(s=this._videoSamples[h]))throw new Error("cannot found video frame #".concat(h));u=s.offset-t,o=e.subarray(u,u+s.size),(d=new Ee(s.pts||s.dts,s.dts)).duration=s.duration,d.gopId=s.gopId,s.keyframe&&d.setToKeyframe();for(var v=0,m=o.length-1;v<m;)f=Ve(o,v),v+=4,d.units.push(o.subarray(v,v+f)),v+=f;c.samples.push(d)}c.baseMediaDecodeTime=c.samples[0].dts}if(n){for(var y=n[0],g=n[1];y<=g;y++){if(!(s=this._audioSamples[y]))throw new Error("cannot found video frame #".concat(y));u=s.offset-t,o=e.subarray(u,u+s.size),l.samples.push(new De(s.dts,o,s.duration))}l.baseMediaDecodeTime=l.samples[0].dts}return{videoTrack:c,audioTrack:l,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this._videoSamples=[],this._audioSamples=[],this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}}],[{key:"probe",value:function(e){return rt.probe(e)}}]),e}();var ht=c((function e(t,r){o(this,e),this.type="file",this.message=t,this.data=r})),pt=function(){function e(){o(this,e),l(this,"_data",Object.create(null))}return c(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 vt(e,t){var r=e.trak;if(r&&r.length){var n=r.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),i=r.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(n||i){var a,s=[],o=[];if(n){var u,c,l,d=null===(u=n.mdia)||void 0===u||null===(c=u.minf)||void 0===c?void 0:c.stbl;if(!d)return;var f=null===(l=n.mdia.mdhd)||void 0===l?void 0:l.timescale,h=d.stts,p=d.stsc,v=d.stsz,m=d.stco,y=d.stss,g=d.ctts;if(!(f&&h&&p&&v&&m&&y))return;a=(s=mt(t,f,h,p,v,m,y,g)).map((function(e){return e.duration}))}if(i){var b,k,_,x=null===(b=i.mdia)||void 0===b||null===(k=b.minf)||void 0===k?void 0:k.stbl;if(!x)return;var w=null===(_=i.mdia.mdhd)||void 0===_?void 0:_.timescale,S=x.stts,T=x.stsc,E=x.stsz,D=x.stco;if(!(w&&S&&T&&E&&D))return;o=mt(t,w,S,T,E,D,null,null,a)}return{videoSegments:s,audioSegments:o}}}}function mt(e,t,r,n,i,a,s,o,u){var c,l,d,f,h=[],p=[],v=[],m=n.entries,y=a.entries,g=i.entrySizes,b=null==s?void 0:s.entries,k=null==o?void 0:o.entries;k&&(c=[],k.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)c.push(r)}))),b&&(l={},b.forEach((function(e){l[e-1]=!0})));var _=0,w=0,S=0,T=0,E=0,D=m[0].samplesPerChunk,B=m[1]?m[1].firstChunk-1:1/0,C=0,A=-1;r.entries.forEach((function(e){var t=e.count,r=e.delta;f=r;for(var n=0;n<t;n++)d={dts:C,startTime:_,duration:f,size:g[w]||i.sampleSize,offset:y[S]+E,index:w},b&&(d.keyframe=l[w],d.keyframe?(A++,p.push([d]),v.push(d.duration)):(p[p.length-1].push(d),v[p.length-1]+=d.duration),d.gopId=A),c&&w<c.length&&(d.pts=C+c[w]),h.push(d),_+=f,C+=r,++w<D?E+=d.size:(S++,E=0,S>=B&&(T++,B=m[T+1]?m[T+1].firstChunk-1:1/0),D+=m[T].samplesPerChunk)}));var P=h.length;if(P&&(!s||h[0].keyframe)){var L,O=[],U=[],I=0,M=function(e){var r;L=U[U.length-1],O.push({index:O.length,startTime:(null===(r=O[O.length-1])||void 0===r?void 0:r.endTime)||U[0].startTime/t,endTime:(L.startTime+L.duration)/t,duration:e,range:[U[0].offset,L.offset+L.size],frames:U}),I=0,U=[]};if(s)for(var R=e*t,j=0,N=p.length;j<N;j++){var z;I+=v[j],(z=U).push.apply(z,x(p[j])),j+1<N?I>R&&M(I/t):M(I/t)}else for(var F=(u=u||[])[0]||e,G=0;G<P;G++)U.push(h[G]),I+=h[G].duration,(G+1>=P||I/t>=F)&&(M(I/t),F=u[O.length]||e);return O}}function yt(e){var t="",r="",n=0,i=0,a=0,s=0,o=0;e.mvhd&&(o=e.mvhd.duration/e.mvhd.timescale);var u=e.trak;if(u){var c,l,d,f,h,p,v,m,y,g,b,k,_,x=u.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)})),w=u.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)})),S=null;if(x)if(S=null===(l=x.mdia)||void 0===l||null===(d=l.minf)||void 0===d||null===(f=d.stbl)||void 0===f?void 0:f.stsd.entries[0])if(n=S.width,i=S.height,t=null===(h=S.avcC||S.hvcC)||void 0===h?void 0:h.codec,"encv"===S.type)c=null===(p=S.sinf)||void 0===p||null===(v=p.schi)||void 0===v?void 0:v.tenc.default_KID;if(w)if(S=null===(m=w.mdia)||void 0===m||null===(y=m.minf)||void 0===y||null===(g=y.stbl)||void 0===g?void 0:g.stsd.entries[0])if(a=S.channelCount,s=S.sampleRate,r=null===(b=S.esds)||void 0===b?void 0:b.codec,"enca"===S.type)c=c||(null===(k=S.sinf)||void 0===k||null===(_=k.schi)||void 0===_?void 0:_.tenc.default_KID);return{kid:c?c.join(""):null,videoCodec:t,audioCodec:r,width:n,height:i,audioChannelCount:a,audioSampleRate:s,duration:o,moov:e}}}function gt(e){return"number"==typeof e&&!isNaN(e)}var bt=["vid","moovEnd","segmentDuration","cache","maxDownloadInfoSize"],kt=function(){function e(t){o(this,e),l(this,"vid",""),l(this,"url",""),l(this,"meta",{}),l(this,"downloadInfo",[]),l(this,"videoSegments",[]),l(this,"audioSegments",[]),l(this,"cache",null),l(this,"_currentSegmentIndex",-1),l(this,"_currentLoadingSegmentIndex",-1),l(this,"_transformError",(function(e){return e.type="network",e})),this._config=r(r({vid:"",moovEnd:8e3,segmentDuration:5,maxDownloadInfoSize:30,cache:null},t),{},{responseType:"arraybuffer"});var n=this._config,i=n.vid;n.moovEnd,n.segmentDuration;var a=n.cache;n.maxDownloadInfoSize;var s=y(n,bt);this.cache=a||new pt,this.vid=i||s.url,this.url=s.url,s.transformError=this._transformError,this._loader=new ie(s)}var t,i,a,u,d,f,h,p,v,m;return c(e,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){gt(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!gt(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:(m=s(n().mark((function e(t){var r,i,a=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:t,i=a.length>2?a[2]:void 0,e.next=4,this.reset();case 4:t&&(this.url=t),r&&(this.vid=r),i&&(this._config.moovEnd=i);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"getOrLoadMeta",value:(v=s(n().mark((function e(t){return n().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 v.apply(this,arguments)})},{key:"loadMeta",value:(p=s(n().mark((function e(t,r){var i,a,s,o,u,c,l,d,f;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=[],e.next=3,this._loadData([0,r||this._config.moovEnd],t);case 3:if(a=e.sent){e.next=6;break}return e.abrupt("return");case 6:if(i.push(a),s=rt.findBox(a.data,["moov"])[0]){e.next=22;break}if(o=rt.findBox(a.data,["mdat"])[0]){e.next=12;break}throw new ht("cannot find moov or mdat box",a.data);case 12:return u=o.start+o.size,e.next=15,this._loadData([u],t);case 15:if(a=e.sent){e.next=18;break}return e.abrupt("return");case 18:if(i.push(a),s=rt.findBox(a.data,["moov"],u)[0]){e.next=22;break}throw new ht("cannot find moov box",a.data);case 22:if(!(s.size>s.data.length)){e.next=30;break}return e.next=25,this._loadData([a.data.length,s.start+s.size-1],t);case 25:if(a=e.sent){e.next=28;break}return e.abrupt("return");case 28:i.push(a),s.data=re(s.data,a.data);case 30:if(c=rt.moov(s)){e.next=33;break}throw new ht("cannot parse moov box",s.data);case 33:if(l=vt(c,this._config.segmentDuration)){e.next=36;break}throw new ht("cannot parse segments",s.data);case 36:return this.meta=yt(c),d=l.videoSegments,f=l.audioSegments,this.videoSegments=d,this.audioSegments=f,e.abrupt("return",{meta:this.meta,videoSegments:d,audioSegments:f,responses:i});case 41:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{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:(h=s(n().mark((function e(t,r){var i,a,s,o,u=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(u.length>2&&void 0!==u[2])||u[2],this.isMetaLoaded){e.next=4;break}return e.next=4,this.loadMeta(r);case 4:return a=this.getSegmentByTime(t),s=a.video,o=a.audio,e.abrupt("return",this._loadSegment(s,o,r,i));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"loadNextSegment",value:(f=s(n().mark((function e(t){var r,i,a,s=arguments;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!(s.length>1&&void 0!==s[1])||s[1],this.isMetaLoaded){e.next=4;break}return e.next=4,this.loadMeta();case 4:return i=this.videoSegments[this._currentSegmentIndex+1],a=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(i,a,t,r));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"preload",value:(d=s(n().mark((function e(t){var r,i,a,o,u,c,l,d=this;return n().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(r=this.getSegmentByTime(t),i=r.video,a=r.audio,o=Math.max((null==i?void 0:i.index)||0,(null==a?void 0:a.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=s(n().mark((function e(t){return n().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 d.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(u=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._loader.cancel();case 2:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"destroy",value:(a=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.cancel();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_loadSegment",value:(i=s(n().mark((function e(t,r,i,a){var s,o;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||r){e.next=2;break}return e.abrupt("return");case 2:return s=(null==t?void 0:t.index)||(null==r?void 0:r.index)||0,this._currentLoadingSegmentIndex=s,e.prev=4,e.next=7,this._loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==r?void 0:r.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==r?void 0:r.range[1])||0)],i);case 7:o=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(o){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=s),o.video=t,o.audio=r,e.abrupt("return",o);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n){return i.apply(this,arguments)})},{key:"_loadData",value:(t=s(n().mark((function e(t,r){var i,a,s;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this._getCacheKey(t),e.next=3,this.cache.get(i);case 3:if(a=e.sent){e.next=10;break}return e.next=7,this._loader.load(this.url,{range:t});case 7:s=e.sent,e.next=11;break;case 10:s={data:a,fromCache:!0};case 11:if(s){e.next=13;break}return e.abrupt("return");case 13:return a||(this.downloadInfo.push({startTime:s.startTime,endTime:s.endTime,size:s.data.byteLength,range:t}),this._addDownloadInfo>this._config.maxDownloadInfoSize&&(this._downloadInfos=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),!a&&r&&this.cache.set(i,s.data),s.range=t,e.abrupt("return",s);case 17:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),e}(),_t=function(){function e(t,r){o(this,e),l(this,"_demuxer",new ft),l(this,"_remuxer",null),l(this,"_mse",null),l(this,"_softVideo",null),l(this,"_needInitSegment",!0),l(this,"_sourceCreated",!1),this.mp4=t,r?this._softVideo=t.media:(this._remuxer=new dt(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new N,this._mse.bindMedia(t.media))}var t,r,i,a,u;return c(e,[{key:"appendBuffer",value:(u=s(n().mark((function e(t,r,i,a,s){var o,u,c,l,d,f,h,p,v,m;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&t.length){e.next=2;break}return e.abrupt("return");case 2:if(i&&(o=[i[0].index,i[i.length-1].index]),a&&(u=[a[0].index,a[a.length-1].index]),o||u){e.next=6;break}return e.abrupt("return");case 6:if(c=this._demuxer.demux(t,r,o,u,s),l=c.videoTrack,d=c.audioTrack,f=l.type,h=d.type,!(p=this._mse)){e.next=28;break}this._sourceCreated||(l.exist()&&(p.createSource(f,"video/mp4;codecs=".concat(l.codec)),this._sourceCreated=!0),d.exist()&&(p.createSource(h,"audio/mp4;codecs=".concat(d.codec)),this._sourceCreated=!0)),e.prev=12,v=this._remuxer.remux(this._needInitSegment),e.next=19;break;case 16:throw e.prev=16,e.t0=e.catch(12),new M(P,U.FMP4,e.t0);case 19:return this._needInitSegment=!1,m=[],v.videoInitSegment&&m.push(p.append(f,v.videoInitSegment)),v.audioInitSegment&&m.push(p.append(h,v.audioInitSegment)),v.videoSegment&&m.push(p.append(f,v.videoSegment)),v.audioSegment&&m.push(p.append(h,v.audioSegment)),e.abrupt("return",Promise.all(m).catch((function(e){if(e.type!==j.CANCELLED)throw new M(L,U.MSE_APPEND_BUFFER,e)})));case 28:this._softVideo&&this._softVideo.appendBuffer(l,d);case 29:case"end":return e.stop()}}),e,this,[[12,16]])}))),function(e,t,r,n,i){return u.apply(this,arguments)})},{key:"evictBuffer",value:(a=s(n().mark((function e(t){var r,i,a,s,o,u=this;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.mp4.media,this._mse&&this._demuxer&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(i=r.currentTime,!((a=i-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(D.start(D.get(r))+1>=a)){e.next=10;break}return e.abrupt("return");case 10:return s=this._demuxer,o=[],[s.videoTrack,s.audioTrack].forEach((function(e){e.exist()&&o.push(u._mse.remove(e.type,0,a))})),e.abrupt("return",Promise.all(o).catch((function(e){if(e.type!==j.CANCELLED)throw new M(L,U.MSE_OTHER,e)})));case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"reset",value:(i=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=6;break}return e.next=3,this._mse.unbindMedia();case 3:return e.next=5,this._mse.bindMedia(this.mp4.media);case 5:this._mseOpened=!1;case 6:this._sourceCreated=!1,this._needInitSegment=!0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"endOfStream",value:(r=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=12;break}if(!this._sourceCreated){e.next=12;break}return e.prev=2,e.next=5,this._mse.endOfStream();case 5:e.next=12;break;case 7:if(e.prev=7,e.t0=e.catch(2),e.t0.type!==j.CANCELLED){e.next=11;break}return e.abrupt("return");case 11:throw new M(L,U.MSE_OTHER,e.t0);case 12:this._softVideo&&this._softVideo.endOfStream();case 13:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(){return r.apply(this,arguments)})},{key:"destroy",value:(t=s(n().mark((function e(){var t;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._mse,this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null,!t){e.next=8;break}return e.next=8,t.unbindMedia();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();var xt=function(e){d(h,e);var t,i,a,u,f=k(h);function h(e){var t,i,a;return o(this,h),l(g(t=f.call(this)),"_prevSegmentEndTime",0),l(g(t),"_tickTimer",null),l(g(t),"_loading",!1),l(g(t),"_onSeeking",s(n().mark((function e(){var r,i,a,s,o,u,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.media){e.next=2;break}return e.abrupt("return");case 2:if(r=t.media.currentTime,i=t._loader,a=i.getSegmentByTime(r),s=a.video,o=a.audio,u=s||o){e.next=8;break}return e.abrupt("return");case 8:if(!i.isSegmentLoading(u.index)){e.next=10;break}return e.abrupt("return");case 10:if(!(c=D.info(D.get(t.media),r,.1)).end||!(c.end>=u.endTime||c.end>=t.media.duration)){e.next=13;break}return e.abrupt("return");case 13:return e.next=15,i.cancel();case 15:t._loading=!1,t._prevSegmentEndTime=0,t._loadSegment(r),t._startTick();case 19:case"end":return e.stop()}}),e)})))),l(g(t),"_tick",(function(){t._stopTick();var e=t.media;e&&(t._startTick(t._config.tickInterval),D.end(D.get(e))<.1||!e.readyState||function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)&&t._loadSegment())})),e=t._config=(a=(null==(i=e)?void 0:i.media)||document.createElement("video"),r(r({softDecode:!1,tickInterval:500,preloadTime:10,bufferBehind:10,segmentDuration:void 0,url:"",retry:3,retryDelay:100},i),{},{media:a})),t.media=t._config.media,e.softDecode&&t.media.setPlayMode&&t.media.setPlayMode("VOD"),t._bufferService=new _t(g(t),e.softDecode),t._loader=new kt({url:e.url,retry:e.retry,retryDelay:e.retryDelay}),t.media.addEventListener("seeking",t._onSeeking),t}return c(h,[{key:"load",value:(u=s(n().mark((function e(t){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._reset();case 2:if(!t){e.next=5;break}return e.next=5,this._loader.changeUrl(t);case 5:return this._startTick(this._config.tickInterval),e.next=8,this._loadSegment(0);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"destroy",value:(a=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.media.removeEventListener("seeking",this._onSeeking),e.next=3,this._reset();case 3:return e.next=5,this._bufferService.destroy();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_reset",value:(i=s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._stopTick(),e.next=3,this._loader.reset();case 3:return e.next=5,this._bufferService.reset();case 5:this._prevSegmentEndTime=0,this._loading=!1;case 7:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_loadSegment",value:(t=s(n().mark((function e(t){var r,i,a,s,o,u,c,l;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._loading){e.next=2;break}return e.abrupt("return");case 2:if(o=this.media.currentTime,!(this._prevSegmentEndTime>o+this._config.preloadTime)){e.next=5;break}return e.abrupt("return");case 5:if(this._loading=!0,e.prev=6,null==t){e.next=13;break}return e.next=10,this._loader.loadSegmentByTime(t);case 10:u=e.sent,e.next=16;break;case 13:return e.next=15,this._loader.loadNextSegment();case 15:u=e.sent;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),this._emitError(M.network(e.t0));case 21:if(u){e.next=24;break}return this._loading=!1,e.abrupt("return");case 24:return this._prevSegmentEndTime=Math.min((null===(r=u.video)||void 0===r?void 0:r.endTime)||1/0,(null===(i=u.audio)||void 0===i?void 0:i.endTime)||1/0),e.prev=25,e.next=28,this._bufferService.appendBuffer(u.data,u.range[0],null===(c=u.video)||void 0===c?void 0:c.frames,null===(l=u.audio)||void 0===l?void 0:l.frames,this._loader.meta.moov);case 28:return e.next=30,this._bufferService.evictBuffer(this._config.bufferBehind);case 30:e.next=35;break;case 32:return e.prev=32,e.t1=e.catch(25),e.abrupt("return",this._emitError(M.create(e.t1)));case 35:return e.prev=35,this._loading=!1,e.finish(35);case 38:this._loader.isLastSegment((null===(a=u.video)||void 0===a?void 0:a.index)||(null===(s=u.audio)||void 0===s?void 0:s.index)||0)?this._end():this._loadSegment();case 39:case"end":return e.stop()}}),e,this,[[6,18],[25,32,35,38]])}))),function(e){return t.apply(this,arguments)})},{key:"_end",value:function(){this._bufferService.endOfStream(),this._stopTick()}},{key:"_startTick",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._stopTick(),this._tickTimer=setTimeout(this._tick,e)}},{key:"_stopTick",value:function(){clearTimeout(this._tickTimer)}},{key:"_emitError",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];console.error(e),console.table(e),this.emit(ae,e),t&&this._end()}}],[{key:"isSupported",value:function(){return N.isSupported()||!!WebAssembly}}]),h}(ce);l(xt,"version","3.0.0-next.2");var wt=function(t){d(i,t);var n=k(i);function i(){var e;o(this,i);for(var t=arguments.length,a=new Array(t),s=0;s<t;s++)a[s]=arguments[s];return l(g(e=n.call.apply(n,[this].concat(a))),"mp4",null),l(g(e),"destroy",(function(){var t,r;e.mp4&&(e.mp4.destroy(),e.mp4=null,null===(t=e.player)||void 0===t||null===(r=t.video)||void 0===r||r.removeEventListener("lowdecode",e._onLowDecode))})),l(g(e),"_onLowDecode",(function(){var t=e.player.video;t&&(e.player.emit("lowdecode",t.degradeInfo),e.player.emit("core_event",r(r({},t.degradeInfo),{},{eventName:se})))})),l(g(e),"_onSwitchURL",(function(t){e.mp4&&(e.player.config.url=t,e.mp4.load(t))})),l(g(e),"_onLowDecode",(function(){var t=e.player.video;t&&(e.player.emit("lowdecode",t.degradeInfo),e.player.emit("core_event",r(r({},t.degradeInfo),{},{eventName:se})))})),l(g(e),"_onDefinitionChange",(function(t){var r=t.to;e.mp4&&e.mp4.load(r)})),e}return c(i,[{key:"core",get:function(){return this.mp4}},{key:"version",get:function(){return xt.version}},{key:"softDecode",get:function(){var e,t,r=null===(e=this.player)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mediaType;return!!r&&"video"!==r}},{key:"beforePlayerInit",value:function(){var t=this,n=this.player.config;this.mp4&&this.mp4.destroy(),this.player.switchURL=this._onSwitchURL;var i=n.mp4||{};this.mp4=new xt(r({softDecode:this.softDecode,media:this.player.video,url:n.url},i)),this.softDecode?(this.player.forceDegradeToVideo=function(){},this.player.video.addEventListener("lowdecode",this._onLowDecode)):e.BasePlugin.defineGetterOrSetter(this.player,{__url:{get:function(){var e,r;return null===(e=t.mp4)||void 0===e||null===(r=e.media)||void 0===r?void 0:r.src},configurable:!0}}),this.on(e.Events.URL_CHANGE,this._onSwitchURL),this.on(e.Events.DEFINITION_CHANGE,this._onDefinitionChange),this.on(e.Events.DESTROY,this.destroy),this._transError(),this.mp4.load()}},{key:"_transError",value:function(){var t=this;this.mp4.on(ae,(function(r){t.player&&t.player.emit(e.Events.ERROR,new e.Errors(t.player,r))}))}}],[{key:"pluginName",get:function(){return"mp4"}},{key:"isSupported",value:function(e){return xt.isSupported(e)}}]),i}(e.BasePlugin);return l(wt,"MP4",xt),wt}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("xgplayer")):"function"==typeof define&&define.amd?define(["xgplayer"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Mp4Player=t(e.Player)}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,n=function(e){try{return!!e()}catch(t){return!0}},s=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),o=function(e){return e&&e.Math==Math&&e},a=o("object"==typeof globalThis&&globalThis)||o("object"==typeof window&&window)||o("object"==typeof self&&self)||o("object"==typeof r&&r)||function(){return this}()||Function("return this")(),u=function(e){return"function"==typeof e},c=u,d="object"==typeof document&&document.all,h=void 0===d&&void 0!==d?function(e){return"object"==typeof e?null!==e:c(e)||e===d}:function(e){return"object"==typeof e?null!==e:c(e)},f=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),l=f,m=Function.prototype,p=m.bind,y=m.call,g=l&&p.bind(y,y),w=l?function(e){return e&&g(e)}:function(e){return e&&function(){return y.apply(e,arguments)}},b=function(e){return null==e},v=b,x=TypeError,U=function(e){if(v(e))throw x("Can't call method on "+e);return e},B=U,S=Object,T=function(e){return S(B(e))},_=T,k=w({}.hasOwnProperty),z=Object.hasOwn||function(e,t){return k(_(e),t)},A={exports:{}},E=a,C=Object.defineProperty,O=function(e,t){try{C(E,e,{value:t,configurable:!0,writable:!0})}catch(r){E[e]=t}return t},M=O,L="__core-js_shared__",P=a[L]||M(L,{}),D=P;(A.exports=function(e,t){return D[e]||(D[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.25.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.1/LICENSE",source:"https://github.com/zloirock/core-js"});var F,j,R=w,I=0,N=Math.random(),q=R(1..toString),K=function(e){return"Symbol("+(void 0===e?"":e)+")_"+q(++I+N,36)},H=a,$=u,G=function(e){return $(e)?e:void 0},W=function(e,t){return arguments.length<2?G(H[e]):H[e]&&H[e][t]},Y=a,V=W("navigator","userAgent")||"",X=Y.process,Z=Y.Deno,J=X&&X.versions||Z&&Z.version,Q=J&&J.v8;Q&&(j=(F=Q.split("."))[0]>0&&F[0]<4?1:+(F[0]+F[1])),!j&&V&&(!(F=V.match(/Edge\/(\d+)/))||F[1]>=74)&&(F=V.match(/Chrome\/(\d+)/))&&(j=+F[1]);var ee=j,te=n,re=!!Object.getOwnPropertySymbols&&!te((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ee&&ee<41})),ie=re&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ne=a,se=A.exports,oe=z,ae=K,ue=re,ce=ie,de=se("wks"),he=ne.Symbol,fe=he&&he.for,le=ce?he:he&&he.withoutSetter||ae,me=function(e){if(!oe(de,e)||!ue&&"string"!=typeof de[e]){var t="Symbol."+e;ue&&oe(he,e)?de[e]=he[e]:de[e]=ce&&fe?fe(t):le(t)}return de[e]},pe={};pe[me("toStringTag")]="z";var ye="[object z]"===String(pe),ge=w,we=ge({}.toString),be=ge("".slice),ve=function(e){return be(we(e),8,-1)},xe=ye,Ue=u,Be=ve,Se=me("toStringTag"),Te=Object,_e="Arguments"==Be(function(){return arguments}()),ke=xe?Be:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=Te(e),Se))?r:_e?Be(t):"Object"==(i=Be(t))&&Ue(t.callee)?"Arguments":i},ze=String,Ae=function(e){try{return ze(e)}catch(t){return"Object"}},Ee={},Ce=h,Oe=a.document,Me=Ce(Oe)&&Ce(Oe.createElement),Le=function(e){return Me?Oe.createElement(e):{}},Pe=!s&&!n((function(){return 7!=Object.defineProperty(Le("div"),"a",{get:function(){return 7}}).a})),De=s&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Fe=h,je=String,Re=TypeError,Ie=function(e){if(Fe(e))return e;throw Re(je(e)+" is not an object")},Ne=f,qe=Function.prototype.call,Ke=Ne?qe.bind(qe):function(){return qe.apply(qe,arguments)},He=w({}.isPrototypeOf),$e=W,Ge=u,We=He,Ye=Object,Ve=ie?function(e){return"symbol"==typeof e}:function(e){var t=$e("Symbol");return Ge(t)&&We(t.prototype,Ye(e))},Xe=u,Ze=Ae,Je=TypeError,Qe=function(e){if(Xe(e))return e;throw Je(Ze(e)+" is not a function")},et=Qe,tt=b,rt=Ke,it=u,nt=h,st=TypeError,ot=Ke,at=h,ut=Ve,ct=function(e,t){var r=e[t];return tt(r)?void 0:et(r)},dt=function(e,t){var r,i;if("string"===t&&it(r=e.toString)&&!nt(i=rt(r,e)))return i;if(it(r=e.valueOf)&&!nt(i=rt(r,e)))return i;if("string"!==t&&it(r=e.toString)&&!nt(i=rt(r,e)))return i;throw st("Can't convert object to primitive value")},ht=TypeError,ft=me("toPrimitive"),lt=function(e,t){if(!at(e)||ut(e))return e;var r,i=ct(e,ft);if(i){if(void 0===t&&(t="default"),r=ot(i,e,t),!at(r)||ut(r))return r;throw ht("Can't convert object to primitive value")}return void 0===t&&(t="number"),dt(e,t)},mt=Ve,pt=function(e){var t=lt(e,"string");return mt(t)?t:t+""},yt=s,gt=Pe,wt=De,bt=Ie,vt=pt,xt=TypeError,Ut=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,St="enumerable",Tt="configurable",_t="writable";Ee.f=yt?wt?function(e,t,r){if(bt(e),t=vt(t),bt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&_t in r&&!r.writable){var i=Bt(e,t);i&&i.writable&&(e[t]=r.value,r={configurable:Tt in r?r.configurable:i.configurable,enumerable:St in r?r.enumerable:i.enumerable,writable:!1})}return Ut(e,t,r)}:Ut:function(e,t,r){if(bt(e),t=vt(t),bt(r),gt)try{return Ut(e,t,r)}catch(i){}if("get"in r||"set"in r)throw xt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var kt=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},zt=Ee,At=kt,Et=s?function(e,t,r){return zt.f(e,t,At(1,r))}:function(e,t,r){return e[t]=r,e},Ct={exports:{}},Ot=s,Mt=z,Lt=Function.prototype,Pt=Ot&&Object.getOwnPropertyDescriptor,Dt=Mt(Lt,"name"),Ft={EXISTS:Dt,PROPER:Dt&&"something"===function(){}.name,CONFIGURABLE:Dt&&(!Ot||Ot&&Pt(Lt,"name").configurable)},jt=u,Rt=P,It=w(Function.toString);jt(Rt.inspectSource)||(Rt.inspectSource=function(e){return It(e)});var Nt,qt,Kt,Ht=Rt.inspectSource,$t=u,Gt=a.WeakMap,Wt=$t(Gt)&&/native code/.test(String(Gt)),Yt=A.exports,Vt=K,Xt=Yt("keys"),Zt=function(e){return Xt[e]||(Xt[e]=Vt(e))},Jt={},Qt=Wt,er=a,tr=w,rr=h,ir=Et,nr=z,sr=P,or=Zt,ar=Jt,ur="Object already initialized",cr=er.TypeError,dr=er.WeakMap;if(Qt||sr.state){var hr=sr.state||(sr.state=new dr),fr=tr(hr.get),lr=tr(hr.has),mr=tr(hr.set);Nt=function(e,t){if(lr(hr,e))throw cr(ur);return t.facade=e,mr(hr,e,t),t},qt=function(e){return fr(hr,e)||{}},Kt=function(e){return lr(hr,e)}}else{var pr=or("state");ar[pr]=!0,Nt=function(e,t){if(nr(e,pr))throw cr(ur);return t.facade=e,ir(e,pr,t),t},qt=function(e){return nr(e,pr)?e[pr]:{}},Kt=function(e){return nr(e,pr)}}var yr={set:Nt,get:qt,has:Kt,enforce:function(e){return Kt(e)?qt(e):Nt(e,{})},getterFor:function(e){return function(t){var r;if(!rr(t)||(r=qt(t)).type!==e)throw cr("Incompatible receiver, "+e+" required");return r}}},gr=n,wr=u,br=z,vr=s,xr=Ft.CONFIGURABLE,Ur=Ht,Br=yr.enforce,Sr=yr.get,Tr=Object.defineProperty,_r=vr&&!gr((function(){return 8!==Tr((function(){}),"length",{value:8}).length})),kr=String(String).split("String"),zr=Ct.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!br(e,"name")||xr&&e.name!==t)&&(vr?Tr(e,"name",{value:t,configurable:!0}):e.name=t),_r&&r&&br(r,"arity")&&e.length!==r.arity&&Tr(e,"length",{value:r.arity});try{r&&br(r,"constructor")&&r.constructor?vr&&Tr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var i=Br(e);return br(i,"source")||(i.source=kr.join("string"==typeof t?t:"")),e};Function.prototype.toString=zr((function(){return wr(this)&&Sr(this).source||Ur(this)}),"toString");var Ar,Er,Cr,Or=u,Mr=Ee,Lr=Ct.exports,Pr=O,Dr=function(e,t,r,i){i||(i={});var n=i.enumerable,s=void 0!==i.name?i.name:t;if(Or(r)&&Lr(r,s,i),i.global)n?e[t]=r:Pr(t,r);else{try{i.unsafe?e[t]&&(n=!0):delete e[t]}catch(o){}n?e[t]=r:Mr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},Fr=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),jr=z,Rr=u,Ir=T,Nr=Fr,qr=Zt("IE_PROTO"),Kr=Object,Hr=Kr.prototype,$r=Nr?Kr.getPrototypeOf:function(e){var t=Ir(e);if(jr(t,qr))return t[qr];var r=t.constructor;return Rr(r)&&t instanceof r?r.prototype:t instanceof Kr?Hr:null},Gr=u,Wr=String,Yr=TypeError,Vr=w,Xr=Ie,Zr=function(e){if("object"==typeof e||Gr(e))return e;throw Yr("Can't set "+Wr(e)+" as a prototype")},Jr=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vr(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return Xr(r),Zr(i),t?e(r,i):r.__proto__=i,r}}():void 0),Qr=i,ei=s,ti=a,ri=u,ii=h,ni=z,si=ke,oi=Ae,ai=Et,ui=Dr,ci=Ee.f,di=He,hi=$r,fi=Jr,li=me,mi=K,pi=yr.enforce,yi=yr.get,gi=ti.Int8Array,wi=gi&&gi.prototype,bi=ti.Uint8ClampedArray,vi=bi&&bi.prototype,xi=gi&&hi(gi),Ui=wi&&hi(wi),Bi=Object.prototype,Si=ti.TypeError,Ti=li("toStringTag"),_i=mi("TYPED_ARRAY_TAG"),ki="TypedArrayConstructor",zi=Qr&&!!fi&&"Opera"!==si(ti.opera),Ai=!1,Ei={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Ci={BigInt64Array:8,BigUint64Array:8},Oi=function(e){var t=hi(e);if(ii(t)){var r=yi(t);return r&&ni(r,ki)?r.TypedArrayConstructor:Oi(t)}},Mi=function(e){if(!ii(e))return!1;var t=si(e);return ni(Ei,t)||ni(Ci,t)};for(Ar in Ei)(Cr=(Er=ti[Ar])&&Er.prototype)?pi(Cr).TypedArrayConstructor=Er:zi=!1;for(Ar in Ci)(Cr=(Er=ti[Ar])&&Er.prototype)&&(pi(Cr).TypedArrayConstructor=Er);if((!zi||!ri(xi)||xi===Function.prototype)&&(xi=function(){throw Si("Incorrect invocation")},zi))for(Ar in Ei)ti[Ar]&&fi(ti[Ar],xi);if((!zi||!Ui||Ui===Bi)&&(Ui=xi.prototype,zi))for(Ar in Ei)ti[Ar]&&fi(ti[Ar].prototype,Ui);if(zi&&hi(vi)!==Ui&&fi(vi,Ui),ei&&!ni(Ui,Ti))for(Ar in Ai=!0,ci(Ui,Ti,{get:function(){return ii(this)?this[_i]:void 0}}),Ei)ti[Ar]&&ai(ti[Ar],_i,Ar);var Li={NATIVE_ARRAY_BUFFER_VIEWS:zi,TYPED_ARRAY_TAG:Ai&&_i,aTypedArray:function(e){if(Mi(e))return e;throw Si("Target is not a typed array")},aTypedArrayConstructor:function(e){if(ri(e)&&(!fi||di(xi,e)))return e;throw Si(oi(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(ei){if(r)for(var n in Ei){var s=ti[n];if(s&&ni(s.prototype,e))try{delete s.prototype[e]}catch(o){try{s.prototype[e]=t}catch(a){}}}Ui[e]&&!r||ui(Ui,e,r?t:zi&&wi[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,n;if(ei){if(fi){if(r)for(i in Ei)if((n=ti[i])&&ni(n,e))try{delete n[e]}catch(s){}if(xi[e]&&!r)return;try{return ui(xi,e,r?t:zi&&xi[e]||t)}catch(s){}}for(i in Ei)!(n=ti[i])||n[e]&&!r||ui(n,e,t)}},getTypedArrayConstructor:Oi,isView:function(e){if(!ii(e))return!1;var t=si(e);return"DataView"===t||ni(Ei,t)||ni(Ci,t)},isTypedArray:Mi,TypedArray:xi,TypedArrayPrototype:Ui},Pi=Math.ceil,Di=Math.floor,Fi=Math.trunc||function(e){var t=+e;return(t>0?Di:Pi)(t)},ji=function(e){var t=+e;return t!=t||0===t?0:Fi(t)},Ri=ji,Ii=Math.min,Ni=function(e){return e>0?Ii(Ri(e),9007199254740991):0},qi=function(e){return Ni(e.length)},Ki=qi,Hi=ji,$i=Li.aTypedArray;(0,Li.exportTypedArrayMethod)("at",(function(e){var t=$i(this),r=Ki(t),i=Hi(e),n=i>=0?i:r+i;return n<0||n>=r?void 0:t[n]}));var Gi=Qe,Wi=f,Yi=w(w.bind),Vi=n,Xi=ve,Zi=Object,Ji=w("".split),Qi=Vi((function(){return!Zi("z").propertyIsEnumerable(0)}))?function(e){return"String"==Xi(e)?Ji(e,""):Zi(e)}:Zi,en=function(e,t){return Gi(e),void 0===t?e:Wi?Yi(e,t):function(){return e.apply(t,arguments)}},tn=Qi,rn=T,nn=qi,sn=function(e){var t=1==e;return function(r,i,n){for(var s,o=rn(r),a=tn(o),u=en(i,n),c=nn(a);c-- >0;)if(u(s=a[c],c,o))switch(e){case 0:return s;case 1:return c}return t?-1:void 0}},on={findLast:sn(0),findLastIndex:sn(1)},an=on.findLast,un=Li.aTypedArray;(0,Li.exportTypedArrayMethod)("findLast",(function(e){return an(un(this),e,arguments.length>1?arguments[1]:void 0)}));var cn=on.findLastIndex,dn=Li.aTypedArray;(0,Li.exportTypedArrayMethod)("findLastIndex",(function(e){return cn(dn(this),e,arguments.length>1?arguments[1]:void 0)}));var hn={exports:{}},fn={exports:{}},ln=function(e){return null!=e},mn=ln,pn={object:!0,function:!0,undefined:!0},yn=function(e){return!!mn(e)&&hasOwnProperty.call(pn,typeof e)},gn=function(e){if(!yn(e))return!1;try{return!!e.constructor&&e.constructor.prototype===e}catch(t){return!1}},wn=function(e){if("function"!=typeof e)return!1;if(!hasOwnProperty.call(e,"length"))return!1;try{if("number"!=typeof e.length)return!1;if("function"!=typeof e.call)return!1;if("function"!=typeof e.apply)return!1}catch(t){return!1}return!gn(e)},bn=/^\s*class[\s{/}]/,vn=Function.prototype.toString,xn=function(e){return null!=e},Un=xn,Bn=Object.keys,Sn=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}()?Object.keys:function(e){return Bn(Un(e)?Object(e):e)},Tn={},_n={},kn={}.propertyIsEnumerable,zn=Object.getOwnPropertyDescriptor,An=zn&&!kn.call({1:2},1);_n.f=An?function(e){var t=zn(this,e);return!!t&&t.enumerable}:kn;var En=Qi,Cn=U,On=function(e){return En(Cn(e))},Mn=s,Ln=Ke,Pn=_n,Dn=kt,Fn=On,jn=pt,Rn=z,In=Pe,Nn=Object.getOwnPropertyDescriptor;Tn.f=Mn?Nn:function(e,t){if(e=Fn(e),t=jn(t),In)try{return Nn(e,t)}catch(r){}if(Rn(e,t))return Dn(!Ln(Pn.f,e,t),e[t])};var qn={},Kn=ji,Hn=Math.max,$n=Math.min,Gn=On,Wn=function(e,t){var r=Kn(e);return r<0?Hn(r+t,0):$n(r,t)},Yn=qi,Vn=function(e){return function(t,r,i){var n,s=Gn(t),o=Yn(s),a=Wn(i,o);if(e&&r!=r){for(;o>a;)if((n=s[a++])!=n)return!0}else for(;o>a;a++)if((e||a in s)&&s[a]===r)return e||a||0;return!e&&-1}},Xn={includes:Vn(!0),indexOf:Vn(!1)},Zn=z,Jn=On,Qn=Xn.indexOf,es=Jt,ts=w([].push),rs=function(e,t){var r,i=Jn(e),n=0,s=[];for(r in i)!Zn(es,r)&&Zn(i,r)&&ts(s,r);for(;t.length>n;)Zn(i,r=t[n++])&&(~Qn(s,r)||ts(s,r));return s},is=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");qn.f=Object.getOwnPropertyNames||function(e){return rs(e,is)};var ns={};ns.f=Object.getOwnPropertySymbols;var ss=W,os=qn,as=ns,us=Ie,cs=w([].concat),ds=ss("Reflect","ownKeys")||function(e){var t=os.f(us(e)),r=as.f;return r?cs(t,r(e)):t},hs=z,fs=ds,ls=Tn,ms=Ee,ps=function(e,t,r){for(var i=fs(t),n=ms.f,s=ls.f,o=0;o<i.length;o++){var a=i[o];hs(e,a)||r&&hs(r,a)||n(e,a,s(t,a))}},ys=n,gs=u,ws=/#|\.prototype\./,bs=function(e,t){var r=xs[vs(e)];return r==Bs||r!=Us&&(gs(t)?ys(t):!!t)},vs=bs.normalize=function(e){return String(e).replace(ws,".").toLowerCase()},xs=bs.data={},Us=bs.NATIVE="N",Bs=bs.POLYFILL="P",Ss=bs,Ts=a,_s=Tn.f,ks=Et,zs=Dr,As=O,Es=ps,Cs=Ss,Os=f,Ms=Function.prototype,Ls=Ms.apply,Ps=Ms.call,Ds="object"==typeof Reflect&&Reflect.apply||(Os?Ps.bind(Ls):function(){return Ps.apply(Ls,arguments)}),Fs=Ee.f,js=u,Rs=h,Is=Jr,Ns=ke,qs=String,Ks=function(e){if("Symbol"===Ns(e))throw TypeError("Cannot convert a Symbol value to a string");return qs(e)},Hs=h,$s=Et,Gs=Error,Ws=w("".replace),Ys=String(Gs("zxcasd").stack),Vs=/\n\s*at [^:]*:[^\n]*/,Xs=Vs.test(Ys),Zs=kt,Js=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Zs(1,7)),7!==e.stack)})),Qs=W,eo=z,to=Et,ro=He,io=Jr,no=ps,so=function(e,t,r){r in e||Fs(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},oo=function(e,t,r){var i,n;return Is&&js(i=t.constructor)&&i!==r&&Rs(n=i.prototype)&&n!==r.prototype&&Is(e,n),e},ao=function(e,t){return void 0===e?arguments.length<2?"":t:Ks(e)},uo=function(e,t){Hs(t)&&"cause"in t&&$s(e,"cause",t.cause)},co=function(e,t){if(Xs&&"string"==typeof e&&!Gs.prepareStackTrace)for(;t--;)e=Ws(e,Vs,"");return e},ho=Js,fo=s,lo=function(e,t){var r,i,n,s,o,a=e.target,u=e.global,c=e.stat;if(r=u?Ts:c?Ts[a]||As(a,{}):(Ts[a]||{}).prototype)for(i in t){if(s=t[i],n=e.dontCallGetSet?(o=_s(r,i))&&o.value:r[i],!Cs(u?i:a+(c?".":"#")+i,e.forced)&&void 0!==n){if(typeof s==typeof n)continue;Es(s,n)}(e.sham||n&&n.sham)&&ks(s,"sham",!0),zs(r,i,s,e)}},mo=Ds,po=function(e,t,r,i){var n="stackTraceLimit",s=i?2:1,o=e.split("."),a=o[o.length-1],u=Qs.apply(null,o);if(u){var c=u.prototype;if(eo(c,"cause")&&delete c.cause,!r)return u;var d=Qs("Error"),h=t((function(e,t){var r=ao(i?t:e,void 0),n=i?new u(e):new u;return void 0!==r&&to(n,"message",r),ho&&to(n,"stack",co(n.stack,2)),this&&ro(c,this)&&oo(n,this,h),arguments.length>s&&uo(n,arguments[s]),n}));h.prototype=c,"Error"!==a?io?io(h,d):no(h,d,{name:!0}):fo&&n in u&&(so(h,u,n),so(h,u,"prepareStackTrace")),no(h,u);try{c.name!==a&&to(c,"name",a),c.constructor=h}catch(f){}return h}},yo="WebAssembly",go=a.WebAssembly,wo=7!==Error("e",{cause:7}).cause,bo=function(e,t){var r={};r[e]=po(e,t,wo),lo({global:!0,constructor:!0,arity:1,forced:wo},r)},vo=function(e,t){if(go&&go[e]){var r={};r[e]=po("WebAssembly."+e,t,wo),lo({target:yo,stat:!0,constructor:!0,arity:1,forced:wo},r)}};bo("Error",(function(e){return function(t){return mo(e,this,arguments)}})),bo("EvalError",(function(e){return function(t){return mo(e,this,arguments)}})),bo("RangeError",(function(e){return function(t){return mo(e,this,arguments)}})),bo("ReferenceError",(function(e){return function(t){return mo(e,this,arguments)}})),bo("SyntaxError",(function(e){return function(t){return mo(e,this,arguments)}})),bo("TypeError",(function(e){return function(t){return mo(e,this,arguments)}})),bo("URIError",(function(e){return function(t){return mo(e,this,arguments)}})),vo("CompileError",(function(e){return function(t){return mo(e,this,arguments)}})),vo("LinkError",(function(e){return function(t){return mo(e,this,arguments)}})),vo("RuntimeError",(function(e){return function(t){return mo(e,this,arguments)}}));var xo,Uo,Bo=xn,So=Sn,To=function(e){if(!Bo(e))throw new TypeError("Cannot use null or undefined");return e},_o=Math.max,ko="function"==typeof(Uo=Object.assign)&&(Uo(xo={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),xo.foo+xo.bar+xo.trzy==="razdwatrzy")?Object.assign:function(e,t){var r,i,n,s=_o(arguments.length,2);for(e=Object(To(e)),n=function(i){try{e[i]=t[i]}catch(n){r||(r=n)}},i=1;i<s;++i)So(t=arguments[i]).forEach(n);if(void 0!==r)throw r;return e},zo=xn,Ao=Array.prototype.forEach,Eo=Object.create,Co=function(e,t){var r;for(r in e)t[r]=e[r]},Oo="razdwatrzy",Mo=String.prototype.indexOf,Lo="function"==typeof Oo.contains&&!0===Oo.contains("dwa")&&!1===Oo.contains("foo")?String.prototype.contains:function(e){return Mo.call(this,e,arguments[1])>-1},Po=ln,Do=function(e){return!!wn(e)&&!bn.test(vn.call(e))},Fo=ko,jo=function(e){var t=Eo(null);return Ao.call(arguments,(function(e){zo(e)&&Co(Object(e),t)})),t},Ro=Lo,Io=fn.exports=function(e,t){var r,i,n,s,o;return arguments.length<2||"string"!=typeof e?(s=t,t=e,e=null):s=arguments[2],Po(e)?(r=Ro.call(e,"c"),i=Ro.call(e,"e"),n=Ro.call(e,"w")):(r=n=!0,i=!1),o={value:t,configurable:r,enumerable:i,writable:n},s?Fo(jo(s),o):o};Io.gs=function(e,t,r){var i,n,s,o;return"string"!=typeof e?(s=r,r=t,t=e,e=null):s=arguments[3],Po(t)?Do(t)?Po(r)?Do(r)||(s=r,r=void 0):r=void 0:(s=t,t=r=void 0):t=void 0,Po(e)?(i=Ro.call(e,"c"),n=Ro.call(e,"e")):(i=!0,n=!1),o={get:t,set:r,configurable:i,enumerable:n},s?Fo(jo(s),o):o};var No,qo,Ko,Ho,$o,Go,Wo,Yo,Vo,Xo,Zo,Jo,Qo,ea,ta,ra,ia,na,sa=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e};No=hn,qo=hn.exports,Xo=fn.exports,Zo=sa,Jo=Function.prototype.apply,Qo=Function.prototype.call,ea=Object.create,ta=Object.defineProperty,ra=Object.defineProperties,ia=Object.prototype.hasOwnProperty,na={configurable:!0,enumerable:!1,writable:!0},Ho=function(e,t){var r,i;return Zo(t),i=this,Ko.call(this,e,r=function(){$o.call(i,e,r),Jo.call(t,this,arguments)}),r.__eeOnceListener__=t,this},Go=function(e){var t,r,i,n,s;if(ia.call(this,"__ee__")&&(n=this.__ee__[e]))if("object"==typeof n){for(r=arguments.length,s=new Array(r-1),t=1;t<r;++t)s[t-1]=arguments[t];for(n=n.slice(),t=0;i=n[t];++t)Jo.call(i,this,s)}else switch(arguments.length){case 1:Qo.call(n,this);break;case 2:Qo.call(n,this,arguments[1]);break;case 3:Qo.call(n,this,arguments[1],arguments[2]);break;default:for(r=arguments.length,s=new Array(r-1),t=1;t<r;++t)s[t-1]=arguments[t];Jo.call(n,this,s)}},Wo={on:Ko=function(e,t){var r;return Zo(t),ia.call(this,"__ee__")?r=this.__ee__:(r=na.value=ea(null),ta(this,"__ee__",na),na.value=null),r[e]?"object"==typeof r[e]?r[e].push(t):r[e]=[r[e],t]:r[e]=t,this},once:Ho,off:$o=function(e,t){var r,i,n,s;if(Zo(t),!ia.call(this,"__ee__"))return this;if(!(r=this.__ee__)[e])return this;if("object"==typeof(i=r[e]))for(s=0;n=i[s];++s)n!==t&&n.__eeOnceListener__!==t||(2===i.length?r[e]=i[s?0:1]:i.splice(s,1));else i!==t&&i.__eeOnceListener__!==t||delete r[e];return this},emit:Go},Yo={on:Xo(Ko),once:Xo(Ho),off:Xo($o),emit:Xo(Go)},Vo=ra({},Yo),No.exports=qo=function(e){return null==e?ea(Vo):ra(Object(e),Yo)},qo.methods=Wo;var oa=hn.exports,aa=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===ua}(e)}(e)};var ua="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function ca(e,t){return!1!==t.clone&&t.isMergeableObject(e)?ha((r=e,Array.isArray(r)?[]:{}),e,t):e;var r}function da(e,t,r){return e.concat(t).map((function(e){return ca(e,r)}))}function ha(e,t,r){(r=r||{}).arrayMerge=r.arrayMerge||da,r.isMergeableObject=r.isMergeableObject||aa;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):function(e,t,r){var i={};return r.isMergeableObject(e)&&Object.keys(e).forEach((function(t){i[t]=ca(e[t],r)})),Object.keys(t).forEach((function(n){r.isMergeableObject(t[n])&&e[n]?i[n]=ha(e[n],t[n],r):i[n]=ca(t[n],r)})),i}(e,t,r):ca(t,r)}ha.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,r){return ha(e,r,t)}),{})};var fa=ha;class la extends e.Errors{constructor(e,t,r={},i=""){r.version="3.0.0-next.3",super(e,t,r),this.url=i}}class ma{constructor(e){if(!(e instanceof ArrayBuffer))throw new la("parse","",{line:9,handle:"[Stream] constructor",msg:"data is valid"});this.buffer=e,this.dataview=new DataView(e),this.dataview.position=0}set position(e){this.dataview.position=e}get position(){return this.dataview.position}skip(e){const t=Math.floor(e/4),r=e%4;for(let i=0;i<t;i++)ma.readByte(this.dataview,4);r>0&&ma.readByte(this.dataview,r)}static readByte(e,t,r){let i;switch(t){case 1:i=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:i=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");i=e.getUint8(e.position)<<16,i|=e.getUint8(e.position+1)<<8,i|=e.getUint8(e.position+2);break;case 4:i=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new la("parse","",{line:73,handle:"[Stream] readByte",msg:"not supported for readBody 8"});i=e.getUint32(e.position)<<32,i|=e.getUint32(e.position+4);break;default:i=""}return e.position+=t,i}readUint8(){return ma.readByte(this.dataview,1)}readUint16(){return ma.readByte(this.dataview,2)}readUint32(){return ma.readByte(this.dataview,4)}readUint64(){return ma.readByte(this.dataview,8)}readInt8(){return ma.readByte(this.dataview,1,!0)}readInt16(){return ma.readByte(this.dataview,2,!0)}readInt32(){return ma.readByte(this.dataview,4,!0)}}class pa{constructor(){this.headSize=8,this.size=0,this.type="",this.subBox=[],this.start=-1}readHeader(e){if(this.start=e.position,this.size=e.readUint32(),this.type=String.fromCharCode(e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),1===this.size)this.size=e.readUint64();else if(0===this.size&&"mdat"!==this.type)throw new la("parse","",{line:19,handle:"[Box] readHeader",msg:"parse mp4 mdat box failed"});if("uuid"===this.type){const t=[];for(let r=0;r<16;r++)t.push(e.readUint8())}}readBody(e){const t=this.size-e.position+this.start,r=this.type;let i;this.data=e.buffer.slice(e.position,e.position+t),e.position+=this.data.byteLength,i=pa.containerBox.find((e=>e===r))?pa.containerParser:pa.boxParse[r],i&&i instanceof Function&&i.call(this)}read(e){this.readHeader(e),this.readBody(e)}static containerParser(){let e=new ma(this.data);const t=e.buffer.byteLength,r=this;for(;e.position<t;){const t=new pa;t.readHeader(e),r.subBox.push(t),t.readBody(e)}delete r.data,e=null}}t(pa,"boxParse",{}),pa.containerBox=["moov","trak","edts","mdia","minf","dinf","stbl","mvex","moof","traf","mfra"];var ya={};Object.defineProperty(ya,"__esModule",{value:!0}),ya.default=function(e){for(var t=0,r=arguments.length,i=Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];var s=!0,o=!1,a=void 0;try{for(var u,c=i[Symbol.iterator]();!(s=(u=c.next()).done);s=!0){var d=u.value;t+=d.length}}catch(b){o=!0,a=b}finally{try{!s&&c.return&&c.return()}finally{if(o)throw a}}var h=new e(t),f=0,l=!0,m=!1,p=void 0;try{for(var y,g=i[Symbol.iterator]();!(l=(y=g.next()).done);l=!0){var w=y.value;h.set(w,f),f+=w.length}}catch(b){m=!0,p=b}finally{try{!l&&g.return&&g.return()}finally{if(m)throw p}}return h};var ga=function(e){return e&&e.__esModule?e:{default:e}}(ya);var wa=ga.default;function ba(e){const t=new pa;let r,i;t.type=e.readUint8(),r=e.readUint8(),128===r?(t.extend=!0,e.skip(2),r=e.readUint8()+5,i=r-5):(i=r,r+=2),t.size=r;const n=[];for(let s=0;s<i;s++)n.push(Number(e.readUint8()).toString(16).padStart(2,"0"));return t.EScode=n,delete t.subBox,t}function va(e){const t=new pa;let r;return t.type=e.readUint8(),r=e.readUint8(),128===r?(t.extend=!0,e.skip(2),r=e.readUint8()+5):r+=2,t.size=r,t.typeID=e.readUint8(),t.streamUint=e.readUint8(),t.bufferSize=ma.readByte(e.dataview,3),t.maximum=e.readUint32(),t.average=e.readUint32(),t.subBox.push(ba(e)),t}function xa(e){const t=new pa;let r;return t.type=e.readUint8(),r=e.readUint8(),128===r?(t.extend=!0,e.skip(2),r=e.readUint8()+5):r+=2,t.size=r,t.SL=e.readUint8(),delete t.subBox,t}function Ua(e){const t=new pa;let r;return t.type=e.readUint8(),r=e.readUint8(),128===r?(t.extend=!0,e.skip(2),r=e.readUint8()+5):r+=2,t.size=r,t.esID=e.readUint16(),t.priority=e.readUint8(),t.subBox.push(va(e)),t.subBox.push(xa(e)),t}class Ba{constructor(){const e=new Date;e.setFullYear(1904),e.setMonth(0),e.setDate(1),e.setHours(0),e.setMinutes(0),e.setSeconds(0),this.time=e}setTime(e){return this.time.setTime(this.time.getTime()+1*e),this.time.toLocaleString()}}var Sa=Object.freeze(Object.defineProperty({__proto__:null,avc1:function(){let e=new ma(this.data);const t=this;e.skip(6),this.dataReferenceIndex=e.readUint16(),e.skip(16),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.skip(4),this.frameCount=e.readUint16(),e.skip(1);for(let r=0;r<31;r++)String.fromCharCode(e.readUint8());for(this.depth=e.readUint16(),e.skip(2);e.buffer.byteLength-e.position>=8;){const r=new pa;r.readHeader(e),t.subBox.push(r),r.readBody(e)}delete this.data,e=null},avcC:function(){let e=new ma(this.data);this.configVersion=e.readUint8(),this.profile=e.readUint8(),this.profileCompatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=1+(3&e.readUint8()),this.numOfSequenceParameterSets=31&e.readUint8();const t=e.readUint16();this.sequenceLength=t;const r=[];for(let a=0;a<t;a++)r.push(Number(e.readUint8()).toString(16));this.ppsCount=e.readUint8();const i=e.readUint16();this.ppsLength=i;const n=[];for(let a=0;a<i;a++)n.push(Number(e.readUint8()).toString(16));this.pps=n,this.sequence=r;const s=[],o=e.dataview.byteLength;for(;e.position<o;)s.push(e.readUint8());this.last=s,delete this.subBox,delete this.data,e=null},btrt:function(){let e=new ma(this.data);this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),delete this.subBox,delete this.data,e=null},co64:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.count=e.readUint32();const t=[];this.entries=t;for(let r=0,i=this.count;r<i;r++)t.push(e.readUint64());delete this.subBox,delete this.data,e=null},ctts:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.entryCount=e.readUint32();const t=[];this.entry=t;for(let r=0,i=this.entryCount;r<i;r++)t.push({count:e.readUint32(),offset:e.readUint32()});delete this.subBox,delete this.data,e=null},dref:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3);const t=e.readUint32();this.entryCount=t;const r=this;for(let i=0;i<t;i++){const t=new pa;r.subBox.push(t),t.read(e)}delete this.data,e=null},elst:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3);const t=[],r=e.readUint32();this.empty_duration=0,this.start_time=0;let i=0;this.entries=t;for(let n=0;n<r;n++){const r={};t.push(r),1===this.version?(r.segment_duration=e.readUint64(),r.media_time=e.readUint64()):(r.segment_duration=e.readUint32(),r.media_time=e.readInt32()),r.media_rate_integer=e.readInt16(),r.media_rate_fraction=e.readInt16(),0===n&&-1===r.media_time?(this.empty_duration=r.segment_duration,i=1):n===i&&r.media_time>=0&&(this.start_time=r.media_time)}delete this.subBox,delete this.data,e=null},esds:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3);const t=Ua(e);this.subBox.push(t),delete this.data,e=null},ftyp:function(){let e=new ma(this.data);this.major_brand=String.fromCharCode(e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),this.minor_version=e.readUint32();const t=[];for(let r=0,i=Math.floor((e.buffer.byteLength-8)/4);r<i;r++)t.push(String.fromCharCode(e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()));this.compatible_brands=t,e=null,delete this.subBox,delete this.data},hdlr:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),e.skip(4),this.handleType=`${String.fromCharCode(e.readUint8())}${String.fromCharCode(e.readUint8())}${String.fromCharCode(e.readUint8())}${String.fromCharCode(e.readUint8())}`,e.skip(12);const t=[];for(;e.position<this.size-8;)t.push(String.fromCharCode(e.readUint8()));this.name=t.join(""),delete this.subBox,delete this.data,e=null},iods:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3);const t=[],r=e.buffer.byteLength;for(;e.position<r;)t.push(e.readUint8());this.content=t,delete this.subBox,delete this.data,e=null},mdat:function(){delete this.subBox},mdhd:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),1===this.version?(this.create=e.readUint64(),this.modify=e.readUint64(),this.createTime=(new Ba).setTime(1e3*this.create),this.modifyTime=(new Ba).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.create=e.readUint32(),this.modify=e.readUint32(),this.createTime=(new Ba).setTime(1e3*this.create),this.modifyTime=(new Ba).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16(),e.readUint16(),delete this.subBox,delete this.data,e=null},mp4a:function(){let e=new ma(this.data);e.skip(6),this.dataReferenceIndex=e.readUint16(),e.skip(8),this.channelCount=e.readUint16(),this.sampleSize=e.readUint16(),e.skip(4),this.sampleRate=e.readUint32()>>16;const t=new pa;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null},MP4DecConfigDescrTag:va,MP4DecSpecificDescrTag:ba,MP4ESDescrTag:Ua,mvhd:function(){const e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.create=e.readUint32(),this.modify=e.readUint32(),this.createTime=(new Ba).setTime(1e3*this.create),this.modifyTime=(new Ba).setTime(1e3*this.modify),this.timeScale=e.readUint32(),this.duration=e.readUint32(),this.rate=e.readUint16()+"."+e.readUint16(),this.volume=e.readUint8()+"."+e.readUint8(),ma.readByte(e.dataview,8),ma.readByte(e.dataview,2);const t=[];for(let r=0;r<9;r++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,ma.readByte(e.dataview,24),this.nextTrackID=e.readUint32(),delete this.subBox,delete this.data},pasp:function(){let e=new ma(this.data);this.content=e.buffer.slice(0,this.size-8),delete this.subBox,delete this.data,e=null},SLConfigDescriptor:xa,smhd:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.balance=e.readInt8()+"."+e.readInt8(),delete this.subBox,delete this.data,e=null},stco:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.count=e.readUint32();const t=[];this.entries=t;for(let r=0,i=this.count;r<i;r++)t.push(e.readUint32());delete this.subBox,delete this.data,e=null},stsc:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.count=e.readUint32();const t=[];this.entries=t;for(let r=0,i=this.count;r<i;r++)t.push({first_chunk:e.readUint32(),samples_per_chunk:e.readUint32(),sample_desc_index:e.readUint32()});for(let r,i,n=0,s=this.count;n<s-1;n++)r=t[n],i=t[n-1],r.chunk_count=t[n+1].first_chunk-r.first_chunk,r.first_sample=0===n?1:i.first_sample+i.chunk_count*i.samples_per_chunk;if(1===this.count){const e=t[0];e.first_sample=1,e.chunk_count=0}else if(this.count>1){const e=t[this.count-1],r=t[this.count-2];e.first_sample=r.first_sample+r.chunk_count*r.samples_per_chunk,e.chunk_count=0}delete this.subBox,delete this.data,e=null},stsd:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.entryCount=e.readUint32();const t=new pa;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null},stss:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.count=e.readUint32();const t=[];this.entries=t;for(let r=0,i=this.count;r<i;r++)t.push(e.readUint32());delete this.subBox,delete this.data,e=null},stsz:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.sampleSize=e.readUint32(),this.count=e.readUint32();const t=[];this.entries=t;for(let r=0,i=this.count;r<i;r++)t.push(e.readUint32());delete this.subBox,delete this.data,e=null},stts:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3),this.count=e.readUint32();const t=[];for(let r=0,i=this.count;r<i;r++)t.push({sampleCount:e.readUint32(),sampleDuration:e.readUint32()});this.entry=t,delete this.subBox,delete this.data,e=null},tkhd:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=ma.readByte(e.dataview,3,0),1===this.version?(this.create=e.readUint64(),this.modify=e.readUint64(),this.createTime=(new Ba).setTime(1e3*this.create),this.modifyTime=(new Ba).setTime(1e3*this.modify),this.trackID=e.readUint32(),this.reserverd=e.readUint32(),this.duration=e.readUint64()):(this.create=e.readUint32(),this.modify=e.readUint32(),this.createTime=(new Ba).setTime(1e3*this.create),this.modifyTime=(new Ba).setTime(1e3*this.modify),this.trackID=e.readUint32(),this.reserverd=e.readUint32(),this.duration=e.readUint32()),e.readUint64(),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16();const t=[];for(let r=0;r<9;r++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,this.width=e.readUint16()+"."+e.readUint16(),this.height=e.readUint16()+"."+e.readUint16(),delete this.data,delete this.subBox,e=null},udta:function(){delete this.subBox},url:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=[e.readUint8(),e.readUint8(),e.readUint8()];const t=[],r=e.buffer.byteLength;for(;e.position<r;)t.push(e.readUint8());this.location=t,delete this.subBox,delete this.data,e=null},vmhd:function(){let e=new ma(this.data);this.version=e.readUint8(),this.flag=[e.readUint8(),e.readUint8(),e.readUint8()],this.graphicsmode=e.readUint16(),this.opcolor=[e.readUint16(),e.readUint16(),e.readUint16()],delete this.subBox,delete this.data,e=null}},Symbol.toStringTag,{value:"Module"}));pa.boxParse=Sa;class Ta{constructor(e){this.buffer=null,this.boxes=[],this.nextBox=null,this.start=0;const t=this;t.buffer?wa(Uint8Array,t.buffer,e):t.buffer=e;const r=e.byteLength;e.position=0;const i=new ma(e);for(;r-i.position>=8;){const e=new pa;if(e.readHeader(i),e.size-8<=r-i.position)e.readBody(i),t.boxes.push(e);else{if("mdat"!==e.type){t.nextBox=e,i.position-=8;break}e.readBody(i),t.boxes.push(e)}}t.buffer=new Uint8Array(t.buffer.slice(i.position))}}class _a{constructor(){this.buffer=new Uint8Array(0)}write(...e){const t=this;e.forEach((e=>{e?t.buffer=wa(Uint8Array,t.buffer,e):window.console.error(e)}))}static writeUint32(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}var ka=Ct.exports,za=Ee,Aa=Ie,Ea=s,Ca=function(e,t,r){return r.get&&ka(r.get,t,{getter:!0}),r.set&&ka(r.set,t,{setter:!0}),za.f(e,t,r)},Oa=function(){var e=Aa(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Ma=n,La=a.RegExp,Pa=La.prototype;Ea&&Ma((function(){var e=!0;try{La(".","d")}catch(a){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",n=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},s={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in e&&(s.hasIndices="d"),s)n(o,s[o]);return Object.getOwnPropertyDescriptor(Pa,"flags").get.call(t)!==i||r!==i}))&&Ca(Pa,"flags",{configurable:!0,get:Oa});const Da=Math.pow(2,32)-1;class Fa{static type(e){return new Uint8Array([e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)])}static size(e){return _a.writeUint32(e)}static extension(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}static ftyp(){const e=new _a;return e.write(Fa.size(24),Fa.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),e.buffer}static moov(e){const t=new _a;let r=8;const i=Fa.mvhd(e.duration,e.timeScale),n=Fa.videoTrak(e);let s;const o=Fa.videoOnly||!e.audioConfig;o||(s=Fa.audioTrak(e));const a=Fa.mvex(e.duration,e.timeScale);return(o?[i,n,a]:[i,n,s,a]).forEach((e=>{r+=e.byteLength})),o?t.write(Fa.size(r),Fa.type("moov"),i,n,a):t.write(Fa.size(r),Fa.type("moov"),i,n,s,a),t.buffer}static mvhd(e,t){const r=new _a;e*=t;const i=Math.floor(e/(Da+1)),n=Math.floor(e%(Da+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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 r.write(Fa.size(8+s.length),Fa.type("mvhd"),new Uint8Array(s)),r.buffer}static videoTrak(e){const t=new _a;let r=8;const i=Fa.tkhd({id:1,duration:e.videoDuration,timescale:e.videoTimeScale,width:e.width,height:e.height,type:"video"}),n=Fa.mdia({type:"video",timescale:e.videoTimeScale,duration:e.videoDuration,sps:e.sps,pps:e.pps,pixelRatio:e.pixelRatio,width:e.width,height:e.height});return[i,n].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("trak"),i,n),t.buffer}static audioTrak(e){const t=new _a;let r=8;const i=Fa.tkhd({id:2,duration:e.audioDuration,timescale:e.audioTimeScale,width:0,height:0,type:"audio"}),n=Fa.mdia({type:"audio",timescale:e.audioTimeScale,duration:e.audioDuration,channelCount:e.channelCount,samplerate:e.sampleRate,audioConfig:e.audioConfig});return[i,n].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("trak"),i,n),t.buffer}static tkhd(e){const t=new _a,r=e.id,i=e.duration*e.timeScale,n=e.width,s=e.height,o=e.type,a=Math.floor(i/(Da+1)),u=Math.floor(i%(Da+1)),c=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,u>>24,u>>16&255,u>>8&255,255&u,0,0,0,0,0,0,0,0,0,0,0,"video"===o?1:0,"audio"===o?1: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,n>>8&255,255&n,0,0,s>>8&255,255&s,0,0]);return t.write(Fa.size(8+c.byteLength),Fa.type("tkhd"),c),t.buffer}static edts(e){const t=new _a,r=e.duration,i=e.mediaTime;return t.write(Fa.size(36),Fa.type("edts")),t.write(Fa.size(28),Fa.type("elst")),t.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),t.buffer}static mdia(e){const t=new _a;let r=8;const i=Fa.mdhd(e.timescale,e.duration),n=Fa.hdlr(e.type),s=Fa.minf(e);return[i,n,s].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("mdia"),i,n,s),t.buffer}static mdhd(e,t=0){const r=new _a;t*=e;const i=Math.floor(t/(Da+1)),n=Math.floor(t%(Da+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]);return r.write(Fa.size(12+s.byteLength),Fa.type("mdhd"),Fa.extension(1,0),s),r.buffer}static hdlr(e){const t=new _a,r=[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];return"audio"===e&&(r.splice(8,4,115,111,117,110),r.splice(24,13,83,111,117,110,100,72,97,110,100,108,101,114,0)),t.write(Fa.size(8+r.length),Fa.type("hdlr"),new Uint8Array(r)),t.buffer}static minf(e){const t=new _a;let r=8;const i="video"===e.type?Fa.vmhd():Fa.smhd(),n=Fa.dinf(),s=Fa.stbl(e);return[i,n,s].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("minf"),i,n,s),t.buffer}static vmhd(){const e=new _a;return e.write(Fa.size(20),Fa.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),e.buffer}static smhd(){const e=new _a;return e.write(Fa.size(16),Fa.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),e.buffer}static dinf(){const e=new _a;return e.write(Fa.size(36),Fa.type("dinf"),Fa.size(28),Fa.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),e.buffer}static stbl(e){const t=new _a;let r=8;const i=Fa.stsd(e),n=Fa.stts(),s=Fa.stsc(),o=Fa.stsz(),a=Fa.stco();return[i,n,s,o,a].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("stbl"),i,n,s,o,a),t.buffer}static stsd(e){const t=new _a;let r;return r="audio"===e.type?Fa.mp4a(e):Fa.avc1(e),t.write(Fa.size(16+r.byteLength),Fa.type("stsd"),Fa.extension(0,0),new Uint8Array([0,0,0,1]),r),t.buffer}static mp4a(e){const t=new _a,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,e.samplerate>>8&255,255&e.samplerate,0,0]),i=Fa.esds(e.audioConfig);return t.write(Fa.size(8+r.byteLength+i.byteLength),Fa.type("mp4a"),r,i),t.buffer}static esds(e=[43,146,8,0]){const t=e.length,r=new _a,i=new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return r.write(Fa.size(8+i.byteLength),Fa.type("esds"),i),r.buffer}static avc1(e){const t=new _a,r=e.sps,i=e.pps,n=e.width,s=e.height,o=e.pixelRatio[0],a=e.pixelRatio[1],u=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>8&255,255&n,s>>8&255,255&s,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([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([o>>24,o>>16&255,o>>8&255,255&o,a>>24,a>>16&255,a>>8&255,255&a]);return t.write(Fa.size(40+c.byteLength+u.byteLength+d.byteLength),Fa.type("avc1"),c,Fa.size(8+u.byteLength),Fa.type("avcC"),u,Fa.size(20),Fa.type("btrt"),d,Fa.size(16),Fa.type("pasp"),h),t.buffer}static stts(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Fa.size(16),Fa.type("stts"),t),e.buffer}static stsc(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Fa.size(16),Fa.type("stsc"),t),e.buffer}static stco(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Fa.size(16),Fa.type("stco"),t),e.buffer}static stsz(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return e.write(Fa.size(20),Fa.type("stsz"),t),e.buffer}static mvex(e,t){const r=new _a,i=_a.writeUint32(e*t);return r.write(Fa.size(88),Fa.type("mvex"),Fa.size(16),Fa.type("mehd"),Fa.extension(0,0),i,Fa.trex(1),Fa.trex(2)),r.buffer}static trex(e){const t=new _a,r=new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return t.write(Fa.size(8+r.byteLength),Fa.type("trex"),r),t.buffer}static moof(e){const t=new _a;let r=8;const i=Fa.mfhd(),n=Fa.traf(e);return[i,n].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("moof"),i,n),t.buffer}static mfhd(){const e=new _a,t=_a.writeUint32(Fa.sequence);return Fa.sequence+=1,e.write(Fa.size(16),Fa.type("mfhd"),Fa.extension(0,0),t),e.buffer}static traf(e){const t=new _a;let r=8;const i=Fa.tfhd(e.id),n=Fa.tfdt(e.time),s=Fa.sdtp(e),o=Fa.trun(e,s.byteLength);return[i,n,s,o].forEach((e=>{r+=e.byteLength})),t.write(Fa.size(r),Fa.type("traf"),i,n,s,o),t.buffer}static tfhd(e){const t=new _a,r=_a.writeUint32(e);return t.write(Fa.size(16),Fa.type("tfhd"),Fa.extension(0,0),r),t.buffer}static tfdt(e){const t=new _a,r=Math.floor(e/(Da+1)),i=Math.floor(e%(Da+1));return t.write(Fa.size(20),Fa.type("tfdt"),Fa.extension(1,0),_a.writeUint32(r),_a.writeUint32(i)),t.buffer}static trun(e,t){const r=e.id,i=1===r?16:12,n=new _a,s=_a.writeUint32(e.samples.length),o=_a.writeUint32(96+i*e.samples.length+t);return n.write(Fa.size(20+i*e.samples.length),Fa.type("trun"),Fa.extension(0,e.flags),s,o),e.samples.forEach(((e,t)=>{n.write(_a.writeUint32(e.duration)),n.write(_a.writeUint32(e.size)),1===r?(n.write(_a.writeUint32(e.key?33554432:16842752)),n.write(_a.writeUint32(e.offset))):n.write(_a.writeUint32(16777216))})),n.buffer}static sdtp(e){const t=new _a;return t.write(Fa.size(12+e.samples.length),Fa.type("sdtp"),Fa.extension(0,0)),e.samples.forEach((r=>{t.write(new Uint8Array(1===e.id?[r.key?32:16]:[16]))})),t.buffer}static mdat(e){const t=new _a;let r=8;return e.samples.forEach((e=>{r+=e.size})),t.write(Fa.size(r),Fa.type("mdat")),e.samples.forEach((e=>{t.write(e.buffer)})),t.buffer}}Fa.sequence=1;const ja={};ja.findBox=function(e,t,r=[]){if(e.type!==t){if(e&&e.subBox){const i=e.subBox.filter((e=>e.type===t));i.length?i.forEach((e=>r.push(e))):e.subBox.forEach((e=>ja.findBox(e,t,r)))}}else r.push(e);return(r=[].concat(r)).length>1?r:r[0]},ja.padStart=function(e,t,r){const i=String(r),n=t>>0;let s=Math.ceil(n/i.length);const o=[],a=String(e);for(;s--;)o.push(i);return o.join("").substring(0,n-a.length)+a},ja.toHex=function(...e){const t=[];return e.forEach((e=>{t.push(ja.padStart(Number(e).toString(16),2,0))})),t},ja.sum=function(...e){let t=0;return e.forEach((e=>{t+=e})),t},ja.stscOffset=function(e,t){let r,i="";const n=e.entries.filter((e=>e.first_sample<=t&&t<e.first_sample+e.chunk_count*e.samples_per_chunk))[0];if(n){const e=Math.floor((t-n.first_sample)/n.samples_per_chunk),s=n.first_sample+e*n.samples_per_chunk;return r=n.first_chunk+e,i=[s,t],{chunk_index:r,samples_offset:i}}{const r=e.entries.pop();e.entries.push(r);const i=Math.floor((t-r.first_sample)/r.samples_per_chunk);return{chunk_index:r.first_chunk+i,samples_offset:[r.first_sample+r.samples_per_chunk*i,t]}}},ja.seekSampleOffset=function(e,t,r,i,n){const s=ja.stscOffset(e,i+1),o=t.entries[s.chunk_index-1]+ja.sum.apply(null,r.entries.slice(s.samples_offset[0]-1,s.samples_offset[1]-1))-n;if(void 0===o)throw new Error(`result=${o},stco.length=${t.entries.length},sum=${ja.sum.apply(null,r.entries.slice(0,i))}`);if(o<0)throw new Error(`result=${o},stco.length=${t.entries.length},sum=${ja.sum.apply(null,r.entries.slice(0,i))}`);return o},ja.seekSampleTime=function(e,t,r,i=0){let n,s,o=0,a=0,u=0;if(e.entry.every((e=>(s=e.sampleDuration,r<o+e.sampleCount?(n=a+(r-o)*e.sampleDuration,!1):(o+=e.sampleCount,a+=e.sampleCount*s,!0)))),t){let e=0;t.entry.every((t=>(e+=t.count,!(r<e)||(u=t.offset,!1))))}return n||(n=a+(r-o)*s),n-=i,{time:n,duration:s,offset:u}},ja.seekOrderSampleByTime=function(e,t,r){let i,n=0,s=0,o=0;return e.every(((e,a)=>(i=e.sampleCount*e.sampleDuration/t,r<=n+i?(s=o+Math.ceil((r-n)*t/e.sampleDuration),n+=Math.ceil((r-n)*t/e.sampleDuration)*e.sampleDuration/t,!1):(n+=i,o+=e.sampleCount,!0)))),{order:s,startTime:n}},ja.sampleCount=function(e){let t=0;return e.forEach(((e,r)=>{t+=e.sampleCount})),t},ja.seekTrakDuration=function(e,t){const r=ja.findBox(e,"stts");let i=0;return r.entry.forEach((e=>{i+=e.sampleCount*e.sampleDuration})),Number(i/t).toFixed(4)};class Ra{constructor(e,t,r={},i,n){oa(this),this.url=e,this.range=t,this.withCredentials=i,this.id=t.join("-"),this.on=!1;const s=new window.XMLHttpRequest;s.target=this,s.responseType="arraybuffer",s.withCredentials=this.withCredentials||!1,s.open("get",e),s.setRequestHeader("Range",`bytes=${t[0]}-${t[1]}`),Object.keys(r).map((e=>{s.setRequestHeader(e,r[e])})),s.onload=function(){const t=function(e){const t={};if(e instanceof window.XMLHttpRequest)try{e.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((function(e){const r=e.split(": "),i=r.shift(),n=r.join(": ");t[i]=n}))}catch(r){}return t}(s);s.target.remove(),200===s.status||206===s.status?n&&n instanceof Function&&n({response:s.response,headers:t,status:s.status}):s.target.emit("error",new la("network","",{status:s.status,headers:t,line:25,handle:"[Task] constructor",msg:s.status,url:e}))},s.onerror=function(t){s.target.emit("error",new la("network","",{line:25,handle:"[Task] constructor",msg:t.message,url:e})),s.target.remove()},s.onabort=function(){s.target.remove()},this.xhr=s,Ra.queue.push(this),this.update()}cancel(){this.xhr.abort()}remove(){Ra.queue.filter(((e,t)=>e.url===this.url&&e.id===this.id&&(Ra.queue.splice(t,1),!0))),this.update()}update(){const e=Ra.queue,t=e.filter((e=>e.on)),r=e.filter((e=>!e.on)),i=Ra.limit-t.length;r.forEach(((e,t)=>{t<i&&e.run()}))}run(){1===this.xhr.readyState?(this.on=!0,this.xhr.send()):this.remove()}static clear(){Ra.queue.forEach((e=>{e.on&&e.cancel()})),Ra.queue.length=0}}Ra.queue=[],Ra.limit=2;class Ia{constructor(e,t,r=Math.pow(25,4)){oa(this),this.url=e,this.options=t,this.withCredentials=t.withCredentials,Fa.videoOnly=this.videoOnly=t.videoOnly||!1,this.CHUNK_SIZE=r,this.init(e),this.once("moovReady",this.moovParse.bind(this)),this.cache=new _a,this.bufferCache=new Set,this.timeRage=[],this.canDownload=!0,this.bufferLoaded=new Uint8Array(0),this._boxes=[],this.count=0}getData(e=0,t=e+this.CHUNK_SIZE){const r=this;return new Promise(((i,n)=>{new Ra(this.url,[e,t],this.options.headers||{},this.withCredentials,i,n).once("error",(e=>{r.emit("error",e)}))}))}moovParse(){const e=this,t=this.moovBox,r=ja.findBox(t,"mvhd");let i,n,s,o,a,u,c,d,h,f,l,m,p,y,g=ja.findBox(t,"trak");g=[].concat(g),g.forEach((t=>{const g=ja.findBox(t,"hdlr"),w=ja.findBox(t,"mdhd");if(!g||!w)return void e.emit("error",new la("parse","",{line:72,handle:"[MP4] moovParse",url:e.url}));if("vide"===g.handleType&&e.videoOnly){const e=ja.findBox(t,"elst");t.empty_duration=0,e.empty_duration&&(t.empty_duration=e.empty_duration*w.timescale/r.timeScale),t.time_offset=e.start_time-t.empty_duration}const b=ja.findBox(t,"stsd").subBox[0];if("vide"===g.handleType){const e=ja.findBox(t,"avcC"),r=ja.findBox(t,"tkhd");i=t,a=w.timescale,e?(s=`${b.type}.`+ja.toHex(e.profile,e.profileCompatibility,e.AVCLevelIndication).join(""),c=e.sequence&&e.sequence.map((e=>Number(`0x${e}`))),d=e.pps&&e.pps.map((e=>Number(`0x${e}`))),h=e.profile):s=`${b.type}`,r&&(f=r.width,l=r.height)}if("soun"===g.handleType){n=t;const e=ja.findBox(t,"esds"),r=ja.findBox(t,"mp4a"),i=ja.findBox(t,5);u=w.timescale,o=e?`${b.type}.`+ja.toHex(e.subBox[0].subBox[0].typeID)+`.${e.subBox[0].subBox[0].subBox[0].type}`:`${b.type}`,i&&i.EScode&&(y=i.EScode.map((e=>Number(`0x${e}`)))),r&&(m=r.channelCount,p=r.sampleRate)}})),this.videoTrak=fa({},i),n||(this.videoOnly=!0),this.videoOnly||(this.audioTrak=fa({},n));const w=this._boxes.find((e=>"mdat"===e.type)),b=ja.seekTrakDuration(i,a);let v;this.videoOnly||(v=ja.seekTrakDuration(n,u)),this.mdatStart=w.start;const x=this.videoKeyFrames,U=x.length-1;x.forEach(((e,t)=>{t<U?this.timeRage.push([e.time.time/a,x[t+1].time.time/a]):this.timeRage.push([e.time.time/a,-1])})),this.meta={videoCodec:s,createTime:r.createTime,modifyTime:r.modifyTime,duration:b,timeScale:r.timeScale,videoDuration:b,videoTimeScale:a,endTime:b,sps:c,pps:d,width:f,height:l,profile:h,pixelRatio:[1,1],channelCount:m,sampleRate:p,audioConfig:y},this.videoOnly||(this.meta.audioCodec=o,this.meta.audioDuration=v,this.meta.audioTimeScale=u,this.meta.duration=r.duration/r.timeScale,this.meta.endTime=Math.min(b,v))}init(){this.getMetaInfo()}checkMoovReady(){const e=this._boxes.filter((e=>"moov"===e.type));e.length?(this.moovBox=e[0],this.emit("moovReady",e)):this.emit("error",new la("parse","",{line:203,handle:"[MP4] init",msg:"not find moov box"}))}getMetaInfo(e=0,t=0+this.CHUNK_SIZE){let r=e;this.getData(e,t).then((e=>{const i=e.response;r+=i.byteLength;let n=null;this.bufferLoaded=wa(Uint8Array,this.bufferLoaded,new Uint8Array(i));try{let e=0;this._boxes.length>0&&(e=this._boxes[this._boxes.length-1].size+this._boxes[this._boxes.length-1].start),n=new Ta(this.bufferLoaded.buffer.slice(e,t)),this._boxes=this._boxes.concat(n.boxes);let i=!1,s=!1,o=null;if(this._boxes.map((e=>{"moov"===e.type&&(i=!0),"mdat"===e.type&&(o=e,s=!0)})),i&&s)this.checkMoovReady();else{const e=n.nextBox;e&&"moov"===e.type?this.getMetaInfo(r,r+e.size+28):s&&!e?(r=o.start+o.size,this.getData(r,"").then((e=>{n=new Ta(e.response),this._boxes=this._boxes.concat(n.boxes),this.checkMoovReady()}))):this.getMetaInfo(r,r+this.CHUNK_SIZE)}}catch(s){throw this.emit("error",s.type?s:new la("parse","",{line:176,handle:"[MP4] init",msg:s.message})),s}})).catch((e=>{throw this.emit("error",new la("network","",{line:231,handle:"[MP4] getData",msg:"getData failed"})),e}))}getSamplesByOrders(e="video",t,r){const i="video"===e?this.videoTrak:this.audioTrak,n=ja.findBox(i,"stsc"),s=ja.findBox(i,"stsz"),o=ja.findBox(i,"stts"),a=ja.findBox(i,"stco"),u=ja.findBox(i,"ctts"),c=this.mdatStart;let d=[];if(r=void 0!==r?r:s.entries.length,t instanceof Array)t.forEach(((e,t)=>{d.push({idx:e,size:s.entries[e],time:ja.seekSampleTime(o,u,e,i.time_offset),offset:ja.seekSampleOffset(n,a,s,e,c)})}));else if(0!==r)for(let h=t;h<r;h++)d.push({idx:h,size:s.entries[h],time:ja.seekSampleTime(o,u,h,i.time_offset),offset:ja.seekSampleOffset(n,a,s,h,c)});else d={idx:t,size:s.entries[t],time:ja.seekSampleTime(o,u,t,i.time_offset),offset:ja.seekSampleOffset(n,a,s,t,c)};return d}get videoKeyFrames(){if(this._videoFrames)return this._videoFrames;const e=this.videoTrak,t=ja.findBox(e,"stss"),r=this.getSamplesByOrders("video",t.entries.map((e=>e-1)));return this._videoFrames=r,r}get audioKeyFrames(){if(this._audioFrames)return this._audioFrames;const e=ja.findBox(this.videoTrak,"mdhd").timescale,t=ja.findBox(this.audioTrak,"mdhd").timescale,r=ja.findBox(this.audioTrak,"stts").entry;let i=[];return i=this.videoKeyFrames.map((i=>ja.seekOrderSampleByTime(r,t,i.time.time/e))),this._audioFrames=i,this._audioFrames}packMeta(){if(!this.meta)return;const e=new _a;return e.write(Fa.ftyp()),e.write(Fa.moov(this.meta)),e.buffer}seek(e){const t=e*this.meta.videoTimeScale;let r;const i=this.videoKeyFrames;let n;return this.videoOnly||(n=this.audioKeyFrames),i.every(((e,n)=>{const s=e.time.time,o=i[n+1]?i[n+1].time.time:Number.MAX_SAFE_INTEGER;return!(s<=t&&t<o)||(r=n,!1)})),this.videoOnly||n.every(((e,i)=>{const s=e.startTime,o=n[i+1]?n[i+1].startTime:Number.MAX_SAFE_INTEGER;return!(s<=t&&t<o)||(r=Math.min(i,r),!1)})),this.bufferCache.has(r)?Promise.resolve(null):this.loadFragment(r)}loadFragment(e){let t,r;const i=this.videoKeyFrames[e];let n;if(t=i.offset,this.videoOnly||(n=this.getSamplesByOrders("audio",this.audioKeyFrames[e].order,0),t=Math.min(i.offset,n.offset)),e<this.videoKeyFrames.length-1){const t=this.videoKeyFrames[e+1];let i;r=t.offset,this.videoOnly||(i=this.getSamplesByOrders("audio",this.audioKeyFrames[e+1].order,0),r=Math.max(t.offset,i.offset))}const s=this;if(window.isNaN(t)||void 0!==r&&window.isNaN(r))return s.emit("error",new la("parse","",{line:366,handle:"[MP4] loadFragment",url:s.url})),!1;const o=t+s.mdatStart;return r=r?s.mdatStart+r:"",this.bufferCache.has(e)?Promise.resolve(null):r&&r<=this.bufferLoaded.byteLength?this.createFragment(new Uint8Array(this.bufferLoaded.buffer.slice(o,r)),t,e):this.getData(o,r).then((r=>this.createFragment(new Uint8Array(r.response),t,e)))}addFragment(e){const t=new _a;return t.write(Fa.moof(e)),t.write(Fa.mdat(e)),t.buffer}createFragment(e,t,r){const i=this,n=[];this.bufferCache.add(r);{const s=i.videoKeyFrames.map((e=>e.idx)),o=i.getSamplesByOrders("video",s[r],s[r+1]),a=o.map(((r,i)=>({size:r.size,duration:r.time.duration,offset:r.time.offset,buffer:new Uint8Array(e.slice(r.offset-t,r.offset-t+r.size)),key:0===i})));n.push(this.addFragment({id:1,time:o[0].time.time,firstFlags:33554432,flags:3841,samples:a}))}if(!this.videoOnly){const i=this.getSamplesByOrders("audio",this.audioKeyFrames[r].order,this.audioKeyFrames[r+1]?this.audioKeyFrames[r+1].order:void 0),s=i.map(((r,i)=>({size:r.size,duration:r.time.duration,offset:r.time.offset,buffer:new Uint8Array(e.slice(r.offset-t,r.offset-t+r.size)),key:0===i})));n.push(this.addFragment({id:2,time:i[0].time.time,firstFlags:0,flags:1793,samples:s}))}let s=0;n.every((e=>(s+=e.byteLength,!0)));const o=new Uint8Array(s);let a=0;return n.every((e=>(o.set(e,a),a+=e.byteLength,!0))),Promise.resolve(o)}download(){}cut(e,t){this.bufferCache.clear();const r=e*this.meta.videoTimeScale,i=t*this.meta.videoTimeScale;let n,s;const o=this.videoKeyFrames,a=this.audioKeyFrames;return o.every(((e,t)=>{const a=e.time.time,u=o[t+1]?o[t+1].time.time:Number.MAX_SAFE_INTEGER;return a<=r&&r<u?(n=t,!0):!(a<=i&&i<u)||(s=t,!1)})),a.every(((e,t)=>{const o=e.startTime,u=a[t+1]?a[t+1].startTime:Number.MAX_SAFE_INTEGER;return o<=r&&r<u?(n=Math.min(t,n),!0):!(o<=i&&i<u)||(s=Math.min(t,s),!1)})),s||(s=o.length),this.loadFragmentForCut(n,s)}loadFragmentForCut(e,t){const r=this.videoKeyFrames[e],i=this.getSamplesByOrders("audio",this.audioKeyFrames[e].order,0),n=Math.min(r.offset,i.offset),s=this.videoKeyFrames[t],o=this.getSamplesByOrders("audio",this.audioKeyFrames[t].order,0),a=Math.max(s.offset,o.offset),u=this;return window.isNaN(n)||void 0!==a&&window.isNaN(a)?(u.emit("error",new la("parse","",{line:366,handle:"[MP4] loadFragment",url:u.url})),!1):this.getData(n+u.mdatStart,a?u.mdatStart+a:"").then((r=>u.createFragmentForCut(new Uint8Array(r.response),n,e,a,t)))}createFragmentForCut(e,t,r,i,n){const s=this,o=[];{const i=s.videoKeyFrames.map((e=>e.idx)),a=s.getSamplesByOrders("video",i[r],i[n]).map(((r,i)=>({size:r.size,duration:r.time.duration,offset:r.time.offset,buffer:new Uint8Array(e.slice(r.offset-t,r.offset-t+r.size)),key:0===i})));o.push(this.addFragment({id:1,time:0,firstFlags:33554432,flags:3841,samples:a}))}const a=this.getSamplesByOrders("audio",this.audioKeyFrames[r].order,this.audioKeyFrames[n]?this.audioKeyFrames[n].order:void 0).map(((r,i)=>({size:r.size,duration:r.time.duration,offset:r.time.offset,buffer:new Uint8Array(e.slice(r.offset-t,r.offset-t+r.size)),key:0===i})));o.push(this.addFragment({id:2,time:0,firstFlags:0,flags:1793,samples:a}));let u=0;o.every((e=>(u+=e.byteLength,!0)));const c=new Uint8Array(u);let d=0;return o.every((e=>(c.set(e,d),d+=e.byteLength,!0))),Promise.resolve(c)}clear(){this.cache=new _a,this.bufferCache.clear()}}class Na{constructor(e='video/mp4; codecs="avc1.64001E, mp4a.40.5"'){const t=this;oa(this),this.codecs=e,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.updating=!1,this.mediaSource.addEventListener("sourceopen",(function(){0===t.mediaSource.sourceBuffers.length&&(t.sourceBuffer=t.mediaSource.addSourceBuffer(t.codecs),t.sourceBuffer.addEventListener("error",(function(e){t.emit("error",new la("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:e.message}))})),t.sourceBuffer.addEventListener("updateend",(function(e){t.emit("updateend");const r=t.queue.shift();r&&t.sourceBuffer&&!t.sourceBuffer.updating&&"open"===t.state&&t.sourceBuffer.appendBuffer(r)})),t.emit("sourceopen"))})),this.mediaSource.addEventListener("sourceclose",(function(){t.emit("sourceclose")}))}get state(){return this.mediaSource.readyState}get duration(){return this.mediaSource.duration}set duration(e){this.mediaSource.duration=e}appendBuffer(e){const t=this.sourceBuffer;return t&&!t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}removeBuffer(e,t){this.sourceBuffer.remove(e,t)}clearBuffer(){if(this.sourceBuffer){const e=this.sourceBuffer.buffered;for(let t=0;t<e.length;t++)this.sourceBuffer.remove(e.start(t),e.end(t))}}endOfStream(){"open"===this.state&&this.mediaSource.endOfStream()}static isSupported(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}class qa extends e.BasePlugin{static get pluginName(){return"mp4Plugin"}static get defaultConfig(){return{withCredentials:!0,videoOnly:!1,headers:{},reqTimeLength:5,preloadTime:60,maxCache:180,chunkSize:Math.pow(25,3),mp4ProgressTimer:500}}static get version(){return"3.0.0-next.3"}constructor(r){super(r),t(this,"onUrlChange",(e=>{const{player:t}=this;this.stopBuffer(),this.initMp4(e).then((e=>{t.video.src=this.mse.url,t.play()})).catch((e=>{console.error(e)}))})),t(this,"onWaiting",(()=>{})),t(this,"onOnceCanplay",(()=>{const{player:t}=this;if("safari"===e.Sniffer.browser&&t.buffered.length){const e=t.buffered.start(0);t.currentTime=e+.1}})),t(this,"onSeeking",(()=>{const{player:e}=this,t=e.buffered;let r=!1;const i=e.video.currentTime;if(Ra.clear(),e.ended&&this.mp4.clear(),this.progressTimer||this.startBuffer(),t.length){for(let e=0,n=t.length;e<n;e++)if(i>=t.start(e)&&i<=t.end(e)){r=!0;break}r||this.loadData(0,i)}else this.loadData(0,i)})),t(this,"onEnded",(e=>{this.stopBuffer(),this.mse.clearBuffer(),this.mp4.clear()})),this.loadData=this.loadData.bind(this),this.destroy=this.destroy.bind(this),this.waiterTimer=null,this.progressTimer=null,this.timer=null,this.timer1=null,this.mp4=null,this.mse=null,this.rmbFlag=0}afterCreate(){window.__mp4player=this;try{e.BasePlugin.defineGetterOrSetter(this.player,{__url:{get:()=>{try{return this.mse?this.mse.url:this.config.url}catch(e){return null}}}})}catch(t){}this.attachEvents()}beforePlayerInit(){return this.initMp4()}attachEvents(){this.on(e.Events.SEEKING,this.onSeeking),this.on(e.Events.WAITING,this.onWaiting),this.on(e.Events.ENDED,this.onEnded),this.on(e.Events.URL_CHANGE,this.onUrlChange)}detachEvents(){this.off(e.Events.SEEKING,this.onSeeking),this.off(e.Events.WAITING,this.onWaiting),this.off(e.Events.URL_CHANGE,this.onUrlChange),this.stopBuffer()}initMp4(t){const{player:r,config:i}=this,n=new Ia(t||r.config.url,this.config,this.config.chunkSize);return n.reqTimeLength=i.reqTimeLength,new Promise(((t,r)=>{n.once("moovReady",(()=>{const r=!n.meta.audioConfig||this.config.videoOnly?'video/mp4; codecs="avc1.64001E"':'video/mp4; codecs="avc1.64001E, mp4a.40.5"',i=new Na(r);i.on("sourceopen",(()=>{i.appendBuffer(n.packMeta()),i.once("updateend",this.loadData)})),this.mse=i,this.mp4=n,this.once(e.Events.CANPLAY,this.onOnceCanplay),this.startBuffer(),t(n)})),n.on("error",(r=>{console.log("mp4 error",r),this.emit(e.Events.ERROR,r),t()}))})).catch((e=>{throw console.error("[initMp4]error",e),e}))}cut(t=0,r){const{player:i}=this,n=new _a,s=new Ia(i.config.url,this.config,i.config.withCredentials);return new Promise(((i,o)=>{s.once("moovReady",(()=>{(!r||r<=t)&&(r=t+15),r>s.meta.duration&&(t=s.meta.duration-(r-t),r=s.meta.duration),s.cut(t,r).then((o=>{if(o){const a=e.Util.deepCopy({duration:r-t,audioDuration:r-t,endTime:r-t},s.meta);a.duration=r-t,a.videoDuration=r-t,a.audioDuration=r-t,a.endTime=r-t,n.write(s.packMeta(a),o),i(new window.Blob([n.buffer],{type:'video/mp4; codecs="avc1.64001E, mp4a.40.5"'}))}}))})),s.on("error",(e=>{o(e)}))}))}startBuffer(){this.progressTimer&&this.stopBuffer(),this.progressTimer=setInterval((()=>{this.onLoadBufferupdate(),this.rmbFlag>4&&(this.rmbFlag=0),0===this.rmbFlag&&this.onRemoveBuffer()}),this.config.mp4ProgressTimer)}stopBuffer(){clearInterval(this.progressTimer),this.progressTimer=null}loadData(e=0,t=this.player.currentTime){this.timer&&clearTimeout(this.timer),this.mp4.seek(t+.1*e).then((e=>{if(e){const{mse:t}=this;t.updating=!0,t.appendBuffer(e),t.once("updateend",(()=>{t.updating=!1}))}}),(t=>{console.error(t),e<10&&(this.timer1=setTimeout((()=>{this.loadData(e+1)}),2e3))}))}onRemoveBuffer(){const{player:e,config:t,mse:r}=this;if(r.updating)return;const i=this.player.buffered,n=e.currentTime-t.maxCache,s=e.currentTime+t.maxCache;for(let o=0;o<i.length;o++)i.end(o)<n||i.start>s?r.removeBuffer(i.start(o),i.end(o)):i.start(o)<n?r.removeBuffer(i.start(o),n):i.end(o)>s&&r.removeBuffer(s,i.end(o))}onLoadBufferupdate(){const{player:e,config:t}=this,r=this.mse,i=this.mp4;if(r&&!r.updating&&i.canDownload){const r=i.timeRage,n=e.getBufferedRange(),s=e.currentTime+t.preloadTime/2;if(n[1]-s>0)return;r.every(((t,r)=>{const s=(t[0]+(-1!==t[1]?t[1]:e.duration))/2;return 0!==n[1]&&(!(s>n[1]&&!i.bufferCache.has(r))||void this.loadData(0,s))})),this.isEnded(e,i)}}errorHandle(e){const{player:t}=this;e.url=t.src,e.errd&&"object"==typeof e.errd&&this.mp4&&(e.errd.url=this.mp4.url,e.url=this.mp4.url,this.mp4.canDownload=!1),Ra.clear(),this.mp4&&this.mp4.bufferCache&&this.mp4.bufferCache.clear(),this.stopBuffer()}isEnded(){const{player:e,mp4:t,mse:r}=this;if(t.meta.endTime-e.currentTime<2){const t=e.getBufferedRange();e.currentTime-t[1]<.1&&r.endOfStream()}}destroy(){Ra.clear(),this.timer&&clearTimeout(this.timer),clearTimeout(this.waiterTimer),clearTimeout(this.timer1),this.detachEvents()}}const Ka=Math.pow(2,32)-1;class Ha{static type(e){return new Uint8Array([e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)])}static size(e){return _a.writeUint32(e)}static extension(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}static ftyp(){const e=new _a;return e.write(Ha.size(28),Ha.type("ftyp"),new Uint8Array([105,115,111,53,0,0,0,1,77,52,65,32,105,115,111,53,100,97,115,104])),e.buffer}static moov(e){const t=new _a;let r=8;const i=Ha.mvhd(e.duration,e.timeScale),n=Ha.audioTrak(e),s=Ha.mvex(e.duration,e.timeScale),o=new _a,a=new Uint8Array([0,0,0,85,117,100,116,97,0,0,0,77,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,32,105,108,115,116,0,0,0,12,45,45,45,45,0,0,0,0,0,0,0,12,45,45,45,45,0,0,0,0]);o.write(new Uint8Array(a));const u=o.buffer;return[i,n,s,u].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("moov"),i,s,n,u),t.buffer}static mvhd(e,t){const r=new _a;e*=t,e=0;const i=Math.floor(e/(Ka+1)),n=Math.floor(e%(Ka+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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 r.write(Ha.size(8+s.length),Ha.type("mvhd"),new Uint8Array(s)),r.buffer}static audioTrak(e){const t=new _a;let r=8;const i=Ha.tkhd({id:1,duration:e.audioDuration,timeScale:e.audioTimeScale,width:0,height:0,type:"audio"}),n=Ha.mdia({type:"audio",timeScale:e.audioTimeScale,duration:e.audioDuration,channelCount:e.channelCount,sampleRate:e.sampleRate,audioConfig:e.audioConfig}),s=new _a,o=new Uint8Array([0,0,0,44,108,117,100,116,0,0,0,36,116,108,111,117,1,0,0,0,1,0,0,0,72,84,132,35,5,1,114,35,3,114,19,4,125,19,5,115,19,6,4,19]);s.write(Ha.size(52),Ha.type("udta"),new Uint8Array(o));const a=s.buffer;return[i,n,a].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("trak"),i,n,a),t.buffer}static tkhd(e){const t=new _a,r=e.id;let i=e.duration*e.timeScale;i=0;const n=e.type,s=Math.floor(0/(Ka+1)),o=Math.floor(0%(Ka+1)),a=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,"video"===n?1:0,"audio"===n?1: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]);return t.write(Ha.size(8+a.byteLength),Ha.type("tkhd"),a),t.buffer}static edts(e){const t=new _a,r=e.duration,i=e.mediaTime;return t.write(Ha.size(36),Ha.type("edts")),t.write(Ha.size(28),Ha.type("elst")),t.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),t.buffer}static mdia(e){const t=new _a;let r=8;const i=Ha.mdhd(e.timeScale),n=Ha.hdlr(e.type),s=Ha.minf(e);return[i,n,s].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("mdia"),i,n,s),t.buffer}static mdhd(e,t=0){const r=new _a;t*=e;const i=Math.floor(t/(Ka+1)),n=Math.floor(t%(Ka+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]);return r.write(Ha.size(12+s.byteLength),Ha.type("mdhd"),Ha.extension(1,0),s),r.buffer}static hdlr(e){const t=new _a,r=[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];return"audio"===e&&(r.splice(8,4,115,111,117,110),r.splice(24,13,83,111,117,110,100,72,97,110,100,108,101,114,0)),t.write(Ha.size(8+r.length),Ha.type("hdlr"),new Uint8Array(r)),t.buffer}static minf(e){const t=new _a;let r=8;const i="video"===e.type?Ha.vmhd():Ha.smhd(),n=Ha.dinf(),s=Ha.stbl(e);return[i,n,s].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("minf"),i,n,s),t.buffer}static vmhd(){const e=new _a;return e.write(Ha.size(20),Ha.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),e.buffer}static smhd(){const e=new _a;return e.write(Ha.size(16),Ha.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),e.buffer}static dinf(){const e=new _a;return e.write(Ha.size(36),Ha.type("dinf"),Ha.size(28),Ha.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),e.buffer}static stbl(e){const t=new _a;let r=8;const i=Ha.stsd(e),n=Ha.stts(),s=Ha.stsc(),o=Ha.stsz(),a=Ha.stco();return[i,n,s,o,a].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("stbl"),i,n,s,o,a),t.buffer}static stsd(e){const t=new _a;let r;return r="audio"===e.type?Ha.mp4a(e):Ha.avc1(e),t.write(Ha.size(16+r.byteLength),Ha.type("stsd"),Ha.extension(0,0),new Uint8Array([0,0,0,1]),r),t.buffer}static mp4a(e){const t=new _a,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,e.sampleRate>>8&255,255&e.sampleRate,0,0]),i=Ha.esds(e.audioConfig);return t.write(Ha.size(8+r.byteLength+i.byteLength),Ha.type("mp4a"),r,i),t.buffer}static esds(e=[43,146,8,0]){const t=e.length,r=new _a,i=new Uint8Array([0,0,0,0,3,23+t,0,0,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return r.write(Ha.size(8+i.byteLength),Ha.type("esds"),i),r.buffer}static avc1(e){const t=new _a,r=e.sps,i=e.pps,n=e.width,s=e.height,o=e.pixelRatio[0],a=e.pixelRatio[1],u=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>8&255,255&n,s>>8&255,255&s,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([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([o>>24,o>>16&255,o>>8&255,255&o,a>>24,a>>16&255,a>>8&255,255&a]);return t.write(Ha.size(40+c.byteLength+u.byteLength+d.byteLength),Ha.type("avc1"),c,Ha.size(8+u.byteLength),Ha.type("avcC"),u,Ha.size(20),Ha.type("btrt"),d,Ha.size(16),Ha.type("pasp"),h),t.buffer}static stts(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Ha.size(16),Ha.type("stts"),t),e.buffer}static stsc(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Ha.size(16),Ha.type("stsc"),t),e.buffer}static stco(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0]);return e.write(Ha.size(16),Ha.type("stco"),t),e.buffer}static stsz(){const e=new _a,t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return e.write(Ha.size(20),Ha.type("stsz"),t),e.buffer}static mvex(e,t){const r=new _a;let i=8;const n=Ha.mehd(e*t),s=Ha.trex(1),o=Ha.trep(1);return[n,s,o].forEach((e=>{i+=e.byteLength})),r.write(Ha.size(i),Ha.type("mvex"),n,s,o),r.buffer}static mehd(e){const t=new _a,r=new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e]);return t.write(Ha.size(16),Ha.type("mehd"),Ha.extension(0,0),r),t.buffer}static trex(e){const t=new _a,r=new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,4,0,0,0,0,0,0,30,132,128]);return t.write(Ha.size(8+r.byteLength),Ha.type("trex"),r),t.buffer}static trep(e){const t=new _a,r=new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e]);return t.write(Ha.size(16),Ha.type("trep"),Ha.extension(0,0),r),t.buffer}static moof(e){const t=new _a;let r=8;const i=Ha.mfhd(),n=Ha.traf(e);return[i,n].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("moof"),i,n),t.buffer}static mfhd(){const e=new _a,t=_a.writeUint32(Ha.sequence);return Ha.sequence+=1,e.write(Ha.size(16),Ha.type("mfhd"),Ha.extension(0,0),t),e.buffer}static traf(e){const t=new _a;let r=8;const i=Ha.tfhd(1),n=Ha.tfdt(e.time),s=Ha.trun(e);return[i,n,s].forEach((e=>{r+=e.byteLength})),t.write(Ha.size(r),Ha.type("traf"),i,n,s),t.buffer}static tfhd(e){const t=new _a,r=_a.writeUint32(e);return t.write(Ha.size(16),Ha.type("tfhd"),Ha.extension(0,131072),r),t.buffer}static tfdt(e){const t=new _a,r=new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e]);return t.write(Ha.size(16),Ha.type("tfdt"),Ha.extension(0,0),r),t.buffer}static trun(e){const t=new _a,r=_a.writeUint32(e.samples.length),i=_a.writeUint32(92+4*e.samples.length);return t.write(Ha.size(20+4*e.samples.length),Ha.type("trun"),Ha.extension(0,513),r,i),e.samples.forEach(((e,r)=>{t.write(_a.writeUint32(e.size))})),t.buffer}static mdat(e){const t=new _a;let r=8;return e.samples.forEach((e=>{r+=e.size})),t.write(Ha.size(r),Ha.type("mdat")),e.samples.forEach((e=>{t.write(e.buffer)})),t.buffer}}Ha.sequence=1;class $a{constructor(e,t,r=1024){oa(this),this.url=e,this.options=t,this.withCredentials=t.withCredentials,this.CHUNK_SIZE=r,this.reqTimeLength=5,this.init(e),this.once("moovReady",this.moovParse.bind(this)),this.cache=new _a,this.bufferCache=new Set,this.mdatCache=[],this.timeRage=[],this.canDownload=!0,this.cut=!1}getData(e=0,t=e+this.CHUNK_SIZE){const r=this;return new Promise(((i,n)=>{new Ra(this.url,[e,t],this.options.headers||{},this.withCredentials,i).once("error",(e=>{r.emit("error",e)}))}))}moovParse(){const t=this,r=this.moovBox,i=ja.findBox(r,"mvhd");let n,s,o,a,u,c,d=ja.findBox(r,"trak");"Array"!==e.Util.typeOf(d)&&(d=[d]),d.forEach((e=>{const r=ja.findBox(e,"hdlr"),i=ja.findBox(e,"mdhd");if(!r||!i)return console.error("!hdlr || !mdhd"),void t.emit("error",new la("parse","",{line:72,handle:"[MP4] moovParse",url:t.url}));const d=ja.findBox(e,"stsd").subBox[0];if("soun"===r.handleType){n=e;const t=ja.findBox(e,"esds"),r=ja.findBox(e,"mp4a"),h=ja.findBox(e,5);o=i.timescale,s=t?`${d.type}.`+ja.toHex(t.subBox[0].subBox[0].typeID)+`.${t.subBox[0].subBox[0].subBox[0].type}`:`${d.type}`,h&&h.EScode&&(c=h.EScode.map((e=>Number(`0x${e}`)))),r&&(a=r.channelCount,u=r.sampleRate)}})),this.audioTrak=fa({},n);const h=this._boxes.find((e=>"mdat"===e.type)),f=parseFloat(ja.seekTrakDuration(n,o));let l,m;this.mdatStart=h.start,this.sampleCount=ja.sampleCount(ja.findBox(this.audioTrak,"stts").entry);const p=ja.findBox(this.audioTrak,"stts").entry;for(let e=0;e<f;e+=this.reqTimeLength)l=ja.seekOrderSampleByTime(p,o,e),e+this.reqTimeLength<f?(m=ja.seekOrderSampleByTime(p,o,e+this.reqTimeLength),this.timeRage.push([{time:l.startTime,order:l.order},{time:m.startTime,order:m.order}])):this.timeRage.push([{time:l.startTime,order:l.order},{time:f,order:this.sampleCount-1}]);this.meta={audioCodec:s,createTime:i.createTime,modifyTime:i.modifyTime,duration:i.duration/i.timeScale,timeScale:i.timeScale,audioDuration:f,audioTimeScale:o,endTime:f,channelCount:a,sampleRate:u,audioConfig:c}}init1(){const e=this;e.getData().then((t=>{let r,i,n,s,o,a=0;try{r=new Ta(t)}catch(u){return console.error(u),e.emit("error",u.type?u:new la("parse","",{line:176,handle:"[MP4] init",msg:u.message})),!1}if(e._boxes=o=r.boxes,o.every((r=>("ftyp"===r.type?(a+=r.size,s=r,e.ftypBox=s,e.ftypBuffer=t.slice(0,s.size)):"mdat"===r.type&&(i=r,i.start=a,a+=r.size,e.mdatBox=i),!0))),i){r.nextBox?e.emit("error",new la("parse","",{line:223,handle:"[MP4] init",msg:"not find moov box"})):e.getData(a,a+1024).then((t=>{const r=new Ta(t);if(e._boxes=e._boxes.concat(r.boxes),r.boxes.every((r=>"moov"===r.type?(a+=r.size,n=r,e.moovBox=n,e.moovBuffer=t.slice(0,n.size),e.emit("moovReady",n),!1):(a+=r.size,!0))),!n){const i=r.nextBox;i?"moov"===i.type?e.getData(a,a+i.size-1).then((r=>{const i=new Ta(r);e._boxes=e._boxes.concat(i.boxes),i.boxes.every((r=>"moov"===r.type?(a+=r.size,n=r,e.moovBox=n,e.moovBuffer=t.slice(0,n.size),e.emit("moovReady",n),!1):(a+=r.size,!0))),n||e.emit("error",new la("parse","",{line:207,handle:"[MP4] init",msg:"not find moov box"}))})).catch((()=>{e.emit("error",new la("network","",{line:210,handle:"[MP4] getData",msg:"getData failed"}))})):e.emit("error",new la("parse","",{line:213,handle:"[MP4] init",msg:"not find moov box"})):e.emit("error",new la("parse","",{line:216,handle:"[MP4] init",msg:"not find moov box"}))}})).catch((()=>{e.emit("error",new la("network","",{line:220,handle:"[MP4] getData",msg:"getData failed"}))}))}else{const t=r.nextBox;t?"moov"===t.type||"free"===t.type?e.getData(a,a+t.size+1024).then((t=>{const r=new Ta(t);if(e._boxes=e._boxes.concat(r.boxes),r.boxes.every((r=>"moov"===r.type?(a+=r.size,n=r,e.moovBox=n,e.moovBuffer=t.slice(0,n.size),!0):"mdat"===r.type?(i=r,i.start=a,a+=r.size,e.mdatBox=i,e.emit("moovReady",n),!1):(a+=r.size,!0))),!i){const t=r.nextBox;t?"free"===t.type?e.getData(a,a+t.size+1024).then((t=>{const r=new Ta(t);e._boxes=e._boxes.concat(r.boxes),r.boxes.every((r=>"mdat"===r.type?(i=r,i.start=a,e.mdatBox=i,e.emit("moovReady",n),!1):"free"===r.type?(e.freeBuffer=t.slice(0,r.size),a+=r.size,!0):(a+=r.size,!0))),i||e.emit("error",new la("parse","",{line:207,handle:"[MP4] init",msg:"not find mdat box"}))})).catch((()=>{e.emit("error",new la("network","",{line:210,handle:"[MP4] getData",msg:"getData failed"}))})):e.emit("error",new la("parse","",{line:213,handle:"[MP4] init",msg:"not find mdat box"})):e.emit("error",new la("parse","",{line:216,handle:"[MP4] init",msg:"not find mdat box"}))}})).catch((t=>{e.emit("error",new la("network","",{line:220,handle:"[MP4] getData",msg:"getData failed"}))})):e.emit("error",new la("parse","",{line:223,handle:"[MP4] init",msg:"not find mdat box"})):e.emit("error",new la("parse","",{line:226,handle:"[MP4] init",msg:"not find mdat box"}))}})).catch((()=>{e.emit("error",new la("network","",{line:230,handle:"[MP4] getData",msg:"getData failed"}))}))}init(){const e=this;e.getData().then((t=>{let r,i,n,s=0;try{r=new Ta(t)}catch(o){return e.emit("error",o.type?o:new la("parse","",{line:176,handle:"[MP4] init",msg:o.message})),!1}if(e._boxes=n=r.boxes,n.every((t=>(s+=t.size,"moov"!==t.type||(i=t,e.moovBox=i,e.emit("moovReady",i),!1)))),!i){const t=r.nextBox;t?"moov"===t.type?e.getData(s,s+t.size+28).then((t=>{const r=new Ta(t);e._boxes=e._boxes.concat(r.boxes),i=r.boxes.filter((e=>"moov"===e.type)),i.length?(e.moovBox=i[0],e.emit("moovReady",i)):e.emit("error",new la("parse","",{line:203,handle:"[MP4] init",msg:"not find moov box"}))})):e.emit("error",new la("parse","",{line:207,handle:"[MP4] init",msg:"not find moov box"})):e.getData(s,"").then((t=>{const r=new Ta(t);r?(e._boxes=e._boxes.concat(r.boxes),r.boxes.every((t=>"moov"!==t.type||(i=t,e.moovBox=i,e.emit("moovReady",i),!1)))):e.emit("error",new la("parse","",{line:225,handle:"[MP4] init",msg:"not find moov box"}))}))}})).catch((t=>{throw e.emit("error",new la("network","",{line:231,handle:"[MP4] getData",msg:"getData failed"})),t}))}getSamplesByOrders(e="audio",t,r){const i=this.audioTrak,n=ja.findBox(i,"stsc"),s=ja.findBox(i,"stsz"),o=ja.findBox(i,"stts"),a=ja.findBox(i,"stco"),u=ja.findBox(i,"ctts"),c=this.mdatStart;let d=[];if(r=void 0!==r?r:s.entries.length,t instanceof Array)t.forEach(((e,t)=>{d.push({idx:e,size:s.entries[e],time:ja.seekSampleTime(o,u,e),offset:ja.seekSampleOffset(n,a,s,e,c)})}));else if(0!==r)for(let h=t;h<r;h++)d.push({idx:h,size:s.entries[h],time:ja.seekSampleTime(o,u,h),offset:ja.seekSampleOffset(n,a,s,h,c)});else d={idx:t,size:s.entries[t],time:ja.seekSampleTime(o,u,t),offset:ja.seekSampleOffset(n,a,s,t,c)};return d}packMeta(){if(!this.meta)return;const e=new _a;return e.write(Ha.ftyp()),e.write(Ha.moov(this.meta)),this.cache.write(e.buffer),e.buffer}seek(e,t=null,r=null){const i=ja.findBox(this.audioTrak,"stts").entry;return t||(t=ja.seekOrderSampleByTime(i,this.meta.audioTimeScale,e).order),r||e+this.reqTimeLength<this.meta.audioDuration&&(r=ja.seekOrderSampleByTime(i,this.meta.audioTimeScale,e+this.reqTimeLength).order),this.bufferCache.has(t)?Promise.resolve(null):this.loadFragment(t,r)}loadFragment(e,t){let r;const i=this,n=this.getSamplesByOrders("audio",e,0).offset;let s;return t?(s=this.getSamplesByOrders("audio",t,0),r=s.offset-1):(s=this.getSamplesByOrders("audio",this.sampleCount-1,0),r=s.offset+s.size-1),window.isNaN(n)||void 0!==r&&window.isNaN(r)?(i.emit("error",new la("parse","",{line:366,handle:"[MP4] loadFragment",url:i.url})),!1):this.getData(n+i.mdatStart,r?i.mdatStart+r:"").then((s=>(r&&this.mdatCache.push({start:n+i.mdatStart,end:i.mdatStart+r,buffer:new Uint8Array(s)}),i.createFragment(new Uint8Array(s),n,e,t))))}addFragment(e){const t=new _a;return t.write(Ha.moof(e)),t.write(Ha.mdat(e)),this.cache.write(t.buffer),t.buffer}createFragment(e,t,r,i){const n=[];this.bufferCache.add(r);const s=this.getSamplesByOrders("audio",r,i),o=s.map(((r,i)=>({size:r.size,duration:r.time.duration,offset:r.time.offset,buffer:new Uint8Array(e.slice(r.offset-t,r.offset-t+r.size)),key:0===i})));n.push(this.addFragment({id:2,time:this.cut?0:s[0].time.time,firstFlags:0,flags:1793,samples:o}));let a=0;n.every((e=>(a+=e.byteLength,!0)));const u=new Uint8Array(a);let c=0;return n.every((e=>(u.set(e,c),c+=e.byteLength,!0))),Promise.resolve(u)}download(){}clear(){this.cache=new _a,this.bufferCache.clear()}}const Ga='audio/mp4; codecs="mp4a.40.5"';class Wa extends e.BasePlugin{static get pluginName(){return"m4aPlugin"}static get defaultConfig(){return{withCredentials:!0,videoOnly:!1,headers:{},reqTimeLength:5,preloadTime:30,maxCache:35,chunkSize:Math.pow(25,5),mp4ProgressTimer:300,segPlay:!1,offline:!1}}static isSupported(){return["chrome","firfox","safari"].some((t=>t===e.Sniffer.browser))&&Na.isSupported(Ga)}constructor(r){super(r),t(this,"onLoadBufferupdate",(()=>{const{config:e,player:t,mse:r,mp4:i}=this;if(r&&!r.updating&&i.canDownload){const r=i.timeRage,n=t.getBufferedRange(),s=t.currentTime+e.preloadTime;if(n[1]-s>0)return;r.every(((e,t)=>0===n[1]?(this.loadData(0,0,0),!1):!(e[0].time>=n[1]&&!i.bufferCache.has(t))||void this.loadData(0,e[0].time,e[0].order,e[1].order))),this.isEnded()}})),t(this,"onOnceCanplay",(()=>{const{player:t}=this;if("safari"===e.Sniffer.browser&&t.buffered.length){const e=t.buffered.start(0);t.currentTime=e+.1}})),t(this,"onSeeking",(e=>{const{player:t}=this,r=t.buffered;let i=!1;const n=t.video.currentTime;console.log("onSeeking",t.ended,n),Ra.clear();const s=t.mp4.timeRage;if(this.progressTimer||this.startBuffer(),r.length){for(let e=0,t=r.length;e<t;e++)if(n>=r.start(e)&&n<=r.end(e)){i=!0;break}i||s.every(((e,t)=>!(e[0].time<=n&&e[1].time>n)||(this.loadData(0,e[0].time,e[0].order,e[1].order),!1)))}else s.every(((e,t)=>!(e[0].time<=n&&e[1].time>n)||(this.loadData(0,e[0].time,e[0].order,e[1].order),!1)))})),t(this,"onPause",(e=>{Ra.clear()})),t(this,"onPlay",(e=>{console.log("onPlay",this.player.ended),this.player.duration-this.player.currentTime<.1&&(this.onEnded(),console.log("ended clearBuffer",this.player.getBufferedRange()),this.player.currentTime=0,this.player.play()),this.waiterTimer&&(clearTimeout(this.waiterTimer),this.waiterTimer=null)})),t(this,"onWaiting",(e=>{const{player:t}=this,r=t.buffered;let i=!1;const n=t.currentTime;Ra.clear();const s=this.mp4.timeRage;if(r.length){for(let e=0,t=r.length;e<t;e++)if(n>=r.start(e)&&n<=r.end(e)){i=!0;break}i||s.every(((e,t)=>!(e[0].time<=n&&e[1].time>n)||(this.loadData(0,e[0].time,e[0].order,e[1].order),!1)))}else s.every(((e,t)=>!(e[0].time<=n&&e[1].time>n)||(this.loadData(0,e[0].time,e[0].order,e[1].order),!1)))})),t(this,"onEnded",(e=>{this.stopBuffer(),this.mp4.clear(),this.mse.clearBuffer()})),t(this,"replay",(()=>{})),this.mp4=null,this.mse=null,this.waiterTimer=null,this.name="",this.vid=""}afterCreate(){if(Wa.isSupported()){try{e.BasePlugin.defineGetterOrSetter(this.player,{__url:{get:()=>{try{return this.mse?this.mse.url:this.config.url}catch(e){return null}}}})}catch(t){}this.attachEvents()}}beforePlayerInit(){if(!Wa.isSupported())return;const{playerConfig:t,player:r}=this;let i={};if(i="Array"===e.Util.typeOf(t.url)?t.url:[{src:t.url,name:t.name,vid:t.vid,poster:t.poster}],i[0].src)return this.urlInfo=i,this.url=i[0].src,this.initM4a(this.url).then((e=>{const t=e[0],i=e[1];r.mp4=t,r.mse=i,t.on("error",(e=>{this.errorHandle(e)}))}));r.emit("error",new e.Errors("other",r.config.vid))}attachEvents(){this.once(e.Events.CANPLAY,this.onOnceCanplay),this.on(e.Events.SEEKING,this.onSeeking),this.on(e.Events.WAITING,this.onWaiting),this.on(e.Events.ENDED,this.onEnded),this.on(e.Events.PLAY,this.onPlay)}detachEvents(){this.off(e.Events.CANPLAY,this.onOnceCanplay),this.off(e.Events.SEEKING,this.onSeeking),this.off(e.Events.WAITING,this.onWaiting),this.stopBuffer()}startBuffer(){this.progressTimer&&this.stopBuffer(),this.progressTimer=setInterval((()=>{this.onLoadBufferupdate()}),this.config.mp4ProgressTimer)}stopBuffer(){clearInterval(this.progressTimer),this.progressTimer=null}loadData(e=0,t=0,r=null,i=null){const{player:n}=this;this.timer&&clearTimeout(n.timer),t=Math.max(t,n.currentTime),this.timer=setTimeout((()=>{n.mp4.seek(t,r,i).then((e=>{if(e){const t=n.mse;t.updating=!0,t.appendBuffer(e),t.once("updateend",(()=>{t.updating=!1}))}}),(e=>{console.error(e)}))}),50)}initM4a(e,t=!1){const{config:r}=this;return this.mp4=new $a(e,this.config,this.config.chunkSize),this.mp4.reqTimeLength=r.reqTimeLength,new Promise(((e,r)=>{this.mp4.once("moovReady",(()=>{this.mse=new Na(Ga),t&&(this.mse.replaying=!0),this.startBuffer(),this.mse.on("sourceopen",(()=>{this.mse.appendBuffer(this.mp4.packMeta()),this.mse.once("updateend",(()=>{this.loadData()}))})),this.mse.on("error",(function(e){r(e)})),e([this.mp4,this.mse])})),this.mp4.on("error",(e=>{r(e)}))}))}cut(t,r=0,i){const n=new _a;return new Promise(((s,o)=>{const a=new $a(t,this.config,this.config.chunkSize);a.once("moovReady",(()=>{(!i||i<=r)&&(i=r+15),i>a.meta.audioDuration&&(r=a.meta.audioDuration-(i-r),i=a.meta.audioDuration),a.reqTimeLength=i-r,a.cut=!0,a.seek(r).then((t=>{if(t){const r=e.Util.deepCopy({duration:a.reqTimeLength,audioDuration:a.reqTimeLength,endTime:a.reqTimeLength},a.meta);r.duration=a.reqTimeLength,r.audioDuration=a.reqTimeLength,r.endTime=a.reqTimeLength,n.write(a.packMeta(r),t),s(new window.Blob([n.buffer],{type:Ga}))}}))})),a.on("error",(e=>{o(e)}))}))}errorHandle(e){const{player:t}=this;e.url=t.src,e.errd&&"object"==typeof e.errd&&this.mp4&&(e.errd.url=this.mp4.url,e.url=this.mp4.url,this.mp4.canDownload=!1),Ra.clear(),this.mp4&&this.mp4.bufferCache&&this.mp4.bufferCache.clear(),this.detachEvents()}isEnded(){const{player:e,mp4:t,mse:r}=this;if(t.meta.endTime-e.currentTime<2){const t=e.getBufferedRange();e.currentTime-t[1]<.1&&r.endOfStream()}}destroy(){const{player:e}=this;Ra.clear(),e.timer&&clearTimeout(e.timer)}}return qa.M4aPlugin=Wa,qa}));
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|