Commit 3ad6b541255e0479e025ee3b2bb79ff1a354b950
1 parent
c593280d
更新视频静音配置
Showing
5 changed files
with
11 additions
and
9 deletions
README.md
dist/index.js
... | ... | @@ -42,4 +42,4 @@ object-assign |
42 | 42 | /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
43 | 43 | t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<<s)-1,c=l>>1,u=-7,d=n?i-1:0,h=n?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=s;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,l,c=8*o-i-1,u=(1<<c)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=f,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[n+p]=255&a,p+=f,a/=256,c-=8);e[n+p-f]|=128*m}},function(e,t){},function(e,t,n){"use strict";function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=n(3).Buffer,s=n(66).inspect,l=s&&s.custom||"inspect";e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,n,c;return t=e,(n=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return a.alloc(0);for(var t,n,r,i=a.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,n=i,r=s,a.prototype.copy.call(t,n,r),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=a.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return s(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}])&&o(t.prototype,n),c&&o(t,c),e}()},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){ |
44 | 44 | /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
45 | -var r=n(3),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";(function(t){var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(20),a=Symbol("lastResolve"),s=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),d=Symbol("handlePromise"),h=Symbol("stream");function p(e,t){return{value:e,done:t}}function f(e){var t=e[a];if(null!==t){var n=e[h].read();null!==n&&(e[u]=null,e[a]=null,e[s]=null,t(p(n,!1)))}}function m(e){t.nextTick(f,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(r={get stream(){return this[h]},next:function(){var e=this,n=this[l];if(null!==n)return Promise.reject(n);if(this[c])return Promise.resolve(p(void 0,!0));if(this[h].destroyed)return new Promise((function(n,r){t.nextTick((function(){e[l]?r(e[l]):n(p(void 0,!0))}))}));var r,i=this[u];if(i)r=new Promise(function(e,t){return function(n,r){e.then((function(){t[c]?n(p(void 0,!0)):t[d](n,r)}),r)}}(i,this));else{var o=this[h].read();if(null!==o)return Promise.resolve(p(o,!1));r=new Promise(this[d])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),i(r,"return",(function(){var e=this;return new Promise((function(t,n){e[h].destroy(null,(function(e){e?n(e):t(p(void 0,!0))}))}))})),r),y);e.exports=function(e){var t,n=Object.create(g,(i(t={},h,{value:e,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,d,{value:function(e,t){var r=n[h].read();r?(n[u]=null,n[a]=null,n[s]=null,e(p(r,!1))):(n[a]=e,n[s]=t)},writable:!0}),t));return n[u]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[s];return null!==t&&(n[u]=null,n[a]=null,n[s]=null,t(e)),void(n[l]=e)}var r=n[a];null!==r&&(n[u]=null,n[a]=null,n[s]=null,r(p(void 0,!0))),n[c]=!0})),e.on("readable",m.bind(null,n)),n}}).call(this,n(2))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,n){"use strict";e.exports=i;var r=n(39);function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}n(7)(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r;var i=n(10).codes,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function l(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var s=!1;e.on("close",(function(){s=!0})),void 0===r&&(r=n(20)),r(e,{readable:t,writable:i},(function(e){if(e)return o(e);s=!0,o()}));var l=!1;return function(t){if(!s&&!l)return l=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new a("pipe"))}}function c(e){e()}function u(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?s:e.pop():s}e.exports=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var a=t.map((function(e,n){var o=n<t.length-1;return l(e,o,n>0,(function(e){r||(r=e),e&&a.forEach(c),o||(a.forEach(c),i(r))}))}));return t.reduce(u)}},function(e,t,n){t.parser=n(74).parser,t.generate=n(80),t.writeToStream=n(41)},function(e,t,n){const r=n(75),i=n(1),o=n(77),a=n(40),s=n(8)("mqtt-packet:parser");class l extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new l).parser(e)}_resetState(){s("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),s("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,s("parse: state complete. _stateCounter is now: %d",this._stateCounter),s("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return s("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),s("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),s("_parseLength %d",e.value),!!e}_parsePayload(){s("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return s("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;s("_parseConnect");const i={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(o.clientId=c,s("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,s("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,s("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));o.username=r,s("_parseConnect: packet.username: %s",o.username)}if(i.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));o.password=n}return this.settings=o,s("_parseConnect: complete"),o}_parseConnack(){s("_parseConnack");const e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}s("_parseConnack: complete")}_parsePublish(){s("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),s("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){s("_parseSubscribe");const e=this.packet;let t,n,r,i,o,l,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&a.SUBSCRIBE_OPTIONS_QOS_MASK,l=0!=(n>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(n>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),i=n>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:r},5===this.settings.protocolVersion&&(c.nl=l,c.rap=o,c.rh=i),s("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){s("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){s("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));s("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){s("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){s("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2&&(e.reasonCode=this._parseByte(),s("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(s("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return s("_parseDisconnect result: true"),!0}_parseAuth(){s("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),s("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(s("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,s("_parseString: result: %s",r),r}_parseStringPair(){return s("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,s("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,s("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,s("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){s("_parseVarByteNum");let t,n=0,r=1,i=0,o=!1;const l=this._pos?this._pos:0;for(;n<4;){if(t=this._list.readUInt8(l+n++),i+=r*(t&a.VARBYTEINT_MASK),r*=128,0==(t&a.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=n)break}return!o&&4===n&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),o=!!o&&(e?{bytes:n,value:i}:i),s("_parseVarByteNum: result: %o",o),o}_parseByte(){const e=this._list.readUInt8(this._pos);return this._pos++,s("_parseByte: result: %o",e),e}_parseByType(e){switch(s("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){s("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte(),t=a.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(a.propertiesTypes[t]))):n[t]=this._parseByType(a.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(a.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return s("_newPacket"),this.packet&&(this._list.consume(this.packet.length),s("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),s("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){s("_emitError"),this.error=e,this.emit("error",e)}}e.exports=l},function(e,t,n){"use strict";const r=n(9).Duplex,i=n(7),o=n(76);function a(e){if(!(this instanceof a))return new a(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}o._init.call(this,e),r.call(this)}i(a,r),Object.assign(a.prototype,o.prototype),a.prototype._new=function(e){return new a(e)},a.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},a.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},a.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},a.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},a.prototype._isBufferList=function(e){return e instanceof a||e instanceof o||a.isBufferList(e)},a.isBufferList=o.isBufferList,e.exports=a,e.exports.BufferListStream=a,e.exports.BufferList=o},function(e,t,n){"use strict";const{Buffer:r}=n(3),i=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e)}o._init=function(e){Object.defineProperty(this,i,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},o.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},o.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,n,i){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof i||i>this.length)&&(i=this.length),n>=this.length)return e||r.alloc(0);if(i<=0)return e||r.alloc(0);const o=!!e,a=this._offset(n),s=i-n;let l=s,c=o&&t||0,u=a[1];if(0===n&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(l<=this._bufs[a[0]].length-u)return o?this._bufs[a[0]].copy(e,t,u,u+l):this._bufs[a[0]].slice(u,u+l);o||(e=r.allocUnsafe(s));for(let t=a[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(l>n)){this._bufs[t].copy(e,c,u,u+l),c+=n;break}this._bufs[t].copy(e,c,u),c+=n,l-=n,u&&(u=0)}return e.length>c?e.slice(0,c):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!==n[1]&&(i[0]=i[0].slice(n[1])),this._new(i)},o.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},o.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const i=this._offset(t);let o=i[0],a=i[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;a<t.length;){if(t.length-a>=e.length){const n=t.indexOf(e,a);if(-1!==n)return this._reverseOffset([o,n]);a=t.length-e.length+1}else{const t=this._reverseOffset([o,a]);if(this._match(t,e))return t;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){o.prototype[t]=null===e[t]?function(e,n){return this.slice(e,e+n)[t](0,n)}:function(n){return this.slice(n,n+e[t])[t](0)}}(t)}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[i]},e.exports=o},function(e,t){e.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},function(e,t,n){e.exports=function(e){function t(e){let n,i=null;function o(...e){if(!o.enabled)return;const r=o,i=Number(new Date),a=i-(n||i);r.diff=a,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,i)=>{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(79),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},function(e,t){var n=1e3,r=6e4,i=60*r,o=24*i;function a(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===s&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=i)return a(e,t,i,"hour");if(t>=r)return a(e,t,r,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){const r=n(41),i=n(1);class o extends i{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const n=new Array(this._array.length),r=this._array;let i,o=0;for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?n[i]=r[i].length:n[i]=t.byteLength(r[i]),e+=n[i];const a=t.allocUnsafe(e);for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?(r[i].copy(a,o),o+=n[i]):(a.write(r[i],o),o+=n[i]);return a}}e.exports=function(e,t){const n=new o;return r(e,n,t),n.concat()}}).call(this,n(3).Buffer)},function(e,t,n){(function(t){const n={},r=t.isBuffer(t.from([1,2]).subarray(0,1));function i(e){const n=t.allocUnsafe(2);return n.writeUInt8(e>>8,0),n.writeUInt8(255&e,1),n}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=i(e)},generateNumber:i,genBufVariableByteInt:function(e){let n=0,i=0;const o=t.allocUnsafe(4);do{n=e%128|0,(e=e/128|0)>0&&(n|=128),o.writeUInt8(n,i++)}while(e>0&&i<4);return e>0&&(i=0),r?o.subarray(0,i):o.slice(0,i)},generate4ByteBuffer:function(e){const n=t.allocUnsafe(4);return n.writeUInt32BE(e,0),n}}}).call(this,n(3).Buffer)},function(e,t,n){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,n)}));case 3:return t.nextTick((function(){e.call(null,n,r)}));case 4:return t.nextTick((function(){e.call(null,n,r,i)}));default:for(o=new Array(s-1),a=0;a<o.length;)o[a++]=arguments[a];return t.nextTick((function(){e.apply(null,o)}))}}}:e.exports=t}).call(this,n(2))},function(e,t,n){"use strict";function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}},function(e,t,n){"use strict";function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}}},function(e,t,n){"use strict";var r=n(86),i=n(88);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=b,t.resolve=function(e,t){return b(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?b(e,!1,!0).resolveObject(t):t},t.format=function(e){i.isString(e)&&(e=b(e));return e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(89);function b(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o<e.indexOf("#")?"?":"#",c=e.split(s);c[0]=c[0].replace(/\\/g,"/");var b=e=c.join(s);if(b=b.trim(),!n&&1===e.split("#").length){var _=l.exec(b);if(_)return this.path=b,this.href=b,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=a.exec(b);if(w){var S=(w=w[0]).toLowerCase();this.protocol=S,b=b.substr(w.length)}if(n||w||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===b.substr(0,2);!k||w&&y[w]||(b=b.substr(2),this.slashes=!0)}if(!y[w]&&(k||w&&!g[w])){for(var E,A,x=-1,T=0;T<h.length;T++){-1!==(R=b.indexOf(h[T]))&&(-1===x||R<x)&&(x=R)}-1!==(A=-1===x?b.lastIndexOf("@"):b.lastIndexOf("@",x))&&(E=b.slice(0,A),b=b.slice(A+1),this.auth=decodeURIComponent(E)),x=-1;for(T=0;T<d.length;T++){var R;-1!==(R=b.indexOf(d[T]))&&(-1===x||R<x)&&(x=R)}-1===x&&(x=b.length),this.host=b.slice(0,x),b=b.slice(x),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var M=this.hostname.split(/\./),L=(T=0,M.length);T<L;T++){var O=M[T];if(O&&!O.match(p)){for(var I="",D=0,P=O.length;D<P;D++)O.charCodeAt(D)>127?I+="x":I+=O[D];if(!I.match(p)){var B=M.slice(0,T),U=M.slice(T+1),N=O.match(f);N&&(B.push(N[1]),U.unshift(N[2])),U.length&&(b="/"+U.join(".")+b),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[S])for(T=0,L=u.length;T<L;T++){var j=u[T];if(-1!==b.indexOf(j)){var V=encodeURIComponent(j);V===j&&(V=escape(j)),b=b.split(j).join(V)}}var Y=b.indexOf("#");-1!==Y&&(this.hash=b.substr(Y),b=b.slice(0,Y));var W=b.indexOf("?");if(-1!==W?(this.search=b.substr(W),this.query=b.substr(W+1),t&&(this.query=v.parse(this.query)),b=b.slice(0,W)):t&&(this.search="",this.query={}),b&&(this.pathname=b),g[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var z=this.search||"";this.path=F+z}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,a="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(a=v.stringify(this.query));var s=this.search||a&&"?"+a||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||g[t])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),t+o+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+r},o.prototype.resolve=function(e){return this.resolveObject(b(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if(i.isString(e)){var t=new o;t.parse(e,!1,!0),e=t}for(var n=new o,r=Object.keys(this),a=0;a<r.length;a++){var s=r[a];n[s]=this[s]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var l=Object.keys(e),c=0;c<l.length;c++){var u=l[c];"protocol"!==u&&(n[u]=e[u])}return g[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!g[e.protocol]){for(var d=Object.keys(e),h=0;h<d.length;h++){var p=d[h];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var f=(e.pathname||"").split("/");f.length&&!(e.host=f.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==f[0]&&f.unshift(""),f.length<2&&f.unshift(""),n.pathname=f.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",v=n.search||"";n.path=m+v}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),_=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=_||b||n.host&&e.pathname,S=w,k=n.pathname&&n.pathname.split("/")||[],E=(f=e.pathname&&e.pathname.split("/")||[],n.protocol&&!g[n.protocol]);if(E&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===f[0]?f[0]=e.host:f.unshift(e.host)),e.host=null),w=w&&(""===f[0]||""===k[0])),_)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=f;else if(f.length)k||(k=[]),k.pop(),k=k.concat(f),n.search=e.search,n.query=e.query;else if(!i.isNullOrUndefined(e.search)){if(E)n.hostname=n.host=k.shift(),(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift());return n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=k.slice(-1)[0],x=(n.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,T=0,R=k.length;R>=0;R--)"."===(A=k[R])?k.splice(R,1):".."===A?(k.splice(R,1),T++):T&&(k.splice(R,1),T--);if(!w&&!S)for(;T--;T)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var C,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=M?"":k.length?k.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift()));return(w=w||n.host&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){(function(e,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof r&&r;a.global!==a&&a.window!==a&&a.self;var s,l=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,f=String.fromCharCode;function m(e){throw new RangeError(h[e])}function y(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+y((e=e.replace(d,".")).split("."),t).join(".")}function v(e){for(var t,n,r=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=f((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=f(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function S(e){var t,n,r,i,o,a,s,c,u,d,h,f=[],y=e.length,g=0,v=128,_=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&m("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<y;){for(o=g,a=1,s=36;i>=y&&m("invalid-input"),((c=(h=e.charCodeAt(i++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((l-g)/a))&&m("overflow"),g+=c*a,!(c<(u=s<=_?1:s>=_+26?26:s-_));s+=36)a>p(l/(d=36-u))&&m("overflow"),a*=d;_=w(g-o,t=f.length+1,0==o),p(g/t)>l-v&&m("overflow"),v+=p(g/t),g%=t,f.splice(g++,0,v)}return b(f)}function k(e){var t,n,r,i,o,a,s,c,u,d,h,y,g,b,S,k=[];for(y=(e=v(e)).length,t=128,n=0,o=72,a=0;a<y;++a)(h=e[a])<128&&k.push(f(h));for(r=i=k.length,i&&k.push("-");r<y;){for(s=l,a=0;a<y;++a)(h=e[a])>=t&&h<s&&(s=h);for(s-t>p((l-n)/(g=r+1))&&m("overflow"),n+=(s-t)*g,t=s,a=0;a<y;++a)if((h=e[a])<t&&++n>l&&m("overflow"),h==t){for(c=n,u=36;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=36)S=c-d,b=36-d,k.push(f(_(d+S%b,0))),c=p(S/b);k.push(f(_(c,0))),o=w(n,g,r==i),n=0,++r}++n,++t}return k.join("")}s={version:"1.4.1",ucs2:{decode:v,encode:b},decode:S,encode:k,toASCII:function(e){return g(e,(function(e){return u.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,n,t,e))||(e.exports=i)}()}).call(this,n(87)(e),n(6))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(90),t.encode=t.stringify=n(91)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u<c;++u){var d,h,p,f,m=e[u].replace(s,"%20"),y=m.indexOf(n);y>=0?(d=m.substr(0,y),h=m.substr(y+1)):(d=m,h=""),p=decodeURIComponent(d),f=decodeURIComponent(h),r(a,p)?i(a[p])?a[p].push(f):a[p]=[a[p],f]:a[p]=f}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,s){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(r(a))+n;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(r(e))})).join(t):s+encodeURIComponent(r(e[a]))})).join(t):s?encodeURIComponent(r(s))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var a=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},function(e,t){},function(e,t){},function(e,t,n){(t=e.exports=n(44)).Stream=t,t.Readable=t,t.Writable=n(47),t.Duplex=n(13),t.Transform=n(48),t.PassThrough=n(99)},function(e,t){},function(e,t,n){"use strict";var r=n(23).Buffer,i=n(97);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){"use strict";e.exports=o;var r=n(48),i=Object.create(n(14));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(12),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){var r=n(101),i=function(){},o=function(e,n,a){if("function"==typeof n)return o(e,null,n);n||(n={}),a=r(a||i);var s=e._writableState,l=e._readableState,c=n.readable||!1!==n.readable&&e.readable,u=n.writable||!1!==n.writable&&e.writable,d=!1,h=function(){e.writable||p()},p=function(){u=!1,c||a.call(e)},f=function(){c=!1,u||a.call(e)},m=function(t){a.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){a.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!d)return(!c||l&&l.ended&&!l.destroyed)&&(!u||s&&s.ended&&!s.destroyed)?void 0:a.call(e,new Error("premature close"))},b=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?u&&!s&&(e.on("end",h),e.on("close",h)):(e.on("complete",p),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",f),e.on("finish",p),!1!==n.error&&e.on("error",y),e.on("close",g),function(){d=!0,e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",p),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",f),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=o}).call(this,n(2))},function(e,t,n){var r=n(102);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}e.exports=r(i),e.exports.strict=r(o),i.proto=i((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}}},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length)return e.buffer.head?e.buffer.head.data.length:e.buffer[0].length;return e.length}(t)):null}},function(e,t,n){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,n){"use strict";n.r(t),n.d(t,"FlvCom",(function(){return ke})),n.d(t,"AllVideoCom",(function(){return Pe})),n.d(t,"Timer",(function(){return ze})),n.d(t,"ImgCom",(function(){return et})),n.d(t,"TransitionCom",(function(){return dt})),n.d(t,"AreaSelete",(function(){return _t})),n.d(t,"FunAreaSelect",(function(){return Rt})),n.d(t,"FunAreaSelectPlus",(function(){return Nt})),n.d(t,"Mqtt",(function(){return jt})),n.d(t,"getQuery",(function(){return Yt})),n.d(t,"getCookie",(function(){return Wt}));var r=n(0),i=n.n(r);class o{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");let t=Object(e);for(let e=1;e<arguments.length;e++){let n=arguments[e];if(null!=n)for(let e in n)n.hasOwnProperty(e)&&(t[e]=n[e])}return t},"function"!=typeof self.Promise&&n(55).polyfill()}}o.install();var a=o,s=n(1),l=n.n(s);class c{static e(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","error",n),c.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))}static i(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","info",n),c.ENABLE_INFO&&(console.info?console.info(n):console.log(n))}static w(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","warn",n),c.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))}static d(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","debug",n),c.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))}static v(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","verbose",n),c.ENABLE_VERBOSE&&console.log(n)}}c.GLOBAL_TAG="flv.js",c.FORCE_GLOBAL_TAG=!1,c.ENABLE_ERROR=!0,c.ENABLE_INFO=!0,c.ENABLE_WARN=!0,c.ENABLE_DEBUG=!0,c.ENABLE_VERBOSE=!0,c.ENABLE_CALLBACK=!1,c.emitter=new l.a;var u=c;var d=class{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}};class h{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class p extends h{constructor(e){super(e)}get name(){return"IllegalStateException"}}class f extends h{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends h{constructor(e){super(e)}get name(){return"NotImplementedException"}}const y={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},g={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class v{constructor(e){this._type=e||"undefined",this._status=y.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=y.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===y.kConnecting||this._status===y.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(e,t){throw new m("Unimplemented abstract function!")}abort(){throw new m("Unimplemented abstract function!")}}let b={};!function(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],n=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},i={};if(r.browser){i[r.browser]=!0;let e=r.majorVersion.split(".");i.version={major:parseInt(r.majorVersion,10),string:r.version},e.length>1&&(i.version.minor=parseInt(e[1],10)),e.length>2&&(i.version.build=parseInt(e[2],10))}if(r.platform&&(i[r.platform]=!0),(i.chrome||i.opr||i.safari)&&(i.webkit=!0),i.rv||i.iemobile){i.rv&&delete i.rv;let e="msie";r.browser=e,i[e]=!0}if(i.edge){delete i.edge;let e="msedge";r.browser=e,i[e]=!0}if(i.opr){let e="opera";r.browser=e,i[e]=!0}if(i.safari&&i.android){let e="android";r.browser=e,i[e]=!0}i.name=r.browser,i.platform=r.platform;for(let e in b)b.hasOwnProperty(e)&&delete b[e];Object.assign(b,i)}();var _=b;var w=class extends v{static isSupported(){try{let e=_.msedge&&_.version.minor>=15048,t=!_.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t),i=new self.Headers;if("object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.append(t,e[t])}let o={method:"GET",headers:i,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(let e in this._config.headers)i.append(e,this._config.headers[e]);!1===e.cors&&(o.mode="same-origin"),e.withCredentials&&(o.credentials="include"),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),this._status=y.kConnecting,self.fetch(r.url,o).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=y.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=y.kError,!this._onError)throw new h("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=y.kError,!this._onError)throw e;this._onError(g.EXCEPTION,{code:-1,msg:e.message})})}abort(){this._requestAbort=!0}_pump(e){return e.read().then(t=>{if(t.done)if(null!==this._contentLength&&this._receivedLength<this._contentLength){this._status=y.kError;let e=g.EARLY_EOF,t={code:-1,msg:"Fetch stream meet Early-EOF"};if(!this._onError)throw new h(t.msg);this._onError(e,t)}else this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1);else{if(!0===this._requestAbort)return this._requestAbort=!1,this._status=y.kComplete,e.cancel();this._status=y.kBuffering;let n=t.value.buffer,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),this._pump(e)}}).catch(e=>{if(11===e.code&&_.msedge)return;this._status=y.kError;let t=0,n=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength<this._contentLength)?(t=g.EXCEPTION,n={code:e.code,msg:e.message}):(t=g.EARLY_EOF,n={code:e.code,msg:"Fetch stream meet Early-EOF"}),!this._onError)throw new h(n.msg);this._onError(t,n)})}};var S=class extends v{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return u.w("MozChunkedLoader",e.message),!1}}constructor(e,t){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t);this._requestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="moz-chunked-arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onloadend=this._onLoadEnd.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}this._status=y.kConnecting,i.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=y.kComplete}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){let e=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(e)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=y.kError,!this._onError)throw new h("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=y.kBuffering}}_onProgress(e){if(this._status===y.kError)return;null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let t=e.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==y.kError&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&e.loaded<this._contentLength?(t=g.EARLY_EOF,n={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=g.EXCEPTION,n={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new h(n.msg);this._onError(t,n)}};var k=class extends v{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return u.w("RangeLoader",e.message),!1}}constructor(e,t){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=e,this._config=t,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new d,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(e,t){this._dataSource=e,this._range=t,this._status=y.kConnecting;let n=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(n=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||n?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}_openSubRange(){let e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,n=t+e;null!=this._contentLength&&n-this._range.from>=this._contentLength&&(n=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let n=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?n=this._currentRedirectedURL:null!=e.redirectedURL&&(n=e.redirectedURL));let r=this._seekHandler.getConfig(n,t);this._currentRequestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onload=this._onLoad.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}i.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=y.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL){let e=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&e!==this._currentRedirectedURL&&(this._currentRedirectedURL=e,this._onURLRedirect&&this._onURLRedirect(e))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=y.kBuffering}else{if(this._status=y.kError,!this._onError)throw new h("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===y.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let n=e.total;this._internalAbort(),null!=n&0!==n&&(this._totalLength=n)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let t=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(t)}_normalizeSpeed(e){let t=this._chunkSizeKBList,n=t.length-1,r=0,i=0,o=n;if(e<t[0])return t[0];for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>=t[r]&&e<t[r+1])return t[r];t[r]<e?i=r+1:o=r-1}}_onLoad(e){if(this._status===y.kError)return;if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;let t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;let i=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():i=!0,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),i&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=g.EARLY_EOF,n={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=g.EXCEPTION,n={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new h(n.msg);this._onError(t,n)}};var E=class extends v{static isSupported(){try{return void 0!==self.WebSocket}catch(e){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(e){try{let t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=y.kConnecting}catch(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}abort(){let e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=y.kComplete}_onWebSocketOpen(e){this._status=y.kBuffering}_onWebSocketClose(e){!0!==this._requestAbort?(this._status=y.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1}_onWebSocketMessage(e){if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){let t=new FileReader;t.onload=()=>{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=y.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,n=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onWebSocketError(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}};var A=class{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let n={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,n.Range=e}else this._zeroStart&&(n.Range="bytes=0-");return{url:e,headers:n}}removeURLParameters(e){return e}};var x=class{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let n=e;if(0!==t.from||-1!==t.to){let e=!0;-1===n.indexOf("?")&&(n+="?",e=!1),e&&(n+="&"),n+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(n+=`&${this._endName}=${t.to.toString()}`)}return{url:n,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],n=void 0,r=e.indexOf("?");-1!==r&&(n=e.substring(r+1));let i="";if(null!=n&&n.length>0){let e=n.split("&");for(let t=0;t<e.length;t++){let n=e[t].split("="),r=t>0;n[0]!==this._startName&&n[0]!==this._endName&&(r&&(i+="&"),i+=e[t])}}return 0===i.length?t:t+"?"+i}};var T=class{constructor(e,t,n){this.TAG="IOController",this._config=t,this._extraData=n,this._stashInitialSize=393216,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new d,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===k?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new A(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",n=e.seekParamEnd||"bend";this._seekHandler=new x(t,n)}else{if("custom"!==e.seekType)throw new f("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new f("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=E;else if(w.isSupported())this._loaderClass=w;else if(S.isSupported())this._loaderClass=S;else{if(!k.isSupported())throw new h("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=k}}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let n={from:e,to:-1};this._currentRange={from:n.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,n),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new f("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+1048576<e;)t*=2;if(t+=1048576,t===this._bufferSize)return;let n=new ArrayBuffer(t);if(this._stashUsed>0){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(n,0,t).set(e,0)}this._stashBuffer=n,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,n=t.length-1,r=0,i=0,o=n;if(e<t[0])return t[0];for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>=t[r]&&e<t[r+1])return t[r];t[r]<e?i=r+1:o=r-1}}_adjustStashSize(e){let t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let n=1024*t+1048576;this._bufferSize<n&&this._expandBuffer(n),this._stashSize=1024*t}_dispatchChunks(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}_onURLRedirect(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)}_onContentLengthKnown(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)}_onLoaderChunkArrival(e,t,n){if(!this._onDataArrival)throw new p("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);let r=this._speedSampler.lastSecondKBps;if(0!==r){let e=this._normalizeSpeed(r);this._speedNormalized!==e&&(this._speedNormalized=e,this._adjustStashSize(e))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){new Uint8Array(this._stashBuffer,0,this._stashSize).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let n=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart);if(r<t.byteLength){if(r>0){let e=new Uint8Array(t,r);n.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=r}}else this._stashUsed=0,this._stashByteStart+=r;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let r=this._dispatchChunks(e,t);if(r<e.byteLength){let i=e.byteLength-r;i>this._bufferSize&&(this._expandBuffer(i),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e,r),0),this._stashUsed+=i,this._stashByteStart=t+r}}}else if(0===this._stashUsed){let n=this._dispatchChunks(e,t);if(n<e.byteLength){let r=e.byteLength-n;r>this._bufferSize&&this._expandBuffer(r),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(e,n),0),this._stashUsed+=r,this._stashByteStart=t+n}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let n=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(n<this._stashUsed&&n>0){let e=new Uint8Array(this._stashBuffer,n);t.set(e,0)}this._stashUsed-=n,this._stashByteStart+=n}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart),r=t.byteLength-n;if(n<t.byteLength){if(!e){if(n>0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),r=new Uint8Array(t,n);e.set(r,0),this._stashUsed=r.byteLength,this._stashByteStart+=n}return 0}u.w(this.TAG,r+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,r}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(u.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=g.UNRECOVERABLE_EARLY_EOF),e){case g.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e<this._totalLength&&(u.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(e,!1)))}e=g.UNRECOVERABLE_EARLY_EOF}if(!this._onError)throw new h("IOException: "+t.msg);this._onError(e,t)}};const R={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function C(){return Object.assign({},R)}class M{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let e=new T({},C()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t}static getNetworkLoaderTypeName(){let e=new T({},C()),t=e.loaderType;return e.destroy(),t}static supportNativeMediaPlayback(e){null==M.videoElement&&(M.videoElement=window.document.createElement("video"));let t=M.videoElement.canPlayType(e);return"probably"===t||"maybe"==t}static getFeatureList(){let e={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return e.mseFlvPlayback=M.supportMSEH264Playback(),e.networkStreamIO=M.supportNetworkStreamIO(),e.networkLoaderName=M.getNetworkLoaderTypeName(),e.mseLiveFlvPlayback=e.mseFlvPlayback&&e.networkStreamIO,e.nativeMP4H264Playback=M.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),e.nativeWebmVP8Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),e.nativeWebmVP9Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp9"'),e}}var L=M;var O={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};class I{static get forceGlobalTag(){return u.FORCE_GLOBAL_TAG}static set forceGlobalTag(e){u.FORCE_GLOBAL_TAG=e,I._notifyChange()}static get globalTag(){return u.GLOBAL_TAG}static set globalTag(e){u.GLOBAL_TAG=e,I._notifyChange()}static get enableAll(){return u.ENABLE_VERBOSE&&u.ENABLE_DEBUG&&u.ENABLE_INFO&&u.ENABLE_WARN&&u.ENABLE_ERROR}static set enableAll(e){u.ENABLE_VERBOSE=e,u.ENABLE_DEBUG=e,u.ENABLE_INFO=e,u.ENABLE_WARN=e,u.ENABLE_ERROR=e,I._notifyChange()}static get enableDebug(){return u.ENABLE_DEBUG}static set enableDebug(e){u.ENABLE_DEBUG=e,I._notifyChange()}static get enableVerbose(){return u.ENABLE_VERBOSE}static set enableVerbose(e){u.ENABLE_VERBOSE=e,I._notifyChange()}static get enableInfo(){return u.ENABLE_INFO}static set enableInfo(e){u.ENABLE_INFO=e,I._notifyChange()}static get enableWarn(){return u.ENABLE_WARN}static set enableWarn(e){u.ENABLE_WARN=e,I._notifyChange()}static get enableError(){return u.ENABLE_ERROR}static set enableError(e){u.ENABLE_ERROR=e,I._notifyChange()}static getConfig(){return{globalTag:u.GLOBAL_TAG,forceGlobalTag:u.FORCE_GLOBAL_TAG,enableVerbose:u.ENABLE_VERBOSE,enableDebug:u.ENABLE_DEBUG,enableInfo:u.ENABLE_INFO,enableWarn:u.ENABLE_WARN,enableError:u.ENABLE_ERROR,enableCallback:u.ENABLE_CALLBACK}}static applyConfig(e){u.GLOBAL_TAG=e.globalTag,u.FORCE_GLOBAL_TAG=e.forceGlobalTag,u.ENABLE_VERBOSE=e.enableVerbose,u.ENABLE_DEBUG=e.enableDebug,u.ENABLE_INFO=e.enableInfo,u.ENABLE_WARN=e.enableWarn,u.ENABLE_ERROR=e.enableError,u.ENABLE_CALLBACK=e.enableCallback}static _notifyChange(){let e=I.emitter;if(e.listenerCount("change")>0){let t=I.getConfig();e.emit("change",t)}}static registerListener(e){I.emitter.addListener("change",e)}static removeListener(e){I.emitter.removeListener("change",e)}static addLogListener(e){u.emitter.addListener("log",e),u.emitter.listenerCount("log")>0&&(u.ENABLE_CALLBACK=!0,I._notifyChange())}static removeLogListener(e){u.emitter.removeListener("log",e),0===u.emitter.listenerCount("log")&&(u.ENABLE_CALLBACK=!1,I._notifyChange())}}I.emitter=new l.a;var D=I;var P=class{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,n=this._search(t.times,e);return{index:n,milliseconds:t.times[n],fileposition:t.filepositions[n]}}_search(e,t){let n=0,r=e.length-1,i=0,o=0,a=r;for(t<e[0]&&(n=0,o=a+1);o<=a;){if(i=o+Math.floor((a-o)/2),i===r||t>=e[i]&&t<e[i+1]){n=i;break}e[i]<t?o=i+1:a=i-1}return n}};function B(e,t,n){let r=e;if(t+n<r.length){for(;n--;)if(128!=(192&r[++t]))return!1;return!0}return!1}var U=function(e){let t=[],n=e,r=0,i=e.length;for(;r<i;)if(n[r]<128)t.push(String.fromCharCode(n[r])),++r;else{if(n[r]<192);else if(n[r]<224){if(B(n,r,1)){let e=(31&n[r])<<6|63&n[r+1];if(e>=128){t.push(String.fromCharCode(65535&e)),r+=2;continue}}}else if(n[r]<240){if(B(n,r,2)){let e=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),r+=3;continue}}}else if(n[r]<248&&B(n,r,3)){let e=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")};let N=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class F{static parseScriptData(e,t,n){let r={};try{let i=F.parseValue(e,t,n),o=F.parseValue(e,t+i.size,n-i.size);r[i.data]=o.data}catch(e){u.e("AMF",e.toString())}return r}static parseObject(e,t,n){if(n<3)throw new p("Data not enough when parse ScriptDataObject");let r=F.parseString(e,t,n),i=F.parseValue(e,t+r.size,n-r.size),o=i.objectEnd;return{data:{name:r.data,value:i.data},size:r.size+i.size,objectEnd:o}}static parseVariable(e,t,n){return F.parseObject(e,t,n)}static parseString(e,t,n){if(n<2)throw new p("Data not enough when parse String");let r,i=new DataView(e,t,n).getUint16(0,!N);return r=i>0?U(new Uint8Array(e,t+2,i)):"",{data:r,size:2+i}}static parseLongString(e,t,n){if(n<4)throw new p("Data not enough when parse LongString");let r,i=new DataView(e,t,n).getUint32(0,!N);return r=i>0?U(new Uint8Array(e,t+4,i)):"",{data:r,size:4+i}}static parseDate(e,t,n){if(n<10)throw new p("Data size invalid when parse Date");let r=new DataView(e,t,n),i=r.getFloat64(0,!N);return i+=60*r.getInt16(8,!N)*1e3,{data:new Date(i),size:10}}static parseValue(e,t,n){if(n<1)throw new p("Data not enough when parse Value");let r,i=new DataView(e,t,n),o=1,a=i.getUint8(0),s=!1;try{switch(a){case 0:r=i.getFloat64(1,!N),o+=8;break;case 1:r=!!i.getUint8(1),o+=1;break;case 2:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}case 3:{r={};let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o<n-4;){let i=F.parseObject(e,t+o,n-o-a);if(i.objectEnd)break;r[i.data.name]=i.data.value,o+=i.size}if(o<=n-3){9===(16777215&i.getUint32(o-1,!N))&&(o+=3)}break}case 8:{r={},o+=4;let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o<n-8;){let i=F.parseVariable(e,t+o,n-o-a);if(i.objectEnd)break;r[i.data.name]=i.data.value,o+=i.size}if(o<=n-3){9===(16777215&i.getUint32(o-1,!N))&&(o+=3)}break}case 9:r=void 0,o=1,s=!0;break;case 10:{r=[];let a=i.getUint32(1,!N);o+=4;for(let i=0;i<a;i++){let i=F.parseValue(e,t+o,n-o);r.push(i.data),o+=i.size}break}case 11:{let i=F.parseDate(e,t+1,n-1);r=i.data,o+=i.size;break}case 12:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}default:o=n,u.w("AMF","Unsupported AMF value type "+a)}}catch(e){u.e("AMF",e.toString())}return{data:r,size:o,objectEnd:s}}}var q=F;var j=class{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)throw new p("ExpGolomb: _fillCurrentWord() but no bytes available");let t=Math.min(4,e),n=new Uint8Array(4);n.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(n.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32)throw new f("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let n=e-this._current_word_bits_left;this._fillCurrentWord();let r=Math.min(n,this._current_word_bits_left),i=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,t=t<<r|i,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(0!=(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}};class V{static _ebsp2rbsp(e){let t=e,n=t.byteLength,r=new Uint8Array(n),i=0;for(let e=0;e<n;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[i]=t[e],i++);return new Uint8Array(r.buffer,0,i)}static parseSPS(e){let t=V._ebsp2rbsp(e),n=new j(t);n.readByte();let r=n.readByte();n.readByte();let i=n.readByte();n.readUEG();let o=V.getProfileString(r),a=V.getLevelString(i),s=1,l=420,c=[0,420,422,444],u=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(s=n.readUEG(),3===s&&n.readBits(1),s<=3&&(l=c[s]),u=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool())){let e=3!==s?8:12;for(let t=0;t<e;t++)n.readBool()&&(t<6?V._skipScalingList(n,16):V._skipScalingList(n,64))}n.readUEG();let d=n.readUEG();if(0===d)n.readUEG();else if(1===d){n.readBits(1),n.readSEG(),n.readSEG();let e=n.readUEG();for(let t=0;t<e;t++)n.readSEG()}let h=n.readUEG();n.readBits(1);let p=n.readUEG(),f=n.readUEG(),m=n.readBits(1);0===m&&n.readBits(1),n.readBits(1);let y=0,g=0,v=0,b=0;n.readBool()&&(y=n.readUEG(),g=n.readUEG(),v=n.readUEG(),b=n.readUEG());let _=1,w=1,S=0,k=!0,E=0,A=0;if(n.readBool()){if(n.readBool()){let e=n.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],r=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(_=t[e-1],w=r[e-1]):255===e&&(_=n.readByte()<<8|n.readByte(),w=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){let e=n.readBits(32),t=n.readBits(32);k=n.readBool(),E=t,A=2*e,S=E/A}}let x=1;1===_&&1===w||(x=_/w);let T=0,R=0;if(0===s)T=1,R=2-m;else{T=3===s?1:2,R=(1===s?2:1)*(2-m)}let C=16*(p+1),M=16*(f+1)*(2-m);C-=(y+g)*T,M-=(v+b)*R;let L=Math.ceil(C*x);return n.destroy(),n=null,{profile_string:o,level_string:a,bit_depth:u,ref_frames:h,chroma_format:l,chroma_format_string:V.getChromaFormatString(l),frame_rate:{fixed:k,fps:S,fps_den:A,fps_num:E},sar_ratio:{width:_,height:w},codec_size:{width:C,height:M},present_size:{width:L,height:M}}}static _skipScalingList(e,t){let n=8,r=8,i=0;for(let o=0;o<t;o++)0!==r&&(i=e.readSEG(),r=(n+i+256)%256),n=0===r?n:r}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var Y=V;var W={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};class z{constructor(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new P,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(e){let t=new Uint8Array(e),n={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return n;let r=(4&t[4])>>>2!=0,i=0!=(1&t[4]),o=(a=t)[s=5]<<24|a[s+1]<<16|a[s+2]<<8|a[s+3];var a,s;return o<9?n:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:r,hasVideoTrack:i}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new P}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new p("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let n=0,r=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;n=z.probe(e).dataOffset}if(this._firstParse){this._firstParse=!1,t+n!==this._dataOffset&&u.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==new DataView(e,n).getUint32(0,!r)&&u.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4}for(;n<e.byteLength;){this._dispatch=!0;let i=new DataView(e,n);if(n+11+4>e.byteLength)break;let o=i.getUint8(0),a=16777215&i.getUint32(0,!r);if(n+11+a+4>e.byteLength)break;if(8!==o&&9!==o&&18!==o){u.w(this.TAG,`Unsupported tag type ${o}, skipped`),n+=11+a+4;continue}let s=i.getUint8(4),l=i.getUint8(5),c=i.getUint8(6)|l<<8|s<<16|i.getUint8(7)<<24;0!==(16777215&i.getUint32(7,!r))&&u.w(this.TAG,"Meet tag which has StreamID != 0!");let d=n+11;switch(o){case 8:this._parseAudioData(e,d,a,c);break;case 9:this._parseVideoData(e,d,a,c,t+n);break;case 18:this._parseScriptData(e,d,a)}let h=i.getUint32(11+a,!r);h!==11+a&&u.w(this.TAG,"Invalid PrevTagSize "+h),n+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n}_parseScriptData(e,t,n){let r=q.parseScriptData(e,t,n);if(r.hasOwnProperty("onMetaData")){if(null==r.onMetaData||"object"!=typeof r.onMetaData)return void u.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&u.w(this.TAG,"Found another onMetaData tag!"),this._metadata=r;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"==typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"==typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"==typeof e.width&&(this._mediaInfo.width=e.width),"number"==typeof e.height&&(this._mediaInfo.height=e.height),"number"==typeof e.duration){if(!this._durationOverrided){let t=Math.floor(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}}else this._mediaInfo.duration=0;if("number"==typeof e.framerate){let t=Math.floor(1e3*e.framerate);if(t>0){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"==typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,u.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(r).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},r))}_parseKeyframesIndex(e){let t=[],n=[];for(let r=1;r<e.times.length;r++){let i=this._timestampBase+Math.floor(1e3*e.times[r]);t.push(i),n.push(e.filepositions[r])}return{times:t,filepositions:n}}_parseAudioData(e,t,n,r){if(n<=1)return void u.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0===this._hasAudioFlagOverrided&&!1===this._hasAudio)return;this._littleEndian;let i=new DataView(e,t,n).getUint8(0),o=i>>>4;if(2!==o&&10!==o)return void this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+o);let a=0,s=(12&i)>>>2;if(!(s>=0&&s<=4))return void this._onError(W.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+s);a=this._flvSoundRateTable[s];let l=1&i,c=this._audioMetadata,d=this._audioTrack;if(c||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),c=this._audioMetadata={},c.type="audio",c.id=d.id,c.timescale=this._timescale,c.duration=this._duration,c.audioSampleRate=a,c.channelCount=0===l?1:2),10===o){let i=this._parseAACAudioData(e,t+1,n-1);if(null==i)return;if(0===i.packetType){c.config&&u.w(this.TAG,"Found another AudioSpecificConfig!");let e=i.data;c.audioSampleRate=e.samplingRate,c.channelCount=e.channelCount,c.codec=e.codec,c.originalCodec=e.originalCodec,c.config=e.config,c.refSampleDuration=1024/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",c);let t=this._mediaInfo;t.audioCodec=c.originalCodec,t.audioSampleRate=c.audioSampleRate,t.audioChannelCount=c.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===i.packetType){let e=this._timestampBase+r,t={unit:i.data,length:i.data.byteLength,dts:e,pts:e};d.samples.push(t),d.length+=i.data.length}else u.e(this.TAG,"Flv: Unsupported AAC data type "+i.packetType)}else if(2===o){if(!c.codec){let r=this._parseMP3AudioData(e,t+1,n-1,!0);if(null==r)return;c.audioSampleRate=r.samplingRate,c.channelCount=r.channelCount,c.codec=r.codec,c.originalCodec=r.originalCodec,c.refSampleDuration=1152/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",c);let i=this._mediaInfo;i.audioCodec=c.codec,i.audioSampleRate=c.audioSampleRate,i.audioChannelCount=c.channelCount,i.audioDataRate=r.bitRate,i.hasVideo?null!=i.videoCodec&&(i.mimeType='video/x-flv; codecs="'+i.videoCodec+","+i.audioCodec+'"'):i.mimeType='video/x-flv; codecs="'+i.audioCodec+'"',i.isComplete()&&this._onMediaInfo(i)}let i=this._parseMP3AudioData(e,t+1,n-1,!1);if(null==i)return;let o=this._timestampBase+r,a={unit:i,length:i.byteLength,dts:o,pts:o};d.samples.push(a),d.length+=i.length}}_parseAACAudioData(e,t,n){if(n<=1)return void u.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let r={},i=new Uint8Array(e,t,n);return r.packetType=i[0],0===i[0]?r.data=this._parseAACAudioSpecificConfig(e,t+1,n-1):r.data=i.subarray(1),r}_parseAACAudioSpecificConfig(e,t,n){let r=new Uint8Array(e,t,n),i=null,o=0,a=0,s=null,l=0,c=null;if(o=a=r[0]>>>3,l=(7&r[0])<<1|r[1]>>>7,l<0||l>=this._mpegSamplingRates.length)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let u=this._mpegSamplingRates[l],d=(120&r[1])>>>3;if(d<0||d>=8)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===o&&(c=(7&r[1])<<1|r[2]>>>7,s=(124&r[2])>>>2);let h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?l>=6?(o=5,i=new Array(4),c=l-3):(o=2,i=new Array(2),c=l):-1!==h.indexOf("android")?(o=2,i=new Array(2),c=l):(o=5,c=l,i=new Array(4),l>=6?c=l-3:1===d&&(o=2,i=new Array(2),c=l)),i[0]=o<<3,i[0]|=(15&l)>>>1,i[1]=(15&l)<<7,i[1]|=(15&d)<<3,5===o&&(i[1]|=(15&c)>>>1,i[2]=(1&c)<<7,i[2]|=8,i[3]=0),{config:i,samplingRate:u,channelCount:d,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,n,r){if(n<4)return void u.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let i=new Uint8Array(e,t,n),o=null;if(r){if(255!==i[0])return;let e=i[1]>>>3&3,t=(6&i[1])>>1,n=(240&i[2])>>>4,r=(12&i[2])>>>2,a=3!==(i[3]>>>6&3)?2:1,s=0,l=0,c=34,u="mp3";switch(e){case 0:s=this._mpegAudioV25SampleRateTable[r];break;case 2:s=this._mpegAudioV20SampleRateTable[r];break;case 3:s=this._mpegAudioV10SampleRateTable[r]}switch(t){case 1:c=34,n<this._mpegAudioL3BitRateTable.length&&(l=this._mpegAudioL3BitRateTable[n]);break;case 2:c=33,n<this._mpegAudioL2BitRateTable.length&&(l=this._mpegAudioL2BitRateTable[n]);break;case 3:c=32,n<this._mpegAudioL1BitRateTable.length&&(l=this._mpegAudioL1BitRateTable[n])}o={bitRate:l,samplingRate:s,channelCount:a,codec:u,originalCodec:u}}else o=i;return o}_parseVideoData(e,t,n,r,i){if(n<=1)return void u.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0===this._hasVideoFlagOverrided&&!1===this._hasVideo)return;let o=new Uint8Array(e,t,n)[0],a=(240&o)>>>4,s=15&o;7===s?this._parseAVCVideoPacket(e,t+1,n-1,r,i,a):this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+s)}_parseAVCVideoPacket(e,t,n,r,i,o){if(n<4)return void u.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,s=new DataView(e,t,n),l=s.getUint8(0),c=(16777215&s.getUint32(0,!a))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,n-4);else if(1===l)this._parseAVCVideoData(e,t+4,n-4,r,i,o,c);else if(2!==l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,n){if(n<7)return void u.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let r=this._videoMetadata,i=this._videoTrack,o=this._littleEndian,a=new DataView(e,t,n);r?void 0!==r.avcc&&u.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),r=this._videoMetadata={},r.type="video",r.id=i.id,r.timescale=this._timescale,r.duration=this._duration);let s=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==s||0===l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(W.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let c=31&a.getUint8(5);if(0===c)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");c>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+c);let d=6;for(let n=0;n<c;n++){let i=a.getUint16(d,!o);if(d+=2,0===i)continue;let s=new Uint8Array(e,t+d,i);d+=i;let l=Y.parseSPS(s);if(0!==n)continue;r.codecWidth=l.codec_size.width,r.codecHeight=l.codec_size.height,r.presentWidth=l.present_size.width,r.presentHeight=l.present_size.height,r.profile=l.profile_string,r.level=l.level_string,r.bitDepth=l.bit_depth,r.chromaFormat=l.chroma_format,r.sarRatio=l.sar_ratio,r.frameRate=l.frame_rate,!1!==l.frame_rate.fixed&&0!==l.frame_rate.fps_num&&0!==l.frame_rate.fps_den||(r.frameRate=this._referenceFrameRate);let c=r.frameRate.fps_den,u=r.frameRate.fps_num;r.refSampleDuration=r.timescale*(c/u);let h=s.subarray(1,4),p="avc1.";for(let e=0;e<3;e++){let t=h[e].toString(16);t.length<2&&(t="0"+t),p+=t}r.codec=p;let f=this._mediaInfo;f.width=r.codecWidth,f.height=r.codecHeight,f.fps=r.frameRate.fps,f.profile=r.profile,f.level=r.level,f.refFrames=l.ref_frames,f.chromaFormat=l.chroma_format_string,f.sarNum=r.sarRatio.width,f.sarDen=r.sarRatio.height,f.videoCodec=p,f.hasAudio?null!=f.audioCodec&&(f.mimeType='video/x-flv; codecs="'+f.videoCodec+","+f.audioCodec+'"'):f.mimeType='video/x-flv; codecs="'+f.videoCodec+'"',f.isComplete()&&this._onMediaInfo(f)}let h=a.getUint8(d);if(0!==h){h>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+h),d++;for(let e=0;e<h;e++){let e=a.getUint16(d,!o);d+=2,0!==e&&(d+=e)}r.avcc=new Uint8Array(n),r.avcc.set(new Uint8Array(e,t,n),0),u.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",r)}else this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}_parseAVCVideoData(e,t,n,r,i,o,a){let s=this._littleEndian,l=new DataView(e,t,n),c=[],d=0,h=0;const p=this._naluLengthSize;let f=this._timestampBase+r,m=1===o;for(;h<n;){if(h+4>=n){u.w(this.TAG,`Malformed Nalu near timestamp ${f}, offset = ${h}, dataSize = ${n}`);break}let r=l.getUint32(h,!s);if(3===p&&(r>>>=8),r>n-p)return void u.w(this.TAG,`Malformed Nalus near timestamp ${f}, NaluSize > DataSize!`);let i=31&l.getUint8(h+p);5===i&&(m=!0);let o=new Uint8Array(e,t+h,p+r),a={type:i,data:o};c.push(a),d+=o.byteLength,h+=p+r}if(c.length){let e=this._videoTrack,t={units:c,length:d,isKeyframe:m,dts:f,cts:a,pts:f+a};m&&(t.fileposition=i),e.samples.push(t),e.length+=d}}}var H=z;class G{static init(){G.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let e in G.types)G.types.hasOwnProperty(e)&&(G.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=G.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_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]),e.HDLR_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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,n=null,r=Array.prototype.slice.call(arguments,1),i=r.length;for(let e=0;e<i;e++)t+=r[e].byteLength;n=new Uint8Array(t),n[0]=t>>>24&255,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n.set(e,4);let o=8;for(let e=0;e<i;e++)n.set(r[e],o),o+=r[e].byteLength;return n}static generateInitSegment(e){let t=G.box(G.types.ftyp,G.constants.FTYP),n=G.moov(e),r=new Uint8Array(t.byteLength+n.byteLength);return r.set(t,0),r.set(n,t.byteLength),r}static moov(e){let t=G.mvhd(e.timescale,e.duration),n=G.trak(e),r=G.mvex(e);return G.box(G.types.moov,t,n,r)}static mvhd(e,t){return G.box(G.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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]))}static trak(e){return G.box(G.types.trak,G.tkhd(e),G.mdia(e))}static tkhd(e){let t=e.id,n=e.duration,r=e.presentWidth,i=e.presentHeight;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,i>>>8&255,255&i,0,0]))}static mdia(e){return G.box(G.types.mdia,G.mdhd(e),G.hdlr(e),G.minf(e))}static mdhd(e){let t=e.timescale,n=e.duration;return G.box(G.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?G.constants.HDLR_AUDIO:G.constants.HDLR_VIDEO,G.box(G.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?G.box(G.types.smhd,G.constants.SMHD):G.box(G.types.vmhd,G.constants.VMHD),G.box(G.types.minf,t,G.dinf(),G.stbl(e))}static dinf(){return G.box(G.types.dinf,G.box(G.types.dref,G.constants.DREF))}static stbl(e){return G.box(G.types.stbl,G.stsd(e),G.box(G.types.stts,G.constants.STTS),G.box(G.types.stsc,G.constants.STSC),G.box(G.types.stsz,G.constants.STSZ),G.box(G.types.stco,G.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp3(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp4a(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.avc1(e))}static mp3(e){let t=e.channelCount,n=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return G.box(G.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,n=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return G.box(G.types.mp4a,r,G.esds(e))}static esds(e){let t=e.config||[],n=t.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return G.box(G.types.esds,r)}static avc1(e){let t=e.avcc,n=e.codecWidth,r=e.codecHeight,i=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,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return G.box(G.types.avc1,i,G.box(G.types.avcC,t))}static mvex(e){return G.box(G.types.mvex,G.trex(e))}static trex(e){let t=e.id,n=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return G.box(G.types.trex,n)}static moof(e,t){return G.box(G.types.moof,G.mfhd(e.sequenceNumber),G.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return G.box(G.types.mfhd,t)}static traf(e,t){let n=e.id,r=G.box(G.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),i=G.box(G.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),o=G.sdtp(e),a=G.trun(e,o.byteLength+16+16+8+16+8+8);return G.box(G.types.traf,r,i,a,o)}static sdtp(e){let t=e.samples||[],n=t.length,r=new Uint8Array(4+n);for(let e=0;e<n;e++){let n=t[e].flags;r[e+4]=n.isLeading<<6|n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy}return G.box(G.types.sdtp,r)}static trun(e,t){let n=e.samples||[],r=n.length,i=12+16*r,o=new Uint8Array(i);t+=8+i,o.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<r;e++){let t=n[e].duration,r=n[e].size,i=n[e].flags,a=n[e].cts;o.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*e)}return G.box(G.types.trun,o)}static mdat(e){return G.box(G.types.mdat,e)}}G.init();var K=G;var Q=class{static getSilentFrame(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])}return null}};class X{constructor(e,t,n,r,i){this.dts=e,this.pts=t,this.duration=n,this.originalDts=r,this.isSyncPoint=i,this.fileposition=null}}class Z{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class J{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))}getLastSyncPointBeforeDts(e){if(0==this._list.length)return null;let t=this._list,n=0,r=t.length-1,i=0,o=0,a=r;for(e<t[0].dts&&(n=0,o=a+1);o<=a;){if(i=o+Math.floor((a-o)/2),i===r||e>=t[i].dts&&e<t[i+1].dts){n=i;break}t[i].dts<e?o=i+1:a=i-1}return this._list[n]}}class ${constructor(e){this._type=e,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return 0===this._list.length}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(e){let t=this._list;if(0===t.length)return-2;let n=t.length-1,r=0,i=0,o=n,a=0;if(e<t[0].originalBeginDts)return a=-1,a;for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>t[r].lastSample.originalDts&&e<t[r+1].originalBeginDts){a=r;break}t[r].originalBeginDts<e?i=r+1:o=r-1}return a}_searchNearestSegmentAfter(e){return this._searchNearestSegmentBefore(e)+1}append(e){let t=this._list,n=e,r=this._lastAppendLocation,i=0;-1!==r&&r<t.length&&n.originalBeginDts>=t[r].lastSample.originalDts&&(r===t.length-1||r<t.length-1&&n.originalBeginDts<t[r+1].originalBeginDts)?i=r+1:t.length>0&&(i=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=i,this._list.splice(i,0,n)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),n=this._list[t].syncPoints;for(;0===n.length&&t>0;)t--,n=this._list[t].syncPoints;return n.length>0?n[n.length-1]:null}}var ee=class{constructor(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new $("audio"),this._videoSegmentInfoList=new $("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!_.chrome||!(_.version.major<50||50===_.version.major&&_.version.build<2661)),this._fillSilentAfterSeek=_.msedge||_.msie,this._mp3UseMpegAudio=!_.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new p("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let n=null,r="mp4",i=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(r="mpeg",i="",n=new Uint8Array):n=K.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,n=K.generateInitSegment(t)}if(!this._onInitSegment)throw new p("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:n.buffer,codec:i,container:`${e}/${r}`,mediaDuration:t.duration})}_calculateDtsBase(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,n={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(n.samples.push(e),n.length=e.length);let r={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(r.samples.push(t),r.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(n,!0),this._remuxAudio(r,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,c=this._dtsBaseInited&&void 0===this._audioNextDts,d=!1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let h=0,p=null,f=0;l?(h=0,f=n.length):(h=8,f=8+n.length);let m=null;if(r.length>1&&(m=r.pop(),f-=m.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(e),f+=e.length}null!=m&&(this._audioStashedLastSample=m);let y=r[0].dts-this._dtsBase;if(this._audioNextDts)i=y-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())i=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(d=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(y);if(null!=e){let t=y-(e.originalDts+e.duration);t<=3&&(t=0),i=y-(e.dts+e.duration+t)}else i=0}if(d){let e=y-i,t=this._videoSegmentInfoList.getLastSegmentBefore(y);if(null!=t&&t.beginDts<e){let n=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(n){let i=t.beginDts,o=e-t.beginDts;u.v(this.TAG,`InsertPrefixSilentAudio: dts: ${i}, duration: ${o}`),r.unshift({unit:n,dts:i,pts:i}),f+=n.byteLength}}else d=!1}let g=[];for(let e=0;e<r.length;e++){let t=r[e],n=t.unit,a=t.dts-this._dtsBase,l=a-i;-1===o&&(o=l);let c=0;if(e!==r.length-1){c=r[e+1].dts-this._dtsBase-i-l}else if(null!=m){c=m.dts-this._dtsBase-i-l}else c=g.length>=1?g[g.length-1].duration:Math.floor(s);let d=!1,h=null;if(c>1.5*s&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!_.safari){d=!0;let e=Math.abs(c-s),t=Math.ceil(e/s),r=l+s;u.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${l+c} ms, expected: ${l+Math.round(s)} ms, delta: ${Math.round(e)} ms, generate: ${t} frames`);let i=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==i&&(u.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),i=n),h=[];for(let e=0;e<t;e++){let e=Math.round(r);if(h.length>0){let t=h[h.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:i,size:i.byteLength,duration:0,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};h.push(t),f+=t.size,r+=s}let o=h[h.length-1];o.duration=l+c-o.dts,c=Math.round(s)}g.push({dts:l,pts:l,cts:0,unit:t.unit,size:t.unit.byteLength,duration:c,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,h)}l?p=new Uint8Array(f):(p=new Uint8Array(f),p[0]=f>>>24&255,p[1]=f>>>16&255,p[2]=f>>>8&255,p[3]=255&f,p.set(K.types.mdat,4));for(let e=0;e<g.length;e++){let t=g[e].unit;p.set(t,h),h+=t.byteLength}let v=g[g.length-1];a=v.dts+v.duration,this._audioNextDts=a;let b=new Z;b.beginDts=o,b.endDts=a,b.beginPts=o,b.endPts=a,b.originalBeginDts=g[0].originalDts,b.originalEndDts=v.originalDts+v.duration,b.firstSample=new X(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,!1),b.lastSample=new X(v.dts,v.pts,v.duration,v.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(b),n.samples=g,n.sequenceNumber++;let w=null;w=l?new Uint8Array:K.moof(n,o),n.samples=[],n.length=0;let S={type:"audio",data:this._mergeBoxes(w,p).buffer,sampleCount:g.length,info:b};l&&c&&(S.timestampOffset=o),this._onMediaSegment("audio",S)}_remuxVideo(e,t){if(null==this._videoMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=-1,l=-1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let c=8,u=null,d=8+e.length,h=null;if(r.length>1&&(h=r.pop(),d-=h.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,r.unshift(e),d+=e.length}null!=h&&(this._videoStashedLastSample=h);let p=r[0].dts-this._dtsBase;if(this._videoNextDts)i=p-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())i=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0),i=p-(e.dts+e.duration+t)}else i=0}let f=new Z,m=[];for(let e=0;e<r.length;e++){let t=r[e],n=t.dts-this._dtsBase,a=t.isKeyframe,l=n-i,c=t.cts,u=l+c;-1===o&&(o=l,s=u);let d=0;if(e!==r.length-1){d=r[e+1].dts-this._dtsBase-i-l}else if(null!=h){d=h.dts-this._dtsBase-i-l}else d=m.length>=1?m[m.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(a){let e=new X(l,u,d,t.dts,!0);e.fileposition=t.fileposition,f.appendSyncPoint(e)}m.push({dts:l,pts:u,cts:c,units:t.units,size:t.length,isKeyframe:a,duration:d,originalDts:n,flags:{isLeading:0,dependsOn:a?2:1,isDependedOn:a?1:0,hasRedundancy:0,isNonSync:a?0:1}})}u=new Uint8Array(d),u[0]=d>>>24&255,u[1]=d>>>16&255,u[2]=d>>>8&255,u[3]=255&d,u.set(K.types.mdat,4);for(let e=0;e<m.length;e++){let t=m[e].units;for(;t.length;){let e=t.shift().data;u.set(e,c),c+=e.byteLength}}let y=m[m.length-1];if(a=y.dts+y.duration,l=y.pts+y.duration,this._videoNextDts=a,f.beginDts=o,f.endDts=a,f.beginPts=s,f.endPts=l,f.originalBeginDts=m[0].originalDts,f.originalEndDts=y.originalDts+y.duration,f.firstSample=new X(m[0].dts,m[0].pts,m[0].duration,m[0].originalDts,m[0].isKeyframe),f.lastSample=new X(y.dts,y.pts,y.duration,y.originalDts,y.isKeyframe),this._isLive||this._videoSegmentInfoList.append(f),n.samples=m,n.sequenceNumber++,this._forceFirstIDR){let e=m[0].flags;e.dependsOn=2,e.isNonSync=0}let g=K.moof(n,o);n.samples=[],n.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(g,u).buffer,sampleCount:m.length,info:f})}_mergeBoxes(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}};var te={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};var ne=class{constructor(e,t){this.TAG="TransmuxingController",this._emitter=new l.a,this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;let n=0;this._mediaDataSource.segments.forEach(r=>{r.timestampBase=n,n+=r.duration,r.cors=e.cors,r.withCredentials=e.withCredentials,t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy)}),isNaN(n)||this._mediaDataSource.duration===n||(this._mediaDataSource.duration=n),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let n=this._mediaDataSource.segments[e],r=this._ioctl=new T(n,this._config,e);r.onError=this._onIOException.bind(this),r.onSeeked=this._onIOSeeked.bind(this),r.onComplete=this._onIOComplete.bind(this),r.onRedirect=this._onIORedirect.bind(this),r.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):r.onDataArrival=this._onInitChunkArrival.bind(this),r.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e;else{let t=n.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let r=n.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,r.fileposition),this._pendingResolveSeekPoint=r.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,n=t.length-1;for(let r=0;r<t.length;r++)if(e<t[r].timestampBase){n=r-1;break}return n}_onInitChunkArrival(e,t){let n=null,r=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=H.probe(e)).match){this._demuxer=new H(n,this._config),this._remuxer||(this._remuxer=new ee(this._config));let i=this._mediaDataSource;null==i.duration||isNaN(i.duration)||(this._demuxer.overridedDuration=i.duration),"boolean"==typeof i.hasAudio&&(this._demuxer.overridedHasAudio=i.hasAudio),"boolean"==typeof i.hasVideo&&(this._demuxer.overridedHasVideo=i.hasVideo),this._demuxer.timestampBase=i.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,u.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(te.DEMUX_ERROR,W.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}_onMediaInfo(e){null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,P.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,P.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(te.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer.flushStashedSamples(),this._emitter.emit(te.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(e){let t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e}_onIORecoveredEarlyEof(){this._emitter.emit(te.RECOVERED_EARLY_EOF)}_onIOException(e,t){u.e(this.TAG,`IOException: type = ${e}, code = ${t.code}, msg = ${t.msg}`),this._emitter.emit(te.IO_ERROR,e,t),this._disableStatisticsReporter()}_onDemuxException(e,t){u.e(this.TAG,`DemuxException: type = ${e}, info = ${t}`),this._emitter.emit(te.DEMUX_ERROR,e,t)}_onRemuxerInitSegmentArrival(e,t){this._emitter.emit(te.INIT_SEGMENT,e,t)}_onRemuxerMediaSegmentArrival(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(te.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){let e=t.info.syncPoints,n=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,_.safari&&e.length>0&&e[0].originalDts===n&&(n=e[0].pts),this._emitter.emit(te.RECOMMEND_SEEKPOINT,n)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],n=Object.assign({},t);n.duration=this._mediaInfo.duration,n.segmentCount=this._mediaInfo.segmentCount,delete n.segments,delete n.keyframesIndex,this._emitter.emit(te.MEDIA_INFO,n)}_reportStatisticsInfo(){let e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(te.STATISTICS_INFO,e)}};var re=function(e){let t=null,n=function(t,n){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:n}})}.bind(this);function r(t,n){let r={msg:te.INIT_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function i(t,n){let r={msg:te.MEDIA_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function o(){let t={msg:te.LOADING_COMPLETE};e.postMessage(t)}function s(){let t={msg:te.RECOVERED_EARLY_EOF};e.postMessage(t)}function l(t){let n={msg:te.MEDIA_INFO,data:t};e.postMessage(n)}function c(t){let n={msg:te.METADATA_ARRIVED,data:t};e.postMessage(n)}function u(t){let n={msg:te.SCRIPTDATA_ARRIVED,data:t};e.postMessage(n)}function d(t){let n={msg:te.STATISTICS_INFO,data:t};e.postMessage(n)}function h(t,n){e.postMessage({msg:te.IO_ERROR,data:{type:t,info:n}})}function p(t,n){e.postMessage({msg:te.DEMUX_ERROR,data:{type:t,info:n}})}function f(t){e.postMessage({msg:te.RECOMMEND_SEEKPOINT,data:t})}a.install(),e.addEventListener("message",(function(a){switch(a.data.cmd){case"init":t=new ne(a.data.param[0],a.data.param[1]),t.on(te.IO_ERROR,h.bind(this)),t.on(te.DEMUX_ERROR,p.bind(this)),t.on(te.INIT_SEGMENT,r.bind(this)),t.on(te.MEDIA_SEGMENT,i.bind(this)),t.on(te.LOADING_COMPLETE,o.bind(this)),t.on(te.RECOVERED_EARLY_EOF,s.bind(this)),t.on(te.MEDIA_INFO,l.bind(this)),t.on(te.METADATA_ARRIVED,c.bind(this)),t.on(te.SCRIPTDATA_ARRIVED,u.bind(this)),t.on(te.STATISTICS_INFO,d.bind(this)),t.on(te.RECOMMEND_SEEKPOINT,f.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(a.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=a.data.param;D.applyConfig(e),!0===e.enableCallback?D.addLogListener(n):D.removeLogListener(n);break}}}))};var ie=class{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new l.a,t.enableWorker&&"undefined"!=typeof Worker)try{let r=n(56);this._worker=r(re),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},D.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:D.getConfig()})}catch(n){u.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ne(e,t)}else this._controller=new ne(e,t);if(this._controller){let e=this._controller;e.on(te.IO_ERROR,this._onIOError.bind(this)),e.on(te.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(te.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(te.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(te.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(te.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(te.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(te.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(te.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(te.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(te.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),D.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(te.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(te.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(te.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,n=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case te.INIT_SEGMENT:case te.MEDIA_SEGMENT:this._emitter.emit(t.msg,n.type,n.data);break;case te.LOADING_COMPLETE:case te.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case te.MEDIA_INFO:Object.setPrototypeOf(n,P.prototype),this._emitter.emit(t.msg,n);break;case te.METADATA_ARRIVED:case te.SCRIPTDATA_ARRIVED:case te.STATISTICS_INFO:this._emitter.emit(t.msg,n);break;case te.IO_ERROR:case te.DEMUX_ERROR:this._emitter.emit(t.msg,n.type,n.info);break;case te.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,n);break;case"logcat_callback":u.emitter.emit("log",n.type,n.logcat)}}};var oe={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var ae=class{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new l.a,this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new J}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new p("MediaSource has been attached to an HTMLMediaElement!");let t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let e=this._mediaSource;for(let t in this._sourceBuffers){let n=this._pendingSegments[t];n.splice(0,n.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let r=this._sourceBuffers[t];if(r){if("closed"!==e.readyState){try{e.removeSourceBuffer(r)}catch(e){u.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){u.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let n=e,r=""+n.container;n.codec&&n.codec.length>0&&(r+=";codecs="+n.codec);let i=!1;if(u.v(this.TAG,"Received Initialization Segment, mimeType: "+r),this._lastInitSegments[n.type]=n,r!==this._mimeTypes[n.type]){if(this._mimeTypes[n.type])u.v(this.TAG,`Notice: ${n.type} mimeType changed, origin: ${this._mimeTypes[n.type]}, target: ${r}`);else{i=!0;try{let e=this._sourceBuffers[n.type]=this._mediaSource.addSourceBuffer(r);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.e(this.TAG,e.message),void this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[n.type]=r}t||this._pendingSegments[n.type].push(n),i||this._sourceBuffers[n.type]&&!this._sourceBuffers[n.type].updating&&this._doAppendSegments(),_.safari&&"audio/mpeg"===n.container&&n.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=n.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let n=this._sourceBuffers[t.type];!n||n.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){u.e(this.TAG,e.message)}this._idrList.clear();let n=this._pendingSegments[e];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(let n=0;n<t.buffered.length;n++){let r=t.buffered.start(n),i=t.buffered.end(n);this._pendingRemoveRanges[e].push({start:r,end:i})}if(t.updating||this._doRemoveRanges(),_.safari){let n=this._lastInitSegments[e];n&&(this._pendingSegments[e].push(n),t.updating||this._doAppendSegments())}}}}endOfStream(){let e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)}getNearestKeyframe(e){return this._idrList.getLastSyncPointBeforeDts(e)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let n=this._sourceBuffers[t];if(n){let t=n.buffered;if(t.length>=1&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let n=this._sourceBuffers[t];if(n){let r=n.buffered,i=!1;for(let n=0;n<r.length;n++){let o=r.start(n),a=r.end(n);if(o<=e&&e<a+3){if(e-o>=this._config.autoCleanupMaxBackwardDuration){i=!0;let n=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:o,end:n})}}else a<e&&(i=!0,this._pendingRemoveRanges[t].push({start:o,end:a}))}i&&!n.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let e=this._sourceBuffers;if(0===this._mediaElement.readyState||"open"!==this._mediaSource.readyState)return;if(e.video&&e.video.updating||e.audio&&e.audio.updating)return;let t=this._mediaSource.duration,n=this._pendingMediaDuration;n>0&&(isNaN(t)||n>t)&&(u.v(this.TAG,`Update MediaSource duration from ${t} to ${n}`),this._mediaSource.duration=n),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let e in this._pendingRemoveRanges){if(!this._sourceBuffers[e]||this._sourceBuffers[e].updating)continue;let t=this._sourceBuffers[e],n=this._pendingRemoveRanges[e];for(;n.length&&!t.updating;){let e=n.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){let n=e[t].shift();if(n.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,r=n.timestampOffset/1e3;Math.abs(e-r)>.1&&(u.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${r}`),this._sourceBuffers[t].timestampOffset=r),delete n.timestampOffset}if(!n.data||0===n.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(n.data),this._isBufferFull=!1,"video"===t&&n.hasOwnProperty("info")&&this._idrList.appendArray(n.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(n),22===e.code?(this._isBufferFull||this._emitter.emit(oe.BUFFER_FULL),this._isBufferFull=!0):(u.e(this.TAG,e.message),this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(u.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;for(;e.length;){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(oe.SOURCE_OPEN)}_onSourceEnded(){u.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){u.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let e=this._pendingSegments;return e.video.length>0||e.audio.length>0}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(oe.UPDATE_END)}_onSourceBufferError(e){u.e(this.TAG,"SourceBuffer Error: "+e)}};const se={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},le={NETWORK_EXCEPTION:g.EXCEPTION,NETWORK_STATUS_CODE_INVALID:g.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:g.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:g.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:W.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:W.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:W.CODEC_UNSUPPORTED};var ce=class{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let n=_.chrome&&(_.version.major<50||50===_.version.major&&_.version.build<2661);this._alwaysSeekKeyframe=!!(n||_.msedge||_.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===O.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new ae(this._config),this._msectl.on(oe.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(oe.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(oe.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(oe.ERROR,e=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,le.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new p("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new ie(this._mediaDataSource,this._config),this._transmuxer.on(te.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(te.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(te.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(O.LOADING_COMPLETE)}),this._transmuxer.on(te.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(O.RECOVERED_EARLY_EOF)}),this._transmuxer.on(te.IO_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.NETWORK_ERROR,e,t)}),this._transmuxer.on(te.DEMUX_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(te.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(O.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(te.METADATA_ARRIVED,e=>{this._emitter.emit(O.METADATA_ARRIVED,e)}),this._transmuxer.on(te.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(O.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(te.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(O.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(te.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open()))}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,n=0,r=0;for(let i=0;i<e.length;i++){let o=e.start(i),a=e.end(i);if(o<=t&&t<a){n=o,r=a;break}}r>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){u.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,n=!1;for(let r=0;r<t.length;r++){let i=t.start(r),o=t.end(r);if(e>=i&&e<o){e>=o-this._config.lazyLoadRecoverDuration&&(n=!0);break}}n&&(window.clearInterval(this._progressChecker),this._progressChecker=null,n&&(u.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let n=0;n<t.length;n++){let r=t.start(n),i=t.end(n);if(e>=r&&e<i)return!0}return!1}_internalSeek(e){let t=this._isTimepointBuffered(e),n=!1,r=0;if(e<1&&this._mediaElement.buffered.length>0){let t=this._mediaElement.buffered.start(0);(t<1&&e<t||_.safari)&&(n=!0,r=_.safari?.1:t)}if(n)this._requestSetTime=!0,this._mediaElement.currentTime=r;else if(t){if(this._alwaysSeekKeyframe){let t=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=t?t.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(e){let t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){let e=t.buffered;e.length>0&&t.currentTime<e.start(0)&&(u.w(this.TAG,`Playback seems stuck at ${t.currentTime}, seek to ${e.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=e.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(e){let t=this._mediaElement.currentTime,n=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&n.length>0){let e=n.start(0);if(e<1&&t<e||_.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=_.safari?.1:e)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){let e=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=e&&(this._requestSetTime=!0,this._mediaElement.currentTime=e.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}}_onvCanPlay(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(e){this._checkAndResumeStuckPlayback(!0)}_onvProgress(e){this._checkAndResumeStuckPlayback()}};var ue=class{constructor(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new f("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new f(`NativePlayer(${e.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===O.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new p("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}};a.install();let de={createPlayer:function(e,t){let n=e;if(null==n||"object"!=typeof n)throw new f("MediaDataSource must be an javascript object!");if(!n.hasOwnProperty("type"))throw new f("MediaDataSource must has type field to indicate video file type!");switch(n.type){case"flv":return new ce(n,t);default:return new ue(n,t)}},isSupported:function(){return L.supportMSEH264Playback()},getFeatureList:function(){return L.getFeatureList()}};de.BaseLoader=v,de.LoaderStatus=y,de.LoaderErrors=g,de.Events=O,de.ErrorTypes=se,de.ErrorDetails=le,de.FlvPlayer=ce,de.NativePlayer=ue,de.LoggingControl=D,Object.defineProperty(de,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var he=de,pe=n(4),fe=n.n(pe),me=n(24),ye={insert:"head",singleton:!1};fe()(me.a,ye),me.a.locals;function ge(e){return(ge="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 ve(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function be(e,t){return(be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _e(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==ge(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Se(e){return(Se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ke=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&be(e,t)}(a,e);var t,n,r,o=_e(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1},t}return t=a,(n=[{key:"shouldComponentUpdate",value:function(e){return e.videoUrl!==this.props.videoUrl&&(this.flvPlayer&&this.destroyFlv(),this.startFlv(e.videoUrl),!0)}},{key:"componentDidMount",value:function(){this.props.videoUrl&&this.startFlv(this.props.videoUrl)}},{key:"startFlv",value:function(e){var t=this.state.id;if(he.isSupported()){var n=document.getElementById(t);this.flvPlayer&&this.destroyFlv(),this.flvPlayer=he.createPlayer({type:"flv",isLive:!0,hasAudio:!1,url:e},{enableStashBuffer:!0,stashInitialSize:128}),this.flvPlayer.attachMediaElement(n),this.flvPlayer.load(),this.flvPlayer.play()}else alert("请更换浏览器,该浏览器暂不支持。")}},{key:"destroyFlv",value:function(){this.flvPlayer.pause(),this.flvPlayer.unload(),this.flvPlayer.detachMediaElement(),this.flvPlayer.destroy(),this.flvPlayer=null}},{key:"render",value:function(){return i.a.createElement("div",{className:"flvWai"},i.a.createElement("video",{id:this.state.id,className:"videoFlv",autoPlay:!0,controls:!0,muted:!0}))}}])&&ve(t.prototype,n),r&&ve(t,r),a}(r.Component),Ee=n(25),Ae={insert:"head",singleton:!1},xe=(fe()(Ee.a,Ae),Ee.a.locals,n(51)),Te=n.n(xe);function Re(e){return(Re="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 Ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Le(e,t){return(Le=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=De(e);if(t){var i=De(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ie(this,n)}}function Ie(e,t){return!t||"object"!==Re(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Pe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Le(e,t)}(a,e);var t,n,r,o=Oe(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1,videoUrl:""},t}return t=a,(n=[{key:"shouldComponentUpdate",value:function(e){return!(e.videoUrl===this.props.videoUrl&&this.state.videoUrl||(e.videoUrl&&this.playerFlvVideo(e.videoUrl),0))}},{key:"componentDidMount",value:function(){this.props.videoUrl&&this.playerFlvVideo(this.props.videoUrl)}},{key:"playerFlvVideo",value:function(e){this.setState({videoUrl:e}),this.dp?(this.dp.destroy(),this.flvPlayer.pause(),this.flvPlayer.unload(),this.flvPlayer.detachMediaElement(),this.flvPlayer.destroy(),clearInterval(this.timer),this.timer=null,this.flvPlayer=null,this.dp=null,this.createFlvPlayer(e)):this.createFlvPlayer(e)}},{key:"createFlvPlayer",value:function(e){var t,n=this,r=this.state.id,i=this.props,o=i.autoplay,a=void 0===o||o,s=i.config,l=void 0===s?{}:s,c=i.maxCount,u=void 0===c?5:c,d=i.testingTimer,h=void 0===d?30:d;this.count=0,this.dp=new Te.a({container:document.getElementById(r),screenshot:!0,autoplay:a,airplay:!0,mutex:!1,video:(t={url:e,type:"flv"},Ce(t,"type","customFlv"),Ce(t,"customType",{customFlv:function(e){n.flvPlayer=he.createPlayer({type:"flv",url:e.src},Object.assign({autoCleanupSourceBuffer:!0},l)),n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.timer=setInterval((function(){n.getNewVideo()}),1e3*h),n.flvPlayer.on("error",(function(t){t&&"NetworkError"===t&&(n.count++,parseInt(u)>=n.count?(n.flvPlayer.pause(),n.flvPlayer.unload(),n.flvPlayer.detachMediaElement(),setTimeout((function(){n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.flvPlayer.play()}),500)):(clearInterval(n.timer),n.timer=null,console.log("重连失败")))}))}}),t)})}},{key:"componentWillUnmount",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"getNewVideo",value:function(){var e=this.state.id,t=document.getElementById(e).getElementsByTagName("video")[0];if(t)for(var n=t.buffered,r=0;r<n.length;r++){var i=n.end(r);i>-1&&(t.currentTime=i-.1)}}},{key:"render",value:function(){var e=this.state.id;return i.a.createElement("div",{className:"dplayerWaikuang"},i.a.createElement("div",{id:e,style:{width:"100%",height:"100%"}}))}}])&&Me(t.prototype,n),r&&Me(t,r),a}(r.Component),Be=n(17),Ue=n(26),Ne={insert:"head",singleton:!1};fe()(Ue.a,Ne),Ue.a.locals;function Fe(e){return(Fe="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 qe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function je(e,t){return(je=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=We(e);if(t){var i=We(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ye(this,n)}}function Ye(e,t){return!t||"object"!==Fe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function We(e){return(We=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ze=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&je(e,t)}(a,e);var t,n,r,o=Ve(a);function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this)).state={showDateTime:"",classInfo:""},e}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.className;return n!==t.className?{classInfo:n}:null}}],(n=[{key:"forShowDateTime",value:function(){var e=this.props.type,t=void 0===e?"YYYY-MM-DD HH:mm:ss":e;this.setState({showDateTime:Object(Be.a)().format(t)})}},{key:"componentDidMount",value:function(){var e=this;this.forShowDateTime(),this.timer=setInterval((function(){e.forShowDateTime()}),1e3)}},{key:"render",value:function(){var e=this.state,t=e.classInfo,n=e.showDateTime;return i.a.createElement("div",{className:"timerComCss"},i.a.createElement("p",{className:t},n))}}])&&qe(t.prototype,n),r&&qe(t,r),a}(r.Component),He=n(27),Ge={insert:"head",singleton:!1};fe()(He.a,Ge),He.a.locals;function Ke(e){return(Ke="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 Qe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Xe(e,t){return(Xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=$e(e);if(t){var i=$e(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Je(this,n)}}function Je(e,t){return!t||"object"!==Ke(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function $e(e){return($e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var et=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Xe(e,t)}(s,e);var t,r,o,a=Ze(s);function s(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(e=a.call(this)).state={imgUrl:"",httpImg:"",base64Url:""},e}return t=s,o=[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.httpImg,r=e.imgUrl;return n&&n!==t.httpImg?{httpImg:n,imgUrl:r}:r!==t.imgUrl?{imgUrl:r}:null}}],(r=[{key:"shouldComponentUpdate",value:function(e){return this.props.imgUrl!==e.imgUrl?(this.count=0,this.getImage(e.imgUrl),!0):0===this.count&&(this.count++,!0)}},{key:"componentDidMount",value:function(){this.count=0,this.state.httpImg&&this.getImage(this.props.imgUrl)}},{key:"getImage",value:function(e){var t=this,r=this.state.httpImg,i=new XMLHttpRequest;i.open("POST",r),i.setRequestHeader("Content-Type","application/json");var o={reqInfo:{imgPath:e},request:"getImgDataByPath"};i.send(JSON.stringify(o)),i.onreadystatechange=function(){if(4===i.readyState&&(200===i.status||304===i.status)){var e=JSON.parse(i.responseText);0===e.status?t.setImgUrl("data:image/png;base64,"+e.resInfo.imgData):t.setImgUrl(n(60))}}}},{key:"setImgUrl",value:function(e){this.setState({base64Url:e})}},{key:"render",value:function(){var e=this.state.base64Url;return i.a.createElement("img",{className:"imageObject",src:e,alt:""})}}])&&Qe(t.prototype,r),o&&Qe(t,o),s}(r.Component),tt=n(28),nt={insert:"head",singleton:!1};fe()(tt.a,nt),tt.a.locals;function rt(e){return(rt="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 it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function at(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t){return(st=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function lt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut(e);if(t){var i=ut(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ct(this,n)}}function ct(e,t){return!t||"object"!==rt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ut(e){return(ut=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var dt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&st(e,t)}(a,e);var t,n,r,o=lt(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach((function(t){ot(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},e),t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e){var t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length>=r+1){var l=((100-o*(r-1))/r).toFixed(2),c=(parseFloat(l)+o)*(t.length-r),u=document.getElementById("objectTransition");u.style.transition=s+"s all 0s",u.style.left=-c+"%"}return{children:t}}}],(n=[{key:"componentDidUpdate",value:function(){var e=this.props,t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length<r+1){var l=((100-o*(r-1))/r).toFixed(2),c=document.getElementById("objectTransition").childNodes,u=c[c.length-1];u.style.left="100%",u.style.transition=s+"s all 0s",setTimeout((function(){u.style.left=(parseFloat(l)+o)*(c.length-1)+"%"}),1e3*s)}}},{key:"render",value:function(){var e=this.state.children,t=this.props,n=t.count,r=void 0===n?3:n,o=t.leftSpance,a=void 0===o?2:o;return i.a.createElement("div",{className:"objectTransitionOther"},i.a.createElement("div",{id:"objectTransition",className:"objectTransition"},e.map((function(e,t){var n=((100-a*(r-1))/r).toFixed(2);return t>=1&&t<3?i.a.createElement("div",{style:{width:n+"%"},key:t},e):i.a.createElement("div",{style:{width:n+"%",left:(parseFloat(n)+a)*t+"%"},key:t},e)}))))}}])&&at(t.prototype,n),r&&at(t,r),a}(r.Component),ht=n(29),pt={insert:"head",singleton:!1};fe()(ht.a,pt),ht.a.locals;function ft(e){return(ft="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 mt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function yt(e,t){return(yt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function gt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=bt(e);if(t){var i=bt(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return vt(this,n)}}function vt(e,t){return!t||"object"!==ft(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function bt(e){return(bt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var _t=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&yt(e,t)}(a,e);var t,n,r,o=gt(a);function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1,mode:"",width:"100px",height:"100px",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)",disabled:"false",title:"",titleColor:"#000",titleFont:"14px bold 黑体",titleLineHeight:"",titleBackgroundColor:"",titlePadding:"10px",titleTextAlign:"center",titleWidth:100,titleFillColor:"",inputStyle:{},position:[10,10],serviceData:[]},e}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&(n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"shouldComponentUpdate",value:function(e){return this.props.serviceData.length!==e.serviceData}},{key:"componentDidMount",value:function(){this.init()}},{key:"init",value:function(){this.setCanvasSize()}},{key:"setCanvasSize",value:function(){var e=this.state.id,t=document.getElementById(e).parentNode,n=t.offsetWidth,r=t.offsetHeight;this.setData({width:n+"px",height:r+"px"})}},{key:"removeTags",value:function(e,t){for(var n=document.getElementsByTagName(e),r=n.length-1;r>=0;r--)n[r].className==t&&n[r].parentNode.removeChild(n[r])}},{key:"draw",value:function(){var e=this.state,t=e.id,n=e.serviceData,r=e.width,i=e.height,o=e.mode,a=e.disabled,s=document.getElementById(t).getContext("2d");s.clearRect(0,0,parseFloat(r),parseFloat(i)),this.removeTags("input",this.props.listId?this.props.listId:t+""),this.drawLine(s,n),this.drawCircleAll(s,n),this.drawWriting(s,n),"false"===a&&("click"===o?this.isontouchend()?this.touchMove():this.clickMove():this.isontouchend()?this.touchMove():this.mouseMove())}},{key:"isontouchend",value:function(){return"ontouchend"in document}},{key:"drawCircleAll",value:function(e,t){for(var n=0;n<t.length;n++)this.drawCircle(e,t[n][0],t[n][1],this.selectedIndex===n)}},{key:"drawCircle",value:function(e,t,n,r){var i=this.state,o=i.circleRadius,a=i.circleInColor,s=i.circleBorderColor,l=i.circleBorderWidth,c=i.circleSelectColor;e.fillStyle=r?c:a,e.beginPath(),e.arc(t,n,parseInt(o),0,2*Math.PI,!0),e.closePath(),e.fill(),e.beginPath(),e.arc(t,n,parseInt(o),0,2*Math.PI,!0),e.lineWidth=parseInt(l),e.strokeStyle=s,e.stroke(),e.closePath()}},{key:"drawLine",value:function(e,t){var n=this.state,r=n.lineColor,i=n.lineWidth,o=n.areaColor;e.beginPath();for(var a=0;a<t.length;a++)0===a?e.moveTo(t[a][0],t[a][1]):e.lineTo(t[a][0],t[a][1]);e.lineWidth=parseInt(i),e.strokeStyle=r,e.closePath(),e.fillStyle=o,e.fill(),e.stroke()}},{key:"drawWriting",value:function(e,t){var n=this,r=this.state,i=r.title,o=r.titleColor,a=r.titleFont,s=r.titleLineHeight,l=r.position,c=r.titlePadding,u=r.disabled;e.font=a||"18px bold 黑体",e.fillStyle=o||"#fff",e.lineHeight=s||a.split(" ")[0],e.textBaseline="middle";var d=parseInt(s||a.split(" ")[0]);if("true"===u)this.ctxWnzi(e,t);else{for(var h=0,p=99999999,f=0;f<t.length;f++)parseFloat(t[f][0])>h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])<p&&(p=parseFloat(t[f][1]));i&&i.split(/\n/).forEach((function(e,t){n.inputStyleCreate(e,h+(l[0]||15),p+(l[1]||15)+t*(d+3*parseInt(c)),t)}))}}},{key:"ctxWnzi",value:function(e,t){var n=this.state,r=n.title,i=n.titleColor,o=n.titleFont,a=n.titleLineHeight,s=n.position,l=n.titleWidth,c=n.titlePadding,u=n.titleFillColor;e.font=o||"18px bold 黑体",e.lineHeight=a||o.split(" ")[0],e.textBaseline="middle";for(var d=parseInt(a||o.split(" ")[0]),h=0,p=99999999,f=0;f<t.length;f++)parseFloat(t[f][0])>h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])<p&&(p=parseFloat(t[f][1]));r.split(/\n/).forEach((function(t,n){e.fillStyle=u||"rgba(15, 62, 166, 0.2)",e.fill(),e.fillRect(h+(s[0]||15),p+(s[1]||15)+n*(d+2*parseInt(c))-parseFloat(d/2)-parseFloat(parseInt(c)/2),l+parseInt(c),d+parseInt(c)),e.fillStyle=i||"#fff",e.fillText(t,h+(s[0]||15)+parseFloat(parseInt(c)/2),p+(s[1]||15)+n*(d+2*parseInt(c)))}))}},{key:"inputStyleCreate",value:function(e,t,n,r){var i=this,o=this.state,a=o.title,s=o.titleColor,l=o.titleFont,c=o.titleTextAlign,u=o.inputStyle,d=o.titleLineHeight,h=o.titleBackgroundColor,p=o.titleWidth,f=o.titlePadding,m=o.id,y=document.getElementById(m).parentNode,g=document.createElement("input");if(g.style.font=l,g.style.lineHeight=d,g.style.color=s,g.style.backgroundColor=h||"rgba(40, 177, 217, 0.2)",g.style.padding=f,g.style.textAlign=c,g.style.position="absolute",g.style.border="none",g.style.left=t+"px",g.style.top=n+"px",g.style.zIndex="100",g.style.width=p+"px",Object.keys(u).length>0)for(var v in u)g.style[v]=u[v];g.value=e,g.className=this.props.listId?this.props.listId+"":m+"",g.oninput=function(e){var t=a.split(/\n/);t[r]=e.target.value,i.setState({title:t.join("\n")}),i.props.wenziChange(t.join("\n"))},y.appendChild(g)}},{key:"clickMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData;document.getElementById(n).onclick=function(t){var n=t.layerX,i=t.layerY;e.selectedIndex||0===e.selectedIndex?(r[e.selectedIndex]=[n,i],e.selectedIndex=null,e.setData({serviceData:r}),e.sendFather(r)):(e.selectBox(n,i),e.setData({serviceData:r}))}}},{key:"mouseMove",value:function(){var e=this,t=this.state.id,n=document.getElementById(t);n.onmousedown=function(t){var r=e.state.serviceData,i=t.layerX,o=t.layerY;e.selectBox(i,o)&&(n.onmousemove=function(t){r[e.selectedIndex]=[t.layerX,t.layerY],e.setData({serviceData:r})})},n.onmouseup=function(t){n.onmousemove=null,e.selectedIndex=null,e.setData({serviceData:e.state.serviceData});var r=t.layerX,i=t.layerY;e.selectBox(r,i)&&e.sendFather(e.state.serviceData)}}},{key:"touchMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData,i=document.getElementById(n),o=i.parentNode,a=o.getBoundingClientRect().top,s=o.getBoundingClientRect().left;i.ontouchstart=function(t){var n=t.touches[0].pageX-s,o=t.touches[0].pageY-a;e.selectBox(n,o)&&(i.ontouchmove=function(t){r[e.selectedIndex]=[t.touches[0].pageX-s,t.touches[0].pageY-a],e.setData({serviceData:r})})},i.ontouchend=function(t){e.selectedIndex=null,i.ontouchmove=null,e.setData({serviceData:r});var n=t.changedTouches[0].pageX-s,o=t.changedTouches[0].pageY-a;e.selectBox(n,o)&&e.sendFather(r)}}},{key:"selectBox",value:function(e,t){var n=this.state,r=n.serviceData,i=n.circleRadius+n.circleBorderWidth;this.selectedIndex=null;for(var o=0;o<r.length;o++){var a=r[o][0],s=r[o][1];if((a-e)*(a-e)+(s-t)*(s-t)<i*i){this.selectedIndex=o;break}}return o!=r.length}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"setData",value:function(e){var t=this;this.setState(e,(function(){t.draw()}))}},{key:"render",value:function(){var e=this.state,t=e.id,n=e.width,r=e.height;return i.a.createElement("canvas",{style:{position:"absolute",top:0,left:0},id:t,width:n,height:r})}}])&&mt(t.prototype,n),r&&mt(t,r),a}(r.Component);function wt(e){return(wt="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 St(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Et(e,t){return(Et=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function At(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Tt(e);if(t){var i=Tt(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return xt(this,n)}}function xt(e,t){return!t||"object"!==wt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Tt(e){return(Tt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Rt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Et(e,t)}(a,e);var t,n,r,o=At(a);function a(e){var t,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(n=o.call(this,e)).state=(St(t={id:(new Date).getTime()+"fun",serviceData:[],mode:"polygon",disabled:"false",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)"},"disabled","false"),St(t,"title",""),St(t,"titleColor","#000"),St(t,"titleFont","14px bold 黑体"),St(t,"titleLineHeight",""),St(t,"titleBackgroundColor",""),St(t,"titlePadding","10px"),St(t,"titleTextAlign","center"),St(t,"titleWidth",100),St(t,"titleFillColor",""),St(t,"position",[10,10]),St(t,"inputStyle",{}),t),n}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&(n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.state.mode;"react"===e?this.setReact():this.setPolygon()}},{key:"isNull",value:function(){var e=this.state.id,t=document.getElementById(this[e].state.id),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,t.toDataURL()==n.toDataURL()}},{key:"setReact",value:function(){var e=this,t=this.state.id;this.count=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=e.state.serviceData,i=n.layerX,o=n.layerY;if(0===e.count)r[1][1]=o,r[2]=[i,o],r[3][0]=i;else if(e[t].selectedIndex||0===e[t].selectedIndex){switch(r[e[t].selectedIndex]=[i,o],e[t].selectedIndex){case 0:r[1][0]=i,r[3][1]=o;break;case 1:r[0][0]=i,r[2][1]=o;break;case 2:r[1][1]=o,r[3][0]=i;break;case 3:r[0][1]=o,r[2][0]=i}e.props.change(r)}e.setState({serviceData:r},(function(){e[t].draw()}))};n.addEventListener("mousedown",(function(i){if(2!==i.button){var o=i.layerX,a=i.layerY,s=[o,a];if(0===e.state.serviceData.length){e.count++;var l=[[].concat(s),[].concat(s),[].concat(s),[].concat(s)];e.setState({serviceData:l},(function(){e[t].draw()})),n.addEventListener("mousemove",r)}else e[t].selectBox(o,a)&&(e.count++,n.addEventListener("mousemove",r))}})),n.addEventListener("mouseup",(function(e){n.removeEventListener("mousemove",r)})),n.oncontextmenu=function(e){e.preventDefault()}}},{key:"setPolygon",value:function(){var e=this,t=this.state.id;this.state.serviceData.length>1?this.serviceDataFlag=!0:this.polygonCount=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=n.layerX,i=n.layerY,o=e.state.serviceData;o.push([r,i]),e.setState({serviceData:o},(function(){e[t].draw()}))};this.serviceDataFlag||n.addEventListener("click",r),n.oncontextmenu=function(t){t.preventDefault(),2===t.button&&(0==e.polygonCount&&(e.polygonCount++,e.sendFather(e.state.serviceData)),n.removeEventListener("click",r))}}},{key:"isInPolygon",value:function(e,t,n){var r,i,o,a=0,s=t.length;i=t[0];for(var l=1;l<=s;l++)o=t[l%s],e[0]>Math.min(i[0],o[0])&&e[0]<=Math.max(i[0],o[0])&&e[1]<=Math.max(i[1],o[1])&&i[0]!=o[0]&&(r=(e[0]-i[0])*(o[1]-i[1])/(o[0]-i[0])+i[1],(i[1]==o[1]||e[1]<=r)&&a++),i=o;return a%2!=0||!!n.selectBox(e[0],e[1])}},{key:"wenziChange",value:function(e){this.setState({title:e}),this.props.wenziChange(e)}},{key:"change",value:function(e){this.sendFather(e)}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"render",value:function(){var e=this,t=this.state,n=t.serviceData,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.inputStyle,k=t.position,E=t.id;return i.a.createElement(_t,{serviceData:n,disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:p,titleColor:f,titleFont:m,titleLineHeight:y,titleBackgroundColor:g,titlePadding:v,titleTextAlign:b,titleWidth:_,titleFillColor:w,position:k,inputStyle:S,listId:this.props.listId,ref:function(t){e[E]=t},wenziChange:function(t){return e.wenziChange(t)},change:function(t){return e.change(t)}})}}])&&kt(t.prototype,n),r&&kt(t,r),a}(r.Component),Ct=n(30),Mt={insert:"head",singleton:!1};fe()(Ct.a,Mt),Ct.a.locals;function Lt(e){return(Lt="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 Ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Dt(e,t){return(Dt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ut(e);if(t){var i=Ut(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Bt(this,n)}}function Bt(e,t){return!t||"object"!==Lt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ut(e){return(Ut=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Nt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Dt(e,t)}(a,e);var t,n,r,o=Pt(a);function a(){var e,t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this)).state=(Ot(e={id:(new Date).getTime()+"waiceng",disabled:"false",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)"},"disabled","false"),Ot(e,"title",""),Ot(e,"titleColor","#000"),Ot(e,"titleFont","14px bold 黑体"),Ot(e,"titleLineHeight",""),Ot(e,"titleBackgroundColor",""),Ot(e,"titlePadding","10px"),Ot(e,"titleTextAlign","center"),Ot(e,"titleWidth",100),Ot(e,"titleFillColor",""),Ot(e,"position",[10,10]),Ot(e,"inputStyle",{}),e),t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&("object"===Lt(e[r])?n[r]=JSON.parse(JSON.stringify(e[r])):n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.props.list;e&&e.length>0&&(this.selectIndex=e[e.length-1].id),this.selectArea()}},{key:"clickIt",value:function(e){var t=this.props.list,n=(new Date).getTime();t&&0!==t.length?this[t[t.length-1].id+t[t.length-1].mode].isNull()?this.props.err(!1,"画布为空,请先绘制在添加。"):t[t.length-1].serviceData?(t.push({id:n+"",title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n+""):this.props.err(!1,"画布没有保存,请先绘制完成在添加"):((t=[]).push({id:n,title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n),this.props.change(t)}},{key:"delete",value:function(){var e=this,t=this.state.list.filter((function(t){return t.id===e.selectIndex})),n=this[t[0].id+t[0].mode];n[n.state.id].removeTags("input",n.props.listId),this.props.delete(this.selectIndex,"发出删除指令")}},{key:"change",value:function(e){var t=this,n=this.props.list;n=n.map((function(n){return n.id===t.selectIndex&&(n.serviceData=JSON.parse(JSON.stringify(e))),n})),this.props.change(n)}},{key:"selectArea",value:function(){var e=this,t=this.state.id;document.getElementById(t).onclick=function(t){var n=e.props.list,r=t.layerX,i=t.layerY;if(e.indexflag=!1,n)for(var o=0;o<n.length;o++)if(n[o].serviceData){var a=e[n[o].id+n[o].mode].state.id;if(e.isInPolygon([r,i],JSON.parse(JSON.stringify(n[o].serviceData)),e[n[o].id+n[o].mode][a])){var s=e[n[o].id+n[o].mode][a].state.id;e.indexflag?document.getElementById(s).style.zIndex=0:(document.getElementById(s).style.zIndex=99,e.selectIndex=n[o].id,e.indexflag=!0)}else s=e[n[o].id+n[o].mode][a].state.id,document.getElementById(s).style.zIndex=0}}}},{key:"isInPolygon",value:function(e,t,n){for(var r=e[0],i=e[1],o=!1,a=0,s=t.length-1;a<t.length;s=a++){var l=t[a][0],c=t[a][1],u=t[s][0],d=t[s][1],h=c>i!=d>i&&r<(u-l)*(i-c)/(d-c)+l;h&&(o=!o)}return!(h||!n.selectBox(e[0],e[1]))||o}},{key:"wenziChange",value:function(e,t){this.props.wenziChange(e,t)}},{key:"render",value:function(){var e=this,t=this.state,n=t.id,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.position,k=this.props.list;return i.a.createElement("div",{id:n,style:{width:"100%",height:"100%",position:"relative"}},k&&k.map((function(t,n){return i.a.createElement(Rt,{disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:t.title?t.title:p,titleColor:t.titleColor?t.titleColor:f,titleFont:t.titleFont?t.titleFont:m,titleLineHeight:t.titleLineHeight?t.titleLineHeight:y,titleBackgroundColor:t.titleBackgroundColor?t.titleBackgroundColor:g,titlePadding:t.titlePadding?t.titlePadding:v,titleTextAlign:t.titleTextAlign?t.titleTextAlign:b,titleWidth:t.titleWidth?t.titleWidth:_,titleFillColor:t.titleFillColor?t.titleFillColor:w,position:S,key:t.id,listId:t.id,serviceData:t.serviceData,ref:function(n){e[t.id+t.mode]=n},mode:t.mode,wenziChange:function(t){return e.wenziChange(t,n)},change:function(t){return e.change(t)}})})))}}])&&It(t.prototype,n),r&&It(t,r),a}(r.Component),Ft=n(52),qt=n.n(Ft),jt=function(e){this.mqtt=qt.a,this.random=Vt,this.clientId=Vt();var t={clientId:this.clientId,username:"test",password:"test",connectTimeout:100,keepalive:100};this.client=this.mqtt.connect("ws://"+e+"/mqtt",t),this.reconnectNum=0,this.link=function(){var e=this;return new Promise((function(t,n){e.client.on("connect",(function(n){console.log("-----------------------链接成功-----------------------"),t(e.client)})),e.client.on("reconnect",(function(t){e.reconnectNum++,e.reconnectNum>=10&&e.client.end(!0),console.log("正在重连:",t)})),e.client.on("error",(function(e){console.log("订阅失败",e)}))}))},this.subscribe=function(e,t){this.client.subscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"订阅成功-----------------------")}))},this.unsubscribe=function(e,t){this.client.unsubscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"取消订阅成功-----------------------")}))},this.publish=function(e,t,n){this.client.publish(e,JSON.stringify(t),n,(function(t,n){if(t)throw new Error(t);console.log("-----------------------"+e+"发送成功-----------------------")}))},this.message=function(e){this.client.on("message",(function(t,n){var r=JSON.parse(n.toString());e(r,t)}))},this.close=function(){this.client.end(!0)}};function Vt(){for(var e=String.fromCharCode(65+Math.floor(26*Math.random())),t=0;t<31;++t){var n=Math.floor(62*Math.random());e+=n<10?n.toString():n<36?String.fromCharCode(65+n-10):String.fromCharCode(97+n-10-26)}return e}function Yt(e){for(var t=window.location.search.substring(1).split("&"),n=0;n<t.length;n++){var r=t[n].split("=");if(r[0]==e)return r[1]}return!1}function Wt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=null,i=0;return new Promise((function(o,a){zt(e)?o(zt(e)):r=setInterval((function(){i<t?(i++,zt(e)&&(clearInterval(r),o(zt(e)))):a("获取"+t+"后失败")}),n)}))}function zt(e){for(var t=document.cookie.split("; "),n=0;n<t.length;n++)if(t[n].split("=")[0]===e)return t[n].split("=")[1]}console.log("%c中科视语-组件库","text-shadow: 0 1px 0 #fff,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);font-size:35px")}])})); | |
46 | 45 | \ No newline at end of file |
46 | +var r=n(3),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";(function(t){var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(20),a=Symbol("lastResolve"),s=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),d=Symbol("handlePromise"),h=Symbol("stream");function p(e,t){return{value:e,done:t}}function f(e){var t=e[a];if(null!==t){var n=e[h].read();null!==n&&(e[u]=null,e[a]=null,e[s]=null,t(p(n,!1)))}}function m(e){t.nextTick(f,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(r={get stream(){return this[h]},next:function(){var e=this,n=this[l];if(null!==n)return Promise.reject(n);if(this[c])return Promise.resolve(p(void 0,!0));if(this[h].destroyed)return new Promise((function(n,r){t.nextTick((function(){e[l]?r(e[l]):n(p(void 0,!0))}))}));var r,i=this[u];if(i)r=new Promise(function(e,t){return function(n,r){e.then((function(){t[c]?n(p(void 0,!0)):t[d](n,r)}),r)}}(i,this));else{var o=this[h].read();if(null!==o)return Promise.resolve(p(o,!1));r=new Promise(this[d])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),i(r,"return",(function(){var e=this;return new Promise((function(t,n){e[h].destroy(null,(function(e){e?n(e):t(p(void 0,!0))}))}))})),r),y);e.exports=function(e){var t,n=Object.create(g,(i(t={},h,{value:e,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,d,{value:function(e,t){var r=n[h].read();r?(n[u]=null,n[a]=null,n[s]=null,e(p(r,!1))):(n[a]=e,n[s]=t)},writable:!0}),t));return n[u]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[s];return null!==t&&(n[u]=null,n[a]=null,n[s]=null,t(e)),void(n[l]=e)}var r=n[a];null!==r&&(n[u]=null,n[a]=null,n[s]=null,r(p(void 0,!0))),n[c]=!0})),e.on("readable",m.bind(null,n)),n}}).call(this,n(2))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,n){"use strict";e.exports=i;var r=n(39);function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}n(7)(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r;var i=n(10).codes,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function l(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var s=!1;e.on("close",(function(){s=!0})),void 0===r&&(r=n(20)),r(e,{readable:t,writable:i},(function(e){if(e)return o(e);s=!0,o()}));var l=!1;return function(t){if(!s&&!l)return l=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new a("pipe"))}}function c(e){e()}function u(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?s:e.pop():s}e.exports=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var a=t.map((function(e,n){var o=n<t.length-1;return l(e,o,n>0,(function(e){r||(r=e),e&&a.forEach(c),o||(a.forEach(c),i(r))}))}));return t.reduce(u)}},function(e,t,n){t.parser=n(74).parser,t.generate=n(80),t.writeToStream=n(41)},function(e,t,n){const r=n(75),i=n(1),o=n(77),a=n(40),s=n(8)("mqtt-packet:parser");class l extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new l).parser(e)}_resetState(){s("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),s("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,s("parse: state complete. _stateCounter is now: %d",this._stateCounter),s("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return s("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),s("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),s("_parseLength %d",e.value),!!e}_parsePayload(){s("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return s("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;s("_parseConnect");const i={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(o.clientId=c,s("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,s("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,s("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));o.username=r,s("_parseConnect: packet.username: %s",o.username)}if(i.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));o.password=n}return this.settings=o,s("_parseConnect: complete"),o}_parseConnack(){s("_parseConnack");const e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}s("_parseConnack: complete")}_parsePublish(){s("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),s("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){s("_parseSubscribe");const e=this.packet;let t,n,r,i,o,l,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&a.SUBSCRIBE_OPTIONS_QOS_MASK,l=0!=(n>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(n>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),i=n>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:r},5===this.settings.protocolVersion&&(c.nl=l,c.rap=o,c.rh=i),s("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){s("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){s("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));s("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){s("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){s("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2&&(e.reasonCode=this._parseByte(),s("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(s("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return s("_parseDisconnect result: true"),!0}_parseAuth(){s("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),s("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(s("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,s("_parseString: result: %s",r),r}_parseStringPair(){return s("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,s("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,s("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,s("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){s("_parseVarByteNum");let t,n=0,r=1,i=0,o=!1;const l=this._pos?this._pos:0;for(;n<4;){if(t=this._list.readUInt8(l+n++),i+=r*(t&a.VARBYTEINT_MASK),r*=128,0==(t&a.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=n)break}return!o&&4===n&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),o=!!o&&(e?{bytes:n,value:i}:i),s("_parseVarByteNum: result: %o",o),o}_parseByte(){const e=this._list.readUInt8(this._pos);return this._pos++,s("_parseByte: result: %o",e),e}_parseByType(e){switch(s("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){s("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte(),t=a.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(a.propertiesTypes[t]))):n[t]=this._parseByType(a.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(a.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return s("_newPacket"),this.packet&&(this._list.consume(this.packet.length),s("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),s("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){s("_emitError"),this.error=e,this.emit("error",e)}}e.exports=l},function(e,t,n){"use strict";const r=n(9).Duplex,i=n(7),o=n(76);function a(e){if(!(this instanceof a))return new a(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}o._init.call(this,e),r.call(this)}i(a,r),Object.assign(a.prototype,o.prototype),a.prototype._new=function(e){return new a(e)},a.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},a.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},a.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},a.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},a.prototype._isBufferList=function(e){return e instanceof a||e instanceof o||a.isBufferList(e)},a.isBufferList=o.isBufferList,e.exports=a,e.exports.BufferListStream=a,e.exports.BufferList=o},function(e,t,n){"use strict";const{Buffer:r}=n(3),i=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e)}o._init=function(e){Object.defineProperty(this,i,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},o.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},o.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,n,i){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof i||i>this.length)&&(i=this.length),n>=this.length)return e||r.alloc(0);if(i<=0)return e||r.alloc(0);const o=!!e,a=this._offset(n),s=i-n;let l=s,c=o&&t||0,u=a[1];if(0===n&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(l<=this._bufs[a[0]].length-u)return o?this._bufs[a[0]].copy(e,t,u,u+l):this._bufs[a[0]].slice(u,u+l);o||(e=r.allocUnsafe(s));for(let t=a[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(l>n)){this._bufs[t].copy(e,c,u,u+l),c+=n;break}this._bufs[t].copy(e,c,u),c+=n,l-=n,u&&(u=0)}return e.length>c?e.slice(0,c):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!==n[1]&&(i[0]=i[0].slice(n[1])),this._new(i)},o.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},o.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const i=this._offset(t);let o=i[0],a=i[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;a<t.length;){if(t.length-a>=e.length){const n=t.indexOf(e,a);if(-1!==n)return this._reverseOffset([o,n]);a=t.length-e.length+1}else{const t=this._reverseOffset([o,a]);if(this._match(t,e))return t;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){o.prototype[t]=null===e[t]?function(e,n){return this.slice(e,e+n)[t](0,n)}:function(n){return this.slice(n,n+e[t])[t](0)}}(t)}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[i]},e.exports=o},function(e,t){e.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},function(e,t,n){e.exports=function(e){function t(e){let n,i=null;function o(...e){if(!o.enabled)return;const r=o,i=Number(new Date),a=i-(n||i);r.diff=a,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,i)=>{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(79),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},function(e,t){var n=1e3,r=6e4,i=60*r,o=24*i;function a(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===s&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=i)return a(e,t,i,"hour");if(t>=r)return a(e,t,r,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){const r=n(41),i=n(1);class o extends i{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const n=new Array(this._array.length),r=this._array;let i,o=0;for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?n[i]=r[i].length:n[i]=t.byteLength(r[i]),e+=n[i];const a=t.allocUnsafe(e);for(i=0;i<r.length&&void 0!==r[i];i++)"string"!=typeof r[i]?(r[i].copy(a,o),o+=n[i]):(a.write(r[i],o),o+=n[i]);return a}}e.exports=function(e,t){const n=new o;return r(e,n,t),n.concat()}}).call(this,n(3).Buffer)},function(e,t,n){(function(t){const n={},r=t.isBuffer(t.from([1,2]).subarray(0,1));function i(e){const n=t.allocUnsafe(2);return n.writeUInt8(e>>8,0),n.writeUInt8(255&e,1),n}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=i(e)},generateNumber:i,genBufVariableByteInt:function(e){let n=0,i=0;const o=t.allocUnsafe(4);do{n=e%128|0,(e=e/128|0)>0&&(n|=128),o.writeUInt8(n,i++)}while(e>0&&i<4);return e>0&&(i=0),r?o.subarray(0,i):o.slice(0,i)},generate4ByteBuffer:function(e){const n=t.allocUnsafe(4);return n.writeUInt32BE(e,0),n}}}).call(this,n(3).Buffer)},function(e,t,n){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,n)}));case 3:return t.nextTick((function(){e.call(null,n,r)}));case 4:return t.nextTick((function(){e.call(null,n,r,i)}));default:for(o=new Array(s-1),a=0;a<o.length;)o[a++]=arguments[a];return t.nextTick((function(){e.apply(null,o)}))}}}:e.exports=t}).call(this,n(2))},function(e,t,n){"use strict";function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}},function(e,t,n){"use strict";function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}}},function(e,t,n){"use strict";var r=n(86),i=n(88);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=b,t.resolve=function(e,t){return b(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?b(e,!1,!0).resolveObject(t):t},t.format=function(e){i.isString(e)&&(e=b(e));return e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o;var a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(89);function b(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o<e.indexOf("#")?"?":"#",c=e.split(s);c[0]=c[0].replace(/\\/g,"/");var b=e=c.join(s);if(b=b.trim(),!n&&1===e.split("#").length){var _=l.exec(b);if(_)return this.path=b,this.href=b,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=a.exec(b);if(w){var S=(w=w[0]).toLowerCase();this.protocol=S,b=b.substr(w.length)}if(n||w||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===b.substr(0,2);!k||w&&y[w]||(b=b.substr(2),this.slashes=!0)}if(!y[w]&&(k||w&&!g[w])){for(var E,A,x=-1,T=0;T<h.length;T++){-1!==(R=b.indexOf(h[T]))&&(-1===x||R<x)&&(x=R)}-1!==(A=-1===x?b.lastIndexOf("@"):b.lastIndexOf("@",x))&&(E=b.slice(0,A),b=b.slice(A+1),this.auth=decodeURIComponent(E)),x=-1;for(T=0;T<d.length;T++){var R;-1!==(R=b.indexOf(d[T]))&&(-1===x||R<x)&&(x=R)}-1===x&&(x=b.length),this.host=b.slice(0,x),b=b.slice(x),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var M=this.hostname.split(/\./),L=(T=0,M.length);T<L;T++){var O=M[T];if(O&&!O.match(p)){for(var I="",D=0,P=O.length;D<P;D++)O.charCodeAt(D)>127?I+="x":I+=O[D];if(!I.match(p)){var B=M.slice(0,T),U=M.slice(T+1),N=O.match(f);N&&(B.push(N[1]),U.unshift(N[2])),U.length&&(b="/"+U.join(".")+b),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[S])for(T=0,L=u.length;T<L;T++){var j=u[T];if(-1!==b.indexOf(j)){var V=encodeURIComponent(j);V===j&&(V=escape(j)),b=b.split(j).join(V)}}var Y=b.indexOf("#");-1!==Y&&(this.hash=b.substr(Y),b=b.slice(0,Y));var W=b.indexOf("?");if(-1!==W?(this.search=b.substr(W),this.query=b.substr(W+1),t&&(this.query=v.parse(this.query)),b=b.slice(0,W)):t&&(this.search="",this.query={}),b&&(this.pathname=b),g[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var z=this.search||"";this.path=F+z}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,a="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(a=v.stringify(this.query));var s=this.search||a&&"?"+a||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||g[t])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),t+o+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+r},o.prototype.resolve=function(e){return this.resolveObject(b(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if(i.isString(e)){var t=new o;t.parse(e,!1,!0),e=t}for(var n=new o,r=Object.keys(this),a=0;a<r.length;a++){var s=r[a];n[s]=this[s]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var l=Object.keys(e),c=0;c<l.length;c++){var u=l[c];"protocol"!==u&&(n[u]=e[u])}return g[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!g[e.protocol]){for(var d=Object.keys(e),h=0;h<d.length;h++){var p=d[h];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var f=(e.pathname||"").split("/");f.length&&!(e.host=f.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==f[0]&&f.unshift(""),f.length<2&&f.unshift(""),n.pathname=f.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",v=n.search||"";n.path=m+v}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),_=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=_||b||n.host&&e.pathname,S=w,k=n.pathname&&n.pathname.split("/")||[],E=(f=e.pathname&&e.pathname.split("/")||[],n.protocol&&!g[n.protocol]);if(E&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===f[0]?f[0]=e.host:f.unshift(e.host)),e.host=null),w=w&&(""===f[0]||""===k[0])),_)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=f;else if(f.length)k||(k=[]),k.pop(),k=k.concat(f),n.search=e.search,n.query=e.query;else if(!i.isNullOrUndefined(e.search)){if(E)n.hostname=n.host=k.shift(),(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift());return n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=k.slice(-1)[0],x=(n.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,T=0,R=k.length;R>=0;R--)"."===(A=k[R])?k.splice(R,1):".."===A?(k.splice(R,1),T++):T&&(k.splice(R,1),T--);if(!w&&!S)for(;T--;T)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var C,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=M?"":k.length?k.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift()));return(w=w||n.host&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){(function(e,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof r&&r;a.global!==a&&a.window!==a&&a.self;var s,l=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,f=String.fromCharCode;function m(e){throw new RangeError(h[e])}function y(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+y((e=e.replace(d,".")).split("."),t).join(".")}function v(e){for(var t,n,r=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=f((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=f(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function S(e){var t,n,r,i,o,a,s,c,u,d,h,f=[],y=e.length,g=0,v=128,_=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&m("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<y;){for(o=g,a=1,s=36;i>=y&&m("invalid-input"),((c=(h=e.charCodeAt(i++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((l-g)/a))&&m("overflow"),g+=c*a,!(c<(u=s<=_?1:s>=_+26?26:s-_));s+=36)a>p(l/(d=36-u))&&m("overflow"),a*=d;_=w(g-o,t=f.length+1,0==o),p(g/t)>l-v&&m("overflow"),v+=p(g/t),g%=t,f.splice(g++,0,v)}return b(f)}function k(e){var t,n,r,i,o,a,s,c,u,d,h,y,g,b,S,k=[];for(y=(e=v(e)).length,t=128,n=0,o=72,a=0;a<y;++a)(h=e[a])<128&&k.push(f(h));for(r=i=k.length,i&&k.push("-");r<y;){for(s=l,a=0;a<y;++a)(h=e[a])>=t&&h<s&&(s=h);for(s-t>p((l-n)/(g=r+1))&&m("overflow"),n+=(s-t)*g,t=s,a=0;a<y;++a)if((h=e[a])<t&&++n>l&&m("overflow"),h==t){for(c=n,u=36;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=36)S=c-d,b=36-d,k.push(f(_(d+S%b,0))),c=p(S/b);k.push(f(_(c,0))),o=w(n,g,r==i),n=0,++r}++n,++t}return k.join("")}s={version:"1.4.1",ucs2:{decode:v,encode:b},decode:S,encode:k,toASCII:function(e){return g(e,(function(e){return u.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,n,t,e))||(e.exports=i)}()}).call(this,n(87)(e),n(6))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(90),t.encode=t.stringify=n(91)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u<c;++u){var d,h,p,f,m=e[u].replace(s,"%20"),y=m.indexOf(n);y>=0?(d=m.substr(0,y),h=m.substr(y+1)):(d=m,h=""),p=decodeURIComponent(d),f=decodeURIComponent(h),r(a,p)?i(a[p])?a[p].push(f):a[p]=[a[p],f]:a[p]=f}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,s){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(r(a))+n;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(r(e))})).join(t):s+encodeURIComponent(r(e[a]))})).join(t):s?encodeURIComponent(r(s))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var a=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},function(e,t){},function(e,t){},function(e,t,n){(t=e.exports=n(44)).Stream=t,t.Readable=t,t.Writable=n(47),t.Duplex=n(13),t.Transform=n(48),t.PassThrough=n(99)},function(e,t){},function(e,t,n){"use strict";var r=n(23).Buffer,i=n(97);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){"use strict";e.exports=o;var r=n(48),i=Object.create(n(14));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(12),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){var r=n(101),i=function(){},o=function(e,n,a){if("function"==typeof n)return o(e,null,n);n||(n={}),a=r(a||i);var s=e._writableState,l=e._readableState,c=n.readable||!1!==n.readable&&e.readable,u=n.writable||!1!==n.writable&&e.writable,d=!1,h=function(){e.writable||p()},p=function(){u=!1,c||a.call(e)},f=function(){c=!1,u||a.call(e)},m=function(t){a.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){a.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!d)return(!c||l&&l.ended&&!l.destroyed)&&(!u||s&&s.ended&&!s.destroyed)?void 0:a.call(e,new Error("premature close"))},b=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?u&&!s&&(e.on("end",h),e.on("close",h)):(e.on("complete",p),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",f),e.on("finish",p),!1!==n.error&&e.on("error",y),e.on("close",g),function(){d=!0,e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",p),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",f),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=o}).call(this,n(2))},function(e,t,n){var r=n(102);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}e.exports=r(i),e.exports.strict=r(o),i.proto=i((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}}},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length)return e.buffer.head?e.buffer.head.data.length:e.buffer[0].length;return e.length}(t)):null}},function(e,t,n){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,n){"use strict";n.r(t),n.d(t,"FlvCom",(function(){return ke})),n.d(t,"AllVideoCom",(function(){return Pe})),n.d(t,"Timer",(function(){return ze})),n.d(t,"ImgCom",(function(){return et})),n.d(t,"TransitionCom",(function(){return dt})),n.d(t,"AreaSelete",(function(){return _t})),n.d(t,"FunAreaSelect",(function(){return Rt})),n.d(t,"FunAreaSelectPlus",(function(){return Nt})),n.d(t,"Mqtt",(function(){return jt})),n.d(t,"getQuery",(function(){return Yt})),n.d(t,"getCookie",(function(){return Wt}));var r=n(0),i=n.n(r);class o{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");let t=Object(e);for(let e=1;e<arguments.length;e++){let n=arguments[e];if(null!=n)for(let e in n)n.hasOwnProperty(e)&&(t[e]=n[e])}return t},"function"!=typeof self.Promise&&n(55).polyfill()}}o.install();var a=o,s=n(1),l=n.n(s);class c{static e(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","error",n),c.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))}static i(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","info",n),c.ENABLE_INFO&&(console.info?console.info(n):console.log(n))}static w(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","warn",n),c.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))}static d(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","debug",n),c.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))}static v(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","verbose",n),c.ENABLE_VERBOSE&&console.log(n)}}c.GLOBAL_TAG="flv.js",c.FORCE_GLOBAL_TAG=!1,c.ENABLE_ERROR=!0,c.ENABLE_INFO=!0,c.ENABLE_WARN=!0,c.ENABLE_DEBUG=!0,c.ENABLE_VERBOSE=!0,c.ENABLE_CALLBACK=!1,c.emitter=new l.a;var u=c;var d=class{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}};class h{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class p extends h{constructor(e){super(e)}get name(){return"IllegalStateException"}}class f extends h{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends h{constructor(e){super(e)}get name(){return"NotImplementedException"}}const y={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},g={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class v{constructor(e){this._type=e||"undefined",this._status=y.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=y.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===y.kConnecting||this._status===y.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(e,t){throw new m("Unimplemented abstract function!")}abort(){throw new m("Unimplemented abstract function!")}}let b={};!function(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],n=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},i={};if(r.browser){i[r.browser]=!0;let e=r.majorVersion.split(".");i.version={major:parseInt(r.majorVersion,10),string:r.version},e.length>1&&(i.version.minor=parseInt(e[1],10)),e.length>2&&(i.version.build=parseInt(e[2],10))}if(r.platform&&(i[r.platform]=!0),(i.chrome||i.opr||i.safari)&&(i.webkit=!0),i.rv||i.iemobile){i.rv&&delete i.rv;let e="msie";r.browser=e,i[e]=!0}if(i.edge){delete i.edge;let e="msedge";r.browser=e,i[e]=!0}if(i.opr){let e="opera";r.browser=e,i[e]=!0}if(i.safari&&i.android){let e="android";r.browser=e,i[e]=!0}i.name=r.browser,i.platform=r.platform;for(let e in b)b.hasOwnProperty(e)&&delete b[e];Object.assign(b,i)}();var _=b;var w=class extends v{static isSupported(){try{let e=_.msedge&&_.version.minor>=15048,t=!_.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t),i=new self.Headers;if("object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.append(t,e[t])}let o={method:"GET",headers:i,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(let e in this._config.headers)i.append(e,this._config.headers[e]);!1===e.cors&&(o.mode="same-origin"),e.withCredentials&&(o.credentials="include"),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),this._status=y.kConnecting,self.fetch(r.url,o).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=y.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=y.kError,!this._onError)throw new h("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=y.kError,!this._onError)throw e;this._onError(g.EXCEPTION,{code:-1,msg:e.message})})}abort(){this._requestAbort=!0}_pump(e){return e.read().then(t=>{if(t.done)if(null!==this._contentLength&&this._receivedLength<this._contentLength){this._status=y.kError;let e=g.EARLY_EOF,t={code:-1,msg:"Fetch stream meet Early-EOF"};if(!this._onError)throw new h(t.msg);this._onError(e,t)}else this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1);else{if(!0===this._requestAbort)return this._requestAbort=!1,this._status=y.kComplete,e.cancel();this._status=y.kBuffering;let n=t.value.buffer,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),this._pump(e)}}).catch(e=>{if(11===e.code&&_.msedge)return;this._status=y.kError;let t=0,n=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength<this._contentLength)?(t=g.EXCEPTION,n={code:e.code,msg:e.message}):(t=g.EARLY_EOF,n={code:e.code,msg:"Fetch stream meet Early-EOF"}),!this._onError)throw new h(n.msg);this._onError(t,n)})}};var S=class extends v{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return u.w("MozChunkedLoader",e.message),!1}}constructor(e,t){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t);this._requestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="moz-chunked-arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onloadend=this._onLoadEnd.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}this._status=y.kConnecting,i.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=y.kComplete}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){let e=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(e)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=y.kError,!this._onError)throw new h("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=y.kBuffering}}_onProgress(e){if(this._status===y.kError)return;null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let t=e.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==y.kError&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&e.loaded<this._contentLength?(t=g.EARLY_EOF,n={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=g.EXCEPTION,n={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new h(n.msg);this._onError(t,n)}};var k=class extends v{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return u.w("RangeLoader",e.message),!1}}constructor(e,t){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=e,this._config=t,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new d,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(e,t){this._dataSource=e,this._range=t,this._status=y.kConnecting;let n=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(n=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||n?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}_openSubRange(){let e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,n=t+e;null!=this._contentLength&&n-this._range.from>=this._contentLength&&(n=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let n=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?n=this._currentRedirectedURL:null!=e.redirectedURL&&(n=e.redirectedURL));let r=this._seekHandler.getConfig(n,t);this._currentRequestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onload=this._onLoad.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}i.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=y.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL){let e=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&e!==this._currentRedirectedURL&&(this._currentRedirectedURL=e,this._onURLRedirect&&this._onURLRedirect(e))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=y.kBuffering}else{if(this._status=y.kError,!this._onError)throw new h("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===y.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let n=e.total;this._internalAbort(),null!=n&0!==n&&(this._totalLength=n)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let t=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(t)}_normalizeSpeed(e){let t=this._chunkSizeKBList,n=t.length-1,r=0,i=0,o=n;if(e<t[0])return t[0];for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>=t[r]&&e<t[r+1])return t[r];t[r]<e?i=r+1:o=r-1}}_onLoad(e){if(this._status===y.kError)return;if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;let t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;let i=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():i=!0,this._onDataArrival&&this._onDataArrival(n,r,this._receivedLength),i&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=g.EARLY_EOF,n={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=g.EXCEPTION,n={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new h(n.msg);this._onError(t,n)}};var E=class extends v{static isSupported(){try{return void 0!==self.WebSocket}catch(e){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(e){try{let t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=y.kConnecting}catch(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}abort(){let e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=y.kComplete}_onWebSocketOpen(e){this._status=y.kBuffering}_onWebSocketClose(e){!0!==this._requestAbort?(this._status=y.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1}_onWebSocketMessage(e){if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){let t=new FileReader;t.onload=()=>{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=y.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,n=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onWebSocketError(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}};var A=class{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let n={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,n.Range=e}else this._zeroStart&&(n.Range="bytes=0-");return{url:e,headers:n}}removeURLParameters(e){return e}};var x=class{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let n=e;if(0!==t.from||-1!==t.to){let e=!0;-1===n.indexOf("?")&&(n+="?",e=!1),e&&(n+="&"),n+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(n+=`&${this._endName}=${t.to.toString()}`)}return{url:n,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],n=void 0,r=e.indexOf("?");-1!==r&&(n=e.substring(r+1));let i="";if(null!=n&&n.length>0){let e=n.split("&");for(let t=0;t<e.length;t++){let n=e[t].split("="),r=t>0;n[0]!==this._startName&&n[0]!==this._endName&&(r&&(i+="&"),i+=e[t])}}return 0===i.length?t:t+"?"+i}};var T=class{constructor(e,t,n){this.TAG="IOController",this._config=t,this._extraData=n,this._stashInitialSize=393216,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new d,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===k?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new A(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",n=e.seekParamEnd||"bend";this._seekHandler=new x(t,n)}else{if("custom"!==e.seekType)throw new f("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new f("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=E;else if(w.isSupported())this._loaderClass=w;else if(S.isSupported())this._loaderClass=S;else{if(!k.isSupported())throw new h("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=k}}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let n={from:e,to:-1};this._currentRange={from:n.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,n),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new f("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+1048576<e;)t*=2;if(t+=1048576,t===this._bufferSize)return;let n=new ArrayBuffer(t);if(this._stashUsed>0){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(n,0,t).set(e,0)}this._stashBuffer=n,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,n=t.length-1,r=0,i=0,o=n;if(e<t[0])return t[0];for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>=t[r]&&e<t[r+1])return t[r];t[r]<e?i=r+1:o=r-1}}_adjustStashSize(e){let t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let n=1024*t+1048576;this._bufferSize<n&&this._expandBuffer(n),this._stashSize=1024*t}_dispatchChunks(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}_onURLRedirect(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)}_onContentLengthKnown(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)}_onLoaderChunkArrival(e,t,n){if(!this._onDataArrival)throw new p("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);let r=this._speedSampler.lastSecondKBps;if(0!==r){let e=this._normalizeSpeed(r);this._speedNormalized!==e&&(this._speedNormalized=e,this._adjustStashSize(e))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){new Uint8Array(this._stashBuffer,0,this._stashSize).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let n=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart);if(r<t.byteLength){if(r>0){let e=new Uint8Array(t,r);n.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=r}}else this._stashUsed=0,this._stashByteStart+=r;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let r=this._dispatchChunks(e,t);if(r<e.byteLength){let i=e.byteLength-r;i>this._bufferSize&&(this._expandBuffer(i),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e,r),0),this._stashUsed+=i,this._stashByteStart=t+r}}}else if(0===this._stashUsed){let n=this._dispatchChunks(e,t);if(n<e.byteLength){let r=e.byteLength-n;r>this._bufferSize&&this._expandBuffer(r),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(e,n),0),this._stashUsed+=r,this._stashByteStart=t+n}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let n=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(n<this._stashUsed&&n>0){let e=new Uint8Array(this._stashBuffer,n);t.set(e,0)}this._stashUsed-=n,this._stashByteStart+=n}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart),r=t.byteLength-n;if(n<t.byteLength){if(!e){if(n>0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),r=new Uint8Array(t,n);e.set(r,0),this._stashUsed=r.byteLength,this._stashByteStart+=n}return 0}u.w(this.TAG,r+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,r}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(u.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=g.UNRECOVERABLE_EARLY_EOF),e){case g.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e<this._totalLength&&(u.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(e,!1)))}e=g.UNRECOVERABLE_EARLY_EOF}if(!this._onError)throw new h("IOException: "+t.msg);this._onError(e,t)}};const R={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function C(){return Object.assign({},R)}class M{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let e=new T({},C()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t}static getNetworkLoaderTypeName(){let e=new T({},C()),t=e.loaderType;return e.destroy(),t}static supportNativeMediaPlayback(e){null==M.videoElement&&(M.videoElement=window.document.createElement("video"));let t=M.videoElement.canPlayType(e);return"probably"===t||"maybe"==t}static getFeatureList(){let e={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return e.mseFlvPlayback=M.supportMSEH264Playback(),e.networkStreamIO=M.supportNetworkStreamIO(),e.networkLoaderName=M.getNetworkLoaderTypeName(),e.mseLiveFlvPlayback=e.mseFlvPlayback&&e.networkStreamIO,e.nativeMP4H264Playback=M.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),e.nativeWebmVP8Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),e.nativeWebmVP9Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp9"'),e}}var L=M;var O={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};class I{static get forceGlobalTag(){return u.FORCE_GLOBAL_TAG}static set forceGlobalTag(e){u.FORCE_GLOBAL_TAG=e,I._notifyChange()}static get globalTag(){return u.GLOBAL_TAG}static set globalTag(e){u.GLOBAL_TAG=e,I._notifyChange()}static get enableAll(){return u.ENABLE_VERBOSE&&u.ENABLE_DEBUG&&u.ENABLE_INFO&&u.ENABLE_WARN&&u.ENABLE_ERROR}static set enableAll(e){u.ENABLE_VERBOSE=e,u.ENABLE_DEBUG=e,u.ENABLE_INFO=e,u.ENABLE_WARN=e,u.ENABLE_ERROR=e,I._notifyChange()}static get enableDebug(){return u.ENABLE_DEBUG}static set enableDebug(e){u.ENABLE_DEBUG=e,I._notifyChange()}static get enableVerbose(){return u.ENABLE_VERBOSE}static set enableVerbose(e){u.ENABLE_VERBOSE=e,I._notifyChange()}static get enableInfo(){return u.ENABLE_INFO}static set enableInfo(e){u.ENABLE_INFO=e,I._notifyChange()}static get enableWarn(){return u.ENABLE_WARN}static set enableWarn(e){u.ENABLE_WARN=e,I._notifyChange()}static get enableError(){return u.ENABLE_ERROR}static set enableError(e){u.ENABLE_ERROR=e,I._notifyChange()}static getConfig(){return{globalTag:u.GLOBAL_TAG,forceGlobalTag:u.FORCE_GLOBAL_TAG,enableVerbose:u.ENABLE_VERBOSE,enableDebug:u.ENABLE_DEBUG,enableInfo:u.ENABLE_INFO,enableWarn:u.ENABLE_WARN,enableError:u.ENABLE_ERROR,enableCallback:u.ENABLE_CALLBACK}}static applyConfig(e){u.GLOBAL_TAG=e.globalTag,u.FORCE_GLOBAL_TAG=e.forceGlobalTag,u.ENABLE_VERBOSE=e.enableVerbose,u.ENABLE_DEBUG=e.enableDebug,u.ENABLE_INFO=e.enableInfo,u.ENABLE_WARN=e.enableWarn,u.ENABLE_ERROR=e.enableError,u.ENABLE_CALLBACK=e.enableCallback}static _notifyChange(){let e=I.emitter;if(e.listenerCount("change")>0){let t=I.getConfig();e.emit("change",t)}}static registerListener(e){I.emitter.addListener("change",e)}static removeListener(e){I.emitter.removeListener("change",e)}static addLogListener(e){u.emitter.addListener("log",e),u.emitter.listenerCount("log")>0&&(u.ENABLE_CALLBACK=!0,I._notifyChange())}static removeLogListener(e){u.emitter.removeListener("log",e),0===u.emitter.listenerCount("log")&&(u.ENABLE_CALLBACK=!1,I._notifyChange())}}I.emitter=new l.a;var D=I;var P=class{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,n=this._search(t.times,e);return{index:n,milliseconds:t.times[n],fileposition:t.filepositions[n]}}_search(e,t){let n=0,r=e.length-1,i=0,o=0,a=r;for(t<e[0]&&(n=0,o=a+1);o<=a;){if(i=o+Math.floor((a-o)/2),i===r||t>=e[i]&&t<e[i+1]){n=i;break}e[i]<t?o=i+1:a=i-1}return n}};function B(e,t,n){let r=e;if(t+n<r.length){for(;n--;)if(128!=(192&r[++t]))return!1;return!0}return!1}var U=function(e){let t=[],n=e,r=0,i=e.length;for(;r<i;)if(n[r]<128)t.push(String.fromCharCode(n[r])),++r;else{if(n[r]<192);else if(n[r]<224){if(B(n,r,1)){let e=(31&n[r])<<6|63&n[r+1];if(e>=128){t.push(String.fromCharCode(65535&e)),r+=2;continue}}}else if(n[r]<240){if(B(n,r,2)){let e=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),r+=3;continue}}}else if(n[r]<248&&B(n,r,3)){let e=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")};let N=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class F{static parseScriptData(e,t,n){let r={};try{let i=F.parseValue(e,t,n),o=F.parseValue(e,t+i.size,n-i.size);r[i.data]=o.data}catch(e){u.e("AMF",e.toString())}return r}static parseObject(e,t,n){if(n<3)throw new p("Data not enough when parse ScriptDataObject");let r=F.parseString(e,t,n),i=F.parseValue(e,t+r.size,n-r.size),o=i.objectEnd;return{data:{name:r.data,value:i.data},size:r.size+i.size,objectEnd:o}}static parseVariable(e,t,n){return F.parseObject(e,t,n)}static parseString(e,t,n){if(n<2)throw new p("Data not enough when parse String");let r,i=new DataView(e,t,n).getUint16(0,!N);return r=i>0?U(new Uint8Array(e,t+2,i)):"",{data:r,size:2+i}}static parseLongString(e,t,n){if(n<4)throw new p("Data not enough when parse LongString");let r,i=new DataView(e,t,n).getUint32(0,!N);return r=i>0?U(new Uint8Array(e,t+4,i)):"",{data:r,size:4+i}}static parseDate(e,t,n){if(n<10)throw new p("Data size invalid when parse Date");let r=new DataView(e,t,n),i=r.getFloat64(0,!N);return i+=60*r.getInt16(8,!N)*1e3,{data:new Date(i),size:10}}static parseValue(e,t,n){if(n<1)throw new p("Data not enough when parse Value");let r,i=new DataView(e,t,n),o=1,a=i.getUint8(0),s=!1;try{switch(a){case 0:r=i.getFloat64(1,!N),o+=8;break;case 1:r=!!i.getUint8(1),o+=1;break;case 2:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}case 3:{r={};let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o<n-4;){let i=F.parseObject(e,t+o,n-o-a);if(i.objectEnd)break;r[i.data.name]=i.data.value,o+=i.size}if(o<=n-3){9===(16777215&i.getUint32(o-1,!N))&&(o+=3)}break}case 8:{r={},o+=4;let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o<n-8;){let i=F.parseVariable(e,t+o,n-o-a);if(i.objectEnd)break;r[i.data.name]=i.data.value,o+=i.size}if(o<=n-3){9===(16777215&i.getUint32(o-1,!N))&&(o+=3)}break}case 9:r=void 0,o=1,s=!0;break;case 10:{r=[];let a=i.getUint32(1,!N);o+=4;for(let i=0;i<a;i++){let i=F.parseValue(e,t+o,n-o);r.push(i.data),o+=i.size}break}case 11:{let i=F.parseDate(e,t+1,n-1);r=i.data,o+=i.size;break}case 12:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}default:o=n,u.w("AMF","Unsupported AMF value type "+a)}}catch(e){u.e("AMF",e.toString())}return{data:r,size:o,objectEnd:s}}}var q=F;var j=class{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)throw new p("ExpGolomb: _fillCurrentWord() but no bytes available");let t=Math.min(4,e),n=new Uint8Array(4);n.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(n.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32)throw new f("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let n=e-this._current_word_bits_left;this._fillCurrentWord();let r=Math.min(n,this._current_word_bits_left),i=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,t=t<<r|i,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(0!=(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}};class V{static _ebsp2rbsp(e){let t=e,n=t.byteLength,r=new Uint8Array(n),i=0;for(let e=0;e<n;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[i]=t[e],i++);return new Uint8Array(r.buffer,0,i)}static parseSPS(e){let t=V._ebsp2rbsp(e),n=new j(t);n.readByte();let r=n.readByte();n.readByte();let i=n.readByte();n.readUEG();let o=V.getProfileString(r),a=V.getLevelString(i),s=1,l=420,c=[0,420,422,444],u=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(s=n.readUEG(),3===s&&n.readBits(1),s<=3&&(l=c[s]),u=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool())){let e=3!==s?8:12;for(let t=0;t<e;t++)n.readBool()&&(t<6?V._skipScalingList(n,16):V._skipScalingList(n,64))}n.readUEG();let d=n.readUEG();if(0===d)n.readUEG();else if(1===d){n.readBits(1),n.readSEG(),n.readSEG();let e=n.readUEG();for(let t=0;t<e;t++)n.readSEG()}let h=n.readUEG();n.readBits(1);let p=n.readUEG(),f=n.readUEG(),m=n.readBits(1);0===m&&n.readBits(1),n.readBits(1);let y=0,g=0,v=0,b=0;n.readBool()&&(y=n.readUEG(),g=n.readUEG(),v=n.readUEG(),b=n.readUEG());let _=1,w=1,S=0,k=!0,E=0,A=0;if(n.readBool()){if(n.readBool()){let e=n.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],r=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(_=t[e-1],w=r[e-1]):255===e&&(_=n.readByte()<<8|n.readByte(),w=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){let e=n.readBits(32),t=n.readBits(32);k=n.readBool(),E=t,A=2*e,S=E/A}}let x=1;1===_&&1===w||(x=_/w);let T=0,R=0;if(0===s)T=1,R=2-m;else{T=3===s?1:2,R=(1===s?2:1)*(2-m)}let C=16*(p+1),M=16*(f+1)*(2-m);C-=(y+g)*T,M-=(v+b)*R;let L=Math.ceil(C*x);return n.destroy(),n=null,{profile_string:o,level_string:a,bit_depth:u,ref_frames:h,chroma_format:l,chroma_format_string:V.getChromaFormatString(l),frame_rate:{fixed:k,fps:S,fps_den:A,fps_num:E},sar_ratio:{width:_,height:w},codec_size:{width:C,height:M},present_size:{width:L,height:M}}}static _skipScalingList(e,t){let n=8,r=8,i=0;for(let o=0;o<t;o++)0!==r&&(i=e.readSEG(),r=(n+i+256)%256),n=0===r?n:r}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var Y=V;var W={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};class z{constructor(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new P,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(e){let t=new Uint8Array(e),n={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return n;let r=(4&t[4])>>>2!=0,i=0!=(1&t[4]),o=(a=t)[s=5]<<24|a[s+1]<<16|a[s+2]<<8|a[s+3];var a,s;return o<9?n:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:r,hasVideoTrack:i}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new P}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new p("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let n=0,r=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;n=z.probe(e).dataOffset}if(this._firstParse){this._firstParse=!1,t+n!==this._dataOffset&&u.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==new DataView(e,n).getUint32(0,!r)&&u.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4}for(;n<e.byteLength;){this._dispatch=!0;let i=new DataView(e,n);if(n+11+4>e.byteLength)break;let o=i.getUint8(0),a=16777215&i.getUint32(0,!r);if(n+11+a+4>e.byteLength)break;if(8!==o&&9!==o&&18!==o){u.w(this.TAG,`Unsupported tag type ${o}, skipped`),n+=11+a+4;continue}let s=i.getUint8(4),l=i.getUint8(5),c=i.getUint8(6)|l<<8|s<<16|i.getUint8(7)<<24;0!==(16777215&i.getUint32(7,!r))&&u.w(this.TAG,"Meet tag which has StreamID != 0!");let d=n+11;switch(o){case 8:this._parseAudioData(e,d,a,c);break;case 9:this._parseVideoData(e,d,a,c,t+n);break;case 18:this._parseScriptData(e,d,a)}let h=i.getUint32(11+a,!r);h!==11+a&&u.w(this.TAG,"Invalid PrevTagSize "+h),n+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n}_parseScriptData(e,t,n){let r=q.parseScriptData(e,t,n);if(r.hasOwnProperty("onMetaData")){if(null==r.onMetaData||"object"!=typeof r.onMetaData)return void u.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&u.w(this.TAG,"Found another onMetaData tag!"),this._metadata=r;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"==typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"==typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"==typeof e.width&&(this._mediaInfo.width=e.width),"number"==typeof e.height&&(this._mediaInfo.height=e.height),"number"==typeof e.duration){if(!this._durationOverrided){let t=Math.floor(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}}else this._mediaInfo.duration=0;if("number"==typeof e.framerate){let t=Math.floor(1e3*e.framerate);if(t>0){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"==typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,u.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(r).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},r))}_parseKeyframesIndex(e){let t=[],n=[];for(let r=1;r<e.times.length;r++){let i=this._timestampBase+Math.floor(1e3*e.times[r]);t.push(i),n.push(e.filepositions[r])}return{times:t,filepositions:n}}_parseAudioData(e,t,n,r){if(n<=1)return void u.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0===this._hasAudioFlagOverrided&&!1===this._hasAudio)return;this._littleEndian;let i=new DataView(e,t,n).getUint8(0),o=i>>>4;if(2!==o&&10!==o)return void this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+o);let a=0,s=(12&i)>>>2;if(!(s>=0&&s<=4))return void this._onError(W.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+s);a=this._flvSoundRateTable[s];let l=1&i,c=this._audioMetadata,d=this._audioTrack;if(c||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),c=this._audioMetadata={},c.type="audio",c.id=d.id,c.timescale=this._timescale,c.duration=this._duration,c.audioSampleRate=a,c.channelCount=0===l?1:2),10===o){let i=this._parseAACAudioData(e,t+1,n-1);if(null==i)return;if(0===i.packetType){c.config&&u.w(this.TAG,"Found another AudioSpecificConfig!");let e=i.data;c.audioSampleRate=e.samplingRate,c.channelCount=e.channelCount,c.codec=e.codec,c.originalCodec=e.originalCodec,c.config=e.config,c.refSampleDuration=1024/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",c);let t=this._mediaInfo;t.audioCodec=c.originalCodec,t.audioSampleRate=c.audioSampleRate,t.audioChannelCount=c.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===i.packetType){let e=this._timestampBase+r,t={unit:i.data,length:i.data.byteLength,dts:e,pts:e};d.samples.push(t),d.length+=i.data.length}else u.e(this.TAG,"Flv: Unsupported AAC data type "+i.packetType)}else if(2===o){if(!c.codec){let r=this._parseMP3AudioData(e,t+1,n-1,!0);if(null==r)return;c.audioSampleRate=r.samplingRate,c.channelCount=r.channelCount,c.codec=r.codec,c.originalCodec=r.originalCodec,c.refSampleDuration=1152/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",c);let i=this._mediaInfo;i.audioCodec=c.codec,i.audioSampleRate=c.audioSampleRate,i.audioChannelCount=c.channelCount,i.audioDataRate=r.bitRate,i.hasVideo?null!=i.videoCodec&&(i.mimeType='video/x-flv; codecs="'+i.videoCodec+","+i.audioCodec+'"'):i.mimeType='video/x-flv; codecs="'+i.audioCodec+'"',i.isComplete()&&this._onMediaInfo(i)}let i=this._parseMP3AudioData(e,t+1,n-1,!1);if(null==i)return;let o=this._timestampBase+r,a={unit:i,length:i.byteLength,dts:o,pts:o};d.samples.push(a),d.length+=i.length}}_parseAACAudioData(e,t,n){if(n<=1)return void u.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let r={},i=new Uint8Array(e,t,n);return r.packetType=i[0],0===i[0]?r.data=this._parseAACAudioSpecificConfig(e,t+1,n-1):r.data=i.subarray(1),r}_parseAACAudioSpecificConfig(e,t,n){let r=new Uint8Array(e,t,n),i=null,o=0,a=0,s=null,l=0,c=null;if(o=a=r[0]>>>3,l=(7&r[0])<<1|r[1]>>>7,l<0||l>=this._mpegSamplingRates.length)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let u=this._mpegSamplingRates[l],d=(120&r[1])>>>3;if(d<0||d>=8)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===o&&(c=(7&r[1])<<1|r[2]>>>7,s=(124&r[2])>>>2);let h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?l>=6?(o=5,i=new Array(4),c=l-3):(o=2,i=new Array(2),c=l):-1!==h.indexOf("android")?(o=2,i=new Array(2),c=l):(o=5,c=l,i=new Array(4),l>=6?c=l-3:1===d&&(o=2,i=new Array(2),c=l)),i[0]=o<<3,i[0]|=(15&l)>>>1,i[1]=(15&l)<<7,i[1]|=(15&d)<<3,5===o&&(i[1]|=(15&c)>>>1,i[2]=(1&c)<<7,i[2]|=8,i[3]=0),{config:i,samplingRate:u,channelCount:d,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,n,r){if(n<4)return void u.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let i=new Uint8Array(e,t,n),o=null;if(r){if(255!==i[0])return;let e=i[1]>>>3&3,t=(6&i[1])>>1,n=(240&i[2])>>>4,r=(12&i[2])>>>2,a=3!==(i[3]>>>6&3)?2:1,s=0,l=0,c=34,u="mp3";switch(e){case 0:s=this._mpegAudioV25SampleRateTable[r];break;case 2:s=this._mpegAudioV20SampleRateTable[r];break;case 3:s=this._mpegAudioV10SampleRateTable[r]}switch(t){case 1:c=34,n<this._mpegAudioL3BitRateTable.length&&(l=this._mpegAudioL3BitRateTable[n]);break;case 2:c=33,n<this._mpegAudioL2BitRateTable.length&&(l=this._mpegAudioL2BitRateTable[n]);break;case 3:c=32,n<this._mpegAudioL1BitRateTable.length&&(l=this._mpegAudioL1BitRateTable[n])}o={bitRate:l,samplingRate:s,channelCount:a,codec:u,originalCodec:u}}else o=i;return o}_parseVideoData(e,t,n,r,i){if(n<=1)return void u.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0===this._hasVideoFlagOverrided&&!1===this._hasVideo)return;let o=new Uint8Array(e,t,n)[0],a=(240&o)>>>4,s=15&o;7===s?this._parseAVCVideoPacket(e,t+1,n-1,r,i,a):this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+s)}_parseAVCVideoPacket(e,t,n,r,i,o){if(n<4)return void u.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,s=new DataView(e,t,n),l=s.getUint8(0),c=(16777215&s.getUint32(0,!a))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,n-4);else if(1===l)this._parseAVCVideoData(e,t+4,n-4,r,i,o,c);else if(2!==l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,n){if(n<7)return void u.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let r=this._videoMetadata,i=this._videoTrack,o=this._littleEndian,a=new DataView(e,t,n);r?void 0!==r.avcc&&u.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),r=this._videoMetadata={},r.type="video",r.id=i.id,r.timescale=this._timescale,r.duration=this._duration);let s=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==s||0===l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(W.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let c=31&a.getUint8(5);if(0===c)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");c>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+c);let d=6;for(let n=0;n<c;n++){let i=a.getUint16(d,!o);if(d+=2,0===i)continue;let s=new Uint8Array(e,t+d,i);d+=i;let l=Y.parseSPS(s);if(0!==n)continue;r.codecWidth=l.codec_size.width,r.codecHeight=l.codec_size.height,r.presentWidth=l.present_size.width,r.presentHeight=l.present_size.height,r.profile=l.profile_string,r.level=l.level_string,r.bitDepth=l.bit_depth,r.chromaFormat=l.chroma_format,r.sarRatio=l.sar_ratio,r.frameRate=l.frame_rate,!1!==l.frame_rate.fixed&&0!==l.frame_rate.fps_num&&0!==l.frame_rate.fps_den||(r.frameRate=this._referenceFrameRate);let c=r.frameRate.fps_den,u=r.frameRate.fps_num;r.refSampleDuration=r.timescale*(c/u);let h=s.subarray(1,4),p="avc1.";for(let e=0;e<3;e++){let t=h[e].toString(16);t.length<2&&(t="0"+t),p+=t}r.codec=p;let f=this._mediaInfo;f.width=r.codecWidth,f.height=r.codecHeight,f.fps=r.frameRate.fps,f.profile=r.profile,f.level=r.level,f.refFrames=l.ref_frames,f.chromaFormat=l.chroma_format_string,f.sarNum=r.sarRatio.width,f.sarDen=r.sarRatio.height,f.videoCodec=p,f.hasAudio?null!=f.audioCodec&&(f.mimeType='video/x-flv; codecs="'+f.videoCodec+","+f.audioCodec+'"'):f.mimeType='video/x-flv; codecs="'+f.videoCodec+'"',f.isComplete()&&this._onMediaInfo(f)}let h=a.getUint8(d);if(0!==h){h>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+h),d++;for(let e=0;e<h;e++){let e=a.getUint16(d,!o);d+=2,0!==e&&(d+=e)}r.avcc=new Uint8Array(n),r.avcc.set(new Uint8Array(e,t,n),0),u.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",r)}else this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}_parseAVCVideoData(e,t,n,r,i,o,a){let s=this._littleEndian,l=new DataView(e,t,n),c=[],d=0,h=0;const p=this._naluLengthSize;let f=this._timestampBase+r,m=1===o;for(;h<n;){if(h+4>=n){u.w(this.TAG,`Malformed Nalu near timestamp ${f}, offset = ${h}, dataSize = ${n}`);break}let r=l.getUint32(h,!s);if(3===p&&(r>>>=8),r>n-p)return void u.w(this.TAG,`Malformed Nalus near timestamp ${f}, NaluSize > DataSize!`);let i=31&l.getUint8(h+p);5===i&&(m=!0);let o=new Uint8Array(e,t+h,p+r),a={type:i,data:o};c.push(a),d+=o.byteLength,h+=p+r}if(c.length){let e=this._videoTrack,t={units:c,length:d,isKeyframe:m,dts:f,cts:a,pts:f+a};m&&(t.fileposition=i),e.samples.push(t),e.length+=d}}}var H=z;class G{static init(){G.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let e in G.types)G.types.hasOwnProperty(e)&&(G.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=G.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_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]),e.HDLR_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]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,n=null,r=Array.prototype.slice.call(arguments,1),i=r.length;for(let e=0;e<i;e++)t+=r[e].byteLength;n=new Uint8Array(t),n[0]=t>>>24&255,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n.set(e,4);let o=8;for(let e=0;e<i;e++)n.set(r[e],o),o+=r[e].byteLength;return n}static generateInitSegment(e){let t=G.box(G.types.ftyp,G.constants.FTYP),n=G.moov(e),r=new Uint8Array(t.byteLength+n.byteLength);return r.set(t,0),r.set(n,t.byteLength),r}static moov(e){let t=G.mvhd(e.timescale,e.duration),n=G.trak(e),r=G.mvex(e);return G.box(G.types.moov,t,n,r)}static mvhd(e,t){return G.box(G.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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]))}static trak(e){return G.box(G.types.trak,G.tkhd(e),G.mdia(e))}static tkhd(e){let t=e.id,n=e.duration,r=e.presentWidth,i=e.presentHeight;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,i>>>8&255,255&i,0,0]))}static mdia(e){return G.box(G.types.mdia,G.mdhd(e),G.hdlr(e),G.minf(e))}static mdhd(e){let t=e.timescale,n=e.duration;return G.box(G.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?G.constants.HDLR_AUDIO:G.constants.HDLR_VIDEO,G.box(G.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?G.box(G.types.smhd,G.constants.SMHD):G.box(G.types.vmhd,G.constants.VMHD),G.box(G.types.minf,t,G.dinf(),G.stbl(e))}static dinf(){return G.box(G.types.dinf,G.box(G.types.dref,G.constants.DREF))}static stbl(e){return G.box(G.types.stbl,G.stsd(e),G.box(G.types.stts,G.constants.STTS),G.box(G.types.stsc,G.constants.STSC),G.box(G.types.stsz,G.constants.STSZ),G.box(G.types.stco,G.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp3(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp4a(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.avc1(e))}static mp3(e){let t=e.channelCount,n=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return G.box(G.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,n=e.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return G.box(G.types.mp4a,r,G.esds(e))}static esds(e){let t=e.config||[],n=t.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return G.box(G.types.esds,r)}static avc1(e){let t=e.avcc,n=e.codecWidth,r=e.codecHeight,i=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,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return G.box(G.types.avc1,i,G.box(G.types.avcC,t))}static mvex(e){return G.box(G.types.mvex,G.trex(e))}static trex(e){let t=e.id,n=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return G.box(G.types.trex,n)}static moof(e,t){return G.box(G.types.moof,G.mfhd(e.sequenceNumber),G.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return G.box(G.types.mfhd,t)}static traf(e,t){let n=e.id,r=G.box(G.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),i=G.box(G.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),o=G.sdtp(e),a=G.trun(e,o.byteLength+16+16+8+16+8+8);return G.box(G.types.traf,r,i,a,o)}static sdtp(e){let t=e.samples||[],n=t.length,r=new Uint8Array(4+n);for(let e=0;e<n;e++){let n=t[e].flags;r[e+4]=n.isLeading<<6|n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy}return G.box(G.types.sdtp,r)}static trun(e,t){let n=e.samples||[],r=n.length,i=12+16*r,o=new Uint8Array(i);t+=8+i,o.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<r;e++){let t=n[e].duration,r=n[e].size,i=n[e].flags,a=n[e].cts;o.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*e)}return G.box(G.types.trun,o)}static mdat(e){return G.box(G.types.mdat,e)}}G.init();var K=G;var Q=class{static getSilentFrame(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])}return null}};class X{constructor(e,t,n,r,i){this.dts=e,this.pts=t,this.duration=n,this.originalDts=r,this.isSyncPoint=i,this.fileposition=null}}class Z{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class J{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))}getLastSyncPointBeforeDts(e){if(0==this._list.length)return null;let t=this._list,n=0,r=t.length-1,i=0,o=0,a=r;for(e<t[0].dts&&(n=0,o=a+1);o<=a;){if(i=o+Math.floor((a-o)/2),i===r||e>=t[i].dts&&e<t[i+1].dts){n=i;break}t[i].dts<e?o=i+1:a=i-1}return this._list[n]}}class ${constructor(e){this._type=e,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return 0===this._list.length}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(e){let t=this._list;if(0===t.length)return-2;let n=t.length-1,r=0,i=0,o=n,a=0;if(e<t[0].originalBeginDts)return a=-1,a;for(;i<=o;){if(r=i+Math.floor((o-i)/2),r===n||e>t[r].lastSample.originalDts&&e<t[r+1].originalBeginDts){a=r;break}t[r].originalBeginDts<e?i=r+1:o=r-1}return a}_searchNearestSegmentAfter(e){return this._searchNearestSegmentBefore(e)+1}append(e){let t=this._list,n=e,r=this._lastAppendLocation,i=0;-1!==r&&r<t.length&&n.originalBeginDts>=t[r].lastSample.originalDts&&(r===t.length-1||r<t.length-1&&n.originalBeginDts<t[r+1].originalBeginDts)?i=r+1:t.length>0&&(i=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=i,this._list.splice(i,0,n)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),n=this._list[t].syncPoints;for(;0===n.length&&t>0;)t--,n=this._list[t].syncPoints;return n.length>0?n[n.length-1]:null}}var ee=class{constructor(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new $("audio"),this._videoSegmentInfoList=new $("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!_.chrome||!(_.version.major<50||50===_.version.major&&_.version.build<2661)),this._fillSilentAfterSeek=_.msedge||_.msie,this._mp3UseMpegAudio=!_.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new p("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let n=null,r="mp4",i=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(r="mpeg",i="",n=new Uint8Array):n=K.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,n=K.generateInitSegment(t)}if(!this._onInitSegment)throw new p("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:n.buffer,codec:i,container:`${e}/${r}`,mediaDuration:t.duration})}_calculateDtsBase(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,n={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(n.samples.push(e),n.length=e.length);let r={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(r.samples.push(t),r.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(n,!0),this._remuxAudio(r,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,c=this._dtsBaseInited&&void 0===this._audioNextDts,d=!1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let h=0,p=null,f=0;l?(h=0,f=n.length):(h=8,f=8+n.length);let m=null;if(r.length>1&&(m=r.pop(),f-=m.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(e),f+=e.length}null!=m&&(this._audioStashedLastSample=m);let y=r[0].dts-this._dtsBase;if(this._audioNextDts)i=y-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())i=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(d=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(y);if(null!=e){let t=y-(e.originalDts+e.duration);t<=3&&(t=0),i=y-(e.dts+e.duration+t)}else i=0}if(d){let e=y-i,t=this._videoSegmentInfoList.getLastSegmentBefore(y);if(null!=t&&t.beginDts<e){let n=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(n){let i=t.beginDts,o=e-t.beginDts;u.v(this.TAG,`InsertPrefixSilentAudio: dts: ${i}, duration: ${o}`),r.unshift({unit:n,dts:i,pts:i}),f+=n.byteLength}}else d=!1}let g=[];for(let e=0;e<r.length;e++){let t=r[e],n=t.unit,a=t.dts-this._dtsBase,l=a-i;-1===o&&(o=l);let c=0;if(e!==r.length-1){c=r[e+1].dts-this._dtsBase-i-l}else if(null!=m){c=m.dts-this._dtsBase-i-l}else c=g.length>=1?g[g.length-1].duration:Math.floor(s);let d=!1,h=null;if(c>1.5*s&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!_.safari){d=!0;let e=Math.abs(c-s),t=Math.ceil(e/s),r=l+s;u.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${l+c} ms, expected: ${l+Math.round(s)} ms, delta: ${Math.round(e)} ms, generate: ${t} frames`);let i=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==i&&(u.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),i=n),h=[];for(let e=0;e<t;e++){let e=Math.round(r);if(h.length>0){let t=h[h.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:i,size:i.byteLength,duration:0,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};h.push(t),f+=t.size,r+=s}let o=h[h.length-1];o.duration=l+c-o.dts,c=Math.round(s)}g.push({dts:l,pts:l,cts:0,unit:t.unit,size:t.unit.byteLength,duration:c,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,h)}l?p=new Uint8Array(f):(p=new Uint8Array(f),p[0]=f>>>24&255,p[1]=f>>>16&255,p[2]=f>>>8&255,p[3]=255&f,p.set(K.types.mdat,4));for(let e=0;e<g.length;e++){let t=g[e].unit;p.set(t,h),h+=t.byteLength}let v=g[g.length-1];a=v.dts+v.duration,this._audioNextDts=a;let b=new Z;b.beginDts=o,b.endDts=a,b.beginPts=o,b.endPts=a,b.originalBeginDts=g[0].originalDts,b.originalEndDts=v.originalDts+v.duration,b.firstSample=new X(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,!1),b.lastSample=new X(v.dts,v.pts,v.duration,v.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(b),n.samples=g,n.sequenceNumber++;let w=null;w=l?new Uint8Array:K.moof(n,o),n.samples=[],n.length=0;let S={type:"audio",data:this._mergeBoxes(w,p).buffer,sampleCount:g.length,info:b};l&&c&&(S.timestampOffset=o),this._onMediaSegment("audio",S)}_remuxVideo(e,t){if(null==this._videoMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=-1,l=-1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let c=8,u=null,d=8+e.length,h=null;if(r.length>1&&(h=r.pop(),d-=h.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,r.unshift(e),d+=e.length}null!=h&&(this._videoStashedLastSample=h);let p=r[0].dts-this._dtsBase;if(this._videoNextDts)i=p-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())i=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0),i=p-(e.dts+e.duration+t)}else i=0}let f=new Z,m=[];for(let e=0;e<r.length;e++){let t=r[e],n=t.dts-this._dtsBase,a=t.isKeyframe,l=n-i,c=t.cts,u=l+c;-1===o&&(o=l,s=u);let d=0;if(e!==r.length-1){d=r[e+1].dts-this._dtsBase-i-l}else if(null!=h){d=h.dts-this._dtsBase-i-l}else d=m.length>=1?m[m.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(a){let e=new X(l,u,d,t.dts,!0);e.fileposition=t.fileposition,f.appendSyncPoint(e)}m.push({dts:l,pts:u,cts:c,units:t.units,size:t.length,isKeyframe:a,duration:d,originalDts:n,flags:{isLeading:0,dependsOn:a?2:1,isDependedOn:a?1:0,hasRedundancy:0,isNonSync:a?0:1}})}u=new Uint8Array(d),u[0]=d>>>24&255,u[1]=d>>>16&255,u[2]=d>>>8&255,u[3]=255&d,u.set(K.types.mdat,4);for(let e=0;e<m.length;e++){let t=m[e].units;for(;t.length;){let e=t.shift().data;u.set(e,c),c+=e.byteLength}}let y=m[m.length-1];if(a=y.dts+y.duration,l=y.pts+y.duration,this._videoNextDts=a,f.beginDts=o,f.endDts=a,f.beginPts=s,f.endPts=l,f.originalBeginDts=m[0].originalDts,f.originalEndDts=y.originalDts+y.duration,f.firstSample=new X(m[0].dts,m[0].pts,m[0].duration,m[0].originalDts,m[0].isKeyframe),f.lastSample=new X(y.dts,y.pts,y.duration,y.originalDts,y.isKeyframe),this._isLive||this._videoSegmentInfoList.append(f),n.samples=m,n.sequenceNumber++,this._forceFirstIDR){let e=m[0].flags;e.dependsOn=2,e.isNonSync=0}let g=K.moof(n,o);n.samples=[],n.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(g,u).buffer,sampleCount:m.length,info:f})}_mergeBoxes(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}};var te={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};var ne=class{constructor(e,t){this.TAG="TransmuxingController",this._emitter=new l.a,this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;let n=0;this._mediaDataSource.segments.forEach(r=>{r.timestampBase=n,n+=r.duration,r.cors=e.cors,r.withCredentials=e.withCredentials,t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy)}),isNaN(n)||this._mediaDataSource.duration===n||(this._mediaDataSource.duration=n),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let n=this._mediaDataSource.segments[e],r=this._ioctl=new T(n,this._config,e);r.onError=this._onIOException.bind(this),r.onSeeked=this._onIOSeeked.bind(this),r.onComplete=this._onIOComplete.bind(this),r.onRedirect=this._onIORedirect.bind(this),r.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):r.onDataArrival=this._onInitChunkArrival.bind(this),r.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e;else{let t=n.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let r=n.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,r.fileposition),this._pendingResolveSeekPoint=r.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,n=t.length-1;for(let r=0;r<t.length;r++)if(e<t[r].timestampBase){n=r-1;break}return n}_onInitChunkArrival(e,t){let n=null,r=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=H.probe(e)).match){this._demuxer=new H(n,this._config),this._remuxer||(this._remuxer=new ee(this._config));let i=this._mediaDataSource;null==i.duration||isNaN(i.duration)||(this._demuxer.overridedDuration=i.duration),"boolean"==typeof i.hasAudio&&(this._demuxer.overridedHasAudio=i.hasAudio),"boolean"==typeof i.hasVideo&&(this._demuxer.overridedHasVideo=i.hasVideo),this._demuxer.timestampBase=i.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else n=null,u.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(te.DEMUX_ERROR,W.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}_onMediaInfo(e){null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,P.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,P.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(te.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer.flushStashedSamples(),this._emitter.emit(te.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(e){let t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e}_onIORecoveredEarlyEof(){this._emitter.emit(te.RECOVERED_EARLY_EOF)}_onIOException(e,t){u.e(this.TAG,`IOException: type = ${e}, code = ${t.code}, msg = ${t.msg}`),this._emitter.emit(te.IO_ERROR,e,t),this._disableStatisticsReporter()}_onDemuxException(e,t){u.e(this.TAG,`DemuxException: type = ${e}, info = ${t}`),this._emitter.emit(te.DEMUX_ERROR,e,t)}_onRemuxerInitSegmentArrival(e,t){this._emitter.emit(te.INIT_SEGMENT,e,t)}_onRemuxerMediaSegmentArrival(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(te.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){let e=t.info.syncPoints,n=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,_.safari&&e.length>0&&e[0].originalDts===n&&(n=e[0].pts),this._emitter.emit(te.RECOMMEND_SEEKPOINT,n)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],n=Object.assign({},t);n.duration=this._mediaInfo.duration,n.segmentCount=this._mediaInfo.segmentCount,delete n.segments,delete n.keyframesIndex,this._emitter.emit(te.MEDIA_INFO,n)}_reportStatisticsInfo(){let e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(te.STATISTICS_INFO,e)}};var re=function(e){let t=null,n=function(t,n){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:n}})}.bind(this);function r(t,n){let r={msg:te.INIT_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function i(t,n){let r={msg:te.MEDIA_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function o(){let t={msg:te.LOADING_COMPLETE};e.postMessage(t)}function s(){let t={msg:te.RECOVERED_EARLY_EOF};e.postMessage(t)}function l(t){let n={msg:te.MEDIA_INFO,data:t};e.postMessage(n)}function c(t){let n={msg:te.METADATA_ARRIVED,data:t};e.postMessage(n)}function u(t){let n={msg:te.SCRIPTDATA_ARRIVED,data:t};e.postMessage(n)}function d(t){let n={msg:te.STATISTICS_INFO,data:t};e.postMessage(n)}function h(t,n){e.postMessage({msg:te.IO_ERROR,data:{type:t,info:n}})}function p(t,n){e.postMessage({msg:te.DEMUX_ERROR,data:{type:t,info:n}})}function f(t){e.postMessage({msg:te.RECOMMEND_SEEKPOINT,data:t})}a.install(),e.addEventListener("message",(function(a){switch(a.data.cmd){case"init":t=new ne(a.data.param[0],a.data.param[1]),t.on(te.IO_ERROR,h.bind(this)),t.on(te.DEMUX_ERROR,p.bind(this)),t.on(te.INIT_SEGMENT,r.bind(this)),t.on(te.MEDIA_SEGMENT,i.bind(this)),t.on(te.LOADING_COMPLETE,o.bind(this)),t.on(te.RECOVERED_EARLY_EOF,s.bind(this)),t.on(te.MEDIA_INFO,l.bind(this)),t.on(te.METADATA_ARRIVED,c.bind(this)),t.on(te.SCRIPTDATA_ARRIVED,u.bind(this)),t.on(te.STATISTICS_INFO,d.bind(this)),t.on(te.RECOMMEND_SEEKPOINT,f.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(a.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=a.data.param;D.applyConfig(e),!0===e.enableCallback?D.addLogListener(n):D.removeLogListener(n);break}}}))};var ie=class{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new l.a,t.enableWorker&&"undefined"!=typeof Worker)try{let r=n(56);this._worker=r(re),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},D.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:D.getConfig()})}catch(n){u.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ne(e,t)}else this._controller=new ne(e,t);if(this._controller){let e=this._controller;e.on(te.IO_ERROR,this._onIOError.bind(this)),e.on(te.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(te.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(te.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(te.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(te.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(te.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(te.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(te.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(te.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(te.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),D.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(te.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(te.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(te.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,n=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case te.INIT_SEGMENT:case te.MEDIA_SEGMENT:this._emitter.emit(t.msg,n.type,n.data);break;case te.LOADING_COMPLETE:case te.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case te.MEDIA_INFO:Object.setPrototypeOf(n,P.prototype),this._emitter.emit(t.msg,n);break;case te.METADATA_ARRIVED:case te.SCRIPTDATA_ARRIVED:case te.STATISTICS_INFO:this._emitter.emit(t.msg,n);break;case te.IO_ERROR:case te.DEMUX_ERROR:this._emitter.emit(t.msg,n.type,n.info);break;case te.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,n);break;case"logcat_callback":u.emitter.emit("log",n.type,n.logcat)}}};var oe={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var ae=class{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new l.a,this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new J}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new p("MediaSource has been attached to an HTMLMediaElement!");let t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let e=this._mediaSource;for(let t in this._sourceBuffers){let n=this._pendingSegments[t];n.splice(0,n.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let r=this._sourceBuffers[t];if(r){if("closed"!==e.readyState){try{e.removeSourceBuffer(r)}catch(e){u.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){u.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let n=e,r=""+n.container;n.codec&&n.codec.length>0&&(r+=";codecs="+n.codec);let i=!1;if(u.v(this.TAG,"Received Initialization Segment, mimeType: "+r),this._lastInitSegments[n.type]=n,r!==this._mimeTypes[n.type]){if(this._mimeTypes[n.type])u.v(this.TAG,`Notice: ${n.type} mimeType changed, origin: ${this._mimeTypes[n.type]}, target: ${r}`);else{i=!0;try{let e=this._sourceBuffers[n.type]=this._mediaSource.addSourceBuffer(r);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.e(this.TAG,e.message),void this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[n.type]=r}t||this._pendingSegments[n.type].push(n),i||this._sourceBuffers[n.type]&&!this._sourceBuffers[n.type].updating&&this._doAppendSegments(),_.safari&&"audio/mpeg"===n.container&&n.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=n.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let n=this._sourceBuffers[t.type];!n||n.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){u.e(this.TAG,e.message)}this._idrList.clear();let n=this._pendingSegments[e];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(let n=0;n<t.buffered.length;n++){let r=t.buffered.start(n),i=t.buffered.end(n);this._pendingRemoveRanges[e].push({start:r,end:i})}if(t.updating||this._doRemoveRanges(),_.safari){let n=this._lastInitSegments[e];n&&(this._pendingSegments[e].push(n),t.updating||this._doAppendSegments())}}}}endOfStream(){let e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)}getNearestKeyframe(e){return this._idrList.getLastSyncPointBeforeDts(e)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let n=this._sourceBuffers[t];if(n){let t=n.buffered;if(t.length>=1&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let n=this._sourceBuffers[t];if(n){let r=n.buffered,i=!1;for(let n=0;n<r.length;n++){let o=r.start(n),a=r.end(n);if(o<=e&&e<a+3){if(e-o>=this._config.autoCleanupMaxBackwardDuration){i=!0;let n=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:o,end:n})}}else a<e&&(i=!0,this._pendingRemoveRanges[t].push({start:o,end:a}))}i&&!n.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let e=this._sourceBuffers;if(0===this._mediaElement.readyState||"open"!==this._mediaSource.readyState)return;if(e.video&&e.video.updating||e.audio&&e.audio.updating)return;let t=this._mediaSource.duration,n=this._pendingMediaDuration;n>0&&(isNaN(t)||n>t)&&(u.v(this.TAG,`Update MediaSource duration from ${t} to ${n}`),this._mediaSource.duration=n),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let e in this._pendingRemoveRanges){if(!this._sourceBuffers[e]||this._sourceBuffers[e].updating)continue;let t=this._sourceBuffers[e],n=this._pendingRemoveRanges[e];for(;n.length&&!t.updating;){let e=n.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){let n=e[t].shift();if(n.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,r=n.timestampOffset/1e3;Math.abs(e-r)>.1&&(u.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${r}`),this._sourceBuffers[t].timestampOffset=r),delete n.timestampOffset}if(!n.data||0===n.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(n.data),this._isBufferFull=!1,"video"===t&&n.hasOwnProperty("info")&&this._idrList.appendArray(n.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(n),22===e.code?(this._isBufferFull||this._emitter.emit(oe.BUFFER_FULL),this._isBufferFull=!0):(u.e(this.TAG,e.message),this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(u.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;for(;e.length;){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(oe.SOURCE_OPEN)}_onSourceEnded(){u.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){u.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let e=this._pendingSegments;return e.video.length>0||e.audio.length>0}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(oe.UPDATE_END)}_onSourceBufferError(e){u.e(this.TAG,"SourceBuffer Error: "+e)}};const se={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},le={NETWORK_EXCEPTION:g.EXCEPTION,NETWORK_STATUS_CODE_INVALID:g.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:g.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:g.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:W.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:W.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:W.CODEC_UNSUPPORTED};var ce=class{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let n=_.chrome&&(_.version.major<50||50===_.version.major&&_.version.build<2661);this._alwaysSeekKeyframe=!!(n||_.msedge||_.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===O.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new ae(this._config),this._msectl.on(oe.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(oe.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(oe.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(oe.ERROR,e=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,le.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new p("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new ie(this._mediaDataSource,this._config),this._transmuxer.on(te.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(te.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(te.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(O.LOADING_COMPLETE)}),this._transmuxer.on(te.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(O.RECOVERED_EARLY_EOF)}),this._transmuxer.on(te.IO_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.NETWORK_ERROR,e,t)}),this._transmuxer.on(te.DEMUX_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(te.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(O.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(te.METADATA_ARRIVED,e=>{this._emitter.emit(O.METADATA_ARRIVED,e)}),this._transmuxer.on(te.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(O.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(te.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(O.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(te.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open()))}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,n=0,r=0;for(let i=0;i<e.length;i++){let o=e.start(i),a=e.end(i);if(o<=t&&t<a){n=o,r=a;break}}r>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){u.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,n=!1;for(let r=0;r<t.length;r++){let i=t.start(r),o=t.end(r);if(e>=i&&e<o){e>=o-this._config.lazyLoadRecoverDuration&&(n=!0);break}}n&&(window.clearInterval(this._progressChecker),this._progressChecker=null,n&&(u.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let n=0;n<t.length;n++){let r=t.start(n),i=t.end(n);if(e>=r&&e<i)return!0}return!1}_internalSeek(e){let t=this._isTimepointBuffered(e),n=!1,r=0;if(e<1&&this._mediaElement.buffered.length>0){let t=this._mediaElement.buffered.start(0);(t<1&&e<t||_.safari)&&(n=!0,r=_.safari?.1:t)}if(n)this._requestSetTime=!0,this._mediaElement.currentTime=r;else if(t){if(this._alwaysSeekKeyframe){let t=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=t?t.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(e){let t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){let e=t.buffered;e.length>0&&t.currentTime<e.start(0)&&(u.w(this.TAG,`Playback seems stuck at ${t.currentTime}, seek to ${e.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=e.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(e){let t=this._mediaElement.currentTime,n=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&n.length>0){let e=n.start(0);if(e<1&&t<e||_.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=_.safari?.1:e)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){let e=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=e&&(this._requestSetTime=!0,this._mediaElement.currentTime=e.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}}_onvCanPlay(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(e){this._checkAndResumeStuckPlayback(!0)}_onvProgress(e){this._checkAndResumeStuckPlayback()}};var ue=class{constructor(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new f("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new f(`NativePlayer(${e.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===O.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new p("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}};a.install();let de={createPlayer:function(e,t){let n=e;if(null==n||"object"!=typeof n)throw new f("MediaDataSource must be an javascript object!");if(!n.hasOwnProperty("type"))throw new f("MediaDataSource must has type field to indicate video file type!");switch(n.type){case"flv":return new ce(n,t);default:return new ue(n,t)}},isSupported:function(){return L.supportMSEH264Playback()},getFeatureList:function(){return L.getFeatureList()}};de.BaseLoader=v,de.LoaderStatus=y,de.LoaderErrors=g,de.Events=O,de.ErrorTypes=se,de.ErrorDetails=le,de.FlvPlayer=ce,de.NativePlayer=ue,de.LoggingControl=D,Object.defineProperty(de,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var he=de,pe=n(4),fe=n.n(pe),me=n(24),ye={insert:"head",singleton:!1};fe()(me.a,ye),me.a.locals;function ge(e){return(ge="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 ve(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function be(e,t){return(be=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _e(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==ge(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Se(e){return(Se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ke=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&be(e,t)}(a,e);var t,n,r,o=_e(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1},t}return t=a,(n=[{key:"shouldComponentUpdate",value:function(e){return e.videoUrl!==this.props.videoUrl&&(this.flvPlayer&&this.destroyFlv(),this.startFlv(e.videoUrl),!0)}},{key:"componentDidMount",value:function(){this.props.videoUrl&&this.startFlv(this.props.videoUrl)}},{key:"startFlv",value:function(e){var t=this.state.id;if(he.isSupported()){var n=document.getElementById(t);this.flvPlayer&&this.destroyFlv(),this.flvPlayer=he.createPlayer({type:"flv",isLive:!0,hasAudio:!1,url:e},{enableStashBuffer:!0,stashInitialSize:128}),this.flvPlayer.attachMediaElement(n),this.flvPlayer.load(),this.flvPlayer.play()}else alert("请更换浏览器,该浏览器暂不支持。")}},{key:"destroyFlv",value:function(){this.flvPlayer.pause(),this.flvPlayer.unload(),this.flvPlayer.detachMediaElement(),this.flvPlayer.destroy(),this.flvPlayer=null}},{key:"render",value:function(){return i.a.createElement("div",{className:"flvWai"},i.a.createElement("video",{id:this.state.id,className:"videoFlv",autoPlay:!0,controls:!0,muted:!0}))}}])&&ve(t.prototype,n),r&&ve(t,r),a}(r.Component),Ee=n(25),Ae={insert:"head",singleton:!1},xe=(fe()(Ee.a,Ae),Ee.a.locals,n(51)),Te=n.n(xe);function Re(e){return(Re="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 Ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Le(e,t){return(Le=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=De(e);if(t){var i=De(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ie(this,n)}}function Ie(e,t){return!t||"object"!==Re(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function De(e){return(De=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Pe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Le(e,t)}(a,e);var t,n,r,o=Oe(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1,videoUrl:""},t}return t=a,(n=[{key:"shouldComponentUpdate",value:function(e){return!(e.videoUrl===this.props.videoUrl&&this.state.videoUrl||(e.videoUrl&&this.playerFlvVideo(e.videoUrl),0))}},{key:"componentDidMount",value:function(){this.props.videoUrl&&this.playerFlvVideo(this.props.videoUrl)}},{key:"playerFlvVideo",value:function(e){this.setState({videoUrl:e}),this.dp?(this.dp.destroy(),this.flvPlayer.pause(),this.flvPlayer.unload(),this.flvPlayer.detachMediaElement(),this.flvPlayer.destroy(),clearInterval(this.timer),this.timer=null,this.flvPlayer=null,this.dp=null,this.createFlvPlayer(e)):this.createFlvPlayer(e)}},{key:"createFlvPlayer",value:function(e){var t,n=this,r=this.state.id,i=this.props,o=i.volume,a=void 0===o?0:o,s=i.autoplay,l=void 0===s||s,c=i.config,u=void 0===c?{}:c,d=i.maxCount,h=void 0===d?5:d,p=i.testingTimer,f=void 0===p?30:p;this.count=0,this.dp=new Te.a({container:document.getElementById(r),screenshot:!0,autoplay:l,airplay:!0,mutex:!1,volume:a,video:(t={url:e,type:"flv"},Ce(t,"type","customFlv"),Ce(t,"customType",{customFlv:function(e){n.flvPlayer=he.createPlayer({type:"flv",url:e.src},Object.assign({autoCleanupSourceBuffer:!0},u)),n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.timer=setInterval((function(){n.getNewVideo()}),1e3*f),n.flvPlayer.on("error",(function(t){t&&"NetworkError"===t&&(n.count++,parseInt(h)>=n.count?(n.flvPlayer.pause(),n.flvPlayer.unload(),n.flvPlayer.detachMediaElement(),setTimeout((function(){n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.flvPlayer.play()}),500)):(clearInterval(n.timer),n.timer=null,console.log("重连失败")))}))}}),t)})}},{key:"componentWillUnmount",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"getNewVideo",value:function(){var e=this.state.id,t=document.getElementById(e).getElementsByTagName("video")[0];if(t)for(var n=t.buffered,r=0;r<n.length;r++){var i=n.end(r);i>-1&&(t.currentTime=i-.1)}}},{key:"render",value:function(){var e=this.state.id;return i.a.createElement("div",{className:"dplayerWaikuang"},i.a.createElement("div",{id:e,style:{width:"100%",height:"100%"}}))}}])&&Me(t.prototype,n),r&&Me(t,r),a}(r.Component),Be=n(17),Ue=n(26),Ne={insert:"head",singleton:!1};fe()(Ue.a,Ne),Ue.a.locals;function Fe(e){return(Fe="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 qe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function je(e,t){return(je=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=We(e);if(t){var i=We(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Ye(this,n)}}function Ye(e,t){return!t||"object"!==Fe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function We(e){return(We=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ze=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&je(e,t)}(a,e);var t,n,r,o=Ve(a);function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this)).state={showDateTime:"",classInfo:""},e}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.className;return n!==t.className?{classInfo:n}:null}}],(n=[{key:"forShowDateTime",value:function(){var e=this.props.type,t=void 0===e?"YYYY-MM-DD HH:mm:ss":e;this.setState({showDateTime:Object(Be.a)().format(t)})}},{key:"componentDidMount",value:function(){var e=this;this.forShowDateTime(),this.timer=setInterval((function(){e.forShowDateTime()}),1e3)}},{key:"render",value:function(){var e=this.state,t=e.classInfo,n=e.showDateTime;return i.a.createElement("div",{className:"timerComCss"},i.a.createElement("p",{className:t},n))}}])&&qe(t.prototype,n),r&&qe(t,r),a}(r.Component),He=n(27),Ge={insert:"head",singleton:!1};fe()(He.a,Ge),He.a.locals;function Ke(e){return(Ke="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 Qe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Xe(e,t){return(Xe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=$e(e);if(t){var i=$e(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Je(this,n)}}function Je(e,t){return!t||"object"!==Ke(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function $e(e){return($e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var et=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Xe(e,t)}(s,e);var t,r,o,a=Ze(s);function s(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(e=a.call(this)).state={imgUrl:"",httpImg:"",base64Url:""},e}return t=s,o=[{key:"getDerivedStateFromProps",value:function(e,t){var n=e.httpImg,r=e.imgUrl;return n&&n!==t.httpImg?{httpImg:n,imgUrl:r}:r!==t.imgUrl?{imgUrl:r}:null}}],(r=[{key:"shouldComponentUpdate",value:function(e){return this.props.imgUrl!==e.imgUrl?(this.count=0,this.getImage(e.imgUrl),!0):0===this.count&&(this.count++,!0)}},{key:"componentDidMount",value:function(){this.count=0,this.state.httpImg&&this.getImage(this.props.imgUrl)}},{key:"getImage",value:function(e){var t=this,r=this.state.httpImg,i=new XMLHttpRequest;i.open("POST",r),i.setRequestHeader("Content-Type","application/json");var o={reqInfo:{imgPath:e},request:"getImgDataByPath"};i.send(JSON.stringify(o)),i.onreadystatechange=function(){if(4===i.readyState&&(200===i.status||304===i.status)){var e=JSON.parse(i.responseText);0===e.status?t.setImgUrl("data:image/png;base64,"+e.resInfo.imgData):t.setImgUrl(n(60))}}}},{key:"setImgUrl",value:function(e){this.setState({base64Url:e})}},{key:"render",value:function(){var e=this.state.base64Url;return i.a.createElement("img",{className:"imageObject",src:e,alt:""})}}])&&Qe(t.prototype,r),o&&Qe(t,o),s}(r.Component),tt=n(28),nt={insert:"head",singleton:!1};fe()(tt.a,nt),tt.a.locals;function rt(e){return(rt="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 it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function at(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function st(e,t){return(st=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function lt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ut(e);if(t){var i=ut(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return ct(this,n)}}function ct(e,t){return!t||"object"!==rt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ut(e){return(ut=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var dt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&st(e,t)}(a,e);var t,n,r,o=lt(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this,e)).state=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach((function(t){ot(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},e),t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e){var t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length>=r+1){var l=((100-o*(r-1))/r).toFixed(2),c=(parseFloat(l)+o)*(t.length-r),u=document.getElementById("objectTransition");u.style.transition=s+"s all 0s",u.style.left=-c+"%"}return{children:t}}}],(n=[{key:"componentDidUpdate",value:function(){var e=this.props,t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length<r+1){var l=((100-o*(r-1))/r).toFixed(2),c=document.getElementById("objectTransition").childNodes,u=c[c.length-1];u.style.left="100%",u.style.transition=s+"s all 0s",setTimeout((function(){u.style.left=(parseFloat(l)+o)*(c.length-1)+"%"}),1e3*s)}}},{key:"render",value:function(){var e=this.state.children,t=this.props,n=t.count,r=void 0===n?3:n,o=t.leftSpance,a=void 0===o?2:o;return i.a.createElement("div",{className:"objectTransitionOther"},i.a.createElement("div",{id:"objectTransition",className:"objectTransition"},e.map((function(e,t){var n=((100-a*(r-1))/r).toFixed(2);return t>=1&&t<3?i.a.createElement("div",{style:{width:n+"%"},key:t},e):i.a.createElement("div",{style:{width:n+"%",left:(parseFloat(n)+a)*t+"%"},key:t},e)}))))}}])&&at(t.prototype,n),r&&at(t,r),a}(r.Component),ht=n(29),pt={insert:"head",singleton:!1};fe()(ht.a,pt),ht.a.locals;function ft(e){return(ft="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 mt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function yt(e,t){return(yt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function gt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=bt(e);if(t){var i=bt(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return vt(this,n)}}function vt(e,t){return!t||"object"!==ft(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function bt(e){return(bt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var _t=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&yt(e,t)}(a,e);var t,n,r,o=gt(a);function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(e=o.call(this)).state={id:(new Date).getTime()+Math.floor(9999*Math.random())+1,mode:"",width:"100px",height:"100px",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)",disabled:"false",title:"",titleColor:"#000",titleFont:"14px bold 黑体",titleLineHeight:"",titleBackgroundColor:"",titlePadding:"10px",titleTextAlign:"center",titleWidth:100,titleFillColor:"",inputStyle:{},position:[10,10],serviceData:[]},e}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&(n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"shouldComponentUpdate",value:function(e){return this.props.serviceData.length!==e.serviceData}},{key:"componentDidMount",value:function(){this.init()}},{key:"init",value:function(){this.setCanvasSize()}},{key:"setCanvasSize",value:function(){var e=this.state.id,t=document.getElementById(e).parentNode,n=t.offsetWidth,r=t.offsetHeight;this.setData({width:n+"px",height:r+"px"})}},{key:"removeTags",value:function(e,t){for(var n=document.getElementsByTagName(e),r=n.length-1;r>=0;r--)n[r].className==t&&n[r].parentNode.removeChild(n[r])}},{key:"draw",value:function(){var e=this.state,t=e.id,n=e.serviceData,r=e.width,i=e.height,o=e.mode,a=e.disabled,s=document.getElementById(t).getContext("2d");s.clearRect(0,0,parseFloat(r),parseFloat(i)),this.removeTags("input",this.props.listId?this.props.listId:t+""),this.drawLine(s,n),this.drawCircleAll(s,n),this.drawWriting(s,n),"false"===a&&("click"===o?this.isontouchend()?this.touchMove():this.clickMove():this.isontouchend()?this.touchMove():this.mouseMove())}},{key:"isontouchend",value:function(){return"ontouchend"in document}},{key:"drawCircleAll",value:function(e,t){for(var n=0;n<t.length;n++)this.drawCircle(e,t[n][0],t[n][1],this.selectedIndex===n)}},{key:"drawCircle",value:function(e,t,n,r){var i=this.state,o=i.circleRadius,a=i.circleInColor,s=i.circleBorderColor,l=i.circleBorderWidth,c=i.circleSelectColor;e.fillStyle=r?c:a,e.beginPath(),e.arc(t,n,parseInt(o),0,2*Math.PI,!0),e.closePath(),e.fill(),e.beginPath(),e.arc(t,n,parseInt(o),0,2*Math.PI,!0),e.lineWidth=parseInt(l),e.strokeStyle=s,e.stroke(),e.closePath()}},{key:"drawLine",value:function(e,t){var n=this.state,r=n.lineColor,i=n.lineWidth,o=n.areaColor;e.beginPath();for(var a=0;a<t.length;a++)0===a?e.moveTo(t[a][0],t[a][1]):e.lineTo(t[a][0],t[a][1]);e.lineWidth=parseInt(i),e.strokeStyle=r,e.closePath(),e.fillStyle=o,e.fill(),e.stroke()}},{key:"drawWriting",value:function(e,t){var n=this,r=this.state,i=r.title,o=r.titleColor,a=r.titleFont,s=r.titleLineHeight,l=r.position,c=r.titlePadding,u=r.disabled;e.font=a||"18px bold 黑体",e.fillStyle=o||"#fff",e.lineHeight=s||a.split(" ")[0],e.textBaseline="middle";var d=parseInt(s||a.split(" ")[0]);if("true"===u)this.ctxWnzi(e,t);else{for(var h=0,p=99999999,f=0;f<t.length;f++)parseFloat(t[f][0])>h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])<p&&(p=parseFloat(t[f][1]));i&&i.split(/\n/).forEach((function(e,t){n.inputStyleCreate(e,h+(l[0]||15),p+(l[1]||15)+t*(d+3*parseInt(c)),t)}))}}},{key:"ctxWnzi",value:function(e,t){var n=this.state,r=n.title,i=n.titleColor,o=n.titleFont,a=n.titleLineHeight,s=n.position,l=n.titleWidth,c=n.titlePadding,u=n.titleFillColor;e.font=o||"18px bold 黑体",e.lineHeight=a||o.split(" ")[0],e.textBaseline="middle";for(var d=parseInt(a||o.split(" ")[0]),h=0,p=99999999,f=0;f<t.length;f++)parseFloat(t[f][0])>h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])<p&&(p=parseFloat(t[f][1]));r.split(/\n/).forEach((function(t,n){e.fillStyle=u||"rgba(15, 62, 166, 0.2)",e.fill(),e.fillRect(h+(s[0]||15),p+(s[1]||15)+n*(d+2*parseInt(c))-parseFloat(d/2)-parseFloat(parseInt(c)/2),l+parseInt(c),d+parseInt(c)),e.fillStyle=i||"#fff",e.fillText(t,h+(s[0]||15)+parseFloat(parseInt(c)/2),p+(s[1]||15)+n*(d+2*parseInt(c)))}))}},{key:"inputStyleCreate",value:function(e,t,n,r){var i=this,o=this.state,a=o.title,s=o.titleColor,l=o.titleFont,c=o.titleTextAlign,u=o.inputStyle,d=o.titleLineHeight,h=o.titleBackgroundColor,p=o.titleWidth,f=o.titlePadding,m=o.id,y=document.getElementById(m).parentNode,g=document.createElement("input");if(g.style.font=l,g.style.lineHeight=d,g.style.color=s,g.style.backgroundColor=h||"rgba(40, 177, 217, 0.2)",g.style.padding=f,g.style.textAlign=c,g.style.position="absolute",g.style.border="none",g.style.left=t+"px",g.style.top=n+"px",g.style.zIndex="100",g.style.width=p+"px",Object.keys(u).length>0)for(var v in u)g.style[v]=u[v];g.value=e,g.className=this.props.listId?this.props.listId+"":m+"",g.oninput=function(e){var t=a.split(/\n/);t[r]=e.target.value,i.setState({title:t.join("\n")}),i.props.wenziChange(t.join("\n"))},y.appendChild(g)}},{key:"clickMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData;document.getElementById(n).onclick=function(t){var n=t.layerX,i=t.layerY;e.selectedIndex||0===e.selectedIndex?(r[e.selectedIndex]=[n,i],e.selectedIndex=null,e.setData({serviceData:r}),e.sendFather(r)):(e.selectBox(n,i),e.setData({serviceData:r}))}}},{key:"mouseMove",value:function(){var e=this,t=this.state.id,n=document.getElementById(t);n.onmousedown=function(t){var r=e.state.serviceData,i=t.layerX,o=t.layerY;e.selectBox(i,o)&&(n.onmousemove=function(t){r[e.selectedIndex]=[t.layerX,t.layerY],e.setData({serviceData:r})})},n.onmouseup=function(t){n.onmousemove=null,e.selectedIndex=null,e.setData({serviceData:e.state.serviceData});var r=t.layerX,i=t.layerY;e.selectBox(r,i)&&e.sendFather(e.state.serviceData)}}},{key:"touchMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData,i=document.getElementById(n),o=i.parentNode,a=o.getBoundingClientRect().top,s=o.getBoundingClientRect().left;i.ontouchstart=function(t){var n=t.touches[0].pageX-s,o=t.touches[0].pageY-a;e.selectBox(n,o)&&(i.ontouchmove=function(t){r[e.selectedIndex]=[t.touches[0].pageX-s,t.touches[0].pageY-a],e.setData({serviceData:r})})},i.ontouchend=function(t){e.selectedIndex=null,i.ontouchmove=null,e.setData({serviceData:r});var n=t.changedTouches[0].pageX-s,o=t.changedTouches[0].pageY-a;e.selectBox(n,o)&&e.sendFather(r)}}},{key:"selectBox",value:function(e,t){var n=this.state,r=n.serviceData,i=n.circleRadius+n.circleBorderWidth;this.selectedIndex=null;for(var o=0;o<r.length;o++){var a=r[o][0],s=r[o][1];if((a-e)*(a-e)+(s-t)*(s-t)<i*i){this.selectedIndex=o;break}}return o!=r.length}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"setData",value:function(e){var t=this;this.setState(e,(function(){t.draw()}))}},{key:"render",value:function(){var e=this.state,t=e.id,n=e.width,r=e.height;return i.a.createElement("canvas",{style:{position:"absolute",top:0,left:0},id:t,width:n,height:r})}}])&&mt(t.prototype,n),r&&mt(t,r),a}(r.Component);function wt(e){return(wt="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 St(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Et(e,t){return(Et=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function At(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Tt(e);if(t){var i=Tt(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return xt(this,n)}}function xt(e,t){return!t||"object"!==wt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Tt(e){return(Tt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Rt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Et(e,t)}(a,e);var t,n,r,o=At(a);function a(e){var t,n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(n=o.call(this,e)).state=(St(t={id:(new Date).getTime()+"fun",serviceData:[],mode:"polygon",disabled:"false",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)"},"disabled","false"),St(t,"title",""),St(t,"titleColor","#000"),St(t,"titleFont","14px bold 黑体"),St(t,"titleLineHeight",""),St(t,"titleBackgroundColor",""),St(t,"titlePadding","10px"),St(t,"titleTextAlign","center"),St(t,"titleWidth",100),St(t,"titleFillColor",""),St(t,"position",[10,10]),St(t,"inputStyle",{}),t),n}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&(n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.state.mode;"react"===e?this.setReact():this.setPolygon()}},{key:"isNull",value:function(){var e=this.state.id,t=document.getElementById(this[e].state.id),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,t.toDataURL()==n.toDataURL()}},{key:"setReact",value:function(){var e=this,t=this.state.id;this.count=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=e.state.serviceData,i=n.layerX,o=n.layerY;if(0===e.count)r[1][1]=o,r[2]=[i,o],r[3][0]=i;else if(e[t].selectedIndex||0===e[t].selectedIndex){switch(r[e[t].selectedIndex]=[i,o],e[t].selectedIndex){case 0:r[1][0]=i,r[3][1]=o;break;case 1:r[0][0]=i,r[2][1]=o;break;case 2:r[1][1]=o,r[3][0]=i;break;case 3:r[0][1]=o,r[2][0]=i}e.props.change(r)}e.setState({serviceData:r},(function(){e[t].draw()}))};n.addEventListener("mousedown",(function(i){if(2!==i.button){var o=i.layerX,a=i.layerY,s=[o,a];if(0===e.state.serviceData.length){e.count++;var l=[[].concat(s),[].concat(s),[].concat(s),[].concat(s)];e.setState({serviceData:l},(function(){e[t].draw()})),n.addEventListener("mousemove",r)}else e[t].selectBox(o,a)&&(e.count++,n.addEventListener("mousemove",r))}})),n.addEventListener("mouseup",(function(e){n.removeEventListener("mousemove",r)})),n.oncontextmenu=function(e){e.preventDefault()}}},{key:"setPolygon",value:function(){var e=this,t=this.state.id;this.state.serviceData.length>1?this.serviceDataFlag=!0:this.polygonCount=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=n.layerX,i=n.layerY,o=e.state.serviceData;o.push([r,i]),e.setState({serviceData:o},(function(){e[t].draw()}))};this.serviceDataFlag||n.addEventListener("click",r),n.oncontextmenu=function(t){t.preventDefault(),2===t.button&&(0==e.polygonCount&&(e.polygonCount++,e.sendFather(e.state.serviceData)),n.removeEventListener("click",r))}}},{key:"isInPolygon",value:function(e,t,n){var r,i,o,a=0,s=t.length;i=t[0];for(var l=1;l<=s;l++)o=t[l%s],e[0]>Math.min(i[0],o[0])&&e[0]<=Math.max(i[0],o[0])&&e[1]<=Math.max(i[1],o[1])&&i[0]!=o[0]&&(r=(e[0]-i[0])*(o[1]-i[1])/(o[0]-i[0])+i[1],(i[1]==o[1]||e[1]<=r)&&a++),i=o;return a%2!=0||!!n.selectBox(e[0],e[1])}},{key:"wenziChange",value:function(e){this.setState({title:e}),this.props.wenziChange(e)}},{key:"change",value:function(e){this.sendFather(e)}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"render",value:function(){var e=this,t=this.state,n=t.serviceData,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.inputStyle,k=t.position,E=t.id;return i.a.createElement(_t,{serviceData:n,disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:p,titleColor:f,titleFont:m,titleLineHeight:y,titleBackgroundColor:g,titlePadding:v,titleTextAlign:b,titleWidth:_,titleFillColor:w,position:k,inputStyle:S,listId:this.props.listId,ref:function(t){e[E]=t},wenziChange:function(t){return e.wenziChange(t)},change:function(t){return e.change(t)}})}}])&&kt(t.prototype,n),r&&kt(t,r),a}(r.Component),Ct=n(30),Mt={insert:"head",singleton:!1};fe()(Ct.a,Mt),Ct.a.locals;function Lt(e){return(Lt="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 Ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Dt(e,t){return(Dt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ut(e);if(t){var i=Ut(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Bt(this,n)}}function Bt(e,t){return!t||"object"!==Lt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ut(e){return(Ut=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Nt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Dt(e,t)}(a,e);var t,n,r,o=Pt(a);function a(){var e,t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=o.call(this)).state=(Ot(e={id:(new Date).getTime()+"waiceng",disabled:"false",circleRadius:5,circleBorderWidth:2,circleBorderColor:"#28B1D9",circleInColor:"#28B1D9",circleSelectColor:"#FFF",lineColor:"#28B1D9",lineWidth:2,areaColor:"rgba(40, 177, 217, 0.2)"},"disabled","false"),Ot(e,"title",""),Ot(e,"titleColor","#000"),Ot(e,"titleFont","14px bold 黑体"),Ot(e,"titleLineHeight",""),Ot(e,"titleBackgroundColor",""),Ot(e,"titlePadding","10px"),Ot(e,"titleTextAlign","center"),Ot(e,"titleWidth",100),Ot(e,"titleFillColor",""),Ot(e,"position",[10,10]),Ot(e,"inputStyle",{}),e),t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n={};for(var r in e)e[r]&&e[r]!==t[r]&&("object"===Lt(e[r])?n[r]=JSON.parse(JSON.stringify(e[r])):n[r]=e[r]);return Object.keys(n).length>0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.props.list;e&&e.length>0&&(this.selectIndex=e[e.length-1].id),this.selectArea()}},{key:"clickIt",value:function(e){var t=this.props.list,n=(new Date).getTime();t&&0!==t.length?this[t[t.length-1].id+t[t.length-1].mode].isNull()?this.props.err(!1,"画布为空,请先绘制在添加。"):t[t.length-1].serviceData?(t.push({id:n+"",title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n+""):this.props.err(!1,"画布没有保存,请先绘制完成在添加"):((t=[]).push({id:n,title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n),this.props.change(t)}},{key:"delete",value:function(){var e=this,t=this.state.list.filter((function(t){return t.id===e.selectIndex})),n=this[t[0].id+t[0].mode];n[n.state.id].removeTags("input",n.props.listId),this.props.delete(this.selectIndex,"发出删除指令")}},{key:"change",value:function(e){var t=this,n=this.props.list;n=n.map((function(n){return n.id===t.selectIndex&&(n.serviceData=JSON.parse(JSON.stringify(e))),n})),this.props.change(n)}},{key:"selectArea",value:function(){var e=this,t=this.state.id;document.getElementById(t).onclick=function(t){var n=e.props.list,r=t.layerX,i=t.layerY;if(e.indexflag=!1,n)for(var o=0;o<n.length;o++)if(n[o].serviceData){var a=e[n[o].id+n[o].mode].state.id;if(e.isInPolygon([r,i],JSON.parse(JSON.stringify(n[o].serviceData)),e[n[o].id+n[o].mode][a])){var s=e[n[o].id+n[o].mode][a].state.id;e.indexflag?document.getElementById(s).style.zIndex=0:(document.getElementById(s).style.zIndex=99,e.selectIndex=n[o].id,e.indexflag=!0)}else s=e[n[o].id+n[o].mode][a].state.id,document.getElementById(s).style.zIndex=0}}}},{key:"isInPolygon",value:function(e,t,n){for(var r=e[0],i=e[1],o=!1,a=0,s=t.length-1;a<t.length;s=a++){var l=t[a][0],c=t[a][1],u=t[s][0],d=t[s][1],h=c>i!=d>i&&r<(u-l)*(i-c)/(d-c)+l;h&&(o=!o)}return!(h||!n.selectBox(e[0],e[1]))||o}},{key:"wenziChange",value:function(e,t){this.props.wenziChange(e,t)}},{key:"render",value:function(){var e=this,t=this.state,n=t.id,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.position,k=this.props.list;return i.a.createElement("div",{id:n,style:{width:"100%",height:"100%",position:"relative"}},k&&k.map((function(t,n){return i.a.createElement(Rt,{disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:t.title?t.title:p,titleColor:t.titleColor?t.titleColor:f,titleFont:t.titleFont?t.titleFont:m,titleLineHeight:t.titleLineHeight?t.titleLineHeight:y,titleBackgroundColor:t.titleBackgroundColor?t.titleBackgroundColor:g,titlePadding:t.titlePadding?t.titlePadding:v,titleTextAlign:t.titleTextAlign?t.titleTextAlign:b,titleWidth:t.titleWidth?t.titleWidth:_,titleFillColor:t.titleFillColor?t.titleFillColor:w,position:S,key:t.id,listId:t.id,serviceData:t.serviceData,ref:function(n){e[t.id+t.mode]=n},mode:t.mode,wenziChange:function(t){return e.wenziChange(t,n)},change:function(t){return e.change(t)}})})))}}])&&It(t.prototype,n),r&&It(t,r),a}(r.Component),Ft=n(52),qt=n.n(Ft),jt=function(e){this.mqtt=qt.a,this.random=Vt,this.clientId=Vt();var t={clientId:this.clientId,username:"test",password:"test",connectTimeout:100,keepalive:100};this.client=this.mqtt.connect("ws://"+e+"/mqtt",t),this.reconnectNum=0,this.link=function(){var e=this;return new Promise((function(t,n){e.client.on("connect",(function(n){console.log("-----------------------链接成功-----------------------"),t(e.client)})),e.client.on("reconnect",(function(t){e.reconnectNum++,e.reconnectNum>=10&&e.client.end(!0),console.log("正在重连:",t)})),e.client.on("error",(function(e){console.log("订阅失败",e)}))}))},this.subscribe=function(e,t){this.client.subscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"订阅成功-----------------------")}))},this.unsubscribe=function(e,t){this.client.unsubscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"取消订阅成功-----------------------")}))},this.publish=function(e,t,n){this.client.publish(e,JSON.stringify(t),n,(function(t,n){if(t)throw new Error(t);console.log("-----------------------"+e+"发送成功-----------------------")}))},this.message=function(e){this.client.on("message",(function(t,n){var r=JSON.parse(n.toString());e(r,t)}))},this.close=function(){this.client.end(!0)}};function Vt(){for(var e=String.fromCharCode(65+Math.floor(26*Math.random())),t=0;t<31;++t){var n=Math.floor(62*Math.random());e+=n<10?n.toString():n<36?String.fromCharCode(65+n-10):String.fromCharCode(97+n-10-26)}return e}function Yt(e){for(var t=window.location.search.substring(1).split("&"),n=0;n<t.length;n++){var r=t[n].split("=");if(r[0]==e)return r[1]}return!1}function Wt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=null,i=0;return new Promise((function(o,a){zt(e)?o(zt(e)):r=setInterval((function(){i<t?(i++,zt(e)&&(clearInterval(r),o(zt(e)))):a("获取"+t+"后失败")}),n)}))}function zt(e){for(var t=document.cookie.split("; "),n=0;n<t.length;n++)if(t[n].split("=")[0]===e)return t[n].split("=")[1]}console.log("%c中科视语-组件库","text-shadow: 0 1px 0 #fff,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);font-size:35px")}])})); | |
47 | 47 | \ No newline at end of file | ... | ... |
package.json
src/components/allVideoCom/allVideoCom.js
... | ... | @@ -44,7 +44,7 @@ export default class AllVideoCom extends Component { |
44 | 44 | } |
45 | 45 | createFlvPlayer(videoUrl) { |
46 | 46 | let { id } = this.state |
47 | - let { autoplay = true, config = {}, maxCount = 5,testingTimer=30 } = this.props; | |
47 | + let { volume=0, autoplay = true, config = {}, maxCount = 5, testingTimer = 30 } = this.props; | |
48 | 48 | this.count = 0;//重连次数 |
49 | 49 | this.dp = new DPlayer({ |
50 | 50 | container: document.getElementById(id), |
... | ... | @@ -52,6 +52,7 @@ export default class AllVideoCom extends Component { |
52 | 52 | autoplay: autoplay, |
53 | 53 | airplay: true, |
54 | 54 | mutex: false, |
55 | + volume: volume, | |
55 | 56 | video: { |
56 | 57 | url: videoUrl, |
57 | 58 | type: "flv", |
... | ... | @@ -93,8 +94,8 @@ export default class AllVideoCom extends Component { |
93 | 94 | }, |
94 | 95 | }); |
95 | 96 | } |
96 | - componentWillUnmount(){ | |
97 | - if(this.timer){ | |
97 | + componentWillUnmount() { | |
98 | + if (this.timer) { | |
98 | 99 | clearInterval(this.timer) |
99 | 100 | this.timer = null; |
100 | 101 | } | ... | ... |
src/index.js
... | ... | @@ -123,7 +123,7 @@ class App extends Component { |
123 | 123 | margin:"0 auto", |
124 | 124 | position:"relative" |
125 | 125 | }}> |
126 | - {/* <AllVideoCom videoUrl="http://8.131.254.61:8888/httpflvlive?app=lskjapp&stream=2200001201000B01.flv"></AllVideoCom> */} | |
126 | + <AllVideoCom videoUrl="http://8.131.254.61:8888/httpflvlive?app=lskjapp&stream=2200001201000B01.flv"></AllVideoCom> | |
127 | 127 | {/* <TransitionCom> |
128 | 128 | { |
129 | 129 | listArr.map((item,index)=>{ |
... | ... | @@ -144,7 +144,7 @@ class App extends Component { |
144 | 144 | delete={(selectIndex) => { this.delete(selectIndex) }} |
145 | 145 | err={(falg, msg) => { this.err(falg, msg) }}></FunAreaSelectPlus> */} |
146 | 146 | {/* <button onClick={() => this.clickIt()}>添加</button> */} |
147 | - <div id="waiceng" style={{ width: "81.2%", height: "80%", position: "relative" }}> | |
147 | + {/* <div id="waiceng" style={{ width: "81.2%", height: "80%", position: "relative" }}> | |
148 | 148 | { |
149 | 149 | arr.map(item => { |
150 | 150 | return (<AreaSelete key={item.id} |
... | ... | @@ -152,9 +152,9 @@ class App extends Component { |
152 | 152 | change={(val) => this.changeSelect(val)}></AreaSelete>) |
153 | 153 | }) |
154 | 154 | } |
155 | - </div> | |
155 | + </div> */} | |
156 | 156 | {/* <ImgCom httpImg="http://112.125.25.140:8083/syboxms/getImgDataByPath" imgUrl={imgUrl}></ImgCom> */} |
157 | - {/* <FlvCom videoUrl="http://27.128.170.246:8888/httpflvlive?app=lskjapp&stream=2200001201001501.flv"></FlvCom> */} | |
157 | + {/* <FlvCom videoUrl=" http://8.131.254.61:8888/httpflvlive?app=lskjapp&stream=2200001201000B01.flv"></FlvCom> */} | |
158 | 158 | {/* <Timer className="timerComCssss" type="YYYY-MM-DD HH:mm:ss"></Timer> */} |
159 | 159 | |
160 | 160 | </div> | ... | ... |