@seastart/srtc-web-sdk 0.6.3 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/srtc.mjs CHANGED
@@ -1 +1 @@
1
- var e={5964:(e,t,r)=>{var i=r(3908);const n=r(9273).EventEmitter,o=r(6394),s=r(9790),a=r(3124),c=r(3140),u=r(9996),l=r(1181).Writable,h=r(6371),d=r(5371),f=r(1691),p=r(1223),g=r(7616),m=r(659)("mqttjs:client"),y=i?i.nextTick:function(e){setTimeout(e,0)},v=r.g.setImmediate||function(e){y(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND","ETIMEDOUT"],k={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(e,t){let r;t.properties&&(r=t.properties.topicAlias);let i=t.topic.toString();if(0===i.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(i=e.topicAliasSend.getTopicByAlias(r),void 0===i)return new Error("Unregistered Topic Alias");t.topic=i}r&&delete t.properties.topicAlias}function S(e,t,r){m("sendPacket :: packet: %O",t),m("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),m("sendPacket :: writing to stream");const i=c.writeToStream(t,e.stream,e.options);m("sendPacket :: writeToStream result %s",i),!i&&r&&r!==T?(m("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(m("sendPacket :: invoking cb"),r())}function E(e,t,r,i){m("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let n,o=t;if("publish"===o.cmd&&(o=f(t),n=_(e,o),n))return r&&r(n);e.outgoingStore.put(o,(function(n){if(n)return r&&r(n);i(),S(e,t,r)}))}function T(e){m("nop ::",e)}function C(e,t){let r;const i=this;if(!(this instanceof C))return new C(e,t);for(r in this.options=t||{},b)void 0===this.options[r]?this.options[r]=b[r]:this.options[r]=t[r];m("MqttClient :: options.protocol",t.protocol),m("MqttClient :: options.protocolVersion",t.protocolVersion),m("MqttClient :: options.username",t.username),m("MqttClient :: options.keepalive",t.keepalive),m("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),m("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),m("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),m("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new u:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new o,this.incomingStore=t.incomingStore||new o,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?m("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;m("connect :: sending queued packets"),function t(){const r=e.shift();m("deliver :: entry %o",r);let n=null;if(!r)return void i._resubscribe();n=r.packet,m("deliver :: call _sendPacket for %o",n);let o=!0;n.messageId&&0!==n.messageId&&(i.messageIdProvider.register(n.messageId)||(o=!1)),o?i._sendPacket(n,(function(e){r.cb&&r.cb(e),t()})):(m("messageId: %d has already used. The message is skipped and removed.",n.messageId),t())}()})),this.on("close",(function(){m("close :: connected set to `false`"),this.connected=!1,m("close :: clearing connackTimer"),clearTimeout(this.connackTimer),m("close :: clearing ping timer"),null!==i.pingTimer&&(i.pingTimer.clear(),i.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),m("close :: calling _setupReconnect"),this._setupReconnect()})),n.call(this),m("MqttClient :: setting up stream"),this._setupStream()}h(C,n),C.prototype._setupStream=function(){const e=this,t=new l,r=c.parser(this.options);let i=null;const n=[];function o(){if(n.length)y(s);else{const e=i;i=null,e()}}function s(){m("work :: getting next packet in queue");const t=n.shift();if(t)m("work :: packet pulled from queue"),e._handlePacket(t,o);else{m("work :: no packets in queue");const e=i;i=null,m("work :: done flag is %s",!!e),e&&e()}}m("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),m("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){m("parser :: on packet push to packets array."),n.push(e)})),t._write=function(e,t,n){i=n,m("writable stream :: parsing buffer"),r.parse(e),s()},m("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",(function(t){m("streamErrorHandler :: error",t.message),w.includes(t.code)?(m("streamErrorHandler :: emitting error"),e.emit("error",t)):T(t)})),this.stream.on("close",(function(){var t;m("(%s)stream :: on close",e.options.clientId),(t=e.outgoing)&&(m("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach((function(e){t[e].volatile&&"function"==typeof t[e].cb&&(t[e].cb(new Error("Connection closed")),delete t[e])}))),m("stream: emit close to MqttClient"),e.emit("close")})),m("_setupStream: sending packet `connect`");const a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),S(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket){S(this,g({cmd:"auth",reasonCode:0},this.options.authPacket))}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){m("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},C.prototype._handlePacket=function(e,t){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(m("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},C.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==T?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},C.prototype.publish=function(e,t,r,i){m("publish :: message `%s` to topic `%s`",t,e);const n=this.options;"function"==typeof r&&(i=r,r=null);if(r=g({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(i))return this;const o=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=o._nextId(),null===s))return m("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===n.protocolVersion&&(a.properties=r.properties),m("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[a.messageId]={volatile:!1,cb:i||T},m("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,void 0,r.cbStorePut);break;default:m("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,i,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:i}),this},C.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const r=[];let i=t.shift();const n=i.resubscribe;let o=t.pop()||T,s=t.pop();const a=this.options.protocolVersion;delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof o&&(s=o,o=T);const c=p.validateTopics(i);if(null!==c)return v(o,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(o))return m("subscribe: discconecting true"),this;const u={qos:0};if(5===a&&(u.nl=!1,u.rap=!1,u.rh=0),s=g(u,s),Array.isArray(i)?i.forEach((function(t){if(m("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||n){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),m("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e)}})):Object.keys(i).forEach((function(t){if(m("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<i[t].qos||n){const e={topic:t,qos:i[t].qos};5===a&&(e.nl=i[t].nl,e.rap=i[t].rap,e.rh=i[t].rh,e.properties=s.properties),m("subscribe: pushing `%s` to subs list",e),r.push(e)}})),!r.length)return o(null,[]),this;const l=function(){const t=e._nextId();if(null===t)return m("No messageId left"),!1;const i={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(i.properties=s.properties),e.options.resubscribe){m("subscribe :: resubscribe true");const t=[];r.forEach((function(r){if(e.options.reconnectPeriod>0){const i={qos:r.qos};5===a&&(i.nl=r.nl||!1,i.rap=r.rap||!1,i.rh=r.rh||0,i.properties=r.properties),e._resubscribeTopics[r.topic]=i,t.push(r.topic)}})),e.messageIdToTopic[i.messageId]=t}return e.outgoing[i.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t]}o(e,r)}},m("subscribe :: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!l())&&this._storeProcessingQueue.push({invoke:l,callback:o}),this},C.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),i=t.pop()||T,n=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof i&&(n=i,i=T);const o=p.validateTopics(r);if(null!==o)return v(i,new Error("Invalid topic "+o)),this;if(e._checkDisconnecting(i))return this;const s=function(){const t=e._nextId();if(null===t)return m("No messageId left"),!1;const o={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof r?o.unsubscriptions=[r]:Array.isArray(r)&&(o.unsubscriptions=r),e.options.resubscribe&&o.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof n&&n.properties&&(o.properties=n.properties),e.outgoing[o.messageId]={volatile:!0,cb:i},m("unsubscribe: call _sendPacket"),e._sendPacket(o),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:i}),this},C.prototype.end=function(e,t,r){const i=this;function n(){m("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close((function(e){i.outgoingStore.close((function(t){if(m("end :: closeStores: emitting end"),i.emit("end"),r){const i=e||t;m("end :: closeStores: invoking callback with args"),r(i)}}))})),i._deferredReconnect&&i._deferredReconnect()}function o(){m("end :: (%s) :: finish :: calling _cleanUp with force %s",i.options.clientId,e),i._cleanUp(e,(()=>{m("end :: finish :: calling process.nextTick on closeStores"),y(n.bind(i))}),t)}return m("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||T,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=T))),"object"!=typeof t&&(r=t,t=null),m("end :: cb? %s",!!r),r=r||T,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(m("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(m("end :: (%s) :: immediately calling finish",i.options.clientId),o()),this)},C.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},C.prototype.reconnect=function(e){m("client reconnect");const t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},C.prototype._reconnect=function(){m("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),m("client already connected. disconnecting first.")):(m("_reconnect: calling _setupStream"),this._setupStream())},C.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(m("_setupReconnect :: emit `offline` state"),this.emit("offline"),m("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),m("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){m("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):m("_setupReconnect :: doing nothing...")},C.prototype._clearReconnect=function(){m("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},C.prototype._cleanUp=function(e,t){const r=arguments[2];if(t&&(m("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),m("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&(i=this.outgoing)&&(m("flush: queue exists? %b",!!i),Object.keys(i).forEach((function(e){"function"==typeof i[e].cb&&(i[e].cb(new Error("Connection closed")),delete i[e])}))),m("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=g({cmd:"disconnect"},r);m("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,v.bind(null,this.stream.end.bind(this.stream)))}var i;this.disconnecting||(m("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(m("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(m("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},C.prototype._sendPacket=function(e,t,r){m("_sendPacket :: (%s) :: start",this.options.clientId),r=r||T,t=t||T;const i=function(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);const i=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==i.length&&(m("applyTopicAlias :: register topic: %s - alias: %d",i,r),!e.topicAliasSend.put(i,r)))return m("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}else 0!==i.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(i),r?(t.topic="",t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",i,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(i,r),t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto assign topic: %s - alias: %d",i,r))):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(i),r&&(t.topic="",t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto use topic: %s - alias: %d",i,r))));else if(r)return m("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}}(this,e);if(i)t(i);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void S(this,e,t)):(m("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void E(this,e,t,r);default:return void S(this,e,t)}switch(e.qos){case 2:case 1:E(this,e,t,r);break;default:S(this,e,t)}m("_sendPacket :: (%s) :: end",this.options.clientId)}},C.prototype._storePacket=function(e,t,r){m("_storePacket :: packet: %o",e),m("_storePacket :: cb? %s",!!t),r=r||T;let i=e;if("publish"===i.cmd){i=f(e);const r=_(this,i);if(r)return t&&t(r)}0===(i.qos||0)&&this.queueQoSZero||"publish"!==i.cmd?this.queue.push({packet:i,cb:t}):i.qos>0?(t=this.outgoing[i.messageId]?this.outgoing[i.messageId].cb:null,this.outgoingStore.put(i,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},C.prototype._setupPingTimer=function(){m("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=d((function(){e._checkPing()}),1e3*this.options.keepalive))},C.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},C.prototype._checkPing=function(){m("_checkPing :: checking ping..."),this.pingResp?(m("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(m("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},C.prototype._handlePingresp=function(){this.pingResp=!0},C.prototype._handleConnack=function(e){m("_handleConnack");const t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){const e=new Error("Connection refused: "+k[r]);e.code=r,this.emit("error",e)}},C.prototype._handleAuth=function(e){const t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=r,void this.emit("error",e)}const i=this;this.handleAuth(e,(function(e,t){if(e)i.emit("error",e);else if(24===r)i.reconnecting=!1,i._sendPacket(t);else{const t=new Error("Connection refused: "+k[r]);e.code=r,i.emit("error",t)}}))},C.prototype.handleAuth=function(e,t){t()},C.prototype._handlePublish=function(e,t){m("_handlePublish: packet %o",e),t=void 0!==t?t:T;let r=e.topic.toString();const i=e.payload,n=e.qos,o=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length){if(!(t>0&&t<=65535))return m("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return m("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));r=e,m("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,t)}}else{if(!this.topicAliasRecv.put(r,t))return m("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));m("_handlePublish :: registered topic: %s - alias: %d",r,t)}}switch(m("_handlePublish: qos %d",n),n){case 2:a.customHandleAcks(r,i,e,(function(r,i){return r instanceof Error||(i=r,r=null),r?s.emit("error",r):-1===c.indexOf(i)?s.emit("error",new Error("Wrong reason code for pubrec")):void(i?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:i},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:o},t)})))}));break;case 1:a.customHandleAcks(r,i,e,(function(n,a){return n instanceof Error||(a=n,n=null),n?s.emit("error",n):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,i,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,i,e),this.handleMessage(e,t);break;default:m("_handlePublish: unknown QoS. Doing nothing.")}},C.prototype.handleMessage=function(e,t){t()},C.prototype._handleAck=function(e){const t=e.messageId,r=e.cmd;let i=null;const n=this.outgoing[t]?this.outgoing[t].cb:null,o=this;let s;if(n){switch(m("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=e.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+k[r]),s.code=r,n(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,n),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{i={cmd:"pubrel",qos:2,messageId:t};const r=e.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+k[r]),s.code=r,n(s,e)):this._sendPacket(i);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let r=0;r<e.granted.length;r++)if(128&e.granted[r]){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete o._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),n(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),n(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else m("_handleAck :: Server sent an ack in error. Ignoring.")},C.prototype._handlePubrel=function(e,t){m("handling pubrel packet"),t=void 0!==t?t:T;const r=e.messageId,i=this,n={cmd:"pubcomp",messageId:r};i.incomingStore.get(e,(function(e,r){e?i._sendPacket(n,t):(i.emit("message",r.topic,r.payload,r),i.handleMessage(r,(function(e){if(e)return t(e);i.incomingStore.del(r,T),i._sendPacket(n,t)})))}))},C.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},C.prototype._nextId=function(){return this.messageIdProvider.allocate()},C.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},C.prototype._resubscribe=function(){m("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){m("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=!0,this.subscribe(r,{properties:r[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},C.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function r(){let i=t.outgoingStore.createStream();function n(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function o(){i.destroy(),i=null,t._flushStoreProcessingQueue(),n()}t.once("close",o),i.on("error",(function(e){n(),t._flushStoreProcessingQueue(),t.removeListener("close",o),t.emit("error",e)})),i.on("end",(function(){let i=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){i=!1;break}i?(n(),t.removeListener("close",o),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r()})),function e(){if(!i)return;t._storeProcessing=!0;const r=i.read(1);let n;r?t._packetIdsDuringStoreProcessing[r.messageId]?e():t.disconnecting||t.reconnectTimer?i.destroy&&i.destroy():(n=t.outgoing[r.messageId]?t.outgoing[r.messageId].cb:null,t.outgoing[r.messageId]={volatile:!1,cb:function(t,r){n&&n(t,r),e()}},t._packetIdsDuringStoreProcessing[r.messageId]=!0,t.messageIdProvider.register(r.messageId)?t._sendPacket(r):m("messageId: %d has already used.",r.messageId)):i.once("readable",e)}()}()},C.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},C.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},C.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},e.exports=C},2670:(e,t,r)=>{const{Buffer:i}=r(2577),n=r(1181).Transform,o=r(3521);let s,a,c,u=!1;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const l=function(e,t){const r="alis"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);return s=t.my,s.connectSocket({url:l,protocols:r}),a=function(){const e=new n;return e._write=function(e,t,r){s.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}(),c=o.obj(),u||(u=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=i.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?i.from(e):i.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)}))),c}},7594:(e,t,r)=>{var i=r(3908);const n=r(5964),o=r(6394),s=r(4837),a=r(7616),c=r(659)("mqttjs"),u={};function l(e,t){if(c("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const r=s.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=a(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!u[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,r){return(!e||r%2!=0)&&"function"==typeof u[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);const r=new n((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),c("calling streambuilder for",t.protocol),u[t.protocol](e,t)}),t);return r.on("error",(function(){})),r}void 0!==i&&"browser"!==i.title||"function"!=typeof r?(u.mqtt=r(8793),u.tcp=r(8793),u.ssl=r(5351),u.tls=r(5351),u.mqtts=r(5351)):(u.wx=r(3027),u.wxs=r(3027),u.ali=r(2670),u.alis=r(2670)),u.ws=r(5838),u.wss=r(5838),e.exports=l,e.exports.connect=l,e.exports.MqttClient=n,e.exports.Store=o},8793:(e,t,r)=>{const i=r(5653),n=r(659)("mqttjs:tcp");e.exports=function(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const r=t.port,o=t.hostname;return n("port %d and host %s",r,o),i.createConnection(r,o)}},5351:(e,t,r)=>{const i=r(8535),n=r(5653),o=r(659)("mqttjs:tls");e.exports=function(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===n.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const r=i.connect(t);function s(i){t.rejectUnauthorized&&e.emit("error",i),r.end()}return r.on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s)})),r.on("error",s),r}},5838:(e,t,r)=>{var i=r(3908);const{Buffer:n}=r(2577),o=r(965),s=r(659)("mqttjs:ws"),a=r(3521),c=r(1181).Transform,u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==i&&"browser"===i.title||"function"==typeof r;function h(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function d(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||u.forEach((function(r){Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,r)&&(t.wsOptions[r]=e[r])})),t}e.exports=l?function(e,t){let r;s("browserStreamBuilder");const i=function(e){const t=d(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t).browserBufferSize||524288,o=t.browserBufferTimeout||1e3,u=!t.objectMode,l=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",i=h(t,e),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}(e,t),f=function(e,t,r){const i=new c({objectModeMode:e.objectMode});return i._write=t,i._flush=r,i}(t,(function e(t,r,s){l.bufferedAmount>i&&setTimeout(e,o,t,r,s),u&&"string"==typeof t&&(t=n.from(t,"utf8"));try{l.send(t)}catch(e){return s(e)}s()}),(function(e){l.close(),e()}));t.objectMode||(f._writev=b),f.on("close",(()=>{l.close()}));const p=void 0!==l.addEventListener;function g(){r.setReadable(f),r.setWritable(f),r.emit("connect")}function m(){r.end(),r.destroy()}function y(e){r.destroy(e)}function v(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),f.push(t)}function b(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}return l.readyState===l.OPEN?r=f:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=b),p?l.addEventListener("open",g):l.onopen=g),r.socket=l,p?(l.addEventListener("close",m),l.addEventListener("error",y),l.addEventListener("message",v)):(l.onclose=m,l.onerror=y,l.onmessage=v),r}:function(e,t){s("streamBuilder");const r=d(t),i=h(r,e),n=function(e,t,r){s("createWebSocket"),s("protocol: "+r.protocolId+" "+r.protocolVersion);const i="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return s("creating new Websocket for url: "+t+" and protocol: "+i),new o(t,[i],r.wsOptions)}(0,i,r),a=o.createWebSocketStream(n,r.wsOptions);return a.url=i,n.on("close",(()=>{a.destroy()})),a}},3027:(e,t,r)=>{const{Buffer:i}=r(2577),n=r(1181).Transform,o=r(3521);let s,a,c;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const u=function(e,t){const r="wxs"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);return s=wx.connectSocket({url:u,protocols:[r]}),a=function(){const e=new n;return e._write=function(e,t,r){s.send({data:0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}(),c=o.obj(),s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?i.from(t):i.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))})),c}},9996:e=>{function t(){if(!(this instanceof t))return new t;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}t.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},t.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},t.prototype.register=function(e){return!0},t.prototype.deallocate=function(e){},t.prototype.clear=function(){},e.exports=t},6394:(e,t,r)=>{const i=r(7616),n=r(1181).Readable,o={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=i(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new n(o),t=[];let r=!1,i=0;return this._inflights.forEach((function(e,r){t.push(e)})),e._read=function(){!r&&i<t.length?this.push(t[i++]):this.push(null)},e.destroy=function(){if(r)return;const e=this;r=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},e.exports=a},9790:e=>{function t(e){if(!(this instanceof t))return new t(e);this.aliasToTopic={},this.max=e}t.prototype.put=function(e,t){return!(0===t||t>this.max)&&(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,!0)},t.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},t.prototype.clear=function(){this.aliasToTopic={}},e.exports=t},3124:(e,t,r)=>{const i=r(8103),n=r(1846).t;function o(e){if(!(this instanceof o))return new o(e);e>0&&(this.aliasToTopic=new i({max:e}),this.topicToAlias={},this.numberAllocator=new n(1,e),this.max=e,this.length=0)}o.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},o.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},o.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},o.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},e.exports=o},1223:e=>{function t(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(let r=0;r<e.length;r++)if(!t(e[r]))return e[r];return null}}},8752:(e,t)=>{t.byteLength=function(e){var t=a(e),r=t[0],i=t[1];return 3*(r+i)/4-i},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],c=o[1],u=new n(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),l=0,h=c>0?s-4:s;for(r=0;r<h;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===c&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===c&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,i=e.length,n=i%3,o=[],s=16383,a=0,u=i-n;a<u;a+=s)o.push(c(e,a,a+s>u?u:a+s));1===n?(t=e[i-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],i[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,i){for(var n,o,s=[],a=t;a<i;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=n)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},1951:(e,t,r)=>{const{Buffer:i}=r(9183),n=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,n,{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 r=0;r<this._bufs.length;r++){const i=t+this._bufs[r].length;if(e<i||r===this._bufs.length-1)return[r,e-t];t=i}},o.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},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,r,n){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof n||n>this.length)&&(n=this.length),r>=this.length)return e||i.alloc(0);if(n<=0)return e||i.alloc(0);const o=!!e,s=this._offset(r),a=n-r;let c=a,u=o&&t||0,l=s[1];if(0===r&&n===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:i.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,u),u+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-l)return o?this._bufs[s[0]].copy(e,t,l,l+c):this._bufs[s[0]].slice(l,l+c);o||(e=i.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-l;if(!(c>r)){this._bufs[t].copy(e,u,l,l+c),u+=r;break}this._bufs[t].copy(e,u,l),u+=r,c-=r,l&&(l=0)}return e.length>u?e.slice(0,u):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 r=this._offset(e),i=this._offset(t),n=this._bufs.slice(r[0],i[0]+1);return 0===i[1]?n.pop():n[n.length-1]=n[n.length-1].slice(0,i[1]),0!==r[1]&&(n[0]=n[0].slice(r[1])),this._new(n)},o.prototype.toString=function(e,t,r){return this.slice(t,r).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(i.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(i.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=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=i.from([e]):"string"==typeof e?e=i.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=i.from(e.buffer,e.byteOffset,e.byteLength):i.isBuffer(e)||(e=i.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 n=this._offset(t);let o=n[0],s=n[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;s<t.length;){if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}}s=0}return-1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])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,r){return this.slice(e,e+r)[t](0,r)}:function(r=0){return this.slice(r,r+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[n]},e.exports=o},6431:(e,t,r)=>{const i=r(1181).Duplex,n=r(6371),o=r(1951);function s(e){if(!(this instanceof s))return new s(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),i.call(this)}n(s,i),Object.assign(s.prototype,o.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.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)},s.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof o||s.isBufferList(e)},s.isBufferList=o.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=o},9183:(e,t,r)=>{var i=r(8752),n=r(6701),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|g(e,t),i=a(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(V(e,Uint8Array)){var t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(V(e,ArrayBuffer)||e&&V(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(V(e,SharedArrayBuffer)||e&&V(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,r);var n=function(e){if(c.isBuffer(e)){var t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||z(e.length)?a(0):d(e);if("Buffer"===e.type&&Array.isArray(e.data))return d(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=a(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(i,c.prototype),i}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||V(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(n)return i?-1:U(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return P(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function y(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function v(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:b(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,i,n){var o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function w(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(t.substr(2*s,2),16);if(z(a))return s;e[r+s]=a}return s}function k(e,t,r,i){return F(U(t,e.length-r),e,r,i)}function _(e,t,r,i){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function S(e,t,r,i){return F(j(t),e,r,i)}function E(e,t,r,i){return F(function(e,t){for(var r,i,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function T(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,s,a,c,u=e[n],l=null,h=u>239?4:u>223?3:u>191?2:1;if(n+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=h}return function(e){var t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=A));return r}(i)}t.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return l(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},c.allocUnsafe=function(e){return h(e)},c.allocUnsafeSlow=function(e){return h(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=c.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(V(o,Uint8Array))n+o.length>i.length?c.from(o).copy(i,n):Uint8Array.prototype.set.call(i,o,n);else{if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n)}n+=o.length}return i},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):m.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,i,n){if(V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(i,n),l=e.slice(t,r),h=0;h<a;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return v(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return v(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":case"latin1":case"binary":return _(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function R(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function x(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=t;o<r;++o)n+=q[e[o]];return n}function I(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,r,i,n,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function B(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,i,o){return t=+t,r>>>=0,o||B(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function L(e,t,r,i,o){return t=+t,r>>>=0,o||B(e,0,r,8),n.write(e,t,r,i,52,8),r+8}c.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var i=this.subarray(e,t);return Object.setPrototypeOf(i,c.prototype),i},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||O(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||O(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);O(this,e,t,r,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);O(this,e,t,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n=i-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),n},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=c.isBuffer(e)?e:c.from(e,i),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var D=/[^+/0-9A-Za-z-_]/g;function U(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function V(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function z(e){return e!=e}var q=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=16*r,n=0;n<16;++n)t[i+n]=e[r]+e[n];return t}()},2577:(e,t,r)=>{var i=r(8752),n=r(6701);t.Buffer=a,t.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|f(e,t),i=s(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(V(e,ArrayBuffer)||e&&V(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r);return i.__proto__=a.prototype,i}(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return a.from(i,t,r);var n=function(e){if(a.isBuffer(e)){var t=0|d(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||z(e.length)?s(0):h(e);if("Buffer"===e.type&&Array.isArray(e.data))return h(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return u(e),s(e<0?0:0|d(e))}function h(e){for(var t=e.length<0?0:0|d(e.length),r=s(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function d(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function f(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||V(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(n)return i?-1:U(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function g(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function m(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=a.from(t,i)),a.isBuffer(t))return 0===t.length?-1:y(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,i,n){var o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function v(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(t.substr(2*s,2),16);if(z(a))return s;e[r+s]=a}return s}function b(e,t,r,i){return F(U(t,e.length-r),e,r,i)}function w(e,t,r,i){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function k(e,t,r,i){return w(e,t,r,i)}function _(e,t,r,i){return F(j(t),e,r,i)}function S(e,t,r,i){return F(function(e,t){for(var r,i,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function E(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,s,a,c,u=e[n],l=null,h=u>239?4:u>223?3:u>191?2:1;if(n+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=h}return function(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=C));return r}(i)}t.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return c(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}(e,t,r)},a.allocUnsafe=function(e){return l(e)},a.allocUnsafeSlow=function(e){return l(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(V(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=a.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(V(o,Uint8Array)&&(o=a.from(o)),!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},a.byteLength=f,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):p.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,i,n){if(V(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0),c=Math.min(o,s),u=this.slice(i,n),l=e.slice(t,r),h=0;h<c;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},a.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return k(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function A(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function R(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=t;o<r;++o)n+=D(e[o]);return n}function x(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function I(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,i,n,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function O(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(e,t,r,i,o){return t=+t,r>>>=0,o||O(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function N(e,t,r,i,o){return t=+t,r>>>=0,o||O(e,0,r,8),n.write(e,t,r,i,52,8),r+8}a.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var i=this.subarray(e,t);return i.__proto__=a.prototype,i},a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||I(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||I(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},a.prototype.readUInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||I(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||I(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||I(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||I(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return B(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return B(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return N(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return N(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,i){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n=i-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,i);else if(this===e&&r<t&&t<i)for(var o=n-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),t);return n},a.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=a.isBuffer(e)?e:a.from(e,i),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%c]}return this};var L=/[^+/0-9A-Za-z-_]/g;function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function U(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function V(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function z(e){return e!=e}},659:(e,t,r)=>{var i=r(3908);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let i=0,n=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),t.splice(n,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(8798)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},8798:(e,t,r)=>{e.exports=function(e){function t(e){let r,n,o,s=null;function a(...e){if(!a.enabled)return;const i=a,n=Number(new Date),o=n-(r||n);i.diff=o,i.prev=r,i.curr=n,r=n,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,((r,n)=>{if("%%"===r)return"%";s++;const o=t.formatters[n];if("function"==typeof o){const t=e[s];r=o.call(i,t),e.splice(s,1),s--}return r})),t.formatArgs.call(i,e);(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==t.namespaces&&(n=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,r){const i=t(this.namespace+(void 0===r?":":r)+e);return i.log=this.log,i}function n(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(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),n=i.length;for(r=0;r<n;r++)i[r]&&("-"===(e=i[r].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 r,i;for(r=0,i=t.skips.length;r<i;r++)if(t.skips[r].test(e))return!1;for(r=0,i=t.names.length;r<i;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(7103),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((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},3521:(e,t,r)=>{var i=r(2577).Buffer,n=r(3908),o=r(1181),s=r(8717),a=r(6371),c=r(3462),u=i.from&&i.from!==Uint8Array.from?i.from([0]):new i([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},h=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},d=function(){},f=function(e,t,r){if(!(this instanceof f))return new f(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};a(f,o.Duplex),f.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new f(e,t,r)},f.prototype.cork=function(){1==++this._corked&&this.emit("cork")},f.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},f.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=s(e,{writable:!0,readable:!1},h(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()}else this.end()},f.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,i=s(e,{writable:!1,readable:!0},h(this)),n=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",n),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",n),r._readable2.removeListener("end",a),i()},this._forward()}},f.prototype._read=function(){this._drained=!0,this._forward()},f.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=c(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},f.prototype.destroy=function(e,t){if(t||(t=d),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},f.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},f.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},f.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){var r,i;r=t._forwardEnd&&t._writable,i=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)},r?r._writableState&&r._writableState.finished?i():r._writableState?r.end(i):(r.end(),i()):i()}))},f.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},e.exports=f},8717:(e,t,r)=>{var i=r(3908),n=r(8377),o=function(){},s=function(e,t,r){if("function"==typeof t)return s(e,null,t);t||(t={}),r=n(r||o);var a=e._writableState,c=e._readableState,u=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,h=!1,d=function(){e.writable||f()},f=function(){l=!1,u||r.call(e)},p=function(){u=!1,l||r.call(e)},g=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},m=function(t){r.call(e,t)},y=function(){i.nextTick(v)},v=function(){if(!h)return(!u||c&&c.ended&&!c.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:r.call(e,new Error("premature close"))},b=function(){e.req.on("finish",f)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!a&&(e.on("end",d),e.on("close",d)):(e.on("complete",f),e.on("abort",y),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",g),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",y),function(){h=!0,e.removeListener("complete",f),e.removeListener("abort",y),e.removeListener("request",b),e.req&&e.req.removeListener("finish",f),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",f),e.removeListener("exit",g),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",y)}};e.exports=s},9273:e=>{var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,n,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(o){i.once&&e.removeEventListener(t,n),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)i(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},6701:(e,t)=>{t.read=function(e,t,r,i,n){var o,s,a=8*n-i-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?n-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),o-=u}return(f?-1:1)*s*Math.pow(2,o-i)},t.write=function(e,t,r,i,n,o){var s,a,c,u=8*o-n-1,l=(1<<u)-1,h=l>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,p=i?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;e[r+f]=255&a,f+=p,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*g}},6371:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},310:(e,t,r)=>{r.d(t,{NZ:()=>_});var i=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},o=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},s=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);var r=0,a=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[r-1]},this.forEach=function(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<r-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(r){r!==e&&t.push(r)})),t.forEach((function(e,t){a[t]=e}));for(var i=t.length;r>i;)this.popBack()},this.pushBack=function(e){a.push(e),++r},this.popBack=function(){a.pop(),r>0&&--r},this.setElementByPos=function(e,t){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,i){if(void 0===i&&(i=1),e<0||e>r)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,o([e,0],n(new Array(i).fill(t)),!1)),r+=i},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(r,i){0!==i&&r===e||(t.push(r),e=r)})),t.forEach((function(e,t){a[t]=e}));for(var i=t.length;r>i;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return i(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(a);function c(e){var t=this;void 0===e&&(e=[]);var r=0,i=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,i.length=0},this.push=function(e){i.push(e),++r},this.pop=function(){i.pop(),r>0&&--r},this.top=function(){return i[r-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.freeze(c);var u=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},l=function(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e};function h(e){var t=this;void 0===e&&(e=[]);var r=0,i=void 0,n=void 0;this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){i=n=void 0,r=0},this.front=function(){return null==i?void 0:i.value},this.back=function(){return null==n?void 0:n.value},this.forEach=function(e){for(var t=i,r=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,r++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var t=i;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===r-1)this.popBack();else{for(var t=i;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var n=t.pre,o=t.next;o.pre=n,n.next=o,r>0&&--r}},this.eraseElementByValue=function(e){for(;i&&i.value===e;)this.popFront();for(;n&&n.value===e;)this.popBack();if(i)for(var t=i;t;){if(t.value===e){var o=t.pre,s=t.next;s&&(s.pre=o),o&&(o.next=s),r>0&&--r}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new l(e);n?(n.next=t,t.pre=n,n=t):i=n=t},this.popBack=function(){n&&(r>0&&--r,n&&(i===n?i=n=void 0:(n=n.pre)&&(n.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var n=i;e--;){if(!n)throw new Error("unknown error");n=n.next}n&&(n.value=t)},this.insert=function(e,t,n){if(void 0===n&&(n=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>r)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(n<0)throw new Error("insert size must more than 0");if(0===e)for(;n--;)this.pushFront(t);else if(e===r)for(;n--;)this.pushBack(t);else{for(var o=i,s=1;s<e;++s){if(!(null==o?void 0:o.next))throw new Error("unknown error");o=null==o?void 0:o.next}if(!o)throw new Error("unknown error");var a=o.next;for(r+=n;n--;)o.next=new l(t),o.next.pre=o,o=o.next;o.next=a,a&&(a.pre=o)}},this.find=function(e){for(var t=i;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=i,t=n,o=0;e&&t&&2*o<r;){var s=e.value;e.value=t.value,t.value=s,e=e.next,t=t.pre,++o}},this.unique=function(){for(var e=i;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,r>0&&--r;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var r=i;t.forEach((function(e){r&&(r.value=e,r=r.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new l(e);i?(t.next=i,i.pre=t,i=t):i=n=t},this.popFront=function(){i&&(r>0&&--r,i&&(i===n?i=n=void 0:(i=i.next)&&(i.pre=void 0)))},this.merge=function(e){var t=this,o=i;e.forEach((function(e){for(;o&&void 0!==o.value&&o.value<=e;)o=o.next;if(void 0===o)t.pushBack(e),o=n;else if(o===i)t.pushFront(e),o=i;else{++r;var s=o.pre;s&&(s.next=new l(e),s.next.pre=s,s.next.next=o,o&&(o.pre=s.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return u(this,(function(t){switch(t.label){case 0:e=i,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(h);const d=h;function f(e){void 0===e&&(e=[]);var t=new d(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(f);var p=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function g(e){var t=this;void 0===e&&(e=[]);var r=[],i=0,n=0,o=0,s=0,a=0,c=0;this.size=function(){return c},this.empty=function(){return 0===c},this.clear=function(){i=o=n=s=a=c=0,l.call(this,g.bucketSize),c=0},this.front=function(){return r[i][n]},this.back=function(){return r[o][s]},this.forEach=function(e){if(!this.empty()){var t=0;if(i!==o){for(c=n;c<g.bucketSize;++c)e(r[i][c],t++);for(c=i+1;c<o;++c)for(var a=0;a<g.bucketSize;++a)e(r[c][a],t++);for(c=0;c<=s;++c)e(r[o][c],t++)}else for(var c=n;c<=s;++c)e(r[i][c],t++)}};var u=function(e){var t=i*g.bucketSize+n,r=t+e,a=o*g.bucketSize+s;if(r<t||r>a)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(r/g.bucketSize),curNodePointerIndex:r%g.bucketSize}};this.getElementByPos=function(e){var t=u(e),i=t.curNodeBucketIndex,n=t.curNodePointerIndex;return r[i][n]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>c)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var r=[],i=e+1;i<c;++i)r.push(this.getElementByPos(i));this.cut(e),this.popBack(),r.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(r){r!==e&&t.push(r)}));for(var r=t.length,i=0;i<r;++i)this.setElementByPos(i,t[i]);this.cut(r-1)}};var l=function(e){for(var t=[],u=e*g.sigma,l=Math.max(Math.ceil(u/g.bucketSize),2),h=0;h<l;++h)t.push(new Array(g.bucketSize));var d=Math.ceil(e/g.bucketSize),f=Math.floor(l/2)-Math.floor(d/2),p=f,m=0;if(this.size())for(h=0;h<d;++h){for(var y=0;y<g.bucketSize;++y)if(t[f+h][y]=this.front(),this.popFront(),this.empty()){p=f+h,m=y;break}if(this.empty())break}r=t,i=f,n=0,o=p,s=m,a=l,c=e};this.pushBack=function(e){this.empty()||(o===a-1&&s===g.bucketSize-1&&l.call(this,this.size()),s<g.bucketSize-1?++s:o<a-1&&(++o,s=0)),++c,r[o][s]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(s>0?--s:i<o&&(--o,s=g.bucketSize-1)),c>0&&--c)},this.setElementByPos=function(e,t){var i=u(e),n=i.curNodeBucketIndex,o=i.curNodePointerIndex;r[n][o]=t},this.insert=function(e,t,r){var i=this;if(void 0===r&&(r=1),0===e)for(;r--;)this.pushFront(t);else if(e===this.size())for(;r--;)this.pushBack(t);else{for(var n=[],o=e;o<c;++o)n.push(this.getElementByPos(o));this.cut(e-1);for(o=0;o<r;++o)this.pushBack(t);n.forEach((function(e){return i.pushBack(e)}))}},this.find=function(e){if(i===o){for(var t=n;t<=s;++t)if(r[i][t]===e)return!0;return!1}for(t=n;t<g.bucketSize;++t)if(r[i][t]===e)return!0;for(t=i+1;t<o;++t)for(var a=0;a<g.bucketSize;++a)if(r[t][a]===e)return!0;for(t=0;t<=s;++t)if(r[o][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=c-1;e<t;){var r=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,r),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(r,i){0!==i&&r===t||(e.push(r),t=r)}));for(var r=0;r<c;++r)this.setElementByPos(r,e[r]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var r=0;r<c;++r)this.setElementByPos(r,t[r])},this.pushFront=function(e){this.empty()||(0===i&&0===n&&l.call(this,this.size()),n>0?--n:i>0&&(--i,n=g.bucketSize-1)),++c,r[i][n]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(n<g.bucketSize-1?++n:i<o&&(++i,n=0)),c>0&&--c)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var i=t.length;r=[];for(var n=Math.ceil(i/g.bucketSize),o=0;o<n;++o)r.push(new Array(g.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=u(e),r=t.curNodeBucketIndex,i=t.curNodePointerIndex;o=r,s=i,c=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return p(this,(function(a){switch(a.label){case 0:if(0===c)return[2];if(i!==o)return[3,5];t=n,a.label=1;case 1:return t<=s?[4,r[i][t]]:[3,4];case 2:a.sent(),a.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=n,a.label=6;case 6:return t<g.bucketSize?[4,r[i][t]]:[3,9];case 7:a.sent(),a.label=8;case 8:return++t,[3,6];case 9:t=i+1,a.label=10;case 10:if(!(t<o))return[3,15];e=0,a.label=11;case 11:return e<g.bucketSize?[4,r[t][e]]:[3,14];case 12:a.sent(),a.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,a.label=16;case 16:return t<=s?[4,r[o][t]]:[3,19];case 17:a.sent(),a.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var n=g.bucketSize;e.size?n=e.size():e.length&&(n=e.length);var s=n*g.sigma;a=Math.ceil(s/g.bucketSize),a=Math.max(a,3);for(var c=0;c<a;++c)r.push(new Array(g.bucketSize));var u=Math.ceil(n/g.bucketSize);i=Math.floor(a/2)-Math.floor(u/2),o=i,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}g.sigma=3,g.bucketSize=5e3,Object.freeze(g);function m(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var r=[];e.forEach((function(e){return r.push(e)}));var i=r.length,n=function(e,t){if(e<0||e>=i)throw new Error("unknown error");if(t<0||t>=i)throw new Error("unknown error");var n=r[e];r[e]=r[t],r[t]=n},o=function(e){if(e<0||e>=i)throw new Error("unknown error");var o=2*e+1,s=2*e+2;o<i&&t(r[e],r[o])>0&&n(e,o),s<i&&t(r[e],r[s])>0&&n(e,s)};!function(){for(var e=Math.floor((i-1)/2);e>=0;--e)for(var o=e,s=2*o+1;s<i;){var a=s+1,c=s;if(a<i&&t(r[s],r[a])>0&&(c=a),t(r[o],r[c])<=0)break;n(o,c),s=2*(o=c)+1}}(),this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,r.length=0},this.push=function(e){if(r.push(e),1!==++i)for(var n=i-1;n>0;){var s=Math.floor((n-1)/2);if(t(r[s],e)<=0)break;o(s),n=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=r[i-1];--i;for(var n=0;n<this.size();){var o=2*n+1,s=2*n+2;if(o>=this.size())break;var a=o;if(s<this.size()&&t(r[o],r[s])>0&&(a=s),t(r[a],e)>=0)break;r[n]=r[a],n=a}r[n]=e}else--i},this.top=function(){return r[0]},Object.freeze(this)}Object.freeze(m);var y=function(){function e(e,t){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,r=this.leftChild,i=this.rightChild;if(!i)throw new Error("unknown error");var n=i.leftChild,o=i.rightChild;return e&&(e.leftChild===this?e.leftChild=i:e.rightChild===this&&(e.rightChild=i)),i.parent=e,i.brother=t,i.leftChild=this,i.rightChild=o,t&&(t.brother=i),this.parent=i,this.brother=o,this.leftChild=r,this.rightChild=n,o&&(o.parent=i,o.brother=this),r&&(r.parent=this,r.brother=n),n&&(n.parent=this,n.brother=r),i},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,r=this.leftChild;if(!r)throw new Error("unknown error");var i=this.rightChild,n=r.leftChild,o=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=n,r.rightChild=this,t&&(t.brother=r),n&&(n.parent=r,n.brother=this),this.parent=r,this.brother=n,this.leftChild=o,this.rightChild=i,o&&(o.parent=this,o.brother=i),i&&(i.parent=this,i.brother=o),r},e.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(y);const v=y;var b=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},w=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function k(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var i=0,n=new v;n.color=v.TreeNodeColorType.black,this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,n.key=void 0,n.leftChild=n.rightChild=n.brother=n.parent=void 0,n.color=v.TreeNodeColorType.black};var o=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?o(e.leftChild):e},s=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?s(e.rightChild):e};this.front=function(){if(!this.empty())return o(n).key},this.back=function(){if(!this.empty())return s(n).key},this.forEach=function(e){var t,r,i=0;try{for(var n=w(this),o=n.next();!o.done;o=n.next()){e(o.value,i++)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var n=w(this),o=n.next();!o.done;o=n.next()){var s=o.value;if(i===e)return s;++i}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}throw new Error("unknown error")};var a=function(e){var t=e.parent;if(!t){if(e===n)return;throw new Error("unknown error")}if(e.color!==v.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild){if(r.color===v.TreeNodeColorType.red){r.color=v.TreeNodeColorType.black,t.color=v.TreeNodeColorType.red;var i=t.rotateLeft();n===t&&(n=i),a(e)}else if(r.color===v.TreeNodeColorType.black)if(r.rightChild&&r.rightChild.color===v.TreeNodeColorType.red){r.color=t.color,t.color=v.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=v.TreeNodeColorType.black);i=t.rotateLeft();n===t&&(n=i),e.color=v.TreeNodeColorType.black}else if(r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==v.TreeNodeColorType.red)r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||(r.color=v.TreeNodeColorType.red,a(t));else{r.color=v.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=v.TreeNodeColorType.black);i=r.rotateRight();n===r&&(n=i),a(e)}}else if(e===t.rightChild)if(r.color===v.TreeNodeColorType.red){r.color=v.TreeNodeColorType.black,t.color=v.TreeNodeColorType.red;i=t.rotateRight();n===t&&(n=i),a(e)}else if(r.color===v.TreeNodeColorType.black)if(r.leftChild&&r.leftChild.color===v.TreeNodeColorType.red){r.color=t.color,t.color=v.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=v.TreeNodeColorType.black);i=t.rotateRight();n===t&&(n=i),e.color=v.TreeNodeColorType.black}else if(r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==v.TreeNodeColorType.red)r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||(r.color=v.TreeNodeColorType.red,a(t));else{r.color=v.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=v.TreeNodeColorType.black);i=r.rotateLeft();n===r&&(n=i),a(e)}}else e.color=v.TreeNodeColorType.black},c=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=o(t.rightChild);var r=e.key;e.key=t.key,t.key=r,e=t}if(t.leftChild){t=s(t.leftChild);r=e.key;e.key=t.key,t.key=r,e=t}}a(t),t&&t.remove(),--i,n.color=v.TreeNodeColorType.black},u=function(e,t){return!(!e||void 0===e.key)&&(!!u(e.leftChild,t)||(!!t(e)||u(e.rightChild,t)))};this.eraseElementByPos=function(e){if(e<0||e>=i)throw new Error("pos must more than 0 and less than set's size");var t=0;u(n,(function(r){return e===t?(c(r),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var r=d(n,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&c(r)}};var l=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var i=t(r,e.key);return i<0?e.leftChild?l(e.leftChild,r):(e.leftChild=new v,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):i>0?e.rightChild?l(e.rightChild,r):(e.rightChild=new v,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},h=function(e){var t=e.parent;if(!t){if(e===n)return;throw new Error("unknown error")}if(t.color!==v.TreeNodeColorType.black&&t.color===v.TreeNodeColorType.red){var r=t.brother,i=t.parent;if(!i)throw new Error("unknown error");if(r&&r.color===v.TreeNodeColorType.red)r.color=t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red,h(i);else if(!r||r.color===v.TreeNodeColorType.black)if(t===i.leftChild){if(e===t.leftChild){t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red;var o=i.rotateRight();i===n&&(n=o)}else if(e===t.rightChild){o=t.rotateLeft();i===n&&(n=o),h(t)}}else if(t===i.rightChild)if(e===t.leftChild){o=t.rotateRight();i===n&&(n=o),h(t)}else if(e===t.rightChild){t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red;o=i.rotateLeft();i===n&&(n=o)}}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++i,n.key=e,void(n.color=v.TreeNodeColorType.black);var r=l(n,e);void 0!==r.key&&0===t(r.key,e)||(++i,r.key=e,h(r),n.color=v.TreeNodeColorType.black)};var d=function(e,r){if(e&&void 0!==e.key){var i=t(r,e.key);return i<0?d(e.leftChild,r):i>0?d(e.rightChild,r):e}};this.find=function(e){var r=d(n,e);return void 0!==r&&void 0!==r.key&&0===t(r.key,e)};var f=function(e,r){if(e&&void 0!==e.key){var i=t(e.key,r);if(0===i)return e.key;if(i<0)return f(e.rightChild,r);var n=f(e.leftChild,r);return void 0!==n?n:e.key}};this.lowerBound=function(e){return f(n,e)};var p=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)<=0)return p(e.rightChild,r);var i=p(e.leftChild,r);return void 0!==i?i:e.key}};this.upperBound=function(e){return p(n,e)};var g=function(e,r){if(e&&void 0!==e.key){var i=t(e.key,r);if(0===i)return e.key;if(i>0)return g(e.leftChild,r);var n=g(e.rightChild,r);return void 0!==n?n:e.key}};this.reverseLowerBound=function(e){return g(n,e)};var m=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)>=0)return m(e.leftChild,r);var i=m(e.rightChild,r);return void 0!==i?i:e.key}};this.reverseUpperBound=function(e){return m(n,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(n)};var y=function(e){return b(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,w(y(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,w(y(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return y(n)},e.forEach((function(e){return r.insert(e)})),Object.freeze(this)}Object.freeze(k);const _=k;var S=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},E=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function T(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var i=0,n=new v;n.color=v.TreeNodeColorType.black,this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,n.key=n.value=void 0,n.leftChild=n.rightChild=n.brother=void 0};var o=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?o(e.leftChild):e},s=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?s(e.rightChild):e};this.front=function(){if(!this.empty()){var e=o(n);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=s(n);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,r,i=0;try{for(var n=E(this),o=n.next();!o.done;o=n.next()){e(o.value,i++)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var n=E(this),o=n.next();!o.done;o=n.next()){var s=o.value;if(i===e)return s;++i}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var a=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var i=t(e.key,r);return 0===i?{key:e.key,value:e.value}:i<0?a(e.rightChild,r):a(e.leftChild,r)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return a(n,e)};var c=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)<=0?c(e.rightChild,r):c(e.leftChild,r)||{key:e.key,value:e.value}};this.upperBound=function(e){return c(n,e)};var u=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var i=t(e.key,r);return 0===i?{key:e.key,value:e.value}:i>0?u(e.leftChild,r):u(e.rightChild,r)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return u(n,e)};var l=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)>=0?l(e.leftChild,r):l(e.rightChild,r)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return l(n,e)};var h=function(e){var t=e.parent;if(!t){if(e===n)return;throw new Error("unknown error")}if(e.color!==v.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild){if(r.color===v.TreeNodeColorType.red){r.color=v.TreeNodeColorType.black,t.color=v.TreeNodeColorType.red;var i=t.rotateLeft();n===t&&(n=i),h(e)}else if(r.color===v.TreeNodeColorType.black)if(r.rightChild&&r.rightChild.color===v.TreeNodeColorType.red){r.color=t.color,t.color=v.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=v.TreeNodeColorType.black);i=t.rotateLeft();n===t&&(n=i),e.color=v.TreeNodeColorType.black}else if(r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==v.TreeNodeColorType.red)r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||(r.color=v.TreeNodeColorType.red,h(t));else{r.color=v.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=v.TreeNodeColorType.black);i=r.rotateRight();n===r&&(n=i),h(e)}}else if(e===t.rightChild)if(r.color===v.TreeNodeColorType.red){r.color=v.TreeNodeColorType.black,t.color=v.TreeNodeColorType.red;i=t.rotateRight();n===t&&(n=i),h(e)}else if(r.color===v.TreeNodeColorType.black)if(r.leftChild&&r.leftChild.color===v.TreeNodeColorType.red){r.color=t.color,t.color=v.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=v.TreeNodeColorType.black);i=t.rotateRight();n===t&&(n=i),e.color=v.TreeNodeColorType.black}else if(r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==v.TreeNodeColorType.red)r.leftChild&&r.leftChild.color!==v.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==v.TreeNodeColorType.black||(r.color=v.TreeNodeColorType.red,h(t));else{r.color=v.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=v.TreeNodeColorType.black);i=r.rotateLeft();n===r&&(n=i),h(e)}}else e.color=v.TreeNodeColorType.black},d=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=o(t.rightChild);var r=e.key;e.key=t.key,t.key=r;var a=e.value;e.value=t.value,t.value=a,e=t}if(t.leftChild){t=s(t.leftChild);r=e.key;e.key=t.key,t.key=r;a=e.value;e.value=t.value,t.value=a,e=t}}h(t),t&&t.remove(),--i,n.color=v.TreeNodeColorType.black},f=function(e,t){return!(!e||void 0===e.key)&&(!!f(e.leftChild,t)||(!!t(e)||f(e.rightChild,t)))};this.eraseElementByPos=function(e){if(e<0||e>=i)throw new Error("pos must more than 0 and less than set's size");var t=0;f(n,(function(r){return e===t?(d(r),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var r=m(n,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&d(r)}};var p=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var i=t(r,e.key);return i<0?e.leftChild?p(e.leftChild,r):(e.leftChild=new v,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):i>0?e.rightChild?p(e.rightChild,r):(e.rightChild=new v,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},g=function(e){var t=e.parent;if(!t){if(e===n)return;throw new Error("unknown error")}if(t.color!==v.TreeNodeColorType.black&&t.color===v.TreeNodeColorType.red){var r=t.brother,i=t.parent;if(!i)throw new Error("unknown error");if(r&&r.color===v.TreeNodeColorType.red)r.color=t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red,g(i);else if(!r||r.color===v.TreeNodeColorType.black)if(t===i.leftChild){if(e===t.leftChild){t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red;var o=i.rotateRight();i===n&&(n=o)}else if(e===t.rightChild){o=t.rotateLeft();i===n&&(n=o),g(t)}}else if(t===i.rightChild)if(e===t.leftChild){o=t.rotateRight();i===n&&(n=o),g(t)}else if(e===t.rightChild){t.color=v.TreeNodeColorType.black,i.color=v.TreeNodeColorType.red;o=i.rotateLeft();i===n&&(n=o)}}};this.setElement=function(e,r){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=r){if(this.empty())return++i,n.key=e,n.value=r,void(n.color=v.TreeNodeColorType.black);var o=p(n,e);void 0===o.key||0!==t(o.key,e)?(++i,o.key=e,o.value=r,g(o),n.color=v.TreeNodeColorType.black):o.value=r}else this.eraseElementByKey(e)};var m=function(e,r){if(e&&void 0!==e.key){var i=t(r,e.key);return i<0?m(e.leftChild,r):i>0?m(e.rightChild,r):e}};this.find=function(e){return!!m(n,e)},this.getElementByKey=function(e){var t=m(n,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var r=e.key,i=e.value;return t.setElement(r,i)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(n)};var y=function(e){return S(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,E(y(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,E(y(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return y(n)},e.forEach((function(e){var t=e.key,i=e.value;return r.setElement(t,i)})),Object.freeze(this)}Object.freeze(T);const C=T;var A=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},P=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function R(e,t,r){var i=this;if(void 0===e&&(e=[]),void 0===t&&(t=R.initSize),r=r||function(e){var t=0,r="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t|=0;else{r="string"!=typeof e?JSON.stringify(e):e;for(var i=0;i<r.length;i++){t=(t<<5)-t+r.charCodeAt(i),t|=0}}return t^=t>>>16},t&t-1)throw new Error("initBucketNum must be 2 to the power of n");var n=0,o=[],s=Math.max(R.initSize,Math.min(R.maxSize,t));this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,s=t,o=[]},this.forEach=function(e){var t=0;o.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var a=function(e){if(!(e>=R.maxSize)){s=2*e;var t=[];o.forEach((function(i,n){if(!i.empty()){if(i instanceof d&&1===i.size()){var a=i.front();if(void 0===a)throw new Error("unknown error");t[r(a)&s-1]=new d([a])}else if(i instanceof _){var c=new d,u=new d;i.forEach((function(t){r(t)&e?u.pushBack(t):c.pushBack(t)})),c.size()>R.untreeifyThreshold?t[n]=new _(c):c.size()&&(t[n]=c),u.size()>R.untreeifyThreshold?t[n+e]=new _(u):u.size()&&(t[n+e]=u)}else{var l=new d,h=new d;i.forEach((function(t){r(t)&e?h.pushBack(t):l.pushBack(t)})),l.size()&&(t[n]=l),h.size()&&(t[n+e]=h)}o[n].clear()}})),o=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=r(e)&s-1;if(o[t]){var i=o[t].size();if(o[t]instanceof d){if(o[t].find(e))return;o[t].pushBack(e),o[t].size()>=R.treeifyThreshold&&(o[t]=new _(o[t]))}else o[t].insert(e);var c=o[t].size();n+=c-i}else o[t]=new d([e]),++n;n>s*R.sigma&&a.call(this,s)},this.eraseElementByValue=function(e){var t=r(e)&s-1;if(o[t]){var i=o[t].size();o[t].eraseElementByValue(e),o[t]instanceof _&&o[t].size()<=R.untreeifyThreshold&&(o[t]=new d(o[t]));var a=o[t].size();n+=a-i}},this.find=function(e){var t=r(e)&s-1;return!!o[t]&&o[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,r,i,n,a;return A(this,(function(c){switch(c.label){case 0:e=0,c.label=1;case 1:if(!(e<s))return[3,10];for(;e<s&&!o[e];)++e;if(e>=s)return[3,10];c.label=2;case 2:c.trys.push([2,7,8,9]),n=void 0,t=P(o[e]),r=t.next(),c.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:c.sent(),c.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return i=c.sent(),n={error:i},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(n)throw n.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return i.insert(e)})),Object.freeze(this)}R.initSize=16,R.maxSize=1<<30,R.sigma=.75,R.treeifyThreshold=8,R.untreeifyThreshold=6,R.minTreeifySize=64,Object.freeze(R);var x=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},I=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function M(e,t,r){var i=this;if(void 0===e&&(e=[]),void 0===t&&(t=M.initSize),r=r||function(e){var t,r,i=0,n="";if("number"==typeof e)i=((i=Math.floor(e))<<5)-i,i|=0;else{n="string"!=typeof e?JSON.stringify(e):e;try{for(var o=I(n),s=o.next();!s.done;s=o.next()){i=(i<<5)-i+s.value.charCodeAt(0),i|=0}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}return i^=i>>>16},t&t-1)throw new Error("initBucketNum must be 2 to the power of n");var n=0,o=[],s=Math.max(M.initSize,Math.min(M.maxSize,t));this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,s=t,o=[]},this.forEach=function(e){var t=0;o.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var a=function(e){if(!(e>=M.maxSize)){s=2*e;var t=[];o.forEach((function(i,n){if(!i.empty()){if(i instanceof d&&1===i.size()){var a=i.front(),c=a.key,u=a.value;t[r(c)&s-1]=new d([{key:c,value:u}])}else if(i instanceof C){var l=new d,h=new d;i.forEach((function(t){r(t.key)&e?h.pushBack(t):l.pushBack(t)})),l.size()>M.untreeifyThreshold?t[n]=new C(l):l.size()&&(t[n]=l),h.size()>M.untreeifyThreshold?t[n+e]=new C(h):h.size()&&(t[n+e]=h)}else{var f=new d,p=new d;i.forEach((function(t){r(t.key)&e?p.pushBack(t):f.pushBack(t)})),f.size()&&(t[n]=f),p.size()&&(t[n+e]=p)}o[n].clear()}})),o=t}};this.setElement=function(e,t){var i,c;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var u=r(e)&s-1;if(o[u]){var l=o[u].size();if(o[u]instanceof d){try{for(var h=I(o[u]),f=h.next();!f.done;f=h.next()){var p=f.value;if(p.key===e)return void(p.value=t)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(c=h.return)&&c.call(h)}finally{if(i)throw i.error}}o[u].pushBack({key:e,value:t}),o[u].size()>=M.treeifyThreshold&&(o[u]=new C(o[u]))}else o[u].setElement(e,t);var g=o[u].size();n+=g-l}else++n,o[u]=new d([{key:e,value:t}]);n>s*M.sigma&&a.call(this,s)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,i,n=r(e)&s-1;if(o[n]){if(o[n]instanceof C)return o[n].getElementByKey(e);try{for(var a=I(o[n]),c=a.next();!c.done;c=a.next()){var u=c.value;if(u.key===e)return u.value}}catch(e){t={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,i,a=r(e)&s-1;if(o[a]){var c=o[a].size();if(o[a]instanceof C)o[a].eraseElementByKey(e),o[a].size()<=M.untreeifyThreshold&&(o[a]=new d(o[a]));else{var u=-1;try{for(var l=I(o[a]),h=l.next();!h.done;h=l.next()){var f=h.value;if(++u,f.key===e){o[a].eraseElementByPos(u);break}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(t)throw t.error}}}var p=o[a].size();n+=p-c}},this.find=function(e){var t,i,n=r(e)&s-1;if(!o[n])return!1;if(o[n]instanceof C)return o[n].find(e);try{for(var a=I(o[n]),c=a.next();!c.done;c=a.next()){if(c.value.key===e)return!0}}catch(e){t={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,r,i,n,a;return x(this,(function(c){switch(c.label){case 0:e=0,c.label=1;case 1:if(!(e<s))return[3,10];for(;e<s&&!o[e];)++e;if(e>=s)return[3,10];c.label=2;case 2:c.trys.push([2,7,8,9]),n=void 0,t=I(o[e]),r=t.next(),c.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:c.sent(),c.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return i=c.sent(),n={error:i},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(n)throw n.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,r=e.value;return i.setElement(t,r)})),Object.freeze(this)}M.initSize=16,M.maxSize=1<<30,M.sigma=.75,M.treeifyThreshold=8,M.untreeifyThreshold=6,M.minTreeifySize=64,Object.freeze(M)},8103:(e,t,r)=>{const i=r(601),n=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),u=Symbol("dispose"),l=Symbol("noDisposeOnSet"),h=Symbol("lruList"),d=Symbol("cache"),f=Symbol("updateAgeOnGet"),p=()=>1;const g=(e,t,r)=>{const i=e[d].get(t);if(i){const t=i.value;if(m(e,t)){if(v(e,i),!e[a])return}else r&&(e[f]&&(i.value.now=Date.now()),e[h].unshiftNode(i));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[c]&&r>e[c]},y=e=>{if(e[o]>e[n])for(let t=e[h].tail;e[o]>e[n]&&null!==t;){const r=t.prev;v(e,t),t=r}},v=(e,t)=>{if(t){const r=t.value;e[u]&&e[u](r.key,r.value),e[o]-=r.length,e[d].delete(r.key),e[h].removeNode(t)}};class b{constructor(e,t,r,i,n){this.key=e,this.value=t,this.length=r,this.now=i,this.maxAge=n||0}}const w=(e,t,r,i)=>{let n=r.value;m(e,n)&&(v(e,r),e[a]||(n=void 0)),n&&t.call(i,n.value,n.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[n]=e.max||1/0;const t=e.length||p;if(this[s]="function"!=typeof t?p:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[u]=e.dispose,this[l]=e.noDisposeOnSet||!1,this[f]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[n]=e||1/0,y(this)}get max(){return this[n]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,y(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[s]&&(this[s]=e,this[o]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[o]+=e.length}))),y(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){const i=r.prev;w(this,e,r,t),r=i}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){const i=r.next;w(this,e,r,t),r=i}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((e=>this[u](e.key,e.value))),this[d]=new Map,this[h]=new i,this[o]=0}dump(){return this[h].map((e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[c])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[s](t,e);if(this[d].has(e)){if(a>this[n])return v(this,this[d].get(e)),!1;const s=this[d].get(e).value;return this[u]&&(this[l]||this[u](e,s.value)),s.now=i,s.maxAge=r,s.value=t,this[o]+=a-s.length,s.length=a,this.get(e),y(this),!0}const f=new b(e,t,a,i,r);return f.length>this[n]?(this[u]&&this[u](e,t),!1):(this[o]+=f.length,this[h].unshift(f),this[d].set(e,this[h].head),y(this),!0)}has(e){if(!this[d].has(e))return!1;const t=this[d].get(e).value;return!m(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(v(this,e),e.value):null}del(e){v(this,this[d].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const i=e[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const e=n-t;e>0&&this.set(i.k,i.v,e)}}}prune(){this[d].forEach(((e,t)=>g(this,t,!1)))}}},9513:(e,t,r)=>{var i=r(2577).Buffer;const n=e.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=i.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=i.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=i.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function o(e){return[0,1,2].map((t=>[0,1].map((r=>[0,1].map((o=>{const s=i.alloc(1);return s.writeUInt8(n.codes[e]<<n.CMD_SHIFT|(r?n.DUP_MASK:0)|t<<n.QOS_SHIFT|o,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=o("publish"),n.SUBSCRIBE_HEADER=o("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=o("unsubscribe"),n.ACKS={unsuback:o("unsuback"),puback:o("puback"),pubcomp:o("pubcomp"),pubrel:o("pubrel"),pubrec:o("pubrec")},n.SUBACK_HEADER=i.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=i.from([3]),n.VERSION4=i.from([4]),n.VERSION5=i.from([5]),n.VERSION131=i.from([131]),n.VERSION132=i.from([132]),n.QOS=[0,1,2].map((e=>i.from([e]))),n.EMPTY={pingreq:i.from([n.codes.pingreq<<4,0]),pingresp:i.from([n.codes.pingresp<<4,0]),disconnect:i.from([n.codes.disconnect<<4,0])}},1017:(e,t,r)=>{var i=r(2577).Buffer;const n=r(5706),o=r(9273);class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let n,o=0;for(n=0;n<r.length&&void 0!==r[n];n++)"string"!=typeof r[n]?t[n]=r[n].length:t[n]=i.byteLength(r[n]),e+=t[n];const s=i.allocUnsafe(e);for(n=0;n<r.length&&void 0!==r[n];n++)"string"!=typeof r[n]?(r[n].copy(s,o),o+=t[n]):(s.write(r[n],o),o+=t[n]);return s}}e.exports=function(e,t){const r=new s;return n(e,r,t),r.concat()}},3140:(e,t,r)=>{t.parser=r(4481).parser,t.generate=r(1017),t.writeToStream=r(5706)},534:(e,t,r)=>{var i=r(2577).Buffer;const n={},o=i.isBuffer(i.from([1,2]).subarray(0,1));function s(e){const t=i.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=s(e)},generateNumber:s,genBufVariableByteInt:function(e){let t=0,r=0;const n=i.allocUnsafe(4);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),n.writeUInt8(t,r++)}while(e>0&&r<4);return e>0&&(r=0),o?n.subarray(0,r):n.slice(0,r)},generate4ByteBuffer:function(e){const t=i.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},2654:e=>{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}}},4481:(e,t,r)=>{const i=r(6431),n=r(9273),o=r(2654),s=r(9513),a=r(659)("mqtt-packet:parser");class c extends n{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=i(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("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++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("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=s.types[e>>s.CMD_SHIFT],this.packet.retain=!!(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=!!(e&s.DUP_MASK),a("_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)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_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 a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,i;a("_parseConnect");const n={},o=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),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(n.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,n.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,n.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,n.will&&(o.will={},o.will.retain=!!(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=!!(this._list.readUInt8(this._pos)&s.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 u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(o.clientId=u,a("_parseConnect: packet.clientId: %s",o.clientId),n.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,a("_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,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(n.username){if(i=this._parseString(),null===i)return this._emitError(new Error("Cannot parse username"));o.username=i,a("_parseConnect: packet.username: %s",o.username)}if(n.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-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)}a("_parseConnack: complete")}_parsePublish(){a("_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),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,i,n,o,c,u;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"));r=this._parseByte(),i=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=!!(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=!!(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),n=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,u={topic:t,qos:i},5===this.settings.protocolVersion?(u.nl=c,u.rap=o,u.rh=n):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){a("_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(){a("_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"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_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(){a("_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(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_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),a("_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):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const i=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",i),i}_parseStringPair(){return a("_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 r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_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,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,i=1,n=0,o=!1;const c=this._pos?this._pos:0;for(;r<4&&c+r<this._list.length;){if(t=this._list.readUInt8(c+r++),n+=i*(t&s.VARBYTEINT_MASK),i*=128,!(t&s.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=r)break}return!o&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),c&&(this._pos+=r),o=!!o&&(e?{bytes:r,value:n}:n),a("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_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(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const i=r[t][e.name];r[t][e.name]=[i],r[t][e.name].push(e.value)}else r[t][e.name]=e.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_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)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}e.exports=c},5706:(e,t,r)=>{var i=r(2577).Buffer;const n=r(9513),o=i.allocUnsafe(0),s=i.from([0]),a=r(534),c=r(4303).nextTick,u=r(659)("mqtt-packet:writeToStream"),l=a.cache,h=a.generateNumber,d=a.generateCache,f=a.genBufVariableByteInt,p=a.generate4ByteBuffer;let g=S,m=!0;function y(e,t,r){switch(u("generate called"),t.cork&&(t.cork(),c(v,t)),m&&(m=!1,d()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,r){const o=e||{},s=o.protocolId||"MQTT";let a=o.protocolVersion||4;const c=o.will;let u=o.clean;const l=o.keepalive||0,h=o.clientId||"",d=o.username,f=o.password,p=o.properties;void 0===u&&(u=!0);let m=0;if(!s||"string"!=typeof s&&!i.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;m+=s.length+2;if(3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;m+=1;if(("string"==typeof h||i.isBuffer(h))&&(h||a>=4)&&(h||u))m+=i.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;m+=2;if(m+=1,5===a){var y=C(t,p);if(!y)return!1;m+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(m+=i.byteLength(c.topic)+2,m+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?m+=i.byteLength(c.payload):m+=c.payload.length}var v={};if(5===a){if(!(v=C(t,c.properties)))return!1;m+=v.length}}let b=!1;if(null!=d){if(!I(d))return t.emit("error",new Error("Invalid username")),!1;b=!0,m+=i.byteLength(d)+2}if(null!=f){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!I(f))return t.emit("error",new Error("Invalid password")),!1;m+=x(f)+2}t.write(n.CONNECT_HEADER),w(t,m),T(t,s),o.bridgeMode&&(a+=128);t.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let _=0;_|=null!=d?n.USERNAME_MASK:0,_|=null!=f?n.PASSWORD_MASK:0,_|=c&&c.retain?n.WILL_RETAIN_MASK:0,_|=c&&c.qos?c.qos<<n.WILL_QOS_SHIFT:0,_|=c?n.WILL_FLAG_MASK:0,_|=u?n.CLEAN_SESSION_MASK:0,t.write(i.from([_])),g(t,l),5===a&&y.write();T(t,h),c&&(5===a&&v.write(),k(t,c.topic),T(t,c.payload));null!=d&&T(t,d);null!=f&&T(t,f);return!0}(e,t);case"connack":return function(e,t,r){const o=r?r.protocolVersion:4,a=e||{},c=5===o?a.reasonCode:a.returnCode,u=a.properties;let l=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===o){if(h=C(t,u),!h)return!1;l+=h.length}t.write(n.CONNACK_HEADER),w(t,l),t.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:s),t.write(i.from([c])),null!=h&&h.write();return!0}(e,t,r);case"publish":return function(e,t,r){u("publish: packet: %o",e);const s=r?r.protocolVersion:4,a=e||{},c=a.qos||0,l=a.retain?n.RETAIN_MASK:0,h=a.topic,d=a.payload||o,f=a.messageId,p=a.properties;let m=0;if("string"==typeof h)m+=i.byteLength(h)+2;else{if(!i.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;m+=h.length+2}i.isBuffer(d)?m+=d.length:m+=i.byteLength(d);if(c&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;c&&(m+=2);let y=null;if(5===s){if(y=C(t,p),!y)return!1;m+=y.length}t.write(n.PUBLISH_HEADER[c][a.dup?1:0][l?1:0]),w(t,m),g(t,x(h)),t.write(h),c>0&&g(t,f);null!=y&&y.write();return u("publish: payload: %o",d),t.write(d)}(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,u=s.dup&&"pubrel"===a?n.DUP_MASK:0;let l=0;const h=s.reasonCode,d=s.properties;let f=5===o?3:2;"pubrel"===a&&(l=1);if("number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let p=null;if(5===o&&"object"==typeof d){if(p=A(t,d,r,f),!p)return!1;f+=p.length}t.write(n.ACKS[a][l][u][0]),w(t,f),g(t,c),5===o&&t.write(i.from([h]));null!==p&&p.write();return!0}(e,t,r);case"subscribe":return function(e,t,r){u("subscribe: packet: ");const o=r?r.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,l=s.subscriptions,h=s.properties;let d=0;if("number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;d+=2;let f=null;if(5===o){if(f=C(t,h),!f)return!1;d+=f.length}if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const r=l[e].topic,n=l[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===o){if("boolean"!=typeof(l[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const r=l[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}d+=i.byteLength(r)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),w(t,d),g(t,c),null!==f&&f.write();let p=!0;for(const e of l){const r=e.topic,s=e.qos,a=+e.nl,c=+e.rap,u=e.rh;let l;k(t,r),l=n.SUBSCRIBE_OPTIONS_QOS[s],5===o&&(l|=a?n.SUBSCRIBE_OPTIONS_NL:0,l|=c?n.SUBSCRIBE_OPTIONS_RAP:0,l|=u?n.SUBSCRIBE_OPTIONS_RH[u]:0),p=t.write(i.from([l]))}return p}(e,t,r);case"suback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,u=s.properties;let l=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;l+=1}let h=null;if(5===o){if(h=A(t,u,r,l),!h)return!1;l+=h.length}t.write(n.SUBACK_HEADER),w(t,l),g(t,a),null!==h&&h.write();return t.write(i.from(c))}(e,t,r);case"unsubscribe":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,u=s.unsubscriptions,l=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;h+=2;if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=i.byteLength(u[e])+2}let d=null;if(5===o){if(d=C(t,l),!d)return!1;h+=d.length}t.write(n.UNSUBSCRIBE_HEADER[1][c?1:0][0]),w(t,h),g(t,a),null!==d&&d.write();let f=!0;for(let e=0;e<u.length;e++)f=k(t,u[e]);return f}(e,t,r);case"unsuback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,u=s.granted,l=s.properties,h=s.cmd,d=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===o){if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let p=null;if(5===o){if(p=A(t,l,r,f),!p)return!1;f+=p.length}t.write(n.ACKS[h][d][c][0]),w(t,f),g(t,a),null!==p&&p.write();5===o&&t.write(i.from(u));return!0}(e,t,r);case"pingreq":case"pingresp":return function(e,t,r){return t.write(n.EMPTY[e.cmd])}(e,t);case"disconnect":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===o?1:0,l=null;if(5===o){if(l=A(t,c,r,u),!l)return!1;u+=l.length}t.write(i.from([n.codes.disconnect<<4])),w(t,u),5===o&&t.write(i.from([a]));null!==l&&l.write();return!0}(e,t,r);case"auth":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===o?1:0;5!==o&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const l=A(t,c,r,u);if(!l)return!1;u+=l.length,t.write(i.from([n.codes.auth<<4])),w(t,u),t.write(i.from([a])),null!==l&&l.write();return!0}(e,t,r);default:return t.emit("error",new Error("Unknown command")),!1}}function v(e){e.uncork()}Object.defineProperty(y,"cacheNumbers",{get:()=>g===S,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),g=S):(m=!1,g=E)}});const b={};function w(e,t){if(t>n.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=b[t];return r||(r=f(t),t<16384&&(b[t]=r)),u("writeVarByteInt: writing to stream: %o",r),e.write(r)}function k(e,t){const r=i.byteLength(t);return g(e,r),u("writeString: %s",t),e.write(t,"utf8")}function _(e,t,r){k(e,t),k(e,r)}function S(e,t){return u("writeNumberCached: number: %d",t),u("writeNumberCached: %o",l[t]),e.write(l[t])}function E(e,t){const r=h(t);return u("writeNumberGenerated: %o",r),e.write(r)}function T(e,t){"string"==typeof t?k(e,t):t?(g(e,t.length),e.write(t)):g(e,0)}function C(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){R(e,{},0)}};let r=0;function o(t,r){let o=0;switch(n.propertiesTypes[t]){case"byte":if("boolean"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=2;break;case"int8":if("number"!=typeof r||r<0||r>255)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=2;break;case"binary":if(r&&null===r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=1+i.byteLength(r)+2;break;case"int16":if("number"!=typeof r||r<0||r>65535)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=3;break;case"int32":if("number"!=typeof r||r<0||r>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=5;break;case"var":if("number"!=typeof r||r<0||r>268435455)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=1+i.byteLength(f(r));break;case"string":if("string"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=3+i.byteLength(r.toString());break;case"pair":if("object"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=Object.getOwnPropertyNames(r).reduce(((e,t)=>{const n=r[t];return Array.isArray(n)?e+=n.reduce(((e,r)=>e+=3+i.byteLength(t.toString())+2+i.byteLength(r.toString())),0):e+=3+i.byteLength(t.toString())+2+i.byteLength(r[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${r}`)),!1}return o}if(t)for(const e in t){let i=0,n=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(n=o(e,s[t]),!n)return!1;i+=n}else{if(n=o(e,s),!n)return!1;i=n}if(!i)return!1;r+=i}return{length:i.byteLength(f(r))+r,write(){R(e,t,r)}}}function A(e,t,r,i){const n=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=C(e,t);if(o)for(;i+s.length>o;){const r=n.shift();if(!r||!t[r])return!1;delete t[r],s=C(e,t)}return s}function P(e,t,r){switch(n.propertiesTypes[t]){case"byte":e.write(i.from([n.properties[t]])),e.write(i.from([+r]));break;case"int8":e.write(i.from([n.properties[t]])),e.write(i.from([r]));break;case"binary":e.write(i.from([n.properties[t]])),T(e,r);break;case"int16":e.write(i.from([n.properties[t]])),g(e,r);break;case"int32":e.write(i.from([n.properties[t]])),function(e,t){const r=p(t);u("write4ByteNumber: %o",r),e.write(r)}(e,r);break;case"var":e.write(i.from([n.properties[t]])),w(e,r);break;case"string":e.write(i.from([n.properties[t]])),k(e,r);break;case"pair":Object.getOwnPropertyNames(r).forEach((o=>{const s=r[o];Array.isArray(s)?s.forEach((r=>{e.write(i.from([n.properties[t]])),_(e,o.toString(),r.toString())})):(e.write(i.from([n.properties[t]])),_(e,o.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${r}`)),!1}}function R(e,t,r){w(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const i=t[r];if(Array.isArray(i))for(let t=0;t<i.length;t++)P(e,r,i[t]);else P(e,r,i)}}function x(e){return e?e instanceof i?e.length:i.byteLength(e):0}function I(e){return"string"==typeof e||e instanceof i}e.exports=y},7103:e=>{var t=1e3,r=60*t,i=60*r,n=24*i,o=7*n,s=365.25*n;function a(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\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(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=n)return a(e,o,n,"day");if(o>=i)return a(e,o,i,"hour");if(o>=r)return a(e,o,r,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=n)return Math.round(e/n)+"d";if(o>=i)return Math.round(e/i)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},1846:(e,t,r)=>{const i=r(3285);e.exports.t=i},3285:(e,t,r)=>{const i=r(310).NZ,n=r(659)("number-allocator:trace"),o=r(659)("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new i([],((e,t)=>e.compare(t))),n("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return n("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),n("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.equals(t))return this.ss.eraseElementByValue(r),n("use():"+e),!0;if(r.low>e)return!1;if(r.low===e)return++r.low,n("use():"+e),!0;if(r.high===e)return--r.high,n("use():"+e),!0;const i=r.low;return r.low=e+1,this.ss.insert(new s(i,e-1)),n("use():"+e),!0}return n("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void o("free():"+e+" is out of range");const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.low<=e&&e<=r.high)return void o("free():"+e+" has already been vacant");if(r===this.ss.front())e+1===r.low?--r.low:this.ss.insert(t);else{const i=this.ss.reverseLowerBound(t);i.high+1===e?e+1===r.low?(this.ss.eraseElementByValue(i),r.low=i.low):i.high=e:e+1===r.low?r.low=e:this.ss.insert(t)}}else{if(r===this.ss.front())return void this.ss.insert(t);const i=this.ss.reverseLowerBound(t);i.high+1===e?i.high=e:this.ss.insert(t)}n("free():"+e)},a.prototype.clear=function(){n("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},e.exports=a},8377:(e,t,r)=>{var i=r(2781);function n(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)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=i(n),e.exports.strict=i(o),n.proto=n((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},4303:(e,t,r)=>{var i=r(3908);void 0===i||!i.version||0===i.version.indexOf("v0.")||0===i.version.indexOf("v1.")&&0!==i.version.indexOf("v1.8.")?e.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return i.nextTick(e);case 2:return i.nextTick((function(){e.call(null,t)}));case 3:return i.nextTick((function(){e.call(null,t,r)}));case 4:return i.nextTick((function(){e.call(null,t,r,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return i.nextTick((function(){e.apply(null,o)}))}}}:e.exports=i},3908:e=>{var t,r,i=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,c=[],u=!1,l=-1;function h(){u&&a&&(u=!1,a.length?c=a.concat(c):l=-1,c.length&&d())}function d(){if(!u){var e=s(h);u=!0;for(var t=c.length;t;){for(a=c,c=[];++l<t;)a&&a[l].run();l=-1,t=c.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new f(e,t)),1!==c.length||u||s(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},7192:e=>{function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,r,i,n){r=r||"&",i=i||"=";var o={};if("string"!=typeof e||0===e.length)return o;var s=/\+/g;e=e.split(r);var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var c=e.length;a>0&&c>a&&(c=a);for(var u=0;u<c;++u){var l,h,d,f,p=e[u].replace(s,"%20"),g=p.indexOf(i);g>=0?(l=p.substr(0,g),h=p.substr(g+1)):(l=p,h=""),d=decodeURIComponent(l),f=decodeURIComponent(h),t(o,d)?Array.isArray(o[d])?o[d].push(f):o[d]=[o[d],f]:o[d]=f}return o}},5696:e=>{var t=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,r,i,n){return r=r||"&",i=i||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){var o=encodeURIComponent(t(n))+i;return Array.isArray(e[n])?e[n].map((function(e){return o+encodeURIComponent(t(e))})).join(r):o+encodeURIComponent(t(e[n]))})).join(r):n?encodeURIComponent(t(n))+i+encodeURIComponent(t(e)):""}},6316:(e,t,r)=>{t.decode=t.parse=r(7192),t.encode=t.stringify=r(5696)},1690:e=>{var t={};function r(e,r,i){i||(i=Error);var n=function(e){var t,i;function n(t,i,n){return e.call(this,function(e,t,i){return"string"==typeof r?r:r(e,t,i)}(t,i,n))||this}return i=e,(t=n).prototype=Object.create(i.prototype),t.prototype.constructor=t,t.__proto__=i,n}(i);n.prototype.name=i.name,n.prototype.code=e,t[e]=n}function i(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(i(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(i(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},444:(e,t,r)=>{var i=r(3908),n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=r(4258),s=r(4486);r(6371)(l,o);for(var a=n(s.prototype),c=0;c<a.length;c++){var u=a[c];l.prototype[u]||(l.prototype[u]=s.prototype[u])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",h)))}function h(){this._writableState.ended||i.nextTick(d,this)}function d(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},9942:(e,t,r)=>{e.exports=n;var i=r(2892);function n(e){if(!(this instanceof n))return new n(e);i.call(this,e)}r(6371)(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},4258:(e,t,r)=>{var i,n=r(3908);e.exports=T,T.ReadableState=E;r(9273).EventEmitter;var o=function(e,t){return e.listeners(t).length},s=r(4363),a=r(2577).Buffer,c=r.g.Uint8Array||function(){};var u,l=r(2472);u=l&&l.debuglog?l.debuglog("stream"):function(){};var h,d,f,p=r(7703),g=r(4386),m=r(5069).getHighWaterMark,y=r(1690).F,v=y.ERR_INVALID_ARG_TYPE,b=y.ERR_STREAM_PUSH_AFTER_EOF,w=y.ERR_METHOD_NOT_IMPLEMENTED,k=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6371)(T,s);var _=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function E(e,t,n){i=i||r(444),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=m(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(6127).I),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function T(e){if(i=i||r(444),!(this instanceof T))return new T(e);var t=this instanceof i;this._readableState=new E(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function C(e,t,r,i,n){u("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?x(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,I(e)))}(e,s);else if(n||(o=function(e,t){var r;i=t,a.isBuffer(i)||i instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],t));var i;return r}(s,t)),o)_(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)s.endEmitted?_(e,new k):A(e,s,t,!0);else if(s.ended)_(e,new b);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?A(e,s,t,!1):M(e,s)):A(e,s,t,!1)}else i||(s.reading=!1,M(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&x(e)),M(e,t)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),T.prototype.destroy=g.destroy,T.prototype._undestroy=g.undestroy,T.prototype._destroy=function(e,t){t(e)},T.prototype.push=function(e,t){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=a.from(e,t),t=""),r=!0),C(this,e,t,!1,r)},T.prototype.unshift=function(e){return C(this,e,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(e){h||(h=r(6127).I);var t=new h(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n="";null!==i;)n+=t.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var P=1073741824;function R(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(I,e))}function I(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,D(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(O,e,t))}function O(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(u("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function B(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function N(e){u("readable nexttick read 0"),e.read(0)}function L(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),D(e),t.flowing&&!t.reading&&e.read(0)}function D(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function j(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(F,t,e))}function F(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function V(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}T.prototype.read=function(e){u("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?j(this):x(this),null;if(0===(e=R(e,t))&&t.ended)return 0===t.length&&j(this),null;var i,n=t.needReadable;return u("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&u("length less than watermark",n=!0),t.ended||t.reading?u("reading or ended",n=!1):n&&(u("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=R(r,t))),null===(i=e>0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&j(this)),null!==i&&this.emit("data",i),i},T.prototype._read=function(e){_(this,new w("_read()"))},T.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:m;function a(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",f),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",m),r.removeListener("data",d),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){u("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,D(e))}}(r);e.on("drain",l);var h=!1;function d(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==V(i.pipes,e))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function f(t){u("onerror",t),m(),e.removeListener("error",f),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",g),m()}function g(){u("onfinish"),e.removeListener("close",p),m()}function m(){u("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=V(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},T.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?x(this):i.reading||n.nextTick(N,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(B,this),r},T.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(B,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){(u("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var o=0;o<S.length;o++)e.on(S[o],this.emit.bind(this,S[o]));return this._read=function(t){u("wrapped _read",t),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=r(5209)),d(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),T._fromList=U,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(e,t){return void 0===f&&(f=r(923)),f(T,e,t)})},2892:(e,t,r)=>{e.exports=l;var i=r(1690).F,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,c=r(444);function u(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);c.call(this,e),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?d(this,null,null):this._flush((function(t,r){d(e,t,r)}))}function d(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(6371)(l,c),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,r){r(new n("_transform()"))},l.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},4486:(e,t,r)=>{var i,n=r(3908);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var i=e.entry;e.entry=null;for(;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}(t,e)}}e.exports=T,T.WritableState=E;var s={deprecate:r(5721)},a=r(4363),c=r(2577).Buffer,u=r.g.Uint8Array||function(){};var l,h=r(4386),d=r(5069).getHighWaterMark,f=r(1690).F,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_METHOD_NOT_IMPLEMENTED,m=f.ERR_MULTIPLE_CALLBACK,y=f.ERR_STREAM_CANNOT_PIPE,v=f.ERR_STREAM_DESTROYED,b=f.ERR_STREAM_NULL_VALUES,w=f.ERR_STREAM_WRITE_AFTER_END,k=f.ERR_UNKNOWN_ENCODING,_=h.errorOrDestroy;function S(){}function E(e,t,s){i=i||r(444),e=e||{},"boolean"!=typeof s&&(s=t instanceof i),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=d(this,e,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===e.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,i=r.sync,o=r.writecb;if("function"!=typeof o)throw new m;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,i,o){--t.pendingcb,r?(n.nextTick(o,i),n.nextTick(I,e,t),e._writableState.errorEmitted=!0,_(e,i)):(o(i),e._writableState.errorEmitted=!0,_(e,i),I(e,t))}(e,r,i,t,o);else{var s=R(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||P(e,r),i?n.nextTick(A,e,r,s,o):A(e,r,s,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(e){var t=this instanceof(i=i||r(444));if(!t&&!l.call(T,this))return new T(e);this._writableState=new E(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function C(e,t,r,i,n,o,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new v("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function A(e,t,r,i){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),I(e,t)}function P(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)n[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;n.allBuffers=c,C(e,t,!0,t.length,n,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,h=r.callback;if(C(e,t,!1,t.objectMode?1:u.length,u,l,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function R(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(r){t.pendingcb--,r&&_(e,r),t.prefinished=!0,e.emit("prefinish"),I(e,t)}))}function I(e,t){var r=R(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(x,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}r(6371)(T,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(l=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!l.call(this,e)||this===T&&(e&&e._writableState instanceof E)}})):l=function(e){return e instanceof this},T.prototype.pipe=function(){_(this,new y)},T.prototype.write=function(e,t,r){var i,o=this._writableState,s=!1,a=!o.objectMode&&(i=e,c.isBuffer(i)||i instanceof u);return a&&!c.isBuffer(e)&&(e=function(e){return c.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(e,t){var r=new w;_(e,r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,i){var o;return null===r?o=new b:"string"==typeof r||t.objectMode||(o=new p("chunk",["string","Buffer"],r)),!o||(_(e,o),n.nextTick(i,o),!1)}(this,o,e,r))&&(o.pendingcb++,s=function(e,t,r,i,n,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,r));return t}(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=t.objectMode?1:i.length;t.length+=a;var u=t.length<t.highWaterMark;u||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,a,i,n,o);return u}(this,o,a,e,t,r)),s},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||P(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new g("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,I(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=h.destroy,T.prototype._undestroy=h.undestroy,T.prototype._destroy=function(e,t){t(e)}},5209:(e,t,r)=>{var i,n=r(3908);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(2888),a=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),h=Symbol("lastPromise"),d=Symbol("handlePromise"),f=Symbol("stream");function p(e,t){return{value:e,done:t}}function g(e){var t=e[a];if(null!==t){var r=e[f].read();null!==r&&(e[h]=null,e[a]=null,e[c]=null,t(p(r,!1)))}}function m(e){n.nextTick(g,e)}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(i={get stream(){return this[f]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(p(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[u]?r(e[u]):t(p(void 0,!0))}))}));var r,i=this[h];if(i)r=new Promise(function(e,t){return function(r,i){e.then((function(){t[l]?r(p(void 0,!0)):t[d](r,i)}),i)}}(i,this));else{var o=this[f].read();if(null!==o)return Promise.resolve(p(o,!1));r=new Promise(this[d])}return this[h]=r,r}},Symbol.asyncIterator,(function(){return this})),o(i,"return",(function(){var e=this;return new Promise((function(t,r){e[f].destroy(null,(function(e){e?r(e):t(p(void 0,!0))}))}))})),i),y);e.exports=function(e){var t,r=Object.create(v,(o(t={},f,{value:e,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,d,{value:function(e,t){var i=r[f].read();i?(r[h]=null,r[a]=null,r[c]=null,e(p(i,!1))):(r[a]=e,r[c]=t)},writable:!0}),t));return r[h]=null,s(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[c];return null!==t&&(r[h]=null,r[a]=null,r[c]=null,t(e)),void(r[u]=e)}var i=r[a];null!==i&&(r[h]=null,r[a]=null,r[c]=null,i(p(void 0,!0))),r[l]=!0})),e.on("readable",m.bind(null,r)),r}},7703:(e,t,r)=>{function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var s=r(2577).Buffer,a=r(9546).inspect,c=a&&a.custom||"inspect";function u(e,t,r){s.prototype.copy.call(e,t,r)}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,r,l;return t=e,r=[{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,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t=s.allocUnsafe(e>>>0),r=this.head,i=0;r;)u(r.data,t,i),i+=r.data.length,r=r.next;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,o=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,o),0==(e-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],r&&o(t.prototype,r),l&&o(t,l),e}()},4386:(e,t,r)=>{var i=r(3908);function n(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function s(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(s,this,e)):i.nextTick(s,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?r._writableState?r._writableState.errorEmitted?i.nextTick(o,r):(r._writableState.errorEmitted=!0,i.nextTick(n,r,e)):i.nextTick(n,r,e):t?(i.nextTick(o,r),t(e)):i.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}}},2888:(e,t,r)=>{var i=r(1690).F.ERR_STREAM_PREMATURE_CLOSE;function n(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}(o||n);var s=r.readable||!1!==r.readable&&t.readable,a=r.writable||!1!==r.writable&&t.writable,c=function(){t.writable||l()},u=t._writableState&&t._writableState.finished,l=function(){a=!1,u=!0,s||o.call(t)},h=t._readableState&&t._readableState.endEmitted,d=function(){s=!1,h=!0,a||o.call(t)},f=function(e){o.call(t,e)},p=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new i),o.call(t,e)):a&&!u?(t._writableState&&t._writableState.ended||(e=new i),o.call(t,e)):void 0},g=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",c),t.on("close",c)):(t.on("complete",l),t.on("abort",p),t.req?g():t.on("request",g)),t.on("end",d),t.on("finish",l),!1!==r.error&&t.on("error",f),t.on("close",p),function(){t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",g),t.req&&t.req.removeListener("finish",l),t.removeListener("end",c),t.removeListener("close",c),t.removeListener("finish",l),t.removeListener("end",d),t.removeListener("error",f),t.removeListener("close",p)}}},923:e=>{e.exports=function(){throw new Error("Readable.from is not available in the browser")}},9844:(e,t,r)=>{var i;var n=r(1690).F,o=n.ERR_MISSING_ARGS,s=n.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function c(e){e()}function u(e,t){return e.pipe(t)}e.exports=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var l,h=function(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var d=t.map((function(e,n){var o=n<t.length-1;return function(e,t,n,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var a=!1;e.on("close",(function(){a=!0})),void 0===i&&(i=r(2888)),i(e,{readable:t,writable:n},(function(e){if(e)return o(e);a=!0,o()}));var c=!1;return function(t){if(!a&&!c)return c=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new s("pipe"))}}(e,o,n>0,(function(e){l||(l=e),e&&d.forEach(c),o||(d.forEach(c),h(l))}))}));return t.reduce(u)}},5069:(e,t,r)=>{var i=r(1690).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,n){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,n,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new i(n?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},4363:(e,t,r)=>{e.exports=r(9273).EventEmitter},1181:(e,t,r)=>{(t=e.exports=r(4258)).Stream=t,t.Readable=t,t.Writable=r(4486),t.Duplex=r(444),t.Transform=r(2892),t.PassThrough=r(9942),t.finished=r(2888),t.pipeline=r(9844)},5371:e=>{function t(e,t,r){var i=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,e,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._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 r=0;r<e.length;r++)e[r]=arguments[r+2]}return new t(arguments[0],arguments[1],e)}},1691:(e,t,r)=>{e.exports=r(5962)()},5962:(e,t,r)=>{var i=r(2577).Buffer;function n(e){return e instanceof i?i.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}e.exports=function(e){return(e=e||{}).circles?function(e){var t=[],r=[];return e.proto?function e(o){if("object"!=typeof o||null===o)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return i(o,e);if(o instanceof Map)return new Map(i(Array.from(o),e));if(o instanceof Set)return new Set(i(Array.from(o),e));var s={};for(var a in t.push(o),r.push(s),o){var c=o[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(i(Array.from(c),e));else if(c instanceof Set)s[a]=new Set(i(Array.from(c),e));else if(ArrayBuffer.isView(c))s[a]=n(c);else{var u=t.indexOf(c);s[a]=-1!==u?r[u]:e(c)}}return t.pop(),r.pop(),s}:function e(o){if("object"!=typeof o||null===o)return o;if(o instanceof Date)return new Date(o);if(Array.isArray(o))return i(o,e);if(o instanceof Map)return new Map(i(Array.from(o),e));if(o instanceof Set)return new Set(i(Array.from(o),e));var s={};for(var a in t.push(o),r.push(s),o)if(!1!==Object.hasOwnProperty.call(o,a)){var c=o[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(i(Array.from(c),e));else if(c instanceof Set)s[a]=new Set(i(Array.from(c),e));else if(ArrayBuffer.isView(c))s[a]=n(c);else{var u=t.indexOf(c);s[a]=-1!==u?r[u]:e(c)}}return t.pop(),r.pop(),s};function i(e,i){for(var o=Object.keys(e),s=new Array(o.length),a=0;a<o.length;a++){var c=o[a],u=e[c];if("object"!=typeof u||null===u)s[c]=u;else if(u instanceof Date)s[c]=new Date(u);else if(ArrayBuffer.isView(u))s[c]=n(u);else{var l=t.indexOf(u);s[c]=-1!==l?r[l]:i(u)}}return s}}(e):e.proto?function e(r){if("object"!=typeof r||null===r)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return t(r,e);if(r instanceof Map)return new Map(t(Array.from(r),e));if(r instanceof Set)return new Set(t(Array.from(r),e));var i={};for(var o in r){var s=r[o];"object"!=typeof s||null===s?i[o]=s:s instanceof Date?i[o]=new Date(s):s instanceof Map?i[o]=new Map(t(Array.from(s),e)):s instanceof Set?i[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?i[o]=n(s):i[o]=e(s)}return i}:function e(r){if("object"!=typeof r||null===r)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return t(r,e);if(r instanceof Map)return new Map(t(Array.from(r),e));if(r instanceof Set)return new Set(t(Array.from(r),e));var i={};for(var o in r)if(!1!==Object.hasOwnProperty.call(r,o)){var s=r[o];"object"!=typeof s||null===s?i[o]=s:s instanceof Date?i[o]=new Date(s):s instanceof Map?i[o]=new Map(t(Array.from(s),e)):s instanceof Set?i[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?i[o]=n(s):i[o]=e(s)}return i};function t(e,t){for(var r=Object.keys(e),i=new Array(r.length),o=0;o<r.length;o++){var s=r[o],a=e[s];"object"!=typeof a||null===a?i[s]=a:a instanceof Date?i[s]=new Date(a):ArrayBuffer.isView(a)?i[s]=n(a):i[s]=t(a)}return i}}},3843:(e,t,r)=>{var i=r(2577),n=i.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(o(i,t),t.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},3462:e=>{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}},6127:(e,t,r)=>{var i=r(3843).Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=h,t=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var n=s(t[i]);if(n>=0)return n>0&&(e.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if(n=s(t[i]),n>=0)return n>0&&(e.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if(n=s(t[i]),n>=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},8884:function(e,t,r){var i;e=r.nmd(e),function(n){t&&t.nodeType,e&&e.nodeType;var o="object"==typeof r.g&&r.g;o.global!==o&&o.window!==o&&o.self;var s,a=2147483647,c=36,u=1,l=26,h=38,d=700,f=72,p=128,g="-",m=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-u,k=Math.floor,_=String.fromCharCode;function S(e){throw RangeError(b[e])}function E(e,t){for(var r=e.length,i=[];r--;)i[r]=t(e[r]);return i}function T(e,t){var r=e.split("@"),i="";return r.length>1&&(i=r[0]+"@",e=r[1]),i+E((e=e.replace(v,".")).split("."),t).join(".")}function C(e){for(var t,r,i=[],n=0,o=e.length;n<o;)(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<o?56320==(64512&(r=e.charCodeAt(n++)))?i.push(((1023&t)<<10)+(1023&r)+65536):(i.push(t),n--):i.push(t);return i}function A(e){return E(e,(function(e){var t="";return e>65535&&(t+=_((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=_(e)})).join("")}function P(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function R(e,t,r){var i=0;for(e=r?k(e/d):e>>1,e+=k(e/t);e>w*l>>1;i+=c)e=k(e/w);return k(i+(w+1)*e/(e+h))}function x(e){var t,r,i,n,o,s,h,d,m,y,v,b=[],w=e.length,_=0,E=p,T=f;for((r=e.lastIndexOf(g))<0&&(r=0),i=0;i<r;++i)e.charCodeAt(i)>=128&&S("not-basic"),b.push(e.charCodeAt(i));for(n=r>0?r+1:0;n<w;){for(o=_,s=1,h=c;n>=w&&S("invalid-input"),((d=(v=e.charCodeAt(n++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:c)>=c||d>k((a-_)/s))&&S("overflow"),_+=d*s,!(d<(m=h<=T?u:h>=T+l?l:h-T));h+=c)s>k(a/(y=c-m))&&S("overflow"),s*=y;T=R(_-o,t=b.length+1,0==o),k(_/t)>a-E&&S("overflow"),E+=k(_/t),_%=t,b.splice(_++,0,E)}return A(b)}function I(e){var t,r,i,n,o,s,h,d,m,y,v,b,w,E,T,A=[];for(b=(e=C(e)).length,t=p,r=0,o=f,s=0;s<b;++s)(v=e[s])<128&&A.push(_(v));for(i=n=A.length,n&&A.push(g);i<b;){for(h=a,s=0;s<b;++s)(v=e[s])>=t&&v<h&&(h=v);for(h-t>k((a-r)/(w=i+1))&&S("overflow"),r+=(h-t)*w,t=h,s=0;s<b;++s)if((v=e[s])<t&&++r>a&&S("overflow"),v==t){for(d=r,m=c;!(d<(y=m<=o?u:m>=o+l?l:m-o));m+=c)T=d-y,E=c-y,A.push(_(P(y+T%E,0))),d=k(T/E);A.push(_(P(d,0))),o=R(r,w,i==n),r=0,++i}++r,++t}return A.join("")}s={version:"1.3.2",ucs2:{decode:C,encode:A},decode:x,encode:I,toASCII:function(e){return T(e,(function(e){return y.test(e)?"xn--"+I(e):e}))},toUnicode:function(e){return T(e,(function(e){return m.test(e)?x(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,r,t,e))||(e.exports=i)}()},4837:(e,t,r)=>{var i=r(8884),n=r(7342);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){n.isString(e)&&(e=b(e));return e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),h=["%","/","?",";","#"].concat(l),d=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=r(6316);function b(e,t,r){if(e&&n.isObject(e)&&e instanceof o)return e;var i=new o;return i.parse(e,t,r),i}o.prototype.parse=function(e,t,r){if(!n.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o<e.indexOf("#")?"?":"#",u=e.split(a);u[0]=u[0].replace(/\\/g,"/");var b=e=u.join(a);if(b=b.trim(),!r&&1===e.split("#").length){var w=c.exec(b);if(w)return this.path=b,this.href=b,this.pathname=w[1],w[2]?(this.search=w[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var k=s.exec(b);if(k){var _=(k=k[0]).toLowerCase();this.protocol=_,b=b.substr(k.length)}if(r||k||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var S="//"===b.substr(0,2);!S||k&&m[k]||(b=b.substr(2),this.slashes=!0)}if(!m[k]&&(S||k&&!y[k])){for(var E,T,C=-1,A=0;A<d.length;A++){-1!==(P=b.indexOf(d[A]))&&(-1===C||P<C)&&(C=P)}-1!==(T=-1===C?b.lastIndexOf("@"):b.lastIndexOf("@",C))&&(E=b.slice(0,T),b=b.slice(T+1),this.auth=decodeURIComponent(E)),C=-1;for(A=0;A<h.length;A++){var P;-1!==(P=b.indexOf(h[A]))&&(-1===C||P<C)&&(C=P)}-1===C&&(C=b.length),this.host=b.slice(0,C),b=b.slice(C),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var x=this.hostname.split(/\./),I=(A=0,x.length);A<I;A++){var M=x[A];if(M&&!M.match(f)){for(var O="",B=0,N=M.length;B<N;B++)M.charCodeAt(B)>127?O+="x":O+=M[B];if(!O.match(f)){var L=x.slice(0,A),D=x.slice(A+1),U=M.match(p);U&&(L.push(U[1]),D.unshift(U[2])),D.length&&(b="/"+D.join(".")+b),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=i.toASCII(this.hostname));var j=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+j,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!g[_])for(A=0,I=l.length;A<I;A++){var V=l[A];if(-1!==b.indexOf(V)){var z=encodeURIComponent(V);z===V&&(z=escape(V)),b=b.split(V).join(z)}}var q=b.indexOf("#");-1!==q&&(this.hash=b.substr(q),b=b.slice(0,q));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),y[_]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){j=this.pathname||"";var H=this.search||"";this.path=j+H}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||"",r=this.pathname||"",i=this.hash||"",o=!1,s="";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&&n.isObject(this.query)&&Object.keys(this.query).length&&(s=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||y[t])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),i&&"#"!==i.charAt(0)&&(i="#"+i),a&&"?"!==a.charAt(0)&&(a="?"+a),t+o+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+i},o.prototype.resolve=function(e){return this.resolveObject(b(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if(n.isString(e)){var t=new o;t.parse(e,!1,!0),e=t}for(var r=new o,i=Object.keys(this),s=0;s<i.length;s++){var a=i[s];r[a]=this[a]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0;u<c.length;u++){var l=c[u];"protocol"!==l&&(r[l]=e[l])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!y[e.protocol]){for(var h=Object.keys(e),d=0;d<h.length;d++){var f=h[d];r[f]=e[f]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||m[e.protocol])r.pathname=e.pathname;else{for(var p=(e.pathname||"").split("/");p.length&&!(e.host=p.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var g=r.pathname||"",v=r.search||"";r.path=g+v}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var b=r.pathname&&"/"===r.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),k=w||b||r.host&&e.pathname,_=k,S=r.pathname&&r.pathname.split("/")||[],E=(p=e.pathname&&e.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===S[0]?S[0]=r.host:S.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===p[0]?p[0]=e.host:p.unshift(e.host)),e.host=null),k=k&&(""===p[0]||""===S[0])),w)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,S=p;else if(p.length)S||(S=[]),S.pop(),S=S.concat(p),r.search=e.search,r.query=e.query;else if(!n.isNullOrUndefined(e.search)){if(E)r.hostname=r.host=S.shift(),(R=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=R.shift(),r.host=r.hostname=R.shift());return r.search=e.search,r.query=e.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=S.slice(-1)[0],C=(r.host||e.host||S.length>1)&&("."===T||".."===T)||""===T,A=0,P=S.length;P>=0;P--)"."===(T=S[P])?S.splice(P,1):".."===T?(S.splice(P,1),A++):A&&(S.splice(P,1),A--);if(!k&&!_)for(;A--;A)S.unshift("..");!k||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),C&&"/"!==S.join("/").substr(-1)&&S.push("");var R,x=""===S[0]||S[0]&&"/"===S[0].charAt(0);E&&(r.hostname=r.host=x?"":S.length?S.shift():"",(R=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=R.shift(),r.host=r.hostname=R.shift()));return(k=k||r.host&&S.length)&&!x&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},7342:e=>{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}}},5721:(e,t,r)=>{function i(e){try{if(!r.g.localStorage)return!1}catch(e){return!1}var t=r.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}},2781:e=>{e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){i[e]=t[e]})),i;function i(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var i=t.apply(this,e),n=e[e.length-1];return"function"==typeof i&&i!==n&&Object.keys(n).forEach((function(e){i[e]=n[e]})),i}}},965:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},7616:e=>{e.exports=function(){for(var e={},r=0;r<arguments.length;r++){var i=arguments[r];for(var n in i)t.call(i,n)&&(e[n]=i[n])}return e};var t=Object.prototype.hasOwnProperty},785:e=>{e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},601:(e,t,r)=>{function i(e){var t=this;if(t instanceof i||(t=new i),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)t.push(arguments[r]);return t}function n(e,t,r){var i=t===e.head?new a(r,null,t,e):new a(r,t,t.next,e);return null===i.next&&(e.tail=i),null===i.prev&&(e.head=i),e.length++,i}function o(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,r,i){if(!(this instanceof a))return new a(e,t,r,i);this.list=i,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},i.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},i.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},i.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},i.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},i.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},i.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},i.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,i=0;null!==r;i++)e.call(t,r.value,i,this),r=r.next},i.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,i=this.length-1;null!==r;i--)e.call(t,r.value,i,this),r=r.prev},i.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},i.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},i.prototype.map=function(e,t){t=t||this;for(var r=new i,n=this.head;null!==n;)r.push(e.call(t,n.value,this)),n=n.next;return r},i.prototype.mapReverse=function(e,t){t=t||this;for(var r=new i,n=this.tail;null!==n;)r.push(e.call(t,n.value,this)),n=n.prev;return r},i.prototype.reduce=function(e,t){var r,i=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=e(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(e,t){var r,i=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=e(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},i.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},i.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,o=this.head;null!==o&&n<e;n++)o=o.next;for(;null!==o&&n<t;n++,o=o.next)r.push(o.value);return r},i.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,o=this.tail;null!==o&&n>t;n--)o=o.prev;for(;null!==o&&n>e;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var i=0,o=this.head;null!==o&&i<e;i++)o=o.next;var s=[];for(i=0;o&&i<t;i++)s.push(o.value),o=this.removeNode(o);null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev);for(i=0;i<r.length;i++)o=n(this,o,r[i]);return s},i.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=t,this.tail=e,this};try{r(785)(i)}catch(e){}},6880:function(e){e.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var i=r(18),n=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,i){void 0===i&&(i=!1);var n=e.getVersionPrecision(t),o=e.getVersionPrecision(r),s=Math.max(n,o),a=0,c=e.map([t,r],(function(t){var r=s-e.getVersionPrecision(t),i=t+new Array(r+1).join(".0");return e.map(i.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(i&&(a=s-Math.min(n,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var r,i=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)i.push(t(e[r]));return i},e.find=function(e,t){var r,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,i=e.length;r<i;r+=1){var n=e[r];if(t(n,r))return n}},e.assign=function(e){for(var t,r,i=e,n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){i[t]=e[t]}))};for(t=0,r=o.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return i.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return i.BROWSER_MAP[e]||""},e}();t.default=n,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(91))&&i.__esModule?i:{default:i},o=r(18);function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(){}var t,r,i;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new n.default(e,t)},e.parse=function(e){return new n.default(e).getResult()},t=e,i=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],(r=null)&&s(t.prototype,r),i&&s(t,i),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var i=c(r(92)),n=c(r(93)),o=c(r(94)),s=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},i=0,n={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(n[t]=s,o+=1):"object"==typeof s&&(r[t]=s,i+=1)})),i>0){var s=Object.keys(r),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var u=this.satisfies(r[c]);if(void 0!==u)return u}var l=a.default.find(s,(function(e){return t.isPlatform(e)}));if(l){var h=this.satisfies(r[l]);if(void 0!==h)return h}}if(o>0){var d=Object.keys(n),f=a.default.find(d,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(n[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),i=e.toLowerCase(),n=a.default.getBrowserTypeByAlias(i);return t&&n&&(i=n.toLowerCase()),i===r},t.compareVersion=function(e){var t=[0],r=e,i=!1,n=this.getBrowserVersion();if("string"==typeof n)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(i=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(i=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(n,r,i))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=n.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=n.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=n.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=n.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=n.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=n.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=n.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=n.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=n.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=n.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=n.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=n.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=n.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=n.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=n.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=n.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=n.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=n.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=n.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=n.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=n.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=n.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=n.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=n.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=n.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=n.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=n.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:n.default.getFirstMatch(t,e),version:n.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=n.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=n.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=n.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=n.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=n.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=n.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=n.default.getMacOSVersionName(t),i={name:o.OS_MAP.MacOS,version:t};return r&&(i.versionName=r),i}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=n.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=n.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=n.default.getAndroidVersionName(t),i={name:o.OS_MAP.Android,version:t};return r&&(i.versionName=r),i}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=n.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=n.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||n.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||n.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=n.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=n.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=n.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=n.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=n.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=n.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=n.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=n.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=n.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=n.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=s,e.exports=t.default}})},955:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib.BlockCipher,r=e.algo,n=[],o=[],s=[],a=[],c=[],u=[],l=[],h=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,n[r]=p,o[p]=r;var g=e[r],m=e[g],y=e[m],v=257*e[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,u[r]=v,v=16843009*y^65537*m^257*g^16843008*r,l[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,d[p]=v<<8|v>>>24,f[p]=v,r?(r=g^e[e[e[y^g]]],i^=e[e[i]]):r=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s<i;s++)s<r?o[s]=t[s]:(u=o[s-1],s%r?r>6&&s%r==4&&(u=n[u>>>24]<<24|n[u>>>16&255]<<16|n[u>>>8&255]<<8|n[255&u]):(u=n[(u=u<<8|u>>>24)>>>24]<<24|n[u>>>16&255]<<16|n[u>>>8&255]<<8|n[255&u],u^=p[s/r|0]<<24),o[s]=o[s-r]^u);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(s=i-c,c%4)var u=o[s];else u=o[s-4];a[c]=c<4||s<=4?u:l[n[u>>>24]]^h[n[u>>>16&255]]^d[n[u>>>8&255]]^f[n[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,u,n)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,h,d,f,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,i,n,o,s,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],h=e[t+2]^r[2],d=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=i[u>>>24]^n[l>>>16&255]^o[h>>>8&255]^s[255&d]^r[f++],m=i[l>>>24]^n[h>>>16&255]^o[d>>>8&255]^s[255&u]^r[f++],y=i[h>>>24]^n[d>>>16&255]^o[u>>>8&255]^s[255&l]^r[f++],v=i[d>>>24]^n[u>>>16&255]^o[l>>>8&255]^s[255&h]^r[f++];u=g,l=m,h=y,d=v}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&d])^r[f++],m=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^r[f++],y=(a[h>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[f++],v=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^r[f++],e[t]=g,e[t+1]=m,e[t+2]=y,e[t+3]=v},keySize:8});e.AES=t._createHelper(g)}(),i.AES)},3128:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib.BlockCipher,r=e.algo;const n=16,o=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],s=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var a={pbox:[],sbox:[]};function c(e,t){let r=t>>24&255,i=t>>16&255,n=t>>8&255,o=255&t,s=e.sbox[0][r]+e.sbox[1][i];return s^=e.sbox[2][n],s+=e.sbox[3][o],s}function u(e,t,r){let i,o=t,s=r;for(let t=0;t<n;++t)o^=e.pbox[t],s=c(e,o)^s,i=o,o=s,s=i;return i=o,o=s,s=i,s^=e.pbox[n],o^=e.pbox[n+1],{left:o,right:s}}function l(e,t,r){let i,o=t,s=r;for(let t=n+1;t>1;--t)o^=e.pbox[t],s=c(e,o)^s,i=o,o=s,s=i;return i=o,o=s,s=i,s^=e.pbox[1],o^=e.pbox[0],{left:o,right:s}}function h(e,t,r){for(let t=0;t<4;t++){e.sbox[t]=[];for(let r=0;r<256;r++)e.sbox[t][r]=s[t][r]}let i=0;for(let s=0;s<n+2;s++)e.pbox[s]=o[s]^t[i],i++,i>=r&&(i=0);let a=0,c=0,l=0;for(let t=0;t<n+2;t+=2)l=u(e,a,c),a=l.left,c=l.right,e.pbox[t]=a,e.pbox[t+1]=c;for(let t=0;t<4;t++)for(let r=0;r<256;r+=2)l=u(e,a,c),a=l.left,c=l.right,e.sbox[t][r]=a,e.sbox[t][r+1]=c;return!0}var d=r.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4;h(a,t,r)}},encryptBlock:function(e,t){var r=u(a,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},decryptBlock:function(e,t){var r=l(a,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(d)}(),i.Blowfish)},7165:function(e,t,r){var i;e.exports=(i=r(9021),r(9506),void(i.lib.Cipher||function(e){var t=i,r=t.lib,n=r.Base,o=r.WordArray,s=r.BufferedBlockAlgorithm,a=t.enc,c=(a.Utf8,a.Base64),u=t.algo.EvpKDF,l=r.Cipher=s.extend({cfg:n.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?b:y}return function(t){return{encrypt:function(r,i,n){return e(i).encrypt(t,r,i,n)},decrypt:function(r,i,n){return e(i).decrypt(t,r,i,n)}}}}()}),h=(r.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),t.mode={}),d=r.BlockCipherMode=n.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=h.CBC=function(){var t=d.extend();function r(t,r,i){var n,o=this._iv;o?(n=o,this._iv=e):n=this._prevBlock;for(var s=0;s<i;s++)t[r+s]^=n[s]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;r.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,o=e.slice(t,t+n);i.decryptBlock(e,t),r.call(this,e,t,n),this._prevBlock=o}}),t}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,n=i<<24|i<<16|i<<8|i,s=[],a=0;a<i;a+=4)s.push(n);var c=o.create(s,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},g=(r.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,r=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(i,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),r.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),m=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?o.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=o.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),g.create({ciphertext:r,salt:t})}},y=r.SerializableCipher=n.extend({cfg:n.extend({format:m}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=e.createEncryptor(r,i),o=n.finalize(t),s=n.cfg;return g.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(r,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),v=(t.kdf={}).OpenSSL={execute:function(e,t,r,i,n){if(i||(i=o.random(8)),n)s=u.create({keySize:t+r,hasher:n}).compute(e,i);else var s=u.create({keySize:t+r}).compute(e,i);var a=o.create(s.words.slice(t),4*r);return s.sigBytes=4*t,g.create({key:s,iv:a,salt:i})}},b=r.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:v}),encrypt:function(e,t,r,i){var n=(i=this.cfg.extend(i)).kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=n.iv;var o=y.encrypt.call(this,e,t,n.key,i);return o.mixIn(n),o},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);return i.iv=n.iv,y.decrypt.call(this,e,t,n.key,i)}})}()))},9021:function(e,t,r){var i;e.exports=(i=i||function(e,t){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==r.g&&r.g.crypto&&(i=r.g.crypto),!i)try{i=r(477)}catch(e){}var n=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),s={},a=s.lib={},c=a.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=a.WordArray=c.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var s=r[o>>>2]>>>24-o%4*8&255;t[i+o>>>2]|=s<<24-(i+o)%4*8}else for(var a=0;a<n;a+=4)t[i+a>>>2]=r[a>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new u.init(t,e)}}),l=s.enc={},h=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new u.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new u.init(r,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,i=this._data,n=i.words,o=i.sigBytes,s=this.blockSize,a=o/(4*s),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,l=e.min(4*c,o);if(c){for(var h=0;h<c;h+=s)this._doProcessBlock(n,h);r=n.splice(0,c),i.sigBytes-=l}return new u.init(r,l)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new g.HMAC.init(e,r).finalize(t)}}}),s.algo={});return s}(Math),i)},754:function(e,t,r){var i;e.exports=(i=r(9021),function(){var e=i,t=e.lib.WordArray;function r(e,r,i){for(var n=[],o=0,s=0;s<r;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2|i[e.charCodeAt(s)]>>>6-s%4*2;n[o>>>2]|=a<<24-o%4*8,o++}return t.create(n,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,i=this._map;e.clamp();for(var n=[],o=0;o<r;o+=3)for(var s=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<r;a++)n.push(i.charAt(s>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;n.length%4;)n.push(c);return n.join("")},parse:function(e){var t=e.length,i=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var o=0;o<i.length;o++)n[i.charCodeAt(o)]=o}var s=i.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return r(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),i.enc.Base64)},4725:function(e,t,r){var i;e.exports=(i=r(9021),function(){var e=i,t=e.lib.WordArray;function r(e,r,i){for(var n=[],o=0,s=0;s<r;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2|i[e.charCodeAt(s)]>>>6-s%4*2;n[o>>>2]|=a<<24-o%4*8,o++}return t.create(n,o)}e.enc.Base64url={stringify:function(e,t){void 0===t&&(t=!0);var r=e.words,i=e.sigBytes,n=t?this._safe_map:this._map;e.clamp();for(var o=[],s=0;s<i;s+=3)for(var a=(r[s>>>2]>>>24-s%4*8&255)<<16|(r[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|r[s+2>>>2]>>>24-(s+2)%4*8&255,c=0;c<4&&s+.75*c<i;c++)o.push(n.charAt(a>>>6*(3-c)&63));var u=n.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(e,t){void 0===t&&(t=!0);var i=e.length,n=t?this._safe_map:this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var s=0;s<n.length;s++)o[n.charCodeAt(s)]=s}var a=n.charAt(64);if(a){var c=e.indexOf(a);-1!==c&&(i=c)}return r(e,i,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),i.enc.Base64url)},5503:function(e,t,r){var i;e.exports=(i=r(9021),function(){var e=i,t=e.lib.WordArray,r=e.enc;function n(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n+=2){var o=t[n>>>2]>>>16-n%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var r=e.length,i=[],n=0;n<r;n++)i[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return t.create(i,2*r)}},r.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],o=0;o<r;o+=2){var s=n(t[o>>>2]>>>16-o%4*8&65535);i.push(String.fromCharCode(s))}return i.join("")},parse:function(e){for(var r=e.length,i=[],o=0;o<r;o++)i[o>>>1]|=n(e.charCodeAt(o)<<16-o%2*16);return t.create(i,2*r)}}}(),i.enc.Utf16)},9506:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(9021),r(5471),r(1025),n=(i=l).lib,o=n.Base,s=n.WordArray,a=i.algo,c=a.MD5,u=a.EvpKDF=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,i=this.cfg,n=i.hasher.create(),o=s.create(),a=o.words,c=i.keySize,u=i.iterations;a.length<c;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var l=1;l<u;l++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),i.EvpKDF=function(e,t,r){return u.create(r).compute(e,t)},l.EvpKDF)},25:function(e,t,r){var i,n,o,s;e.exports=(s=r(9021),r(7165),n=(i=s).lib.CipherParams,o=i.enc.Hex,i.format.Hex={stringify:function(e){return e.ciphertext.toString(o)},parse:function(e){var t=o.parse(e);return n.create({ciphertext:t})}},s.format.Hex)},3793:function(e,t,r){var i;e.exports=(i=r(9021),r(3009),r(1025),i.HmacSHA256)},1025:function(e,t,r){var i,n,o,s;e.exports=(i=r(9021),o=(n=i).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,i=4*r;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),o=this._iKey=t.clone(),a=n.words,c=o.words,u=0;u<r;u++)a[u]^=1549556828,c[u]^=909522486;n.sigBytes=o.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},1396:function(e,t,r){var i;e.exports=(i=r(9021),r(3240),r(6440),r(5503),r(754),r(4725),r(4636),r(5471),r(3009),r(6308),r(1380),r(9557),r(5953),r(8056),r(1025),r(19),r(9506),r(7165),r(2169),r(6939),r(6372),r(3797),r(8454),r(2073),r(4905),r(482),r(2155),r(8124),r(25),r(955),r(7628),r(7193),r(6298),r(2696),r(3128),i)},6440:function(e,t,r){var i;e.exports=(i=r(9021),function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,i=[],n=0;n<r;n++)i[n>>>2]|=e[n]<<24-n%4*8;t.call(this,i,r)}else t.apply(this,arguments)};r.prototype=e}}(),i.lib.WordArray)},4636:function(e,t,r){var i;e.exports=(i=r(9021),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],v=e[t+7],b=e[t+8],w=e[t+9],k=e[t+10],_=e[t+11],S=e[t+12],E=e[t+13],T=e[t+14],C=e[t+15],A=o[0],P=o[1],R=o[2],x=o[3];A=u(A,P,R,x,s,7,a[0]),x=u(x,A,P,R,c,12,a[1]),R=u(R,x,A,P,f,17,a[2]),P=u(P,R,x,A,p,22,a[3]),A=u(A,P,R,x,g,7,a[4]),x=u(x,A,P,R,m,12,a[5]),R=u(R,x,A,P,y,17,a[6]),P=u(P,R,x,A,v,22,a[7]),A=u(A,P,R,x,b,7,a[8]),x=u(x,A,P,R,w,12,a[9]),R=u(R,x,A,P,k,17,a[10]),P=u(P,R,x,A,_,22,a[11]),A=u(A,P,R,x,S,7,a[12]),x=u(x,A,P,R,E,12,a[13]),R=u(R,x,A,P,T,17,a[14]),A=l(A,P=u(P,R,x,A,C,22,a[15]),R,x,c,5,a[16]),x=l(x,A,P,R,y,9,a[17]),R=l(R,x,A,P,_,14,a[18]),P=l(P,R,x,A,s,20,a[19]),A=l(A,P,R,x,m,5,a[20]),x=l(x,A,P,R,k,9,a[21]),R=l(R,x,A,P,C,14,a[22]),P=l(P,R,x,A,g,20,a[23]),A=l(A,P,R,x,w,5,a[24]),x=l(x,A,P,R,T,9,a[25]),R=l(R,x,A,P,p,14,a[26]),P=l(P,R,x,A,b,20,a[27]),A=l(A,P,R,x,E,5,a[28]),x=l(x,A,P,R,f,9,a[29]),R=l(R,x,A,P,v,14,a[30]),A=h(A,P=l(P,R,x,A,S,20,a[31]),R,x,m,4,a[32]),x=h(x,A,P,R,b,11,a[33]),R=h(R,x,A,P,_,16,a[34]),P=h(P,R,x,A,T,23,a[35]),A=h(A,P,R,x,c,4,a[36]),x=h(x,A,P,R,g,11,a[37]),R=h(R,x,A,P,v,16,a[38]),P=h(P,R,x,A,k,23,a[39]),A=h(A,P,R,x,E,4,a[40]),x=h(x,A,P,R,s,11,a[41]),R=h(R,x,A,P,p,16,a[42]),P=h(P,R,x,A,y,23,a[43]),A=h(A,P,R,x,w,4,a[44]),x=h(x,A,P,R,S,11,a[45]),R=h(R,x,A,P,C,16,a[46]),A=d(A,P=h(P,R,x,A,f,23,a[47]),R,x,s,6,a[48]),x=d(x,A,P,R,v,10,a[49]),R=d(R,x,A,P,T,15,a[50]),P=d(P,R,x,A,m,21,a[51]),A=d(A,P,R,x,S,6,a[52]),x=d(x,A,P,R,p,10,a[53]),R=d(R,x,A,P,k,15,a[54]),P=d(P,R,x,A,c,21,a[55]),A=d(A,P,R,x,b,6,a[56]),x=d(x,A,P,R,C,10,a[57]),R=d(R,x,A,P,y,15,a[58]),P=d(P,R,x,A,E,21,a[59]),A=d(A,P,R,x,g,6,a[60]),x=d(x,A,P,R,_,10,a[61]),R=d(R,x,A,P,f,15,a[62]),P=d(P,R,x,A,w,21,a[63]),o[0]=o[0]+A|0,o[1]=o[1]+P|0,o[2]=o[2]+R|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;r[n>>>5]|=128<<24-n%32;var o=e.floor(i/4294967296),s=i;r[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,n,o,s){var a=e+(t&r|~t&i)+n+s;return(a<<o|a>>>32-o)+t}function l(e,t,r,i,n,o,s){var a=e+(t&i|r&~i)+n+s;return(a<<o|a>>>32-o)+t}function h(e,t,r,i,n,o,s){var a=e+(t^r^i)+n+s;return(a<<o|a>>>32-o)+t}function d(e,t,r,i,n,o,s){var a=e+(r^(t|~i))+n+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),i.MD5)},2169:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,r,i){var n,o=this._iv;o?(n=o.slice(0),this._iv=void 0):n=this._prevBlock,i.encryptBlock(n,0);for(var s=0;s<r;s++)e[t+s]^=n[s]}return e.Encryptor=e.extend({processBlock:function(e,r){var i=this._cipher,n=i.blockSize;t.call(this,e,r,n,i),this._prevBlock=e.slice(r,r+n)}}),e.Decryptor=e.extend({processBlock:function(e,r){var i=this._cipher,n=i.blockSize,o=e.slice(r,r+n);t.call(this,e,r,n,i),this._prevBlock=o}}),e}(),i.mode.CFB)},6372:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,r=e>>8&255,i=255&e;255===t?(t=0,255===r?(r=0,255===i?i=0:++i):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=i}return e}function r(e){return 0===(e[0]=t(e[0]))&&(e[1]=t(e[1])),e}var n=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),r(s);var a=s.slice(0);i.encryptBlock(a,0);for(var c=0;c<n;c++)e[t+c]^=a[c]}});return e.Decryptor=n,e}(),i.mode.CTRGladman)},6939:function(e,t,r){var i,n,o;e.exports=(o=r(9021),r(7165),o.mode.CTR=(i=o.lib.BlockCipherMode.extend(),n=i.Encryptor=i.extend({processBlock:function(e,t){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);r.encryptBlock(s,0),o[i-1]=o[i-1]+1|0;for(var a=0;a<i;a++)e[t+a]^=s[a]}}),i.Decryptor=n,i),o.mode.CTR)},8454:function(e,t,r){var i,n;e.exports=(n=r(9021),r(7165),n.mode.ECB=((i=n.lib.BlockCipherMode.extend()).Encryptor=i.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),i.Decryptor=i.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),i),n.mode.ECB)},3797:function(e,t,r){var i,n,o;e.exports=(o=r(9021),r(7165),o.mode.OFB=(i=o.lib.BlockCipherMode.extend(),n=i.Encryptor=i.extend({processBlock:function(e,t){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),r.encryptBlock(o,0);for(var s=0;s<i;s++)e[t+s]^=o[s]}}),i.Decryptor=n,i),o.mode.OFB)},2073:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,i=4*t,n=i-r%i,o=r+n-1;e.clamp(),e.words[o>>>2]|=n<<24-o%4*8,e.sigBytes+=n},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)},4905:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.pad.Iso10126={pad:function(e,t){var r=4*t,n=r-e.sigBytes%r;e.concat(i.lib.WordArray.random(n-1)).concat(i.lib.WordArray.create([n<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)},482:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)},8124:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)},2155:function(e,t,r){var i;e.exports=(i=r(9021),r(7165),i.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){var t=e.words,r=e.sigBytes-1;for(r=e.sigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.sigBytes=r+1;break}}},i.pad.ZeroPadding)},19:function(e,t,r){var i,n,o,s,a,c,u,l,h;e.exports=(h=r(9021),r(3009),r(1025),n=(i=h).lib,o=n.Base,s=n.WordArray,a=i.algo,c=a.SHA256,u=a.HMAC,l=a.PBKDF2=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:25e4}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,i=u.create(r.hasher,e),n=s.create(),o=s.create([1]),a=n.words,c=o.words,l=r.keySize,h=r.iterations;a.length<l;){var d=i.update(t).finalize(o);i.reset();for(var f=d.words,p=f.length,g=d,m=1;m<h;m++){g=i.finalize(g),i.reset();for(var y=g.words,v=0;v<p;v++)f[v]^=y[v]}n.concat(d),c[0]++}return n.sigBytes=4*l,n}}),i.PBKDF2=function(e,t,r){return l.create(r).compute(e,t)},h.PBKDF2)},2696:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=u>>>16|4294901760&l,d=l<<16|65535&u;for(i[0]^=u,i[1]^=h,i[2]^=l,i[3]^=d,i[4]^=u,i[5]^=h,i[6]^=l,i[7]^=d,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)o[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,r=0;r<8;r++){var i=e[r]+t[r],n=65535&i,a=i>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,u=((4294901760&i)*i|0)+((65535&i)*i|0);s[r]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.RabbitLegacy=t._createHelper(a)}(),i.RabbitLegacy)},6298:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)c.call(this);for(r=0;r<8;r++)n[r]^=i[r+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=u>>>16|4294901760&l,d=l<<16|65535&u;for(n[0]^=u,n[1]^=h,n[2]^=l,n[3]^=d,n[4]^=u,n[5]^=h,n[6]^=l,n[7]^=d,r=0;r<4;r++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)o[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,r=0;r<8;r++){var i=e[r]+t[r],n=65535&i,a=i>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,u=((4294901760&i)*i|0)+((65535&i)*i|0);s[r]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.Rabbit=t._createHelper(a)}(),i.Rabbit)},7193:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,i=this._S=[],n=0;n<256;n++)i[n]=n;n=0;for(var o=0;n<256;n++){var s=n%r,a=t[s>>>2]>>>24-s%4*8&255;o=(o+i[n]+a)%256;var c=i[n];i[n]=i[o],i[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,r=this._j,i=0,n=0;n<4;n++){r=(r+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[r],e[r]=o,i|=e[(e[t]+e[r])%256]<<24-8*n}return this._i=t,this._j=r,i}e.RC4=t._createHelper(n);var s=r.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});e.RC4Drop=t._createHelper(s)}(),i.RC4)},8056:function(e,t,r){var i;e.exports=(i=r(9021),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),l=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=n.create([0,1518500249,1859775393,2400959708,2840853838]),d=n.create([1352829926,1548603684,1836072691,2053994217,0]),f=s.RIPEMD160=o.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,f,w,k,_,S,E,T,C,A,P=this._hash.words,R=h.words,x=d.words,I=a.words,M=c.words,O=u.words,B=l.words;for(_=o=P[0],S=s=P[1],E=f=P[2],T=w=P[3],C=k=P[4],r=0;r<80;r+=1)A=o+e[t+I[r]]|0,A+=r<16?p(s,f,w)+R[0]:r<32?g(s,f,w)+R[1]:r<48?m(s,f,w)+R[2]:r<64?y(s,f,w)+R[3]:v(s,f,w)+R[4],A=(A=b(A|=0,O[r]))+k|0,o=k,k=w,w=b(f,10),f=s,s=A,A=_+e[t+M[r]]|0,A+=r<16?v(S,E,T)+x[0]:r<32?y(S,E,T)+x[1]:r<48?m(S,E,T)+x[2]:r<64?g(S,E,T)+x[3]:p(S,E,T)+x[4],A=(A=b(A|=0,B[r]))+C|0,_=C,C=T,T=b(E,10),E=S,S=A;A=P[1]+f+T|0,P[1]=P[2]+w+C|0,P[2]=P[3]+k+_|0,P[3]=P[4]+o+S|0,P[4]=P[0]+s+E|0,P[0]=A},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var n=this._hash,o=n.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return n},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function g(e,t,r){return e&t|~e&r}function m(e,t,r){return(e|~t)^r}function y(e,t,r){return e&r|t&~r}function v(e,t,r){return e^(t|~r)}function b(e,t){return e<<t|e>>>32-t}t.RIPEMD160=o._createHelper(f),t.HmacRIPEMD160=o._createHmacHelper(f)}(Math),i.RIPEMD160)},5471:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(9021),n=(i=l).lib,o=n.WordArray,s=n.Hasher,a=i.algo,c=[],u=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var h=(i<<5|i>>>27)+a+c[u];h+=u<20?1518500249+(n&o|~n&s):u<40?1859775393+(n^o^s):u<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,a=s,s=o,o=n<<30|n>>>2,n=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(i+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.SHA1=s._createHelper(u),i.HmacSHA1=s._createHmacHelper(u),l.SHA1)},6308:function(e,t,r){var i,n,o,s,a,c;e.exports=(c=r(9021),r(3009),n=(i=c).lib.WordArray,o=i.algo,s=o.SHA256,a=o.SHA224=s.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=4,e}}),i.SHA224=s._createHelper(a),i.HmacSHA224=s._createHmacHelper(a),c.SHA224)},3009:function(e,t,r){var i;e.exports=(i=r(9021),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),i=2;i<=r;i++)if(!(t%i))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var i=2,n=0;n<64;)t(i)&&(n<8&&(a[n]=r(e.pow(i,.5))),c[n]=r(e.pow(i,1/3)),n++),i++}();var u=[],l=s.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,m=u[f-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[f]=g+u[f-7]+y+u[f-16]}var v=i&n^i&o^n&o,b=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),w=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=s+w|0,s=o,o=n,n=i,i=w+(b+v)|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+d|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=e.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(l),t.HmacSHA256=o._createHmacHelper(l)}(Math),i.SHA256)},5953:function(e,t,r){var i;e.exports=(i=r(9021),r(3240),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.x64.Word,a=t.algo,c=[],u=[],l=[];!function(){for(var e=1,t=0,r=0;r<24;r++){c[e+5*t]=(r+1)*(r+2)/2%64;var i=(2*e+3*t)%5;e=t%5,t=i}for(e=0;e<5;e++)for(t=0;t<5;t++)u[e+5*t]=t+(2*e+3*t)%5*5;for(var n=1,o=0;o<24;o++){for(var a=0,h=0,d=0;d<7;d++){if(1&n){var f=(1<<d)-1;f<32?h^=1<<f:a^=1<<f-32}128&n?n=n<<1^113:n<<=1}l[o]=s.create(a,h)}}();var h=[];!function(){for(var e=0;e<25;e++)h[e]=s.create()}();var d=a.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var r=this._state,i=this.blockSize/2,n=0;n<i;n++){var o=e[t+2*n],s=e[t+2*n+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(P=r[n]).high^=s,P.low^=o}for(var a=0;a<24;a++){for(var d=0;d<5;d++){for(var f=0,p=0,g=0;g<5;g++)f^=(P=r[d+5*g]).high,p^=P.low;var m=h[d];m.high=f,m.low=p}for(d=0;d<5;d++){var y=h[(d+4)%5],v=h[(d+1)%5],b=v.high,w=v.low;for(f=y.high^(b<<1|w>>>31),p=y.low^(w<<1|b>>>31),g=0;g<5;g++)(P=r[d+5*g]).high^=f,P.low^=p}for(var k=1;k<25;k++){var _=(P=r[k]).high,S=P.low,E=c[k];E<32?(f=_<<E|S>>>32-E,p=S<<E|_>>>32-E):(f=S<<E-32|_>>>64-E,p=_<<E-32|S>>>64-E);var T=h[u[k]];T.high=f,T.low=p}var C=h[0],A=r[0];for(C.high=A.high,C.low=A.low,d=0;d<5;d++)for(g=0;g<5;g++){var P=r[k=d+5*g],R=h[k],x=h[(d+1)%5+5*g],I=h[(d+2)%5+5*g];P.high=R.high^~x.high&I.high,P.low=R.low^~x.low&I.low}P=r[0];var M=l[a];P.high^=M.high,P.low^=M.low}},_doFinalize:function(){var t=this._data,r=t.words,i=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[i>>>5]|=1<<24-i%32,r[(e.ceil((i+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],l=0;l<c;l++){var h=s[l],d=h.high,f=h.low;d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),u.push(f),u.push(d)}return new n.init(u,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});t.SHA3=o._createHelper(d),t.HmacSHA3=o._createHmacHelper(d)}(Math),i.SHA3)},9557:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(9021),r(3240),r(1380),n=(i=l).x64,o=n.Word,s=n.WordArray,a=i.algo,c=a.SHA512,u=a.SHA384=c.extend({_doReset:function(){this._hash=new s.init([new o.init(3418070365,3238371032),new o.init(1654270250,914150663),new o.init(2438529370,812702999),new o.init(355462360,4144912697),new o.init(1731405415,4290775857),new o.init(2394180231,1750603025),new o.init(3675008525,1694076839),new o.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),i.SHA384=c._createHelper(u),i.HmacSHA384=c._createHmacHelper(u),l.SHA384)},1380:function(e,t,r){var i;e.exports=(i=r(9021),r(3240),function(){var e=i,t=e.lib.Hasher,r=e.x64,n=r.Word,o=r.WordArray,s=e.algo;function a(){return n.create.apply(n,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var e=0;e<80;e++)u[e]=a()}();var l=s.SHA512=t.extend({_doReset:function(){this._hash=new o.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=i.high,p=i.low,g=n.high,m=n.low,y=o.high,v=o.low,b=s.high,w=s.low,k=a.high,_=a.low,S=l.high,E=l.low,T=h.high,C=h.low,A=d.high,P=d.low,R=f,x=p,I=g,M=m,O=y,B=v,N=b,L=w,D=k,U=_,j=S,F=E,V=T,z=C,q=A,W=P,H=0;H<80;H++){var K,$,G=u[H];if(H<16)$=G.high=0|e[t+2*H],K=G.low=0|e[t+2*H+1];else{var Q=u[H-15],J=Q.high,Y=Q.low,X=(J>>>1|Y<<31)^(J>>>8|Y<<24)^J>>>7,Z=(Y>>>1|J<<31)^(Y>>>8|J<<24)^(Y>>>7|J<<25),ee=u[H-2],te=ee.high,re=ee.low,ie=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ne=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),oe=u[H-7],se=oe.high,ae=oe.low,ce=u[H-16],ue=ce.high,le=ce.low;$=($=($=X+se+((K=Z+ae)>>>0<Z>>>0?1:0))+ie+((K+=ne)>>>0<ne>>>0?1:0))+ue+((K+=le)>>>0<le>>>0?1:0),G.high=$,G.low=K}var he,de=D&j^~D&V,fe=U&F^~U&z,pe=R&I^R&O^I&O,ge=x&M^x&B^M&B,me=(R>>>28|x<<4)^(R<<30|x>>>2)^(R<<25|x>>>7),ye=(x>>>28|R<<4)^(x<<30|R>>>2)^(x<<25|R>>>7),ve=(D>>>14|U<<18)^(D>>>18|U<<14)^(D<<23|U>>>9),be=(U>>>14|D<<18)^(U>>>18|D<<14)^(U<<23|D>>>9),we=c[H],ke=we.high,_e=we.low,Se=q+ve+((he=W+be)>>>0<W>>>0?1:0),Ee=ye+ge;q=V,W=z,V=j,z=F,j=D,F=U,D=N+(Se=(Se=(Se=Se+de+((he+=fe)>>>0<fe>>>0?1:0))+ke+((he+=_e)>>>0<_e>>>0?1:0))+$+((he+=K)>>>0<K>>>0?1:0))+((U=L+he|0)>>>0<L>>>0?1:0)|0,N=O,L=B,O=I,B=M,I=R,M=x,R=Se+(me+pe+(Ee>>>0<ye>>>0?1:0))+((x=he+Ee|0)>>>0<he>>>0?1:0)|0}p=i.low=p+x,i.high=f+R+(p>>>0<x>>>0?1:0),m=n.low=m+M,n.high=g+I+(m>>>0<M>>>0?1:0),v=o.low=v+B,o.high=y+O+(v>>>0<B>>>0?1:0),w=s.low=w+L,s.high=b+N+(w>>>0<L>>>0?1:0),_=a.low=_+U,a.high=k+D+(_>>>0<U>>>0?1:0),E=l.low=E+F,l.high=S+j+(E>>>0<F>>>0?1:0),C=h.low=C+z,h.high=T+V+(C>>>0<z>>>0?1:0),P=d.low=P+W,d.high=A+q+(P>>>0<W>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(i+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),i.SHA512)},7628:function(e,t,r){var i;e.exports=(i=r(9021),r(754),r(4636),r(9506),r(7165),function(){var e=i,t=e.lib,r=t.WordArray,n=t.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=n.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var i=s[r]-1;t[r]=e[i>>>5]>>>31-i%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var u=n[o]=[],l=c[o];for(r=0;r<24;r++)u[r/6|0]|=t[(a[r]-1+l)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(a[r+24]-1+l)%28]<<31-r%6;for(u[0]=u[0]<<1|u[0]>>>31,r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=n[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],d.call(this,4,252645135),d.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),d.call(this,1,1431655765);for(var i=0;i<16;i++){for(var n=r[i],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^n[c])&l[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,d.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),d.call(this,16,65535),d.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function d(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<<e}function f(e,t){var r=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<<e}e.DES=n._createHelper(h);var p=o.TripleDES=n.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),i=e.length<4?e.slice(0,2):e.slice(2,4),n=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=h.createEncryptor(r.create(t)),this._des2=h.createEncryptor(r.create(i)),this._des3=h.createEncryptor(r.create(n))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=n._createHelper(p)}(),i.TripleDES)},3240:function(e,t,r){var i;e.exports=(i=r(9021),function(e){var t=i,r=t.lib,n=r.Base,o=r.WordArray,s=t.x64={};s.Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),s.WordArray=n.extend({init:function(t,r){t=this.words=t||[],this.sigBytes=r!=e?r:8*t.length},toX32:function(){for(var e=this.words,t=e.length,r=[],i=0;i<t;i++){var n=e[i];r.push(n.high),r.push(n.low)}return o.create(r,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),r=t.length,i=0;i<r;i++)t[i]=t[i].clone();return e}})}(),i)},7007:e=>{var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,n,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(o){i.once&&e.removeEventListener(t,n),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)i(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},3790:(e,t,r)=>{e.exports=function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){var r=t[s][1][e];return n(r||e)}),u,u.exports,e,t,r,i)}return r[s].exports}for(var o=void 0,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,i){(function(e){var r,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var o=0,s=new n(l),a=e.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){l(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(l,0)};else{var c=new e.MessageChannel;c.port1.onmessage=l,r=function(){c.port2.postMessage(0)}}var u=[];function l(){var e,t;i=!0;for(var r=u.length;r;){for(t=u,u=[],e=-1;++e<r;)t[e]();r=u.length}i=!1}function h(e){1!==u.push(e)||i||r()}t.exports=h}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){var i=e(1);function n(){}var o={},s=["REJECTED"],a=["FULFILLED"],c=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==n&&f(this,e)}function l(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function h(e,t,r){i((function(){var i;try{i=t(r)}catch(t){return o.reject(e,t)}i===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,i)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var r=!1;function i(t){r||(r=!0,o.reject(e,t))}function n(t){r||(r=!0,o.resolve(e,t))}function s(){t(n,i)}var a=p(s);"error"===a.status&&i(a.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}function g(e){return e instanceof this?e:o.resolve(new this(n),e)}function m(e){var t=new this(n);return o.reject(t,e)}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,i=!1;if(!r)return this.resolve([]);for(var s=new Array(r),a=0,c=-1,u=new this(n);++c<r;)l(e[c],c);return u;function l(e,n){function c(e){s[n]=e,++a!==r||i||(i=!0,o.resolve(u,s))}t.resolve(e).then(c,(function(e){i||(i=!0,o.reject(u,e))}))}}function v(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,i=!1;if(!r)return this.resolve([]);for(var s=-1,a=new this(n);++s<r;)c(e[s]);return a;function c(e){t.resolve(e).then((function(e){i||(i=!0,o.resolve(a,e))}),(function(e){i||(i=!0,o.reject(a,e))}))}}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(n);return this.state!==c?h(r,this.state===a?e:t,this.outcome):this.queue.push(new l(r,e,t)),r},l.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},l.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},l.prototype.callRejected=function(e){o.reject(this.promise,e)},l.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},o.resolve=function(e,t){var r=p(d,t);if("error"===r.status)return o.reject(e,r.value);var i=r.value;if(i)f(e,i);else{e.state=a,e.outcome=t;for(var n=-1,s=e.queue.length;++n<s;)e.queue[n].callFulfilled(t)}return e},o.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,i=e.queue.length;++r<i;)e.queue[r].callRejected(t);return e},u.resolve=g,u.reject=m,u.all=y,u.race=v},{1:1}],3:[function(e,t,i){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var s=o();function a(){try{if(!s||!s.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function c(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if("TypeError"!==n.name)throw n;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)r.append(e[i]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var u=Promise;function l(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",g=void 0,m={},y=Object.prototype.toString,v="readonly",b="readwrite";function w(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),n=0;n<t;n++)i[n]=e.charCodeAt(n);return r}function k(e){return new u((function(t){var r=e.transaction(p,b),i=c([""]);r.objectStore(p).put(i,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function _(e){return"boolean"==typeof g?u.resolve(g):k(e).then((function(e){return g=e}))}function S(e){var t=m[e.name],r={};r.promise=new u((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function E(e){var t=m[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function T(e,t){var r=m[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function C(e,t){return new u((function(r,i){if(m[e.name]=m[e.name]||L(),e.db){if(!t)return r(e.db);S(e),e.db.close()}var n=[e.name];t&&n.push(e.version);var o=s.open.apply(s,n);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(p)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),i(o.error)},o.onsuccess=function(){var t=o.result;t.onversionchange=function(e){e.target.close()},r(t),E(e)}}))}function A(e){return C(e,!1)}function P(e){return C(e,!0)}function R(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,n=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),n||r){if(r){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function x(e){return new u((function(t,r){var i=new FileReader;i.onerror=r,i.onloadend=function(r){var i=btoa(r.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function I(e){return c([w(atob(e.data))],{type:e.type})}function M(e){return e&&e.__local_forage_encoded_blob}function O(e){var t=this,r=t._initReady().then((function(){var e=m[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(r,e,e),r}function B(e){S(e);for(var t=m[e.name],r=t.forages,i=0;i<r.length;i++){var n=r[i];n._dbInfo.db&&(n._dbInfo.db.close(),n._dbInfo.db=null)}return e.db=null,A(e).then((function(t){return e.db=t,R(e)?P(e):t})).then((function(i){e.db=t.db=i;for(var n=0;n<r.length;n++)r[n]._dbInfo.db=i})).catch((function(t){throw T(e,t),t}))}function N(e,t,r,i){void 0===i&&(i=1);try{var n=e.db.transaction(e.storeName,t);r(null,n)}catch(n){if(i>0&&(!e.db||"InvalidStateError"===n.name||"NotFoundError"===n.name))return u.resolve().then((function(){if(!e.db||"NotFoundError"===n.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),P(e)})).then((function(){return B(e).then((function(){N(e,t,r,i-1)}))})).catch(r);r(n)}}function L(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function D(e){var t=this,r={db:null};if(e)for(var i in e)r[i]=e[i];var n=m[r.name];n||(n=L(),m[r.name]=n),n.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=O);var o=[];function s(){return u.resolve()}for(var a=0;a<n.forages.length;a++){var c=n.forages[a];c!==t&&o.push(c._initReady().catch(s))}var l=n.forages.slice(0);return u.all(o).then((function(){return r.db=n.db,A(r)})).then((function(e){return r.db=e,R(r,t._defaultConfig.version)?P(r):e})).then((function(e){r.db=n.db=e,t._dbInfo=r;for(var i=0;i<l.length;i++){var o=l[i];o!==t&&(o._dbInfo.db=r.db,o._dbInfo.version=r.version)}}))}function U(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){N(r._dbInfo,v,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),M(e)&&(e=I(e)),t(e)},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function j(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){N(r._dbInfo,v,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).openCursor(),a=1;s.onsuccess=function(){var r=s.result;if(r){var i=r.value;M(i)&&(i=I(i));var n=e(i,r.key,a++);void 0!==n?t(n):r.continue()}else t()},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function F(e,t,r){var i=this;e=d(e);var n=new u((function(r,n){var o;i.ready().then((function(){return o=i._dbInfo,"[object Blob]"===y.call(t)?_(o.db).then((function(e){return e?t:x(t)})):t})).then((function(t){N(i._dbInfo,b,(function(o,s){if(o)return n(o);try{var a=s.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var c=a.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),r(t)},s.onabort=s.onerror=function(){var e=c.error?c.error:c.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return l(n,r),n}function V(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){N(r._dbInfo,b,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).delete(e);o.oncomplete=function(){t()},o.onerror=function(){i(s.error)},o.onabort=function(){var e=s.error?s.error:s.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function z(e){var t=this,r=new u((function(e,r){t.ready().then((function(){N(t._dbInfo,b,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).clear();n.oncomplete=function(){e()},n.onabort=n.onerror=function(){var e=o.error?o.error:o.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function q(e){var t=this,r=new u((function(e,r){t.ready().then((function(){N(t._dbInfo,v,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).count();o.onsuccess=function(){e(o.result)},o.onerror=function(){r(o.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function W(e,t){var r=this,i=new u((function(t,i){e<0?t(null):r.ready().then((function(){N(r._dbInfo,v,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName),a=!1,c=s.openKeyCursor();c.onsuccess=function(){var r=c.result;r?0===e||a?t(r.key):(a=!0,r.advance(e)):t(null)},c.onerror=function(){i(c.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function H(e){var t=this,r=new u((function(e,r){t.ready().then((function(){N(t._dbInfo,v,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];o.onsuccess=function(){var t=o.result;t?(s.push(t.key),t.continue()):e(s)},o.onerror=function(){r(o.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function K(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var i,n=this;if(e.name){var o=e.name===r.name&&n._dbInfo.db?u.resolve(n._dbInfo.db):A(e).then((function(t){var r=m[e.name],i=r.forages;r.db=t;for(var n=0;n<i.length;n++)i[n]._dbInfo.db=t;return t}));i=e.storeName?o.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;S(e);var i=m[e.name],n=i.forages;t.close();for(var o=0;o<n.length;o++){var a=n[o];a._dbInfo.db=null,a._dbInfo.version=r}var c=new u((function(t,i){var n=s.open(e.name,r);n.onerror=function(e){n.result.close(),i(e)},n.onupgradeneeded=function(){n.result.deleteObjectStore(e.storeName)},n.onsuccess=function(){var e=n.result;e.close(),t(e)}}));return c.then((function(e){i.db=e;for(var t=0;t<n.length;t++){var r=n[t];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(t){throw(T(e,t)||u.resolve()).catch((function(){})),t}))}})):o.then((function(t){S(e);var r=m[e.name],i=r.forages;t.close();for(var n=0;n<i.length;n++)i[n]._dbInfo.db=null;var o=new u((function(t,r){var i=s.deleteDatabase(e.name);i.onerror=function(){var e=i.result;e&&e.close(),r(i.error)},i.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return o.then((function(e){r.db=e;for(var t=0;t<i.length;t++)E(i[t]._dbInfo)})).catch((function(t){throw(T(e,t)||u.resolve()).catch((function(){})),t}))}))}else i=u.reject("Invalid arguments");return l(i,t),i}var $={_driver:"asyncStorage",_initStorage:D,_support:a(),iterate:j,getItem:U,setItem:F,removeItem:V,clear:z,length:q,key:W,keys:H,dropInstance:K};function G(){return"function"==typeof openDatabase}var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",Y=/^~~local_forage_type~([^~]+)~/,X="__lfsc__:",Z=X.length,ee="arbf",te="blob",re="si08",ie="ui08",ne="uic8",oe="si16",se="si32",ae="ur16",ce="ui32",ue="fl32",le="fl64",he=Z+ee.length,de=Object.prototype.toString;function fe(e){var t,r,i,n,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var u=new ArrayBuffer(s),l=new Uint8Array(u);for(t=0;t<a;t+=4)r=Q.indexOf(e[t]),i=Q.indexOf(e[t+1]),n=Q.indexOf(e[t+2]),o=Q.indexOf(e[t+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|n>>2,l[c++]=(3&n)<<6|63&o;return u}function pe(e){var t,r=new Uint8Array(e),i="";for(t=0;t<r.length;t+=3)i+=Q[r[t]>>2],i+=Q[(3&r[t])<<4|r[t+1]>>4],i+=Q[(15&r[t+1])<<2|r[t+2]>>6],i+=Q[63&r[t+2]];return r.length%3==2?i=i.substring(0,i.length-1)+"=":r.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function ge(e,t){var r="";if(e&&(r=de.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var i,n=X;e instanceof ArrayBuffer?(i=e,n+=ee):(i=e.buffer,"[object Int8Array]"===r?n+=re:"[object Uint8Array]"===r?n+=ie:"[object Uint8ClampedArray]"===r?n+=ne:"[object Int16Array]"===r?n+=oe:"[object Uint16Array]"===r?n+=ae:"[object Int32Array]"===r?n+=se:"[object Uint32Array]"===r?n+=ce:"[object Float32Array]"===r?n+=ue:"[object Float64Array]"===r?n+=le:t(new Error("Failed to get type for BinaryArray"))),t(n+pe(i))}else if("[object Blob]"===r){var o=new FileReader;o.onload=function(){var r=J+e.type+"~"+pe(this.result);t(X+te+r)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}}function me(e){if(e.substring(0,Z)!==X)return JSON.parse(e);var t,r=e.substring(he),i=e.substring(Z,he);if(i===te&&Y.test(r)){var n=r.match(Y);t=n[1],r=r.substring(n[0].length)}var o=fe(r);switch(i){case ee:return o;case te:return c([o],{type:t});case re:return new Int8Array(o);case ie:return new Uint8Array(o);case ne:return new Uint8ClampedArray(o);case oe:return new Int16Array(o);case ae:return new Uint16Array(o);case se:return new Int32Array(o);case ce:return new Uint32Array(o);case ue:return new Float32Array(o);case le:return new Float64Array(o);default:throw new Error("Unkown type: "+i)}}var ye={serialize:ge,deserialize:me,stringToBuffer:fe,bufferToString:pe};function ve(e,t,r,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,i)}function be(e){var t=this,r={db:null};if(e)for(var i in e)r[i]="string"!=typeof e[i]?e[i].toString():e[i];var n=new u((function(e,i){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return i(e)}r.db.transaction((function(n){ve(n,r,(function(){t._dbInfo=r,e()}),(function(e,t){i(t)}))}),i)}));return r.serializer=ye,n}function we(e,t,r,i,n,o){e.executeSql(r,i,n,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?o(e,s):ve(e,t,(function(){e.executeSql(r,i,n,o)}),o)}),o):o(e,s)}),o)}function ke(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT * FROM "+n.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var i=r.rows.length?r.rows.item(0).value:null;i&&(i=n.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function _e(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT * FROM "+n.storeName,[],(function(r,i){for(var o=i.rows,s=o.length,a=0;a<s;a++){var c=o.item(a),u=c.value;if(u&&(u=n.serializer.deserialize(u)),void 0!==(u=e(u,c.key,a+1)))return void t(u)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function Se(e,t,r,i){var n=this;e=d(e);var o=new u((function(o,s){n.ready().then((function(){void 0===t&&(t=null);var a=t,c=n._dbInfo;c.serializer.serialize(t,(function(t,u){u?s(u):c.db.transaction((function(r){we(r,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){o(a)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void o(Se.apply(n,[e,a,r,i-1]));s(t)}}))}))})).catch(s)}));return l(o,r),o}function Ee(e,t,r){return Se.apply(this,[e,t,r,1])}function Te(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"DELETE FROM "+n.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function Ce(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function Ae(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,r){var i=r.rows.item(0).c;e(i)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function Pe(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT key FROM "+n.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var i=r.rows.length?r.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function Re(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT key FROM "+i.storeName,[],(function(t,r){for(var i=[],n=0;n<r.rows.length;n++)i.push(r.rows.item(n).key);e(i)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function xe(e){return new u((function(t,r){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,i){for(var n=[],o=0;o<i.rows.length;o++)n.push(i.rows.item(o).name);t({db:e,storeNames:n})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}function Ie(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var i,n=this;return l(i=e.name?new u((function(t){var i;i=e.name===r.name?n._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(xe(i))})).then((function(e){return new u((function(t,r){e.db.transaction((function(i){function n(e){return new u((function(t,r){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var o=[],s=0,a=e.storeNames.length;s<a;s++)o.push(n(e.storeNames[s]));u.all(o).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):u.reject("Invalid arguments"),t),i}var Me={_driver:"webSQLStorage",_initStorage:be,_support:G(),iterate:_e,getItem:ke,setItem:Ee,removeItem:Te,clear:Ce,length:Ae,key:Pe,keys:Re,dropInstance:Ie};function Oe(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Be(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Ne(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Le(){return!Ne()||localStorage.length>0}function De(e){var t=this,r={};if(e)for(var i in e)r[i]=e[i];return r.keyPrefix=Be(e,t._defaultConfig),Le()?(t._dbInfo=r,r.serializer=ye,u.resolve()):u.reject()}function Ue(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var i=localStorage.key(r);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return l(r,e),r}function je(e,t){var r=this;e=d(e);var i=r.ready().then((function(){var t=r._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return l(i,t),i}function Fe(e,t){var r=this,i=r.ready().then((function(){for(var t=r._dbInfo,i=t.keyPrefix,n=i.length,o=localStorage.length,s=1,a=0;a<o;a++){var c=localStorage.key(a);if(0===c.indexOf(i)){var u=localStorage.getItem(c);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,c.substring(n),s++)))return u}}}));return l(i,t),i}function Ve(e,t){var r=this,i=r.ready().then((function(){var t,i=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return l(i,t),i}function ze(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,i=[],n=0;n<r;n++){var o=localStorage.key(n);0===o.indexOf(e.keyPrefix)&&i.push(o.substring(e.keyPrefix.length))}return i}));return l(r,e),r}function qe(e){var t=this.keys().then((function(e){return e.length}));return l(t,e),t}function We(e,t){var r=this;e=d(e);var i=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return l(i,t),i}function He(e,t,r){var i=this;e=d(e);var n=i.ready().then((function(){void 0===t&&(t=null);var r=t;return new u((function(n,o){var s=i._dbInfo;s.serializer.serialize(t,(function(t,i){if(i)o(i);else try{localStorage.setItem(s.keyPrefix+e,t),n(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||o(e),o(e)}}))}))}));return l(n,r),n}function Ke(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var i,n=this;return i=e.name?new u((function(t){e.storeName?t(Be(e,n._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):u.reject("Invalid arguments"),l(i,t),i}var $e={_driver:"localStorageWrapper",_initStorage:De,_support:Oe(),iterate:Fe,getItem:je,setItem:He,removeItem:We,clear:Ue,length:qe,key:Ve,keys:ze,dropInstance:Ke},Ge=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Qe=function(e,t){for(var r=e.length,i=0;i<r;){if(Ge(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ye={},Xe={},Ze={INDEXEDDB:$,WEBSQL:Me,LOCALSTORAGE:$e},et=[Ze.INDEXEDDB._driver,Ze.WEBSQL._driver,Ze.LOCALSTORAGE._driver],tt=["dropInstance"],rt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function nt(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function ot(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Je(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var st=function(){function e(t){for(var r in n(this,e),Ze)if(Ze.hasOwnProperty(r)){var i=Ze[r],o=i._driver;this[r]=o,Ye[o]||this.defineDriver(i)}this._defaultConfig=ot({},it),this._config=ot({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var i=new u((function(t,r){try{var i=e._driver,n=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(n);for(var o=rt.concat("_initStorage"),s=0,a=o.length;s<a;s++){var c=o[s];if((!Qe(tt,c)||e[c])&&"function"!=typeof e[c])return void r(n)}var h=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=u.reject(t);return l(r,arguments[arguments.length-1]),r}},r=0,i=tt.length;r<i;r++){var n=tt[r];e[n]||(e[n]=t(n))}};h();var d=function(r){Ye[i]&&console.info("Redefining LocalForage driver: "+i),Ye[i]=e,Xe[i]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,r):d(!!e._support):d(!0)}catch(e){r(e)}}));return h(i,t,r),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var i=Ye[e]?u.resolve(Ye[e]):u.reject(new Error("Driver not found."));return h(i,t,r),i},e.prototype.getSerializer=function(e){var t=u.resolve(ye);return h(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(r,e,e),r},e.prototype.setDriver=function(e,t,r){var i=this;Je(e)||(e=[e]);var n=this._getSupportedDrivers(e);function o(){i._config.driver=i.driver()}function s(e){return i._extend(e),o(),i._ready=i._initStorage(i._config),i._ready}function a(e){return function(){var t=0;function r(){for(;t<e.length;){var n=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(n).then(s).catch(r)}o();var a=new Error("No available storage method found.");return i._driverSet=u.reject(a),i._driverSet}return r()}}var c=null!==this._driverSet?this._driverSet.catch((function(){return u.resolve()})):u.resolve();return this._driverSet=c.then((function(){var e=n[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,o(),i._wrapLibraryMethodsWithReady(),i._initDriver=a(n)}))})).catch((function(){o();var e=new Error("No available storage method found.");return i._driverSet=u.reject(e),i._driverSet})),h(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!Xe[e]},e.prototype._extend=function(e){ot(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,i=e.length;r<i;r++){var n=e[r];this.supports(n)&&t.push(n)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=rt.length;e<t;e++)nt(this,rt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),at=new st;t.exports=at},{3:3}]},{},[4])(4)},5602:e=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},7363:(e,t,r)=>{var i=r(5020),n=r(3804);r(5602),t.M9=n,t.qg=i.parse,i.parseParams,i.parseFmtpConfig,i.parsePayloads,i.parseRemoteCandidates,i.parseImageAttributes,i.parseSimulcastStreamList},5020:(e,t,r)=>{var i=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,r){var n=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:n&&!t[e.name]&&(t[e.name]={});var o=e.push?{}:n?t[e.name]:t;!function(e,t,r,n){if(n&&!r)t[n]=i(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(t[r[o]]=i(e[o+1]))}(r.match(e.reg),o,e.names,e.name),e.push&&t[e.push].push(o)},o=r(5602),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},r=[],i=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach((function(e){var t=e[0],s=e.slice(2);"m"===t&&(r.push({rtp:[],fmtp:[]}),i=r[r.length-1]);for(var a=0;a<(o[t]||[]).length;a+=1){var c=o[t][a];if(c.reg.test(s))return n(c,i,s)}})),t.media=r,t};var a=function(e,t){var r=t.split(/=(.+)/,2);return 2===r.length?e[r[0]]=i(r[1]):1===r.length&&t.length>1&&(e[r[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],r=e.split(" ").map(i),n=0;n<r.length;n+=3)t.push({component:r[n],ip:r[n+1],port:r[n+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,r=!1;return"~"!==e[0]?t=i(e):(t=i(e.substring(1,e.length)),r=!0),{scid:t,paused:r}}))}))}},3804:(e,t,r)=>{var i=r(5602),n=/%[sdv%]/g,o=function(e){var t=1,r=arguments,i=r.length;return e.replace(n,(function(e){if(t>=i)return e;var n=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(n);case"%d":return Number(n);case"%v":return""}}))},s=function(e,t,r){var i=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var s=t.names[n];t.name?i.push(r[t.name][s]):i.push(r[t.names[n]])}else i.push(r[t.name]);return o.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,n=t.innerOrder||c,o=[];return r.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(s(t,r,e))}))}))})),e.media.forEach((function(e){o.push(s("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(s(t,r,e))}))}))}))})),o.join("\r\n")+"\r\n"}},5653:()=>{},8535:()=>{},9546:()=>{},2472:()=>{},477:()=>{},5995:()=>{},6351:e=>{e.exports={version:"0.6.3"}}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var i={};r.d(i,{He:()=>ur,L0:()=>z,Yk:()=>ni,c3:()=>ti,Mz:()=>lr,Ne:()=>j,_N:()=>fr,bq:()=>q,hj:()=>o,h4:()=>c,xk:()=>a,J:()=>Kr,a7:()=>Yr,tg:()=>di,s_:()=>Qr,VO:()=>Gr,VF:()=>Xr,M0:()=>Jr,$b:()=>Z,WI:()=>X,cp:()=>ri,PN:()=>qr,ez:()=>Ar,EQ:()=>Cr,$t:()=>xr,jL:()=>yi,Ps:()=>si,VV:()=>oi,_b:()=>U,dT:()=>Jt,CM:()=>F,Zq:()=>Er});class n{static CHANNEL_UPDATE="channel_update";static JOIN_SUCCEED="join_succeed";static ME_UPDATE="me_update";static RECONNECTING="reconnecting";static RECONNECTED="reconnected";static DISCONNECTED="disconnected";static USER_JOIN="user_join";static USER_UPDATE="user_update";static USER_LEAVE="user_leave";static USER_TRACK_ADD="user_track_add";static USER_TRACK_UPDATE="user_track_update";static USER_TRACK_REMOVE="user_track_remove";static CUSTOM_MSG="custom_msg";static TRACK_MUTED="track_muted";static TRACK_UNMUTED="track_unmuted";static TRACK_ENDED="track_ended"}let o=function(e){return e[e.Error=-1]="Error",e[e.Self=1]="Self",e[e.Kicked=2]="Kicked",e[e.Replace=3]="Replace",e[e.Timeout=4]="Timeout",e[e.Destroy=5]="Destroy",e}({});class s{static INFO_UPDATE="info_update";static MUTED="muted";static UNMUTED="unmuted";static ENDED="ended"}class a{static ENABLE_SUCCEED="enable_succeed";static RECONNECTING="reconnecting";static RECONNECTED="reconnected";static DISCONNECTED="disconnected";static IM_MSG="im_msg"}let c=function(e){return e[e.Error=-1]="Error",e[e.Self=1]="Self",e[e.Kicked=2]="Kicked",e[e.Timeout=4]="Timeout",e}({});var u=r(7007),l=r.n(u),h=r(1396),d=r(955),f=r.n(d);function p(){return"undefined"!=typeof uni&&"mp-weixin"===uni.getSystemInfoSync().uniPlatform||"undefined"==typeof uni&&"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfo}function g(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function m(e){return Object.keys(e).filter((t=>null!==e[t]&&void 0!==e[t])).reduce(((t,r)=>({...t,[r]:e[r]})),{})}function y(e){return"string"==typeof e}function v(){}class b{m_lastPromise=Promise.resolve();async lock(e=!1){let t=v;if(e)return t;const r=this.m_lastPromise;return this.m_lastPromise=new Promise((e=>t=e)),await r,t}}async function w(e){return new Promise((t=>{setTimeout(t,e)}))}function k(e,t){let r=!1;t={maxRetries:10,initialDelay:500,...t};let i=()=>new Promise(((i,n)=>{let o=0,s=async a=>{if(r)n("canceled");else try{if(o>0){if(t?.onRetry&&!1===t.onRetry(o,a))return void n(a);let e=Math.pow(2,o-1)*t.initialDelay;await w(e)}let r=await e();i(r)}catch(e){t.maxRetries>0&&o>=t.maxRetries?n("maxretry"):(o++,s(e))}};s()}));return i.cancel=()=>{r=!0},i}function _(e,t,r){let i=[];var n;return(n=t,Object.getOwnPropertyNames(n)).forEach((n=>{let o=!0;g(e[n])?JSON.stringify(e[n])!==JSON.stringify(t[n])&&(o=!1):e[n]!==t[n]&&(o=!1),o||(i.push({prop:n,value:t[n],old:e[n]}),r&&r[n]?r[n](t[n],e[n]):e[n]=t[n])})),i}function S(e,t=new Date){for(var r="",i=t.getMonth(),n=i+1,o=t.getDay(),s=t.getDate(),a=t.getFullYear(),c=t.getHours(),u=t.getMinutes(),l=t.getSeconds(),h=0,d=e.length;h<d;h++)switch(e[h]){case"j":r+=s;break;case"d":r+=s<10?"0"+s:s;break;case"l":var f=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");r+=f[o];break;case"w":r+=o;break;case"D":r+=(f=Array("Sun","Mon","Tue","Wed","Thr","Fri","Sat"))[o];break;case"m":r+=n<10?"0"+n:n;break;case"n":r+=n;break;case"F":var p=Array("January","February","March","April","May","June","July","August","September","October","November","December");r+=p[i];break;case"M":r+=(p=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"))[i];break;case"Y":r+=a;break;case"y":r+=a.toString().slice(-2);break;case"H":r+=c<10?"0"+c:c;break;case"g":var g=0===c?12:c;r+=g>12?g-12:g;break;case"h":r+=(g=(g=0===c?12:c)>12?g-12:g)<10?"0"+g:g;break;case"a":r+=c<12?"am":"pm";break;case"i":r+=u<10?"0"+u:u;break;case"s":r+=l<10?"0"+l:l;break;case"c":r+=t.toISOString();break;default:r+=e[h]}return r}function E(e,t){if(t<0)throw new Error("小数位数必须是非负整数");const r=Math.pow(10,t);return Math.round(e*r)/r}function T(e=18){e=e||32;let t="ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz1234567890",r="";for(let i=0;i<e;i++)r+=t.charAt(Math.floor(61*Math.random()));return r}function C(e){const t=e.match(/^(?:.+?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im);return t&&t[1]?t[1]:""}function A(e){return JSON.parse(f().decrypt(e,h.enc.Utf8.parse("6o30j79YRE39bEwI"),{iv:h.enc.Utf8.parse("2apW3WiFl72ZVS3x"),padding:h.pad.Pkcs7,mode:h.mode.CBC}).toString(h.enc.Utf8))}function P(e){return e<=0?-60:Math.max(-60,Math.round(20*Math.log10(e)))}class R{code;msg;prefixCode(){return p()?"107":"106"}constructor(e,t=0){this.msg=e,this.code=t<1e3?Number(this.prefixCode()+String(t).padStart(3,"0")):t}static fromError(e){return new R(e.name+":"+e.message)}toString(){return`${this.code}: ${this.msg}`}toJSON(){return{code:this.code,msg:this.msg}}}const x=new R("您不在频道内",1),I=new R("token已过期",2),M=function(e){return new R(e||"流轨道不存在",3)},O=new Set([1033,1034,1035]);const B="__amixer__",N="__amcu__",L="__mcu__",D="__mcu__";let U=function(e){return e.Video="video",e.Audio="audio",e}({}),j=function(e){return e[e.H264=27]="H264",e[e.H265=36]="H265",e[e.AAC=15]="AAC",e[e.VP8=56]="VP8",e[e.VP9=57]="VP9",e[e.AV1=58]="AV1",e[e.OPUS=1398100047]="OPUS",e}({});function F(e){for(const[t,r]of Object.entries(j))if(r===e)return t;return""}class V{publishers=new Set;defaultPublishOptions;constructor(e){this.track=e}retain(e){this.publishers.add(e)}release(e){this.publishers.delete(e)}get count(){return this.publishers.size}soleRecord(){if(1===this.publishers.size)return this.publishers.values().next().value.getPublishRecord(this.track)}resolveInfo(){if(this.publishers.size>1)throw new R(`该轨道已发布到 ${this.publishers.size} 个频道,各频道的轨道描述不同,请改用 channel.getPublishInfo(track) 查询指定频道内的描述`);let e=this.soleRecord();if(!e)return;let t={...e.info};return t.props={...t.props},t}}class z extends(l()){info;uid;prevStats;constructor(e,t){super(),this.info=e,this.uid=t}getRawInfo(){let e={...this.info};return e.props={...e.props},e}get id(){return this.info.id}get kind(){return this.info.kind}get desc(){return this.info.desc}get variant(){return this.info.variant}get angle(){return this.info.angle}getInfo(){return this.getRawInfo()}updateInfo(e){let t=_(this.info,e);return t.length>0&&this.emit(s.INFO_UPDATE,this),t}getUid(){return this.uid}strPrefix(){return"流轨道"}toString(){const e=[this.uid?`uid:${this.uid}`:null,this.info.desc?`desc:${this.info.desc}`:null,this.id?`id:${this.info.id}`:null].filter(Boolean);return this.strPrefix()+"["+e.join("; ")+"]"}}let q=function(e){return e[e.Unknown=0]="Unknown",e[e.Windows=1]="Windows",e[e.Android=2]="Android",e[e.IOS=3]="IOS",e[e.Linux=4]="Linux",e[e.MacOS=5]="MacOS",e[e.WebRTC=6]="WebRTC",e[e.XCX=7]="XCX",e}({});var W=r(3790),H=r.n(W);let K={keyPrefix:"",_driver:"localForageWxDriver",_initStorage:function(e){this.keyPrefix=e.name+"/"+e.storeName+"/"},_support:!!p(),getItem:function(e,t){return new Promise(((t,r)=>{try{t(wx.getStorageSync(this.keyPrefix+e))}catch(e){r(e)}}))},setItem:function(e,t,r){return new Promise(((r,i)=>{try{wx.setStorageSync(this.keyPrefix+e,t),r(t)}catch(e){i(e)}}))},removeItem:function(e,t){return new Promise(((t,r)=>{try{wx.removeStorageSync(this.keyPrefix+e),t()}catch(e){r(e)}}))},clear:async function(e){const t=(await this.keys()).map((e=>this.removeItem(e)));await Promise.all(t)},length:async function(e){return(await this.keys()).length},key:async function(e,t){return(await this.keys())[e]},keys:function(e){return new Promise(((e,t)=>{try{var r=this.keyPrefix.length;const t=wx.getStorageInfoSync();let n=[];for(let e=0;e<t.keys.length;e++){var i=t.keys[e];i.startsWith(this.keyPrefix)&&n.push(i.substring(r))}e(n)}catch(e){t(e)}}))},iterate:async function(e,t){const r=await this.keys();let i=1;for(var n=0;n<r.length;n++){const t=r[n];let o=e(await this.getItem(t),t,i++);if(void 0!==o)return o}},dropInstance:function(e,t){return this.clear()}},$=function(e){return e[e.Undefined=0]="Undefined",e[e.Trace=1]="Trace",e[e.Debug=5]="Debug",e[e.Info=9]="Info",e[e.Warn=13]="Warn",e[e.Error=17]="Error",e[e.FATAL=21]="FATAL",e}({}),G=function(e){return e.AppStart="app.start",e.AppResource="app.resource",e.AppNetwork="app.network",e.RtcEvtAudioInput="rtc.event.audioinput",e.RtcEvtAudioOutput="rtc.event.audiooutput",e.RtcEvtVideoInput="rtc.event.videoinput",e.RtcEvtVideoOutput="rtc.event.videooutput",e.RtcEvtRemoteStream="rtc.event.remotestream",e.RtcEvtConnection="rtc.event.connection",e.RtcMqtt="rtc.mqtt",e.RtcRequest="rtc.request",e.RtcOok="rtc.ook",e.RtcMarker="rtc.marker",e.RtcLog="rtc.log",e.AppLog="app.log",e}({});var Q=function(e){return e[e.Log=0]="Log",e[e.Metric=1]="Metric",e}(Q||{});class J{enabled;token;deviceID;deviceType;api;storage;workTimer;isWorking=!1;keyIdx=0;startTime=Date.now();constructor(e,t,r,i){if(this.enabled=i,this.token=e,this.deviceID=t,this.deviceType=r,this.api=new Y(e.app_id,e.log_center,t,r,"vaZ7MQ45m0KRjJ2u"),!i)return;r==q.XCX&&H().defineDriver(K);let n=e.app_id+":"+e.uid+":"+("channel"in e?e.channel:"im");r==q.XCX?this.storage=H().createInstance({name:"rtcsdk",storeName:n,driver:K._driver}):this.storage=H().createInstance({name:"rtcsdk",storeName:n}),this.storage.ready().then((()=>{console.debug("localforage initialized",this.storage.driver()),this.work()})).catch((e=>{console.debug("localforage initialize error",e),this.storage=void 0})),this.workTimer=setInterval((()=>{this.work()}),6e4)}flush(){this.work()}shutdown(){clearInterval(this.workTimer)}async work(){if(this.enabled&&!this.isWorking){this.isWorking=!0;try{await this.upload()}catch(e){console.error("rtc日志上传报错",e)}finally{this.isWorking=!1}}}makeKey(e){let t=[e==Q.Log?"log":"metric",this.startTime,this.keyIdx].join("_");return this.keyIdx++,t}async appendToStorage(e,t){if(!this.storage)return;let r=this.makeKey(e);await this.storage.setItem(r,t);let i=await this.storage.keys();if(i.length>=5e3){i.sort(((e,t)=>{let r=parseFloat(e.split("_").slice(1).join(".")),i=parseFloat(t.split("_").slice(1).join("."));return r<i?-1:r>i?1:0}));const e=i.slice(0,1e3).map((e=>this.storage.removeItem(e)));await Promise.all(e)}}async peekFromStorage(){if(!this.storage)return[];let e=await this.storage.keys();e.sort(((e,t)=>{let r=parseFloat(e.split("_").slice(1).join(".")),i=parseFloat(t.split("_").slice(1).join("."));return r<i?-1:r>i?1:0})),console.debug("rtclog storage count="+e.length);let t=[];for(let r=0;r<e.length;r++){let i=e[r],n={type:Q.Log,key:i,content:void 0};if(i.startsWith("log_"))n.type=Q.Log;else{if(!i.startsWith("metric_"))continue;n.type=Q.Metric}if(n.content=await this.storage.getItem(i),n.content&&n.content.body&&Array.isArray(n.content.body)&&(n.content.body=JSON.stringify(n.content.body)),t.push(n),t.length>=500)break}return t}async removeStorage(e){if(!this.storage)return;const t=e.map((e=>this.storage.removeItem(e.key)));await Promise.all(t)}async upload(){let e=await this.peekFromStorage();if(0==e.length)return;let t={device_id:this.deviceID,device_type:this.deviceType,app_id:this.token.app_id,uid:this.token.uid,logs:[],metrics:[]};for(let r=0;r<e.length;r++){let i=e[r];i.type==Q.Log?t.logs.push(i.content):i.type==Q.Metric&&t.metrics.push(i.content)}await this.api.push(t),await this.removeStorage(e)}async addLog({body:e,level:t=$.Undefined,type:r=G.AppLog}){if(!this.enabled)return;let i={time:Date.now(),type:r,serverity:t,channel:"channel"in this.token?this.token.channel:void 0,attr:g(e)?JSON.parse(JSON.stringify(e)):{},body:g(e)?"":y(e)?e:JSON.stringify(e)};return await this.appendToStorage(Q.Log,i)}async addMetric(e){if(this.enabled)return e.time=Date.now(),e.channel="channel"in this.token?this.token.channel:void 0,await this.appendToStorage(Q.Metric,JSON.parse(JSON.stringify(e)))}}class Y{appID;serverPrefix;deviceID;deviceType;logSecretKey;logToken;constructor(e,t,r,i,n){this.appID=e,"/"!==t.substring(t.length-1)&&(t+="/"),t+="v1/",this.serverPrefix=t,this.deviceID=r,this.deviceType=i,this.logSecretKey=n}async refreshToken(){let e={app_id:this.appID,device_id:this.deviceID,device_type:this.deviceType,requested_at:Date.now()};e.sign=this.signutreRequest(e);let t=await this.request("auth/gettoken",e);if(0!=t.code)throw new R("获取rtc日志中心token失败: "+t.msg,t.code);this.logToken=t.data.token}async push(e){this.logToken||await this.refreshToken();let t=await this.request("data/push",e);if(10041==t.code||10042==t.code||10043==t.code)return this.logToken="",this.push(e);if(0!=t.code)throw new R(t.msg,t.code);console.debug("上传rtc日志成功")}signutreRequest(e){let t,r=[];for(t in e)r.push(t+"="+e[t]);r.sort();let i=r.join("&")+"&"+this.logSecretKey;return(0,h.SHA256)(i).toString()}request(e,t){let r=this.serverPrefix+e,i={"Content-Type":"application/json;charset=UTF-8"};return this.logToken&&(i.Authorization="Bearer "+this.logToken),this.deviceType==q.XCX?new Promise(((e,n)=>{wx.request({url:r,method:"POST",header:i,data:JSON.stringify(t),success(t){if(200!=t.statusCode)n(new Error(t.statusCode+":"+t.errMsg));else{let r=t.data;e(r)}},fail:function(e){n(new Error(e.errMsg))}})})):new Promise(((e,n)=>{fetch(r,{method:"POST",headers:i,body:JSON.stringify(t)}).then((t=>{200!=t.status?n(new Error(t.status+":"+t.statusText)):t.json().then((t=>{e(t)})).catch((e=>{n(e)}))})).catch((e=>{n(e)}))}))}}let X=function(e){return e.CONSOLE="console",e.WXREALTIME="wxrealtime",e.NONE="none",e}({}),Z=function(e){return e.DEBUG="debug",e.INFO="info",e.WARN="warn",e.ERROR="error",e}({}),ee=X.CONSOLE,te=Z.INFO;class re{center;dftPrefix;dftCenterLogType;constructor(e="rtc",t=G.RtcLog){this.dftPrefix=e,this.dftCenterLogType=t}setTarget(e){ee=e}setLevel(e){te=e}get logTarget(){return ee}get logLevel(){return te}logCss="border: 1px solid; padding:2px 5px; border-radius: 3px";getPrefix(e){return`%c ${S("H:i:s")} ${this.dftPrefix}_${e}`}debug(...e){if(this.logTarget!=X.NONE&&(this.snapshotArgs(e),p()&&wx.getLogManager({level:1}).debug(this.dftPrefix+"_debug",...e),this.center?.addLog({level:$.Debug,type:this.dftCenterLogType,body:e}),this.logLevel===Z.DEBUG))switch(this.logTarget){case X.CONSOLE:return console.debug(this.getPrefix("debug"),this.logCss,...e);case X.WXREALTIME:return wx.getRealtimeLogManager().info(this.dftPrefix+"_debug",...e)}}info(...e){if(this.logTarget!=X.NONE&&(this.snapshotArgs(e),p()&&wx.getLogManager({level:1}).info(this.dftPrefix+"_info",...e),this.center?.addLog({level:$.Info,type:this.dftCenterLogType,body:e}),this.logLevel===Z.DEBUG||this.logLevel===Z.INFO))switch(this.logTarget){case X.CONSOLE:return console.log(this.getPrefix("info"),this.logCss,...e);case X.WXREALTIME:return wx.getRealtimeLogManager().info(this.dftPrefix+"_info",...e)}}warn(...e){if(this.logTarget!=X.NONE&&(this.snapshotArgs(e),p()&&wx.getLogManager({level:1}).warn(this.dftPrefix+"_warn",...e),this.center?.addLog({level:$.Warn,type:this.dftCenterLogType,body:e}),this.logLevel===Z.DEBUG||this.logLevel===Z.INFO||this.logLevel===Z.WARN))switch(this.logTarget){case X.CONSOLE:return console.warn(this.getPrefix("warn"),this.logCss,...e);case X.WXREALTIME:return wx.getRealtimeLogManager().warn(this.dftPrefix+"_warn",...e)}}error(...e){if(this.logTarget!=X.NONE)switch(this.snapshotArgs(e),p()&&wx.getLogManager({level:1}).warn(this.dftPrefix+"_error",...e),console.error(this.getPrefix("error"),this.logCss,...e),this.center?.addLog({level:$.Error,type:this.dftCenterLogType,body:e}),this.logTarget){case X.CONSOLE:return;case X.WXREALTIME:return wx.getRealtimeLogManager().error(this.dftPrefix+"_error",...e)}}snapshotArgs(e){e.forEach(((t,r)=>{g(t)&&(t instanceof Error?e[r]=t.toString():e[r]=JSON.parse(JSON.stringify(t)))}))}}let ie=new re,ne=function(e){return e.UserJoin="user_join",e.UserUpdate="user_update",e.UserLeave="user_leave",e.StreamUpdate="stream_update",e.ChannelUpdate="channel_update",e.ChannelDestroy="channel_destroy",e.Custom="custom",e.ImMsg="im_msg",e.ImDisconnect="im_disconnect",e}({});var oe,se,ae,ce=r(7594),ue=r.n(ce),le=r(5995).Buffer;try{oe=new TextDecoder}catch(e){}var he=0;const de=[];var fe,pe,ge,me,ye,ve=de,be=0,we={},ke=0,_e=0,Se=[],Ee={useRecords:!1,mapsAsObjects:!0};class Te{}const Ce=new Te;Ce.name="MessagePack 0xC1";var Ae,Pe,Re,xe=!1,Ie=2;try{new Function("")}catch(e){Ie=1/0}class Me{constructor(e){e&&(!1===e.useRecords&&void 0===e.mapsAsObjects&&(e.mapsAsObjects=!0),e.sequential&&!1!==e.trusted&&(e.trusted=!0,e.structures||0==e.useRecords||(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(se)return at((()=>(ct(),this?this.unpack(e,t):Me.prototype.unpack.call(Ee,e,t))));e.buffer||e.constructor!==ArrayBuffer||(e=void 0!==le?le.from(e):new Uint8Array(e)),"object"==typeof t?(ae=t.end||e.length,he=t.start||0):(he=0,ae=t>-1?t:e.length),be=0,_e=0,pe=null,ve=de,ge=null,se=e;try{ye=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){if(se=null,e instanceof Uint8Array)throw t;throw new Error("Source must be a Uint8Array or Buffer but was a "+(e&&"object"==typeof e?e.constructor.name:typeof e))}if(this instanceof Me){if(we=this,this.structures)return fe=this.structures,Oe(t);(!fe||fe.length>0)&&(fe=[])}else we=Ee,(!fe||fe.length>0)&&(fe=[]);return Oe(t)}unpackMultiple(e,t){let r,i=0;try{xe=!0;let n=e.length,o=this?this.unpack(e,n):lt.unpack(e,n);if(!t){for(r=[o];he<n;)i=he,r.push(Oe());return r}if(!1===t(o,i,he))return;for(;he<n;)if(i=he,!1===t(Oe(),i,he))return}catch(e){throw e.lastPosition=i,e.values=r,e}finally{xe=!1,ct()}}_mergeStructures(e,t){Pe&&(e=Pe.call(this,e)),e=e||[],Object.isFrozen(e)&&(e=e.map((e=>e.slice(0))));for(let t=0,r=e.length;t<r;t++){let r=e[t];r&&(r.isShared=!0,t>=32&&(r.highByte=t-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let i=e[r],n=t[r];n&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[r]=i),e[r]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function Oe(e){try{if(!we.trusted&&!xe){let e=fe.sharedLength||0;e<fe.length&&(fe.length=e)}let t;if(we.randomAccessStructure&&se[he]<64&&se[he]>=32&&Ae?(t=Ae(se,he,ae,we),se=null,e&&e.lazy||!t||(t=t.toJSON()),he=ae):t=Ne(),ge&&(he=ge.postBundlePosition,ge=null),xe&&(fe.restoreStructures=null),he==ae)fe&&fe.restoreStructures&&Be(),fe=null,se=null,me&&(me=null);else{if(he>ae)throw new Error("Unexpected end of MessagePack data");if(!xe){let e;try{e=JSON.stringify(t,((e,t)=>"bigint"==typeof t?`${t}n`:t)).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(e){throw fe&&fe.restoreStructures&&Be(),ct(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||he>ae)&&(e.incomplete=!0),e}}function Be(){for(let e in fe.restoreStructures)fe[e]=fe.restoreStructures[e];fe.restoreStructures=null}function Ne(){let e=se[he++];if(e<160){if(e<128){if(e<64)return e;{let t=fe[63&e]||we.getStructures&&je()[63&e];return t?(t.read||(t.read=De(t,63&e)),t.read()):e}}if(e<144){if(e-=128,we.mapsAsObjects){let t={};for(let r=0;r<e;r++){let e=et();"__proto__"===e&&(e="__proto_"),t[e]=Ne()}return t}{let t=new Map;for(let r=0;r<e;r++)t.set(Ne(),Ne());return t}}{e-=144;let t=new Array(e);for(let r=0;r<e;r++)t[r]=Ne();return we.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(_e>=he)return pe.slice(he-ke,(he+=t)-ke);if(0==_e&&ae<140){let e=t<16?Qe(t):Ge(t);if(null!=e)return e}return Fe(t)}{let t;switch(e){case 192:return null;case 193:return ge?(t=Ne(),t>0?ge[1].slice(ge.position1,ge.position1+=t):ge[0].slice(ge.position0,ge.position0-=t)):Ce;case 194:return!1;case 195:return!0;case 196:if(t=se[he++],void 0===t)throw new Error("Unexpected end of buffer");return Ye(t);case 197:return t=ye.getUint16(he),he+=2,Ye(t);case 198:return t=ye.getUint32(he),he+=4,Ye(t);case 199:return Xe(se[he++]);case 200:return t=ye.getUint16(he),he+=2,Xe(t);case 201:return t=ye.getUint32(he),he+=4,Xe(t);case 202:if(t=ye.getFloat32(he),we.useFloat32>2){let e=ut[(127&se[he])<<1|se[he+1]>>7];return he+=4,(e*t+(t>0?.5:-.5)|0)/e}return he+=4,t;case 203:return t=ye.getFloat64(he),he+=8,t;case 204:return se[he++];case 205:return t=ye.getUint16(he),he+=2,t;case 206:return t=ye.getUint32(he),he+=4,t;case 207:return"number"===we.int64AsType?(t=4294967296*ye.getUint32(he),t+=ye.getUint32(he+4)):"string"===we.int64AsType?t=ye.getBigUint64(he).toString():"auto"===we.int64AsType?(t=ye.getBigUint64(he),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ye.getBigUint64(he),he+=8,t;case 208:return ye.getInt8(he++);case 209:return t=ye.getInt16(he),he+=2,t;case 210:return t=ye.getInt32(he),he+=4,t;case 211:return"number"===we.int64AsType?(t=4294967296*ye.getInt32(he),t+=ye.getUint32(he+4)):"string"===we.int64AsType?t=ye.getBigInt64(he).toString():"auto"===we.int64AsType?(t=ye.getBigInt64(he),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ye.getBigInt64(he),he+=8,t;case 212:if(t=se[he++],114==t)return rt(63&se[he++]);{let e=Se[t];if(e)return e.read?(he++,e.read(Ne())):e.noBuffer?(he++,e()):e(se.subarray(he,++he));throw new Error("Unknown extension "+t)}case 213:return t=se[he],114==t?(he++,rt(63&se[he++],se[he++])):Xe(2);case 214:return Xe(4);case 215:return Xe(8);case 216:return Xe(16);case 217:return t=se[he++],_e>=he?pe.slice(he-ke,(he+=t)-ke):Ve(t);case 218:return t=ye.getUint16(he),_e>=(he+=2)?pe.slice(he-ke,(he+=t)-ke):ze(t);case 219:return t=ye.getUint32(he),_e>=(he+=4)?pe.slice(he-ke,(he+=t)-ke):qe(t);case 220:return t=ye.getUint16(he),he+=2,He(t);case 221:return t=ye.getUint32(he),he+=4,He(t);case 222:return t=ye.getUint16(he),he+=2,Ke(t);case 223:return t=ye.getUint32(he),he+=4,Ke(t);default:if(e>=224)return e-256;if(void 0===e){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+e)}}}const Le=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function De(e,t){function r(){if(r.count++>Ie){let r=e.read=new Function("r","return function(){return "+(we.freezeData?"Object.freeze":"")+"({"+e.map((e=>"__proto__"===e?"__proto_:r()":Le.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()")).join(",")+"})}")(Ne);return 0===e.highByte&&(e.read=Ue(t,e.read)),r()}let i={};for(let t=0,r=e.length;t<r;t++){let r=e[t];"__proto__"===r&&(r="__proto_"),i[r]=Ne()}return we.freezeData?Object.freeze(i):i}return r.count=0,0===e.highByte?Ue(t,r):r}const Ue=(e,t)=>function(){let r=se[he++];if(0===r)return t();let i=e<32?-(e+(r<<5)):e+(r<<5),n=fe[i]||je()[i];if(!n)throw new Error("Record id is not defined for "+i);return n.read||(n.read=De(n,e)),n.read()};function je(){let e=at((()=>(se=null,we.getStructures())));return fe=we._mergeStructures(e,fe)}var Fe=We,Ve=We,ze=We,qe=We;function We(e){let t;if(e<16&&(t=Qe(e)))return t;if(e>64&&oe)return oe.decode(se.subarray(he,he+=e));const r=he+e,i=[];for(t="";he<r;){const e=se[he++];if(128&e)if(192==(224&e)){const t=63&se[he++];i.push((31&e)<<6|t)}else if(224==(240&e)){const t=63&se[he++],r=63&se[he++];i.push((31&e)<<12|t<<6|r)}else if(240==(248&e)){let t=(7&e)<<18|(63&se[he++])<<12|(63&se[he++])<<6|63&se[he++];t>65535&&(t-=65536,i.push(t>>>10&1023|55296),t=56320|1023&t),i.push(t)}else i.push(e);else i.push(e);i.length>=4096&&(t+=$e.apply(String,i),i.length=0)}return i.length>0&&(t+=$e.apply(String,i)),t}function He(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=Ne();return we.freezeData?Object.freeze(t):t}function Ke(e){if(we.mapsAsObjects){let t={};for(let r=0;r<e;r++){let e=et();"__proto__"===e&&(e="__proto_"),t[e]=Ne()}return t}{let t=new Map;for(let r=0;r<e;r++)t.set(Ne(),Ne());return t}}var $e=String.fromCharCode;function Ge(e){let t=he,r=new Array(e);for(let i=0;i<e;i++){const e=se[he++];if((128&e)>0)return void(he=t);r[i]=e}return $e.apply(String,r)}function Qe(e){if(e<4){if(e<2){if(0===e)return"";{let e=se[he++];return(128&e)>1?void(he-=1):$e(e)}}{let t=se[he++],r=se[he++];if((128&t)>0||(128&r)>0)return void(he-=2);if(e<3)return $e(t,r);let i=se[he++];return(128&i)>0?void(he-=3):$e(t,r,i)}}{let t=se[he++],r=se[he++],i=se[he++],n=se[he++];if((128&t)>0||(128&r)>0||(128&i)>0||(128&n)>0)return void(he-=4);if(e<6){if(4===e)return $e(t,r,i,n);{let e=se[he++];return(128&e)>0?void(he-=5):$e(t,r,i,n,e)}}if(e<8){let o=se[he++],s=se[he++];if((128&o)>0||(128&s)>0)return void(he-=6);if(e<7)return $e(t,r,i,n,o,s);let a=se[he++];return(128&a)>0?void(he-=7):$e(t,r,i,n,o,s,a)}{let o=se[he++],s=se[he++],a=se[he++],c=se[he++];if((128&o)>0||(128&s)>0||(128&a)>0||(128&c)>0)return void(he-=8);if(e<10){if(8===e)return $e(t,r,i,n,o,s,a,c);{let e=se[he++];return(128&e)>0?void(he-=9):$e(t,r,i,n,o,s,a,c,e)}}if(e<12){let u=se[he++],l=se[he++];if((128&u)>0||(128&l)>0)return void(he-=10);if(e<11)return $e(t,r,i,n,o,s,a,c,u,l);let h=se[he++];return(128&h)>0?void(he-=11):$e(t,r,i,n,o,s,a,c,u,l,h)}{let u=se[he++],l=se[he++],h=se[he++],d=se[he++];if((128&u)>0||(128&l)>0||(128&h)>0||(128&d)>0)return void(he-=12);if(e<14){if(12===e)return $e(t,r,i,n,o,s,a,c,u,l,h,d);{let e=se[he++];return(128&e)>0?void(he-=13):$e(t,r,i,n,o,s,a,c,u,l,h,d,e)}}{let f=se[he++],p=se[he++];if((128&f)>0||(128&p)>0)return void(he-=14);if(e<15)return $e(t,r,i,n,o,s,a,c,u,l,h,d,f,p);let g=se[he++];return(128&g)>0?void(he-=15):$e(t,r,i,n,o,s,a,c,u,l,h,d,f,p,g)}}}}}function Je(){let e,t=se[he++];if(t<192)e=t-160;else switch(t){case 217:e=se[he++];break;case 218:e=ye.getUint16(he),he+=2;break;case 219:e=ye.getUint32(he),he+=4;break;default:throw new Error("Expected string")}return We(e)}function Ye(e){return we.copyBuffers?Uint8Array.prototype.slice.call(se,he,he+=e):se.subarray(he,he+=e)}function Xe(e){let t=se[he++];if(Se[t]){let r;return Se[t](se.subarray(he,r=he+=e),(e=>{he=e;try{return Ne()}finally{he=r}}))}throw new Error("Unknown extension type "+t)}var Ze=new Array(4096);function et(){let e=se[he++];if(!(e>=160&&e<192))return he--,tt(Ne());if(e-=160,_e>=he)return pe.slice(he-ke,(he+=e)-ke);if(!(0==_e&&ae<180))return Fe(e);let t,r=4095&(e<<5^(e>1?ye.getUint16(he):e>0?se[he]:0)),i=Ze[r],n=he,o=he+e-3,s=0;if(i&&i.bytes==e){for(;n<o;){if(t=ye.getUint32(n),t!=i[s++]){n=1879048192;break}n+=4}for(o+=3;n<o;)if(t=se[n++],t!=i[s++]){n=1879048192;break}if(n===o)return he=n,i.string;o-=3,n=he}for(i=[],Ze[r]=i,i.bytes=e;n<o;)t=ye.getUint32(n),i.push(t),n+=4;for(o+=3;n<o;)t=se[n++],i.push(t);let a=e<16?Qe(e):Ge(e);return i.string=null!=a?a:Fe(e)}function tt(e){if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return e.toString();if(null==e)return e+"";throw new Error("Invalid property type for record",typeof e)}const rt=(e,t)=>{let r=Ne().map(tt),i=e;void 0!==t&&(e=e<32?-((t<<5)+e):(t<<5)+e,r.highByte=t);let n=fe[e];return n&&(n.isShared||xe)&&((fe.restoreStructures||(fe.restoreStructures=[]))[e]=n),fe[e]=r,r.read=De(r,i),r.read()};Se[0]=()=>{},Se[0].noBuffer=!0,Se[66]=e=>{let t=e.length,r=BigInt(128&e[0]?e[0]-256:e[0]);for(let i=1;i<t;i++)r<<=8n,r+=BigInt(e[i]);return r};let it={Error,TypeError,ReferenceError};Se[101]=()=>{let e=Ne();return(it[e[0]]||Error)(e[1],{cause:e[2]})},Se[105]=e=>{if(!1===we.structuredClone)throw new Error("Structured clone extension is disabled");let t=ye.getUint32(he-4);me||(me=new Map);let r,i=se[he];r=i>=144&&i<160||220==i||221==i?[]:{};let n={target:r};me.set(t,n);let o=Ne();return n.used?Object.assign(r,o):(n.target=o,o)},Se[112]=e=>{if(!1===we.structuredClone)throw new Error("Structured clone extension is disabled");let t=ye.getUint32(he-4),r=me.get(t);return r.used=!0,r.target},Se[115]=()=>new Set(Ne());const nt=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((e=>e+"Array"));let ot="object"==typeof globalThis?globalThis:window;Se[116]=e=>{let t=e[0],r=nt[t];if(!r){if(16===t){let t=new ArrayBuffer(e.length-1);return new Uint8Array(t).set(e.subarray(1)),t}throw new Error("Could not find typed array for code "+t)}return new ot[r](Uint8Array.prototype.slice.call(e,1).buffer)},Se[120]=()=>{let e=Ne();return new RegExp(e[0],e[1])};const st=[];function at(e){Re&&Re();let t=ae,r=he,i=be,n=ke,o=_e,s=pe,a=ve,c=me,u=ge,l=new Uint8Array(se.slice(0,ae)),h=fe,d=fe.slice(0,fe.length),f=we,p=xe,g=e();return ae=t,he=r,be=i,ke=n,_e=o,pe=s,ve=a,me=c,ge=u,se=l,xe=p,(fe=h).splice(0,fe.length,...d),we=f,ye=new DataView(se.buffer,se.byteOffset,se.byteLength),g}function ct(){se=null,me=null,fe=null}Se[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],r=he;return he+=t-e.length,ge=st,(ge=[Je(),Je()]).position0=0,ge.position1=0,ge.postBundlePosition=he,he=r,Ne()},Se[255]=e=>4==e.length?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):8==e.length?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):12==e.length?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid");const ut=new Array(147);for(let e=0;e<256;e++)ut[e]=+("1e"+Math.floor(45.15-.30103*e));var lt=new Me({useRecords:!1});lt.unpack,lt.unpackMultiple,lt.unpack;let ht=new Float32Array(1);new Uint8Array(ht.buffer,0,4);var dt=r(5995).Buffer;let ft,pt,gt;try{ft=new TextEncoder}catch(e){}const mt=void 0!==dt,yt=mt?function(e){return dt.allocUnsafeSlow(e)}:Uint8Array,vt=mt?dt:Uint8Array,bt=mt?4294967296:2144337920;let wt,kt,_t,St,Et,Tt=0,Ct=null;const At=/[\u0080-\uFFFF]/,Pt=Symbol("record-id");class Rt extends Me{constructor(e){let t,r,i,n;super(e),this.offset=0;let o=vt.prototype.utf8Write?function(e,t){return wt.utf8Write(e,t,4294967295)}:!(!ft||!ft.encodeInto)&&function(e,t){return ft.encodeInto(e,wt.subarray(t)).written},s=this;e||(e={});let a=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(null==u&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&null==e.moreTypes&&(this.moreTypes=!0);let l=e.maxOwnStructures;null==l&&(l=c?32:64),this.structures||0==e.useRecords||(this.structures=[]);let h=u>32||l+u>64,d=u+64,f=u+l+64;if(f>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let p=[],g=0,m=0;this.pack=this.encode=function(e,o){if(wt||(wt=new yt(8192),_t=wt.dataView||(wt.dataView=new DataView(wt.buffer,0,8192)),Tt=0),St=wt.length-10,St-Tt<2048?(wt=new yt(wt.length),_t=wt.dataView||(wt.dataView=new DataView(wt.buffer,0,wt.length)),St=wt.length-10,Tt=0):Tt=Tt+7&2147483640,t=Tt,o&zt&&(Tt+=255&o),n=s.structuredClone?new Map:null,s.bundleStrings&&"string"!=typeof e?(Ct=[],Ct.size=1/0):Ct=null,i=s.structures,i){i.uninitialized&&(i=s._mergeStructures(s.getStructures()));let e=i.sharedLength||0;if(e>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let t=0;t<e;t++){let e=i[t];if(!e)continue;let r,n=i.transitions;for(let t=0,i=e.length;t<i;t++){let i=e[t];r=n[i],r||(r=n[i]=Object.create(null)),n=r}n[Pt]=t+64}this.lastNamedStructuresLength=e}a||(i.nextId=e+64)}let c;r&&(r=!1);try{s.randomAccessStructure&&e&&e.constructor&&e.constructor===Object?A(e):b(e);let r=Ct;if(Ct&&Ot(t,b,0),n&&n.idsToInsert){let e=n.idsToInsert.sort(((e,t)=>e.offset>t.offset?1:-1)),i=e.length,o=-1;for(;r&&i>0;){let n=e[--i].offset+t;n<r.stringsPosition+t&&-1===o&&(o=0),n>r.position+t?o>=0&&(o+=6):(o>=0&&(_t.setUint32(r.position+t,_t.getUint32(r.position+t)+o),o=-1),r=r.previous,i++)}o>=0&&r&&_t.setUint32(r.position+t,_t.getUint32(r.position+t)+o),Tt+=6*e.length,Tt>St&&E(Tt),s.offset=Tt;let a=function(e,t){let r,i=6*t.length,n=e.length-i;for(;r=t.pop();){let t=r.offset,o=r.id;e.copyWithin(t+i,t,n),i-=6;let s=t+i;e[s++]=214,e[s++]=105,e[s++]=o>>24,e[s++]=o>>16&255,e[s++]=o>>8&255,e[s++]=255&o,n=t}return e}(wt.subarray(t,Tt),e);return n=null,a}return s.offset=Tt,o&Ft?(wt.start=t,wt.end=Tt,wt):wt.subarray(t,Tt)}catch(e){throw c=e,e}finally{if(i&&(y(),r&&s.saveStructures)){let r=i.sharedLength||0,n=wt.subarray(t,Tt),a=Bt(i,s);if(!c)return!1===s.saveStructures(a,a.isCompatible)?s.pack(e,o):(s.lastNamedStructuresLength=r,wt.length>1073741824&&(wt=null),n)}wt.length>1073741824&&(wt=null),o&Vt&&(Tt=t)}};const y=()=>{m<10&&m++;let e=i.sharedLength||0;if(i.length>e&&!a&&(i.length=e),g>1e4)i.transitions=null,m=0,g=0,p.length>0&&(p=[]);else if(p.length>0&&!a){for(let e=0,t=p.length;e<t;e++)p[e][Pt]=0;p=[]}},v=e=>{var t=e.length;t<16?wt[Tt++]=144|t:t<65536?(wt[Tt++]=220,wt[Tt++]=t>>8,wt[Tt++]=255&t):(wt[Tt++]=221,_t.setUint32(Tt,t),Tt+=4);for(let r=0;r<t;r++)b(e[r])},b=e=>{Tt>St&&(wt=E(Tt));var r,i=typeof e;if("string"===i){let i,n=e.length;if(Ct&&n>=4&&n<4096){if((Ct.size+=n)>21760){let e,r,i=(Ct[0]?3*Ct[0].length+Ct[1].length:0)+10;Tt+i>St&&(wt=E(Tt+i)),Ct.position?(r=Ct,wt[Tt]=200,Tt+=3,wt[Tt++]=98,e=Tt-t,Tt+=4,Ot(t,b,0),_t.setUint16(e+t-3,Tt-t-e)):(wt[Tt++]=214,wt[Tt++]=98,e=Tt-t,Tt+=4),Ct=["",""],Ct.previous=r,Ct.size=0,Ct.position=e}let r=At.test(e);return Ct[r?0:1]+=e,wt[Tt++]=193,void b(r?-n:n)}i=n<32?1:n<256?2:n<65536?3:5;let s=3*n;if(Tt+s>St&&(wt=E(Tt+s)),n<64||!o){let t,o,s,a=Tt+i;for(t=0;t<n;t++)o=e.charCodeAt(t),o<128?wt[a++]=o:o<2048?(wt[a++]=o>>6|192,wt[a++]=63&o|128):55296==(64512&o)&&56320==(64512&(s=e.charCodeAt(t+1)))?(o=65536+((1023&o)<<10)+(1023&s),t++,wt[a++]=o>>18|240,wt[a++]=o>>12&63|128,wt[a++]=o>>6&63|128,wt[a++]=63&o|128):(wt[a++]=o>>12|224,wt[a++]=o>>6&63|128,wt[a++]=63&o|128);r=a-Tt-i}else r=o(e,Tt+i);r<32?wt[Tt++]=160|r:r<256?(i<2&&wt.copyWithin(Tt+2,Tt+1,Tt+1+r),wt[Tt++]=217,wt[Tt++]=r):r<65536?(i<3&&wt.copyWithin(Tt+3,Tt+2,Tt+2+r),wt[Tt++]=218,wt[Tt++]=r>>8,wt[Tt++]=255&r):(i<5&&wt.copyWithin(Tt+5,Tt+3,Tt+3+r),wt[Tt++]=219,_t.setUint32(Tt,r),Tt+=4),Tt+=r}else if("number"===i)if(e>>>0===e)e<32||e<128&&!1===this.useRecords||e<64&&!this.randomAccessStructure?wt[Tt++]=e:e<256?(wt[Tt++]=204,wt[Tt++]=e):e<65536?(wt[Tt++]=205,wt[Tt++]=e>>8,wt[Tt++]=255&e):(wt[Tt++]=206,_t.setUint32(Tt,e),Tt+=4);else if((e|0)===e)e>=-32?wt[Tt++]=256+e:e>=-128?(wt[Tt++]=208,wt[Tt++]=e+256):e>=-32768?(wt[Tt++]=209,_t.setInt16(Tt,e),Tt+=2):(wt[Tt++]=210,_t.setInt32(Tt,e),Tt+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){let r;if(wt[Tt++]=202,_t.setFloat32(Tt,e),t<4||((r=e*ut[(127&wt[Tt])<<1|wt[Tt+1]>>7])|0)===r)return void(Tt+=4);Tt--}wt[Tt++]=203,_t.setFloat64(Tt,e),Tt+=8}else if("object"===i||"function"===i)if(e){if(n){let r=n.get(e);if(r){if(!r.id){let e=n.idsToInsert||(n.idsToInsert=[]);r.id=e.push(r)}return wt[Tt++]=214,wt[Tt++]=112,_t.setUint32(Tt,r.id),void(Tt+=4)}n.set(e,{offset:Tt-t})}let o=e.constructor;if(o===Object)S(e);else if(o===Array)v(e);else if(o===Map)if(this.mapAsEmptyObject)wt[Tt++]=128;else{(r=e.size)<16?wt[Tt++]=128|r:r<65536?(wt[Tt++]=222,wt[Tt++]=r>>8,wt[Tt++]=255&r):(wt[Tt++]=223,_t.setUint32(Tt,r),Tt+=4);for(let[t,r]of e)b(t),b(r)}else{for(let t=0,r=pt.length;t<r;t++){if(e instanceof gt[t]){let r=pt[t];if(r.write){r.type&&(wt[Tt++]=212,wt[Tt++]=r.type,wt[Tt++]=0);let t=r.write.call(this,e);return void(t===e?Array.isArray(e)?v(e):S(e):b(t))}let i,n=wt,o=_t,s=Tt;wt=null;try{i=r.pack.call(this,e,(e=>(wt=n,n=null,Tt+=e,Tt>St&&E(Tt),{target:wt,targetView:_t,position:Tt-e})),b)}finally{n&&(wt=n,_t=o,Tt=s,St=wt.length-10)}return void(i&&(i.length+Tt>St&&E(i.length+Tt),Tt=Mt(i,wt,Tt,r.type)))}}if(Array.isArray(e))v(e);else{if(e.toJSON){const t=e.toJSON();if(t!==e)return b(t)}if("function"===i)return b(this.writeFunction&&this.writeFunction(e));S(e)}}}else wt[Tt++]=192;else if("boolean"===i)wt[Tt++]=e?195:194;else if("bigint"===i){if(e<BigInt(1)<<BigInt(63)&&e>=-(BigInt(1)<<BigInt(63)))wt[Tt++]=211,_t.setBigInt64(Tt,e);else if(e<BigInt(1)<<BigInt(64)&&e>0)wt[Tt++]=207,_t.setBigUint64(Tt,e);else{if(!this.largeBigIntToFloat){if(this.useBigIntExtension&&e<2n**1023n&&e>-(2n**1023n)){wt[Tt++]=199,Tt++,wt[Tt++]=66;let t,r=[];do{let i=0xffn&e;t=(0x80n&i)===(e<0n?0x80n:0n),r.push(i),e>>=8n}while(0n!==e&&-1n!==e||!t);wt[Tt-2]=r.length;for(let e=r.length;e>0;)wt[Tt++]=Number(r[--e]);return}throw new RangeError(e+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension or set largeBigIntToFloat to convert to float-64")}wt[Tt++]=203,_t.setFloat64(Tt,Number(e))}Tt+=8}else{if("undefined"!==i)throw new Error("Unknown type: "+i);this.encodeUndefinedAsNil?wt[Tt++]=192:(wt[Tt++]=212,wt[Tt++]=0,wt[Tt++]=0)}},w=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let r in e)"function"==typeof e.hasOwnProperty&&!e.hasOwnProperty(r)||this.skipValues.includes(e[r])||t.push(r)}else t=Object.keys(e);let r,i=t.length;if(i<16?wt[Tt++]=128|i:i<65536?(wt[Tt++]=222,wt[Tt++]=i>>8,wt[Tt++]=255&i):(wt[Tt++]=223,_t.setUint32(Tt,i),Tt+=4),this.coercibleKeyAsNumber)for(let n=0;n<i;n++){r=t[n];let i=Number(r);b(isNaN(i)?r:i),b(e[r])}else for(let n=0;n<i;n++)b(r=t[n]),b(e[r])}:e=>{wt[Tt++]=222;let r=Tt-t;Tt+=2;let i=0;for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&(b(t),b(e[t]),i++);wt[r+++t]=i>>8,wt[r+t]=255&i},k=!1===this.useRecords?w:e.progressiveRecords&&!h?e=>{let r,n,o=i.transitions||(i.transitions=Object.create(null)),s=Tt++-t;for(let a in e)if("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(a)){if(r=o[a],r)o=r;else{let c=Object.keys(e),u=o;o=i.transitions;let l=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];r=o[t],r||(r=o[t]=Object.create(null),l++),o=r}s+t+1==Tt?(Tt--,T(o,c,l)):C(o,c,s,l),n=!0,o=u[a]}b(e[a])}if(!n){let r=o[Pt];r?wt[s+t]=r:C(o,Object.keys(e),s,0)}}:e=>{let t,r=i.transitions||(i.transitions=Object.create(null)),n=0;for(let i in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(i))&&(t=r[i],t||(t=r[i]=Object.create(null),n++),r=t);let o=r[Pt];o?o>=96&&h?(wt[Tt++]=96+(31&(o-=96)),wt[Tt++]=o>>5):wt[Tt++]=o:T(r,r.__keys__||Object.keys(e),n);for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&b(e[t])},_="function"==typeof this.useRecords&&this.useRecords,S=_?e=>{_(e)?k(e):w(e)}:k,E=e=>{let r;if(e>16777216){if(e-t>bt)throw new Error("Packed buffer would be larger than maximum buffer size");r=Math.min(bt,4096*Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096))}else r=1+(Math.max(e-t<<2,wt.length-1)>>12)<<12;let i=new yt(r);return _t=i.dataView||(i.dataView=new DataView(i.buffer,0,r)),e=Math.min(e,wt.length),wt.copy?wt.copy(i,0,t,e):i.set(wt.slice(t,e)),Tt-=t,t=0,St=i.length-10,wt=i},T=(e,t,n)=>{let o=i.nextId;o||(o=64),o<d&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(o=i.nextOwnId,o<f||(o=d),i.nextOwnId=o+1):(o>=f&&(o=d),i.nextId=o+1);let s=t.highByte=o>=96&&h?o-96>>5:-1;e[Pt]=o,e.__keys__=t,i[o-64]=t,o<d?(t.isShared=!0,i.sharedLength=o-63,r=!0,s>=0?(wt[Tt++]=96+(31&o),wt[Tt++]=s):wt[Tt++]=o):(s>=0?(wt[Tt++]=213,wt[Tt++]=114,wt[Tt++]=96+(31&o),wt[Tt++]=s):(wt[Tt++]=212,wt[Tt++]=114,wt[Tt++]=o),n&&(g+=m*n),p.length>=l&&(p.shift()[Pt]=0),p.push(e),b(t))},C=(e,r,i,n)=>{let o=wt,s=Tt,a=St,c=t;wt=kt,Tt=0,t=0,wt||(kt=wt=new yt(8192)),St=wt.length-10,T(e,r,n),kt=wt;let u=Tt;if(wt=o,Tt=s,St=a,t=c,u>1){let e=Tt+u-1;e>St&&E(e);let r=i+t;wt.copyWithin(r+u,r+1,Tt),wt.set(kt.slice(0,u),r),Tt=e}else wt[i+t]=kt[0]},A=e=>{let n=Et(e,wt,t,Tt,i,E,((e,t,i)=>{if(i)return r=!0;Tt=t;let n=wt;return b(e),y(),n!==wt?{position:Tt,targetView:_t,target:wt}:Tt}),this);if(0===n)return S(e);Tt=n}}useBuffer(e){wt=e,wt.dataView||(wt.dataView=new DataView(wt.buffer,wt.byteOffset,wt.byteLength)),Tt=0}set position(e){Tt=e}get position(){return Tt}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}function xt(e,t,r,i){let n=e.byteLength;if(n+1<256){var{target:o,position:s}=r(4+n);o[s++]=199,o[s++]=n+1}else if(n+1<65536){var{target:o,position:s}=r(5+n);o[s++]=200,o[s++]=n+1>>8,o[s++]=n+1&255}else{var{target:o,position:s,targetView:a}=r(7+n);o[s++]=201,a.setUint32(s,n+1),s+=4}o[s++]=116,o[s++]=t,e.buffer||(e=new Uint8Array(e)),o.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s)}function It(e,t){let r=e.byteLength;var i,n;if(r<256){var{target:i,position:n}=t(r+2);i[n++]=196,i[n++]=r}else if(r<65536){var{target:i,position:n}=t(r+3);i[n++]=197,i[n++]=r>>8,i[n++]=255&r}else{var{target:i,position:n,targetView:o}=t(r+5);i[n++]=198,o.setUint32(n,r),n+=4}i.set(e,n)}function Mt(e,t,r,i){let n=e.length;switch(n){case 1:t[r++]=212;break;case 2:t[r++]=213;break;case 4:t[r++]=214;break;case 8:t[r++]=215;break;case 16:t[r++]=216;break;default:n<256?(t[r++]=199,t[r++]=n):n<65536?(t[r++]=200,t[r++]=n>>8,t[r++]=255&n):(t[r++]=201,t[r++]=n>>24,t[r++]=n>>16&255,t[r++]=n>>8&255,t[r++]=255&n)}return t[r++]=i,t.set(e,r),r+=n}function Ot(e,t,r){if(Ct.length>0){_t.setUint32(Ct.position+e,Tt+r-Ct.position-e),Ct.stringsPosition=Tt-e;let i=Ct;Ct=null,t(i[0]),t(i[1])}}function Bt(e,t){return e.isCompatible=e=>{let r=!e||(t.lastNamedStructuresLength||0)===e.length;return r||t._mergeStructures(e),r},e}gt=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Te],pt=[{pack(e,t,r){let i=e.getTime()/1e3;if((this.useTimestamp32||0===e.getMilliseconds())&&i>=0&&i<4294967296){let{target:e,targetView:r,position:n}=t(6);e[n++]=214,e[n++]=255,r.setUint32(n,i)}else if(i>0&&i<4294967296){let{target:r,targetView:n,position:o}=t(10);r[o++]=215,r[o++]=255,n.setUint32(o,4e6*e.getMilliseconds()+(i/1e3/4294967296|0)),n.setUint32(o+4,i)}else if(isNaN(i)){if(this.onInvalidDate)return t(0),r(this.onInvalidDate());let{target:e,targetView:i,position:n}=t(3);e[n++]=212,e[n++]=255,e[n++]=255}else{let{target:r,targetView:n,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,n.setUint32(o,1e6*e.getMilliseconds()),n.setBigInt64(o+4,BigInt(Math.floor(i)))}}},{pack(e,t,r){if(this.setAsEmptyObject)return t(0),r({});let i=Array.from(e),{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=115,n[o++]=0),r(i)}},{pack(e,t,r){let{target:i,position:n}=t(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=101,i[n++]=0),r([e.name,e.message,e.cause])}},{pack(e,t,r){let{target:i,position:n}=t(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=120,i[n++]=0),r([e.source,e.flags])}},{pack(e,t){this.moreTypes?xt(e,16,t):It(mt?dt.from(e):new Uint8Array(e),t)}},{pack(e,t){let r=e.constructor;r!==vt&&this.moreTypes?xt(e,nt.indexOf(r.name),t):It(e,t)}},{pack(e,t){let{target:r,position:i}=t(1);r[i]=193}}];let Nt=new Rt({useRecords:!1});Nt.pack,Nt.pack;const{NEVER:Lt,ALWAYS:Dt,DECIMAL_ROUND:Ut,DECIMAL_FIT:jt}={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Ft=512,Vt=1024,zt=2048;r(5995).Buffer;let qt=function(e){return e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.CHANNEL_MESSAGE="channelmessage",e.IM_MESSAGE="immessage",e.WHITEBOARD_MESSAGE="whiteboardmessage",e.CUSTOM_TOPIC_MESSAGE="custommessage",e}({});class Wt extends(l()){logger;client;version=1;ssTopics={};authReconnect;isFirstConnect=!0;unpacker;constructor(e,t=ie){super(),this.authReconnect=e,this.logger=t,this.unpacker=new Me({useRecords:!1,int64AsType:"number"})}initClient(e){let t=this.getBrokerUrl(e.ws);return ue().connect(t,{keepalive:30,clean:!1,connectTimeout:1e4,reconnectPeriod:3e3,resubscribe:!1,clientId:e.client_id,username:e.username,password:e.jwt_token,protocolVersion:5,properties:{sessionExpiryInterval:400},transformWsUrl:this.authReconnect})}getBrokerUrl(e){return e}async connect(e){return this.client&&await this.close(!0),this.isFirstConnect=!0,new Promise(((t,r)=>{this.client=this.initClient(e);let i=e=>{o(),setTimeout((()=>{this.close(!0)}),0);let t=e?R.fromError(e):new R("会控服务连接失败");r(t)},n=async i=>{o();try{await this.subscribe(e.topics,2)}catch(e){return this.close(!0),void r(e)}this.addListeners(),this.client.emit("connect",i),this.isFirstConnect=!1,t()},o=()=>{this.client.off("connect",n),this.client.off("error",i),this.client.off("offline",i),this.client.off("close",i)};this.client.once("connect",n),this.client.once("error",i),this.client.once("offline",i),this.client.once("close",i)}))}addListeners(){this.client.on("connect",(()=>{if(!this.isFirstConnect)for(const e in this.ssTopics)k((()=>this.subscribe(e,this.ssTopics[e])),{maxRetries:10})().catch((t=>{"maxretry"==t&&this.logger.error(`socket尝试订阅${e}多次重试依旧失败,已放弃`)}));this.emit(qt.CONNECTED)})),this.client.on("reconnect",(()=>{this.logger.info("socket start reconnect"),this.emit(qt.RECONNECTING)})),this.client.on("close",(()=>{this.logger.info("socket closed")})),this.client.on("offline",(()=>{this.logger.info("socket offline")})),this.client.on("error",(e=>{throw this.logger.error("socket error",e),R.fromError(e)})),this.onMsg=this.onMsg.bind(this),this.client.on("message",this.onMsg)}subscribe(e,t=0){return new Promise(((r,i)=>{this.client.subscribe(e,{qos:t},((t,n)=>{t?(this.logger.error(`subscribe ${e} error`,t),i(R.fromError(t))):n&&(this.logger.debug(`subscribe ${e} success`,n),n.forEach((e=>{this.ssTopics[e.topic]=e.qos})),r())}))}))}unsubscribe(e){return new Promise(((t,r)=>{this.client.unsubscribe(e,(i=>{if(i)this.logger.error(`unsubscribe ${e} error`,i),r(R.fromError(i));else{("string"==typeof e?[e]:e).forEach((e=>{delete this.ssTopics[e]})),t()}}))}))}async close(e=!1){return new Promise(((t,r)=>{this.client.end(e,(e=>{this.ssTopics={},null!=e?r(R.fromError(e)):t()}))}))}sendMsg(e,t,r=0){return new Promise(((i,n)=>{this.client.publish(t,e,{qos:r},(e=>{null!=e?n(R.fromError(e)):i()}))}))}onMsg(e,t,r){try{if(0!==e.indexOf("/rtc/"))return void this.emit(qt.CUSTOM_TOPIC_MESSAGE,e,t);let r=this.unpacker.unpack(t);if(null==r)return void this.logger.error("解析报文失败",e,t);this.logger.debug(r.data.channel?"收到会控消息":r.data.board?"收到电子白板消息":"收到im消息",r),this.emit(r.data.channel?qt.CHANNEL_MESSAGE:r.data.board?qt.WHITEBOARD_MESSAGE:qt.IM_MESSAGE,e,r)}catch(e){this.logger.error("消息处理报错",e)}}}var Ht=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.DISCONNECTED="disconnected",e}(Ht||{});class Kt extends(l()){rtcApi;rtcSocket;connectState;heartbeatIntervalID;eventCB;logger;constructor(e,t,r=null,i=new re){super(),this.rtcApi=e,this.rtcSocket=t,this.logger=i,this.eventCB=r,this.addSocketListeners(),this.connectState=Ht.INIT}addSocketListeners(){this.onConnected=this.onConnected.bind(this),this.onStartReconnect=this.onStartReconnect.bind(this),this.onImMessage=this.onImMessage.bind(this),this.rtcSocket.on(qt.CONNECTED,this.onConnected),this.rtcSocket.on(qt.RECONNECTING,this.onStartReconnect),this.rtcSocket.on(qt.IM_MESSAGE,this.onImMessage)}removeSocketListeners(){this.rtcSocket.off(qt.CONNECTED,this.onConnected),this.rtcSocket.off(qt.RECONNECTING,this.onStartReconnect),this.rtcSocket.off(qt.IM_MESSAGE,this.onImMessage)}triggerEvent(e,...t){const r=t[0];try{const t={type:e,data:r};this.emit(e,t),this.eventCB&&this.eventCB(t)}catch(t){this.logger.error(`im事件${e}上层响应出错,请sdk调用者检查`,t,r)}}async heartbeat(){let e=this.heartbeatIntervalID;if(this.connectState!=Ht.CONNECTED)throw this.logger.info(`异常im心跳,当前im状态${this.connectState}`),clearInterval(e),new R(`异常im心跳,im状态为:${this.connectState}`);try{await this.rtcApi.imHeartbeat()}catch(e){this.logger.error("im心跳失败",e),e instanceof R&&this.disconnnect(c.Error,e)}this.logger.debug("im heartbeat interval",e)}async onConnected(){let e=this.connectState;this.logger.warn(e==Ht.RECONNECTING?"imsocket重连成功":"imsocket连接成功"),this.connectState=Ht.CONNECTED,this.heartbeatIntervalID&&clearInterval(this.heartbeatIntervalID);let t=this.heartbeatIntervalID=setInterval((()=>this.heartbeat()),3e4);this.logger.debug("imheartbeat interval started",t),e==Ht.RECONNECTING?this.triggerEvent(a.RECONNECTED):this.triggerEvent(a.ENABLE_SUCCEED)}onStartReconnect(){this.logger.warn("imsocket开始重连"),clearInterval(this.heartbeatIntervalID),this.connectState=Ht.RECONNECTING,this.triggerEvent(a.RECONNECTING)}onImMessage(e,t){switch(t.type){case ne.ImDisconnect:const e=t.data;if(!e)return;this.disconnnect(e.reason);break;case ne.ImMsg:{const e=t.data;if(!e)return;this.triggerEvent(a.IM_MSG,e);break}}}async disconnnect(e,t){if(this.connectState!==Ht.DISCONNECTED){clearInterval(this.heartbeatIntervalID),this.removeSocketListeners();try{await this.rtcSocket.close()}catch(e){this.logger.error("断开imsocket报错",e)}try{await this.rtcApi.imDisconnect()}catch(e){this.logger.error("调im断开api报错",e)}this.connectState=Ht.DISCONNECTED,this.triggerEvent(a.DISCONNECTED,{reason:e,error:t}),this.removeAllListeners(),this.eventCB=null,this.logger.center?.flush(),this.logger.info("disconnected im",e)}}}class $t{static liveInstanceCount=0;channels=[];im;imLogger;isAppHide;destroyed=!1;supportsMultiChannel(){return!0}get defaultChannel(){return this.channels[0]??null}isDefaultChannel(e,t){const r=this.channels[0];return!(!r||!e)&&(r===e||!!t&&this.getChannelId(r)===t)}getChannelId(e){try{return e?.getInfo()?.channel??""}catch{return""}}warnIfReactiveProxy(){const e=this;(e.__v_isReactive||e.__v_isReadonly||e.__v_raw)&&ie.warn("SRTC 实例被响应式框架代理(如 Vue reactive / Pinia state),请改用 markRaw() 或 shallowRef 存放 SDK 实例,否则可能出现频道事件丢失等问题")}onNotifyChannelEvent=null;onNotifyImEvent=null;constructor(e){this.isAppHide=!1,e.logLevel&&($t.liveInstanceCount>0&&ie.warn("logLevel 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),ie.setLevel(e.logLevel)),e.logTarget&&(p()||e.logTarget!=X.WXREALTIME||(e.logTarget=X.CONSOLE,ie.warn("仅微信小程序支持实时日志")),$t.liveInstanceCount>0&&ie.warn("logTarget 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),ie.setTarget(e.logTarget)),$t.liveInstanceCount++;let t=this.buildInfo();ie.warn("srtc "+(p()?"wechat":"webrtc")+" sdk version:",t.version,"build time:",S("Y-m-d H:i:s",new Date(1e3*t.timestamp)))}get joinVersion(){return this.buildInfo().version}async join(e,t={}){if(this.destroyed)throw new R("SRTC 实例已 destroy");if(this.warnIfReactiveProxy(),!this.supportsMultiChannel()&&this.channels.length>0)throw new R("请先退出频道");t={autoSubscribeAudio:!1,autoSubscribeVideo:!1,adaptiveStream:!0,...t};const r=Math.floor(Date.now()/1e3);let i=A(e);if(i.exp_at&&i.exp_at<r)throw I;let s,a=new re;i.log_center&&(a.center=new J(i,this.getStoredDeviceId(),this.getDeviceType(),!0));let c="";const u=e=>{s&&this.isDefaultChannel(s,c)&&this.onNotifyChannelEvent&&this.onNotifyChannelEvent(e),s&&e.type===n.DISCONNECTED&&this.removeChannel(s)};let l,h;try{let e=this.newRtcApi(i,a);h=await e.join({deviceType:this.getDeviceType(),deviceID:this.getStoredDeviceId(),version:this.joinVersion}),c=h.channel;let r=this.newStreamEngine(t,h,e,a);await r.connect();let n=(t,r,i)=>{const n=Math.floor(Date.now()/1e3);return h.mqtt.token_exp_at<n&&e.reconnect({type:0}).then((e=>{h.mqtt=e.mqtt,h.upload=e.upload,h.rtmp=e.rtmp,h.webrtc=e.webrtc})).catch((e=>{e instanceof R&&s?.leave(o.Error,e)})),i.options.username=h.mqtt.username,i.options.clientId=h.mqtt.client_id,i.options.password=h.mqtt.jwt_token,h.mqtt.ws};l=this.newRtcSocket(n,a),s=this.newChannel(t,h,e,r,l,u,a)}catch(e){throw a.center?.shutdown(),a.center=void 0,e}const d=s;return this.channels.push(d),this.syncGlobalLogCenter(),new Promise((async(e,t)=>{d.once(n.JOIN_SUCCEED,(()=>{a.info("joined channel: "+h.channel),e(d)})),d.once(n.DISCONNECTED,(e=>{t(e.data)}));try{await l.connect(h.mqtt)}catch(e){d.leave(o.Error,e).catch((()=>{})),t(e)}}))}async leave(){let e=this.defaultChannel;if(e)try{await e.leave(o.Self)}catch(t){this.removeChannel(e),ie.error("离开频道报错,强制离开",t)}else ie.warn("您不在频道中,无需调用离开")}removeChannel(e){let t=this.channels.indexOf(e);if(t<0){const r=this.getChannelId(e);r&&(t=this.channels.findIndex((e=>this.getChannelId(e)===r)))}t>=0&&this.channels.splice(t,1),this.syncGlobalLogCenter(),e.getLogCenter()?.shutdown(),e.setLogCenter(void 0),this.postLeave(e)}syncGlobalLogCenter(){ie.center=this.defaultChannel?.getLogCenter()}postLeave(e){}getChannelInfo(){return this.defaultChannel?this.defaultChannel.getInfo():null}getPublishInfo(e){if(!this.defaultChannel)throw x;return this.defaultChannel.getPublishInfo(e)}getUserInfo(e){if(!this.defaultChannel)throw x;return this.defaultChannel.getUser(e).getInfo()}getUsersInfo(e=!1){if(!this.defaultChannel)throw x;return this.defaultChannel.getUsersInfo(e)}async subscribeRemoteAudioMixTrack(e){if(!this.defaultChannel)throw x;return await this.defaultChannel.subscribeRemoteAudioMixTrack(e)}async subscribeRemoteAudioTrack(e,t){if(!this.defaultChannel)throw x;return await this.defaultChannel.subscribeRemoteAudioTrack(e,t)}async subscribeRemoteVideoMcuTrack(){if(!this.defaultChannel)throw x;return await this.defaultChannel.subscribeRemoteVideoMcuTrack()}async subscribeRemoteVideoTrack(e,t){if(!this.defaultChannel)throw x;return await this.defaultChannel.subscribeRemoteVideoTrack(e,t)}async unsubscribeRemoteTrack(e){if(!this.defaultChannel)throw x;await this.defaultChannel.unsubscribeRemoteTrack(e)}getRemoteTrack(e,t,r){if(!this.defaultChannel)throw x;if(!t&&!r)throw new R("id或desc至少一项不为空");let i=t?this.defaultChannel.getUser(e).getTrack(t):this.defaultChannel.getUser(e).getTrackByDesc(r);if(!i)throw M(t?e+"没有id为"+t+"的音视频流":e+"没有desc为"+r+"的音视频流");return i}async enableIm(e){if(this.destroyed)throw new R("SRTC 实例已 destroy");if(this.im)throw new R("您已启用im频道外消息通道");const t=Math.floor(Date.now()/1e3);let r=A(e);if(r.exp_at&&r.exp_at<t)throw I;let i=new re;r.log_center&&(this.imLogger=new J(r,this.getStoredDeviceId(),this.getDeviceType(),!0),i.center=this.imLogger);let n,o=this.newRtcApi(r,i);try{n=await o.imConnect({deviceType:this.getDeviceType(),deviceID:this.getStoredDeviceId(),version:this.joinVersion})}catch(e){throw this.imLogger?.shutdown(),this.imLogger=void 0,e}let s=this.newRtcSocket(((e,t,r)=>{const i=Math.floor(Date.now()/1e3);return n.mqtt.token_exp_at<i&&o.imReconnect().then((e=>{n.mqtt=e.mqtt})).catch((e=>{e instanceof R&&u?.disconnnect(c.Error,e)})),r.options.username=n.mqtt.username,r.options.clientId=n.mqtt.client_id,r.options.password=n.mqtt.jwt_token,n.mqtt.ws}),i),u=this.im=new Kt(o,s,(e=>{this.onNotifyImEvent&&this.onNotifyImEvent(e)}),i);return new Promise((async(e,t)=>{u.once(a.ENABLE_SUCCEED,(()=>{e(r.sid)})),u.once(a.DISCONNECTED,(e=>{this.postDisableIm(),t(e.data)}));try{await s.connect(n.mqtt)}catch(e){t(e)}}))}async disableIm(){if(this.im)try{await this.im.disconnnect(c.Self)}catch(e){this.postDisableIm(),ie.error("离开频道报错,强制离开",e)}else ie.warn("您尚未启用im频道外消息通道")}postDisableIm(){this.im=null,this.imLogger&&(this.imLogger.shutdown(),this.imLogger=void 0)}onAppShow(e){e?ie.warn("页面恢复显示",e):ie.warn("页面恢复显示"),this.isAppHide=!1}onAppHide(){ie.warn("页面切后台或最小化"),this.isAppHide=!0}async destroy(){if(this.destroyed)return;this.destroyed=!0,$t.liveInstanceCount--;let e=[];for(const t of[...this.channels])await t.leave(o.Self).catch((t=>e.push(t)));if(this.im&&await this.disableIm().catch((t=>e.push(t))),this.releaseGlobalListeners(),e.length>0)throw ie.error("destroy 过程中部分清理步骤报错,已尽量清理完毕",e),new R("destroy 过程中部分清理步骤报错: "+e.map((e=>e?.message??e)).join("; "))}releaseGlobalListeners(){}}var Gt=r(3793),Qt=r.n(Gt);let Jt;!function(e){e.BaseSRTC_I=$t,e.CommonChannelEventType_I=n,e.isWxxcx_I=p,e.Logger_I=re,e.SdkError_I=R,e.propAssign_I=_,e.isObject_I=g,e.isString_I=y,e.sleep_I=w,e.retry_I=k,e.dateFormat_I=S,e.genNonce_I=T,e.getHostnameFromUrl_I=C,e.dct_I=A;e.hmac_I=function(e,t){return Qt()(e,t).toString()}}(Jt||(Jt={}));let Yt=function(e){return e.OOK="ook",e.WangsuCDN="wangsucdn",e.Seastart="seastart",e}({});class Xt extends(l()){joinRsp;published;subscribed;ability;logger;publisher;monitorInterval;prevMetric;constructor(e,t,r=ie){super(),this.joinRsp=e,this.logger=r,this.published={},this.subscribed={},t&&setTimeout((()=>{this.ability?_(this.ability,t):this.ability=t}),0)}async connect(){this.startMonitor()}async publish(e,t,r){let i=0;if(e.kind==U.Audio&&this.ability&&void 0!==this.ability.audioMaxPub&&-1!=this.ability.audioMaxPub){for(const e in this.published){this.published[e].kind==U.Audio&&i++}if(this.ability.audioMaxPub>0&&i>=this.ability.audioMaxPub)throw new R("最多允许发布"+this.ability.audioMaxPub+"个音频轨道")}else if(e.kind==U.Video&&this.ability&&void 0!==this.ability.videoMaxPub&&-1!=this.ability.videoMaxPub){for(const e in this.published){this.published[e].kind==U.Video&&i++}if(this.ability.videoMaxPub>0&&i>=this.ability.videoMaxPub)throw new R("最多允许发布"+this.ability.videoMaxPub+"个视频轨道")}}setPublisher(e){this.publisher=e}updatePublishInfo(e,t){this.publisher?.updatePublishInfo(e,t)}async subscribe(e,t){let r=0;if(e.kind==U.Audio&&this.ability&&void 0!==this.ability.audioMaxSub&&-1!=this.ability.audioMaxSub){for(const e in this.subscribed){this.subscribed[e].kind==U.Audio&&r++}if(this.ability.audioMaxSub>0&&r>=this.ability.audioMaxSub)throw new R("最多允许订阅"+this.ability.audioMaxSub+"个音频轨道")}else if(e.kind==U.Video&&this.ability&&void 0!==this.ability.videoMaxSub&&-1!=this.ability.videoMaxSub){for(const e in this.subscribed){this.subscribed[e].kind==U.Video&&r++}if(this.ability.videoMaxSub>0&&r>=this.ability.videoMaxSub)throw new R("最多允许订阅"+this.ability.videoMaxSub+"个视频轨道")}}haveSubscribed(e){return!!this.subscribed[e.id]}async disconnect(){this.stopMonitor();for(const e in this.published){const t=this.published[e];try{await this.unpublish(t.track)}catch(e){this.logger.error(t.track.toString(),"取消发布失败",e)}}for(const e in this.subscribed){const t=this.subscribed[e];try{await this.unsubscribe(t.track)}catch(e){this.logger.error(t.track.toString(),"取消订阅失败")}}this.published={},this.subscribed={}}getMetricSnapshot(){return this.prevMetric}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval((async()=>{try{const e=await this.getMetric();this.logger.center?.addMetric(e),this.logger.debug("metric",e)}catch(e){this.logger.error("metric","采集metric失败")}}),1e4))}stopMonitor(){this.monitorInterval&&(window.clearInterval(this.monitorInterval),this.monitorInterval=void 0,this.prevMetric=void 0)}}var Zt=r(6880),er=r.n(Zt);let tr;function rr(e=!1){return(e||void 0===tr)&&(tr={...er().parse(navigator?.userAgent),supported:"undefined"!=typeof RTCPeerConnection&&("addTransceiver"in RTCPeerConnection.prototype||"addTrack"in RTCPeerConnection.prototype),secure:isSecureContext,mediaDevices:void 0!==navigator?.mediaDevices,screenshare:void 0!==navigator?.mediaDevices?.getDisplayMedia,h264Enc:ir.checkVideoCodec("h264"),h264Dec:ir.checkVideoCodec("h264",!1),vp8Enc:ir.checkVideoCodec("vp8"),vp8Dec:ir.checkVideoCodec("vp8",!1),opusEnc:ir.checkAudioCodec("opus"),opusDec:ir.checkAudioCodec("opus",!1),videoEncCodecs:ir.videoEncCodecs(),videoDecCodecs:ir.videoDecCodecs(),audeoEncCodecs:ir.audioEncCodecs(),audeoDecCodecs:ir.audioDecCodecs(),ua:navigator?.userAgent,screenWidth:screen?.width||0,screenHeight:screen?.height||0,clientWidth:document?.documentElement?.clientWidth||0,clientHeight:document?.documentElement?.clientHeight||0,devicePixelRatio}),tr}class ir{static async checkCameraPermission(){}static async checkMicPermission(){}static videoEncCodecs(){return"getCapabilities"in RTCRtpSender?RTCRtpSender.getCapabilities("video"):(ie.warn("当前环境不支持getCapabilities获取支持的视频编码类型"),null)}static audioEncCodecs(){return"getCapabilities"in RTCRtpSender?RTCRtpSender.getCapabilities("audio"):(ie.warn("当前环境不支持getCapabilities获取支持的音频编码类型"),null)}static videoDecCodecs(){return"getCapabilities"in RTCRtpReceiver?RTCRtpReceiver.getCapabilities("video"):(ie.warn("当前环境不支持getCapabilities获取支持的视频解码类型"),null)}static audioDecCodecs(){return"getCapabilities"in RTCRtpReceiver?RTCRtpReceiver.getCapabilities("audio"):(ie.warn("当前环境不支持getCapabilities获取支持的音频解码类型"),null)}static checkVideoCodec(e,t=!0){const r=t?this.videoEncCodecs():this.videoDecCodecs();if(r)for(const t of r.codecs)if(t.mimeType.toLowerCase().replace("video/","")===e.toLowerCase())return!0;return!1}static checkAudioCodec(e,t=!0){const r=t?this.audioEncCodecs():this.audioDecCodecs();if(r)for(const t of r.codecs)if(t.mimeType.toLowerCase().replace("audio/","")===e.toLowerCase())return!0;return!1}static preferAudioEncCodec(e){let t=this.audioEncCodecs(),r=[],i=[];if(t)for(const n of t.codecs)n.mimeType.toLowerCase().replace("audio/","")===e.toLowerCase()?i.push(n):r.push(n);return i.push(...r),i}static preferVideoEncCodec(e){let t=this.videoEncCodecs(),r=[],i=[],n=[];if(t)for(const o of t.codecs)o.mimeType.toLowerCase().replace("video/","")===e.toLowerCase()?"h264"===e.toLowerCase()&&o.sdpFmtpLine&&o.sdpFmtpLine.includes("profile-level-id=42e01f")?i.push(o):n.push(o):r.push(o);return i.push(...n),i.push(...r),i}}class nr{appID;sid;clientKey;serverPrefix;logger;constructor(e,t,r,i,n=ie){this.appID=e,this.sid=t,this.clientKey=r,this.logger=n,"/"!==i.substring(i.length-1)&&(i+="/"),this.serverPrefix=i+"v1/"}async join(e){let t=await this.req("channel/join",{device_type:e.deviceType,device_id:e.deviceID,version:e.version});return t.device_type=e.deviceType,t.device_id=e.deviceID,t.version=e.version,t}async detail(e){let t=await this.req("channel/detail",{with_userlist:e});if(e){let e=t.users;return delete t.users,{channelinfo:t,userinfos:e}}return{channelinfo:t,userinfos:null}}async leave(){return this.req("channel/leave",{})}async heartbeat(){return this.req("channel/heartbeat",{})}async reconnect(e){return this.req("channel/reconnect",{type:e.type})}async updateStream(e){return this.req("channel/update-stream",{stream_tracks:e})}async imConnect(e){return this.req("im/connect",{device_type:e.deviceType,device_id:e.deviceID,version:e.version})}async imReconnect(){return this.req("im/reconnect",{})}async imHeartbeat(){return this.req("im/heartbeat",{})}async imDisconnect(){return this.req("im/disconnect",{})}async req(e,t={},r={}){const i=Math.floor(Date.now()/1e3),n=T(16);r.app_id=this.appID,r.sid=this.sid,r.nonce=n,r.timestamp=i+"";let o=this.signature(t,n,i);r.signature=o;let s=Date.now(),a=(r,i)=>{this.logger[r]("rtc api: "+this.serverPrefix+e,t,i,Date.now()-s+"ms")};return this.http(e,t,{...r,"Content-Type":"application/json"}).then((e=>{if(0==e.code)return a(Z.DEBUG,e),e.data;throw new R(e.msg,e.code)})).catch((e=>{throw a(Z.ERROR,e),e}))}signature(e,t,r){let i=`app_id=${this.appID}&sid=${this.sid}&nonce=${t}&timestamp=${r}&`+JSON.stringify(e);return Qt()(i,this.clientKey).toString()}}class or extends nr{http(e,t,r){return new Promise(((i,n)=>{fetch(this.serverPrefix+e,{method:"POST",headers:r,body:JSON.stringify(t)}).then((e=>{200!=e.status?n(new Error(e.status+":"+e.statusText)):e.json().then((e=>{i(e)})).catch((e=>{n(e)}))})).catch((e=>{n(e)}))}))}async cdnURL(e){return(await this.req("cdn/url",e)).url}async sfuConnect(e,t){return this.req("sfu/connect",{publish_offer:e,net:t})}async sfuDisconnect(){return this.req("sfu/disconnect",{})}async sfuOfferPublish(e,t){return this.req("sfu/offer-publish",{offer:e,track_hints:t})}async sfuSubscribe(e){return this.req("sfu/subscribe",{tracks:e})}async sfuAnswerSubscribe(e){return this.req("sfu/answer-subscribe",{answer:e})}}function sr(e,t,r){var i,n,o;void 0===t&&(t=50),void 0===r&&(r={});var s=null!=(i=r.isImmediate)&&i,a=null!=(n=r.callback)&&n,c=r.maxWait,u=Date.now(),l=[];function h(){if(void 0!==c){var e=Date.now()-u;if(e+t>=c)return c-e}return t}var d=function(){var t=[].slice.call(arguments),r=this;return new Promise((function(i,n){var c=s&&void 0===o;if(void 0!==o&&clearTimeout(o),o=setTimeout((function(){if(o=void 0,u=Date.now(),!s){var i=e.apply(r,t);a&&a(i),l.forEach((function(e){return(0,e.resolve)(i)})),l=[]}}),h()),c){var d=e.apply(r,t);return a&&a(d),i(d)}l.push({resolve:i,reject:n})}))};return d.cancel=function(e){void 0!==o&&clearTimeout(o),l.forEach((function(t){return(0,t.reject)(e)})),l=[]},d}class ar{ctn={};linkids={};*[Symbol.iterator](){yield*Object.entries(this.ctn)}set(e,t){this.ctn[e]=t,t.link_id&&(this.linkids[t.link_id]=e)}get(e){return this.ctn[e]}getByLinkid(e){return this.get(this.linkids[e])}del(e){delete this.ctn[e]}clear(){this.ctn={},this.linkids={}}listInfo(e){if(e){let e={};for(const t in this.ctn)e[t]=this.ctn[t].getInfo();return e}{let e=[];for(const t in this.ctn)e.push(this.ctn[t].getInfo());return e}}}var cr=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.LEAVED="leaved",e}(cr||{});class ur extends(l()){options;publishRecords=new Map;joinRsp;me;users;info;heartbeatIntervalID;connectState;logger;rtcApi;rtcSocket;rtcStreamEngine;audioMixTrack;videoMcuTrack;audioMcuTrack;eventCB;onNotifyEvent=null;trackMutex;trackDebounce;constructor(e,t,r,i,n,o=null,s=new re){super(),this.options=e,this.joinRsp=t,this.users=new ar,this.trackMutex={},this.trackDebounce={},this.logger=s,this.rtcApi=r,this.rtcSocket=n,this.rtcStreamEngine=i,this.rtcStreamEngine.setPublisher(this),this.eventCB=o,this.addSocketListeners(),this.addStreamEngineListeners(),this.connectState=cr.INIT}async refresh(e){if(!e){const{channelinfo:e,userinfos:t}=await this.rtcApi.detail(!0);if(this.info=e,this.users.clear(),t&&t.forEach((e=>{let t=this.newUser(e);this.users.set(e.uid,t),e.sid==this.joinRsp.sid&&(this.me=t)})),null==this.me){let e={app_id:this.joinRsp.app_id,uid:this.joinRsp.uid,name:"me_fake",device_id:this.joinRsp.device_id,device_type:this.joinRsp.device_type,version:this.joinRsp.version,channel:this.joinRsp.channel,sid:this.joinRsp.sid,is_audience:!0,join_at:Math.floor((new Date).getTime()/1e3)};this.me=this.newUser(e),this.users.set(this.joinRsp.uid,this.me)}this.autoSubscribeExistingTracks()}this.heartbeatIntervalID&&clearInterval(this.heartbeatIntervalID);let t=this.heartbeatIntervalID=setInterval((()=>this.heartbeat()),3e4);this.logger.debug("channel heartbeat interval started",t),this.connectState=cr.CONNECTED}autoSubscribeExistingTracks(){if(this.options.autoSubscribeAudio||this.options.autoSubscribeVideo)for(const[e,t]of this.users){if(e===this.joinRsp.uid)continue;const r=t.getTracks();for(const t in r){const i=r[t];i.variant||(this.options.autoSubscribeAudio&&i.kind===U.Audio&&this.subscribeRemoteAudioTrack(e,t),this.options.autoSubscribeVideo&&i.kind===U.Video&&this.subscribeRemoteVideoTrack(e,t))}}}checkConnected(){if(this.connectState!=cr.CONNECTED)switch(this.connectState){case cr.RECONNECTING:throw new R("网络重连中,请稍后");case cr.LEAVED:throw new R("您已离开频道")}}addSocketListeners(){this.onConnected=this.onConnected.bind(this),this.onStartReconnect=this.onStartReconnect.bind(this),this.onChannelMessage=this.onChannelMessage.bind(this),this.rtcSocket.on(qt.CONNECTED,this.onConnected),this.rtcSocket.on(qt.RECONNECTING,this.onStartReconnect),this.rtcSocket.on(qt.CHANNEL_MESSAGE,this.onChannelMessage)}removeSocketListeners(){this.rtcSocket.off(qt.CONNECTED,this.onConnected),this.rtcSocket.off(qt.RECONNECTING,this.onStartReconnect),this.rtcSocket.off(qt.CHANNEL_MESSAGE,this.onChannelMessage)}triggerEvent(e,...t){const r=t[0];try{const t={type:e,data:r};this.emit(e,t),this.onNotifyEvent&&this.onNotifyEvent(t),this.eventCB&&this.eventCB(t)}catch(t){this.logger.error(`事件${e}上层响应出错,请sdk调用者检查`,t,r)}}async heartbeat(){let e=this.heartbeatIntervalID;if(this.connectState!=cr.CONNECTED)throw this.logger.info(`异常channel心跳,当前频道状态${this.connectState}`),clearInterval(e),new R(`异常channel心跳,频道状态为:${this.connectState}`);try{await this.rtcApi.heartbeat()}catch(e){this.logger.error("channel心跳失败",e),e instanceof R&&this.leave(o.Error,e)}this.logger.debug("channel heartbeat interval",e)}async onConnected(){let e=this.connectState;this.logger.warn(e==cr.RECONNECTING?"会控socket重连成功":"会控socket连接成功");try{this.connectState=cr.CONNECTED,await this.refresh(e==cr.RECONNECTING),e==cr.RECONNECTING?this.triggerEvent(n.RECONNECTED):this.triggerEvent(n.JOIN_SUCCEED,this.getInfo())}catch(e){this.leave(o.Error,e)}}onStartReconnect(){this.logger.warn("会控socket开始重连"),clearInterval(this.heartbeatIntervalID),this.connectState=cr.RECONNECTING,this.triggerEvent(n.RECONNECTING)}onChannelMessage(e,t){switch(t.type){case ne.ChannelUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;this.info.props=e.props,this.info.updated_at=e.updated_at,this.triggerEvent(n.CHANNEL_UPDATE,this.getInfo());break}case ne.ChannelDestroy:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;this.leave(o.Destroy);break}case ne.UserUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;let r=this.users.get(e.uid);r&&(r.updateInfo(e),this.triggerEvent(e.sid==this.joinRsp.sid?n.ME_UPDATE:n.USER_UPDATE,r.getInfo()));break}case ne.UserLeave:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;if(e.sid==this.joinRsp.sid)this.leave(e.reason);else{let t=this.users.get(e.uid);if(!t)return void this.logger.error(`收到用户${e.uid}离开消息,但其不在频道内`);for(const e in t.getTracks()){let r=t.getTracks()[e];this.rtcStreamEngine.haveSubscribed(r)&&this.unsubscribeRemoteTrack(r,0)}this.users.del(e.uid),this.triggerEvent(n.USER_LEAVE,{uid:e.uid,reason:e.reason})}break}case ne.UserJoin:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel||e.sid==this.joinRsp.sid)return;let r=this.users.get(e.uid);if(r){this.logger.warn(`收到成员${e.uid}(${e.name})入会消息,但其已经在频道内,先模拟一次离开频道`);for(const e in r.getTracks()){let t=r.getTracks()[e];this.rtcStreamEngine.haveSubscribed(t)&&this.unsubscribeRemoteTrack(t,0)}this.users.del(e.uid),this.triggerEvent(n.USER_LEAVE,{uid:e.uid,reason:o.Error})}r=this.newUser(e),this.users.set(e.uid,r),this.triggerEvent(n.USER_JOIN,r.getInfo());break}case ne.StreamUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel||e.sid==this.joinRsp.sid)return;let r=this.users.get(e.uid),{added:i,updated:o,deleted:s}=r.updateTracks(e.stream_tracks),a=r.getInfo();s.forEach((e=>{this.rtcStreamEngine.haveSubscribed(e)&&this.unsubscribeRemoteTrack(e,0),"stopPlay"in e&&"function"==typeof e.stopPlay&&e.stopPlay(),"removeAllPlayViews"in e&&"function"==typeof e.removeAllPlayViews&&e.removeAllPlayViews(),this.triggerEvent(n.USER_TRACK_REMOVE,{user:a,track:e.getInfo()})})),o.forEach((e=>{this.triggerEvent(n.USER_TRACK_UPDATE,{user:a,track:e.getInfo()})})),i.forEach((e=>{!e.variant&&this.options.autoSubscribeAudio&&e.kind==U.Audio&&this.subscribeRemoteAudioTrack(a.uid,e.id),!e.variant&&this.options.autoSubscribeVideo&&e.kind==U.Video&&this.subscribeRemoteVideoTrack(a.uid,e.id),this.triggerEvent(n.USER_TRACK_ADD,{user:a,track:e.getInfo()})})),this.triggerEvent(n.USER_UPDATE,a);break}case ne.Custom:{const r=t.data;if(!r||r.channel!=this.joinRsp.channel)return;r.private=-1!==e.indexOf("/channel-user/"),this.triggerEvent(n.CUSTOM_MSG,r);break}}}getMe(){if(!this.me)throw new R("尚未获取到自己信息");return this.me}getUser(e){let t=this.users.get(e);if(!t)throw new R(`频道内没有用户${e}`);return t}getUsersInfo(e){return this.users.listInfo(e)}async leave(e=o.Self,t){if(this.connectState!==cr.LEAVED){clearInterval(this.heartbeatIntervalID),this.removeSocketListeners();try{await this.rtcSocket.close()}catch(e){this.logger.error("断开会控socket报错",e)}try{await this.rtcApi.leave()}catch(e){this.logger.error("调离开频道api报错",e)}try{await this.rtcStreamEngine.disconnect()}catch(e){this.logger.error("断开流媒体引擎报错",e)}this.connectState=cr.LEAVED,[...this.publishRecords.keys()].forEach((e=>this.deletePublishRecord(e))),this.logger.info("leaved channel",this.joinRsp.channel,e),this.logger.center?.flush(),this.triggerEvent(n.DISCONNECTED,{reason:e,error:t}),this.removeAllListeners(),this.eventCB=null,this.onNotifyEvent=null}}getInfo(){let e={...this.info};return e.props={...e.props},e}addStreamEngineListeners(){}getStreamEngineVendor(){return this.rtcStreamEngine.vendor()}async getPublishExOption(e,t){return{}}getPublishRecord(e){return this.publishRecords.get(e)}getPublishInfo(e){let t=this.publishRecords.get(e);if(!t)return;let r={...t.info};return r.props={...r.props},r}updatePublishInfo(e,t){let r=this.publishRecords.get(e);r&&_(r.info,t).length>0&&e.emitInfoUpdate()}newPublishRecord(e,t){let r={info:e.getRawInfo(),uid:""};return _(r.info,t),this.publishRecords.set(e,r),e.publishState.retain(this),r}createPublishRecords(e,t){if(e.kind==U.Audio){let r=t;this.newPublishRecord(e,m({desc:r.desc,codec:r.codec,bitrate:r.maxBitrate,props:r.props}))}else{let r=t;this.newPublishRecord(e,m({desc:r.desc,codec:r.codec,width:r.width,height:r.height,fps:r.maxFramerate,bitrate:r.maxBitrate,props:r.props}))}return[e]}getDeletedTracksAfterUnpublish(e){return this.publishRecords.has(e)?[e]:[]}deletePublishRecord(e){this.publishRecords.delete(e),e.publishState.release(this)}resolvePublishOptions(e,t){let r=e.publishState.defaultPublishOptions;if(r&&t!==r&&(t&&_(r,t),t=r),!t)throw new R("轨道发布配置不能为空");return t}async publishLocalTrack(e,t){const r=this.resolvePublishOptions(e,t);if(!r.desc)throw new R("轨道发布描述不能为空");e.publishState.count>0&&!this.getPublishRecord(e)&&this.logger.warn(e.toString(),"已发布到其它频道,本次为多频道发布;多频道期间 track.getInfo() 会抛错,请用 channel.getPublishInfo(track) 查询指定频道内的轨道描述");const i=[...this.publishRecords].find((([t,i])=>t!==e&&i.info.desc===r.desc));if(i)throw new R(`desc[${r.desc}] 已被 ${i[0].toString()} 占用,同一描述不能重复发布`);let o=this.getMe();const s=await this.lockTrack(e.id);try{let t=this.createPublishRecords(e,r);try{let t=await this.getPublishExOption(e,r);await this.rtcStreamEngine.publish(e,r,t)}catch(e){throw t.forEach((e=>this.deletePublishRecord(e))),e}try{let e=[...this.publishRecords].filter((([e])=>!t.includes(e))).map((([,e])=>e.info));e.push(...t.map((e=>this.publishRecords.get(e).info))),await this.rtcApi.updateStream(e),t.forEach((e=>{let t=this.publishRecords.get(e);t.uid=o.uid,o.getTracks()[t.info.id]=e})),o.updateInfo({stream_tracks:e}),this.triggerEvent(n.ME_UPDATE,o.getInfo())}catch(t){throw this.unpublishLocalTrack(e),t}return this.getPublishInfo(e)}finally{s()}}setLogCenter(e){this.logger.center=e}getLogCenter(){return this.logger.center}getLocalTracks(){return this.me?Object.values(this.me.getTracks()):[]}async unpublishLocalTrack(e){let t=this.getMe();const r=await this.lockTrack(e.id);try{let r=[...this.publishRecords.values()].map((e=>e.info));if(!this.publishRecords.has(e))return void this.logger.warn(e.toString()+"已取消发布,无需再次取消发布");let i=this.getDeletedTracksAfterUnpublish(e),o=i.map((e=>this.publishRecords.get(e).info.id)),s=r.filter((e=>!o.includes(e.id)));await this.rtcApi.updateStream(s);try{await this.rtcStreamEngine.unpublish(e),i.forEach((e=>{delete t.getTracks()[this.publishRecords.get(e).info.id],this.deletePublishRecord(e)})),t.updateInfo({stream_tracks:s}),this.triggerEvent(n.ME_UPDATE,t.getInfo())}catch(e){throw await this.rtcApi.updateStream(r),e}}finally{r()}}async getSubscribeExOption(e){return{}}async subscribeRemoteAudioMixTrack(e){let t=this.audioMixTrack;if(t)if("RemoteAudioMixTrack"===t.__type){let r=t.getFilterUids(),i=[];e&&Array.isArray(e)&&(i=e),r.join(",")!==i.join(",")&&this.rtcStreamEngine.haveSubscribed(t)&&await this.unsubscribeRemoteTrack(t,0)}else t.stop(),this.audioMixTrack=t=void 0;t||(t=this.newRemoteAudioMixTrack(e));const r=await this.lockTrack(t.id);try{if("RemoteAudioMixTrack"===t.__type){let e=await this.getSubscribeExOption(t);await this.rtcStreamEngine.subscribe(t,e)}else if("MockRemoteAudioMixTrack"===t.__type){this.options.autoSubscribeAudio=!0;for(const[e,r]of this.users){if(e===this.joinRsp.uid)continue;let i=r.getTracks();for(const r in i){let n=i[r];n.kind!==U.Audio||t.checkFilter(n)||(this.subscribeRemoteAudioTrack(e,r),t.addTrack(n))}}}return this.audioMixTrack=t,t}finally{r()}}async subscribeRemoteAudioTrack(e,t){let r=this.getUser(e),i=r.getTrack(t);if(!i)throw M(e+"没有id为"+t+"的音频流");if(i.kind!=U.Audio)throw new R(e+"id为"+t+"的流非音频,而是"+i.kind);const n=e===this.joinRsp.uid?r.spawnTrack(i.getInfo()):i,o=await this.lockTrack(i.id);try{let t=await this.getSubscribeExOption(n);return await this.rtcStreamEngine.subscribe(n,t),e!==this.joinRsp.uid&&this.audioMixTrack&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type&&!this.audioMixTrack.checkFilter(i)&&this.audioMixTrack.addTrack(i),n}finally{o()}}async subscribeRemoteVideoMcuTrack(){let e=this.videoMcuTrack;e||(e=this.newRemoteVideoMcuTrack());const t=await this.lockTrack(e.id);try{let t=await this.getSubscribeExOption(e);return await this.rtcStreamEngine.subscribe(e,t),this.videoMcuTrack=e,e}finally{t()}}async subscribeRemoteAudioMcuTrack(){let e=this.audioMcuTrack;e||(e=this.newRemoteAudioMcuTrack());const t=await this.lockTrack(e.id);try{let t=await this.getSubscribeExOption(e);return await this.rtcStreamEngine.subscribe(e,t),this.audioMcuTrack=e,e}finally{t()}}async subscribeRemoteVideoTrack(e,t){let r=this.getUser(e),i=r.getTrack(t);if(!i)throw M(e+"没有id为"+t+"的视频流");if(i.kind!=U.Video)throw new R(e+"id为"+t+"的流非视频,而是"+i.kind);const n=e===this.joinRsp.uid?r.spawnTrack(i.getInfo()):i;this.trackDebounce[i.id]?.cancel("subscribe");const o=await this.lockTrack(i.id);try{let e=await this.getSubscribeExOption(n);return await this.rtcStreamEngine.subscribe(n,e),n}finally{o()}}async unsubscribeRemoteTrack(e,t=2e3){if(t<=0){const t=await this.lockTrack(e.id);try{this.audioMixTrack&&this.audioMixTrack===e&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type?(this.audioMixTrack.stop(),this.audioMixTrack=void 0):(await this.rtcStreamEngine.unsubscribe(e),e.kind===U.Audio&&this.audioMixTrack&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type&&this.audioMixTrack.removeTrack(e))}finally{t()}return}(this.trackDebounce[e.id]=sr((async()=>{await this.unsubscribeRemoteTrack(e,0)}),2e3))().catch((t=>{this.logger.warn(e.toString()+"取消订阅动作被终止",t)}))}async lockTrack(e){let t=this.trackMutex[e];return t||(this.trackMutex[e]=t=new b),t.lock()}}class lr extends n{static DEVICE_ADD="device_add";static DEVICE_REMOVE="device_remove";static TRACK_AUTOPLAY_FAIL="track_autoplay_fail";static TRACK_PIP_ENTER="track_pip_enter";static TRACK_PIP_EXIT="track_pip_exit";static TRACK_POPOUT_OPEN="track_popout_open";static TRACK_POPOUT_CLOSE="track_popout_close";static CONNECTION_QUALITY_CHANGED="connection_quality_changed";static CPU_CONSTRAINED="cpu_constrained";static BANDWIDTH_CONSTRAINED="bandwidth_constrained";static ACTIVE_SPEAKERS_CHANGED="active_speakers_changed"}class hr extends s{static AUTOPLAY_FAIL="autoplay_fail";static MSTRACK_REPLACED="mstrack_replaced";static RECONNECTING="reconnecting";static RECONNECTED="reconnected";static PIP_ENTER="pip_enter";static PIP_EXIT="pip_exit";static POPOUT_OPEN="popout_open";static POPOUT_CLOSE="popout_close"}let dr=function(e){return e.ActiveSpeakersChanged="activeSpeakersChanged",e}({}),fr=function(e){return e.Unknown="unknown",e.Excellent="excellent",e.Good="good",e.Poor="poor",e.Lost="lost",e}({}),pr=function(e){return e.ConnectionQualityChanged="connectionQualityChanged",e.CpuConstrained="cpuConstrained",e.BandwidthConstrained="bandwidthConstrained",e.NetworkUnstable="networkUnstable",e}({});const gr={scoreGood:80,scorePoor:40,scoreLost:20,packetLossWeight:8,emaIncrease:.4,emaDecrease:.8,scoreFloor:30};class mr{thresholds;lostSampleCount;constraintSampleCount;uplinkScore=100;downlinkScore=100;lastEvaluation;noTrafficCount=0;cpuLimitedCount=0;bwLimitedCount=0;prevFreezeTotal=0;hasSample=!1;constructor(e={}){this.thresholds=e.thresholds??gr,this.lostSampleCount=e.lostSampleCount??3,this.constraintSampleCount=e.constraintSampleCount??2}update(e){const t=this.extractSample(e);this.noTrafficCount=t.hasTraffic?0:this.noTrafficCount+1,this.cpuLimitedCount=t.cpuLimited?this.cpuLimitedCount+1:0,this.bwLimitedCount=t.bwLimited?this.bwLimitedCount+1:0;const r=this.packetScore(t.uplinkLoss,t.uplinkRtt,t.uplinkJitter),i=this.packetScore(t.downlinkLoss,t.downlinkRtt,t.downlinkJitter);this.uplinkScore=this.hasSample?this.emaMerge(this.uplinkScore,r):r,this.downlinkScore=this.hasSample?this.emaMerge(this.downlinkScore,i):i,this.hasSample=!0;const n=this.evaluate(t);return this.lastEvaluation=n,n}shouldEmitCpuConstrained(){return this.cpuLimitedCount===this.constraintSampleCount}shouldEmitBandwidthConstrained(){return this.bwLimitedCount===this.constraintSampleCount}getLastEvaluation(){return this.lastEvaluation}reset(){this.uplinkScore=100,this.downlinkScore=100,this.lastEvaluation=void 0,this.noTrafficCount=0,this.cpuLimitedCount=0,this.bwLimitedCount=0,this.prevFreezeTotal=0,this.hasSample=!1}extractSample(e){const t=e.network,r=[...e.local_audios||[],...e.local_videos||[]],i=[...e.remote_audios||[],...e.remote_videos||[]];let n=t?.rtt_up??0;if(0===n){let e=0,t=0;for(const i of r){const r=i.stats;null!=r?.roundTripTime&&(e+=r.roundTripTime,t++)}t>0&&(n=e/t)}let o=t?.rtt_down??0;0===o&&(o=n);let s=!1,a=!1;for(const e of r){const t=e.stats;"cpu"===t?.qualityLimitationReason&&(s=!0),"bandwidth"===t?.qualityLimitationReason&&(a=!0)}let c=0,u=0;for(const e of r){const t=e.stats;null!=t?.jitter&&(c+=t.jitter,u++)}let l=0,h=0,d=0;for(const e of i){const t=e.stats;null!=t?.jitter&&(l+=t.jitter,h++),"number"==typeof t?.freezeCount&&(d+=t.freezeCount)}const f=0===this.prevFreezeTotal?0:Math.max(0,d-this.prevFreezeTotal);this.prevFreezeTotal=d;const p=t?.available_outgoing_bitrate??0,g=p>0&&t?.bitrate_up?t.bitrate_up/p:0,m=r.length>0||i.length>0,y=(t?.bitrate_up??0)>0||(t?.bitrate_down??0)>0;return{timestamp:Date.now(),uplinkLoss:t?.lossrate_up??0,downlinkLoss:t?.lossrate_down??0,uplinkRtt:n,downlinkRtt:o,uplinkJitter:u?c/u:0,downlinkJitter:h?l/h:0,cpuLimited:s,bwLimited:a,hasActiveTrack:m,hasTraffic:y,freezeDelta:f,uplinkBwPressure:g}}packetScore(e,t,r){const i=t/2+2*r;let n;n=i<=160?i/40:(i-120)/10;const o=100-n-e*this.thresholds.packetLossWeight;return Math.max(0,Math.min(100,o))}emaMerge(e,t){const r=t<e?this.thresholds.emaDecrease:this.thresholds.emaIncrease,i=r*t+(1-r)*e;return Math.max(this.thresholds.scoreFloor,i)}scoreToQuality(e){const t=this.thresholds;return e>t.scoreGood?fr.Excellent:e>t.scorePoor?fr.Good:e>t.scoreLost?fr.Poor:fr.Lost}scoreToMos(e){if(e<=0)return 1;if(e>=100)return 4.5;const t=1+.035*e+7e-6*e*(e-60)*(100-e);return Number(Math.max(1,Math.min(4.5,t)).toFixed(2))}evaluate(e){const t=[];if(e.hasActiveTrack&&this.noTrafficCount>=this.lostSampleCount)return t.push(`连续${this.noTrafficCount}次无流量`),{uplink:fr.Lost,downlink:fr.Lost,overall:fr.Lost,mos:1,reasons:t,timestamp:e.timestamp};if(!this.hasSample)return{uplink:fr.Unknown,downlink:fr.Unknown,overall:fr.Unknown,mos:4,reasons:["采样不足"],timestamp:e.timestamp};let r=this.scoreToQuality(this.uplinkScore),i=this.scoreToQuality(this.downlinkScore);this.cpuLimitedCount>=this.constraintSampleCount&&(t.push("cpu 持续限制"),r=vr(r,fr.Poor)),this.bwLimitedCount>=this.constraintSampleCount&&(t.push("带宽持续限制"),r=vr(r,fr.Poor)),e.uplinkBwPressure>=.9&&(t.push(`上行带宽压力 ${(100*e.uplinkBwPressure).toFixed(0)}%`),r=vr(r,fr.Good)),e.freezeDelta>0&&e.downlinkLoss>1?(t.push(`下行卡顿 ${e.freezeDelta} 次 + 丢包 ${e.downlinkLoss.toFixed(1)}%`),i=vr(i,fr.Poor)):e.freezeDelta>0&&t.push(`下行卡顿 ${e.freezeDelta} 次(无本端丢包,疑似发布方问题)`),t.push(`score up=${this.uplinkScore.toFixed(0)} down=${this.downlinkScore.toFixed(0)}`);return{uplink:r,downlink:i,overall:vr(r,i),mos:this.scoreToMos(Math.min(this.uplinkScore,this.downlinkScore)),reasons:t,timestamp:e.timestamp}}}const yr={[fr.Unknown]:0,[fr.Excellent]:1,[fr.Good]:2,[fr.Poor]:3,[fr.Lost]:4};function vr(e,t){return e===fr.Unknown?t:t===fr.Unknown||yr[e]>=yr[t]?e:t}class br extends z{mediaStream;mediaStreamTrack;constructor(e,t){super(e,t),this.onMute=this.onMute.bind(this),this.onUnmute=this.onUnmute.bind(this),this.onEnded=this.onEnded.bind(this),this.mediaStream=new MediaStream}addMsTrackListeners(e){e.addEventListener("mute",this.onMute),e.addEventListener("unmute",this.onUnmute),e.addEventListener("ended",this.onEnded)}removeMsTrackListeners(e){e.removeEventListener("mute",this.onMute),e.removeEventListener("unmute",this.onUnmute),e.removeEventListener("ended",this.onEnded)}onMute(){ie.info(this.toString(),"muted"),this.emit(s.MUTED,this)}onUnmute(){ie.info(this.toString(),"unmuted"),this.emit(s.UNMUTED,this)}onEnded(){ie.info(this.toString(),"ended"),this.emit(s.ENDED,this)}setMediaStreamTrack(e){let t=this.mediaStreamTrack;if(t!=e){if(t&&(this.mediaStream.removeTrack(t),this.removeMsTrackListeners(t)),this.mediaStreamTrack=e,e){this.mediaStream.addTrack(e),this.addMsTrackListeners(e);let t=e.getSettings();ie.debug(this.toString(),"实际采集到的mstrack设置",t)}this.emit(hr.MSTRACK_REPLACED,this,t)}}getMediaStreamTrack(){return this.mediaStreamTrack}getMediaStream(){return this.mediaStream}}class wr{track;rtpReceiver;targetMs;constructor(e,t){this.track=e,this.targetMs=t}setRtpReceiver(e){if(!e)return this.apply(void 0),void(this.rtpReceiver=void 0);this.rtpReceiver=e,this.apply(this.targetMs)}setTarget(e){this.targetMs=e,this.apply(e)}getTarget(){return this.targetMs}apply(e){const t=this.rtpReceiver;if(t)try{"jitterBufferTarget"in t&&(t.jitterBufferTarget=null==e?null:Math.min(Math.max(e,0),4e3)),"playoutDelayHint"in t&&(t.playoutDelayHint=null==e?void 0:e/1e3)}catch(e){ie.warn(this.track.toString(),"设置 jitterBufferTarget 失败",e)}}}class kr{track;audioElements;constructor(e){this.track=e,this.audioElements=[]}isPlaying(){return this.audioElements.length>0}destroyAudioElement(e){e.srcObject=null,e.remove()}async startPlay(e){this.stopPlay();let t=this.track.getMediaStreamTrack();if(!t)throw new R(this.track.toString()+"的mediaStreamTrack不存在,无法播放声音");const r=t.context;if(r&&"running"!==r.state){try{await Promise.race([r.resume(),new Promise(((e,t)=>setTimeout((()=>t(new Error("resume timeout"))),500)))])}catch(e){ie.warn("混音音频上下文恢复失败或超时",e)}if("running"!==r.state)return!1}let i=document.createElement("audio");return i.autoplay=!1,i.srcObject=this.track.getMediaStream(),i.style.display="none",document.body.appendChild(i),e?.deviceId&&("setSinkId"in i?await i.setSinkId(e.deviceId):ie.error("当前环境不支持setSinkId,将从默认扬声器播放")),e?.volume&&(i.volume=e.volume),i.addEventListener("pause",(()=>{i.play().catch((e=>{console.error("音频暂停,尝试恢复播放失败",e)}))})),new Promise((async(e,t)=>{let r=setTimeout((()=>{ie.warn("音频play超时未响应,默认视为浏览器权限问题处理"),this.destroyAudioElement(i),e(!1)}),1e3);try{await i.play(),clearTimeout(r),this.audioElements.push(i),e(!0)}catch(n){clearTimeout(r),this.destroyAudioElement(i),n instanceof DOMException&&"NotAllowedError"===n.name?e(!1):t(new R(this.track.toString()+"自动播放失败:"+n))}}))}stopPlay(){this.audioElements.forEach((e=>this.destroyAudioElement(e))),this.audioElements=[]}setVolume(e){this.audioElements.forEach((t=>t.volume=e))}}class _r{track;videoElements;resizeObserver;intersectionObserver;pipStates=new Map;popOutStates=new Map;hiddenOriginViews=new Map;playViewStates=new Map;detachedViewStates=new Map;elementIds=new WeakMap;nextElementId=0;isAppHidden="undefined"!=typeof document&&"hidden"===document.visibilityState;onAdaptiveStateChange;constructor(e,t){this.track=e,this.videoElements=[],this.onAdaptiveStateChange=t,this.track.on(hr.INFO_UPDATE,(()=>{this.videoElements.forEach((e=>{this.freshTransform(e)}))})),this.track.on(hr.MSTRACK_REPLACED,(()=>{this.videoElements.forEach((e=>{this.freshTransform(e)}))})),this.resizeObserver=new ResizeObserver((e=>{for(const t of e){const e=this.videoElements.find((e=>e.parentElement===t.target));e&&(this.freshTransform(e),this.updatePlayViewState(t.target,{width:t.target.clientWidth,height:t.target.clientHeight}))}})),"undefined"!=typeof IntersectionObserver&&(this.intersectionObserver=new IntersectionObserver((e=>{for(const t of e)this.updatePlayViewState(t.target,{visible:t.isIntersecting&&this.isElementRenderable(t.target)})}),{threshold:[0,.01]}))}addPlayView(e){if(!this.track.getMediaStreamTrack())throw new R(this.track.toString()+"的mediaStreamTrack不存在,无法添加播放view");if(this.videoElements.find((t=>t.parentElement==e)))return;"static"===getComputedStyle(e).position&&(e.style.position="relative"),e.style.overflow="hidden";let t=document.createElement("video");t.muted=!0,t.controls=!1,t.playsInline=!0,t.style.objectFit="contain",t.onloadedmetadata=()=>{this.freshTransform(t)},t.srcObject=this.track.getMediaStream(),"safari"===rr().browser?.name?.toLowerCase()||"firefox"===rr()?.browser?.name?.toLowerCase()?setTimeout((()=>{t.srcObject=this.track.getMediaStream(),t.play().catch((e=>{console.error("视频播放失败",e)}))}),0):t.autoplay=!0,("miniprogram"===window.__wxjs_environment||navigator?.userAgent.toLowerCase().includes("miniprogram")||navigator?.userAgent.toLowerCase().includes("micromessenger"))&&t.play().catch((e=>{Sr.show(this.track.id,this.track.desc,(()=>{t.play().catch((e=>{console.error("视频播放失败",e)}))}))})),t.addEventListener("pause",(()=>{t.play().catch((e=>{console.error("视频暂停,尝试恢复播放失败",e)}))})),e.appendChild(t),this.videoElements.push(t),this.resizeObserver.observe(e),this.intersectionObserver?.observe(e),this.playViewStates.set(e,this.snapshotPlayViewState(e)),this.emitAdaptiveState(),1==this.videoElements.length&&this.watchAppShowHide()}onAppShowHide=()=>{this.isAppHidden="hidden"===document.visibilityState,this.emitAdaptiveState(),"hidden"!==document.visibilityState&&this.videoElements.forEach((e=>{e.play().catch((e=>{console.error("视频播放失败",e)}))}))};watchAppShowHide(){document.addEventListener("visibilitychange",this.onAppShowHide)}unwatchAppShowHide(){document.removeEventListener("visibilitychange",this.onAppShowHide)}needSwapDimensions(e){return 1129136434===e||1129136441===e}freshTransform(e){const t=e.parentElement;if(!t)return;const r=this.track.angle,i=t.clientWidth,n=t.clientHeight;switch(e.style.position="absolute",e.style.left="50%",e.style.top="50%",this.needSwapDimensions(r)?(e.style.width=`${n}px`,e.style.height=`${i}px`):(e.style.width=`${i}px`,e.style.height=`${n}px`),r){case 1129136434:e.style.transform="translate(-50%, -50%) rotate(270deg)";break;case 1129136433:e.style.transform="translate(-50%, -50%) rotate(180deg)";break;case 1129136441:e.style.transform="translate(-50%, -50%) rotateY(180deg) rotate(-90deg)";break;default:e.style.transform="translate(-50%, -50%)"}this.shouldMirrorView()&&(e.style.transform+=" scaleX(-1)")}shouldMirrorView(){const e=this.track;return"function"==typeof e.isMirrored&&e.isMirrored()}refreshTransform(){this.videoElements.forEach((e=>this.freshTransform(e))),this.popOutStates.forEach((e=>{this.freshTransformForPopOut(e.video,e.handle.window)})),this.pipStates.forEach((e=>{e.pipVideo&&e.pipWindow&&this.freshTransformForPopOut(e.pipVideo,e.pipWindow)}))}hasPlayView(){return this.videoElements.length>0}removePlayView(e){this.cleanupPipState(e),this.cleanupPopOutState(e),this.restoreOriginView(e);let t=this.videoElements.findIndex((t=>t.parentElement==e));t>=0&&(this.resizeObserver.unobserve(e),this.intersectionObserver?.unobserve(e),this.playViewStates.delete(e),this.videoElements[t].remove(),this.videoElements.splice(t,1),this.emitAdaptiveState()),0==this.videoElements.length&&this.unwatchAppShowHide()}removeAllPlayViews(){this.hiddenOriginViews.clear(),this.exitAllPictureInPicture(),this.closeAllPopOutWindows(),this.videoElements.forEach((e=>{e.parentElement&&(this.resizeObserver.unobserve(e.parentElement),this.intersectionObserver?.unobserve(e.parentElement)),e.remove()})),this.videoElements=[],this.playViewStates.clear(),this.detachedViewStates.clear(),this.unwatchAppShowHide(),this.emitAdaptiveState()}destroy(){this.removeAllPlayViews(),this.resizeObserver.disconnect(),this.intersectionObserver?.disconnect()}async enterPictureInPicture(e,t){const r=this.videoElements.find((t=>t.parentElement===e));if(!r)throw new R(this.track.toString()+" 未找到该容器对应的播放视频,请先调用addPlayView");this.pipStates.has(e)&&await this.exitPictureInPicture(e);const i=!1!==t?.preferDocumentPip,n=t?.width||320,o=t?.height||240,s=!1!==t?.hideOriginView;if(i&&"documentPictureInPicture"in window)return this.enterDocumentPip(e,n,o,s);if("requestPictureInPicture"in r)return this.enterVideoPip(e,r);throw new R("当前浏览器不支持画中画功能")}async enterDocumentPip(e,t,r,i){const n=window.documentPictureInPicture,o=await n.requestWindow({width:t,height:r}),s=o.document.createElement("style");s.textContent="\n body { margin: 0; background: #000; overflow: hidden; width: 100vw; height: 100vh; }\n video { width: 100%; height: 100%; object-fit: contain; }\n ",o.document.head.appendChild(s);const a=o.document.createElement("video");a.muted=!0,a.autoplay=!0,a.playsInline=!0,a.srcObject=this.track.getMediaStream(),o.document.body.appendChild(a);const c=this.getDetachedViewKey("doc-pip",e),u=()=>{this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState)};o.document.addEventListener("visibilitychange",u);const l=new ResizeObserver((()=>{this.freshTransformForPopOut(a,o),this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState)}));l.observe(o.document.body),this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState);const h=()=>{a.srcObject=this.track.getMediaStream()};this.track.on(hr.MSTRACK_REPLACED,h);const d={type:"document-pip",pipWindow:o,exit:async()=>{this.cleanupPipState(e)}},f=()=>{this.cleanupPipState(e)};return o.addEventListener("pagehide",f),i&&this.hideOriginView(e),this.pipStates.set(e,{container:e,handle:d,pipVideo:a,pipWindow:o,hideOriginView:i,cleanup:()=>{o.removeEventListener("pagehide",f),o.document.removeEventListener("visibilitychange",u),this.track.off(hr.MSTRACK_REPLACED,h),l.disconnect(),this.removeDetachedViewState(c),a.srcObject=null,o.closed||o.close(),i&&this.restoreOriginView(e),this.track.emit(hr.PIP_EXIT,this.track)}}),this.track.emit(hr.PIP_ENTER,this.track),this.emitAdaptiveState(),d}async enterVideoPip(e,t){await t.requestPictureInPicture();const r={type:"video-pip",exit:async()=>{this.cleanupPipState(e)}},i=()=>{this.cleanupPipState(e)};return t.addEventListener("leavepictureinpicture",i),this.pipStates.set(e,{container:e,handle:r,hideOriginView:!1,cleanup:()=>{t.removeEventListener("leavepictureinpicture",i),document.pictureInPictureElement===t&&document.exitPictureInPicture().catch((()=>{})),this.track.emit(hr.PIP_EXIT,this.track)}}),this.track.emit(hr.PIP_ENTER,this.track),this.updateDetachedViewState(this.getDetachedViewKey("video-pip",e),t.clientWidth,t.clientHeight,!0),this.emitAdaptiveState(),r}cleanupPipState(e){const t=this.pipStates.get(e);t&&(this.pipStates.delete(e),this.removeDetachedViewState(this.getDetachedViewKey("doc-pip",e)),this.removeDetachedViewState(this.getDetachedViewKey("video-pip",e)),t.cleanup(),this.emitAdaptiveState())}async exitPictureInPicture(e){this.cleanupPipState(e)}isPictureInPicture(e){return this.pipStates.has(e)}exitAllPictureInPicture(){[...this.pipStates.keys()].forEach((e=>this.cleanupPipState(e)))}popOutToWindow(e,t){if(!this.videoElements.find((t=>t.parentElement===e)))throw new R(this.track.toString()+" 未找到该容器对应的播放视频,请先调用addPlayView");this.popOutStates.has(e)&&this.closePopOutWindow(e);const r=t?.width||640,i=t?.height||480,n=t?.title||this.track.toString(),o=Math.round((screen.width-r)/2),s=Math.round((screen.height-i)/2),a=window.open("","_blank",`width=${r},height=${i},left=${o},top=${s},resizable=yes,scrollbars=no`);if(!a)throw new R("弹出窗口被浏览器拦截,请允许弹窗权限");a.document.title=n;const c=a.document.createElement("style");c.textContent="\n body { margin: 0; background: #000; overflow: hidden; width: 100vw; height: 100vh; }\n video { width: 100%; height: 100%; object-fit: contain; }\n ",a.document.head.appendChild(c);const u=a.document.createElement("video");u.muted=!0,u.autoplay=!0,u.playsInline=!0,u.srcObject=this.track.getMediaStream(),a.document.body.appendChild(u);const l=this.getDetachedViewKey("popout",e),h=()=>{this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState)};a.document.addEventListener("visibilitychange",h);const d=new ResizeObserver((()=>{this.freshTransformForPopOut(u,a),this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState)}));d.observe(a.document.body),this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState);const f={window:a,moveBack:t=>{this.moveBackFromPopOut(e,t)},close:()=>{this.closePopOutWindow(e)}},p=()=>{this.cleanupPopOutState(e)};a.addEventListener("beforeunload",p);const g=()=>{u.srcObject=this.track.getMediaStream()};return this.track.on(hr.MSTRACK_REPLACED,g),this.popOutStates.set(e,{originContainer:e,handle:f,video:u,hideOriginView:!1!==t?.hideOriginView,cleanup:()=>{this.track.off(hr.MSTRACK_REPLACED,g),a.removeEventListener("beforeunload",p),a.document.removeEventListener("visibilitychange",h),d.disconnect(),this.removeDetachedViewState(l),u.srcObject=null,a.closed||a.close(),!1!==t?.hideOriginView&&this.restoreOriginView(e),this.track.emit(hr.POPOUT_CLOSE,this.track)}}),!1!==t?.hideOriginView&&this.hideOriginView(e),this.track.emit(hr.POPOUT_OPEN,this.track),this.emitAdaptiveState(),f}freshTransformForPopOut(e,t){const r=this.track.angle,i=t.innerWidth,n=t.innerHeight;switch(e.style.position="absolute",e.style.left="50%",e.style.top="50%",this.needSwapDimensions(r)?(e.style.width=`${n}px`,e.style.height=`${i}px`):(e.style.width=`${i}px`,e.style.height=`${n}px`),r){case 1129136434:e.style.transform="translate(-50%, -50%) rotate(270deg)";break;case 1129136433:e.style.transform="translate(-50%, -50%) rotate(180deg)";break;case 1129136441:e.style.transform="translate(-50%, -50%) rotateY(180deg) rotate(-90deg)";break;default:e.style.transform="translate(-50%, -50%)"}this.shouldMirrorView()&&(e.style.transform+=" scaleX(-1)")}moveBackFromPopOut(e,t){const r=this.popOutStates.get(e);r&&(r.cleanup(),this.popOutStates.delete(e),this.videoElements.find((e=>e.parentElement===t))||this.addPlayView(t))}closePopOutWindow(e){this.cleanupPopOutState(e)}cleanupPopOutState(e){const t=this.popOutStates.get(e);t&&(this.popOutStates.delete(e),this.removeDetachedViewState(this.getDetachedViewKey("popout",e)),t.cleanup(),this.emitAdaptiveState())}isPopOut(e){return this.popOutStates.has(e)}closeAllPopOutWindows(){[...this.popOutStates.keys()].forEach((e=>this.cleanupPopOutState(e)))}hideOriginView(e){const t=this.hiddenOriginViews.get(e);if(t)return void t.count++;const r=this.videoElements.find((t=>t.parentElement===e));r&&(this.hiddenOriginViews.set(e,{video:r,count:1,display:r.style.display}),r.style.display="none",this.updatePlayViewState(e,{visible:!1}))}restoreOriginView(e){const t=this.hiddenOriginViews.get(e);t&&(t.count--,t.count>0||(t.video.style.display=t.display,this.hiddenOriginViews.delete(e),this.freshTransform(t.video),this.updatePlayViewState(e,{visible:this.isElementVisible(e)}),t.video.play().catch((e=>{console.error("视频播放失败",e)}))))}refreshAdaptiveState(){this.emitAdaptiveState()}updatePlayViewState(e,t){const r=this.playViewStates.get(e)||this.snapshotPlayViewState(e);this.playViewStates.set(e,{...r,...t}),this.emitAdaptiveState()}updateDetachedViewState(e,t,r,i){this.detachedViewStates.set(e,{width:t,height:r,visible:i}),this.emitAdaptiveState()}removeDetachedViewState(e){this.detachedViewStates.delete(e)&&this.emitAdaptiveState()}emitAdaptiveState(){if(!this.onAdaptiveStateChange)return;let e=!1,t=0,r=0,i=0,n=!1;const o=(n,o)=>{if(!o)return;e=!0;const s=n.width*n.height;s>=i&&(i=s,t=n.width,r=n.height)};for(const e of this.playViewStates.values())o(e,e.visible&&!this.isAppHidden);for(const e of this.detachedViewStates.values())e.visible&&(n=!0),o(e,e.visible);this.onAdaptiveStateChange({viewCount:this.playViewStates.size+this.detachedViewStates.size,visible:e,width:t,height:r,inBackground:this.isAppHidden&&!n})}snapshotPlayViewState(e){return{width:e.clientWidth,height:e.clientHeight,visible:this.isElementVisible(e)}}getDetachedViewKey(e,t){let r=this.elementIds.get(t);return void 0===r&&(r=++this.nextElementId,this.elementIds.set(t,r)),`${e}:${this.track.id}:${r}`}isElementRenderable(e){const t=getComputedStyle(e);return!e.hidden&&"none"!==t.display&&"hidden"!==t.visibility}isElementVisible(e){if(!this.isElementRenderable(e))return!1;const t=e.getBoundingClientRect();return!(t.width<=0||t.height<=0)&&(t.bottom>0&&t.right>0&&t.top<window.innerHeight&&t.left<window.innerWidth)}}class Sr{static htmlTpl='<div id="$id$" class="autoplay-dialog-container">\n <div class="autoplay-dialog">\n <div class="autoplay-dialog-content">\n <p>因浏览器权限问题自动播放$desc$失败,点击恢复自动播放</p>\n </div>\n <div class="autoplay-dialog-actions">\n <button class="autoplay-dialog-button">确定</button>\n </div>\n </div>\n</div>';static cssTpl=".autoplay-dialog-container {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n}\n\n.autoplay-dialog {\n background-color: white;\n padding: 20px;\n border-radius: 5px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n text-align: center;\n}\n\n.autoplay-dialog-content {\n margin-bottom: 20px;\n}\n\n.autoplay-dialog-button {\n background-color: #007bff;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 5px;\n cursor: pointer;\n}";static callbacks=[];static isShowing=!1;static show(e,t,r){if(this.callbacks.push(r),this.isShowing)return;this.isShowing=!0;const i=document.createElement("style");i.textContent=this.cssTpl,document.head.appendChild(i);let n="autoplay-"+e,o=document.createElement("div");document.body.append(o),o.outerHTML=this.htmlTpl.replace("$id$",n).replace("$desc$",t),document.getElementById(n).onclick=e=>{i.remove(),e.currentTarget.remove();const t=this.callbacks.slice();this.callbacks=[],this.isShowing=!1,t.forEach((e=>{try{e()}catch(e){ie.error("AutoPlayDialog callback error",e)}}))}}}function Er(e){const t=new AudioContext,r=t.createMediaStreamDestination(),i=r.stream.getAudioTracks()[0];if(!i)throw new Error("Failed to create mixed audio track");i.context=t,i.trackCount=0;const n=t.createGain();let o,s;if(n.gain.value=0,n.connect(t.destination),i.speakerGain=n,e){o=t.createAnalyser(),o.fftSize=256;const r=o.frequencyBinCount,i=new Uint8Array(r),n=()=>{s=requestAnimationFrame(n),o.getByteFrequencyData(i);const t=e.canvas;e.fillStyle="rgb(0, 0, 0)",e.fillRect(0,0,t.width,t.height);const a=t.width/r*2.5;let c,u=0;for(let n=0;n<r;n++)c=i[n]/255*t.height,e.fillStyle=`rgb(${c+100}, 50, 50)`,e.fillRect(u,t.height-c/2,a,c/2),u+=a+1};n()}const a=new Map;return i.addTrack=e=>{if("ended"===e.readyState||!t||a.has(e))return;const s=new MediaStream([e]),c=t.createMediaStreamSource(s);o&&c.connect(o),c.connect(r),c.connect(n),a.set(e,{source:c,stream:s}),e.addEventListener("ended",(()=>{i.removeTrack(e)})),i.trackCount++},i.removeTrack=e=>{const t=a.get(e);t&&(t.source.disconnect(),a.delete(e),i.trackCount--)},i}class Tr{mediaStreamTrack;tracks;contextResumeRequested;speakerPlaying;warmupElements;constructor(){this.mediaStreamTrack=Er(),this.tracks={},this.contextResumeRequested=!1,this.speakerPlaying=!1,this.warmupElements={}}requestContextResumeIfNeeded(){const e=this.mediaStreamTrack?.context;e&&"running"!==e.state&&!this.contextResumeRequested&&(this.contextResumeRequested=!0,e.resume().catch((t=>{ie.warn("混音音频上下文自动恢复失败,等待用户交互",t),Sr.show(this.mediaStreamTrack.id,"混音音频",(async()=>{try{"suspended"===e.state&&await e.resume()}catch(e){ie.error("混音音频上下文恢复失败",e)}}))})).finally((()=>{this.contextResumeRequested=!1})))}warnupRemoteAudioTrack(e){const t=e.getMediaStreamTrack();if(!t||e.isPlaying()||this.warmupElements[e.id])return;const r=new Audio;r.muted=!0,r.srcObject=new MediaStream([t]),this.warmupElements[e.id]=r}releaseWarmupElement(e){const t=this.warmupElements[e];t&&(t.srcObject=null,delete this.warmupElements[e])}addTrack(e){if(this.tracks[e.id])return;const t=e.getMediaStreamTrack();t&&(e instanceof Cr&&this.warnupRemoteAudioTrack(e),this.mediaStreamTrack?.addTrack(t),this.requestContextResumeIfNeeded()),e.on(hr.MSTRACK_REPLACED,this.onTrackMsTrackReplace),this.tracks[e.id]=new WeakRef(e)}removeTrack(e){let t=e.getMediaStreamTrack();t&&this.mediaStreamTrack?.removeTrack(t),e.off(hr.MSTRACK_REPLACED,this.onTrackMsTrackReplace),this.releaseWarmupElement(e.id),delete this.tracks[e.id]}onTrackMsTrackReplace=(e,t)=>{t&&this.mediaStreamTrack?.removeTrack(t),this.releaseWarmupElement(e.id);const r=e.getMediaStreamTrack();r&&(e instanceof Cr&&this.warnupRemoteAudioTrack(e),this.mediaStreamTrack?.addTrack(r),this.requestContextResumeIfNeeded())};async startSpeakerPlay(e){const t=this.mediaStreamTrack?.context;if(!t)return!1;if(e?.deviceId){if("function"!=typeof t.setSinkId)return"unsupported-sink";try{await t.setSinkId(e.deviceId)}catch(e){return ie.warn("混音输出设备切换失败",e),"unsupported-sink"}}if("running"!==t.state){try{await Promise.race([t.resume(),new Promise(((e,t)=>setTimeout((()=>t(new Error("resume timeout"))),500)))])}catch(e){ie.warn("混音音频上下文恢复失败或超时",e)}if("running"!==t.state)return!1}return this.mediaStreamTrack.speakerGain.gain.value=null!=e?.volume?e.volume:1,this.speakerPlaying=!0,!0}stopSpeakerPlay(){this.mediaStreamTrack?.speakerGain&&(this.mediaStreamTrack.speakerGain.gain.value=0),this.speakerPlaying=!1}isSpeakerPlaying(){return this.speakerPlaying}setSpeakerVolume(e){this.speakerPlaying&&this.mediaStreamTrack?.speakerGain&&(this.mediaStreamTrack.speakerGain.gain.value=e)}getTrackCount(){return Object.keys(this.tracks).length}stop(){for(const e in this.tracks){const t=this.tracks[e].deref();t&&this.removeTrack(t)}this.tracks={},Object.keys(this.warmupElements).forEach((e=>this.releaseWarmupElement(e))),this.mediaStreamTrack?.context.close(),this.mediaStreamTrack?.stop()}getMixedMediaStreamTrack(){return this.mediaStreamTrack}}class Cr extends br{playTrait;jitterTrait;constructor(e,t){super(e,t),this.playTrait=new kr(this),this.jitterTrait=new wr(this),this.on(s.ENDED,(()=>{this.jitterTrait.setRtpReceiver(void 0)}))}setRtpReceiver(e){this.jitterTrait.setRtpReceiver(e)}setJitterBufferTarget(e){this.jitterTrait.setTarget(e)}getJitterBufferTarget(){return this.jitterTrait.getTarget()}strPrefix(){return"远端音频流轨道"}isPlaying(){return this.playTrait.isPlaying()}async startPlay(e){await this.playTrait.startPlay(e)||(e&&e.disableAutoPlayDialog?this.emit(hr.AUTOPLAY_FAIL,this):Sr.show(this.id,this.desc,(()=>{this.startPlay(e)})))}stopPlay(){this.playTrait.stopPlay()}}class Ar extends Cr{__type="RemoteAudioMixTrack";filterUids;constructor(e,t){super(e,""),this.filterUids=t||[]}getFilterUids(){return this.filterUids}strPrefix(){return"远端频道混音流轨道"}}class Pr extends Cr{__type="MockRemoteAudioMixTrack";audioMixTrait;filter;constructor(e,t){super(e,""),this.audioMixTrait=new Tr,this.setMediaStreamTrack(this.audioMixTrait.getMixedMediaStreamTrack()),this.filter=t}checkFilter(e){return!!this.filter&&this.filter(e)}addTrack(e){this.checkFilter(e)||this.audioMixTrait.addTrack(e)}removeTrack(e){this.audioMixTrait.removeTrack(e)}async startPlay(e){const t=await this.audioMixTrait.startSpeakerPlay(e);if("unsupported-sink"===t)return this.audioMixTrait.stopSpeakerPlay(),super.startPlay(e);!1===t&&(e&&e.disableAutoPlayDialog?this.emit(hr.AUTOPLAY_FAIL,this):Sr.show(this.id,this.desc,(()=>{this.startPlay(e)})))}stopPlay(){this.audioMixTrait.stopSpeakerPlay(),super.stopPlay()}isPlaying(){return this.audioMixTrait.isSpeakerPlaying()||super.isPlaying()}stop(){this.audioMixTrait.stop()}strPrefix(){return"本地合成的远端混音流轨道"}}class Rr extends Cr{constructor(){super({id:N,desc:"频道音频合成流",kind:U.Audio},D)}strPrefix(){return"远端音频合成流轨道"}}class xr extends br{playTrait;adaptiveStreamController;jitterTrait;constructor(e,t){super(e,t),this.playTrait=new _r(this,(e=>{this.adaptiveStreamController?.(e)})),this.jitterTrait=new wr(this),this.on(s.ENDED,(()=>{this.jitterTrait.setRtpReceiver(void 0)}))}strPrefix(){return"远端视频流轨道"}addPlayView(e){this.playTrait.addPlayView(e)}hasPlayView(){return this.playTrait.hasPlayView()}removePlayView(e){this.playTrait.removePlayView(e)}removeAllPlayViews(){this.playTrait.removeAllPlayViews()}async enterPictureInPicture(e,t){return this.playTrait.enterPictureInPicture(e,t)}async exitPictureInPicture(e){return this.playTrait.exitPictureInPicture(e)}isPictureInPicture(e){return this.playTrait.isPictureInPicture(e)}popOutToWindow(e,t){return this.playTrait.popOutToWindow(e,t)}closePopOutWindow(e){this.playTrait.closePopOutWindow(e)}isPopOut(e){return this.playTrait.isPopOut(e)}setAdaptiveStreamController(e){this.adaptiveStreamController=e,this.playTrait.refreshAdaptiveState()}setRtpReceiver(e){this.jitterTrait.setRtpReceiver(e)}setJitterBufferTarget(e){this.jitterTrait.setTarget(e)}getJitterBufferTarget(){return this.jitterTrait.getTarget()}}class Ir extends xr{constructor(){super({id:L,desc:"视频合成流",kind:U.Video},D)}strPrefix(){return"远端视频合成流轨道"}}function Mr(e,t){if(!t)return 0;let r,i;return"bytesReceived"in e?(r=e.bytesReceived,i=t.bytesReceived):"bytesSent"in e&&(r=e.bytesSent,i=t.bytesSent),void 0===r||void 0===i||void 0===e.timestamp||void 0===t.timestamp||e.timestamp<=t.timestamp?0:E(8*(r-i)/(e.timestamp-t.timestamp),2)}function Or(e){let t,r;return e.forEach((e=>{"candidate-pair"===e.type&&(e.nominated&&"succeeded"===e.state?t&&!e.selected||(t=e):"succeeded"!==e.state||r||(r=e))})),t||r}function Br(e,t){if(!t)return;const r=(e.jitterBufferDelay??0)-(t.jitterBufferDelay??0),i=(e.jitterBufferEmittedCount??0)-(t.jitterBufferEmittedCount??0);return i<=0?void 0:E(r/i,2)}function Nr(e,t){return t?void 0===e.framesDecoded||void 0===t.framesDecoded||void 0===e.timestamp||void 0===t.timestamp||e.timestamp<=t.timestamp?0:Math.round(1e3*(e.framesDecoded-t.framesDecoded)/(e.timestamp-t.timestamp)):0}class Lr extends Xt{qualityMonitor=new mr;lastBroadcastQuality=fr.Unknown;lastQualityEvaluation;qualityInterval;startMonitor(){super.startMonitor(),this.qualityInterval||(this.qualityInterval=setInterval((async()=>{try{const e=await this.getMetric();this.evaluateQuality(e)}catch(e){this.logger.error("metric","质量评分采集失败",e)}}),2e3))}evaluateQuality(e){const t=this.qualityMonitor.update(e),r=this.refineQualityEvaluation(t);if(this.lastQualityEvaluation=r,r.overall!==this.lastBroadcastQuality){const e=this.lastBroadcastQuality;this.lastBroadcastQuality=r.overall,this.emit(pr.ConnectionQualityChanged,r,e),this.logger.debug("quality",`连接质量: ${e} -> ${r.overall}`,r.reasons)}this.qualityMonitor.shouldEmitCpuConstrained()&&this.emit(pr.CpuConstrained,r),this.qualityMonitor.shouldEmitBandwidthConstrained()&&this.emit(pr.BandwidthConstrained,r)}getQualityEvaluation(){return this.lastQualityEvaluation}stopMonitor(){super.stopMonitor(),this.qualityInterval&&(window.clearInterval(this.qualityInterval),this.qualityInterval=void 0),this.qualityMonitor.reset(),this.lastBroadcastQuality=fr.Unknown,this.lastQualityEvaluation=void 0}refineQualityEvaluation(e){return e}dftPCConfig={bundlePolicy:"max-bundle",iceServers:[]};async publish(e,t,r){if(await super.publish(e,t,r),!e.getMediaStreamTrack())throw new R(e.toString()+"的mediaStreamTrack不存在,无法发布");if(e.kind==U.Audio&&!ir.checkAudioCodec("OPUS"))throw new R("当前环境不支持OPUS音频编解码,"+e.toString()+"无法发布");if(e.kind==U.Video&&!ir.checkVideoCodec("H264"))throw new R("当前环境不支持H264视频编解码,"+e.toString()+"无法发布");if(!("addTransceiver"in RTCPeerConnection.prototype)&&!("addTrack"in RTCPeerConnection.prototype))throw new R("当前环境不支持addTransceiver或addTrack,无法发布")}onPubMsTrackReplace=(e,t)=>{if(!this.published[e.id])return;const r=this.published[e.id];r.sender?.replaceTrack(e.getMediaStreamTrack()??null)};updateTrackInfoAfterPublish(e){if(!this.published[e.id])return;const t=this.published[e.id];if(!t.sender)return;let r=t.sender.getParameters().codecs;if(0===r.length)return void this.logger.warn("推流成功后,无法获取编码器信息",e.toString());let i=r[0];this.logger.debug("推流成功后,更新trackinfo codec",e.toString(),"codecInfo",i);let n=i.mimeType;if(e.kind==U.Video){let t=j[n.replace("video/","").toUpperCase()];this.updatePublishInfo(e,{codec:t})}else{let t=j[n.replace("audio/","").toUpperCase()];this.updatePublishInfo(e,{codec:t,sample_rate:i.clockRate,channel_count:i.channels})}}}var Dr=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.DISCONNECTED="disconnected",e}(Dr||{});const Ur=12e3;class jr extends Lr{publishPc;subscribePc;publishNegotiationPromise=null;isPublishNegotiating=!1;state=Dr.INIT;api;signalDataChannel=null;onDataChannelMessage=null;pendingSubscribeTracks=[];subscribeDebounce;subscribeHit={};lastServerQualityReport;lastClientStatsReportAt=0;simulcastTracks={};activeSpeakers=new Map;ability={audioCodecs:[j.OPUS],videoCodecs:[j.H264,j.VP8,j.VP9,j.AV1,j.H265],audioMaxPub:-1,videoMaxPub:-1,audioMaxSub:-1,videoMaxSub:-1};constructor(e,t,r,i){super(t,r,i),this.api=e,this.publishPc=this.newPublishPc(),this.subscribePc=this.newSubscribePc(),this.subscribeDebounce=sr((async()=>{if(0===this.pendingSubscribeTracks.length)return{ignored:{},failed:{},hit:{}};try{const e=[...this.pendingSubscribeTracks];this.pendingSubscribeTracks=[],this.logger.debug("执行批量订阅操作",JSON.stringify(e));const t=await this.sfuApiWithRetry("subscribe",(()=>this.api.sfuSubscribe(e)));return t.offer&&await this.handleSfuSubscribeOffer(t.offer),{ignored:t.ignored||{},failed:t.failed||{},hit:t.hit||{}}}catch(e){throw this.logger.error("批量订阅操作失败",e),e}}),100,{isImmediate:!1})}newPublishPc(){return this.publishPc=new RTCPeerConnection(this.dftPCConfig),this.publishPc.createDataChannel("dummy",{ordered:!1,maxRetransmits:0}),this.setupPublishPcListeners(),this.publishPc}newSubscribePc(){return this.subscribePc=new RTCPeerConnection(this.dftPCConfig),this.setupSubscribePcListeners(),this.subscribePc}vendor(){return Yt.Seastart}refineQualityEvaluation(e){const t=this.lastServerQualityReport;if(!t||!Number.isFinite(t.ts)||Date.now()-t.ts>Ur)return e;let r=vr(t.pub.level,e.uplink),i=vr(t.sub.level,e.downlink);return{uplink:r,downlink:i,overall:vr(r,i),mos:Math.min(t.pub.mos,t.sub.mos,e.mos),reasons:e.reasons,timestamp:e.timestamp}}async connect(){const e=await this.publishPc.createOffer();await this.publishPc.setLocalDescription(e),await this.waitForIceGathering(this.publishPc);const{publish_answer:t,subscribe_offer:r,prefer_video_codec:i,prefer_audio_codec:n}=await this.sfuApiWithRetry("connect",(()=>this.api.sfuConnect(this.publishPc.localDescription,this.joinRsp.net)));i&&!this.ability.preferVideoCodec&&(this.ability.preferVideoCodec=j[i.toUpperCase()]),n&&!this.ability.preferAudioCodec&&(this.ability.preferAudioCodec=j[n.toUpperCase()]),await this.publishPc.setRemoteDescription(t),await this.handleSfuSubscribeOffer(r),await this.waitForPCConnected(this.publishPc,5e3),await this.waitForPCConnected(this.subscribePc,5e3),await super.connect(),this.state=Dr.CONNECTED}async sfuApiWithRetry(e,t){try{return await k(t,{maxRetries:3,initialDelay:10,onRetry:(t,r)=>(this.logger.warn(`SFU API ${e} 调用失败第${t}次`,r),!(r instanceof R))})()}catch(t){throw"maxretry"==t?(t=new Error(`SFU API ${e} 调用多次重试依旧失败,已放弃调用`),this.logger.error(`SFU API ${e} 多次重试依旧无法调用,已放弃调用`)):"canceled"==t?(t=new Error(`SFU API ${e} 调用被取消`),this.logger.error(`SFU API ${e} 调用被取消`)):this.logger.error(`SFU API ${e} 调用失败,不再重试`,t),t}}async reconnectWithRetry(e){if(this.state!=Dr.CONNECTED)return;this.state=Dr.RECONNECTING,this.logger.warn("SFU 开始重连",e),this.stopMonitor(),this.clearSignalDataChannel(),this.lastServerQualityReport=void 0,this.resetActiveSpeakers(),this.publishPc.close(),this.subscribePc.close();for(const e in this.published){const t=this.published[e];t.track.emit(hr.RECONNECTING,t.track,t.opt,t.exopt)}for(const e in this.subscribed){const t=this.subscribed[e];t.track.emit(hr.RECONNECTING,t.track,t.exopt)}try{await k((async()=>{this.clearSignalDataChannel(),this.publishPc.close(),this.subscribePc.close(),this.publishPc=this.newPublishPc(),this.subscribePc=this.newSubscribePc(),await this.connect()}),{maxRetries:10,initialDelay:500,onRetry:(e,t)=>(this.logger.warn(`SFU 重连失败第${e}次`,t),this.state==Dr.RECONNECTING&&(function(e){return e instanceof R&&O.has(e.code)}(t)?(this.logger.warn("SFU 重连遇到暂时性错误(容量不足),继续退避重试",t),!0):!(t instanceof R)))})()}catch(e){throw"maxretry"==e?this.logger.error("SFU 重连多次重试依旧无法连接,已放弃重连"):"canceled"==e?this.logger.error("SFU 重连被取消"):this.logger.error("SFU 重连失败,不再重试",e),e}let t=this.published,r=this.subscribed;this.published={},this.simulcastTracks={},this.subscribed={},this.subscribeHit={};for(const e in t){const r=t[e];try{await this.publish(r.track,r.opt,r.exopt),r.track.emit(hr.RECONNECTED,r.track)}catch(e){this.logger.error(`SFU 重连后,重新发布 ${r.track.toString()} 失败`,e)}}for(const e in r){const t=r[e];try{await this.subscribe(t.track,t.exopt),t.track.emit(hr.RECONNECTED,t.track)}catch(e){this.logger.error(`SFU 重连后,重新订阅 ${t.track.toString()} 失败`,e)}}this.logger.warn("SFU 重连成功"),this.state=Dr.CONNECTED}async disconnect(){await super.disconnect(),this.clearSignalDataChannel(),this.lastServerQualityReport=void 0,this.resetActiveSpeakers(),this.publishPc.close(),this.subscribePc.close(),this.onDataChannelMessage=null,this.state=Dr.DISCONNECTED}setupPublishPcListeners(){this.publishPc.addEventListener("icecandidate",(e=>{this.logger.debug("发布PeerConnection","icecandidate",e.candidate)})),this.publishPc.addEventListener("iceconnectionstatechange",(e=>{this.logger.debug("发布PeerConnection","ICE connection state change",this.publishPc?.iceConnectionState),"failed"==this.publishPc?.iceConnectionState&&this.reconnectWithRetry("发布PeerConnection iceConnectionState: failed")})),this.publishPc.addEventListener("signalingstatechange",(e=>{this.logger.debug("发布PeerConnection","signaling state change",this.publishPc?.signalingState),"closed"==this.publishPc?.signalingState&&this.reconnectWithRetry("发布PeerConnection signaling state: closed")})),this.publishPc.addEventListener("connectionstatechange",(e=>{if(this.logger.info("发布PeerConnection","connection state",this.publishPc?.connectionState),this.publishPc)switch(this.publishPc.connectionState){case"failed":case"closed":this.reconnectWithRetry("发布PeerConnection连接状态: "+this.publishPc.connectionState);break;case"connected":this.logger.info("发布PeerConnection已连接")}}))}setupSubscribePcListeners(){this.subscribePc.addEventListener("icecandidate",(e=>{this.logger.debug("订阅PeerConnection","icecandidate",e.candidate)})),this.subscribePc.addEventListener("iceconnectionstatechange",(e=>{this.logger.debug("订阅PeerConnection","ICE connection state change",this.subscribePc?.iceConnectionState),"failed"==this.subscribePc?.iceConnectionState&&this.reconnectWithRetry("订阅PeerConnection iceConnectionState: failed")})),this.subscribePc.addEventListener("signalingstatechange",(e=>{this.logger.debug("订阅PeerConnection","signaling state change",this.subscribePc?.signalingState),"closed"==this.subscribePc?.signalingState&&this.reconnectWithRetry("订阅PeerConnection signaling state: closed")})),this.subscribePc.addEventListener("track",(e=>{const t=e.streams[0]?.id||e.track.id;this.logger.info("订阅PeerConnection","收到远程轨道",e.track.kind,e.track.id,t);let r=this.subscribed[t];r?(r.track.setMediaStreamTrack(e.track),(r.track instanceof xr||r.track instanceof Cr)&&r.track.setRtpReceiver(e.receiver),this.logger.warn("拉流",r.track.toString(),"mstrack got"),e.streams[0].onremovetrack=()=>{this.logger.warn("拉流",r.track.toString(),"mstrack removed"),r.track.emit(s.ENDED,r.track)}):this.logger.warn("收到的远程轨道",e.track.kind,e.track.id,"未订阅或已取消")})),this.subscribePc.addEventListener("connectionstatechange",(e=>{if(this.logger.debug("订阅PeerConnection","connection state",this.subscribePc?.connectionState),this.subscribePc)switch(this.subscribePc.connectionState){case"failed":case"closed":this.reconnectWithRetry("订阅PeerConnection连接状态: "+this.subscribePc.connectionState);break;case"connected":this.logger.info("订阅PeerConnection已连接")}})),this.subscribePc.addEventListener("datachannel",(e=>{this.logger.info("订阅PeerConnection","收到数据通道",e.channel.label),this.clearSignalDataChannel(),this.signalDataChannel=e.channel,this.setupDataChannelListeners()}))}async publish(e,t,r){if(this.state!=Dr.CONNECTED)throw new R("当前状态: "+this.state+",无法发布");if("connected"!=this.publishPc.connectionState)throw new R("发布PeerConnection未连接,无法发布");if(this.published[e.id])return void this.logger.warn("推流",e.toString(),"进行中,当前状态",this.published[e.id].pc.connectionState);await super.publish(e,t,r);let i={priority:t.priority,networkPriority:t.priority,maxBitrate:t.maxBitrate},n=[i];if(e.kind==U.Video){let r=e,o=t;if(i.maxFramerate=o.maxFramerate,i.scaleResolutionDownBy=r.getScaleResolutionDownBy(),o.simulcasts&&o.simulcasts.length>0){if(!("addTransceiver"in RTCPeerConnection.prototype))throw new R("不支持simulcast,当前浏览器不支持addTransceiver");i.rid="0",this.simulcastTracks[e.id]={};for(let t=1;t<=o.simulcasts.length;t++){let i=o.simulcasts[t-1],s=r.getSimulcastTrack(i,o.width,o.height);n.push({rid:t.toString(),priority:i.priority,networkPriority:i.priority,maxBitrate:i.maxBitrate,maxFramerate:i.maxFramerate,scaleResolutionDownBy:s.getScaleResolutionDownBy()}),this.simulcastTracks[e.id][t.toString()]=s}}}let o=this.publishPc,s={kind:e.kind,pc:o,track:e,opt:t,exopt:r||{}};this.published[e.id]=s,this.logger.debug("推流编码参数",e.toString(),"encodings",n);let a=!1;if("addTransceiver"in RTCPeerConnection.prototype){let r=o.addTransceiver(e.getMediaStreamTrack(),{direction:"sendonly",sendEncodings:n,streams:[e.getMediaStream()]});if(s.sender=r.sender,e.kind==U.Video){let e=t.codec||this.ability.preferVideoCodec;if(e){let t=ir.preferVideoEncCodec(F(e));try{r.setCodecPreferences(t)}catch(e){this.logger.warn("setCodecPreferences(video) 失败,将使用浏览器默认编码顺序",e)}}}else{let e=t.codec||this.ability.preferAudioCodec;if(e){let t=ir.preferAudioEncCodec(F(e));try{r.setCodecPreferences(t)}catch(e){this.logger.warn("setCodecPreferences(audio) 失败,将使用浏览器默认编码顺序",e)}}}}else{let t=o.addTrack(e.getMediaStreamTrack(),e.getMediaStream());s.sender=t,a=!0}let c=s.sender.getParameters();a&&(c.encodings=n),e.kind==U.Video&&t.degradationPreference&&(c.degradationPreference=t.degradationPreference),await s.sender.setParameters(c);try{await this.negotiatePublishPc()}catch(t){throw delete this.published[e.id],delete this.simulcastTracks[e.id],t}this.updateTrackInfoAfterPublish(e),e.on(hr.MSTRACK_REPLACED,this.onPubMsTrackReplace)}updateTrackInfoAfterPublish(e){if(super.updateTrackInfoAfterPublish(e),e.kind==U.Video){let t=[];for(const r in this.simulcastTracks[e.id]){let i=this.simulcastTracks[e.id][r],n=e.id+"_"+r;this.updatePublishInfo(i,{id:n,codec:this.publisher?.getPublishInfo(e)?.codec,variant:!0}),t.push(n)}t.length>0&&this.updatePublishInfo(e,{fallback_ids:t})}}async unpublish(e){if(!this.published[e.id])return void this.logger.warn("推流",e.toString(),"已取消,无需取消发布");e.off(hr.MSTRACK_REPLACED,this.onPubMsTrackReplace);const t=this.published[e.id];if(this.logger.warn("推流",e.toString(),"unpublished"),delete this.published[e.id],delete this.simulcastTracks[e.id],this.state==Dr.CONNECTED)try{t.pc.removeTrack(t.sender),await this.negotiatePublishPc()}catch(t){this.logger.warn("推流",e.toString(),"取消发布失败",t)}}async subscribe(e,t){if("connected"!=this.subscribePc.connectionState)throw new R("订阅PeerConnection未连接,无法订阅");if(this.subscribed[e.id])return void this.logger.warn("拉流",e.toString(),"进行中,当前状态",this.subscribed[e.id].pc.connectionState);await super.subscribe(e,t);let r={kind:e.kind,pc:this.subscribePc,track:e,exopt:t||{}};this.subscribed[e.id]=r;const i=t?.prefer_track_ids;try{await k((()=>this.debouncedSfuSubscribe(e.getUid(),e.id,!0,i)),{maxRetries:3,initialDelay:1e3,onRetry:(t,r)=>"not found"==r?(this.logger.warn(`SFU track ${e.toString()}不存在,重试第${t}次`),!0):(this.logger.warn(`SFU track ${e.toString()}订阅失败`,r),!1)})()}catch(t){throw delete this.subscribed[e.id],t}}async unsubscribe(e){if(this.subscribed[e.id]){if(this.logger.warn("拉流",e.toString(),"unsubscribed"),delete this.subscribed[e.id],delete this.subscribeHit[`${e.getUid()}:${e.id}`],this.state==Dr.CONNECTED)try{await this.debouncedSfuSubscribe(e.getUid(),e.id,!1)}catch(t){this.logger.warn("拉流",e.toString(),"取消订阅失败",t)}}else this.logger.warn("拉流",e.toString(),"未订阅或已取消,无需取消订阅")}getSubscribeHit(e){return this.subscribeHit[`${e.getUid()}:${e.id}`]}async debouncedSfuSubscribe(e,t,r,i){const n={pub_uid:e,track_id:t,subscribe:r,prefer_track_ids:i},o=this.pendingSubscribeTracks.findIndex((r=>r.pub_uid===e&&r.track_id===t));if(-1!==o){this.pendingSubscribeTracks[o].subscribe!==r&&(this.pendingSubscribeTracks.splice(o,1),this.logger.debug("订阅操作",`${e}:${t}`,"订阅和取消订阅操作相互抵消"))}else this.pendingSubscribeTracks.push(n);const s=await this.subscribeDebounce(),a=`${e}:${t}`;if(s.ignored[a]&&this.logger.warn(`轨道 ${a} 订阅被忽略: ${s.ignored[a]}`),s.failed[a])throw s.failed[a];s.hit[a]&&(this.logger.debug(`轨道 ${a} 订阅命中层: ${s.hit[a]}`),this.updateSubscribeHit(a,s.hit[a]))}async negotiatePublishPc(e=!1){if(this.isPublishNegotiating)return this.publishNegotiationPromise?void await this.publishNegotiationPromise:(await w(100),this.negotiatePublishPc(e));this.isPublishNegotiating=!0,this.publishNegotiationPromise=(async()=>{try{if(await new Promise((e=>setTimeout(e,100))),this.publishNegotiationPromise=null,"stable"===this.publishPc.signalingState&&"connected"===this.publishPc.connectionState){const t=await this.publishPc.createOffer({iceRestart:e}),r=[];for(const e in this.published){const t=this.published[e].track;r.push({track_id:e,stream_id:t.getMediaStream().id,mstrack_id:t.getMediaStreamTrack()?.id})}await this.publishPc.setLocalDescription(t),await this.waitForIceGathering(this.publishPc);const i=await this.sfuApiWithRetry("offerPublish",(()=>this.api.sfuOfferPublish(this.publishPc.localDescription,r)));await this.publishPc.setRemoteDescription(i.answer),this.logger.info("发布PeerConnection协商成功")}}catch(e){throw this.logger.error("发布PeerConnection协商失败",e),this.reconnectWithRetry(e),e}finally{this.isPublishNegotiating=!1}})(),await this.publishNegotiationPromise}async handleSfuSubscribeOffer(e){this.logger.info("收到订阅PeerConnection Offer");try{await this.subscribePc.setRemoteDescription(e);const t=await this.subscribePc.createAnswer();await this.subscribePc.setLocalDescription(t),await this.waitForIceGathering(this.subscribePc),await this.sfuApiWithRetry("answerSubscribe",(()=>this.api.sfuAnswerSubscribe(this.subscribePc.localDescription))),this.logger.info("订阅PeerConnection Answer已发送")}catch(e){throw this.logger.error("处理订阅PeerConnection Offer失败",e),this.reconnectWithRetry(e),e}}async waitForPCConnected(e,t){if("connected"!==e.connectionState)return new Promise(((r,i)=>{const n=()=>{"connected"===e.connectionState&&(clearTimeout(o),e.removeEventListener("connectionstatechange",n),r())};e.addEventListener("connectionstatechange",n);const o=setTimeout((()=>{e.removeEventListener("connectionstatechange",n),i(new Error("peerconnection连接超时"))}),t)}))}async waitForIceGathering(e){if("complete"!==e.iceGatheringState)return new Promise((t=>{const r=()=>{"complete"===e.iceGatheringState&&(clearTimeout(i),e.removeEventListener("icegatheringstatechange",r),t())};e.addEventListener("icegatheringstatechange",r);const i=setTimeout((()=>{e.removeEventListener("icegatheringstatechange",r),this.logger.warn("ICE收集超时,继续处理"),t()}),5e3)}))}clearSignalDataChannel(e=this.signalDataChannel){e&&(e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null,e===this.signalDataChannel&&(this.signalDataChannel=null))}setupDataChannelListeners(){if(!this.signalDataChannel)return;const e=this.signalDataChannel;e.onopen=e=>{this.logger.info("信令DataChannel已打开")},e.onclose=()=>{this.logger.warn("信令DataChannel已关闭"),this.signalDataChannel===e&&this.clearSignalDataChannel(e)},e.onerror=t=>{const r=e.readyState;console.log(t),this.logger.warn("信令DataChannel错误",{readyState:r},t.error)},this.onDataChannelMessage=e=>{try{const t=JSON.parse(e.data);switch(this.logger.debug("收到信令DataChannel消息",t),t.type){case"layer-switched":this.handleLayerSwitched(t);break;case"quality":this.handleConnectionQualityReport(t);break;case"active-speakers":this.handleActiveSpeakersMessage(t);break;default:this.logger.debug("未知的DataChannel消息类型",t.type)}}catch(t){this.logger.error("处理信令DataChannel消息失败",t,e.data)}},e.onmessage=this.onDataChannelMessage}updateSubscribeHit(e,t){e&&t&&(this.subscribeHit[e]=t)}handleLayerSwitched(e){this.updateSubscribeHit(e.sub_key,e.to_track_id),this.logger.info("订阅层切换",e.sub_key,`${e.from_track_id||"none"} -> ${e.to_track_id}`,`reason=${e.reason}`,`latency=${e.latency_ms}ms`)}handleConnectionQualityReport(e){e&&Number.isFinite(e.ts)&&(this.lastServerQualityReport=e)}handleActiveSpeakersMessage(e){if(!e||!Array.isArray(e.speakers))return;let t=!1;for(const r of e.speakers){if(!r||!r.uid||!r.track_id)continue;const e=`${r.uid}:${r.track_id}`;if(r.active){const i=this.activeSpeakers.get(e);i&&i.level===r.level||(this.activeSpeakers.set(e,{uid:r.uid,trackId:r.track_id,level:r.level}),t=!0)}else this.activeSpeakers.delete(e)&&(t=!0)}if(!t)return;const r=Array.from(this.activeSpeakers.values()).sort(((e,t)=>t.level-e.level)),i={ts:e.ts,speakers:r};this.emit(dr.ActiveSpeakersChanged,i)}resetActiveSpeakers(){if(0===this.activeSpeakers.size)return;this.activeSpeakers.clear();const e={ts:Date.now(),speakers:[]};this.emit(dr.ActiveSpeakersChanged,e)}sendSignalMessage(e,t){if(!this.signalDataChannel||"open"!==this.signalDataChannel.readyState)return this.logger.warn("信令DataChannel未打开,无法发送消息"),!1;try{const r=JSON.stringify({type:e,...t});return this.signalDataChannel.send(r),!0}catch(e){return this.logger.error("发送信令DataChannel消息失败",e),!1}}requestSwitchSubscribedLayer(e,t){return this.sendSignalMessage("switch-layer",{sub_key:`${e.getUid()}:${e.id}`,track_id:t})}findPublishTrackByMidRid(e,t){if(!e)return;const r=this.publishPc.getTransceivers().find((t=>t.mid===e)),i=r?.sender?.track?.id;if(i)for(const e in this.published){const r=this.published[e];if(r.track.getMediaStreamTrack()?.id===i){if(t&&"0"!==t){const r=this.simulcastTracks[e]?.[t];if(r)return r}return r.track}}}findSubscribedTrackByMid(e){if(!e)return;const t=this.subscribePc.getTransceivers().find((t=>t.mid===e)),r=t?.receiver?.track?.id;if(r)for(const e in this.subscribed){const t=this.subscribed[e];if(t.track.getMediaStreamTrack()?.id===r)return t.track}}async getMetric(){const e={bitrate_down:0,bitrate_up:0,lossrate_down:0,lossrate_up:0,pkt_up:0,pkt_down:0,pkt_loss_up:0,pkt_loss_down:0},t=this.prevMetric?.network,r=[],i=[],n=await this.publishPc.getStats();n.forEach((t=>{if("outbound-rtp"!==t.type)return;const o=this.findPublishTrackByMidRid(t.mid,t.rid);if(!o)return;const s=this.publisher?.getPublishInfo(o)??o.getRawInfo(),a=o.prevStats;if("audio"==t.kind){const i={type:"audio",streamId:t.id,packetsSent:t.packetsSent,bytesSent:t.bytesSent,timestamp:t.timestamp,audioLevel:t.mediaSourceId?n.get(t.mediaSourceId)?.audioLevel:void 0},c=n.get(t.remoteId);c&&(i.jitter=null!=c.jitter?1e3*c.jitter:void 0,i.packetsLost=c.packetsLost,i.roundTripTime=null!=c.roundTripTime?1e3*c.roundTripTime:void 0),s.bitrate=a?Mr(i,a):0,s.db=i.audioLevel?P(i.audioLevel):-60,s.stats=i,o.prevStats=i,e.bitrate_up+=s.bitrate,e.pkt_up+=i.packetsSent||0,e.pkt_loss_up+=i.packetsLost||0,r.push(s)}else if("video"==t.kind){const r={type:"video",streamId:t.id,frameHeight:t.frameHeight,frameWidth:t.frameWidth,framesPerSecond:t.framesPerSecond,framesSent:t.framesSent,firCount:t.firCount,pliCount:t.pliCount,nackCount:t.nackCount,packetsSent:t.packetsSent,bytesSent:t.bytesSent,qualityLimitationReason:t.qualityLimitationReason,qualityLimitationDurations:t.qualityLimitationDurations,qualityLimitationResolutionChanges:t.qualityLimitationResolutionChanges,rid:t.rid??t.id,retransmittedPacketsSent:t.retransmittedPacketsSent,targetBitrate:t.targetBitrate,timestamp:t.timestamp},c=n.get(t.remoteId);c&&(r.jitter=null!=c.jitter?1e3*c.jitter:void 0,r.packetsLost=c.packetsLost,r.roundTripTime=null!=c.roundTripTime?1e3*c.roundTripTime:void 0),s.width=r.frameWidth,s.height=r.frameHeight,s.fps=r.framesPerSecond,s.bitrate=a?Mr(r,a):0,s.stats=r,o.prevStats=r,e.bitrate_up+=s.bitrate,e.pkt_up+=r.packetsSent||0,e.pkt_loss_up+=r.packetsLost||0,i.push(s)}}));const o=[],s=[],a=await this.subscribePc.getStats();let c,u;a.forEach((t=>{if("inbound-rtp"!==t.type)return;const r=this.findSubscribedTrackByMid(t.mid);if(!r)return;const i=r.getInfo();i.uid=r.getUid();const n=r.prevStats;if("audio"==t.kind){const s={type:"audio",streamId:t.id,timestamp:t.timestamp,jitter:null!=t.jitter?1e3*t.jitter:void 0,jitterBufferDelay:null!=t.jitterBufferDelay?1e3*t.jitterBufferDelay:void 0,jitterBufferEmittedCount:t.jitterBufferEmittedCount,packetsLost:t.packetsLost,packetsReceived:t.packetsReceived,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,audioLevel:t.audioLevel,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration};s.jitterBufferAvgDelay=Br(s,n),i.bitrate=n?Mr(s,n):0,i.db=s.audioLevel?P(s.audioLevel):-60,i.stats=s,r.prevStats=s,e.bitrate_down+=i.bitrate,e.pkt_down+=s.packetsReceived||0,e.pkt_loss_down+=s.packetsLost||0,o.push(i)}else if("video"==t.kind){const o={type:"video",streamId:t.id,framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesReceived:t.framesReceived,packetsReceived:t.packetsReceived,packetsLost:t.packetsLost,framesPerSecond:t.framesPerSecond,frameWidth:t.frameWidth,frameHeight:t.frameHeight,pliCount:t.pliCount,firCount:t.firCount,nackCount:t.nackCount,jitter:null!=t.jitter?1e3*t.jitter:void 0,jitterBufferDelay:null!=t.jitterBufferDelay?1e3*t.jitterBufferDelay:void 0,jitterBufferEmittedCount:t.jitterBufferEmittedCount,timestamp:t.timestamp,bytesReceived:t.bytesReceived,decoderImplementation:t.decoderImplementation,freezeCount:t.freezeCount,totalFreezesDuration:t.totalFreezesDuration,pauseCount:t.pauseCount,totalPausesDuration:t.totalPausesDuration,framesAssembledFromMultiplePackets:t.framesAssembledFromMultiplePackets,totalAssemblyTime:t.totalAssemblyTime};if(t.codecId){const e=a.get(t.codecId);e&&(o.mimeType=e.mimeType)}o.jitterBufferAvgDelay=Br(o,n),i.width=o.frameWidth,i.height=o.frameHeight,i.fps=t.framesPerSecond||(n?Nr(o,n):0),i.bitrate=n?Mr(o,n):0,i.stats=o,r.prevStats=o,e.bitrate_down+=i.bitrate,e.pkt_down+=o.packetsReceived||0,e.pkt_loss_down+=o.packetsLost||0,s.push(i)}}));const l=Or(n);l&&(null!=l.availableOutgoingBitrate&&(e.available_outgoing_bitrate=E(l.availableOutgoingBitrate/1e3,2)),null!=l.currentRoundTripTime&&(c=E(1e3*l.currentRoundTripTime,2)));const h=Or(a);h&&(null!=h.availableIncomingBitrate&&(e.available_incoming_bitrate=E(h.availableIncomingBitrate/1e3,2)),null!=h.currentRoundTripTime&&(u=E(1e3*h.currentRoundTripTime,2))),e.rtt_up=c,e.rtt_down=u;const d=e.pkt_up-(t?.pkt_up??0),f=e.pkt_down-(t?.pkt_down??0),p=e.pkt_loss_up-(t?.pkt_loss_up??0),g=e.pkt_loss_down-(t?.pkt_loss_down??0);e.lossrate_up=E(d>0?p/d*100:0,2),e.lossrate_down=E(f>0?g/f*100:0,2);const m=this.lastServerQualityReport;m&&Number.isFinite(m.ts)&&Date.now()-m.ts<=Ur&&(e.server={ts:m.ts,pub:m.pub,sub:m.sub});let y=this.prevMetric={local_audios:r,local_videos:i,remote_audios:o,remote_videos:s,network:e};return this.maybeReportClientStatsToSfu(r,i,o,s,e,c,u),y}maybeReportClientStatsToSfu(e,t,r,i,n,o,s){if(!this.signalDataChannel||"open"!==this.signalDataChannel.readyState)return;const a="undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now();if(!this.shouldReportClientStats(a))return;this.lastClientStatsReportAt=a;const c=[];for(const t of e){const e=t.stats;e&&c.push({track_id:t.id,kind:"audio",packets_sent:e.packetsSent??0,packets_lost:e.packetsLost??0,bytes_sent:e.bytesSent??0,nack_count:0,pli_count:0,fir_count:0,retransmitted_packets:0,jitter_ms:e.jitter,rtt_ms:e.roundTripTime})}for(const e of t){const t=e.stats;t&&c.push({track_id:e.id,rid:t.rid,kind:"video",packets_sent:t.packetsSent??0,packets_lost:t.packetsLost??0,bytes_sent:t.bytesSent??0,nack_count:t.nackCount??0,pli_count:t.pliCount??0,fir_count:t.firCount??0,retransmitted_packets:t.retransmittedPacketsSent??0,target_bitrate_bps:t.targetBitrate,frame_width:t.frameWidth,frame_height:t.frameHeight,frames_per_second:t.framesPerSecond,frames_sent:t.framesSent,quality_limitation_reason:t.qualityLimitationReason,jitter_ms:t.jitter,rtt_ms:t.roundTripTime})}const u=[];for(const e of r){const t=e.stats;t&&u.push({track_id:e.id,pub_uid:e.uid,kind:"audio",packets_received:t.packetsReceived??0,packets_lost:t.packetsLost??0,bytes_received:t.bytesReceived??0,nack_count:0,pli_count:0,fir_count:0,jitter_ms:t.jitter,jitter_buffer_delay_ms:t.jitterBufferDelay,jitter_buffer_emitted_count:t.jitterBufferEmittedCount})}for(const e of i){const t=e.stats;t&&u.push({track_id:e.id,pub_uid:e.uid,kind:"video",packets_received:t.packetsReceived??0,packets_lost:t.packetsLost??0,bytes_received:t.bytesReceived??0,nack_count:t.nackCount??0,pli_count:t.pliCount??0,fir_count:t.firCount??0,jitter_ms:t.jitter,jitter_buffer_delay_ms:t.jitterBufferDelay,jitter_buffer_emitted_count:t.jitterBufferEmittedCount,frames_decoded:t.framesDecoded,frames_dropped:t.framesDropped,frames_received:t.framesReceived,freeze_count:t.freezeCount,total_freezes_duration_ms:null!=t.totalFreezesDuration?1e3*t.totalFreezesDuration:void 0,pause_count:t.pauseCount,total_pauses_duration_ms:null!=t.totalPausesDuration?1e3*t.totalPausesDuration:void 0,frames_per_second:t.framesPerSecond,frame_width:t.frameWidth,frame_height:t.frameHeight})}const l={ts:Date.now(),available_outgoing_bitrate_bps:null!=n.available_outgoing_bitrate?Math.round(1e3*n.available_outgoing_bitrate):void 0,pub_rtt_ms:o,sub_rtt_ms:s,pub:c,sub:u};try{this.sendSignalMessage("client-stats",l)}catch(e){this.logger.debug("client-stats","DC 上报失败",e)}}shouldReportClientStats(e){if(this.lastClientStatsReportAt>0&&e-this.lastClientStatsReportAt<5e3)return!1;const t=this.lastServerQualityReport;if(!t||!Number.isFinite(t.ts)||Date.now()-t.ts>Ur)return!0;return!(t.pub.level===fr.Excellent&&t.sub.level===fr.Excellent)||!(this.lastClientStatsReportAt>0&&e-this.lastClientStatsReportAt<3e4)}}class Fr{enabled;settings;debouncers=new Map;constructor(e,t,r){this.sengine=e,this.resolveCandidates=r,this.settings=t&&!0!==t?t:void 0,this.enabled=!!t&&e instanceof jr}attach(e){if(!this.enabled)return void e.setAdaptiveStreamController(void 0);this.clearDebouncer(e.id);const t=sr((t=>{this.handleState(e,t)}),100);this.debouncers.set(e.id,t),e.setAdaptiveStreamController((e=>{t(e)}))}detach(e){this.clearDebouncer(e.id),e.setAdaptiveStreamController(void 0)}clearDebouncer(e){const t=this.debouncers.get(e);t&&(t.cancel(),this.debouncers.delete(e))}handleState(e,t){if(!this.enabled||!this.sengine.haveSubscribed(e))return;const r=this.sengine;if(!(r instanceof jr))return;if(t.visible&&0===t.width&&0===t.height)return;const i=this.pickTargetTrackId(e,t);if(!i)return;if((r.getSubscribeHit(e)||e.id)!==i&&r.requestSwitchSubscribedLayer(e,i)){const r=this.getPixelDensity();ie.debug("自适应流切层",e.toString(),`views=${t.viewCount}`,`visible=${t.visible}`,`size=${Math.round(t.width)}x${Math.round(t.height)}`,`density=${r}`,`background=${t.inBackground}`,`target=${i}`)}}pickTargetTrackId(e,t){const r=this.resolveCandidates(e);if(0===r.length)return;if(1===r.length)return r[0].id;const i=this.settings?.pauseVideoInBackground??!0;if(0===t.viewCount||!t.visible||i&&t.inBackground)return r[r.length-1].id;const n=this.getPixelDensity(),o=Math.max(1,Math.ceil(t.width*n))*Math.max(1,Math.ceil(t.height*n))*.9;for(let e=r.length-1;e>=0;e--){const t=r[e].getInfo();if(t.width*t.height>=o)return t.id}return r[0].id}getPixelDensity(){const e=this.settings?.pixelDensity;if("screen"===e)return window.devicePixelRatio||1;if("number"==typeof e&&e>0)return e;return(window.devicePixelRatio||1)>2?2:1}}const Vr="default";class zr extends(l()){static instance;static devices=[];static debouncedDeviceChangeHandler=sr((async()=>{let e=zr.devices,t=await zr.instance.getDevices();const r=t.filter((t=>!e.some((e=>e.deviceId===t.deviceId)))),i=e.filter((e=>!t.some((t=>e.deviceId===t.deviceId))));r.forEach((e=>{ie.info("新设备插入:",e),zr.instance.emit("add",e)})),i.forEach((e=>{ie.info("设备被拔出:",e),zr.instance.emit("remove",e)}))}),100,{isImmediate:!1});static getInstance(){if(void 0===zr.instance){zr.instance=new zr;"undefined"==typeof window||window.isSecureContext||void 0!==navigator?.mediaDevices||ie.warn("当前非安全环境(https或localhost或127.0.0.1),将无法获取麦克风、摄像头等媒体设备进行枚举、音视频采集、推流"),navigator?.mediaDevices?.addEventListener("devicechange",(()=>{zr.debouncedDeviceChangeHandler()}))}return zr.instance}static waitingMediaDevicePromises=[];async addWaitMediaDevice(e,t,r){let i=zr.waitingMediaDevicePromises;i.push(e);try{return await e}catch(e){throw ie.error(`mediaDevices.${t} error`,e,r),e}finally{i.splice(i.indexOf(e),1)}}async enum(){let e=navigator.mediaDevices.enumerateDevices();return this.addWaitMediaDevice(e,"enumerateDevices")}async getUserMedia(e){let t=navigator.mediaDevices.getUserMedia(e);return this.addWaitMediaDevice(t,"getUserMedia",e)}async waitMediaDevices(){return Promise.allSettled(zr.waitingMediaDevicePromises)}async getDevices(e,t=!0){let r=await this.enum();if(t){if(0===r.length||r.some((t=>{const r=""===t.label,i=!e||t.kind===e;return r&&i}))){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e};for(;;)try{const e=await this.getUserMedia(t);r=await this.enum(),e.getTracks().forEach((e=>{e.stop()}));break}catch(e){if(e instanceof DOMException&&"NotFoundError"===e.name&&(t.video?t.video=!1:t.audio&&(t.audio=!1),t.audio||t.video))continue;throw e}}}return e?r=r.filter((t=>t.kind===e)):t&&(zr.devices=r),r}async normalizeDeviceId(e,t,r){if(t!==Vr)return t;const i=await this.getDevices(e),n=new Map(i.map((e=>[e.groupId,0])));i.forEach((e=>n.set(e.groupId,(n.get(e.groupId)??0)+1)));const o=i.find((e=>(r===e.groupId||(n.get(e.groupId)??0)>1)&&e.deviceId!==Vr));return o?.deviceId}}class qr{name;processedTrack;processors;ownedAudioContext;constructor(e){if(!e.length)throw new R("ProcessorPipeline 至少需要一个处理器");this.processors=e,this.name=e.map((e=>e.name)).join(" -> ")}async init(e){let t=e.audioContext;e.kind!==U.Audio||t||(t=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3,latencyHint:"interactive"}),this.ownedAudioContext=t);let r=e.track;for(const i of this.processors){if(await i.init({track:r,kind:e.kind,audioContext:t}),!i.processedTrack)throw new R(`处理器 ${i.name} 未产出 processedTrack`);r=i.processedTrack}this.processedTrack=r}async destroy(){for(const e of[...this.processors].reverse())try{await e.destroy()}catch(t){ie.warn("ProcessorPipeline",`处理器 ${e.name} 释放失败`,t)}this.ownedAudioContext&&"closed"!==this.ownedAudioContext.state&&await this.ownedAudioContext.close(),this.ownedAudioContext=void 0,this.processedTrack=void 0}}class Wr{track;processor;originMsTrack;applying=!1;constructor(e){this.track=e,this.onMsTrackReplaced=this.onMsTrackReplaced.bind(this),this.track.on(hr.MSTRACK_REPLACED,this.onMsTrackReplaced)}async setProcessor(e){const t=this.track.getMediaStreamTrack();if(!t)throw new R("请先 startCapture 采集到轨道,再设置处理器");this.processor&&await this.removeProcessor();const r=Array.isArray(e)?new qr(e):e;this.applying=!0;try{await this.applyProcessor(r,t)}finally{this.applying=!1}}async removeProcessor(){const e=this.processor;e&&(this.processor=void 0,this.originMsTrack&&this.track.setMediaStreamTrack(this.originMsTrack),this.originMsTrack=void 0,await e.destroy())}getProcessor(){return this.processor}async applyProcessor(e,t){await e.init({track:t,kind:this.track.kind});const r=e.processedTrack;if(!r)throw new R(`处理器 ${e.name} 未产出 processedTrack`);this.processor=e,this.originMsTrack=t,this.track.setMediaStreamTrack(r)}onMsTrackReplaced(){if(!this.processor||this.applying)return;const e=this.track.getMediaStreamTrack();if(!e||e===this.processor.processedTrack)return;const t=this.processor,r=e;this.applying=!0,(async()=>{try{await t.destroy(),await this.applyProcessor(t,r)}catch(e){ie.warn("ProcessorController","切换设备后自动重挂处理器失败",e)}finally{this.applying=!1}})()}}class Hr extends br{publishState=new V(this);emitInfoUpdate(){this.emit(s.INFO_UPDATE,this)}get id(){return this.publishState.soleRecord()?.info.id??this.info.id}get desc(){return this.publishState.soleRecord()?.info.desc??this.info.desc}get variant(){return this.publishState.soleRecord()?.info.variant??this.info.variant}get angle(){return this.publishState.soleRecord()?.info.angle??this.info.angle}getInfo(){return this.publishState.resolveInfo()??super.getInfo()}getUid(){return this.publishState.soleRecord()?.uid??this.uid}}class Kr extends Hr{playTrait;processorCtrl;constructor(){super({id:T(20),kind:U.Audio,track:-1},""),this.playTrait=new kr(this),this.processorCtrl=new Wr(this)}async setProcessor(e){return this.processorCtrl.setProcessor(e)}async removeProcessor(){return this.processorCtrl.removeProcessor()}getVolume(){return 0}strPrefix(){return"本地音频流轨道"}isPlaying(){return this.playTrait.isPlaying()}async startPlay(e){await this.playTrait.startPlay(e)||(e&&e.disableAutoPlayDialog?this.emit(hr.AUTOPLAY_FAIL,this):Sr.show(this.id,this.desc,(()=>{this.startPlay(e)})))}stopPlay(){this.playTrait.stopPlay()}}class $r extends Kr{audioMixTrait;constructor(){super(),this.audioMixTrait=new Tr,this.setMediaStreamTrack(this.audioMixTrait.getMixedMediaStreamTrack())}addTrack(e){this.audioMixTrait.addTrack(e)}removeTrack(e){this.audioMixTrait.removeTrack(e)}getTrackCount(){return this.audioMixTrait.getTrackCount()}stop(){this.audioMixTrait.stop()}strPrefix(){return"本地混音流轨道"}}class Gr extends Kr{captureOptions;constructor(e){super(),this.captureOptions=!0===e||{...e}}strPrefix(){return"本地屏幕共享音频流轨道"}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):ie.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}}class Qr extends Kr{captureOptions;constructor(e){super(),this.captureOptions={...e}}strPrefix(){return"本地麦克风流轨道"}onEnded(){ie.warn(this.toString(),"异常结束,自动尝试默认麦克风(最多重试3次)"),k((()=>this.changeDeviceId(Vr)),{maxRetries:3,initialDelay:500,onRetry:(e,t)=>{ie.warn(this.toString(),`自动恢复默认麦克风第${e}次重试`,t)}})().catch((e=>{ie.error(this.toString(),"异常结束,自动恢复默认麦克风最终失败",e),this.setMediaStreamTrack(void 0),super.onEnded()}))}async startCapture(e){e&&_(this.captureOptions,e);let t=this.captureOptions;t.deviceId&&t.deviceId!=Vr&&(t={...this.captureOptions},t.deviceId={exact:this.captureOptions.deviceId});let r=await zr.getInstance().getUserMedia({audio:t,video:!1});this.setMediaStreamTrack(r.getTracks()[0])}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):ie.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}async changeDeviceId(e){if(this.captureOptions.deviceId===e&&e!=Vr)return;return this.captureOptions.deviceId=e,this.getMediaStreamTrack()?(this.stopCapture(),this.startCapture()):void 0}}class Jr extends Hr{playTrait;simulcastTracks={};scaleResolutionDownBy=1;processorCtrl;constructor(){super({id:T(20),kind:U.Video,track:-1},""),this.playTrait=new _r(this),this.processorCtrl=new Wr(this)}async setProcessor(e){return this.processorCtrl.setProcessor(e)}async removeProcessor(){return this.processorCtrl.removeProcessor()}strPrefix(){return"本地视频流轨道"}setMediaStreamTrack(e){super.setMediaStreamTrack(e);for(let t in this.simulcastTracks)this.simulcastTracks[t].setMediaStreamTrack(e)}getSimulcastTrack(e,t,r){if(!e.desc)throw new R("联播轨道发布描述不能为空");let i=this.simulcastTracks[e.desc];if(!i){i=this.simulcastTracks[e.desc]=new Jr;const n=Math.min(t||this.mediaStreamTrack?.getSettings().width||0,r||this.mediaStreamTrack?.getSettings().height||0);n>0&&e.width&&e.height&&(i.scaleResolutionDownBy=Math.max(1,n/Math.min(e.width,e.height)),ie.debug(i.toString(),`编码缩放倍数:${i.scaleResolutionDownBy}`)),i.setMediaStreamTrack(this.mediaStreamTrack)}return i}getSimulcastTracks(){return this.simulcastTracks}clearSimulcastTracks(){this.simulcastTracks={}}getScaleResolutionDownBy(){return this.scaleResolutionDownBy}addPlayView(e){this.playTrait.addPlayView(e)}refreshPlayView(){this.playTrait.refreshTransform()}hasPlayView(){return this.playTrait.hasPlayView()}removePlayView(e){this.playTrait.removePlayView(e)}removeAllPlayViews(){this.playTrait.removeAllPlayViews()}async enterPictureInPicture(e,t){return this.playTrait.enterPictureInPicture(e,t)}async exitPictureInPicture(e){return this.playTrait.exitPictureInPicture(e)}isPictureInPicture(e){return this.playTrait.isPictureInPicture(e)}popOutToWindow(e,t){return this.playTrait.popOutToWindow(e,t)}closePopOutWindow(e){this.playTrait.closePopOutWindow(e)}isPopOut(e){return this.playTrait.isPopOut(e)}}class Yr extends Jr{captureOptions;mirror=!0;constructor(e){super(),this.captureOptions={...e}}strPrefix(){return"本地摄像头视频流轨道"}onEnded(){ie.warn(this.toString(),"异常结束,自动尝试默认摄像头(最多重试3次)"),k((()=>this.changeDeviceId(Vr)),{maxRetries:3,initialDelay:500,onRetry:(e,t)=>{ie.warn(this.toString(),`自动恢复默认摄像头第${e}次重试`,t)}})().catch((e=>{ie.error(this.toString(),"异常结束,自动恢复默认摄像头最终失败",e),this.setMediaStreamTrack(void 0),super.onEnded()}))}async startCapture(e){e&&_(this.captureOptions,e);let t=this.captureOptions;t.deviceId&&t.deviceId!=Vr&&(t={...this.captureOptions},t.deviceId={exact:this.captureOptions.deviceId});let r=await zr.getInstance().getUserMedia({audio:!1,video:t});this.setMediaStreamTrack(r.getTracks()[0])}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):ie.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}async changeDeviceId(e){if(this.captureOptions.deviceId===e&&e!=Vr)return;return this.captureOptions.deviceId=e,this.getMediaStreamTrack()?(this.stopCapture(),this.startCapture()):void 0}isFrontFacing(){return"environment"!==this.captureOptions.facingMode}setMirror(e){this.isFrontFacing()&&this.mirror!==e&&(this.mirror=e,this.refreshPlayView())}isMirrored(){return this.isFrontFacing()&&this.mirror}async switchFacingMode(){if(this.captureOptions.facingMode="environment"==this.captureOptions.facingMode?"user":"environment",this.getMediaStreamTrack())return this.stopCapture(),this.startCapture()}}class Xr extends Jr{captureOptions;audioTrack;constructor(e){super(),this.captureOptions={...e}}strPrefix(){return"本地屏幕分享视频流轨道"}setAudioTrack(e){this.audioTrack=e}getAudioTrack(){return this.audioTrack}async startCapture(e){if(e&&_(this.captureOptions,e),void 0===navigator.mediaDevices.getDisplayMedia)throw new R("getDisplayMedia not supported");(await navigator.mediaDevices.getDisplayMedia({audio:!!this.audioTrack&&this.audioTrack.captureOptions,video:{displaySurface:"monitor",selfBrowserSurface:"exclude",surfaceSwitching:"include",...this.captureOptions}})).getTracks().forEach((e=>{e.kind==U.Audio?this.audioTrack?.setMediaStreamTrack(e):(this.setMediaStreamTrack(e),this.captureOptions.contentHint&&(e.contentHint=this.captureOptions.contentHint))}))}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0),this.audioTrack?.stopCapture()):ie.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}}class Zr{tracks;info;constructor(e){this.info=e,this.tracks={},e.stream_tracks?.forEach((e=>{let t=this.newTrack(e);this.tracks[e.id]=t}))}getTrack(e){return this.tracks[e]}spawnTrack(e){return this.newTrack(e)}getTrackByDesc(e){for(let t in this.tracks)if(this.tracks[t].desc===e)return this.tracks[t]}getTracks(){return this.tracks}updateTracks(e){let t=[],r=[],i=[],n={},o={};for(let e in this.tracks)n[e]=!0,o[e]=this.tracks[e];e.forEach((e=>{let i=o[e.id];if(i){let t=i.updateInfo(e);delete n[e.id],t.length>0&&r.push(i)}else{let r=this.newTrack(e);this.tracks[e.id]=r,t.push(r)}}));for(let e in n){let t=this.tracks[e];t&&(delete this.tracks[e],i.push(t))}return this.info.stream_tracks=e,{added:t,updated:r,deleted:i}}get uid(){return this.info.uid}get sid(){return this.info.sid}get device_type(){return this.info.device_type}get device_id(){return this.info.device_id}get link_id(){return this.info.link_id}getInfo(){let e={...this.info};return e.props={...e.props},e.stream_tracks=e.stream_tracks?.map((e=>({...e}))),e}updateInfo(e){_(this.info,e)}}class ei extends Zr{newTrack(e){switch(e.kind){case U.Video:return new xr(e,this.uid);case U.Audio:return new Cr(e,this.uid)}}}class ti extends ur{static create(e,t,r,i,n,o,s){return new ti(e,t,r,i,n,o,s)}_trackIdx=0;newUser(e){return new ei(e)}addStreamEngineListeners(){this.rtcStreamEngine.on(pr.ConnectionQualityChanged,((e,t)=>{const r={evaluation:e,previous:t};this.triggerEvent(lr.CONNECTION_QUALITY_CHANGED,r)})),this.rtcStreamEngine.on(pr.CpuConstrained,(e=>{this.triggerEvent(lr.CPU_CONSTRAINED,e)})),this.rtcStreamEngine.on(pr.BandwidthConstrained,(e=>{this.triggerEvent(lr.BANDWIDTH_CONSTRAINED,e)})),this.rtcStreamEngine.on(dr.ActiveSpeakersChanged,(e=>{this.triggerEvent(lr.ACTIVE_SPEAKERS_CHANGED,e)}))}getStreamMetric(){return this.rtcStreamEngine.getMetricSnapshot()}getNetworkStats(){return this.getStreamMetric()?.network}getConnectionQuality(){return this.rtcStreamEngine.getQualityEvaluation()}async publishLocalTrack(e,t){const r=this.resolvePublishOptions(e,t);if(e instanceof Xr){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.publishLocalTrack(t)}if(e.kind==U.Video&&this.rtcStreamEngine.vendor()!=Yt.Seastart){let t=r,i=e;if(t.simulcasts&&t.simulcasts.length>0)for(let e of t.simulcasts)await this.publishLocalTrack(i.getSimulcastTrack(e,t.width,t.height),e)}return super.publishLocalTrack(e,r)}async unpublishLocalTrack(e){if(await super.unpublishLocalTrack(e),e instanceof Xr){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.unpublishLocalTrack(t)}if(e.kind==U.Video){let t=e,r=t.getSimulcastTracks();if(this.rtcStreamEngine.vendor()!=Yt.Seastart)for(let e in r)await this.unpublishLocalTrack(r[e]);0===e.publishState.count&&t.clearSimulcastTracks()}}async getPublishExOption(e,t){let r={};if(this.rtcStreamEngine.vendor()===Yt.OOK){let t=-1;e.kind==U.Video&&(t=this.rtcStreamEngine.getAvailableVideoTrackNo()),r={track:t},this.updatePublishInfo(e,{track:t})}else this.updatePublishInfo(e,{track:this._trackIdx++});return r}createPublishRecords(e,t){let r=super.createPublishRecords(e,t);if(e.kind==U.Video){let i=t,n=e;if(i.simulcasts&&i.simulcasts.length>0)switch(this.rtcStreamEngine.vendor()){case Yt.Seastart:for(let e=0;e<i.simulcasts.length;e++){let t=i.simulcasts[e],o=n.getSimulcastTrack(t,i.width,i.height);this.newPublishRecord(o,m({desc:t.desc,codec:t.codec,width:t.width,height:t.height,fps:t.maxFramerate,bitrate:t.maxBitrate,props:t.props})),r.push(o)}break;default:{const t=i.simulcasts.map((e=>this.getPublishRecord(n.getSimulcastTrack(e,i.width,i.height))?.info.id)).filter((e=>!!e));t.length>0&&this.updatePublishInfo(e,{variant:!0,fallback_ids:t});break}}}return r}getDeletedTracksAfterUnpublish(e){let t=super.getDeletedTracksAfterUnpublish(e);if(this.rtcStreamEngine.vendor()===Yt.Seastart)if(e.kind==U.Video){let r=e;for(let e of Object.values(r.getSimulcastTracks()))this.getPublishRecord(e)&&t.push(e)}return t}async getSubscribeExOption(e){let t={};switch(this.rtcStreamEngine.vendor()){case Yt.OOK:if(e instanceof Ar){let r=[];e.getFilterUids().forEach((e=>{if(e&&e!=this.joinRsp.uid)try{let t=this.getUser(e);r.push(t.link_id)}catch(e){}})),t={filter_link_ids:r}}else if(e instanceof Ir)t={};else{let r=this.getUser(e.getUid()),i=e.getInfo();t={link_id:r.link_id,track:i.track}}break;case Yt.Seastart:{const r=e.getInfo();t={prefer_track_ids:r.fallback_ids?.length?[e.id,...r.fallback_ids]:[]};break}}return t}newRemoteAudioMixTrack(e){if(this.getStreamEngineVendor()==Yt.OOK)return new Ar({id:B,desc:"频道混音流",kind:U.Audio},Array.isArray(e)?e:[]);if(e&&Array.isArray(e)){let t=e;e=e=>t.includes(e.getUid())}return new Pr({id:B,desc:"频道混音流",kind:U.Audio},e)}newRemoteVideoMcuTrack(){return new Ir}newRemoteAudioMcuTrack(){return new Rr}trackRegistrar;async subscribeRemoteAudioMixTrack(e){const t=await super.subscribeRemoteAudioMixTrack(e);return this.trackRegistrar?.(t),t}async subscribeRemoteAudioTrack(e,t){const r=await super.subscribeRemoteAudioTrack(e,t);return this.trackRegistrar?.(r),r}async subscribeRemoteVideoMcuTrack(){const e=await super.subscribeRemoteVideoMcuTrack();return this.trackRegistrar?.(e),e}async subscribeRemoteAudioMcuTrack(){const e=await super.subscribeRemoteAudioMcuTrack();return this.trackRegistrar?.(e),e}async subscribeRemoteVideoTrack(e,t){const r=await super.subscribeRemoteVideoTrack(e,t);return r instanceof xr&&this.getAdaptiveStream().attach(r),this.trackRegistrar?.(r),r}async unsubscribeRemoteTrack(e,t=2e3){t<=0&&e instanceof xr&&this.getAdaptiveStream().detach(e),await super.unsubscribeRemoteTrack(e,t)}adaptiveStream;getAdaptiveStream(){return this.adaptiveStream||(this.adaptiveStream=new Fr(this.rtcStreamEngine,this.options.adaptiveStream,(e=>this.getAdaptiveVideoCandidates(e)))),this.adaptiveStream}getAdaptiveVideoCandidates(e){const t=this.getUser(e.getUid()),r=[e.id,...e.getInfo().fallback_ids||[]],i=[];for(const e of r){const r=t.getTrack(e);r instanceof xr&&i.push(r)}return i}}const ri={speech:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:24e3,priority:"high"}},music:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:32e3,priority:"high"}},musicStereo:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:2,sampleRate:48e3},publish:{desc:"mic",maxBitrate:48e3,priority:"high"}},musicHighQuality:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:64e3,priority:"high"}},musicHighQualityStereo:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:2,sampleRate:48e3},publish:{desc:"mic",maxBitrate:96e3,priority:"high"}}},ii=[{desc:"camera_small",width:320,height:180,maxBitrate:25e4,maxFramerate:15}],ni={"1080p":{capture:{width:1920,height:1080,frameRate:15},publish:{desc:"camera_big",maxBitrate:25e5,maxFramerate:15,simulcasts:ii,degradationPreference:"maintain-resolution"}},"720p":{capture:{width:1280,height:720,frameRate:15},publish:{desc:"camera_big",maxBitrate:12e5,maxFramerate:15,simulcasts:ii,degradationPreference:"maintain-resolution"}},"360p":{capture:{width:640,height:360,frameRate:15},publish:{maxBitrate:55e4,maxFramerate:15}},"180p":{capture:{width:320,height:180,frameRate:15},publish:{maxBitrate:25e4,maxFramerate:15}}},oi={"1080p":{capture:{width:1920,height:1080,frameRate:10},publish:{desc:"screen",maxBitrate:2e6,maxFramerate:10,priority:"medium",degradationPreference:"maintain-resolution"}},"720p":{capture:{width:1280,height:720,frameRate:10},publish:{desc:"screen",maxBitrate:15e5,maxFramerate:10,priority:"medium",degradationPreference:"maintain-resolution"}}},si={default:{capture:!0,publish:{desc:"screen_audio",maxBitrate:24e3,priority:"high"}}};class ai extends Wt{}const ci="#101216",ui="rgba(0, 0, 0, 0.58)",li=1129136434,hi=1129136441;class di{canvas;canvasContext;canvasStream;recordStream;mediaRecorder;audioContext;audioDestination;audioSources=new Map;audioInputTracks=[];trackedTrackListeners=new Map;videoElements=new Map;avatarImages=new Map;avatarFailedUrls=new Set;chunks=[];videoItems=[];width=1280;height=720;fps=15;background=ci;labelBackground=ui;animationFrameId=0;onDataAvailable;getState(){const e=this.mediaRecorder?.state;return"recording"===e||"paused"===e?e:"inactive"}async start(e){if("inactive"!==this.getState())return;if("undefined"==typeof MediaRecorder)throw new Error("Current browser does not support MediaRecorder");this.width=e.width||1280,this.height=e.height||720,this.fps=e.fps||15,this.background=e.background||ci,this.labelBackground=e.labelBackground||ui,this.onDataAvailable=e.onDataAvailable,this.videoItems=e.videoItems.slice(),this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height;const t=this.canvas.getContext("2d");if(!t)throw new Error("Failed to create recorder canvas context");this.canvasContext=t,this.canvasStream=this.canvas.captureStream(this.fps),await this.initAudio(e.audioTracks||[]),this.syncTrackedTrackListeners(),this.syncVideoElements(),this.syncAvatarImages();const r=[...this.canvasStream.getVideoTracks(),...this.audioDestination?.stream.getAudioTracks()||[]];this.recordStream=new MediaStream(r);const i=(n=e.mimeType)&&MediaRecorder.isTypeSupported(n)?n:["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find((e=>MediaRecorder.isTypeSupported(e)))||"";var n;this.mediaRecorder=new MediaRecorder(this.recordStream,i?{mimeType:i}:void 0),this.mediaRecorder.ondataavailable=e=>{e.data.size<=0||(this.chunks.push(e.data),this.onDataAvailable?.(e.data))},this.render(),this.mediaRecorder.start(e.timeslice)}updateVideoItems(e){this.videoItems=e.slice(),this.syncTrackedTrackListeners(),this.syncVideoElements(),this.syncAvatarImages()}async updateAudioTracks(e){this.audioContext&&this.audioDestination&&(this.audioInputTracks=e.slice(),this.syncTrackedTrackListeners(),this.setAudioTracks(e),"suspended"===this.audioContext.state&&await this.audioContext.resume())}pause(){"recording"===this.mediaRecorder?.state&&this.mediaRecorder.pause()}resume(){"paused"===this.mediaRecorder?.state&&this.mediaRecorder.resume()}stop(){if(!this.mediaRecorder)return Promise.resolve(new Blob([],{type:"video/webm"}));const e=this.mediaRecorder;return new Promise((t=>{e.onstop=()=>{const r=new Blob(this.chunks,{type:e.mimeType||"video/webm"});this.cleanup(),t(r)},"inactive"===e.state?e.onstop(new Event("stop")):e.stop()}))}destroy(){this.mediaRecorder&&"inactive"!==this.mediaRecorder.state&&this.mediaRecorder.stop(),this.cleanup()}async initAudio(e){this.audioContext=new AudioContext,this.audioDestination=this.audioContext.createMediaStreamDestination(),this.audioInputTracks=e.slice(),this.setAudioTracks(e),"suspended"===this.audioContext.state&&await this.audioContext.resume()}setAudioTracks(e){this.clearAudioSources(),e.forEach((e=>{const t=this.resolveMediaStreamTrack(e);if(!t||"live"!==t.readyState||!this.audioContext||!this.audioDestination)return;const r=new MediaStream([t]),i=this.audioContext.createMediaStreamSource(r);i.connect(this.audioDestination),this.audioSources.set(t.id,{source:i,stream:r})}))}clearAudioSources(){this.audioSources.forEach((({source:e})=>e.disconnect())),this.audioSources.clear()}resolveMediaStreamTrack(e){if(e)return e instanceof MediaStreamTrack?e:e.getMediaStreamTrack()}resolveTrackAngle(e){const t=e;return t?.angle??1129136432}isTrackLike(e){return!(!e||e instanceof MediaStreamTrack||"function"!=typeof e.getMediaStreamTrack||"function"!=typeof e.on||"function"!=typeof e.off)}syncTrackedTrackListeners(){const e=new Set;this.videoItems.forEach((t=>{this.isTrackLike(t.track)&&e.add(t.track)})),this.audioInputTracks.forEach((t=>{this.isTrackLike(t)&&e.add(t)})),this.trackedTrackListeners.forEach(((t,r)=>{e.has(r)||(r.off(hr.MSTRACK_REPLACED,t),this.trackedTrackListeners.delete(r))})),e.forEach((e=>{if(this.trackedTrackListeners.has(e))return;const t=()=>{this.syncVideoElements(),this.setAudioTracks(this.audioInputTracks)};e.on(hr.MSTRACK_REPLACED,t),this.trackedTrackListeners.set(e,t)}))}clearTrackedTrackListeners(){this.trackedTrackListeners.forEach(((e,t)=>{t.off(hr.MSTRACK_REPLACED,e)})),this.trackedTrackListeners.clear()}syncVideoElements(){const e=new Set;this.videoItems.forEach((t=>{const r=this.resolveMediaStreamTrack(t.track);if(!r||"live"!==r.readyState)return;if(e.add(r),this.videoElements.has(r))return;const i=document.createElement("video");i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.srcObject=new MediaStream([r]),i.play().catch((()=>{})),this.videoElements.set(r,i)})),this.videoElements.forEach(((t,r)=>{e.has(r)||(t.srcObject=null,this.videoElements.delete(r))}))}syncAvatarImages(){const e=new Set;this.videoItems.forEach((t=>{if(!t.avatar)return;if(e.add(t.avatar),this.avatarImages.has(t.avatar))return;const r=t.avatar,i=new Image;i.crossOrigin="anonymous",i.onerror=()=>{this.avatarFailedUrls.add(r)},i.src=r,this.avatarImages.set(r,i)})),this.avatarImages.forEach(((t,r)=>{e.has(r)||(this.avatarImages.delete(r),this.avatarFailedUrls.delete(r))}))}render=()=>{if(!this.canvas||!this.canvasContext)return;const e=this.canvasContext;e.fillStyle=this.background,e.fillRect(0,0,this.width,this.height),this.videoItems.forEach((t=>{const r=t.rect;e.fillStyle=t.background||"#1a1c22",e.fillRect(r.x,r.y,r.width,r.height);const i=this.resolveMediaStreamTrack(t.track),n=i?this.videoElements.get(i):void 0;!!n&&n.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&n.videoWidth>0&&n.videoHeight>0?this.drawVideo(e,n,t):i||!t.avatar&&!t.label||this.drawAvatarPlaceholder(e,t),t.label&&this.drawLabel(e,t)})),this.animationFrameId=requestAnimationFrame(this.render)};drawVideo(e,t,r){const i=r.rect,n=r.fit||"contain",o=this.resolveTrackAngle(r.track),s=function(e){return e===li||e===hi}(o),a=s?t.videoHeight/t.videoWidth:t.videoWidth/t.videoHeight,c=i.width/i.height;let u,l;("cover"===n?a>c:a<c)?(l=i.height,u=l*a):(u=i.width,l=u/a);const h=s?l:u,d=s?u:l;switch(e.save(),e.beginPath(),e.rect(i.x,i.y,i.width,i.height),e.clip(),e.translate(i.x+i.width/2,i.y+i.height/2),o){case hi:e.scale(-1,1),e.rotate(-Math.PI/2);break;case li:e.rotate(3*Math.PI/2);break;case 1129136433:e.rotate(Math.PI)}e.drawImage(t,-h/2,-d/2,h,d),e.restore()}drawLabel(e,t){const r=t.rect,i=r.x+12,n=r.y+r.height-42,o=Math.max(80,r.width-24);e.fillStyle=this.labelBackground,e.fillRect(i,n,o,30),e.fillStyle="#fff",e.font="16px sans-serif",e.textAlign="left",e.textBaseline="middle",e.fillText(t.label||"",i+10,n+15,o-20)}drawAvatarPlaceholder(e,t){const r=t.rect,i=r.x+r.width/2,n=r.y+r.height/2,o=Math.min(Math.max(.4*Math.min(r.width,r.height),48),180),s=o/2,a=t.avatar?this.avatarImages.get(t.avatar):void 0;if(!!a&&!!t.avatar&&!this.avatarFailedUrls.has(t.avatar)&&a.complete&&a.naturalWidth>0&&a.naturalHeight>0){const t=a.naturalWidth/a.naturalHeight;let r=o,c=o;return t>1?r=o*t:c=o/t,e.save(),e.beginPath(),e.arc(i,n,s,0,2*Math.PI),e.clip(),e.drawImage(a,i-r/2,n-c/2,r,c),void e.restore()}e.save(),e.beginPath(),e.arc(i,n,s,0,2*Math.PI),e.fillStyle="#4a4e57",e.fill(),e.fillStyle="#e6e8ec",e.font=`${Math.round(s)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(this.avatarInitial(t.label),i,n),e.restore()}avatarInitial(e){const t=Array.from((e||"").trim())[0];return t?t.toUpperCase():"?"}cleanup(){cancelAnimationFrame(this.animationFrameId),this.canvasStream?.getTracks().forEach((e=>e.stop())),this.recordStream?.getTracks().forEach((e=>{this.canvasStream?.getTracks().includes(e)||e.stop()})),this.videoElements.forEach((e=>{e.srcObject=null})),this.videoElements.clear(),this.avatarImages.clear(),this.avatarFailedUrls.clear(),this.clearAudioSources(),this.clearTrackedTrackListeners(),this.audioContext?.close(),this.audioContext=void 0,this.audioDestination=void 0,this.canvas=void 0,this.canvasContext=void 0,this.canvasStream=void 0,this.recordStream=void 0,this.mediaRecorder=void 0,this.audioInputTracks=[],this.videoItems=[],this.chunks=[],this.onDataAvailable=void 0}}class fi extends Lr{streamNameStates={};createMockAudioTrack(){const e=new AudioContext,t=e.createOscillator(),r=e.createMediaStreamDestination();t.connect(r),t.start();const i=r.stream.getAudioTracks()[0];return i.enabled=!1,i}createMockVideoTrack(){const e=document.createElement("canvas");e.width=640,e.height=480;const t=e.getContext("2d");t.fillStyle="black",t.fillRect(0,0,e.width,e.height);return e.captureStream(1).getVideoTracks()[0]}async publish(e,t,r){this.published[e.id]?this.logger.warn("推流",e.toString(),"进行中,当前状态",this.published[e.id].pc.connectionState):(await super.publish(e,t,r),await this.doPublish(e,t,r,!1),e.on(hr.MSTRACK_REPLACED,this.onPubMsTrackReplace),e.on(hr.RECONNECTING,this.onPubTrackReconnecting))}async unpublish(e){if(!this.published[e.id])return void this.logger.warn("推流",e.toString(),"已取消,无需取消发布");e.off(hr.MSTRACK_REPLACED,this.onPubMsTrackReplace),e.off(hr.RECONNECTING,this.onPubTrackReconnecting);const t=this.published[e.id],r=t.opt?.props?.streamName;if(r&&this.streamNameStates[r]){const t=this.streamNameStates[r];return e.kind===U.Audio&&t.audioTrack===e?(await(t.audioSender?.replaceTrack(t.mockAudioTrack)),t.audioTrack=null,this.logger.warn("推流",e.toString(),`unpublished (替换为mock,streamName=${r})`)):e.kind===U.Video&&t.videoTrack===e&&(await(t.videoSender?.replaceTrack(t.mockVideoTrack)),t.videoTrack=null,this.logger.warn("推流",e.toString(),`unpublished (替换为mock,streamName=${r})`)),delete this.published[e.id],void(null===t.audioTrack&&null===t.videoTrack&&(t.pc.close(),t.mockAudioTrack.stop(),t.mockVideoTrack.stop(),delete this.streamNameStates[r],this.logger.info("推流",`streamName=${r},所有 track 已 unpublish,关闭 PC`)))}t.pc.close(),delete this.published[e.id],this.logger.warn("推流",e.toString(),"unpublished")}async doPublish(e,t,r,i){let n=e.getMediaStreamTrack();const o=t.props?.streamName,s=o&&!i?this.streamNameStates[o]:void 0;if(s){if(e.kind===U.Audio&&null!==s.audioTrack)throw new R(`streamName=${o} 已有音频 track,请先 unpublish`);if(e.kind===U.Video&&null!==s.videoTrack)throw new R(`streamName=${o} 已有视频 track,请先 unpublish`)}let a=s?s.pc:new RTCPeerConnection(this.dftPCConfig),c={kind:e.kind,pc:a,track:e,opt:t,exopt:r||{}};this.published[e.id]=c;let u={maxBitrate:t.maxBitrate,priority:t.priority,networkPriority:t.priority};e.kind==U.Video&&(u.maxFramerate=t.maxFramerate,u.scaleResolutionDownBy=e.getScaleResolutionDownBy());let l=k((()=>this.negotiateSDP(c,"publish")),{maxRetries:10,initialDelay:500,onRetry:(t,r)=>!!this.published[e.id]&&(this.logger.warn("推流",e.toString(),`建连重试第${t}次`,r),!0)}),h=()=>{l().catch((t=>{"maxretry"==t&&this.logger.error("推流",e.toString(),"建连多次重试依旧无法连接,已放弃")}))},d=()=>{i?(this.vendor()!=Yt.OOK&&"closed"!=a.signalingState||l.cancel(),this.logger.error("推流",e.toString(),"已断开,将自动尝试重连"),e.emit(hr.RECONNECTING,e,t,r)):(l.cancel(),this.unpublish(e))};return new Promise((async(r,l)=>{let f=setTimeout((()=>{d(),l("发布超时")}),6e4);if(a.addEventListener("negotiationneeded",(()=>{this.logger.info("推流",e.toString(),"重新协商"),h()})),a.addEventListener("icecandidate",(t=>{this.logger.debug("推流",e.toString(),"icecandidate",t.candidate)})),a.addEventListener("iceconnectionstatechange",(t=>{this.logger.debug("推流",e.toString(),"ICE connection state change",a.iceConnectionState)})),a.addEventListener("signalingstatechange",(t=>{this.logger.debug("推流",e.toString(),"signaling state change",a.signalingState),"closed"==a.signalingState&&(d(),l("发布失败"))})),a.addEventListener("connectionstatechange",(t=>{switch(this.logger.debug("推流",e.toString(),"connection state",a.connectionState),a.connectionState){case"failed":case"closed":d(),l("发布失败");break;case"connected":this.logger.warn("推流",e.toString(),"connected"),clearTimeout(f),i?e.emit(hr.RECONNECTED,e):i=!0,this.updateTrackInfoAfterPublish(e),r()}})),s){e.kind===U.Audio?(await(s.audioSender?.replaceTrack(n)),s.audioTrack=e,c.sender=s.audioSender):(await(s.videoSender?.replaceTrack(n)),s.videoTrack=e,c.sender=s.videoSender);let i=c.sender.getParameters();return i.encodings=[u],e.kind==U.Video&&t.degradationPreference&&(i.degradationPreference=t.degradationPreference),c.sender.setParameters(i),this.updateTrackInfoAfterPublish(e),clearTimeout(f),this.logger.warn("推流",e.toString(),`streamName=${o},replaceTrack 成功`),void r()}o&&!this.streamNameStates[o]&&this.initStreamNameState(a,o);let p=!1;if("addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=Yt.OOK){let e=a.addTransceiver(n,{direction:"sendonly",sendEncodings:[u]});c.sender=e.sender}else{let e=a.addTrack(n);c.sender=e,p=!0}let g=c.sender.getParameters();if(p&&(g.encodings=[u]),e.kind==U.Video&&t.degradationPreference&&(g.degradationPreference=t.degradationPreference),c.sender.setParameters(g),o&&this.streamNameStates[o]){const t=this.streamNameStates[o];if(e.kind===U.Audio){t.audioTrack=e,t.audioSender=c.sender;const r=a.addTransceiver(t.mockVideoTrack,{direction:"sendonly"});t.videoSender=r.sender}else{t.videoTrack=e,t.videoSender=c.sender;const r=a.addTransceiver(t.mockAudioTrack,{direction:"sendonly"});t.audioSender=r.sender}}}))}initStreamNameState(e,t){const r={pc:e,audioTrack:null,audioSender:null,mockAudioTrack:this.createMockAudioTrack(),videoTrack:null,videoSender:null,mockVideoTrack:this.createMockVideoTrack()};return this.streamNameStates[t]=r,this.logger.info("推流",`streamName=${t},初始化合流状态`),r}onPubTrackReconnecting=(e,t,r)=>{if(!this.published[e.id])return;const i=this.published[e.id];"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=Yt.OOK&&"closed"!=i.pc.signalingState?i.pc.restartIce():(i.pc.close(),this.doPublish(e,t,r,!0))};async subscribe(e,t){this.subscribed[e.id]?this.logger.warn("拉流",e.toString(),"进行中,当前状态",this.subscribed[e.id].pc.connectionState):(await super.subscribe(e,t),await this.doSubscribe(e,t,!1),e.on(hr.RECONNECTING,this.onSubTrackReconnecting))}async unsubscribe(e){if(!this.subscribed[e.id])return void this.logger.warn("拉流",e.toString(),"未订阅或已取消,无需取消订阅");e.off(hr.RECONNECTING,this.onSubTrackReconnecting);this.subscribed[e.id].pc.close(),this.logger.warn("拉流",e.toString(),"unsubscribed"),delete this.subscribed[e.id]}async doSubscribe(e,t,r){let i=new RTCPeerConnection(this.dftPCConfig),n={kind:e.kind,pc:i,track:e,exopt:t||{}};this.subscribed[e.id]=n;let o=k((()=>this.negotiateSDP(n,"subscribe")),{maxRetries:10,initialDelay:500,onRetry:(t,r)=>!!this.subscribed[e.id]&&(this.logger.warn("拉流",e.toString(),`建连重试第${t}次`,r),!0)}),a=()=>{o().catch((t=>{"maxretry"==t&&this.logger.error("拉流",e.toString(),"建连多次重试依旧无法连接,已放弃")}))},c=()=>{r?(this.vendor()!=Yt.OOK&&"closed"!=i.signalingState||o.cancel(),this.logger.error("拉流",e.toString(),"已断开,将自动尝试重连"),e.emit(hr.RECONNECTING,e,t)):(o.cancel(),this.unsubscribe(e))};return new Promise((async(t,n)=>{let o=setTimeout((()=>{c(),n("订阅超时")}),6e4);i.addEventListener("negotiationneeded",(()=>{this.logger.info("拉流",e.toString(),"重新协商"),a()})),i.addEventListener("icecandidate",(t=>{this.logger.debug("拉流",e.toString(),"icecandidate",t.candidate)})),i.addEventListener("iceconnectionstatechange",(t=>{this.logger.debug("拉流",e.toString(),"ICE connection state change",i.iceConnectionState)})),i.addEventListener("signalingstatechange",(t=>{this.logger.debug("拉流",e.toString(),"signaling state change",i.signalingState),"closed"==i.signalingState&&(c(),n("订阅失败"))})),i.addEventListener("track",(t=>{e.setMediaStreamTrack(t.track),(e instanceof xr||e instanceof Cr)&&e.setRtpReceiver(t.receiver),t.streams[0].onremovetrack=t=>{this.logger.warn("拉流",e.toString(),"mstrack removed"),e.emit(s.ENDED,e)},this.logger.warn("拉流",e.toString(),"mstrack got")})),i.addEventListener("connectionstatechange",(s=>{switch(this.logger.debug("拉流",e.toString(),"connection state",i.connectionState),i.connectionState){case"failed":case"closed":c(),n("订阅失败");break;case"connected":this.logger.warn("拉流",e.toString(),"connected"),clearTimeout(o),r?e.emit(hr.RECONNECTED,e):r=!0,t()}})),"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=Yt.OOK?i.addTransceiver(e.kind,{direction:"recvonly"}):a()}))}onSubTrackReconnecting=(e,t)=>{if(!this.subscribed[e.id])return!1;const r=this.subscribed[e.id];"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=Yt.OOK&&"closed"!=r.pc.signalingState?r.pc.restartIce():(r.pc.close(),this.doSubscribe(e,t,!0))};async getMetric(){const e={bitrate_down:0,bitrate_up:0,lossrate_down:0,lossrate_up:0,pkt_up:0,pkt_down:0,pkt_loss_up:0,pkt_loss_down:0},t=this.prevMetric?.network;let r=0,i=0,n=0,o=0,s=0,a=0;const c=[],u=[];for(const t in this.published){const i=this.published[t],s=this.publisher?.getPublishInfo(i.track)??i.track.getRawInfo(),a=i.track.prevStats,l=await i.pc.getStats(),h=Or(l);h&&(null!=h.availableOutgoingBitrate&&(r=Math.max(r,h.availableOutgoingBitrate)),null!=h.currentRoundTripTime&&(n+=1e3*h.currentRoundTripTime,o++)),i.kind==U.Audio?(l.forEach((t=>{if("outbound-rtp"===t.type){const r={type:"audio",streamId:t.id,packetsSent:t.packetsSent,bytesSent:t.bytesSent,timestamp:t.timestamp},n=l.get(t.mediaSourceId);n&&(r.audioLevel=n.audioLevel);const o=l.get(t.remoteId);o&&(r.jitter=null!=o.jitter?1e3*o.jitter:void 0,r.packetsLost=o.packetsLost,r.roundTripTime=null!=o.roundTripTime?1e3*o.roundTripTime:void 0),s.bitrate=a?Mr(r,a):0,s.db=r.audioLevel?P(r.audioLevel):-60,s.stats=r,i.track.prevStats=r,e.bitrate_up+=s.bitrate,e.pkt_up+=r.packetsSent||0,e.pkt_loss_up+=r.packetsLost||0}})),c.push(s)):(l.forEach((t=>{if("outbound-rtp"===t.type){const r={type:"video",streamId:t.id,frameHeight:t.frameHeight,frameWidth:t.frameWidth,framesPerSecond:t.framesPerSecond,framesSent:t.framesSent,firCount:t.firCount,pliCount:t.pliCount,nackCount:t.nackCount,packetsSent:t.packetsSent,bytesSent:t.bytesSent,qualityLimitationReason:t.qualityLimitationReason,qualityLimitationDurations:t.qualityLimitationDurations,qualityLimitationResolutionChanges:t.qualityLimitationResolutionChanges,rid:t.rid??t.id,retransmittedPacketsSent:t.retransmittedPacketsSent,targetBitrate:t.targetBitrate,timestamp:t.timestamp},n=l.get(t.remoteId);n&&(r.jitter=null!=n.jitter?1e3*n.jitter:void 0,r.packetsLost=n.packetsLost,r.roundTripTime=null!=n.roundTripTime?1e3*n.roundTripTime:void 0),s.width=r.frameWidth,s.height=r.frameHeight,s.fps=r.framesPerSecond,s.bitrate=a?Mr(r,a):0,s.stats=r,i.track.prevStats=r,e.bitrate_up+=s.bitrate,e.pkt_up+=r.packetsSent||0,e.pkt_loss_up+=r.packetsLost||0}})),u.push(s))}const l=[],h=[];for(const t in this.subscribed){const r=this.subscribed[t],n=r.track.getInfo();n.uid=r.track.getUid();const o=r.track.prevStats,c=await r.pc.getStats(),u=Or(c);null!=u?.availableIncomingBitrate&&(i=Math.max(i,u.availableIncomingBitrate)),null!=u?.currentRoundTripTime&&(s+=1e3*u.currentRoundTripTime,a++),r.kind==U.Audio?(c.forEach((t=>{if("inbound-rtp"===t.type){const i={type:"audio",streamId:t.id,timestamp:t.timestamp,jitter:null!=t.jitter?1e3*t.jitter:void 0,jitterBufferDelay:null!=t.jitterBufferDelay?1e3*t.jitterBufferDelay:void 0,jitterBufferEmittedCount:t.jitterBufferEmittedCount,packetsLost:t.packetsLost,packetsReceived:t.packetsReceived,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,audioLevel:t.audioLevel,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration};i.jitterBufferAvgDelay=Br(i,o),n.bitrate=o?Mr(i,o):0,n.db=i.audioLevel?P(i.audioLevel):-60,n.stats=i,r.track.prevStats=i,e.bitrate_down+=n.bitrate,e.pkt_down+=i.packetsReceived||0,e.pkt_loss_down+=i.packetsLost||0}})),l.push(n)):(c.forEach((t=>{if("inbound-rtp"===t.type){const i={type:"video",streamId:t.id,framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesReceived:t.framesReceived,packetsReceived:t.packetsReceived,packetsLost:t.packetsLost,framesPerSecond:t.framesPerSecond,frameWidth:t.frameWidth,frameHeight:t.frameHeight,pliCount:t.pliCount,firCount:t.firCount,nackCount:t.nackCount,jitter:null!=t.jitter?1e3*t.jitter:void 0,jitterBufferDelay:null!=t.jitterBufferDelay?1e3*t.jitterBufferDelay:void 0,jitterBufferEmittedCount:t.jitterBufferEmittedCount,timestamp:t.timestamp,bytesReceived:t.bytesReceived,decoderImplementation:t.decoderImplementation,freezeCount:t.freezeCount,totalFreezesDuration:t.totalFreezesDuration,pauseCount:t.pauseCount,totalPausesDuration:t.totalPausesDuration,framesAssembledFromMultiplePackets:t.framesAssembledFromMultiplePackets,totalAssemblyTime:t.totalAssemblyTime},s=c.get(t.codecId);s&&(i.mimeType=s.mimeType),i.jitterBufferAvgDelay=Br(i,o),n.width=i.frameWidth,n.height=i.frameHeight,n.fps=t.framesPerSecond||(o?Nr(i,o):0),n.bitrate=o?Mr(i,o):0,n.stats=i,r.track.prevStats=i,e.bitrate_down+=n.bitrate,e.pkt_down+=i.packetsReceived||0,e.pkt_loss_down+=i.packetsLost||0}})),h.push(n))}r>0&&(e.available_outgoing_bitrate=E(r/1e3,2)),i>0&&(e.available_incoming_bitrate=E(i/1e3,2)),o>0&&(e.rtt_up=E(n/o,2)),a>0&&(e.rtt_down=E(s/a,2));const d=e.pkt_up-(t?.pkt_up??0),f=e.pkt_down-(t?.pkt_down??0),p=e.pkt_loss_up-(t?.pkt_loss_up??0),g=e.pkt_loss_down-(t?.pkt_loss_down??0);return e.lossrate_up=E(d>0?p/d*100:0,2),e.lossrate_down=E(f>0?g/f*100:0,2),this.prevMetric={local_audios:c,local_videos:u,remote_audios:l,remote_videos:h,network:e}}}class pi extends fi{localAudioMixTrack=new $r;ability={audioCodecs:[j.OPUS,j.AAC],videoCodecs:[j.H264,j.H265],audioMaxPub:1,videoMaxPub:7,audioMaxSub:9,videoMaxSub:32};vendor(){return Yt.OOK}async connect(){try{await this.free()}catch(e){}await this.create(),await super.connect()}async disconnect(){await super.disconnect(),await this.free()}async publish(e,t,r){if(e!=this.localAudioMixTrack&&e.kind==U.Audio)return this.localAudioMixTrack.addTrack(e),this.published[this.localAudioMixTrack.id]?void 0:await this.publish(this.localAudioMixTrack,t,r);await super.publish(e,t,r)}async unpublish(e){if(e!=this.localAudioMixTrack&&e.kind==U.Audio)return this.localAudioMixTrack.removeTrack(e),void(0==this.localAudioMixTrack.getTrackCount()&&await this.unpublish(this.localAudioMixTrack));let t=this.published[e.id];if(await super.unpublish(e),t)try{await this.freshAVState(t.exopt.session),await this.hangup(t.exopt.session)}catch(e){this.logger.error("ook webrtc取消发布接口报错",e)}}async unsubscribe(e){let t=this.subscribed[e.id];if(await super.unsubscribe(e),t)try{await this.hangup(t.exopt.session)}catch(e){this.logger.error("ook webrtc取消订阅接口报错",e)}}async negotiateSDP(e,t){let r=this.genSessionId();if(e.exopt.session)try{await this.hangup(e.exopt.session)}catch(t){r=e.exopt.session,this.logger.error("ook webrtc挂断接口报错",t)}e.exopt.session=r;let i=e.pc,n="";if("publish"==t&&e.kind==U.Audio)n=await this.offerWithRetry((()=>this.offerPushAudio(r)));else if("publish"==t&&e.kind==U.Video)n=await this.offerWithRetry((()=>this.offerPushVideo(r,e.exopt.track)));else if("subscribe"==t&&e.kind==U.Audio)n=e.track instanceof Ar?await this.offerWithRetry((()=>this.offerPullAmixer(r,e.exopt.filter_link_ids.join(",")))):await this.offerWithRetry((()=>this.offerPullAudio(r,e.exopt.link_id)));else{if("subscribe"!=t||e.kind!=U.Video)throw new R("未知SDP操作:"+t+":"+e.track.toString());n=e.track instanceof Ir?await this.offerWithRetry((()=>this.offerPullMcuVideo(r))):await this.offerWithRetry((()=>this.offerPullVideo(r,e.exopt.link_id,e.exopt.track)))}await i.setRemoteDescription({sdp:n,type:"offer"});let o=await i.createAnswer();await i.setLocalDescription(o),await(()=>new Promise(((e,t)=>{"complete"===i.iceGatheringState?e():i.onicegatheringstatechange=()=>{"complete"==i.iceGatheringState&&e()}}))).bind(this)(),await this.answer(r,i.localDescription?.sdp),"publish"==t&&await this.freshAVState(r)}async freshAVState(e){let t=!1,r=!1,i=0;for(const e in this.published){const n=this.published[e];n.kind==U.Audio?t=!0:n.kind==U.Video&&(r=!0,i|=Math.pow(2,n.exopt.track))}k((()=>this.setMcuTrack(e,i)),{maxRetries:3})(),await this.setAVState(e,t,r)}getAvailableVideoTrackNo(){let e=-1,t=[];for(const e in this.published){const r=this.published[e];r.kind==U.Video&&t.push(r.track.getInfo().track)}for(let r=0;r<this.ability.videoMaxPub;r++)if(-1==t.indexOf(r)){e=r;break}return e}create(){return this.req("create/"+this.joinRsp.link_id,{serv:this.joinRsp.webrtc.upload_host,conf:this.joinRsp.channel_link_id,token:this.joinRsp.session_key,amixer:1})}free(){return this.req("free/"+this.joinRsp.link_id)}async offerWithRetry(e){try{return await e()}catch(t){try{await this.create()}catch(e){}return e()}}async offerPushVideo(e,t){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,track:t+""}),{mode:"recvonly",type:"video"})).sdp}async offerPushAudio(e){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{mode:"recvonly",type:"audio"})).sdp}async offerPullVideo(e,t,r){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:t+"",track:r+""}),{mode:"sendonly",type:"video"})).sdp}async offerPullMcuVideo(e){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:"1",track:"0"}),{mode:"sendonly",type:"video"})).sdp}switchPullVideoTrack(e,t){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{type:"track",setting:{track:t}})}async offerPullAudio(e,t){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:t+""}),{mode:"sendonly",type:"audio"})).sdp}async offerPullAmixer(e,t=""){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:"amixer",filter:t}),{mode:"sendonly",type:"audio"})).sdp}answer(e,t){return this.req("answer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:t})}setAVState(e,t,r){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:JSON.stringify({type:"media",setting:{audio:t?1:0,video:r?1:0}})})}setMcuTrack(e,t){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:JSON.stringify({type:"deftrack",setting:{mmask:t}})})}hangup(e){return this.req("hangup/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}))}req(e,t={},r={}){let i=this.joinRsp.webrtc.cmd_url;"/"!==i.substring(i.length-1)&&(i+="/");let n=t.totalBody;n||(n=Object.keys(t).filter((e=>void 0!==t[e]&&null!==t[e])).map((e=>`${e}=${t[e]}`)).join("\r\n"));let o=Date.now(),s=(r,i)=>{this.logger[r]("ook webrtc gateway api: "+e,t,i,Date.now()-o+"ms")};return new Promise(((t,o)=>{fetch(i+e,{method:"POST",headers:{...r,Accept:"application/json"},body:n}).then((e=>{if(200!=e.status){let t=new Error(e.status+":"+e.statusText);s(Z.ERROR,t),o(t)}else e.json().then((e=>{s(0==e.code?Z.DEBUG:Z.ERROR,e),0==e.code?t(e):o(new R(e.code+":"+e.msg))})).catch((e=>{s(Z.ERROR,e),o(e)}))})).catch((e=>{s(Z.ERROR,e),o(e)}))}))}genSessionId(){return`${`${this.joinRsp.app_id}`}-${T(6)}`}}var gi=r(7363);class mi extends fi{api;ability={audioCodecs:[j.OPUS],videoCodecs:[j.H264],audioMaxPub:-1,videoMaxPub:-1,audioMaxSub:-1,videoMaxSub:-1};vendor(){return Yt.WangsuCDN}constructor(e,t,r,i){super(t,r,i),this.api=e}async negotiateSDP(e,t){let r=e.pc,i=await r.createOffer();await r.setLocalDescription(i);let n="";const o="publish"==t?e.opt?.props?.streamName:e.track.getInfo()?.props?.streamName;if(o)n=o;else if("publish"==t&&e.kind==U.Audio)n=e.track.getUid()==D&&e.track.id==N?"rtc_a_channel_"+this.joinRsp.channel:"rtc_a_user_"+this.joinRsp.uid+"_"+e.track.id;else if("publish"==t&&e.kind==U.Video)n=e.track.getUid()==D&&e.track.id==L?"rtc_v_channel_"+this.joinRsp.channel:"rtc_v_user_"+this.joinRsp.uid+"_"+e.track.id;else if("subscribe"==t&&e.kind==U.Audio)n=e.track.getUid()==D&&e.track.id==N?"rtc_a_channel_"+this.joinRsp.channel:"rtc_a_user_"+e.track.getUid()+"_"+e.track.id;else{if("subscribe"!=t||e.kind!=U.Video)throw new R("未知SDP操作:"+t+":"+e.track.toString());n=e.track.getUid()==D&&e.track.id==L?"rtc_v_channel_"+this.joinRsp.channel:"rtc_v_user_"+e.track.getUid()+"_"+e.track.id}let s=await this.exchangeSDP("publish"==t,n,i);s=this.reorderAnswerMLines(i,s),await r.setRemoteDescription(s)}reorderAnswerMLines(e,t){if(!e.sdp||!t.sdp)return t;const r=gi.qg(e.sdp),i=gi.qg(t.sdp);if(r.media.length<=1)return t;const n=r.media.map((e=>String(e.mid))),o=i.media.map((e=>String(e.mid)));if(n.join(",")===o.join(","))return t;this.logger.info("wangsu",`调整 answer m-line 顺序: ${o.join(",")} -> ${n.join(",")}`);const s=[];for(const e of n){const t=i.media.find((t=>String(t.mid)===e));t&&s.push(t)}if(i.media=s,i.groups)for(const e of i.groups)"BUNDLE"===e.type&&(e.mids=n.join(" "));return{type:t.type,sdp:gi.M9(i)}}async exchangeSDP(e,t,r){let i=await this.api.cdnURL({vendor:this.vendor(),stream_name:t,publish:e}),n=Date.now(),o=(r,i)=>{this.logger[r](`wangsu ${e?"publish":"subscribe"} ${t}, sdp exchange cost: ${Date.now()-n}ms`,i)};return new Promise(((e,t)=>{fetch(i,{method:"POST",headers:{Accept:"application/json"},body:JSON.stringify({version:"v1.0",sessionId:"sidtest",localSdp:r})}).then((r=>{if(200!=r.status){let e=new Error(r.status+":"+r.statusText);o(Z.ERROR,e),t(e)}else r.json().then((r=>{o(200==r.code?Z.DEBUG:Z.ERROR,r),200==r.code?e(r.remoteSdp):t(new R(r.code+":"+r.message))})).catch((e=>{o(Z.ERROR,e),t(e)}))})).catch((e=>{o(Z.ERROR,e),t(e)}))}))}}class yi extends $t{get defaultChannel(){return this.channels[0]??null}localTracks;getStreamMetric(){if(!this.defaultChannel)throw x;return this.defaultChannel.getStreamMetric()}getNetworkStats(){if(!this.defaultChannel)throw x;return this.defaultChannel.getNetworkStats()}getConnectionQuality(){if(!this.defaultChannel)throw x;return this.defaultChannel.getConnectionQuality()}buildInfo(){let{version:e}=r(6351);return{version:e,timestamp:1790146316}}getEnvInfo(){return rr()}createLocalCompositeRecorder(){return new di}getStoredDeviceId(){let e=localStorage.getItem("device_id");return e||(e=T(18),localStorage.setItem("device_id",e)),e}getDeviceType(){return q.WebRTC}newRtcApi(e,t){return new or(e.app_id,e.sid,e.client_key,e.client_api,t)}newRtcSocket(e,t){return new ai(e,t)}newChannel(e,t,r,i,n,o,s){const a=ti.create(e,t,r,i,n,o,s);return a.trackRegistrar=e=>this.addTrackListeners(e),a}newStreamEngine(e,t,r,i){switch(t.stream_vendor){case void 0:case Yt.OOK:return new pi(t,void 0,i);case Yt.WangsuCDN:return new mi(r,t,void 0,i);case Yt.Seastart:return new jr(r,t,{preferVideoCodec:e.preferVideoCodec,preferAudioCodec:e.preferAudioCodec},i);default:throw new R("不支持的流媒体引擎")}}onDeviceAdd=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.DEVICE_ADD,data:e})};onDeviceRemove=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.DEVICE_REMOVE,data:e})};onVisibilityChange=()=>{"visible"===document.visibilityState?this.onAppShow():this.onAppHide()};constructor(e){super(e),this.localTracks=new Set,zr.getInstance().on("add",this.onDeviceAdd),zr.getInstance().on("remove",this.onDeviceRemove),document.addEventListener("visibilitychange",this.onVisibilityChange)}join(e,t={}){return super.join(e,t)}releaseGlobalListeners(){zr.getInstance().off("add",this.onDeviceAdd),zr.getInstance().off("remove",this.onDeviceRemove),document.removeEventListener("visibilitychange",this.onVisibilityChange)}postLeave(e){let t=new Set(e.getLocalTracks());0===this.channels.length&&this.localTracks.forEach((e=>t.add(e)));for(let e of t)if(e.publishState.count>0)ie.info("离开频道",e.toString(),`仍有 ${e.publishState.count} 个频道在发布,保留采集`);else try{e instanceof Kr?e.stopPlay():e instanceof Jr&&e.removeAllPlayViews(),(e instanceof Qr||e instanceof Yr||e instanceof Xr)&&(e.stopCapture(),ie.info("离开频道",e.toString(),"自动停止采集"))}catch(e){}super.postLeave(e)}onAppShow(e){super.onAppShow(e);for(let e of this.localTracks){let t=e.getMediaStreamTrack();t&&("ended"===t.readyState&&(ie.warn(e.toString(),"页面恢复时发现 track 已 ended,尝试重新采集"),(e instanceof Qr||e instanceof Yr)&&e.startCapture().catch((t=>{ie.error(e.toString(),"页面恢复时重新采集失败",t)}))))}}async getDevices(e,t=!0){return zr.getInstance().getDevices(e,t)}addTrackListeners(e){e.listeners(s.MUTED).includes(this.muteCallback)||e.on(s.MUTED,this.muteCallback),e.listeners(s.UNMUTED).includes(this.unmuteCallback)||e.on(s.UNMUTED,this.unmuteCallback),e.listeners(s.ENDED).includes(this.endCallback)||e.on(s.ENDED,this.endCallback),e.listeners(hr.AUTOPLAY_FAIL).includes(this.autoPlayFailCallback)||e.on(hr.AUTOPLAY_FAIL,this.autoPlayFailCallback),e.listeners(hr.PIP_ENTER).includes(this.pipEnterCallback)||e.on(hr.PIP_ENTER,this.pipEnterCallback),e.listeners(hr.PIP_EXIT).includes(this.pipExitCallback)||e.on(hr.PIP_EXIT,this.pipExitCallback),e.listeners(hr.POPOUT_OPEN).includes(this.popOutOpenCallback)||e.on(hr.POPOUT_OPEN,this.popOutOpenCallback),e.listeners(hr.POPOUT_CLOSE).includes(this.popOutCloseCallback)||e.on(hr.POPOUT_CLOSE,this.popOutCloseCallback)}muteCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_MUTED,data:e})};unmuteCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_UNMUTED,data:e})};endCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_ENDED,data:e})};autoPlayFailCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_AUTOPLAY_FAIL,data:e})};pipEnterCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_PIP_ENTER,data:e})};pipExitCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_PIP_EXIT,data:e})};popOutOpenCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_POPOUT_OPEN,data:e})};popOutCloseCallback=e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:lr.TRACK_POPOUT_CLOSE,data:e})};createLocalMicTrack(e=ri.music){let t=new Qr(e.capture);return t.publishState.defaultPublishOptions={...e.publish},this.localTracks.add(t),this.addTrackListeners(t),t}createLocalCustomAudioTrack(e){if(e.kind!=U.Audio)throw new R("MediaStreamTrack必须是音频轨");let t=new Kr;return t.setMediaStreamTrack(e),this.localTracks.add(t),this.addTrackListeners(t),t}createLocalCameraTrack(e=ni["720p"]){let t=new Yr(e.capture);return t.publishState.defaultPublishOptions={width:e.capture.width,height:e.capture.height,...e.publish},this.localTracks.add(t),this.addTrackListeners(t),t}createLocalScreenTrack(e=oi["1080p"],t=si.default){let r=new Xr(e.capture);if(r.publishState.defaultPublishOptions={width:e.capture.width,height:e.capture.height,...e.publish},this.localTracks.add(r),this.addTrackListeners(r),t){let e=new Gr(t.capture);e.publishState.defaultPublishOptions={...t.publish},this.localTracks.add(e),this.addTrackListeners(e),r.setAudioTrack(e)}return r}createLocalCustomVideoTrack(e){if(e.kind!=U.Video)throw new R("MediaStreamTrack必须是视频轨");let t=new Jr;return t.setMediaStreamTrack(e),this.localTracks.add(t),this.addTrackListeners(t),t}async enableLocalTrack(e){let t=e.getMediaStreamTrack();if(t&&"ended"===t.readyState){if(ie.warn(e.toString(),"enableLocalTrack 时 track 已 ended,尝试重新采集"),e instanceof Qr||e instanceof Yr)try{await e.startCapture()}catch(t){ie.error(e.toString(),"重新采集失败",t)}}else t&&(t.enabled=!0);if(e instanceof Xr){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.enableLocalTrack(t)}}disableLocalTrack(e){let t=e.getMediaStreamTrack();if(t&&(t.enabled=!1),e instanceof Xr){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&this.disableLocalTrack(t)}}async publishLocalTrack(e,t){if(!this.defaultChannel)throw x;return this.defaultChannel.publishLocalTrack(e,t)}async unpublishLocalTrack(e){if(!this.defaultChannel)throw x;await this.defaultChannel.unpublishLocalTrack(e)}async subscribeRemoteAudioMixTrack(e){let t=await super.subscribeRemoteAudioMixTrack(e);return this.addTrackListeners(t),t}async subscribeRemoteAudioTrack(e,t){let r=await super.subscribeRemoteAudioTrack(e,t);return this.addTrackListeners(r),r}async subscribeRemoteVideoMcuTrack(){let e=await super.subscribeRemoteVideoMcuTrack();return this.addTrackListeners(e),e}async subscribeRemoteVideoTrack(e,t){let r=await super.subscribeRemoteVideoTrack(e,t);return this.addTrackListeners(r),r}async unsubscribeRemoteTrack(e){await super.unsubscribeRemoteTrack(e)}getRemoteTrack(e,t,r){return super.getRemoteTrack(e,t,r)}}var vi=i.He,bi=i.L0,wi=i.Yk,ki=i.c3,_i=i.Mz,Si=i.Ne,Ei=i._N,Ti=i.bq,Ci=i.hj,Ai=i.h4,Pi=i.xk,Ri=i.J,xi=i.a7,Ii=i.tg,Mi=i.s_,Oi=i.VO,Bi=i.VF,Ni=i.M0,Li=i.$b,Di=i.WI,Ui=i.cp,ji=i.PN,Fi=i.ez,Vi=i.EQ,zi=i.$t,qi=i.jL,Wi=i.Ps,Hi=i.VV,Ki=i._b,$i=i.dT,Gi=i.CM,Qi=i.Zq;export{vi as BaseChannel,bi as BaseTrack,wi as CameraPresets,ki as Channel,_i as ChannelEventType,Si as Codec,Ei as ConnectionQuality,Ti as DeviceType,Ci as DisconnectReason,Ai as ImDisconnectReason,Pi as ImEventType,Ri as LocalAudioTrack,xi as LocalCameraTrack,Ii as LocalCompositeRecorder,Mi as LocalMicTrack,Oi as LocalScreenAudioTrack,Bi as LocalScreenTrack,Ni as LocalVideoTrack,Li as LogLevel,Di as LogTarget,Ui as MicPresets,ji as ProcessorPipeline,Fi as RemoteAudioMixTrack,Vi as RemoteAudioTrack,zi as RemoteVideoTrack,qi as SRTC,Wi as ScreenAudioPresets,Hi as ScreenPresets,Ki as TrackKind,$i as __INNER__,Gi as codec2str,Qi as createMixedAudioMediaStreamTrack};
1
+ var e={5964:(e,t,r)=>{var i=r(1626);const n=r(8987).EventEmitter,o=r(6394),s=r(9790),a=r(3124),c=r(8362),u=r(9996),l=r(4531).Writable,h=r(2982),d=r(1589),f=r(3633),p=r(1223),g=r(2290),m=r(5685)("mqttjs:client"),v=i?i.nextTick:function(e){setTimeout(e,0)},y=r.g.setImmediate||function(e){v(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND","ETIMEDOUT"],S={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(e,t){let r;t.properties&&(r=t.properties.topicAlias);let i=t.topic.toString();if(0===i.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(i=e.topicAliasSend.getTopicByAlias(r),void 0===i)return new Error("Unregistered Topic Alias");t.topic=i}r&&delete t.properties.topicAlias}function k(e,t,r){m("sendPacket :: packet: %O",t),m("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),m("sendPacket :: writing to stream");const i=c.writeToStream(t,e.stream,e.options);m("sendPacket :: writeToStream result %s",i),!i&&r&&r!==T?(m("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(m("sendPacket :: invoking cb"),r())}function E(e,t,r,i){m("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let n,o=t;if("publish"===o.cmd&&(o=f(t),n=_(e,o),n))return r&&r(n);e.outgoingStore.put(o,(function(n){if(n)return r&&r(n);i(),k(e,t,r)}))}function T(e){m("nop ::",e)}function C(e,t){let r;const i=this;if(!(this instanceof C))return new C(e,t);for(r in this.options=t||{},b)void 0===this.options[r]?this.options[r]=b[r]:this.options[r]=t[r];m("MqttClient :: options.protocol",t.protocol),m("MqttClient :: options.protocolVersion",t.protocolVersion),m("MqttClient :: options.username",t.username),m("MqttClient :: options.keepalive",t.keepalive),m("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),m("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),m("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),m("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new u:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new o,this.incomingStore=t.incomingStore||new o,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?m("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;m("connect :: sending queued packets"),function t(){const r=e.shift();m("deliver :: entry %o",r);let n=null;if(!r)return void i._resubscribe();n=r.packet,m("deliver :: call _sendPacket for %o",n);let o=!0;n.messageId&&0!==n.messageId&&(i.messageIdProvider.register(n.messageId)||(o=!1)),o?i._sendPacket(n,(function(e){r.cb&&r.cb(e),t()})):(m("messageId: %d has already used. The message is skipped and removed.",n.messageId),t())}()})),this.on("close",(function(){m("close :: connected set to `false`"),this.connected=!1,m("close :: clearing connackTimer"),clearTimeout(this.connackTimer),m("close :: clearing ping timer"),null!==i.pingTimer&&(i.pingTimer.clear(),i.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),m("close :: calling _setupReconnect"),this._setupReconnect()})),n.call(this),m("MqttClient :: setting up stream"),this._setupStream()}h(C,n),C.prototype._setupStream=function(){const e=this,t=new l,r=c.parser(this.options);let i=null;const n=[];function o(){if(n.length)v(s);else{const e=i;i=null,e()}}function s(){m("work :: getting next packet in queue");const t=n.shift();if(t)m("work :: packet pulled from queue"),e._handlePacket(t,o);else{m("work :: no packets in queue");const e=i;i=null,m("work :: done flag is %s",!!e),e&&e()}}m("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),m("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){m("parser :: on packet push to packets array."),n.push(e)})),t._write=function(e,t,n){i=n,m("writable stream :: parsing buffer"),r.parse(e),s()},m("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",(function(t){m("streamErrorHandler :: error",t.message),w.includes(t.code)?(m("streamErrorHandler :: emitting error"),e.emit("error",t)):T(t)})),this.stream.on("close",(function(){var t;m("(%s)stream :: on close",e.options.clientId),(t=e.outgoing)&&(m("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach((function(e){t[e].volatile&&"function"==typeof t[e].cb&&(t[e].cb(new Error("Connection closed")),delete t[e])}))),m("stream: emit close to MqttClient"),e.emit("close")})),m("_setupStream: sending packet `connect`");const a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),k(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket){k(this,g({cmd:"auth",reasonCode:0},this.options.authPacket))}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){m("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},C.prototype._handlePacket=function(e,t){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(m("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},C.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==T?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},C.prototype.publish=function(e,t,r,i){m("publish :: message `%s` to topic `%s`",t,e);const n=this.options;"function"==typeof r&&(i=r,r=null);if(r=g({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(i))return this;const o=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=o._nextId(),null===s))return m("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===n.protocolVersion&&(a.properties=r.properties),m("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[a.messageId]={volatile:!1,cb:i||T},m("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,void 0,r.cbStorePut);break;default:m("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,i,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:i}),this},C.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const r=[];let i=t.shift();const n=i.resubscribe;let o=t.pop()||T,s=t.pop();const a=this.options.protocolVersion;delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof o&&(s=o,o=T);const c=p.validateTopics(i);if(null!==c)return y(o,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(o))return m("subscribe: discconecting true"),this;const u={qos:0};if(5===a&&(u.nl=!1,u.rap=!1,u.rh=0),s=g(u,s),Array.isArray(i)?i.forEach((function(t){if(m("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||n){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),m("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e)}})):Object.keys(i).forEach((function(t){if(m("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<i[t].qos||n){const e={topic:t,qos:i[t].qos};5===a&&(e.nl=i[t].nl,e.rap=i[t].rap,e.rh=i[t].rh,e.properties=s.properties),m("subscribe: pushing `%s` to subs list",e),r.push(e)}})),!r.length)return o(null,[]),this;const l=function(){const t=e._nextId();if(null===t)return m("No messageId left"),!1;const i={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(i.properties=s.properties),e.options.resubscribe){m("subscribe :: resubscribe true");const t=[];r.forEach((function(r){if(e.options.reconnectPeriod>0){const i={qos:r.qos};5===a&&(i.nl=r.nl||!1,i.rap=r.rap||!1,i.rh=r.rh||0,i.properties=r.properties),e._resubscribeTopics[r.topic]=i,t.push(r.topic)}})),e.messageIdToTopic[i.messageId]=t}return e.outgoing[i.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t]}o(e,r)}},m("subscribe :: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!l())&&this._storeProcessingQueue.push({invoke:l,callback:o}),this},C.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),i=t.pop()||T,n=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof i&&(n=i,i=T);const o=p.validateTopics(r);if(null!==o)return y(i,new Error("Invalid topic "+o)),this;if(e._checkDisconnecting(i))return this;const s=function(){const t=e._nextId();if(null===t)return m("No messageId left"),!1;const o={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof r?o.unsubscriptions=[r]:Array.isArray(r)&&(o.unsubscriptions=r),e.options.resubscribe&&o.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof n&&n.properties&&(o.properties=n.properties),e.outgoing[o.messageId]={volatile:!0,cb:i},m("unsubscribe: call _sendPacket"),e._sendPacket(o),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:i}),this},C.prototype.end=function(e,t,r){const i=this;function n(){m("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close((function(e){i.outgoingStore.close((function(t){if(m("end :: closeStores: emitting end"),i.emit("end"),r){const i=e||t;m("end :: closeStores: invoking callback with args"),r(i)}}))})),i._deferredReconnect&&i._deferredReconnect()}function o(){m("end :: (%s) :: finish :: calling _cleanUp with force %s",i.options.clientId,e),i._cleanUp(e,(()=>{m("end :: finish :: calling process.nextTick on closeStores"),v(n.bind(i))}),t)}return m("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||T,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=T))),"object"!=typeof t&&(r=t,t=null),m("end :: cb? %s",!!r),r=r||T,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(m("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(m("end :: (%s) :: immediately calling finish",i.options.clientId),o()),this)},C.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},C.prototype.reconnect=function(e){m("client reconnect");const t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},C.prototype._reconnect=function(){m("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),m("client already connected. disconnecting first.")):(m("_reconnect: calling _setupStream"),this._setupStream())},C.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(m("_setupReconnect :: emit `offline` state"),this.emit("offline"),m("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),m("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){m("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):m("_setupReconnect :: doing nothing...")},C.prototype._clearReconnect=function(){m("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},C.prototype._cleanUp=function(e,t){const r=arguments[2];if(t&&(m("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),m("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&(i=this.outgoing)&&(m("flush: queue exists? %b",!!i),Object.keys(i).forEach((function(e){"function"==typeof i[e].cb&&(i[e].cb(new Error("Connection closed")),delete i[e])}))),m("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=g({cmd:"disconnect"},r);m("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,y.bind(null,this.stream.end.bind(this.stream)))}var i;this.disconnecting||(m("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(m("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(m("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},C.prototype._sendPacket=function(e,t,r){m("_sendPacket :: (%s) :: start",this.options.clientId),r=r||T,t=t||T;const i=function(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);const i=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==i.length&&(m("applyTopicAlias :: register topic: %s - alias: %d",i,r),!e.topicAliasSend.put(i,r)))return m("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}else 0!==i.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(i),r?(t.topic="",t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",i,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(i,r),t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto assign topic: %s - alias: %d",i,r))):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(i),r&&(t.topic="",t.properties={...t.properties,topicAlias:r},m("applyTopicAlias :: auto use topic: %s - alias: %d",i,r))));else if(r)return m("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}}(this,e);if(i)t(i);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void k(this,e,t)):(m("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void E(this,e,t,r);default:return void k(this,e,t)}switch(e.qos){case 2:case 1:E(this,e,t,r);break;default:k(this,e,t)}m("_sendPacket :: (%s) :: end",this.options.clientId)}},C.prototype._storePacket=function(e,t,r){m("_storePacket :: packet: %o",e),m("_storePacket :: cb? %s",!!t),r=r||T;let i=e;if("publish"===i.cmd){i=f(e);const r=_(this,i);if(r)return t&&t(r)}0===(i.qos||0)&&this.queueQoSZero||"publish"!==i.cmd?this.queue.push({packet:i,cb:t}):i.qos>0?(t=this.outgoing[i.messageId]?this.outgoing[i.messageId].cb:null,this.outgoingStore.put(i,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},C.prototype._setupPingTimer=function(){m("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=d((function(){e._checkPing()}),1e3*this.options.keepalive))},C.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},C.prototype._checkPing=function(){m("_checkPing :: checking ping..."),this.pingResp?(m("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(m("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},C.prototype._handlePingresp=function(){this.pingResp=!0},C.prototype._handleConnack=function(e){m("_handleConnack");const t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){const e=new Error("Connection refused: "+S[r]);e.code=r,this.emit("error",e)}},C.prototype._handleAuth=function(e){const t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=r,void this.emit("error",e)}const i=this;this.handleAuth(e,(function(e,t){if(e)i.emit("error",e);else if(24===r)i.reconnecting=!1,i._sendPacket(t);else{const t=new Error("Connection refused: "+S[r]);e.code=r,i.emit("error",t)}}))},C.prototype.handleAuth=function(e,t){t()},C.prototype._handlePublish=function(e,t){m("_handlePublish: packet %o",e),t=void 0!==t?t:T;let r=e.topic.toString();const i=e.payload,n=e.qos,o=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length){if(!(t>0&&t<=65535))return m("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return m("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));r=e,m("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,t)}}else{if(!this.topicAliasRecv.put(r,t))return m("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));m("_handlePublish :: registered topic: %s - alias: %d",r,t)}}switch(m("_handlePublish: qos %d",n),n){case 2:a.customHandleAcks(r,i,e,(function(r,i){return r instanceof Error||(i=r,r=null),r?s.emit("error",r):-1===c.indexOf(i)?s.emit("error",new Error("Wrong reason code for pubrec")):void(i?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:i},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:o},t)})))}));break;case 1:a.customHandleAcks(r,i,e,(function(n,a){return n instanceof Error||(a=n,n=null),n?s.emit("error",n):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,i,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,i,e),this.handleMessage(e,t);break;default:m("_handlePublish: unknown QoS. Doing nothing.")}},C.prototype.handleMessage=function(e,t){t()},C.prototype._handleAck=function(e){const t=e.messageId,r=e.cmd;let i=null;const n=this.outgoing[t]?this.outgoing[t].cb:null,o=this;let s;if(n){switch(m("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=e.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+S[r]),s.code=r,n(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,n),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{i={cmd:"pubrel",qos:2,messageId:t};const r=e.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+S[r]),s.code=r,n(s,e)):this._sendPacket(i);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let r=0;r<e.granted.length;r++)if(128&e.granted[r]){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete o._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),n(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),n(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else m("_handleAck :: Server sent an ack in error. Ignoring.")},C.prototype._handlePubrel=function(e,t){m("handling pubrel packet"),t=void 0!==t?t:T;const r=e.messageId,i=this,n={cmd:"pubcomp",messageId:r};i.incomingStore.get(e,(function(e,r){e?i._sendPacket(n,t):(i.emit("message",r.topic,r.payload,r),i.handleMessage(r,(function(e){if(e)return t(e);i.incomingStore.del(r,T),i._sendPacket(n,t)})))}))},C.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},C.prototype._nextId=function(){return this.messageIdProvider.allocate()},C.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},C.prototype._resubscribe=function(){m("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){m("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=!0,this.subscribe(r,{properties:r[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},C.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function r(){let i=t.outgoingStore.createStream();function n(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function o(){i.destroy(),i=null,t._flushStoreProcessingQueue(),n()}t.once("close",o),i.on("error",(function(e){n(),t._flushStoreProcessingQueue(),t.removeListener("close",o),t.emit("error",e)})),i.on("end",(function(){let i=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){i=!1;break}i?(n(),t.removeListener("close",o),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r()})),function e(){if(!i)return;t._storeProcessing=!0;const r=i.read(1);let n;r?t._packetIdsDuringStoreProcessing[r.messageId]?e():t.disconnecting||t.reconnectTimer?i.destroy&&i.destroy():(n=t.outgoing[r.messageId]?t.outgoing[r.messageId].cb:null,t.outgoing[r.messageId]={volatile:!1,cb:function(t,r){n&&n(t,r),e()}},t._packetIdsDuringStoreProcessing[r.messageId]=!0,t.messageIdProvider.register(r.messageId)?t._sendPacket(r):m("messageId: %d has already used.",r.messageId)):i.once("readable",e)}()}()},C.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},C.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},C.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},e.exports=C},2670:(e,t,r)=>{const{Buffer:i}=r(6459),n=r(4531).Transform,o=r(1019);let s,a,c,u=!1;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const l=function(e,t){const r="alis"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);return s=t.my,s.connectSocket({url:l,protocols:r}),a=function(){const e=new n;return e._write=function(e,t,r){s.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}(),c=o.obj(),u||(u=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=i.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?i.from(e):i.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)}))),c}},7594:(e,t,r)=>{var i=r(1626);const n=r(5964),o=r(6394),s=r(9199),a=r(2290),c=r(5685)("mqttjs"),u={};function l(e,t){if(c("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const r=s.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=a(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!u[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,r){return(!e||r%2!=0)&&"function"==typeof u[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);const r=new n((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),c("calling streambuilder for",t.protocol),u[t.protocol](e,t)}),t);return r.on("error",(function(){})),r}void 0!==i&&"browser"!==i.title||"function"!=typeof r?(u.mqtt=r(8793),u.tcp=r(8793),u.ssl=r(5351),u.tls=r(5351),u.mqtts=r(5351)):(u.wx=r(3027),u.wxs=r(3027),u.ali=r(2670),u.alis=r(2670)),u.ws=r(5838),u.wss=r(5838),e.exports=l,e.exports.connect=l,e.exports.MqttClient=n,e.exports.Store=o},8793:(e,t,r)=>{const i=r(5653),n=r(5685)("mqttjs:tcp");e.exports=function(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const r=t.port,o=t.hostname;return n("port %d and host %s",r,o),i.createConnection(r,o)}},5351:(e,t,r)=>{const i=r(8535),n=r(5653),o=r(5685)("mqttjs:tls");e.exports=function(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===n.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const r=i.connect(t);function s(i){t.rejectUnauthorized&&e.emit("error",i),r.end()}return r.on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s)})),r.on("error",s),r}},5838:(e,t,r)=>{var i=r(1626);const{Buffer:n}=r(6459),o=r(891),s=r(5685)("mqttjs:ws"),a=r(1019),c=r(4531).Transform,u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==i&&"browser"===i.title||"function"==typeof r;function h(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function d(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||u.forEach((function(r){Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,r)&&(t.wsOptions[r]=e[r])})),t}e.exports=l?function(e,t){let r;s("browserStreamBuilder");const i=function(e){const t=d(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t).browserBufferSize||524288,o=t.browserBufferTimeout||1e3,u=!t.objectMode,l=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",i=h(t,e),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}(e,t),f=function(e,t,r){const i=new c({objectModeMode:e.objectMode});return i._write=t,i._flush=r,i}(t,(function e(t,r,s){l.bufferedAmount>i&&setTimeout(e,o,t,r,s),u&&"string"==typeof t&&(t=n.from(t,"utf8"));try{l.send(t)}catch(e){return s(e)}s()}),(function(e){l.close(),e()}));t.objectMode||(f._writev=b),f.on("close",(()=>{l.close()}));const p=void 0!==l.addEventListener;function g(){r.setReadable(f),r.setWritable(f),r.emit("connect")}function m(){r.end(),r.destroy()}function v(e){r.destroy(e)}function y(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),f.push(t)}function b(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}return l.readyState===l.OPEN?r=f:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=b),p?l.addEventListener("open",g):l.onopen=g),r.socket=l,p?(l.addEventListener("close",m),l.addEventListener("error",v),l.addEventListener("message",y)):(l.onclose=m,l.onerror=v,l.onmessage=y),r}:function(e,t){s("streamBuilder");const r=d(t),i=h(r,e),n=function(e,t,r){s("createWebSocket"),s("protocol: "+r.protocolId+" "+r.protocolVersion);const i="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return s("creating new Websocket for url: "+t+" and protocol: "+i),new o(t,[i],r.wsOptions)}(0,i,r),a=o.createWebSocketStream(n,r.wsOptions);return a.url=i,n.on("close",(()=>{a.destroy()})),a}},3027:(e,t,r)=>{const{Buffer:i}=r(6459),n=r(4531).Transform,o=r(1019);let s,a,c;e.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const u=function(e,t){const r="wxs"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);return s=wx.connectSocket({url:u,protocols:[r]}),a=function(){const e=new n;return e._write=function(e,t,r){s.send({data:0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}(),c=o.obj(),s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?i.from(t):i.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))})),c}},9996:e=>{function t(){if(!(this instanceof t))return new t;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}t.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},t.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},t.prototype.register=function(e){return!0},t.prototype.deallocate=function(e){},t.prototype.clear=function(){},e.exports=t},6394:(e,t,r)=>{const i=r(2290),n=r(4531).Readable,o={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=i(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new n(o),t=[];let r=!1,i=0;return this._inflights.forEach((function(e,r){t.push(e)})),e._read=function(){!r&&i<t.length?this.push(t[i++]):this.push(null)},e.destroy=function(){if(r)return;const e=this;r=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},e.exports=a},9790:e=>{function t(e){if(!(this instanceof t))return new t(e);this.aliasToTopic={},this.max=e}t.prototype.put=function(e,t){return!(0===t||t>this.max)&&(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,!0)},t.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},t.prototype.clear=function(){this.aliasToTopic={}},e.exports=t},3124:(e,t,r)=>{const i=r(7321),n=r(4508).t;function o(e){if(!(this instanceof o))return new o(e);e>0&&(this.aliasToTopic=new i({max:e}),this.topicToAlias={},this.numberAllocator=new n(1,e),this.max=e,this.length=0)}o.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},o.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},o.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},o.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},e.exports=o},1223:e=>{function t(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(let r=0;r<e.length;r++)if(!t(e[r]))return e[r];return null}}},1498:(e,t)=>{t.byteLength=function(e){var t=a(e),r=t[0],i=t[1];return 3*(r+i)/4-i},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],c=o[1],u=new n(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),l=0,h=c>0?s-4:s;for(r=0;r<h;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===c&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===c&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,i=e.length,n=i%3,o=[],s=16383,a=0,u=i-n;a<u;a+=s)o.push(c(e,a,a+s>u?u:a+s));1===n?(t=e[i-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===n&&(t=(e[i-2]<<8)+e[i-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],i[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,i){for(var n,o,s=[],a=t;a<i;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=n)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},5017:(e,t,r)=>{const{Buffer:i}=r(6745),n=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,n,{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 r=0;r<this._bufs.length;r++){const i=t+this._bufs[r].length;if(e<i||r===this._bufs.length-1)return[r,e-t];t=i}},o.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},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,r,n){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof n||n>this.length)&&(n=this.length),r>=this.length)return e||i.alloc(0);if(n<=0)return e||i.alloc(0);const o=!!e,s=this._offset(r),a=n-r;let c=a,u=o&&t||0,l=s[1];if(0===r&&n===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:i.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,u),u+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-l)return o?this._bufs[s[0]].copy(e,t,l,l+c):this._bufs[s[0]].slice(l,l+c);o||(e=i.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-l;if(!(c>r)){this._bufs[t].copy(e,u,l,l+c),u+=r;break}this._bufs[t].copy(e,u,l),u+=r,c-=r,l&&(l=0)}return e.length>u?e.slice(0,u):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 r=this._offset(e),i=this._offset(t),n=this._bufs.slice(r[0],i[0]+1);return 0===i[1]?n.pop():n[n.length-1]=n[n.length-1].slice(0,i[1]),0!==r[1]&&(n[0]=n[0].slice(r[1])),this._new(n)},o.prototype.toString=function(e,t,r){return this.slice(t,r).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(i.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(i.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=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=i.from([e]):"string"==typeof e?e=i.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=i.from(e.buffer,e.byteOffset,e.byteLength):i.isBuffer(e)||(e=i.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 n=this._offset(t);let o=n[0],s=n[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;s<t.length;){if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}}s=0}return-1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])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,r){return this.slice(e,e+r)[t](0,r)}:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.slice(r,r+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[n]},e.exports=o},3209:(e,t,r)=>{const i=r(4531).Duplex,n=r(2982),o=r(5017);function s(e){if(!(this instanceof s))return new s(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),i.call(this)}n(s,i),Object.assign(s.prototype,o.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.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)},s.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof o||s.isBufferList(e)},s.isBufferList=o.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=o},6745:(e,t,r)=>{var i=r(1498),n=r(4959),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|g(e,t),i=a(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(V(e,Uint8Array)){var t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(V(e,ArrayBuffer)||e&&V(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(V(e,SharedArrayBuffer)||e&&V(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,r);var n=function(e){if(c.isBuffer(e)){var t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||W(e.length)?a(0):d(e);if("Buffer"===e.type&&Array.isArray(e.data))return d(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=a(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(i,c.prototype),i}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||V(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(e).length;default:if(n)return i?-1:j(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function v(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function y(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:b(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,i,n){var o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function w(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function S(e,t,r,i){return F(j(t,e.length-r),e,r,i)}function _(e,t,r,i){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function k(e,t,r,i){return F(U(t),e,r,i)}function E(e,t,r,i){return F(function(e,t){for(var r,i,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function T(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,s,a,c,u=e[n],l=null,h=u>239?4:u>223?3:u>191?2:1;if(n+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=h}return function(e){var t=e.length;if(t<=P)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=P));return r}(i)}t.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return l(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},c.allocUnsafe=function(e){return h(e)},c.allocUnsafeSlow=function(e){return h(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=c.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(V(o,Uint8Array))n+o.length>i.length?c.from(o).copy(i,n):Uint8Array.prototype.set.call(i,o,n);else{if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n)}n+=o.length}return i},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)v(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)v(this,t,t+3),v(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)v(this,t,t+7),v(this,t+1,t+6),v(this,t+2,t+5),v(this,t+3,t+4);return this},c.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):m.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,i,n){if(V(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(i,n),l=e.slice(t,r),h=0;h<a;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":case"latin1":case"binary":return _(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var P=4096;function A(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function I(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function R(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=t;o<r;++o)n+=q[e[o]];return n}function x(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function O(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,i,n,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function N(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,i,o){return t=+t,r>>>=0,o||N(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function B(e,t,r,i,o){return t=+t,r>>>=0,o||N(e,0,r,8),n.write(e,t,r,i,52,8),r+8}c.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var i=this.subarray(e,t);return Object.setPrototypeOf(i,c.prototype),i},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n=i-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),n},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=c.isBuffer(e)?e:c.from(e,i),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var D=/[^+/0-9A-Za-z-_]/g;function j(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function V(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}var q=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=16*r,n=0;n<16;++n)t[i+n]=e[r]+e[n];return t}()},6459:(e,t,r)=>{var i=r(1498),n=r(4959);t.Buffer=a,t.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},t.INSPECT_MAX_BYTES=50;var o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|f(e,t),i=s(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(V(e,ArrayBuffer)||e&&V(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r);return i.__proto__=a.prototype,i}(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return a.from(i,t,r);var n=function(e){if(a.isBuffer(e)){var t=0|d(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||W(e.length)?s(0):h(e);if("Buffer"===e.type&&Array.isArray(e.data))return h(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return u(e),s(e<0?0:0|d(e))}function h(e){for(var t=e.length<0?0:0|d(e.length),r=s(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function d(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function f(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||V(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(e).length;default:if(n)return i?-1:j(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return P(this,t,r);case"latin1":case"binary":return A(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function g(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function m(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=a.from(t,i)),a.isBuffer(t))return 0===t.length?-1:v(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,i,n){var o,s=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function y(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function b(e,t,r,i){return F(j(t,e.length-r),e,r,i)}function w(e,t,r,i){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function S(e,t,r,i){return w(e,t,r,i)}function _(e,t,r,i){return F(U(t),e,r,i)}function k(e,t,r,i){return F(function(e,t){for(var r,i,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function E(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,s,a,c,u=e[n],l=null,h=u>239?4:u>223?3:u>191?2:1;if(n+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[n+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=h}return function(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);var r="",i=0;for(;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=C));return r}(i)}t.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return c(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}(e,t,r)},a.allocUnsafe=function(e){return l(e)},a.allocUnsafeSlow=function(e){return l(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(V(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=a.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(V(o,Uint8Array)&&(o=a.from(o)),!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},a.byteLength=f,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?T(this,0,e):p.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,i,n){if(V(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(t>>>=0),c=Math.min(o,s),u=this.slice(i,n),l=e.slice(t,r),h=0;h<c;++h)if(u[h]!==l[h]){o=u[h],s=l[h];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},a.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function A(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function I(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=t;o<r;++o)n+=D(e[o]);return n}function R(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function x(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,r,i,n,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function M(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,i,o){return t=+t,r>>>=0,o||M(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function L(e,t,r,i,o){return t=+t,r>>>=0,o||M(e,0,r,8),n.write(e,t,r,i,52,8),r+8}a.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var i=this.subarray(e,t);return i.__proto__=a.prototype,i},a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||x(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||x(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},a.prototype.readUInt8=function(e,t){return e>>>=0,t||x(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||x(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||x(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||x(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||x(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||x(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||x(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return e>>>=0,t||x(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||x(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||x(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||x(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||x(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||x(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||x(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||x(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||x(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||O(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||O(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);O(this,e,t,r,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);O(this,e,t,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,i){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n=i-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,i);else if(this===e&&r<t&&t<i)for(var o=n-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),t);return n},a.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=a.isBuffer(e)?e:a.from(e,i),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%c]}return this};var B=/[^+/0-9A-Za-z-_]/g;function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function V(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}},7567:(e,t,r)=>{var i=r(9811),n=r(3670),o=r(376),s=r(7595);e.exports=s||i.call(o,n)},3670:e=>{e.exports=Function.prototype.apply},376:e=>{e.exports=Function.prototype.call},7618:(e,t,r)=>{var i=r(9811),n=r(5471),o=r(376),s=r(7567);e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new n("a function is required");return s(i,o,e)}},7595:e=>{e.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},9584:(e,t,r)=>{var i=r(3601),n=r(7618),o=n([i("%String.prototype.indexOf%")]);e.exports=function(e,t){var r=i(e,!!t);return"function"==typeof r&&o(e,".prototype.")>-1?n([r]):r}},5685:(e,t,r)=>{var i=r(1626);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let i=0,n=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),t.splice(n,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(6628)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},6628:(e,t,r)=>{e.exports=function(e){function t(e){let r,n,o,s=null;function a(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];if(!a.enabled)return;const o=a,s=Number(new Date),c=s-(r||s);o.diff=c,o.prev=r,o.curr=s,r=s,i[0]=t.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");let u=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";u++;const n=t.formatters[r];if("function"==typeof n){const t=i[u];e=n.call(o,t),i.splice(u,1),u--}return e})),t.formatArgs.call(o,i);(o.log||t.log).apply(o,i)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==t.namespaces&&(n=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,r){const i=t(this.namespace+(void 0===r?":":r)+e);return i.log=this.log,i}function n(e,t){let r=0,i=0,n=-1,o=0;for(;r<e.length;)if(i<t.length&&(t[i]===e[r]||"*"===t[i]))"*"===t[i]?(n=i,o=r,i++):(r++,i++);else{if(-1===n)return!1;i=n+1,o++,r=o}for(;i<t.length&&"*"===t[i];)i++;return i===t.length}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,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=r(1149),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((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},9948:(e,t,r)=>{var i,n=r(7618),o=r(9975);try{i=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var s=!!i&&o&&o(Object.prototype,"__proto__"),a=Object,c=a.getPrototypeOf;e.exports=s&&"function"==typeof s.get?n([s.get]):"function"==typeof c&&function(e){return c(null==e?e:a(e))}},1019:(e,t,r)=>{var i=r(6459).Buffer,n=r(1626),o=r(4531),s=r(3367),a=r(2982),c=r(1808),u=i.from&&i.from!==Uint8Array.from?i.from([0]):new i([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},h=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},d=function(){},f=function(e,t,r){if(!(this instanceof f))return new f(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};a(f,o.Duplex),f.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new f(e,t,r)},f.prototype.cork=function(){1==++this._corked&&this.emit("cork")},f.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},f.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=s(e,{writable:!0,readable:!1},h(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()}else this.end()},f.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,i=s(e,{writable:!1,readable:!0},h(this)),n=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",n),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",n),r._readable2.removeListener("end",a),i()},this._forward()}},f.prototype._read=function(){this._drained=!0,this._forward()},f.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=c(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},f.prototype.destroy=function(e,t){if(t||(t=d),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},f.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},f.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},f.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){var r,i;r=t._forwardEnd&&t._writable,i=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)},r?r._writableState&&r._writableState.finished?i():r._writableState?r.end(i):(r.end(),i()):i()}))},f.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},e.exports=f},3367:(e,t,r)=>{var i=r(1626),n=r(8491),o=function(){},s=r.g.Bare?queueMicrotask:i.nextTick.bind(i),a=function(e,t,r){if("function"==typeof t)return a(e,null,t);t||(t={}),r=n(r||o);var i=e._writableState,c=e._readableState,u=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,h=!1,d=function(){e.writable||f()},f=function(){l=!1,u||r.call(e)},p=function(){u=!1,l||r.call(e)},g=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},m=function(t){r.call(e,t)},v=function(){s(y)},y=function(){if(!h)return(!u||c&&c.ended&&!c.destroyed)&&(!l||i&&i.ended&&!i.destroyed)?void 0:r.call(e,new Error("premature close"))},b=function(){e.req.on("finish",f)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!i&&(e.on("end",d),e.on("close",d)):(e.on("complete",f),e.on("abort",v),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",g),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",v),function(){h=!0,e.removeListener("complete",f),e.removeListener("abort",v),e.removeListener("request",b),e.req&&e.req.removeListener("finish",f),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",f),e.removeListener("exit",g),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",v)}};e.exports=a},275:e=>{var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}e.exports=t},897:e=>{e.exports=EvalError},2491:e=>{e.exports=Error},6974:e=>{e.exports=RangeError},4766:e=>{e.exports=ReferenceError},5464:e=>{e.exports=SyntaxError},5471:e=>{e.exports=TypeError},741:e=>{e.exports=URIError},5624:e=>{e.exports=Object},8987:e=>{var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,n,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(o){i.once&&e.removeEventListener(t,n),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)i(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},1429:e=>{var t=Object.prototype.toString,r=Math.max,i=function(e,t){for(var r=[],i=0;i<e.length;i+=1)r[i]=e[i];for(var n=0;n<t.length;n+=1)r[n+e.length]=t[n];return r};e.exports=function(e){var n=this;if("function"!=typeof n||"[object Function]"!==t.apply(n))throw new TypeError("Function.prototype.bind called on incompatible "+n);for(var o,s=function(e,t){for(var r=[],i=t||0,n=0;i<e.length;i+=1,n+=1)r[n]=e[i];return r}(arguments,1),a=r(0,n.length-s.length),c=[],u=0;u<a;u++)c[u]="$"+u;if(o=Function("binder","return function ("+function(e,t){for(var r="",i=0;i<e.length;i+=1)r+=e[i],i+1<e.length&&(r+=t);return r}(c,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var t=n.apply(this,i(s,arguments));return Object(t)===t?t:this}return n.apply(e,i(s,arguments))})),n.prototype){var l=function(){};l.prototype=n.prototype,o.prototype=new l,l.prototype=null}return o}},9811:(e,t,r)=>{var i=r(1429);e.exports=Function.prototype.bind||i},3601:(e,t,r)=>{var i,n=r(5624),o=r(2491),s=r(897),a=r(6974),c=r(4766),u=r(5464),l=r(5471),h=r(741),d=r(3366),f=r(8692),p=r(7744),g=r(686),m=r(7860),v=r(4442),y=r(5433),b=Function,w=function(e){try{return b('"use strict"; return ('+e+").constructor;")()}catch(e){}},S=r(9975),_=r(275),k=function(){throw new l},E=S?function(){try{return k}catch(e){try{return S(arguments,"callee").get}catch(e){return k}}}():k,T=r(6123)(),C=r(6008),P=r(2220),A=r(2116),I=r(3670),R=r(376),x={},O="undefined"!=typeof Uint8Array&&C?C(Uint8Array):i,M={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?i:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?i:ArrayBuffer,"%ArrayIteratorPrototype%":T&&C?C([][Symbol.iterator]()):i,"%AsyncFromSyncIteratorPrototype%":i,"%AsyncFunction%":x,"%AsyncGenerator%":x,"%AsyncGeneratorFunction%":x,"%AsyncIteratorPrototype%":x,"%Atomics%":"undefined"==typeof Atomics?i:Atomics,"%BigInt%":"undefined"==typeof BigInt?i:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?i:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?i:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?i:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":s,"%Float16Array%":"undefined"==typeof Float16Array?i:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?i:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?i:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?i:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":x,"%Int8Array%":"undefined"==typeof Int8Array?i:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?i:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?i:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":T&&C?C(C([][Symbol.iterator]())):i,"%JSON%":"object"==typeof JSON?JSON:i,"%Map%":"undefined"==typeof Map?i:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&T&&C?C((new Map)[Symbol.iterator]()):i,"%Math%":Math,"%Number%":Number,"%Object%":n,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?i:Promise,"%Proxy%":"undefined"==typeof Proxy?i:Proxy,"%RangeError%":a,"%ReferenceError%":c,"%Reflect%":"undefined"==typeof Reflect?i:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?i:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&T&&C?C((new Set)[Symbol.iterator]()):i,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?i:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":T&&C?C(""[Symbol.iterator]()):i,"%Symbol%":T?Symbol:i,"%SyntaxError%":u,"%ThrowTypeError%":E,"%TypedArray%":O,"%TypeError%":l,"%Uint8Array%":"undefined"==typeof Uint8Array?i:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?i:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?i:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?i:Uint32Array,"%URIError%":h,"%WeakMap%":"undefined"==typeof WeakMap?i:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?i:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?i:WeakSet,"%Function.prototype.call%":R,"%Function.prototype.apply%":I,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":P,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":g,"%Math.pow%":m,"%Math.round%":v,"%Math.sign%":y,"%Reflect.getPrototypeOf%":A};if(C)try{null.error}catch(e){var N=C(C(e));M["%Error.prototype%"]=N}var L=function e(t){var r;if("%AsyncFunction%"===t)r=w("async function () {}");else if("%GeneratorFunction%"===t)r=w("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=w("async function* () {}");else if("%AsyncGenerator%"===t){var i=e("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if("%AsyncIteratorPrototype%"===t){var n=e("%AsyncGenerator%");n&&C&&(r=C(n.prototype))}return M[t]=r,r},B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},D=r(9811),j=r(2489),U=D.call(R,Array.prototype.concat),F=D.call(I,Array.prototype.splice),V=D.call(R,String.prototype.replace),W=D.call(R,String.prototype.slice),q=D.call(R,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,z=function(e,t){var r,i=e;if(j(B,i)&&(i="%"+(r=B[i])[0]+"%"),j(M,i)){var n=M[i];if(n===x&&(n=L(i)),void 0===n&&!t)throw new l("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:n}}throw new u("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new l('"allowMissing" argument must be a boolean');if(null===q(/^%?[^%]*%?$/,e))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=W(e,0,1),r=W(e,-1);if("%"===t&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new u("invalid intrinsic syntax, expected opening `%`");var i=[];return V(e,H,(function(e,t,r,n){i[i.length]=r?V(n,K,"$1"):t||e})),i}(e),i=r.length>0?r[0]:"",n=z("%"+i+"%",t),o=n.name,s=n.value,a=!1,c=n.alias;c&&(i=c[0],F(r,U([0,1],c)));for(var h=1,d=!0;h<r.length;h+=1){var f=r[h],p=W(f,0,1),g=W(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===g||"'"===g||"`"===g)&&p!==g)throw new u("property names with quotes must have matching quotes");if("constructor"!==f&&d||(a=!0),j(M,o="%"+(i+="."+f)+"%"))s=M[o];else if(null!=s){if(!(f in s)){if(!t)throw new l("base intrinsic for "+e+" exists, but the property is not available.");return}if(S&&h+1>=r.length){var m=S(s,f);s=(d=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:s[f]}else d=j(s,f),s=s[f];d&&!a&&(M[o]=s)}}return s}},2220:(e,t,r)=>{var i=r(5624);e.exports=i.getPrototypeOf||null},2116:e=>{e.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},6008:(e,t,r)=>{var i=r(2116),n=r(2220),o=r(9948);e.exports=i?function(e){return i(e)}:n?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return n(e)}:o?function(e){return o(e)}:null},8593:e=>{e.exports=Object.getOwnPropertyDescriptor},9975:(e,t,r)=>{var i=r(8593);if(i)try{i([],"length")}catch(e){i=null}e.exports=i},6123:(e,t,r)=>{var i="undefined"!=typeof Symbol&&Symbol,n=r(2441);e.exports=function(){return"function"==typeof i&&("function"==typeof Symbol&&("symbol"==typeof i("foo")&&("symbol"==typeof Symbol("bar")&&n())))}},2441:e=>{e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var i in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},2489:(e,t,r)=>{var i=Function.prototype.call,n=Object.prototype.hasOwnProperty,o=r(9811);e.exports=o.call(i,n)},4959:(e,t)=>{t.read=function(e,t,r,i,n){var o,s,a=8*n-i-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?n-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),o-=u}return(f?-1:1)*s*Math.pow(2,o-i)},t.write=function(e,t,r,i,n,o){var s,a,c,u=8*o-n-1,l=(1<<u)-1,h=l>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,p=i?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;e[r+f]=255&a,f+=p,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*g}},2982:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},222:(e,t,r)=>{r.d(t,{CD:()=>E});var i,n=(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=function(){function e(e,t){this.ee=1,this.u=void 0,this.p=void 0,this.K=void 0,this.N=void 0,this.rr=void 0,this.u=e,this.p=t}return e.prototype.L=function(){var e=this;if(1===e.ee&&e.rr.rr===e)e=e.N;else if(e.K)for(e=e.K;e.N;)e=e.N;else{for(var t=e.rr;t.K===e;)t=(e=t).rr;e=t}return e},e.prototype.m=function(){var e=this;if(e.N){for(e=e.N;e.K;)e=e.K;return e}for(var t=e.rr;t.N===e;)t=(e=t).rr;return e.N!==t?t:e},e.prototype.ne=function(){var e=this.rr,t=this.N,r=t.K;return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.K=this,this.rr=t,this.N=r,r&&(r.rr=this),t},e.prototype.te=function(){var e=this.rr,t=this.K,r=t.N;return e.rr===this?e.rr=t:e.K===this?e.K=t:e.N=t,t.rr=e,t.N=this,this.rr=t,this.K=r,r&&(r.rr=this),t},e}(),s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.tr=1,t}return n(t,e),t.prototype.ne=function(){var t=e.prototype.ne.call(this);return this.ie(),t.ie(),t},t.prototype.te=function(){var t=e.prototype.te.call(this);return this.ie(),t.ie(),t},t.prototype.ie=function(){this.tr=1,this.K&&(this.tr+=this.K.tr),this.N&&(this.tr+=this.N.tr)},t}(o),a=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),c=function(){function e(e){void 0===e&&(e=0),this.iteratorType=e}return e.prototype.equals=function(e){return this.o===e.o},e}(),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t}(function(){function e(){this.M=0}return Object.defineProperty(e.prototype,"length",{get:function(){return this.M},enumerable:!1,configurable:!0}),e.prototype.size=function(){return this.M},e.prototype.empty=function(){return 0===this.M},e}());function l(){throw new RangeError("Iterator access denied!")}var h=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),d=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},f=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},p=function(e){function t(t,r){void 0===t&&(t=function(e,t){return e<t?-1:e>t?1:0}),void 0===r&&(r=!1);var i=e.call(this)||this;return i.W=void 0,i.$=t,r?(i.re=s,i.v=function(e,t,r){var i=this.se(e,t,r);if(i){for(var n=i.rr;n!==this.h;)n.tr+=1,n=n.rr;var o=this.fe(i);if(o){var s=o,a=s.parentNode,c=s.grandParent,u=s.curNode;a.ie(),c.ie(),u.ie()}}return this.M},i.G=function(e){for(var t=this.he(e);t!==this.h;)t.tr-=1,t=t.rr}):(i.re=o,i.v=function(e,t,r){var i=this.se(e,t,r);return i&&this.fe(i),this.M},i.G=i.he),i.h=new i.re,i}return h(t,e),t.prototype.U=function(e,t){for(var r=this.h;e;){var i=this.$(e.u,t);if(i<0)e=e.N;else{if(!(i>0))return e;r=e,e=e.K}}return r},t.prototype.X=function(e,t){for(var r=this.h;e;){this.$(e.u,t)<=0?e=e.N:(r=e,e=e.K)}return r},t.prototype.Y=function(e,t){for(var r=this.h;e;){var i=this.$(e.u,t);if(i<0)r=e,e=e.N;else{if(!(i>0))return e;e=e.K}}return r},t.prototype.Z=function(e,t){for(var r=this.h;e;){this.$(e.u,t)<0?(r=e,e=e.N):e=e.K}return r},t.prototype.ue=function(e){for(;;){var t,r=e.rr;if(r===this.h)return;if(1===e.ee)return void(e.ee=0);if(e===r.K)if(1===(t=r.N).ee)t.ee=0,r.ee=1,r===this.W?this.W=r.ne():r.ne();else{if(t.N&&1===t.N.ee)return t.ee=r.ee,r.ee=0,t.N.ee=0,void(r===this.W?this.W=r.ne():r.ne());t.K&&1===t.K.ee?(t.ee=1,t.K.ee=0,t.te()):(t.ee=1,e=r)}else if(1===(t=r.K).ee)t.ee=0,r.ee=1,r===this.W?this.W=r.te():r.te();else{if(t.K&&1===t.K.ee)return t.ee=r.ee,r.ee=0,t.K.ee=0,void(r===this.W?this.W=r.te():r.te());t.N&&1===t.N.ee?(t.ee=1,t.N.ee=0,t.ne()):(t.ee=1,e=r)}}},t.prototype.he=function(e){var t,r;if(1===this.M)return this.clear(),this.h;for(var i=e;i.K||i.N;){if(i.N)for(i=i.N;i.K;)i=i.K;else i=i.K;t=d([i.u,e.u],2),e.u=t[0],i.u=t[1],r=d([i.p,e.p],2),e.p=r[0],i.p=r[1],e=i}this.h.K===i?this.h.K=i.rr:this.h.N===i&&(this.h.N=i.rr),this.ue(i);var n=i.rr;return i===n.K?n.K=void 0:n.N=void 0,this.M-=1,this.W.ee=0,n},t.prototype.ae=function(e,t){return void 0!==e&&(!!this.ae(e.K,t)||(!!t(e)||this.ae(e.N,t)))},t.prototype.fe=function(e){for(;;){var t=e.rr;if(0===t.ee)return;var r=t.rr;if(t===r.K){if((i=r.N)&&1===i.ee){if(i.ee=t.ee=0,r===this.W)return;r.ee=1,e=r;continue}if(e===t.N){if(e.ee=0,e.K&&(e.K.rr=t),e.N&&(e.N.rr=r),t.N=e.K,r.K=e.N,e.K=t,e.N=r,r===this.W)this.W=e,this.h.rr=e;else(n=r.rr).K===r?n.K=e:n.N=e;return e.rr=r.rr,t.rr=e,r.rr=e,r.ee=1,{parentNode:t,grandParent:r,curNode:e}}t.ee=0,r===this.W?this.W=r.te():r.te(),r.ee=1}else{var i;if((i=r.K)&&1===i.ee){if(i.ee=t.ee=0,r===this.W)return;r.ee=1,e=r;continue}if(e===t.K){var n;if(e.ee=0,e.K&&(e.K.rr=r),e.N&&(e.N.rr=t),r.N=e.K,t.K=e.N,e.K=r,e.N=t,r===this.W)this.W=e,this.h.rr=e;else(n=r.rr).K===r?n.K=e:n.N=e;return e.rr=r.rr,t.rr=e,r.rr=e,r.ee=1,{parentNode:t,grandParent:r,curNode:e}}t.ee=0,r===this.W?this.W=r.ne():r.ne(),r.ee=1}return}},t.prototype.se=function(e,t,r){if(void 0===this.W)return this.M+=1,this.W=new this.re(e,t),this.W.ee=0,this.W.rr=this.h,this.h.rr=this.W,this.h.K=this.W,void(this.h.N=this.W);var i,n=this.h.K,o=this.$(n.u,e);if(0!==o){if(o>0)n.K=new this.re(e,t),n.K.rr=n,i=n.K,this.h.K=i;else{var s=this.h.N,a=this.$(s.u,e);if(0===a)return void(s.p=t);if(a<0)s.N=new this.re(e,t),s.N.rr=s,i=s.N,this.h.N=i;else{if(void 0!==r){var c=r.o;if(c!==this.h){var u=this.$(c.u,e);if(0===u)return void(c.p=t);if(u>0){var l=c.L(),h=this.$(l.u,e);if(0===h)return void(l.p=t);h<0&&(i=new this.re(e,t),void 0===l.N?(l.N=i,i.rr=l):(c.K=i,i.rr=c))}}}if(void 0===i)for(i=this.W;;){var d=this.$(i.u,e);if(d>0){if(void 0===i.K){i.K=new this.re(e,t),i.K.rr=i,i=i.K;break}i=i.K}else{if(!(d<0))return void(i.p=t);if(void 0===i.N){i.N=new this.re(e,t),i.N.rr=i,i=i.N;break}i=i.N}}}}return this.M+=1,i}n.p=t},t.prototype.g=function(e,t){for(;e;){var r=this.$(e.u,t);if(r<0)e=e.N;else{if(!(r>0))return e;e=e.K}}return e||this.h},t.prototype.clear=function(){this.M=0,this.W=void 0,this.h.rr=void 0,this.h.K=this.h.N=void 0},t.prototype.updateKeyByIterator=function(e,t){var r=e.o;if(r===this.h&&l(),1===this.M)return r.u=t,!0;if(r===this.h.K)return this.$(r.m().u,t)>0&&(r.u=t,!0);if(r===this.h.N)return this.$(r.L().u,t)<0&&(r.u=t,!0);var i=r.L().u;if(this.$(i,t)>=0)return!1;var n=r.m().u;return!(this.$(n,t)<=0)&&(r.u=t,!0)},t.prototype.eraseElementByPos=function(e){if(e<0||e>this.M-1)throw new RangeError;var t=0,r=this;return this.ae(this.W,(function(i){return e===t?(r.G(i),!0):(t+=1,!1)})),this.M},t.prototype.eraseElementByKey=function(e){if(0===this.M)return!1;var t=this.g(this.W,e);return t!==this.h&&(this.G(t),!0)},t.prototype.eraseElementByIterator=function(e){var t=e.o;t===this.h&&l();var r=void 0===t.N;return 0===e.iteratorType?r&&e.next():r&&void 0!==t.K||e.next(),this.G(t),e},t.prototype.forEach=function(e){var t,r,i=0;try{for(var n=f(this),o=n.next();!o.done;o=n.next()){e(o.value,i++,this)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},t.prototype.getElementByPos=function(e){var t,r,i;if(e<0||e>this.M-1)throw new RangeError;var n=0;try{for(var o=f(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(n===e){i=a;break}n+=1}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return i},t.prototype.getHeight=function(){if(0===this.M)return 0;var e=function(t){return t?Math.max(e(t.K),e(t.N))+1:0};return e(this.W)},t}(u);const g=p;var m=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),v=function(e){function t(t,r,i){var n=e.call(this,i)||this;return n.o=t,n.h=r,0===n.iteratorType?(n.pre=function(){return this.o===this.h.K&&l(),this.o=this.o.L(),this},n.next=function(){return this.o===this.h&&l(),this.o=this.o.m(),this}):(n.pre=function(){return this.o===this.h.N&&l(),this.o=this.o.m(),this},n.next=function(){return this.o===this.h&&l(),this.o=this.o.L(),this}),n}return m(t,e),Object.defineProperty(t.prototype,"index",{get:function(){var e=this.o,t=this.h.rr;if(e===this.h)return t?t.tr-1:0;var r=0;for(e.K&&(r+=e.K.tr);e!==t;){var i=e.rr;e===i.N&&(r+=1,i.K&&(r+=i.K.tr)),e=i}return r},enumerable:!1,configurable:!0}),t}(c);const y=v;var b=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),w=function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return c([e,t])}}function c(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},S=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},_=function(e){function t(t,r,i,n){var o=e.call(this,t,r,n)||this;return o.container=i,o}return b(t,e),Object.defineProperty(t.prototype,"pointer",{get:function(){return this.o===this.h&&l(),this.o.u},enumerable:!1,configurable:!0}),t.prototype.copy=function(){return new t(this.o,this.h,this.container,this.iteratorType)},t}(y),k=function(e){function t(t,r,i){void 0===t&&(t=[]);var n=e.call(this,r,i)||this,o=n;return t.forEach((function(e){o.insert(e)})),n}return b(t,e),t.prototype.P=function(e){return w(this,(function(t){switch(t.label){case 0:return void 0===e?[2]:[5,S(this.P(e.K))];case 1:return t.sent(),[4,e.u];case 2:return t.sent(),[5,S(this.P(e.N))];case 3:return t.sent(),[2]}}))},t.prototype.begin=function(){return new _(this.h.K||this.h,this.h,this)},t.prototype.end=function(){return new _(this.h,this.h,this)},t.prototype.rBegin=function(){return new _(this.h.N||this.h,this.h,this,1)},t.prototype.rEnd=function(){return new _(this.h,this.h,this,1)},t.prototype.front=function(){return this.h.K?this.h.K.u:void 0},t.prototype.back=function(){return this.h.N?this.h.N.u:void 0},t.prototype.insert=function(e,t){return this.v(e,void 0,t)},t.prototype.find=function(e){var t=this.g(this.W,e);return new _(t,this.h,this)},t.prototype.lowerBound=function(e){var t=this.U(this.W,e);return new _(t,this.h,this)},t.prototype.upperBound=function(e){var t=this.X(this.W,e);return new _(t,this.h,this)},t.prototype.reverseLowerBound=function(e){var t=this.Y(this.W,e);return new _(t,this.h,this)},t.prototype.reverseUpperBound=function(e){var t=this.Z(this.W,e);return new _(t,this.h,this)},t.prototype.union=function(e){var t=this;return e.forEach((function(e){t.insert(e)})),this.M},t.prototype[Symbol.iterator]=function(){return this.P(this.W)},t}(g);const E=k},7321:(e,t,r)=>{const i=r(8283),n=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),u=Symbol("dispose"),l=Symbol("noDisposeOnSet"),h=Symbol("lruList"),d=Symbol("cache"),f=Symbol("updateAgeOnGet"),p=()=>1;const g=(e,t,r)=>{const i=e[d].get(t);if(i){const t=i.value;if(m(e,t)){if(y(e,i),!e[a])return}else r&&(e[f]&&(i.value.now=Date.now()),e[h].unshiftNode(i));return t.value}},m=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[c]&&r>e[c]},v=e=>{if(e[o]>e[n])for(let t=e[h].tail;e[o]>e[n]&&null!==t;){const r=t.prev;y(e,t),t=r}},y=(e,t)=>{if(t){const r=t.value;e[u]&&e[u](r.key,r.value),e[o]-=r.length,e[d].delete(r.key),e[h].removeNode(t)}};class b{constructor(e,t,r,i,n){this.key=e,this.value=t,this.length=r,this.now=i,this.maxAge=n||0}}const w=(e,t,r,i)=>{let n=r.value;m(e,n)&&(y(e,r),e[a]||(n=void 0)),n&&t.call(i,n.value,n.key,e)};e.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[n]=e.max||1/0;const t=e.length||p;if(this[s]="function"!=typeof t?p:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[u]=e.dispose,this[l]=e.noDisposeOnSet||!1,this[f]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[n]=e||1/0,v(this)}get max(){return this[n]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[s]&&(this[s]=e,this[o]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[o]+=e.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){const i=r.prev;w(this,e,r,t),r=i}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){const i=r.next;w(this,e,r,t),r=i}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((e=>this[u](e.key,e.value))),this[d]=new Map,this[h]=new i,this[o]=0}dump(){return this[h].map((e=>!m(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[c])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[s](t,e);if(this[d].has(e)){if(a>this[n])return y(this,this[d].get(e)),!1;const s=this[d].get(e).value;return this[u]&&(this[l]||this[u](e,s.value)),s.now=i,s.maxAge=r,s.value=t,this[o]+=a-s.length,s.length=a,this.get(e),v(this),!0}const f=new b(e,t,a,i,r);return f.length>this[n]?(this[u]&&this[u](e,t),!1):(this[o]+=f.length,this[h].unshift(f),this[d].set(e,this[h].head),v(this),!0)}has(e){if(!this[d].has(e))return!1;const t=this[d].get(e).value;return!m(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(y(this,e),e.value):null}del(e){y(this,this[d].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const i=e[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const e=n-t;e>0&&this.set(i.k,i.v,e)}}}prune(){this[d].forEach(((e,t)=>g(this,t,!1)))}}},3366:e=>{e.exports=Math.abs},8692:e=>{e.exports=Math.floor},7943:e=>{e.exports=Number.isNaN||function(e){return e!=e}},7744:e=>{e.exports=Math.max},686:e=>{e.exports=Math.min},7860:e=>{e.exports=Math.pow},4442:e=>{e.exports=Math.round},5433:(e,t,r)=>{var i=r(7943);e.exports=function(e){return i(e)||0===e?e:e<0?-1:1}},5323:(e,t,r)=>{var i=r(6459).Buffer;const n=e.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=i.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=i.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=i.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function o(e){return[0,1,2].map((t=>[0,1].map((r=>[0,1].map((o=>{const s=i.alloc(1);return s.writeUInt8(n.codes[e]<<n.CMD_SHIFT|(r?n.DUP_MASK:0)|t<<n.QOS_SHIFT|o,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=o("publish"),n.SUBSCRIBE_HEADER=o("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=o("unsubscribe"),n.ACKS={unsuback:o("unsuback"),puback:o("puback"),pubcomp:o("pubcomp"),pubrel:o("pubrel"),pubrec:o("pubrec")},n.SUBACK_HEADER=i.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=i.from([3]),n.VERSION4=i.from([4]),n.VERSION5=i.from([5]),n.VERSION131=i.from([131]),n.VERSION132=i.from([132]),n.QOS=[0,1,2].map((e=>i.from([e]))),n.EMPTY={pingreq:i.from([n.codes.pingreq<<4,0]),pingresp:i.from([n.codes.pingresp<<4,0]),disconnect:i.from([n.codes.disconnect<<4,0])}},5115:(e,t,r)=>{var i=r(6459).Buffer;const n=r(9752),o=r(8987);class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let n,o=0;for(n=0;n<r.length&&void 0!==r[n];n++)"string"!=typeof r[n]?t[n]=r[n].length:t[n]=i.byteLength(r[n]),e+=t[n];const s=i.allocUnsafe(e);for(n=0;n<r.length&&void 0!==r[n];n++)"string"!=typeof r[n]?(r[n].copy(s,o),o+=t[n]):(s.write(r[n],o),o+=t[n]);return s}}e.exports=function(e,t){const r=new s;return n(e,r,t),r.concat()}},8362:(e,t,r)=>{t.parser=r(2243).parser,t.generate=r(5115),t.writeToStream=r(9752)},8056:(e,t,r)=>{var i=r(6459).Buffer;const n={},o=i.isBuffer(i.from([1,2]).subarray(0,1));function s(e){const t=i.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=s(e)},generateNumber:s,genBufVariableByteInt:function(e){let t=0,r=0;const n=i.allocUnsafe(4);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),n.writeUInt8(t,r++)}while(e>0&&r<4);return e>0&&(r=0),o?n.subarray(0,r):n.slice(0,r)},generate4ByteBuffer:function(e){const t=i.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},4116:e=>{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}}},2243:(e,t,r)=>{const i=r(3209),n=r(8987),o=r(4116),s=r(5323),a=r(5685)("mqtt-packet:parser");class c extends n{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=i(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("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++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("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=s.types[e>>s.CMD_SHIFT],this.packet.retain=!!(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=!!(e&s.DUP_MASK),a("_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)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_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 a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,i;a("_parseConnect");const n={},o=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),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(n.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,n.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,n.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,n.will&&(o.will={},o.will.retain=!!(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=!!(this._list.readUInt8(this._pos)&s.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 u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(o.clientId=u,a("_parseConnect: packet.clientId: %s",o.clientId),n.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,a("_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,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(n.username){if(i=this._parseString(),null===i)return this._emitError(new Error("Cannot parse username"));o.username=i,a("_parseConnect: packet.username: %s",o.username)}if(n.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-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)}a("_parseConnack: complete")}_parsePublish(){a("_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),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,i,n,o,c,u;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"));r=this._parseByte(),i=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=!!(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=!!(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),n=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,u={topic:t,qos:i},5===this.settings.protocolVersion?(u.nl=c,u.rap=o,u.rh=n):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){a("_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(){a("_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"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_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(){a("_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(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_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),a("_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):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const i=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",i),i}_parseStringPair(){return a("_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 r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_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,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,i=1,n=0,o=!1;const c=this._pos?this._pos:0;for(;r<4&&c+r<this._list.length;){if(t=this._list.readUInt8(c+r++),n+=i*(t&s.VARBYTEINT_MASK),i*=128,!(t&s.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=r)break}return!o&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),c&&(this._pos+=r),o=!!o&&(e?{bytes:r,value:n}:n),a("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_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(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const i=r[t][e.name];r[t][e.name]=[i],r[t][e.name].push(e.value)}else r[t][e.name]=e.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_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)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}e.exports=c},9752:(e,t,r)=>{var i=r(6459).Buffer;const n=r(5323),o=i.allocUnsafe(0),s=i.from([0]),a=r(8056),c=r(6389).nextTick,u=r(5685)("mqtt-packet:writeToStream"),l=a.cache,h=a.generateNumber,d=a.generateCache,f=a.genBufVariableByteInt,p=a.generate4ByteBuffer;let g=k,m=!0;function v(e,t,r){switch(u("generate called"),t.cork&&(t.cork(),c(y,t)),m&&(m=!1,d()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,r){const o=e||{},s=o.protocolId||"MQTT";let a=o.protocolVersion||4;const c=o.will;let u=o.clean;const l=o.keepalive||0,h=o.clientId||"",d=o.username,f=o.password,p=o.properties;void 0===u&&(u=!0);let m=0;if(!s||"string"!=typeof s&&!i.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;m+=s.length+2;if(3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;m+=1;if(("string"==typeof h||i.isBuffer(h))&&(h||a>=4)&&(h||u))m+=i.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;m+=2;if(m+=1,5===a){var v=C(t,p);if(!v)return!1;m+=v.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(m+=i.byteLength(c.topic)+2,m+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?m+=i.byteLength(c.payload):m+=c.payload.length}var y={};if(5===a){if(!(y=C(t,c.properties)))return!1;m+=y.length}}let b=!1;if(null!=d){if(!x(d))return t.emit("error",new Error("Invalid username")),!1;b=!0,m+=i.byteLength(d)+2}if(null!=f){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!x(f))return t.emit("error",new Error("Invalid password")),!1;m+=R(f)+2}t.write(n.CONNECT_HEADER),w(t,m),T(t,s),o.bridgeMode&&(a+=128);t.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let _=0;_|=null!=d?n.USERNAME_MASK:0,_|=null!=f?n.PASSWORD_MASK:0,_|=c&&c.retain?n.WILL_RETAIN_MASK:0,_|=c&&c.qos?c.qos<<n.WILL_QOS_SHIFT:0,_|=c?n.WILL_FLAG_MASK:0,_|=u?n.CLEAN_SESSION_MASK:0,t.write(i.from([_])),g(t,l),5===a&&v.write();T(t,h),c&&(5===a&&y.write(),S(t,c.topic),T(t,c.payload));null!=d&&T(t,d);null!=f&&T(t,f);return!0}(e,t);case"connack":return function(e,t,r){const o=r?r.protocolVersion:4,a=e||{},c=5===o?a.reasonCode:a.returnCode,u=a.properties;let l=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===o){if(h=C(t,u),!h)return!1;l+=h.length}t.write(n.CONNACK_HEADER),w(t,l),t.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:s),t.write(i.from([c])),null!=h&&h.write();return!0}(e,t,r);case"publish":return function(e,t,r){u("publish: packet: %o",e);const s=r?r.protocolVersion:4,a=e||{},c=a.qos||0,l=a.retain?n.RETAIN_MASK:0,h=a.topic,d=a.payload||o,f=a.messageId,p=a.properties;let m=0;if("string"==typeof h)m+=i.byteLength(h)+2;else{if(!i.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;m+=h.length+2}i.isBuffer(d)?m+=d.length:m+=i.byteLength(d);if(c&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;c&&(m+=2);let v=null;if(5===s){if(v=C(t,p),!v)return!1;m+=v.length}t.write(n.PUBLISH_HEADER[c][a.dup?1:0][l?1:0]),w(t,m),g(t,R(h)),t.write(h),c>0&&g(t,f);null!=v&&v.write();return u("publish: payload: %o",d),t.write(d)}(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,u=s.dup&&"pubrel"===a?n.DUP_MASK:0;let l=0;const h=s.reasonCode,d=s.properties;let f=5===o?3:2;"pubrel"===a&&(l=1);if("number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let p=null;if(5===o&&"object"==typeof d){if(p=P(t,d,r,f),!p)return!1;f+=p.length}t.write(n.ACKS[a][l][u][0]),w(t,f),g(t,c),5===o&&t.write(i.from([h]));null!==p&&p.write();return!0}(e,t,r);case"subscribe":return function(e,t,r){u("subscribe: packet: ");const o=r?r.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,l=s.subscriptions,h=s.properties;let d=0;if("number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;d+=2;let f=null;if(5===o){if(f=C(t,h),!f)return!1;d+=f.length}if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const r=l[e].topic,n=l[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===o){if("boolean"!=typeof(l[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const r=l[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}d+=i.byteLength(r)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),w(t,d),g(t,c),null!==f&&f.write();let p=!0;for(const e of l){const r=e.topic,s=e.qos,a=+e.nl,c=+e.rap,u=e.rh;let l;S(t,r),l=n.SUBSCRIBE_OPTIONS_QOS[s],5===o&&(l|=a?n.SUBSCRIBE_OPTIONS_NL:0,l|=c?n.SUBSCRIBE_OPTIONS_RAP:0,l|=u?n.SUBSCRIBE_OPTIONS_RH[u]:0),p=t.write(i.from([l]))}return p}(e,t,r);case"suback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,u=s.properties;let l=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;l+=1}let h=null;if(5===o){if(h=P(t,u,r,l),!h)return!1;l+=h.length}t.write(n.SUBACK_HEADER),w(t,l),g(t,a),null!==h&&h.write();return t.write(i.from(c))}(e,t,r);case"unsubscribe":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,u=s.unsubscriptions,l=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;h+=2;if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=i.byteLength(u[e])+2}let d=null;if(5===o){if(d=C(t,l),!d)return!1;h+=d.length}t.write(n.UNSUBSCRIBE_HEADER[1][c?1:0][0]),w(t,h),g(t,a),null!==d&&d.write();let f=!0;for(let e=0;e<u.length;e++)f=S(t,u[e]);return f}(e,t,r);case"unsuback":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,u=s.granted,l=s.properties,h=s.cmd,d=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===o){if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let p=null;if(5===o){if(p=P(t,l,r,f),!p)return!1;f+=p.length}t.write(n.ACKS[h][d][c][0]),w(t,f),g(t,a),null!==p&&p.write();5===o&&t.write(i.from(u));return!0}(e,t,r);case"pingreq":case"pingresp":return function(e,t,r){return t.write(n.EMPTY[e.cmd])}(e,t);case"disconnect":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===o?1:0,l=null;if(5===o){if(l=P(t,c,r,u),!l)return!1;u+=l.length}t.write(i.from([n.codes.disconnect<<4])),w(t,u),5===o&&t.write(i.from([a]));null!==l&&l.write();return!0}(e,t,r);case"auth":return function(e,t,r){const o=r?r.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===o?1:0;5!==o&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const l=P(t,c,r,u);if(!l)return!1;u+=l.length,t.write(i.from([n.codes.auth<<4])),w(t,u),t.write(i.from([a])),null!==l&&l.write();return!0}(e,t,r);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}Object.defineProperty(v,"cacheNumbers",{get:()=>g===k,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),g=k):(m=!1,g=E)}});const b={};function w(e,t){if(t>n.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=b[t];return r||(r=f(t),t<16384&&(b[t]=r)),u("writeVarByteInt: writing to stream: %o",r),e.write(r)}function S(e,t){const r=i.byteLength(t);return g(e,r),u("writeString: %s",t),e.write(t,"utf8")}function _(e,t,r){S(e,t),S(e,r)}function k(e,t){return u("writeNumberCached: number: %d",t),u("writeNumberCached: %o",l[t]),e.write(l[t])}function E(e,t){const r=h(t);return u("writeNumberGenerated: %o",r),e.write(r)}function T(e,t){"string"==typeof t?S(e,t):t?(g(e,t.length),e.write(t)):g(e,0)}function C(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){I(e,{},0)}};let r=0;function o(t,r){let o=0;switch(n.propertiesTypes[t]){case"byte":if("boolean"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=2;break;case"int8":if("number"!=typeof r||r<0||r>255)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=2;break;case"binary":if(r&&null===r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=1+i.byteLength(r)+2;break;case"int16":if("number"!=typeof r||r<0||r>65535)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=3;break;case"int32":if("number"!=typeof r||r<0||r>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=5;break;case"var":if("number"!=typeof r||r<0||r>268435455)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=1+i.byteLength(f(r));break;case"string":if("string"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=3+i.byteLength(r.toString());break;case"pair":if("object"!=typeof r)return e.emit("error",new Error(`Invalid ${t}: ${r}`)),!1;o+=Object.getOwnPropertyNames(r).reduce(((e,t)=>{const n=r[t];return Array.isArray(n)?e+=n.reduce(((e,r)=>e+=3+i.byteLength(t.toString())+2+i.byteLength(r.toString())),0):e+=3+i.byteLength(t.toString())+2+i.byteLength(r[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${r}`)),!1}return o}if(t)for(const e in t){let i=0,n=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(n=o(e,s[t]),!n)return!1;i+=n}else{if(n=o(e,s),!n)return!1;i=n}if(!i)return!1;r+=i}return{length:i.byteLength(f(r))+r,write(){I(e,t,r)}}}function P(e,t,r,i){const n=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=C(e,t);if(o)for(;i+s.length>o;){const r=n.shift();if(!r||!t[r])return!1;delete t[r],s=C(e,t)}return s}function A(e,t,r){switch(n.propertiesTypes[t]){case"byte":e.write(i.from([n.properties[t]])),e.write(i.from([+r]));break;case"int8":e.write(i.from([n.properties[t]])),e.write(i.from([r]));break;case"binary":e.write(i.from([n.properties[t]])),T(e,r);break;case"int16":e.write(i.from([n.properties[t]])),g(e,r);break;case"int32":e.write(i.from([n.properties[t]])),function(e,t){const r=p(t);u("write4ByteNumber: %o",r),e.write(r)}(e,r);break;case"var":e.write(i.from([n.properties[t]])),w(e,r);break;case"string":e.write(i.from([n.properties[t]])),S(e,r);break;case"pair":Object.getOwnPropertyNames(r).forEach((o=>{const s=r[o];Array.isArray(s)?s.forEach((r=>{e.write(i.from([n.properties[t]])),_(e,o.toString(),r.toString())})):(e.write(i.from([n.properties[t]])),_(e,o.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${r}`)),!1}}function I(e,t,r){w(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const i=t[r];if(Array.isArray(i))for(let t=0;t<i.length;t++)A(e,r,i[t]);else A(e,r,i)}}function R(e){return e?e instanceof i?e.length:i.byteLength(e):0}function x(e){return"string"==typeof e||e instanceof i}e.exports=v},1149:e=>{var t=1e3,r=60*t,i=60*r,n=24*i,o=7*n,s=365.25*n;function a(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\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(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=n)return a(e,o,n,"day");if(o>=i)return a(e,o,i,"hour");if(o>=r)return a(e,o,r,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=n)return Math.round(e/n)+"d";if(o>=i)return Math.round(e/i)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4508:(e,t,r)=>{const i=r(3543);e.exports.t=i},3543:(e,t,r)=>{const i=r(222).CD,n=r(5685)("number-allocator:trace"),o=r(5685)("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new i([],((e,t)=>e.compare(t))),n("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return n("alloc():empty"),null;const e=this.ss.begin(),t=e.pointer.low,r=e.pointer.high,i=t;return i+1<=r?this.ss.updateKeyByIterator(e,new s(t+1,r)):this.ss.eraseElementByPos(0),n("alloc():"+i),i},a.prototype.use=function(e){const t=new s(e,e),r=this.ss.lowerBound(t);if(!r.equals(this.ss.end())){const i=r.pointer.low,o=r.pointer.high;return r.pointer.equals(t)?(this.ss.eraseElementByIterator(r),n("use():"+e),!0):!(i>e)&&(i===e?(this.ss.updateKeyByIterator(r,new s(i+1,o)),n("use():"+e),!0):o===e?(this.ss.updateKeyByIterator(r,new s(i,o-1)),n("use():"+e),!0):(this.ss.updateKeyByIterator(r,new s(e+1,o)),this.ss.insert(new s(i,e-1)),n("use():"+e),!0))}return n("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void o("free():"+e+" is out of range");const t=new s(e,e),r=this.ss.upperBound(t);if(r.equals(this.ss.end())){if(r.equals(this.ss.begin()))return void this.ss.insert(t);r.pre();const i=r.pointer.high;r.pointer.high+1===e?this.ss.updateKeyByIterator(r,new s(i,e)):this.ss.insert(t)}else if(r.equals(this.ss.begin()))if(e+1===r.pointer.low){const t=r.pointer.high;this.ss.updateKeyByIterator(r,new s(e,t))}else this.ss.insert(t);else{const i=r.pointer.low,n=r.pointer.high;r.pre();const o=r.pointer.low;r.pointer.high+1===e?e+1===i?(this.ss.eraseElementByIterator(r),this.ss.updateKeyByIterator(r,new s(o,n))):this.ss.updateKeyByIterator(r,new s(o,e)):e+1===i?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new s(e,n))):this.ss.insert(t)}n("free():"+e)},a.prototype.clear=function(){n("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},e.exports=a},5295:(e,t,r)=>{var i="function"==typeof Map&&Map.prototype,n=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=i&&n&&"function"==typeof n.get?n.get:null,s=i&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,c=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,u=a&&c&&"function"==typeof c.get?c.get:null,l=a&&Set.prototype.forEach,h="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,d="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,f="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,v=String.prototype.match,y=String.prototype.slice,b=String.prototype.replace,w=String.prototype.toUpperCase,S=String.prototype.toLowerCase,_=RegExp.prototype.test,k=Array.prototype.concat,E=Array.prototype.join,T=Array.prototype.slice,C=Math.floor,P="function"==typeof BigInt?BigInt.prototype.valueOf:null,A=Object.getOwnPropertySymbols,I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,R="function"==typeof Symbol&&"object"==typeof Symbol.iterator,x="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===R||"symbol")?Symbol.toStringTag:null,O=Object.prototype.propertyIsEnumerable,M=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function N(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||_.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var i=e<0?-C(-e):C(e);if(i!==e){var n=String(i),o=y.call(t,n.length+1);return b.call(n,r,"$&_")+"."+b.call(b.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(t,r,"$&_")}var L=r(4444),B=L.custom,D=K(B)?B:null,j={__proto__:null,double:'"',single:"'"},U={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function F(e,t,r){var i=r.quoteStyle||t,n=j[i];return n+e+n}function V(e){return b.call(String(e),/"/g,"&quot;")}function W(e){return!x||!("object"==typeof e&&(x in e||void 0!==e[x]))}function q(e){return"[object Array]"===G(e)&&W(e)}function H(e){return"[object RegExp]"===G(e)&&W(e)}function K(e){if(R)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!I)return!1;try{return I.call(e),!0}catch(e){}return!1}e.exports=function e(t,i,n,a){var c=i||{};if($(c,"quoteStyle")&&!$(j,c.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if($(c,"maxStringLength")&&("number"==typeof c.maxStringLength?c.maxStringLength<0&&c.maxStringLength!==1/0:null!==c.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var g=!$(c,"customInspect")||c.customInspect;if("boolean"!=typeof g&&"symbol"!==g)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if($(c,"indent")&&null!==c.indent&&"\t"!==c.indent&&!(parseInt(c.indent,10)===c.indent&&c.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if($(c,"numericSeparator")&&"boolean"!=typeof c.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var w=c.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return J(t,c);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var _=String(t);return w?N(t,_):_}if("bigint"==typeof t){var C=String(t)+"n";return w?N(t,C):C}var A=void 0===c.depth?5:c.depth;if(void 0===n&&(n=0),n>=A&&A>0&&"object"==typeof t)return q(t)?"[Array]":"[Object]";var B=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=E.call(Array(e.indent+1)," ")}return{base:r,prev:E.call(Array(t+1),r)}}(c,n);if(void 0===a)a=[];else if(Q(a,t)>=0)return"[Circular]";function U(t,r,i){if(r&&(a=T.call(a)).push(r),i){var o={depth:c.depth};return $(c,"quoteStyle")&&(o.quoteStyle=c.quoteStyle),e(t,o,n+1,a)}return e(t,c,n+1,a)}if("function"==typeof t&&!H(t)){var z=function(e){if(e.name)return e.name;var t=v.call(m.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),Y=re(t,U);return"[Function"+(z?": "+z:" (anonymous)")+"]"+(Y.length>0?" { "+E.call(Y,", ")+" }":"")}if(K(t)){var ie=R?b.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):I.call(t);return"object"!=typeof t||R?ie:X(ie)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var ne="<"+S.call(String(t.nodeName)),oe=t.attributes||[],se=0;se<oe.length;se++)ne+=" "+oe[se].name+"="+F(V(oe[se].value),"double",c);return ne+=">",t.childNodes&&t.childNodes.length&&(ne+="..."),ne+="</"+S.call(String(t.nodeName))+">"}if(q(t)){if(0===t.length)return"[]";var ae=re(t,U);return B&&!function(e){for(var t=0;t<e.length;t++)if(Q(e[t],"\n")>=0)return!1;return!0}(ae)?"["+te(ae,B)+"]":"[ "+E.call(ae,", ")+" ]"}if(function(e){return"[object Error]"===G(e)&&W(e)}(t)){var ce=re(t,U);return"cause"in Error.prototype||!("cause"in t)||O.call(t,"cause")?0===ce.length?"["+String(t)+"]":"{ ["+String(t)+"] "+E.call(ce,", ")+" }":"{ ["+String(t)+"] "+E.call(k.call("[cause]: "+U(t.cause),ce),", ")+" }"}if("object"==typeof t&&g){if(D&&"function"==typeof t[D]&&L)return L(t,{depth:A-n});if("symbol"!==g&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!o||!e||"object"!=typeof e)return!1;try{o.call(e);try{u.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var ue=[];return s&&s.call(t,(function(e,r){ue.push(U(r,t,!0)+" => "+U(e,t))})),ee("Map",o.call(t),ue,B)}if(function(e){if(!u||!e||"object"!=typeof e)return!1;try{u.call(e);try{o.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var le=[];return l&&l.call(t,(function(e){le.push(U(e,t))})),ee("Set",u.call(t),le,B)}if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{h.call(e,h);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Z("WeakMap");if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{h.call(e,h)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Z("WeakSet");if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{return f.call(e),!0}catch(e){}return!1}(t))return Z("WeakRef");if(function(e){return"[object Number]"===G(e)&&W(e)}(t))return X(U(Number(t)));if(function(e){if(!e||"object"!=typeof e||!P)return!1;try{return P.call(e),!0}catch(e){}return!1}(t))return X(U(P.call(t)));if(function(e){return"[object Boolean]"===G(e)&&W(e)}(t))return X(p.call(t));if(function(e){return"[object String]"===G(e)&&W(e)}(t))return X(U(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||void 0!==r.g&&t===r.g)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===G(e)&&W(e)}(t)&&!H(t)){var he=re(t,U),de=M?M(t)===Object.prototype:t instanceof Object||t.constructor===Object,fe=t instanceof Object?"":"null prototype",pe=!de&&x&&Object(t)===t&&x in t?y.call(G(t),8,-1):fe?"Object":"",ge=(de||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(pe||fe?"["+E.call(k.call([],pe||[],fe||[]),": ")+"] ":"");return 0===he.length?ge+"{}":B?ge+"{"+te(he,B)+"}":ge+"{ "+E.call(he,", ")+" }"}return String(t)};var z=Object.prototype.hasOwnProperty||function(e){return e in this};function $(e,t){return z.call(e,t)}function G(e){return g.call(e)}function Q(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}function J(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,i="... "+r+" more character"+(r>1?"s":"");return J(y.call(e,0,t.maxStringLength),t)+i}var n=U[t.quoteStyle||"single"];return n.lastIndex=0,F(b.call(b.call(e,n,"\\$1"),/[\x00-\x1f]/g,Y),"single",t)}function Y(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+w.call(t.toString(16))}function X(e){return"Object("+e+")"}function Z(e){return e+" { ? }"}function ee(e,t,r,i){return e+" ("+t+") {"+(i?te(r,i):E.call(r,", "))+"}"}function te(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+E.call(e,","+r)+"\n"+t.prev}function re(e,t){var r=q(e),i=[];if(r){i.length=e.length;for(var n=0;n<e.length;n++)i[n]=$(e,n)?t(e[n],e):""}var o,s="function"==typeof A?A(e):[];if(R){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in e)$(e,c)&&(r&&String(Number(c))===c&&c<e.length||R&&o["$"+c]instanceof Symbol||(_.call(/[^\w$]/,c)?i.push(t(c,e)+": "+t(e[c],e)):i.push(c+": "+t(e[c],e))));if("function"==typeof A)for(var u=0;u<s.length;u++)O.call(e,s[u])&&i.push("["+t(s[u])+"]: "+t(e[s[u]],e));return i}},8491:(e,t,r)=>{var i=r(1559);function n(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)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=i(n),e.exports.strict=i(o),n.proto=n((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},6389:(e,t,r)=>{var i=r(1626);void 0===i||!i.version||0===i.version.indexOf("v0.")||0===i.version.indexOf("v1.")&&0!==i.version.indexOf("v1.8.")?e.exports={nextTick:function(e,t,r,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return i.nextTick(e);case 2:return i.nextTick((function(){e.call(null,t)}));case 3:return i.nextTick((function(){e.call(null,t,r)}));case 4:return i.nextTick((function(){e.call(null,t,r,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return i.nextTick((function(){e.apply(null,o)}))}}}:e.exports=i},1626:e=>{var t,r,i=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,c=[],u=!1,l=-1;function h(){u&&a&&(u=!1,a.length?c=a.concat(c):l=-1,c.length&&d())}function d(){if(!u){var e=s(h);u=!0;for(var t=c.length;t;){for(a=c,c=[];++l<t;)a&&a[l].run();l=-1,t=c.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new f(e,t)),1!==c.length||u||s(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},1715:function(e,t,r){var i;e=r.nmd(e),function(n){t&&t.nodeType,e&&e.nodeType;var o="object"==typeof r.g&&r.g;o.global!==o&&o.window!==o&&o.self;var s,a=2147483647,c=36,u=1,l=26,h=38,d=700,f=72,p=128,g="-",m=/^xn--/,v=/[^\x20-\x7E]/,y=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-u,S=Math.floor,_=String.fromCharCode;function k(e){throw new RangeError(b[e])}function E(e,t){for(var r=e.length,i=[];r--;)i[r]=t(e[r]);return i}function T(e,t){var r=e.split("@"),i="";return r.length>1&&(i=r[0]+"@",e=r[1]),i+E((e=e.replace(y,".")).split("."),t).join(".")}function C(e){for(var t,r,i=[],n=0,o=e.length;n<o;)(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<o?56320==(64512&(r=e.charCodeAt(n++)))?i.push(((1023&t)<<10)+(1023&r)+65536):(i.push(t),n--):i.push(t);return i}function P(e){return E(e,(function(e){var t="";return e>65535&&(t+=_((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=_(e)})).join("")}function A(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function I(e,t,r){var i=0;for(e=r?S(e/d):e>>1,e+=S(e/t);e>w*l>>1;i+=c)e=S(e/w);return S(i+(w+1)*e/(e+h))}function R(e){var t,r,i,n,o,s,h,d,m,v,y,b=[],w=e.length,_=0,E=p,T=f;for((r=e.lastIndexOf(g))<0&&(r=0),i=0;i<r;++i)e.charCodeAt(i)>=128&&k("not-basic"),b.push(e.charCodeAt(i));for(n=r>0?r+1:0;n<w;){for(o=_,s=1,h=c;n>=w&&k("invalid-input"),((d=(y=e.charCodeAt(n++))-48<10?y-22:y-65<26?y-65:y-97<26?y-97:c)>=c||d>S((a-_)/s))&&k("overflow"),_+=d*s,!(d<(m=h<=T?u:h>=T+l?l:h-T));h+=c)s>S(a/(v=c-m))&&k("overflow"),s*=v;T=I(_-o,t=b.length+1,0==o),S(_/t)>a-E&&k("overflow"),E+=S(_/t),_%=t,b.splice(_++,0,E)}return P(b)}function x(e){var t,r,i,n,o,s,h,d,m,v,y,b,w,E,T,P=[];for(b=(e=C(e)).length,t=p,r=0,o=f,s=0;s<b;++s)(y=e[s])<128&&P.push(_(y));for(i=n=P.length,n&&P.push(g);i<b;){for(h=a,s=0;s<b;++s)(y=e[s])>=t&&y<h&&(h=y);for(h-t>S((a-r)/(w=i+1))&&k("overflow"),r+=(h-t)*w,t=h,s=0;s<b;++s)if((y=e[s])<t&&++r>a&&k("overflow"),y==t){for(d=r,m=c;!(d<(v=m<=o?u:m>=o+l?l:m-o));m+=c)T=d-v,E=c-v,P.push(_(A(v+T%E,0))),d=S(T/E);P.push(_(A(d,0))),o=I(r,w,i==n),r=0,++i}++r,++t}return P.join("")}s={version:"1.4.1",ucs2:{decode:C,encode:P},decode:R,encode:x,toASCII:function(e){return T(e,(function(e){return v.test(e)?"xn--"+x(e):e}))},toUnicode:function(e){return T(e,(function(e){return m.test(e)?R(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,r,t,e))||(e.exports=i)}()},2449:e=>{var t=String.prototype.replace,r=/%20/g,i="RFC1738",n="RFC3986";e.exports={default:n,formatters:{RFC1738:function(e){return t.call(e,r,"+")},RFC3986:function(e){return String(e)}},RFC1738:i,RFC3986:n}},1065:(e,t,r)=>{var i=r(3904),n=r(4638),o=r(2449);e.exports={formats:o,parse:n,stringify:i}},4638:(e,t,r)=>{var i=r(5292),n=r(8084),o=Object.prototype.hasOwnProperty,s=Array.isArray,a=Object.getPrototypeOf,c=function(e){if(!e||"object"!=typeof e)return!1;if(s(e))return!0;var t=a(e);return t===Object.prototype||null===t},u=function(e){if(s(e)){var t=[];return t.length=e.length,t}return null===a(e)?{__proto__:null}:{}},l={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},h=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},d=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1){if(t.throwOnLimitExceeded)for(var i=0,n=e.indexOf(",");n>-1;){if((i+=1)>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");n=e.indexOf(",",n+1)}return e.split(",")}if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},f=function(e,t,r,i){if(e){var s=function(e,t){var r=t.allowDots?function(e){for(var t="",r=0,i=0;i<e.length;i+=1){var n=e.charCodeAt(i);if(91===n)r+=1,t+="[";else if(93===n)r>0&&(r-=1),t+="]";else if(46===n&&0===r&&i+1<e.length&&46!==e.charCodeAt(i+1)&&91!==e.charCodeAt(i+1)){for(var o=i+1,s=o;s<e.length&&46!==e.charCodeAt(s)&&91!==e.charCodeAt(s);)s+=1;t+="["+e.slice(o,s)+"]",i=s-1}else t+=e.charAt(i)}return t}(e):e;if(t.depth<=0){if(!t.plainObjects&&o.call(Object.prototype,r)&&!t.allowPrototypes)return;return[r]}var i=[],n=r.indexOf("["),s=n>=0?r.slice(0,n):r;if(s){if(!t.plainObjects&&o.call(Object.prototype,s)&&!t.allowPrototypes)return;i[i.length]=s}for(var a=r.length,c=n,u=0;c>=0&&u<t.depth;){for(var l=1,h=c+1,d=-1;h<a&&d<0;){var f=r.charCodeAt(h);91===f?l+=1:93===f&&0==(l-=1)&&(d=h),h+=1}if(d<0)return i[i.length]="["+r.slice(c)+"]",i;var p=r.slice(c,d+1),g=p.slice(1,-1);if(!t.plainObjects&&o.call(Object.prototype,g)&&!t.allowPrototypes)return;i[i.length]=p,u+=1,c=r.indexOf("[",d+1)}if(c>=0){if(!0===t.strictDepth)throw new RangeError("Input depth exceeded depth option of "+t.depth+" and strictDepth is true");i[i.length]="["+r.slice(c)+"]"}return i}(e,r);if(s)return function(e,t,r,i){var o=0;if(e.length>0&&"[]"===e[e.length-1]){var s=e.slice(0,-1).join("");o=Array.isArray(t)&&t[s]?t[s].length:0}for(var a=i?t:d(t,r,o),c=e.length-1;c>=0;--c){var u,l=e[c];if("[]"===l&&r.parseArrays)u=n.isOverflow(a)?a:r.allowEmptyArrays&&(""===a||r.strictNullHandling&&null===a)?[]:n.combine([],a,r.arrayLimit,r.plainObjects,r.throwOnLimitExceeded);else{u=r.plainObjects?{__proto__:null}:{};var h="["===l.charAt(0)&&"]"===l.charAt(l.length-1)?l.slice(1,-1):l,f=r.decodeDotInKeys?h.replace(/%2E/g,"."):h,p=parseInt(f,10),g=!isNaN(p)&&l!==f&&String(p)===f&&p>=0&&r.parseArrays;if(r.parseArrays||""!==f)if(g&&p<r.arrayLimit)(u=[])[p]=a;else{if(g&&r.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");g?(u[p]=a,n.markOverflow(u,p)):"__proto__"!==f&&(u[f]=a)}else u={0:a}}a=u}return a}(s,t,r,i)}};e.exports=function(e,t){var r=function(e){if(!e)return l;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var t=void 0===e.charset?l.charset:e.charset,r=void 0===e.duplicates?l.duplicates:e.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||l.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:l.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:l.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:l.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:l.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:l.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:l.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:l.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:l.decoder,delimiter:"string"==typeof e.delimiter||n.isRegExp(e.delimiter)?e.delimiter:l.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:l.depth,duplicates:r,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:l.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:l.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:l.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:l.strictDepth,strictMerge:"boolean"==typeof e.strictMerge?!!e.strictMerge:l.strictMerge,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:l.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}}(t);if(""===e||null==e)return r.plainObjects?{__proto__:null}:{};for(var a="string"==typeof e?function(e,t){var r={__proto__:null},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;i=i.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var a=t.parameterLimit===1/0?void 0:t.parameterLimit,c=i.split(t.delimiter,t.throwOnLimitExceeded&&void 0!==a?a+1:a);if(t.throwOnLimitExceeded&&void 0!==a&&c.length>a)throw new RangeError("Parameter limit exceeded. Only "+a+" parameter"+(1===a?"":"s")+" allowed.");var u,f=-1,p=t.charset;if(t.charsetSentinel)for(u=0;u<c.length;++u)0===c[u].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[u]?p="utf-8":"utf8=%26%2310003%3B"===c[u]&&(p="iso-8859-1"),f=u,u=c.length);for(u=0;u<c.length;++u)if(u!==f){var g,m,v=c[u],y=v.indexOf("]="),b=-1===y?v.indexOf("="):y+1,w=b>1&&"[]"===v.slice(b-2,b);if(-1===b?(g=t.decoder(v,l.decoder,p,"key"),m=t.strictNullHandling?null:""):null!==(g=t.decoder(v.slice(0,b),l.decoder,p,"key"))&&(m=n.maybeMap(d(v.slice(b+1),t,s(r[g])?r[g].length:0),(function(e){return t.decoder(e,l.decoder,p,"value")}))),m&&t.interpretNumericEntities&&"iso-8859-1"===p&&(m=h(String(m))),w&&(m=s(m)?[m]:m),t.comma&&s(m)&&m.length>t.arrayLimit&&(m=n.combine([],m,t.arrayLimit,t.plainObjects,t.throwOnLimitExceeded)),null!==g){var S=o.call(r,g);S&&("combine"===t.duplicates||w)?r[g]=n.combine(r[g],m,t.arrayLimit,t.plainObjects,t.throwOnLimitExceeded):S&&"last"!==t.duplicates||(r[g]=m)}}return r}(e,r):function(e){for(var t=i(),r={},n=[{source:e,target:r}],o=0;o<n.length;++o)for(var s=n[o].source,a=n[o].target,l=Object.keys(s),h=0;h<l.length;++h){var d=s[l[h]];if(c(d)){if(!t.has(d)){var f=u(d);t.set(d,f),n[n.length]={source:d,target:f}}a[l[h]]=t.get(d)}else a[l[h]]=d}return r}(e),p=r.plainObjects?{__proto__:null}:{},g=Object.keys(a),m=0;m<g.length;++m){var v=g[m],y=f(v,a[v],r,"string"==typeof e);p=n.merge(p,y,r)}return!0===r.allowSparse?p:n.compact(p)}},3904:(e,t,r)=>{var i=r(5292),n=r(8084),o=r(2449),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},c=Array.isArray,u=Array.prototype.push,l=function(e,t){u.apply(e,c(t)?t:[t])},h=Date.prototype.toISOString,d=o.default,f={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",depth:1/0,encode:!0,encodeDotInKeys:!1,encoder:n.encode,encodeValuesOnly:!1,filter:void 0,format:d,formatter:o.formatters[d],indices:!1,serializeDate:function(e){return h.call(e)},skipNulls:!1,strictNullHandling:!1},p={},g=function e(t,r,o,s,a,u,h,d,g,m,v,y,b,w,S,_,k,E,T,C){var P=t;if(C>T)throw new RangeError("Input depth exceeded depth option of "+T);for(var A,I=E,R=0,x=!1;void 0!==(I=I.get(p))&&!x;){var O=I.get(t);if(R+=1,void 0!==O){if(O===R)throw new RangeError("Cyclic object value");x=!0}void 0===I.get(p)&&(R=0)}if((P="function"==typeof m?m(r,P):P)instanceof Date?P=b(P):"comma"===o&&c(P)&&(P=n.maybeMap(P,(function(e){return e instanceof Date?b(e):e}))),null===P){if(u)return S(g&&!_?g(r,f.encoder,k,"key",w):r);P=""}if("string"==typeof(A=P)||"number"==typeof A||"boolean"==typeof A||"symbol"==typeof A||"bigint"==typeof A||n.isBuffer(P))return g?[S(_?r:g(r,f.encoder,k,"key",w))+"="+S(g(P,f.encoder,k,"value",w))]:[S(r)+"="+S(String(P))];var M,N=[];if(void 0===P)return N;if("comma"===o&&c(P))_&&g&&(P=n.maybeMap(P,(function(e){return null==e?e:g(e,f.encoder,k,"value",w)}))),M=[{value:P.length>0?n.toCoercible(P).join(",")||null:void 0}];else if(c(m))M=m;else{var L=Object.keys(P);M=v?L.sort(v):L}var B=String(r),D=s&&c(P)&&1===P.length?B+"[]":B;if(a&&c(P)&&0===P.length&&0===Object.keys(P).length)return S(g&&!_?g(D,f.encoder,k,"key",w):D)+"[]";for(var j=0;j<M.length;++j){var U=M[j],F="object"==typeof U&&U&&void 0!==U.value?U.value:P[U];if(!h||null!==F){var V=y&&d?String(U).replace(/\./g,"%2E"):String(U),W=c(P)?"function"==typeof o?o(D,V):D:D+(y?"."+V:"["+V+"]");E.set(t,R);var q=i();q.set(p,E),l(N,e(F,W,o,s,a,u,h,d,"comma"===o&&_&&c(P)?null:g,m,v,y,b,w,S,_,k,q,T,C+1))}}return N};e.exports=function(e,t){var r,n=e,u=function(e){if(!e)return f;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||f.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=o.default;if(void 0!==e.format){if(!s.call(o.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var i,n=o.formatters[r],u=f.filter;if(("function"==typeof e.filter||c(e.filter))&&(u=e.filter),i=s.call(a,e.arrayFormat)?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":f.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===e.allowDots?!0===e.encodeDotInKeys||f.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:f.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:f.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:f.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?f.delimiter:e.delimiter,depth:"number"==typeof e.depth?e.depth:f.depth,encode:"boolean"==typeof e.encode?e.encode:f.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:f.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:f.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:f.encodeValuesOnly,filter:u,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:f.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:f.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:f.strictNullHandling}}(t);"function"==typeof u.filter?n=(0,u.filter)("",n):c(u.filter)&&(r=u.filter);var h=[];if("object"!=typeof n||null===n)return"";var d=a[u.arrayFormat],p="comma"===d&&u.commaRoundTrip;r||(r=Object.keys(n)),u.sort&&r.sort(u.sort);for(var m=i(),v=0;v<r.length;++v){var y=r[v];if(null!=y){var b=n[y];if(!u.skipNulls||null!==b){var w=u.encodeDotInKeys?String(y).replace(/\./g,"%2E"):String(y);l(h,g(b,w,d,p,u.allowEmptyArrays,u.strictNullHandling,u.skipNulls,u.encodeDotInKeys,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,m,u.depth,0))}}}var S=h.join(u.delimiter),_=!0===u.addQueryPrefix?"?":"";return u.charsetSentinel&&("iso-8859-1"===u.charset?_+="utf8=%26%2310003%3B"+u.delimiter:_+="utf8=%E2%9C%93"+u.delimiter),S.length>0?_+S:""}},8084:(e,t,r)=>{var i=r(2449),n=r(5292),o=r(275),s=Object.prototype.hasOwnProperty,a=Array.isArray,c=n(),u=function(e,t){return c.set(e,t),e},l=function(e){return c.has(e)},h=function(e){return c.get(e)},d=function(e,t){c.set(e,t)},f=n(),p=function(e,t){return f.set(e,t),e},g=function(e){return f.has(e)},m=function(e){return f.get(e)},v=function(){for(var e=[],t=0;t<256;++t)e[e.length]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();return e}(),y=function(e,t){for(var r=t&&t.plainObjects?{__proto__:null}:{},i=0;i<e.length;++i)void 0!==e[i]&&(r[i]=e[i]);return r},b=function(e,t,r){"__proto__"===t&&o?o(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r},w=function(e,t,r){var i=[e,t];if(r&&"number"==typeof r.arrayLimit&&i.length>r.arrayLimit){if(r.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");return u(y(i,r),1)}return i},S="function"==typeof Symbol&&"symbol"==typeof Symbol.toPrimitive,_=Array.prototype.join,k=Array.prototype.toString,E=Object.prototype.toString,T=function e(t,r){if(!t||"object"!=typeof t&&"function"!=typeof t)return t;if(S&&null!=t[Symbol.toPrimitive])return t;if(a(t)&&t.toString===k&&t.join===_){var i,o=r||n();if(o.has(t))return"";o.set(t,!0);for(var s=0;s<t.length;s+=1){var c=t[s],u=e(c,o);if(!i&&u!==c){i=[];for(var l=0;l<s;l+=1)i[l]=t[l]}i&&(i[s]=u)}return o.delete(t),i||t}if("function"==typeof t.toString)return t;var h=t.valueOf;if("function"==typeof h){var d=h.call(t);if(!d||"object"!=typeof d&&"function"!=typeof d)return String(d)}return E.call(t)},C=1024;e.exports={arrayToObject:y,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return b(e,r,t[r]),e}),e)},combine:function(e,t,r,i,n){if(l(e)){if(n)throw new RangeError("Array limit exceeded. Only "+r+" element"+(1===r?"":"s")+" allowed in an array.");for(var o=a(t)?t:[t],s=h(e),c=0;c<o.length;++c)e[s+=1]=o[c];return d(e,s),e}var f=[].concat(e,t);if(f.length>r){if(n)throw new RangeError("Array limit exceeded. Only "+r+" element"+(1===r?"":"s")+" allowed in an array.");return u(y(f,{plainObjects:i}),f.length-1)}return f},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=n(),i=0;i<t.length;++i)for(var o=t[i],s=o.obj[o.prop],c=Object.keys(s),u=0;u<c.length;++u){var l=c[u],h=s[l];"object"!=typeof h||null===h||r.has(h)||(t[t.length]={obj:s,prop:l},r.set(h,!0))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(a(r)){for(var i=[],n=0;n<r.length;++n)void 0!==r[n]&&(i[i.length]=r[n]);t.obj[t.prop]=i}}}(t),e},decode:function(e,t,r){if("string"==typeof e&&-1===e.indexOf("%"))return-1===e.indexOf("+")?e:e.replace(/\+/g," ");var i=e.replace(/\+/g," ");if("iso-8859-1"===r)return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch(e){return i}},encode:function(e,t,r,n,o){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(T(e))),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"})).replace(/\+/g,"%2B");for(var a="",c=0;c<s.length;c+=C){var u=s.length>=C?s.slice(c,c+C):s;if(c+C<s.length){var l=u.charCodeAt(u.length-1);l>=55296&&l<=56319&&(u=u.slice(0,-1),c-=1)}for(var h=[],d=0;d<u.length;++d){var f=u.charCodeAt(d);45===f||46===f||95===f||126===f||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||o===i.RFC1738&&(40===f||41===f)?h[h.length]=u.charAt(d):f<128?h[h.length]=v[f]:f<2048?h[h.length]=v[192|f>>6]+v[128|63&f]:f<55296||f>=57344?h[h.length]=v[224|f>>12]+v[128|f>>6&63]+v[128|63&f]:(d+=1,f=65536+((1023&f)<<10|1023&u.charCodeAt(d)),h[h.length]=v[240|f>>18]+v[128|f>>12&63]+v[128|f>>6&63]+v[128|63&f])}a+=h.join("")}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!(!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))},isOverflow:l,isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},markOverflow:u,maybeMap:function(e,t){if(a(e)){for(var r=[],i=0;i<e.length;i+=1)r[r.length]=t(e[i]);return r}return t(e)},merge:function e(t,r,i){if(!r)return t;if("object"!=typeof r&&"function"!=typeof r){if(a(t)){var n=t.length;if(i&&"number"==typeof i.arrayLimit&&n>=i.arrayLimit){if(i.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+i.arrayLimit+" element"+(1===i.arrayLimit?"":"s")+" allowed in an array.");return u(y(t.concat(r),i),n)}t[n]=r}else{if(!t||"object"!=typeof t)return w(t,r,i);if(l(t)){var o=h(t)+1;t[o]=r,d(t,o)}else if(i&&i.strictMerge&&g(t)){var c=m(t)+1;if(i.throwOnLimitExceeded&&"number"==typeof i.arrayLimit&&c>=i.arrayLimit)throw new RangeError("Array limit exceeded. Only "+i.arrayLimit+" element"+(1===i.arrayLimit?"":"s")+" allowed in an array.");t[c]=r,p(t,c)}else{if(i&&i.strictMerge){var f=w(t,r,i);return a(f)?p(f,1):f}(i&&(i.plainObjects||i.allowPrototypes)||!s.call(Object.prototype,r))&&(t[r]=!0)}}return t}if(!t||"object"!=typeof t){if(l(r)){for(var v=Object.keys(r),S=i&&i.plainObjects?{__proto__:null,0:t}:{0:t},_=0;_<v.length;_++){S[parseInt(v[_],10)+1]=r[v[_]]}return u(S,h(r)+1)}var k=[t].concat(r);if(i&&"number"==typeof i.arrayLimit&&k.length>i.arrayLimit){if(i.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+i.arrayLimit+" element"+(1===i.arrayLimit?"":"s")+" allowed in an array.");return u(y(k,i),k.length-1)}return k}var E=t;if(a(t)&&!a(r)&&(E=y(t,i),g(t)&&p(E,t.length-1)),a(t)&&a(r)){if(r.forEach((function(r,n){if(s.call(t,n)){var o=t[n];o&&"object"==typeof o&&r&&"object"==typeof r?t[n]=e(o,r,i):t[t.length]=r}else t[n]=r})),i&&"number"==typeof i.arrayLimit&&t.length>i.arrayLimit){if(i.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+i.arrayLimit+" element"+(1===i.arrayLimit?"":"s")+" allowed in an array.");return u(y(t,i),t.length-1)}return t}return Object.keys(r).reduce((function(t,n){var o=r[n];if(s.call(t,n)?b(t,n,e(t[n],o,i)):b(t,n,o),l(r)&&!l(t)&&u(t,function(e,t){for(var r=t,i=Object.keys(e),n=0;n<i.length;++n){var o=parseInt(i[n],10);String(o)===i[n]&&o>r&&(r=o)}return r}(t,h(r))),l(t)){var a=parseInt(n,10);String(a)===n&&a>=0&&a>h(t)&&d(t,a)}if(g(t)){var c=parseInt(n,10);String(c)===n&&c>m(t)&&p(t,c)}return t}),E)},toCoercible:T}},2132:e=>{var t={};function r(e,r,i){i||(i=Error);var n=function(e){var t,i;function n(t,i,n){return e.call(this,function(e,t,i){return"string"==typeof r?r:r(e,t,i)}(t,i,n))||this}return i=e,(t=n).prototype=Object.create(i.prototype),t.prototype.constructor=t,t.__proto__=i,n}(i);n.prototype.name=i.name,n.prototype.code=e,t[e]=n}function i(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(i(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(i(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},9490:(e,t,r)=>{var i=r(1626),n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=r(4352),s=r(9904);r(2982)(l,o);for(var a=n(s.prototype),c=0;c<a.length;c++){var u=a[c];l.prototype[u]||(l.prototype[u]=s.prototype[u])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",h)))}function h(){this._writableState.ended||i.nextTick(d,this)}function d(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},2788:(e,t,r)=>{e.exports=n;var i=r(2286);function n(e){if(!(this instanceof n))return new n(e);i.call(this,e)}r(2982)(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},4352:(e,t,r)=>{var i,n=r(1626);e.exports=T,T.ReadableState=E;r(8987).EventEmitter;var o=function(e,t){return e.listeners(t).length},s=r(9325),a=r(6459).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var u,l=r(2472);u=l&&l.debuglog?l.debuglog("stream"):function(){};var h,d,f,p=r(4245),g=r(9820),m=r(2407).getHighWaterMark,v=r(2132).F,y=v.ERR_INVALID_ARG_TYPE,b=v.ERR_STREAM_PUSH_AFTER_EOF,w=v.ERR_METHOD_NOT_IMPLEMENTED,S=v.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(2982)(T,s);var _=g.errorOrDestroy,k=["error","close","destroy","pause","resume"];function E(e,t,n){i=i||r(9490),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=m(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(6913).I),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function T(e){if(i=i||r(9490),!(this instanceof T))return new T(e);var t=this instanceof i;this._readableState=new E(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function C(e,t,r,i,n){u("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?R(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,x(e)))}(e,s);else if(n||(o=function(e,t){var r;i=t,a.isBuffer(i)||i instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new y("chunk",["string","Buffer","Uint8Array"],t));var i;return r}(s,t)),o)_(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)s.endEmitted?_(e,new S):P(e,s,t,!0);else if(s.ended)_(e,new b);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?P(e,s,t,!1):O(e,s)):P(e,s,t,!1)}else i||(s.reading=!1,O(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function P(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&R(e)),O(e,t)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),T.prototype.destroy=g.destroy,T.prototype._undestroy=g.undestroy,T.prototype._destroy=function(e,t){t(e)},T.prototype.push=function(e,t){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=a.from(e,t),t=""),r=!0),C(this,e,t,!1,r)},T.prototype.unshift=function(e){return C(this,e,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(e){h||(h=r(6913).I);var t=new h(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n="";null!==i;)n+=t.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var A=1073741824;function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=A?e=A:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function R(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(x,e))}function x(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,D(e)}function O(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(M,e,t))}function M(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(u("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function N(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function L(e){u("readable nexttick read 0"),e.read(0)}function B(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),D(e),t.flowing&&!t.reading&&e.read(0)}function D(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function j(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function U(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(F,t,e))}function F(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function V(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}T.prototype.read=function(e){u("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):R(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&U(this),null;var i,n=t.needReadable;return u("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&u("length less than watermark",n=!0),t.ended||t.reading?u("reading or ended",n=!1):n&&(u("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(r,t))),null===(i=e>0?j(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&U(this)),null!==i&&this.emit("data",i),i},T.prototype._read=function(e){_(this,new w("_read()"))},T.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:m;function a(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",f),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",m),r.removeListener("data",d),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){u("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,D(e))}}(r);e.on("drain",l);var h=!1;function d(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==V(i.pipes,e))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function f(t){u("onerror",t),m(),e.removeListener("error",f),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",g),m()}function g(){u("onfinish"),e.removeListener("close",p),m()}function m(){u("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},T.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=V(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},T.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?R(this):i.reading||n.nextTick(L,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(N,this),r},T.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(N,this),t},T.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(B,e,t))}(this,e)),e.paused=!1,this},T.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){(u("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var o=0;o<k.length;o++)e.on(k[o],this.emit.bind(this,k[o]));return this._read=function(t){u("wrapped _read",t),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=r(3847)),d(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),T._fromList=j,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(e,t){return void 0===f&&(f=r(3017)),f(T,e,t)})},2286:(e,t,r)=>{e.exports=l;var i=r(2132).F,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,c=r(9490);function u(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);c.call(this,e),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?d(this,null,null):this._flush((function(t,r){d(e,t,r)}))}function d(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(2982)(l,c),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,r){r(new n("_transform()"))},l.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},9904:(e,t,r)=>{var i,n=r(1626);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var i=e.entry;e.entry=null;for(;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}(t,e)}}e.exports=T,T.WritableState=E;var s={deprecate:r(4023)},a=r(9325),c=r(6459).Buffer,u=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l,h=r(9820),d=r(2407).getHighWaterMark,f=r(2132).F,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_METHOD_NOT_IMPLEMENTED,m=f.ERR_MULTIPLE_CALLBACK,v=f.ERR_STREAM_CANNOT_PIPE,y=f.ERR_STREAM_DESTROYED,b=f.ERR_STREAM_NULL_VALUES,w=f.ERR_STREAM_WRITE_AFTER_END,S=f.ERR_UNKNOWN_ENCODING,_=h.errorOrDestroy;function k(){}function E(e,t,s){i=i||r(9490),e=e||{},"boolean"!=typeof s&&(s=t instanceof i),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=d(this,e,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===e.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,i=r.sync,o=r.writecb;if("function"!=typeof o)throw new m;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,i,o){--t.pendingcb,r?(n.nextTick(o,i),n.nextTick(x,e,t),e._writableState.errorEmitted=!0,_(e,i)):(o(i),e._writableState.errorEmitted=!0,_(e,i),x(e,t))}(e,r,i,t,o);else{var s=I(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||A(e,r),i?n.nextTick(P,e,r,s,o):P(e,r,s,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(e){var t=this instanceof(i=i||r(9490));if(!t&&!l.call(T,this))return new T(e);this._writableState=new E(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function C(e,t,r,i,n,o,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new y("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function P(e,t,r,i){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),x(e,t)}function A(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)n[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;n.allBuffers=c,C(e,t,!0,t.length,n,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,h=r.callback;if(C(e,t,!1,t.objectMode?1:u.length,u,l,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function I(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function R(e,t){e._final((function(r){t.pendingcb--,r&&_(e,r),t.prefinished=!0,e.emit("prefinish"),x(e,t)}))}function x(e,t){var r=I(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(R,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}r(2982)(T,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(l=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!l.call(this,e)||this===T&&(e&&e._writableState instanceof E)}})):l=function(e){return e instanceof this},T.prototype.pipe=function(){_(this,new v)},T.prototype.write=function(e,t,r){var i,o=this._writableState,s=!1,a=!o.objectMode&&(i=e,c.isBuffer(i)||i instanceof u);return a&&!c.isBuffer(e)&&(e=function(e){return c.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=k),o.ending?function(e,t){var r=new w;_(e,r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,i){var o;return null===r?o=new b:"string"==typeof r||t.objectMode||(o=new p("chunk",["string","Buffer"],r)),!o||(_(e,o),n.nextTick(i,o),!1)}(this,o,e,r))&&(o.pendingcb++,s=function(e,t,r,i,n,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,r));return t}(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=t.objectMode?1:i.length;t.length+=a;var u=t.length<t.highWaterMark;u||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,a,i,n,o);return u}(this,o,a,e,t,r)),s},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||A(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new g("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,x(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=h.destroy,T.prototype._undestroy=h.undestroy,T.prototype._destroy=function(e,t){t(e)}},3847:(e,t,r)=>{var i,n=r(1626);function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=r(3618),a=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),h=Symbol("lastPromise"),d=Symbol("handlePromise"),f=Symbol("stream");function p(e,t){return{value:e,done:t}}function g(e){var t=e[a];if(null!==t){var r=e[f].read();null!==r&&(e[h]=null,e[a]=null,e[c]=null,t(p(r,!1)))}}function m(e){n.nextTick(g,e)}var v=Object.getPrototypeOf((function(){})),y=Object.setPrototypeOf((o(i={get stream(){return this[f]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(p(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[u]?r(e[u]):t(p(void 0,!0))}))}));var r,i=this[h];if(i)r=new Promise(function(e,t){return function(r,i){e.then((function(){t[l]?r(p(void 0,!0)):t[d](r,i)}),i)}}(i,this));else{var o=this[f].read();if(null!==o)return Promise.resolve(p(o,!1));r=new Promise(this[d])}return this[h]=r,r}},Symbol.asyncIterator,(function(){return this})),o(i,"return",(function(){var e=this;return new Promise((function(t,r){e[f].destroy(null,(function(e){e?r(e):t(p(void 0,!0))}))}))})),i),v);e.exports=function(e){var t,r=Object.create(y,(o(t={},f,{value:e,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,d,{value:function(e,t){var i=r[f].read();i?(r[h]=null,r[a]=null,r[c]=null,e(p(i,!1))):(r[a]=e,r[c]=t)},writable:!0}),t));return r[h]=null,s(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[c];return null!==t&&(r[h]=null,r[a]=null,r[c]=null,t(e)),void(r[u]=e)}var i=r[a];null!==i&&(r[h]=null,r[a]=null,r[c]=null,i(p(void 0,!0))),r[l]=!0})),e.on("readable",m.bind(null,r)),r}},4245:(e,t,r)=>{function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function n(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,a(i.key),i)}}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var c=r(6459).Buffer,u=r(9546).inspect,l=u&&u.custom||"inspect";function h(e,t,r){c.prototype.copy.call(e,t,r)}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,r,i;return t=e,(r=[{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,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return c.alloc(0);for(var t=c.allocUnsafe(e>>>0),r=this.head,i=0;r;)h(r.data,t,i),i+=r.data.length,r=r.next;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=c.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,o=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,o),0==(e-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,t}},{key:l,value:function(e,t){return u(this,n(n({},t),{},{depth:0,customInspect:!1}))}}])&&s(t.prototype,r),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}()},9820:(e,t,r)=>{var i=r(1626);function n(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function s(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(s,this,e)):i.nextTick(s,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?r._writableState?r._writableState.errorEmitted?i.nextTick(o,r):(r._writableState.errorEmitted=!0,i.nextTick(n,r,e)):i.nextTick(n,r,e):t?(i.nextTick(o,r),t(e)):i.nextTick(o,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}}},3618:(e,t,r)=>{var i=r(2132).F.ERR_STREAM_PREMATURE_CLOSE;function n(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}(o||n);var s=r.readable||!1!==r.readable&&t.readable,a=r.writable||!1!==r.writable&&t.writable,c=function(){t.writable||l()},u=t._writableState&&t._writableState.finished,l=function(){a=!1,u=!0,s||o.call(t)},h=t._readableState&&t._readableState.endEmitted,d=function(){s=!1,h=!0,a||o.call(t)},f=function(e){o.call(t,e)},p=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new i),o.call(t,e)):a&&!u?(t._writableState&&t._writableState.ended||(e=new i),o.call(t,e)):void 0},g=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",c),t.on("close",c)):(t.on("complete",l),t.on("abort",p),t.req?g():t.on("request",g)),t.on("end",d),t.on("finish",l),!1!==r.error&&t.on("error",f),t.on("close",p),function(){t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",g),t.req&&t.req.removeListener("finish",l),t.removeListener("end",c),t.removeListener("close",c),t.removeListener("finish",l),t.removeListener("end",d),t.removeListener("error",f),t.removeListener("close",p)}}},3017:e=>{e.exports=function(){throw new Error("Readable.from is not available in the browser")}},7066:(e,t,r)=>{var i;var n=r(2132).F,o=n.ERR_MISSING_ARGS,s=n.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function c(e){e()}function u(e,t){return e.pipe(t)}e.exports=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var l,h=function(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var d=t.map((function(e,n){var o=n<t.length-1;return function(e,t,n,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var a=!1;e.on("close",(function(){a=!0})),void 0===i&&(i=r(3618)),i(e,{readable:t,writable:n},(function(e){if(e)return o(e);a=!0,o()}));var c=!1;return function(t){if(!a&&!c)return c=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new s("pipe"))}}(e,o,n>0,(function(e){l||(l=e),e&&d.forEach(c),o||(d.forEach(c),h(l))}))}));return t.reduce(u)}},2407:(e,t,r)=>{var i=r(2132).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,n){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,n,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new i(n?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},9325:(e,t,r)=>{e.exports=r(8987).EventEmitter},4531:(e,t,r)=>{(t=e.exports=r(4352)).Stream=t,t.Readable=t,t.Writable=r(9904),t.Duplex=r(9490),t.Transform=r(2286),t.PassThrough=r(2788),t.finished=r(3618),t.pipeline=r(7066)},1589:e=>{function t(e,t,r){var i=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,e,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._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 r=0;r<e.length;r++)e[r]=arguments[r+2]}return new t(arguments[0],arguments[1],e)}},3633:(e,t,r)=>{e.exports=r(5520)()},5520:(e,t,r)=>{var i=r(6459).Buffer;function n(e){return e instanceof i?i.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}e.exports=function(e){if((e=e||{}).circles)return function(e){const t=[],r=[],i=new Map;if(i.set(Date,(e=>new Date(e))),i.set(Map,((e,t)=>new Map(s(Array.from(e),t)))),i.set(Set,((e,t)=>new Set(s(Array.from(e),t)))),e.constructorHandlers)for(const t of e.constructorHandlers)i.set(t[0],t[1]);let o=null;return e.proto?c:a;function s(e,s){const a=Object.keys(e),c=new Array(a.length);for(let u=0;u<a.length;u++){const l=a[u],h=e[l];if("object"!=typeof h||null===h)c[l]=h;else if(h.constructor!==Object&&(o=i.get(h.constructor)))c[l]=o(h,s);else if(ArrayBuffer.isView(h))c[l]=n(h);else{const e=t.indexOf(h);c[l]=-1!==e?r[e]:s(h)}}return c}function a(e){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return s(e,a);if(e.constructor!==Object&&(o=i.get(e.constructor)))return o(e,a);const c={};t.push(e),r.push(c);for(const s in e){if(!1===Object.hasOwnProperty.call(e,s))continue;const u=e[s];if("object"!=typeof u||null===u)c[s]=u;else if(u.constructor!==Object&&(o=i.get(u.constructor)))c[s]=o(u,a);else if(ArrayBuffer.isView(u))c[s]=n(u);else{const e=t.indexOf(u);c[s]=-1!==e?r[e]:a(u)}}return t.pop(),r.pop(),c}function c(e){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))return s(e,c);if(e.constructor!==Object&&(o=i.get(e.constructor)))return o(e,c);const a={};t.push(e),r.push(a);for(const s in e){const u=e[s];if("object"!=typeof u||null===u)a[s]=u;else if(u.constructor!==Object&&(o=i.get(u.constructor)))a[s]=o(u,c);else if(ArrayBuffer.isView(u))a[s]=n(u);else{const e=t.indexOf(u);a[s]=-1!==e?r[e]:c(u)}}return t.pop(),r.pop(),a}}(e);const t=new Map;if(t.set(Date,(e=>new Date(e))),t.set(Map,((e,t)=>new Map(i(Array.from(e),t)))),t.set(Set,((e,t)=>new Set(i(Array.from(e),t)))),e.constructorHandlers)for(const r of e.constructorHandlers)t.set(r[0],r[1]);let r=null;return e.proto?function e(o){if("object"!=typeof o||null===o)return o;if(Array.isArray(o))return i(o,e);if(o.constructor!==Object&&(r=t.get(o.constructor)))return r(o,e);const s={};for(const i in o){const a=o[i];"object"!=typeof a||null===a?s[i]=a:a.constructor!==Object&&(r=t.get(a.constructor))?s[i]=r(a,e):ArrayBuffer.isView(a)?s[i]=n(a):s[i]=e(a)}return s}:function e(o){if("object"!=typeof o||null===o)return o;if(Array.isArray(o))return i(o,e);if(o.constructor!==Object&&(r=t.get(o.constructor)))return r(o,e);const s={};for(const i in o){if(!1===Object.hasOwnProperty.call(o,i))continue;const a=o[i];"object"!=typeof a||null===a?s[i]=a:a.constructor!==Object&&(r=t.get(a.constructor))?s[i]=r(a,e):ArrayBuffer.isView(a)?s[i]=n(a):s[i]=e(a)}return s};function i(e,i){const o=Object.keys(e),s=new Array(o.length);for(let a=0;a<o.length;a++){const c=o[a],u=e[c];"object"!=typeof u||null===u?s[c]=u:u.constructor!==Object&&(r=t.get(u.constructor))?s[c]=r(u,i):ArrayBuffer.isView(u)?s[c]=n(u):s[c]=i(u)}return s}}},8681:(e,t,r)=>{var i=r(6459),n=i.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(o(i,t),t.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},7143:(e,t,r)=>{var i=r(5295),n=r(5471),o=function(e,t,r){for(var i,n=e;null!=(i=n.next);n=i)if(i.key===t)return n.next=i.next,r||(i.next=e.next,e.next=i),i};e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n("Side channel does not contain "+i(e))},delete:function(t){var r=function(e,t){if(e)return o(e,t,!0)}(e,t);return r&&e&&!e.next&&(e=void 0),!!r},get:function(t){return function(e,t){if(e){var r=o(e,t);return r&&r.value}}(e,t)},has:function(t){return function(e,t){return!!e&&!!o(e,t)}(e,t)},set:function(t,r){e||(e={next:void 0}),function(e,t,r){var i=o(e,t);i?i.value=r:e.next={key:t,next:e.next,value:r}}(e,t,r)}};return t}},7727:(e,t,r)=>{var i=r(3601),n=r(9584),o=r(5295),s=r(5471),a=i("%Map%",!0),c=n("Map.prototype.get",!0),u=n("Map.prototype.set",!0),l=n("Map.prototype.has",!0),h=n("Map.prototype.delete",!0),d=n("Map.prototype.size",!0);e.exports=!!a&&function(){var e,t={assert:function(e){if(!t.has(e))throw new s("Side channel does not contain "+o(e))},delete:function(t){if(e){var r=h(e,t);return 0===d(e)&&(e=void 0),r}return!1},get:function(t){if(e)return c(e,t)},has:function(t){return!!e&&l(e,t)},set:function(t,r){e||(e=new a),u(e,t,r)}};return t}},7395:(e,t,r)=>{var i=r(3601),n=r(9584),o=r(5295),s=r(7727),a=r(5471),c=i("%WeakMap%",!0),u=n("WeakMap.prototype.get",!0),l=n("WeakMap.prototype.set",!0),h=n("WeakMap.prototype.has",!0),d=n("WeakMap.prototype.delete",!0);e.exports=c?function(){var e,t,r={assert:function(e){if(!r.has(e))throw new a("Side channel does not contain "+o(e))},delete:function(r){if(c&&r&&("object"==typeof r||"function"==typeof r)){if(e)return d(e,r)}else if(s&&t)return t.delete(r);return!1},get:function(r){return c&&r&&("object"==typeof r||"function"==typeof r)&&e?u(e,r):t&&t.get(r)},has:function(r){return c&&r&&("object"==typeof r||"function"==typeof r)&&e?h(e,r):!!t&&t.has(r)},set:function(r,i){c&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new c),l(e,r,i)):s&&(t||(t=s()),t.set(r,i))}};return r}:s},5292:(e,t,r)=>{var i=r(5471),n=r(5295),o=r(7143),s=r(7727),a=r(7395)||s||o;e.exports=function(){var e,t={assert:function(e){if(!t.has(e)){var r=e&&Object(e)===e?"the given object key":n(e);throw new i("Side channel does not contain "+r)}},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,r){e||(e=a()),e.set(t,r)}};return t}},1808:e=>{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){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}(t)):null}},6913:(e,t,r)=>{var i=r(8681).Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=h,t=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var n=s(t[i]);if(n>=0)return n>0&&(e.lastNeed=n-1),n;if(--i<r||-2===n)return 0;if(n=s(t[i]),n>=0)return n>0&&(e.lastNeed=n-2),n;if(--i<r||-2===n)return 0;if(n=s(t[i]),n>=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},9199:(e,t,r)=>{var i=r(1715);function n(){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}var o=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),l=["%","/","?",";","#"].concat(u),h=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,p={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=r(1065);function y(e,t,r){if(e&&"object"==typeof e&&e instanceof n)return e;var i=new n;return i.parse(e,t,r),i}n.prototype.parse=function(e,t,r){if("string"!=typeof e)throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e.indexOf("?"),s=-1!==n&&n<e.indexOf("#")?"?":"#",c=e.split(s);c[0]=c[0].replace(/\\/g,"/");var y=e=c.join(s);if(y=y.trim(),!r&&1===e.split("#").length){var b=a.exec(y);if(b)return this.path=y,this.href=y,this.pathname=b[1],b[2]?(this.search=b[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=o.exec(y);if(w){var S=(w=w[0]).toLowerCase();this.protocol=S,y=y.substr(w.length)}if(r||w||y.match(/^\/\/[^@/]+@[^@/]+/)){var _="//"===y.substr(0,2);!_||w&&g[w]||(y=y.substr(2),this.slashes=!0)}if(!g[w]&&(_||w&&!m[w])){for(var k,E,T=-1,C=0;C<h.length;C++){-1!==(P=y.indexOf(h[C]))&&(-1===T||P<T)&&(T=P)}-1!==(E=-1===T?y.lastIndexOf("@"):y.lastIndexOf("@",T))&&(k=y.slice(0,E),y=y.slice(E+1),this.auth=decodeURIComponent(k)),T=-1;for(C=0;C<l.length;C++){var P;-1!==(P=y.indexOf(l[C]))&&(-1===T||P<T)&&(T=P)}-1===T&&(T=y.length),this.host=y.slice(0,T),y=y.slice(T),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var I=this.hostname.split(/\./),R=(C=0,I.length);C<R;C++){var x=I[C];if(x&&!x.match(d)){for(var O="",M=0,N=x.length;M<N;M++)x.charCodeAt(M)>127?O+="x":O+=x[M];if(!O.match(d)){var L=I.slice(0,C),B=I.slice(C+1),D=x.match(f);D&&(L.push(D[1]),B.unshift(D[2])),B.length&&(y="/"+B.join(".")+y),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),A||(this.hostname=i.toASCII(this.hostname));var j=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+j,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!p[S])for(C=0,R=u.length;C<R;C++){var F=u[C];if(-1!==y.indexOf(F)){var V=encodeURIComponent(F);V===F&&(V=escape(F)),y=y.split(F).join(V)}}var W=y.indexOf("#");-1!==W&&(this.hash=y.substr(W),y=y.slice(0,W));var q=y.indexOf("?");if(-1!==q?(this.search=y.substr(q),this.query=y.substr(q+1),t&&(this.query=v.parse(this.query)),y=y.slice(0,q)):t&&(this.search="",this.query={}),y&&(this.pathname=y),m[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){j=this.pathname||"";var H=this.search||"";this.path=j+H}return this.href=this.format(),this},n.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",i=this.hash||"",n=!1,o="";this.host?n=e+this.host:this.hostname&&(n=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(o=v.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||m[t])&&!1!==n?(n="//"+(n||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):n||(n=""),i&&"#"!==i.charAt(0)&&(i="#"+i),s&&"?"!==s.charAt(0)&&(s="?"+s),t+n+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+i},n.prototype.resolve=function(e){return this.resolveObject(y(e,!1,!0)).format()},n.prototype.resolveObject=function(e){if("string"==typeof e){var t=new n;t.parse(e,!1,!0),e=t}for(var r=new n,i=Object.keys(this),o=0;o<i.length;o++){var s=i[o];r[s]=this[s]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var a=Object.keys(e),c=0;c<a.length;c++){var u=a[c];"protocol"!==u&&(r[u]=e[u])}return m[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!m[e.protocol]){for(var l=Object.keys(e),h=0;h<l.length;h++){var d=l[h];r[d]=e[d]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||g[e.protocol])r.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(""),r.pathname=f.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var p=r.pathname||"",v=r.search||"";r.path=p+v}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var y=r.pathname&&"/"===r.pathname.charAt(0),b=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=b||y||r.host&&e.pathname,S=w,_=r.pathname&&r.pathname.split("/")||[],k=(f=e.pathname&&e.pathname.split("/")||[],r.protocol&&!m[r.protocol]);if(k&&(r.hostname="",r.port=null,r.host&&(""===_[0]?_[0]=r.host:_.unshift(r.host)),r.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]||""===_[0])),b)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,_=f;else if(f.length)_||(_=[]),_.pop(),_=_.concat(f),r.search=e.search,r.query=e.query;else if(null!=e.search){if(k)r.host=_.shift(),r.hostname=r.host,(A=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=A.shift(),r.hostname=A.shift(),r.host=r.hostname);return r.search=e.search,r.query=e.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!_.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=_.slice(-1)[0],T=(r.host||e.host||_.length>1)&&("."===E||".."===E)||""===E,C=0,P=_.length;P>=0;P--)"."===(E=_[P])?_.splice(P,1):".."===E?(_.splice(P,1),C++):C&&(_.splice(P,1),C--);if(!w&&!S)for(;C--;C)_.unshift("..");!w||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),T&&"/"!==_.join("/").substr(-1)&&_.push("");var A,I=""===_[0]||_[0]&&"/"===_[0].charAt(0);k&&(r.hostname=I?"":_.length?_.shift():"",r.host=r.hostname,(A=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=A.shift(),r.hostname=A.shift(),r.host=r.hostname));return(w=w||r.host&&_.length)&&!I&&_.unshift(""),_.length>0?r.pathname=_.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.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)},t.parse=y,t.resolve=function(e,t){return y(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?y(e,!1,!0).resolveObject(t):t},t.format=function(e){return"string"==typeof e&&(e=y(e)),e instanceof n?e.format():n.prototype.format.call(e)},t.Url=n},4023:(e,t,r)=>{function i(e){try{if(!r.g.localStorage)return!1}catch(e){return!1}var t=r.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}},1559:e=>{e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){i[e]=t[e]})),i;function i(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var i=t.apply(this,e),n=e[e.length-1];return"function"==typeof i&&i!==n&&Object.keys(n).forEach((function(e){i[e]=n[e]})),i}}},891:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},2290:e=>{e.exports=function(){for(var e={},r=0;r<arguments.length;r++){var i=arguments[r];for(var n in i)t.call(i,n)&&(e[n]=i[n])}return e};var t=Object.prototype.hasOwnProperty},6623:e=>{e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},8283:(e,t,r)=>{function i(e){var t=this;if(t instanceof i||(t=new i),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)t.push(arguments[r]);return t}function n(e,t,r){var i=t===e.head?new a(r,null,t,e):new a(r,t,t.next,e);return null===i.next&&(e.tail=i),null===i.prev&&(e.head=i),e.length++,i}function o(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,r,i){if(!(this instanceof a))return new a(e,t,r,i);this.list=i,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},i.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},i.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},i.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},i.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},i.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},i.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},i.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,i=0;null!==r;i++)e.call(t,r.value,i,this),r=r.next},i.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,i=this.length-1;null!==r;i--)e.call(t,r.value,i,this),r=r.prev},i.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},i.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},i.prototype.map=function(e,t){t=t||this;for(var r=new i,n=this.head;null!==n;)r.push(e.call(t,n.value,this)),n=n.next;return r},i.prototype.mapReverse=function(e,t){t=t||this;for(var r=new i,n=this.tail;null!==n;)r.push(e.call(t,n.value,this)),n=n.prev;return r},i.prototype.reduce=function(e,t){var r,i=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=e(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(e,t){var r,i=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=e(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},i.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},i.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,o=this.head;null!==o&&n<e;n++)o=o.next;for(;null!==o&&n<t;n++,o=o.next)r.push(o.value);return r},i.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,o=this.tail;null!==o&&n>t;n--)o=o.prev;for(;null!==o&&n>e;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(e,t){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var o=[];for(r=0;i&&r<t;r++)o.push(i.value),i=this.removeNode(i);null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev);for(r=0;r<(arguments.length<=2?0:arguments.length-2);r++)i=n(this,i,r+2<2||arguments.length<=r+2?void 0:arguments[r+2]);return o},i.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=t,this.tail=e,this};try{r(6623)(i)}catch(e){}},6526:function(e){e.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var i=r(18),n=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,i){void 0===i&&(i=!1);var n=e.getVersionPrecision(t),o=e.getVersionPrecision(r),s=Math.max(n,o),a=0,c=e.map([t,r],(function(t){var r=s-e.getVersionPrecision(t),i=t+new Array(r+1).join(".0");return e.map(i.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(i&&(a=s-Math.min(n,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var r,i=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)i.push(t(e[r]));return i},e.find=function(e,t){var r,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,i=e.length;r<i;r+=1){var n=e[r];if(t(n,r))return n}},e.assign=function(e){for(var t,r,i=e,n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){i[t]=e[t]}))};for(t=0,r=o.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return i.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return i.BROWSER_MAP[e]||""},e}();t.default=n,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(91))&&i.__esModule?i:{default:i},o=r(18);function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(){}var t,r,i;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new n.default(e,t)},e.parse=function(e){return new n.default(e).getResult()},t=e,i=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],(r=null)&&s(t.prototype,r),i&&s(t,i),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var i=c(r(92)),n=c(r(93)),o=c(r(94)),s=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},i=0,n={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(n[t]=s,o+=1):"object"==typeof s&&(r[t]=s,i+=1)})),i>0){var s=Object.keys(r),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var u=this.satisfies(r[c]);if(void 0!==u)return u}var l=a.default.find(s,(function(e){return t.isPlatform(e)}));if(l){var h=this.satisfies(r[l]);if(void 0!==h)return h}}if(o>0){var d=Object.keys(n),f=a.default.find(d,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(n[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),i=e.toLowerCase(),n=a.default.getBrowserTypeByAlias(i);return t&&n&&(i=n.toLowerCase()),i===r},t.compareVersion=function(e){var t=[0],r=e,i=!1,n=this.getBrowserVersion();if("string"==typeof n)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(i=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(i=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(n,r,i))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=n.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=n.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=n.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=n.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=n.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=n.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=n.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=n.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=n.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=n.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=n.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=n.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=n.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=n.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=n.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=n.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=n.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=n.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=n.default.getFirstMatch(o,e)||n.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=n.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=n.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=n.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=n.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=n.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=n.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=n.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=n.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=n.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=n.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:n.default.getFirstMatch(t,e),version:n.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=n.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=n.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=n.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=n.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=n.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=n.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=n.default.getMacOSVersionName(t),i={name:o.OS_MAP.MacOS,version:t};return r&&(i.versionName=r),i}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=n.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=n.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=n.default.getAndroidVersionName(t),i={name:o.OS_MAP.Android,version:t};return r&&(i.versionName=r),i}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=n.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=n.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||n.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||n.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=n.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=n.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=n.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=n.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=n.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var i,n=(i=r(17))&&i.__esModule?i:{default:i},o=r(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=n.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=n.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=n.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=n.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=n.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=s,e.exports=t.default}})},6077:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib.BlockCipher,r=e.algo,n=[],o=[],s=[],a=[],c=[],u=[],l=[],h=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,n[r]=p,o[p]=r;var g=e[r],m=e[g],v=e[m],y=257*e[p]^16843008*p;s[r]=y<<24|y>>>8,a[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*v^65537*m^257*g^16843008*r,l[p]=y<<24|y>>>8,h[p]=y<<16|y>>>16,d[p]=y<<8|y>>>24,f[p]=y,r?(r=g^e[e[e[v^g]]],i^=e[e[i]]):r=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=r.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s<i;s++)s<r?o[s]=t[s]:(u=o[s-1],s%r?r>6&&s%r==4&&(u=n[u>>>24]<<24|n[u>>>16&255]<<16|n[u>>>8&255]<<8|n[255&u]):(u=n[(u=u<<8|u>>>24)>>>24]<<24|n[u>>>16&255]<<16|n[u>>>8&255]<<8|n[255&u],u^=p[s/r|0]<<24),o[s]=o[s-r]^u);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(s=i-c,c%4)var u=o[s];else u=o[s-4];a[c]=c<4||s<=4?u:l[n[u>>>24]]^h[n[u>>>16&255]]^d[n[u>>>8&255]]^f[n[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,u,n)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,h,d,f,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,i,n,o,s,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],h=e[t+2]^r[2],d=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=i[u>>>24]^n[l>>>16&255]^o[h>>>8&255]^s[255&d]^r[f++],m=i[l>>>24]^n[h>>>16&255]^o[d>>>8&255]^s[255&u]^r[f++],v=i[h>>>24]^n[d>>>16&255]^o[u>>>8&255]^s[255&l]^r[f++],y=i[d>>>24]^n[u>>>16&255]^o[l>>>8&255]^s[255&h]^r[f++];u=g,l=m,h=v,d=y}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&d])^r[f++],m=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^r[f++],v=(a[h>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[f++],y=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^r[f++],e[t]=g,e[t+1]=m,e[t+2]=v,e[t+3]=y},keySize:8});e.AES=t._createHelper(g)}(),i.AES)},3134:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib.BlockCipher,r=e.algo;const n=16,o=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],s=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var a={pbox:[],sbox:[]};function c(e,t){let r=t>>24&255,i=t>>16&255,n=t>>8&255,o=255&t,s=e.sbox[0][r]+e.sbox[1][i];return s^=e.sbox[2][n],s+=e.sbox[3][o],s}function u(e,t,r){let i,o=t,s=r;for(let t=0;t<n;++t)o^=e.pbox[t],s=c(e,o)^s,i=o,o=s,s=i;return i=o,o=s,s=i,s^=e.pbox[n],o^=e.pbox[n+1],{left:o,right:s}}function l(e,t,r){let i,o=t,s=r;for(let t=n+1;t>1;--t)o^=e.pbox[t],s=c(e,o)^s,i=o,o=s,s=i;return i=o,o=s,s=i,s^=e.pbox[1],o^=e.pbox[0],{left:o,right:s}}function h(e,t,r){for(let t=0;t<4;t++){e.sbox[t]=[];for(let r=0;r<256;r++)e.sbox[t][r]=s[t][r]}let i=0;for(let s=0;s<n+2;s++)e.pbox[s]=o[s]^t[i],i++,i>=r&&(i=0);let a=0,c=0,l=0;for(let t=0;t<n+2;t+=2)l=u(e,a,c),a=l.left,c=l.right,e.pbox[t]=a,e.pbox[t+1]=c;for(let t=0;t<4;t++)for(let r=0;r<256;r+=2)l=u(e,a,c),a=l.left,c=l.right,e.sbox[t][r]=a,e.sbox[t][r+1]=c;return!0}var d=r.Blowfish=t.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4;h(a,t,r)}},encryptBlock:function(e,t){var r=u(a,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},decryptBlock:function(e,t){var r=l(a,e[t],e[t+1]);e[t]=r.left,e[t+1]=r.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=t._createHelper(d)}(),i.Blowfish)},7695:function(e,t,r){var i;e.exports=(i=r(4011),r(6296),void(i.lib.Cipher||function(e){var t=i,r=t.lib,n=r.Base,o=r.WordArray,s=r.BufferedBlockAlgorithm,a=t.enc,c=(a.Utf8,a.Base64),u=t.algo.EvpKDF,l=r.Cipher=s.extend({cfg:n.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?b:v}return function(t){return{encrypt:function(r,i,n){return e(i).encrypt(t,r,i,n)},decrypt:function(r,i,n){return e(i).decrypt(t,r,i,n)}}}}()}),h=(r.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),t.mode={}),d=r.BlockCipherMode=n.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=h.CBC=function(){var t=d.extend();function r(t,r,i){var n,o=this._iv;o?(n=o,this._iv=e):n=this._prevBlock;for(var s=0;s<i;s++)t[r+s]^=n[s]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize;r.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,o=e.slice(t,t+n);i.decryptBlock(e,t),r.call(this,e,t,n),this._prevBlock=o}}),t}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,n=i<<24|i<<16|i<<8|i,s=[],a=0;a<i;a+=4)s.push(n);var c=o.create(s,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},g=(r.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,r=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(i,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),r.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),m=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?o.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=o.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),g.create({ciphertext:r,salt:t})}},v=r.SerializableCipher=n.extend({cfg:n.extend({format:m}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=e.createEncryptor(r,i),o=n.finalize(t),s=n.cfg;return g.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(r,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,i,n){if(i||(i=o.random(8)),n)s=u.create({keySize:t+r,hasher:n}).compute(e,i);else var s=u.create({keySize:t+r}).compute(e,i);var a=o.create(s.words.slice(t),4*r);return s.sigBytes=4*t,g.create({key:s,iv:a,salt:i})}},b=r.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:y}),encrypt:function(e,t,r,i){var n=(i=this.cfg.extend(i)).kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=n.iv;var o=v.encrypt.call(this,e,t,n.key,i);return o.mixIn(n),o},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var n=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);return i.iv=n.iv,v.decrypt.call(this,e,t,n.key,i)}})}()))},4011:function(e,t,r){var i;e.exports=(i=i||function(e,t){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==r.g&&r.g.crypto&&(i=r.g.crypto),!i)try{i=r(477)}catch(e){}var n=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),s={},a=s.lib={},c=a.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=a.WordArray=c.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var s=r[o>>>2]>>>24-o%4*8&255;t[i+o>>>2]|=s<<24-(i+o)%4*8}else for(var a=0;a<n;a+=4)t[i+a>>>2]=r[a>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(n());return new u.init(t,e)}}),l=s.enc={},h=l.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new u.init(r,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new u.init(r,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,i=this._data,n=i.words,o=i.sigBytes,s=this.blockSize,a=o/(4*s),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,l=e.min(4*c,o);if(c){for(var h=0;h<c;h+=s)this._doProcessBlock(n,h);r=n.splice(0,c),i.sigBytes-=l}return new u.init(r,l)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new g.HMAC.init(e,r).finalize(t)}}}),s.algo={});return s}(Math),i)},304:function(e,t,r){var i;e.exports=(i=r(4011),function(){var e=i,t=e.lib.WordArray;function r(e,r,i){for(var n=[],o=0,s=0;s<r;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2|i[e.charCodeAt(s)]>>>6-s%4*2;n[o>>>2]|=a<<24-o%4*8,o++}return t.create(n,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,i=this._map;e.clamp();for(var n=[],o=0;o<r;o+=3)for(var s=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<r;a++)n.push(i.charAt(s>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;n.length%4;)n.push(c);return n.join("")},parse:function(e){var t=e.length,i=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var o=0;o<i.length;o++)n[i.charCodeAt(o)]=o}var s=i.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return r(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),i.enc.Base64)},7371:function(e,t,r){var i;e.exports=(i=r(4011),function(){var e=i,t=e.lib.WordArray;function r(e,r,i){for(var n=[],o=0,s=0;s<r;s++)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2|i[e.charCodeAt(s)]>>>6-s%4*2;n[o>>>2]|=a<<24-o%4*8,o++}return t.create(n,o)}e.enc.Base64url={stringify:function(e,t){void 0===t&&(t=!0);var r=e.words,i=e.sigBytes,n=t?this._safe_map:this._map;e.clamp();for(var o=[],s=0;s<i;s+=3)for(var a=(r[s>>>2]>>>24-s%4*8&255)<<16|(r[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|r[s+2>>>2]>>>24-(s+2)%4*8&255,c=0;c<4&&s+.75*c<i;c++)o.push(n.charAt(a>>>6*(3-c)&63));var u=n.charAt(64);if(u)for(;o.length%4;)o.push(u);return o.join("")},parse:function(e,t){void 0===t&&(t=!0);var i=e.length,n=t?this._safe_map:this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var s=0;s<n.length;s++)o[n.charCodeAt(s)]=s}var a=n.charAt(64);if(a){var c=e.indexOf(a);-1!==c&&(i=c)}return r(e,i,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),i.enc.Base64url)},8997:function(e,t,r){var i;e.exports=(i=r(4011),function(){var e=i,t=e.lib.WordArray,r=e.enc;function n(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],n=0;n<r;n+=2){var o=t[n>>>2]>>>16-n%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var r=e.length,i=[],n=0;n<r;n++)i[n>>>1]|=e.charCodeAt(n)<<16-n%2*16;return t.create(i,2*r)}},r.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],o=0;o<r;o+=2){var s=n(t[o>>>2]>>>16-o%4*8&65535);i.push(String.fromCharCode(s))}return i.join("")},parse:function(e){for(var r=e.length,i=[],o=0;o<r;o++)i[o>>>1]|=n(e.charCodeAt(o)<<16-o%2*16);return t.create(i,2*r)}}}(),i.enc.Utf16)},6296:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(4011),r(4077),r(4031),n=(i=l).lib,o=n.Base,s=n.WordArray,a=i.algo,c=a.MD5,u=a.EvpKDF=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,i=this.cfg,n=i.hasher.create(),o=s.create(),a=o.words,c=i.keySize,u=i.iterations;a.length<c;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var l=1;l<u;l++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),i.EvpKDF=function(e,t,r){return u.create(r).compute(e,t)},l.EvpKDF)},791:function(e,t,r){var i,n,o,s;e.exports=(s=r(4011),r(7695),n=(i=s).lib.CipherParams,o=i.enc.Hex,i.format.Hex={stringify:function(e){return e.ciphertext.toString(o)},parse:function(e){var t=o.parse(e);return n.create({ciphertext:t})}},s.format.Hex)},3303:function(e,t,r){var i;e.exports=(i=r(4011),r(3519),r(4031),i.HmacSHA256)},4031:function(e,t,r){var i,n,o,s;e.exports=(i=r(4011),o=(n=i).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,i=4*r;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),o=this._iKey=t.clone(),a=n.words,c=o.words,u=0;u<r;u++)a[u]^=1549556828,c[u]^=909522486;n.sigBytes=o.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},4422:function(e,t,r){var i;e.exports=(i=r(4011),r(4978),r(1670),r(8997),r(304),r(7371),r(6002),r(4077),r(3519),r(4610),r(9670),r(5895),r(7691),r(9718),r(4031),r(6173),r(6296),r(7695),r(3459),r(2401),r(1546),r(1063),r(2332),r(9283),r(6939),r(6828),r(8989),r(378),r(791),r(6077),r(1506),r(4967),r(7928),r(2210),r(3134),i)},1670:function(e,t,r){var i;e.exports=(i=r(4011),function(){if("function"==typeof ArrayBuffer){var e=i.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,i=[],n=0;n<r;n++)i[n>>>2]|=e[n]<<24-n%4*8;t.call(this,i,r)}else t.apply(this,arguments)};r.prototype=e}}(),i.lib.WordArray)},6002:function(e,t,r){var i;e.exports=(i=r(4011),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],v=e[t+6],y=e[t+7],b=e[t+8],w=e[t+9],S=e[t+10],_=e[t+11],k=e[t+12],E=e[t+13],T=e[t+14],C=e[t+15],P=o[0],A=o[1],I=o[2],R=o[3];P=u(P,A,I,R,s,7,a[0]),R=u(R,P,A,I,c,12,a[1]),I=u(I,R,P,A,f,17,a[2]),A=u(A,I,R,P,p,22,a[3]),P=u(P,A,I,R,g,7,a[4]),R=u(R,P,A,I,m,12,a[5]),I=u(I,R,P,A,v,17,a[6]),A=u(A,I,R,P,y,22,a[7]),P=u(P,A,I,R,b,7,a[8]),R=u(R,P,A,I,w,12,a[9]),I=u(I,R,P,A,S,17,a[10]),A=u(A,I,R,P,_,22,a[11]),P=u(P,A,I,R,k,7,a[12]),R=u(R,P,A,I,E,12,a[13]),I=u(I,R,P,A,T,17,a[14]),P=l(P,A=u(A,I,R,P,C,22,a[15]),I,R,c,5,a[16]),R=l(R,P,A,I,v,9,a[17]),I=l(I,R,P,A,_,14,a[18]),A=l(A,I,R,P,s,20,a[19]),P=l(P,A,I,R,m,5,a[20]),R=l(R,P,A,I,S,9,a[21]),I=l(I,R,P,A,C,14,a[22]),A=l(A,I,R,P,g,20,a[23]),P=l(P,A,I,R,w,5,a[24]),R=l(R,P,A,I,T,9,a[25]),I=l(I,R,P,A,p,14,a[26]),A=l(A,I,R,P,b,20,a[27]),P=l(P,A,I,R,E,5,a[28]),R=l(R,P,A,I,f,9,a[29]),I=l(I,R,P,A,y,14,a[30]),P=h(P,A=l(A,I,R,P,k,20,a[31]),I,R,m,4,a[32]),R=h(R,P,A,I,b,11,a[33]),I=h(I,R,P,A,_,16,a[34]),A=h(A,I,R,P,T,23,a[35]),P=h(P,A,I,R,c,4,a[36]),R=h(R,P,A,I,g,11,a[37]),I=h(I,R,P,A,y,16,a[38]),A=h(A,I,R,P,S,23,a[39]),P=h(P,A,I,R,E,4,a[40]),R=h(R,P,A,I,s,11,a[41]),I=h(I,R,P,A,p,16,a[42]),A=h(A,I,R,P,v,23,a[43]),P=h(P,A,I,R,w,4,a[44]),R=h(R,P,A,I,k,11,a[45]),I=h(I,R,P,A,C,16,a[46]),P=d(P,A=h(A,I,R,P,f,23,a[47]),I,R,s,6,a[48]),R=d(R,P,A,I,y,10,a[49]),I=d(I,R,P,A,T,15,a[50]),A=d(A,I,R,P,m,21,a[51]),P=d(P,A,I,R,k,6,a[52]),R=d(R,P,A,I,p,10,a[53]),I=d(I,R,P,A,S,15,a[54]),A=d(A,I,R,P,c,21,a[55]),P=d(P,A,I,R,b,6,a[56]),R=d(R,P,A,I,C,10,a[57]),I=d(I,R,P,A,v,15,a[58]),A=d(A,I,R,P,E,21,a[59]),P=d(P,A,I,R,g,6,a[60]),R=d(R,P,A,I,_,10,a[61]),I=d(I,R,P,A,f,15,a[62]),A=d(A,I,R,P,w,21,a[63]),o[0]=o[0]+P|0,o[1]=o[1]+A|0,o[2]=o[2]+I|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;r[n>>>5]|=128<<24-n%32;var o=e.floor(i/4294967296),s=i;r[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,n,o,s){var a=e+(t&r|~t&i)+n+s;return(a<<o|a>>>32-o)+t}function l(e,t,r,i,n,o,s){var a=e+(t&i|r&~i)+n+s;return(a<<o|a>>>32-o)+t}function h(e,t,r,i,n,o,s){var a=e+(t^r^i)+n+s;return(a<<o|a>>>32-o)+t}function d(e,t,r,i,n,o,s){var a=e+(r^(t|~i))+n+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),i.MD5)},3459:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.mode.CFB=function(){var e=i.lib.BlockCipherMode.extend();function t(e,t,r,i){var n,o=this._iv;o?(n=o.slice(0),this._iv=void 0):n=this._prevBlock,i.encryptBlock(n,0);for(var s=0;s<r;s++)e[t+s]^=n[s]}return e.Encryptor=e.extend({processBlock:function(e,r){var i=this._cipher,n=i.blockSize;t.call(this,e,r,n,i),this._prevBlock=e.slice(r,r+n)}}),e.Decryptor=e.extend({processBlock:function(e,r){var i=this._cipher,n=i.blockSize,o=e.slice(r,r+n);t.call(this,e,r,n,i),this._prevBlock=o}}),e}(),i.mode.CFB)},1546:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.mode.CTRGladman=function(){var e=i.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,r=e>>8&255,i=255&e;255===t?(t=0,255===r?(r=0,255===i?i=0:++i):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=i}return e}function r(e){return 0===(e[0]=t(e[0]))&&(e[1]=t(e[1])),e}var n=e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,n=i.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),r(s);var a=s.slice(0);i.encryptBlock(a,0);for(var c=0;c<n;c++)e[t+c]^=a[c]}});return e.Decryptor=n,e}(),i.mode.CTRGladman)},2401:function(e,t,r){var i,n,o;e.exports=(o=r(4011),r(7695),o.mode.CTR=(i=o.lib.BlockCipherMode.extend(),n=i.Encryptor=i.extend({processBlock:function(e,t){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);r.encryptBlock(s,0),o[i-1]=o[i-1]+1|0;for(var a=0;a<i;a++)e[t+a]^=s[a]}}),i.Decryptor=n,i),o.mode.CTR)},2332:function(e,t,r){var i,n;e.exports=(n=r(4011),r(7695),n.mode.ECB=((i=n.lib.BlockCipherMode.extend()).Encryptor=i.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),i.Decryptor=i.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),i),n.mode.ECB)},1063:function(e,t,r){var i,n,o;e.exports=(o=r(4011),r(7695),o.mode.OFB=(i=o.lib.BlockCipherMode.extend(),n=i.Encryptor=i.extend({processBlock:function(e,t){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),r.encryptBlock(o,0);for(var s=0;s<i;s++)e[t+s]^=o[s]}}),i.Decryptor=n,i),o.mode.OFB)},9283:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,i=4*t,n=i-r%i,o=r+n-1;e.clamp(),e.words[o>>>2]|=n<<24-o%4*8,e.sigBytes+=n},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Ansix923)},6939:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.pad.Iso10126={pad:function(e,t){var r=4*t,n=r-e.sigBytes%r;e.concat(i.lib.WordArray.random(n-1)).concat(i.lib.WordArray.create([n<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.pad.Iso10126)},6828:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.pad.Iso97971={pad:function(e,t){e.concat(i.lib.WordArray.create([2147483648],1)),i.pad.ZeroPadding.pad(e,t)},unpad:function(e){i.pad.ZeroPadding.unpad(e),e.sigBytes--}},i.pad.Iso97971)},378:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.pad.NoPadding={pad:function(){},unpad:function(){}},i.pad.NoPadding)},8989:function(e,t,r){var i;e.exports=(i=r(4011),r(7695),i.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){var t=e.words,r=e.sigBytes-1;for(r=e.sigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.sigBytes=r+1;break}}},i.pad.ZeroPadding)},6173:function(e,t,r){var i,n,o,s,a,c,u,l,h;e.exports=(h=r(4011),r(3519),r(4031),n=(i=h).lib,o=n.Base,s=n.WordArray,a=i.algo,c=a.SHA256,u=a.HMAC,l=a.PBKDF2=o.extend({cfg:o.extend({keySize:4,hasher:c,iterations:25e4}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,i=u.create(r.hasher,e),n=s.create(),o=s.create([1]),a=n.words,c=o.words,l=r.keySize,h=r.iterations;a.length<l;){var d=i.update(t).finalize(o);i.reset();for(var f=d.words,p=f.length,g=d,m=1;m<h;m++){g=i.finalize(g),i.reset();for(var v=g.words,y=0;y<p;y++)f[y]^=v[y]}n.concat(d),c[0]++}return n.sigBytes=4*l,n}}),i.PBKDF2=function(e,t,r){return l.create(r).compute(e,t)},h.PBKDF2)},2210:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=u>>>16|4294901760&l,d=l<<16|65535&u;for(i[0]^=u,i[1]^=h,i[2]^=l,i[3]^=d,i[4]^=u,i[5]^=h,i[6]^=l,i[7]^=d,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)o[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,r=0;r<8;r++){var i=e[r]+t[r],n=65535&i,a=i>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,u=((4294901760&i)*i|0)+((65535&i)*i|0);s[r]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.RabbitLegacy=t._createHelper(a)}(),i.RabbitLegacy)},7928:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=[],o=[],s=[],a=r.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var i=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)c.call(this);for(r=0;r<8;r++)n[r]^=i[r+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=u>>>16|4294901760&l,d=l<<16|65535&u;for(n[0]^=u,n[1]^=h,n[2]^=l,n[3]^=d,n[4]^=u,n[5]^=h,n[6]^=l,n[7]^=d,r=0;r<4;r++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)o[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,r=0;r<8;r++){var i=e[r]+t[r],n=65535&i,a=i>>>16,c=((n*n>>>17)+n*a>>>15)+a*a,u=((4294901760&i)*i|0)+((65535&i)*i|0);s[r]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}e.Rabbit=t._createHelper(a)}(),i.Rabbit)},4967:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib.StreamCipher,r=e.algo,n=r.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,i=this._S=[],n=0;n<256;n++)i[n]=n;n=0;for(var o=0;n<256;n++){var s=n%r,a=t[s>>>2]>>>24-s%4*8&255;o=(o+i[n]+a)%256;var c=i[n];i[n]=i[o],i[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,r=this._j,i=0,n=0;n<4;n++){r=(r+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[r],e[r]=o,i|=e[(e[t]+e[r])%256]<<24-8*n}return this._i=t,this._j=r,i}e.RC4=t._createHelper(n);var s=r.RC4Drop=n.extend({cfg:n.cfg.extend({drop:192}),_doReset:function(){n._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});e.RC4Drop=t._createHelper(s)}(),i.RC4)},9718:function(e,t,r){var i;e.exports=(i=r(4011),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),l=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=n.create([0,1518500249,1859775393,2400959708,2840853838]),d=n.create([1352829926,1548603684,1836072691,2053994217,0]),f=s.RIPEMD160=o.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,f,w,S,_,k,E,T,C,P,A=this._hash.words,I=h.words,R=d.words,x=a.words,O=c.words,M=u.words,N=l.words;for(_=o=A[0],k=s=A[1],E=f=A[2],T=w=A[3],C=S=A[4],r=0;r<80;r+=1)P=o+e[t+x[r]]|0,P+=r<16?p(s,f,w)+I[0]:r<32?g(s,f,w)+I[1]:r<48?m(s,f,w)+I[2]:r<64?v(s,f,w)+I[3]:y(s,f,w)+I[4],P=(P=b(P|=0,M[r]))+S|0,o=S,S=w,w=b(f,10),f=s,s=P,P=_+e[t+O[r]]|0,P+=r<16?y(k,E,T)+R[0]:r<32?v(k,E,T)+R[1]:r<48?m(k,E,T)+R[2]:r<64?g(k,E,T)+R[3]:p(k,E,T)+R[4],P=(P=b(P|=0,N[r]))+C|0,_=C,C=T,T=b(E,10),E=k,k=P;P=A[1]+f+T|0,A[1]=A[2]+w+C|0,A[2]=A[3]+S+_|0,A[3]=A[4]+o+k|0,A[4]=A[0]+s+E|0,A[0]=P},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var n=this._hash,o=n.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return n},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function g(e,t,r){return e&t|~e&r}function m(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function y(e,t,r){return e^(t|~r)}function b(e,t){return e<<t|e>>>32-t}t.RIPEMD160=o._createHelper(f),t.HmacRIPEMD160=o._createHmacHelper(f)}(Math),i.RIPEMD160)},4077:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(4011),n=(i=l).lib,o=n.WordArray,s=n.Hasher,a=i.algo,c=[],u=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var h=(i<<5|i>>>27)+a+c[u];h+=u<20?1518500249+(n&o|~n&s):u<40?1859775393+(n^o^s):u<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,a=s,s=o,o=n<<30|n>>>2,n=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(i+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.SHA1=s._createHelper(u),i.HmacSHA1=s._createHmacHelper(u),l.SHA1)},4610:function(e,t,r){var i,n,o,s,a,c;e.exports=(c=r(4011),r(3519),n=(i=c).lib.WordArray,o=i.algo,s=o.SHA256,a=o.SHA224=s.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=4,e}}),i.SHA224=s._createHelper(a),i.HmacSHA224=s._createHmacHelper(a),c.SHA224)},3519:function(e,t,r){var i;e.exports=(i=r(4011),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),i=2;i<=r;i++)if(!(t%i))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var i=2,n=0;n<64;)t(i)&&(n<8&&(a[n]=r(e.pow(i,.5))),c[n]=r(e.pow(i,1/3)),n++),i++}();var u=[],l=s.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,m=u[f-2],v=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[f]=g+u[f-7]+v+u[f-16]}var y=i&n^i&o^n&o,b=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),w=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=s+w|0,s=o,o=n,n=i,i=w+(b+y)|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+d|0},_doFinalize:function(){var t=this._data,r=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=e.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(l),t.HmacSHA256=o._createHmacHelper(l)}(Math),i.SHA256)},7691:function(e,t,r){var i;e.exports=(i=r(4011),r(4978),function(e){var t=i,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.x64.Word,a=t.algo,c=[],u=[],l=[];!function(){for(var e=1,t=0,r=0;r<24;r++){c[e+5*t]=(r+1)*(r+2)/2%64;var i=(2*e+3*t)%5;e=t%5,t=i}for(e=0;e<5;e++)for(t=0;t<5;t++)u[e+5*t]=t+(2*e+3*t)%5*5;for(var n=1,o=0;o<24;o++){for(var a=0,h=0,d=0;d<7;d++){if(1&n){var f=(1<<d)-1;f<32?h^=1<<f:a^=1<<f-32}128&n?n=n<<1^113:n<<=1}l[o]=s.create(a,h)}}();var h=[];!function(){for(var e=0;e<25;e++)h[e]=s.create()}();var d=a.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var r=this._state,i=this.blockSize/2,n=0;n<i;n++){var o=e[t+2*n],s=e[t+2*n+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(A=r[n]).high^=s,A.low^=o}for(var a=0;a<24;a++){for(var d=0;d<5;d++){for(var f=0,p=0,g=0;g<5;g++)f^=(A=r[d+5*g]).high,p^=A.low;var m=h[d];m.high=f,m.low=p}for(d=0;d<5;d++){var v=h[(d+4)%5],y=h[(d+1)%5],b=y.high,w=y.low;for(f=v.high^(b<<1|w>>>31),p=v.low^(w<<1|b>>>31),g=0;g<5;g++)(A=r[d+5*g]).high^=f,A.low^=p}for(var S=1;S<25;S++){var _=(A=r[S]).high,k=A.low,E=c[S];E<32?(f=_<<E|k>>>32-E,p=k<<E|_>>>32-E):(f=k<<E-32|_>>>64-E,p=_<<E-32|k>>>64-E);var T=h[u[S]];T.high=f,T.low=p}var C=h[0],P=r[0];for(C.high=P.high,C.low=P.low,d=0;d<5;d++)for(g=0;g<5;g++){var A=r[S=d+5*g],I=h[S],R=h[(d+1)%5+5*g],x=h[(d+2)%5+5*g];A.high=I.high^~R.high&x.high,A.low=I.low^~R.low&x.low}A=r[0];var O=l[a];A.high^=O.high,A.low^=O.low}},_doFinalize:function(){var t=this._data,r=t.words,i=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[i>>>5]|=1<<24-i%32,r[(e.ceil((i+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],l=0;l<c;l++){var h=s[l],d=h.high,f=h.low;d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),u.push(f),u.push(d)}return new n.init(u,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});t.SHA3=o._createHelper(d),t.HmacSHA3=o._createHmacHelper(d)}(Math),i.SHA3)},5895:function(e,t,r){var i,n,o,s,a,c,u,l;e.exports=(l=r(4011),r(4978),r(9670),n=(i=l).x64,o=n.Word,s=n.WordArray,a=i.algo,c=a.SHA512,u=a.SHA384=c.extend({_doReset:function(){this._hash=new s.init([new o.init(3418070365,3238371032),new o.init(1654270250,914150663),new o.init(2438529370,812702999),new o.init(355462360,4144912697),new o.init(1731405415,4290775857),new o.init(2394180231,1750603025),new o.init(3675008525,1694076839),new o.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),i.SHA384=c._createHelper(u),i.HmacSHA384=c._createHmacHelper(u),l.SHA384)},9670:function(e,t,r){var i;e.exports=(i=r(4011),r(4978),function(){var e=i,t=e.lib.Hasher,r=e.x64,n=r.Word,o=r.WordArray,s=e.algo;function a(){return n.create.apply(n,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var e=0;e<80;e++)u[e]=a()}();var l=s.SHA512=t.extend({_doReset:function(){this._hash=new o.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=i.high,p=i.low,g=n.high,m=n.low,v=o.high,y=o.low,b=s.high,w=s.low,S=a.high,_=a.low,k=l.high,E=l.low,T=h.high,C=h.low,P=d.high,A=d.low,I=f,R=p,x=g,O=m,M=v,N=y,L=b,B=w,D=S,j=_,U=k,F=E,V=T,W=C,q=P,H=A,K=0;K<80;K++){var z,$,G=u[K];if(K<16)$=G.high=0|e[t+2*K],z=G.low=0|e[t+2*K+1];else{var Q=u[K-15],J=Q.high,Y=Q.low,X=(J>>>1|Y<<31)^(J>>>8|Y<<24)^J>>>7,Z=(Y>>>1|J<<31)^(Y>>>8|J<<24)^(Y>>>7|J<<25),ee=u[K-2],te=ee.high,re=ee.low,ie=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ne=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),oe=u[K-7],se=oe.high,ae=oe.low,ce=u[K-16],ue=ce.high,le=ce.low;$=($=($=X+se+((z=Z+ae)>>>0<Z>>>0?1:0))+ie+((z+=ne)>>>0<ne>>>0?1:0))+ue+((z+=le)>>>0<le>>>0?1:0),G.high=$,G.low=z}var he,de=D&U^~D&V,fe=j&F^~j&W,pe=I&x^I&M^x&M,ge=R&O^R&N^O&N,me=(I>>>28|R<<4)^(I<<30|R>>>2)^(I<<25|R>>>7),ve=(R>>>28|I<<4)^(R<<30|I>>>2)^(R<<25|I>>>7),ye=(D>>>14|j<<18)^(D>>>18|j<<14)^(D<<23|j>>>9),be=(j>>>14|D<<18)^(j>>>18|D<<14)^(j<<23|D>>>9),we=c[K],Se=we.high,_e=we.low,ke=q+ye+((he=H+be)>>>0<H>>>0?1:0),Ee=ve+ge;q=V,H=W,V=U,W=F,U=D,F=j,D=L+(ke=(ke=(ke=ke+de+((he+=fe)>>>0<fe>>>0?1:0))+Se+((he+=_e)>>>0<_e>>>0?1:0))+$+((he+=z)>>>0<z>>>0?1:0))+((j=B+he|0)>>>0<B>>>0?1:0)|0,L=M,B=N,M=x,N=O,x=I,O=R,I=ke+(me+pe+(Ee>>>0<ve>>>0?1:0))+((R=he+Ee|0)>>>0<he>>>0?1:0)|0}p=i.low=p+R,i.high=f+I+(p>>>0<R>>>0?1:0),m=n.low=m+O,n.high=g+x+(m>>>0<O>>>0?1:0),y=o.low=y+N,o.high=v+M+(y>>>0<N>>>0?1:0),w=s.low=w+B,s.high=b+L+(w>>>0<B>>>0?1:0),_=a.low=_+j,a.high=S+D+(_>>>0<j>>>0?1:0),E=l.low=E+F,l.high=k+U+(E>>>0<F>>>0?1:0),C=h.low=C+W,h.high=T+V+(C>>>0<W>>>0?1:0),A=d.low=A+H,d.high=P+q+(A>>>0<H>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(i+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),i.SHA512)},1506:function(e,t,r){var i;e.exports=(i=r(4011),r(304),r(6002),r(6296),r(7695),function(){var e=i,t=e.lib,r=t.WordArray,n=t.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=n.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var i=s[r]-1;t[r]=e[i>>>5]>>>31-i%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var u=n[o]=[],l=c[o];for(r=0;r<24;r++)u[r/6|0]|=t[(a[r]-1+l)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(a[r+24]-1+l)%28]<<31-r%6;for(u[0]=u[0]<<1|u[0]>>>31,r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=n[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],d.call(this,4,252645135),d.call(this,16,65535),f.call(this,2,858993459),f.call(this,8,16711935),d.call(this,1,1431655765);for(var i=0;i<16;i++){for(var n=r[i],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^n[c])&l[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,d.call(this,1,1431655765),f.call(this,8,16711935),f.call(this,2,858993459),d.call(this,16,65535),d.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function d(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<<e}function f(e,t){var r=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<<e}e.DES=n._createHelper(h);var p=o.TripleDES=n.extend({_doReset:function(){var e=this._key.words;if(2!==e.length&&4!==e.length&&e.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=e.slice(0,2),i=e.length<4?e.slice(0,2):e.slice(2,4),n=e.length<6?e.slice(0,2):e.slice(4,6);this._des1=h.createEncryptor(r.create(t)),this._des2=h.createEncryptor(r.create(i)),this._des3=h.createEncryptor(r.create(n))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=n._createHelper(p)}(),i.TripleDES)},4978:function(e,t,r){var i;e.exports=(i=r(4011),function(e){var t=i,r=t.lib,n=r.Base,o=r.WordArray,s=t.x64={};s.Word=n.extend({init:function(e,t){this.high=e,this.low=t}}),s.WordArray=n.extend({init:function(t,r){t=this.words=t||[],this.sigBytes=r!=e?r:8*t.length},toX32:function(){for(var e=this.words,t=e.length,r=[],i=0;i<t;i++){var n=e[i];r.push(n.high),r.push(n.low)}return o.create(r,this.sigBytes)},clone:function(){for(var e=n.clone.call(this),t=e.words=this.words.slice(0),r=t.length,i=0;i<r;i++)t[i]=t[i].clone();return e}})}(),i)},497:e=>{var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,n,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(n=c(e))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=l.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function n(o){i.once&&e.removeEventListener(t,n),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)i(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},3836:(e,t,r)=>{e.exports=function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){var r=t[s][1][e];return n(r||e)}),u,u.exports,e,t,r,i)}return r[s].exports}for(var o=void 0,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,i){(function(e){var r,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var o=0,s=new n(l),a=e.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){l(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(l,0)};else{var c=new e.MessageChannel;c.port1.onmessage=l,r=function(){c.port2.postMessage(0)}}var u=[];function l(){var e,t;i=!0;for(var r=u.length;r;){for(t=u,u=[],e=-1;++e<r;)t[e]();r=u.length}i=!1}function h(e){1!==u.push(e)||i||r()}t.exports=h}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){var i=e(1);function n(){}var o={},s=["REJECTED"],a=["FULFILLED"],c=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==n&&f(this,e)}function l(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function h(e,t,r){i((function(){var i;try{i=t(r)}catch(t){return o.reject(e,t)}i===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,i)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function f(e,t){var r=!1;function i(t){r||(r=!0,o.reject(e,t))}function n(t){r||(r=!0,o.resolve(e,t))}function s(){t(n,i)}var a=p(s);"error"===a.status&&i(a.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}function g(e){return e instanceof this?e:o.resolve(new this(n),e)}function m(e){var t=new this(n);return o.reject(t,e)}function v(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,i=!1;if(!r)return this.resolve([]);for(var s=new Array(r),a=0,c=-1,u=new this(n);++c<r;)l(e[c],c);return u;function l(e,n){function c(e){s[n]=e,++a!==r||i||(i=!0,o.resolve(u,s))}t.resolve(e).then(c,(function(e){i||(i=!0,o.reject(u,e))}))}}function y(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,i=!1;if(!r)return this.resolve([]);for(var s=-1,a=new this(n);++s<r;)c(e[s]);return a;function c(e){t.resolve(e).then((function(e){i||(i=!0,o.resolve(a,e))}),(function(e){i||(i=!0,o.reject(a,e))}))}}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(n);return this.state!==c?h(r,this.state===a?e:t,this.outcome):this.queue.push(new l(r,e,t)),r},l.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},l.prototype.otherCallFulfilled=function(e){h(this.promise,this.onFulfilled,e)},l.prototype.callRejected=function(e){o.reject(this.promise,e)},l.prototype.otherCallRejected=function(e){h(this.promise,this.onRejected,e)},o.resolve=function(e,t){var r=p(d,t);if("error"===r.status)return o.reject(e,r.value);var i=r.value;if(i)f(e,i);else{e.state=a,e.outcome=t;for(var n=-1,s=e.queue.length;++n<s;)e.queue[n].callFulfilled(t)}return e},o.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,i=e.queue.length;++r<i;)e.queue[r].callRejected(t);return e},u.resolve=g,u.reject=m,u.all=v,u.race=y},{1:1}],3:[function(e,t,i){(function(t){"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,r){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var s=o();function a(){try{if(!s||!s.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function c(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if("TypeError"!==n.name)throw n;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),i=0;i<e.length;i+=1)r.append(e[i]);return r.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var u=Promise;function l(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function h(e,t,r){"function"==typeof t&&e.then(t),"function"==typeof r&&e.catch(r)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var p="local-forage-detect-blob-support",g=void 0,m={},v=Object.prototype.toString,y="readonly",b="readwrite";function w(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),n=0;n<t;n++)i[n]=e.charCodeAt(n);return r}function S(e){return new u((function(t){var r=e.transaction(p,b),i=c([""]);r.objectStore(p).put(i,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);t(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function _(e){return"boolean"==typeof g?u.resolve(g):S(e).then((function(e){return g=e}))}function k(e){var t=m[e.name],r={};r.promise=new u((function(e,t){r.resolve=e,r.reject=t})),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then((function(){return r.promise})):t.dbReady=r.promise}function E(e){var t=m[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function T(e,t){var r=m[e.name].deferredOperations.pop();if(r)return r.reject(t),r.promise}function C(e,t){return new u((function(r,i){if(m[e.name]=m[e.name]||B(),e.db){if(!t)return r(e.db);k(e),e.db.close()}var n=[e.name];t&&n.push(e.version);var o=s.open.apply(s,n);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(p)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),i(o.error)},o.onsuccess=function(){var t=o.result;t.onversionchange=function(e){e.target.close()},r(t),E(e)}}))}function P(e){return C(e,!1)}function A(e){return C(e,!0)}function I(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,n=e.version>e.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),n||r){if(r){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function R(e){return new u((function(t,r){var i=new FileReader;i.onerror=r,i.onloadend=function(r){var i=btoa(r.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},i.readAsBinaryString(e)}))}function x(e){return c([w(atob(e.data))],{type:e.type})}function O(e){return e&&e.__local_forage_encoded_blob}function M(e){var t=this,r=t._initReady().then((function(){var e=m[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return h(r,e,e),r}function N(e){k(e);for(var t=m[e.name],r=t.forages,i=0;i<r.length;i++){var n=r[i];n._dbInfo.db&&(n._dbInfo.db.close(),n._dbInfo.db=null)}return e.db=null,P(e).then((function(t){return e.db=t,I(e)?A(e):t})).then((function(i){e.db=t.db=i;for(var n=0;n<r.length;n++)r[n]._dbInfo.db=i})).catch((function(t){throw T(e,t),t}))}function L(e,t,r,i){void 0===i&&(i=1);try{var n=e.db.transaction(e.storeName,t);r(null,n)}catch(n){if(i>0&&(!e.db||"InvalidStateError"===n.name||"NotFoundError"===n.name))return u.resolve().then((function(){if(!e.db||"NotFoundError"===n.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),A(e)})).then((function(){return N(e).then((function(){L(e,t,r,i-1)}))})).catch(r);r(n)}}function B(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function D(e){var t=this,r={db:null};if(e)for(var i in e)r[i]=e[i];var n=m[r.name];n||(n=B(),m[r.name]=n),n.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=M);var o=[];function s(){return u.resolve()}for(var a=0;a<n.forages.length;a++){var c=n.forages[a];c!==t&&o.push(c._initReady().catch(s))}var l=n.forages.slice(0);return u.all(o).then((function(){return r.db=n.db,P(r)})).then((function(e){return r.db=e,I(r,t._defaultConfig.version)?A(r):e})).then((function(e){r.db=n.db=e,t._dbInfo=r;for(var i=0;i<l.length;i++){var o=l[i];o!==t&&(o._dbInfo.db=r.db,o._dbInfo.version=r.version)}}))}function j(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){L(r._dbInfo,y,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).get(e);s.onsuccess=function(){var e=s.result;void 0===e&&(e=null),O(e)&&(e=x(e)),t(e)},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function U(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){L(r._dbInfo,y,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).openCursor(),a=1;s.onsuccess=function(){var r=s.result;if(r){var i=r.value;O(i)&&(i=x(i));var n=e(i,r.key,a++);void 0!==n?t(n):r.continue()}else t()},s.onerror=function(){i(s.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function F(e,t,r){var i=this;e=d(e);var n=new u((function(r,n){var o;i.ready().then((function(){return o=i._dbInfo,"[object Blob]"===v.call(t)?_(o.db).then((function(e){return e?t:R(t)})):t})).then((function(t){L(i._dbInfo,b,(function(o,s){if(o)return n(o);try{var a=s.objectStore(i._dbInfo.storeName);null===t&&(t=void 0);var c=a.put(t,e);s.oncomplete=function(){void 0===t&&(t=null),r(t)},s.onabort=s.onerror=function(){var e=c.error?c.error:c.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return l(n,r),n}function V(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){L(r._dbInfo,b,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName).delete(e);o.oncomplete=function(){t()},o.onerror=function(){i(s.error)},o.onabort=function(){var e=s.error?s.error:s.transaction.error;i(e)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function W(e){var t=this,r=new u((function(e,r){t.ready().then((function(){L(t._dbInfo,b,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).clear();n.oncomplete=function(){e()},n.onabort=n.onerror=function(){var e=o.error?o.error:o.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function q(e){var t=this,r=new u((function(e,r){t.ready().then((function(){L(t._dbInfo,y,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).count();o.onsuccess=function(){e(o.result)},o.onerror=function(){r(o.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function H(e,t){var r=this,i=new u((function(t,i){e<0?t(null):r.ready().then((function(){L(r._dbInfo,y,(function(n,o){if(n)return i(n);try{var s=o.objectStore(r._dbInfo.storeName),a=!1,c=s.openKeyCursor();c.onsuccess=function(){var r=c.result;r?0===e||a?t(r.key):(a=!0,r.advance(e)):t(null)},c.onerror=function(){i(c.error)}}catch(e){i(e)}}))})).catch(i)}));return l(i,t),i}function K(e){var t=this,r=new u((function(e,r){t.ready().then((function(){L(t._dbInfo,y,(function(i,n){if(i)return r(i);try{var o=n.objectStore(t._dbInfo.storeName).openKeyCursor(),s=[];o.onsuccess=function(){var t=o.result;t?(s.push(t.key),t.continue()):e(s)},o.onerror=function(){r(o.error)}}catch(e){r(e)}}))})).catch(r)}));return l(r,e),r}function z(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var i,n=this;if(e.name){var o=e.name===r.name&&n._dbInfo.db?u.resolve(n._dbInfo.db):P(e).then((function(t){var r=m[e.name],i=r.forages;r.db=t;for(var n=0;n<i.length;n++)i[n]._dbInfo.db=t;return t}));i=e.storeName?o.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var r=t.version+1;k(e);var i=m[e.name],n=i.forages;t.close();for(var o=0;o<n.length;o++){var a=n[o];a._dbInfo.db=null,a._dbInfo.version=r}var c=new u((function(t,i){var n=s.open(e.name,r);n.onerror=function(e){n.result.close(),i(e)},n.onupgradeneeded=function(){n.result.deleteObjectStore(e.storeName)},n.onsuccess=function(){var e=n.result;e.close(),t(e)}}));return c.then((function(e){i.db=e;for(var t=0;t<n.length;t++){var r=n[t];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(t){throw(T(e,t)||u.resolve()).catch((function(){})),t}))}})):o.then((function(t){k(e);var r=m[e.name],i=r.forages;t.close();for(var n=0;n<i.length;n++)i[n]._dbInfo.db=null;var o=new u((function(t,r){var i=s.deleteDatabase(e.name);i.onerror=function(){var e=i.result;e&&e.close(),r(i.error)},i.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},i.onsuccess=function(){var e=i.result;e&&e.close(),t(e)}}));return o.then((function(e){r.db=e;for(var t=0;t<i.length;t++)E(i[t]._dbInfo)})).catch((function(t){throw(T(e,t)||u.resolve()).catch((function(){})),t}))}))}else i=u.reject("Invalid arguments");return l(i,t),i}var $={_driver:"asyncStorage",_initStorage:D,_support:a(),iterate:U,getItem:j,setItem:F,removeItem:V,clear:W,length:q,key:H,keys:K,dropInstance:z};function G(){return"function"==typeof openDatabase}var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="~~local_forage_type~",Y=/^~~local_forage_type~([^~]+)~/,X="__lfsc__:",Z=X.length,ee="arbf",te="blob",re="si08",ie="ui08",ne="uic8",oe="si16",se="si32",ae="ur16",ce="ui32",ue="fl32",le="fl64",he=Z+ee.length,de=Object.prototype.toString;function fe(e){var t,r,i,n,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var u=new ArrayBuffer(s),l=new Uint8Array(u);for(t=0;t<a;t+=4)r=Q.indexOf(e[t]),i=Q.indexOf(e[t+1]),n=Q.indexOf(e[t+2]),o=Q.indexOf(e[t+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|n>>2,l[c++]=(3&n)<<6|63&o;return u}function pe(e){var t,r=new Uint8Array(e),i="";for(t=0;t<r.length;t+=3)i+=Q[r[t]>>2],i+=Q[(3&r[t])<<4|r[t+1]>>4],i+=Q[(15&r[t+1])<<2|r[t+2]>>6],i+=Q[63&r[t+2]];return r.length%3==2?i=i.substring(0,i.length-1)+"=":r.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}function ge(e,t){var r="";if(e&&(r=de.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var i,n=X;e instanceof ArrayBuffer?(i=e,n+=ee):(i=e.buffer,"[object Int8Array]"===r?n+=re:"[object Uint8Array]"===r?n+=ie:"[object Uint8ClampedArray]"===r?n+=ne:"[object Int16Array]"===r?n+=oe:"[object Uint16Array]"===r?n+=ae:"[object Int32Array]"===r?n+=se:"[object Uint32Array]"===r?n+=ce:"[object Float32Array]"===r?n+=ue:"[object Float64Array]"===r?n+=le:t(new Error("Failed to get type for BinaryArray"))),t(n+pe(i))}else if("[object Blob]"===r){var o=new FileReader;o.onload=function(){var r=J+e.type+"~"+pe(this.result);t(X+te+r)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}}function me(e){if(e.substring(0,Z)!==X)return JSON.parse(e);var t,r=e.substring(he),i=e.substring(Z,he);if(i===te&&Y.test(r)){var n=r.match(Y);t=n[1],r=r.substring(n[0].length)}var o=fe(r);switch(i){case ee:return o;case te:return c([o],{type:t});case re:return new Int8Array(o);case ie:return new Uint8Array(o);case ne:return new Uint8ClampedArray(o);case oe:return new Int16Array(o);case ae:return new Uint16Array(o);case se:return new Int32Array(o);case ce:return new Uint32Array(o);case ue:return new Float32Array(o);case le:return new Float64Array(o);default:throw new Error("Unkown type: "+i)}}var ve={serialize:ge,deserialize:me,stringToBuffer:fe,bufferToString:pe};function ye(e,t,r,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,i)}function be(e){var t=this,r={db:null};if(e)for(var i in e)r[i]="string"!=typeof e[i]?e[i].toString():e[i];var n=new u((function(e,i){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return i(e)}r.db.transaction((function(n){ye(n,r,(function(){t._dbInfo=r,e()}),(function(e,t){i(t)}))}),i)}));return r.serializer=ve,n}function we(e,t,r,i,n,o){e.executeSql(r,i,n,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?o(e,s):ye(e,t,(function(){e.executeSql(r,i,n,o)}),o)}),o):o(e,s)}),o)}function Se(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT * FROM "+n.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var i=r.rows.length?r.rows.item(0).value:null;i&&(i=n.serializer.deserialize(i)),t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function _e(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT * FROM "+n.storeName,[],(function(r,i){for(var o=i.rows,s=o.length,a=0;a<s;a++){var c=o.item(a),u=c.value;if(u&&(u=n.serializer.deserialize(u)),void 0!==(u=e(u,c.key,a+1)))return void t(u)}t()}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function ke(e,t,r,i){var n=this;e=d(e);var o=new u((function(o,s){n.ready().then((function(){void 0===t&&(t=null);var a=t,c=n._dbInfo;c.serializer.serialize(t,(function(t,u){u?s(u):c.db.transaction((function(r){we(r,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){o(a)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void o(ke.apply(n,[e,a,r,i-1]));s(t)}}))}))})).catch(s)}));return l(o,r),o}function Ee(e,t,r){return ke.apply(this,[e,t,r,1])}function Te(e,t){var r=this;e=d(e);var i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"DELETE FROM "+n.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function Ce(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"DELETE FROM "+i.storeName,[],(function(){e()}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function Pe(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT COUNT(key) as c FROM "+i.storeName,[],(function(t,r){var i=r.rows.item(0).c;e(i)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function Ae(e,t){var r=this,i=new u((function(t,i){r.ready().then((function(){var n=r._dbInfo;n.db.transaction((function(r){we(r,n,"SELECT key FROM "+n.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var i=r.rows.length?r.rows.item(0).key:null;t(i)}),(function(e,t){i(t)}))}))})).catch(i)}));return l(i,t),i}function Ie(e){var t=this,r=new u((function(e,r){t.ready().then((function(){var i=t._dbInfo;i.db.transaction((function(t){we(t,i,"SELECT key FROM "+i.storeName,[],(function(t,r){for(var i=[],n=0;n<r.rows.length;n++)i.push(r.rows.item(n).key);e(i)}),(function(e,t){r(t)}))}))})).catch(r)}));return l(r,e),r}function Re(e){return new u((function(t,r){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,i){for(var n=[],o=0;o<i.rows.length;o++)n.push(i.rows.item(o).name);t({db:e,storeNames:n})}),(function(e,t){r(t)}))}),(function(e){r(e)}))}))}function xe(e,t){t=f.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var i,n=this;return l(i=e.name?new u((function(t){var i;i=e.name===r.name?n._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:i,storeNames:[e.storeName]}):t(Re(i))})).then((function(e){return new u((function(t,r){e.db.transaction((function(i){function n(e){return new u((function(t,r){i.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){r(t)}))}))}for(var o=[],s=0,a=e.storeNames.length;s<a;s++)o.push(n(e.storeNames[s]));u.all(o).then((function(){t()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):u.reject("Invalid arguments"),t),i}var Oe={_driver:"webSQLStorage",_initStorage:be,_support:G(),iterate:_e,getItem:Se,setItem:Ee,removeItem:Te,clear:Ce,length:Pe,key:Ae,keys:Ie,dropInstance:xe};function Me(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Ne(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Le(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Be(){return!Le()||localStorage.length>0}function De(e){var t=this,r={};if(e)for(var i in e)r[i]=e[i];return r.keyPrefix=Ne(e,t._defaultConfig),Be()?(t._dbInfo=r,r.serializer=ve,u.resolve()):u.reject()}function je(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var i=localStorage.key(r);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return l(r,e),r}function Ue(e,t){var r=this;e=d(e);var i=r.ready().then((function(){var t=r._dbInfo,i=localStorage.getItem(t.keyPrefix+e);return i&&(i=t.serializer.deserialize(i)),i}));return l(i,t),i}function Fe(e,t){var r=this,i=r.ready().then((function(){for(var t=r._dbInfo,i=t.keyPrefix,n=i.length,o=localStorage.length,s=1,a=0;a<o;a++){var c=localStorage.key(a);if(0===c.indexOf(i)){var u=localStorage.getItem(c);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,c.substring(n),s++)))return u}}}));return l(i,t),i}function Ve(e,t){var r=this,i=r.ready().then((function(){var t,i=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return l(i,t),i}function We(e){var t=this,r=t.ready().then((function(){for(var e=t._dbInfo,r=localStorage.length,i=[],n=0;n<r;n++){var o=localStorage.key(n);0===o.indexOf(e.keyPrefix)&&i.push(o.substring(e.keyPrefix.length))}return i}));return l(r,e),r}function qe(e){var t=this.keys().then((function(e){return e.length}));return l(t,e),t}function He(e,t){var r=this;e=d(e);var i=r.ready().then((function(){var t=r._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return l(i,t),i}function Ke(e,t,r){var i=this;e=d(e);var n=i.ready().then((function(){void 0===t&&(t=null);var r=t;return new u((function(n,o){var s=i._dbInfo;s.serializer.serialize(t,(function(t,i){if(i)o(i);else try{localStorage.setItem(s.keyPrefix+e,t),n(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||o(e),o(e)}}))}))}));return l(n,r),n}function ze(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var i,n=this;return i=e.name?new u((function(t){e.storeName?t(Ne(e,n._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}})):u.reject("Invalid arguments"),l(i,t),i}var $e={_driver:"localStorageWrapper",_initStorage:De,_support:Me(),iterate:Fe,getItem:Ue,setItem:Ke,removeItem:He,clear:je,length:qe,key:Ve,keys:We,dropInstance:ze},Ge=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Qe=function(e,t){for(var r=e.length,i=0;i<r;){if(Ge(e[i],t))return!0;i++}return!1},Je=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ye={},Xe={},Ze={INDEXEDDB:$,WEBSQL:Oe,LOCALSTORAGE:$e},et=[Ze.INDEXEDDB._driver,Ze.WEBSQL._driver,Ze.LOCALSTORAGE._driver],tt=["dropInstance"],rt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(tt),it={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function nt(e,t){e[t]=function(){var r=arguments;return e.ready().then((function(){return e[t].apply(e,r)}))}}function ot(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Je(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var st=function(){function e(t){for(var r in n(this,e),Ze)if(Ze.hasOwnProperty(r)){var i=Ze[r],o=i._driver;this[r]=o,Ye[o]||this.defineDriver(i)}this._defaultConfig=ot({},it),this._config=ot({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":i(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,r){var i=new u((function(t,r){try{var i=e._driver,n=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(n);for(var o=rt.concat("_initStorage"),s=0,a=o.length;s<a;s++){var c=o[s];if((!Qe(tt,c)||e[c])&&"function"!=typeof e[c])return void r(n)}var h=function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),r=u.reject(t);return l(r,arguments[arguments.length-1]),r}},r=0,i=tt.length;r<i;r++){var n=tt[r];e[n]||(e[n]=t(n))}};h();var d=function(r){Ye[i]&&console.info("Redefining LocalForage driver: "+i),Ye[i]=e,Xe[i]=r,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,r):d(!!e._support):d(!0)}catch(e){r(e)}}));return h(i,t,r),i},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,r){var i=Ye[e]?u.resolve(Ye[e]):u.reject(new Error("Driver not found."));return h(i,t,r),i},e.prototype.getSerializer=function(e){var t=u.resolve(ve);return h(t,e),t},e.prototype.ready=function(e){var t=this,r=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return h(r,e,e),r},e.prototype.setDriver=function(e,t,r){var i=this;Je(e)||(e=[e]);var n=this._getSupportedDrivers(e);function o(){i._config.driver=i.driver()}function s(e){return i._extend(e),o(),i._ready=i._initStorage(i._config),i._ready}function a(e){return function(){var t=0;function r(){for(;t<e.length;){var n=e[t];return t++,i._dbInfo=null,i._ready=null,i.getDriver(n).then(s).catch(r)}o();var a=new Error("No available storage method found.");return i._driverSet=u.reject(a),i._driverSet}return r()}}var c=null!==this._driverSet?this._driverSet.catch((function(){return u.resolve()})):u.resolve();return this._driverSet=c.then((function(){var e=n[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then((function(e){i._driver=e._driver,o(),i._wrapLibraryMethodsWithReady(),i._initDriver=a(n)}))})).catch((function(){o();var e=new Error("No available storage method found.");return i._driverSet=u.reject(e),i._driverSet})),h(this._driverSet,t,r),this._driverSet},e.prototype.supports=function(e){return!!Xe[e]},e.prototype._extend=function(e){ot(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],r=0,i=e.length;r<i;r++){var n=e[r];this.supports(n)&&t.push(n)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=rt.length;e<t;e++)nt(this,rt[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),at=new st;t.exports=at},{3:3}]},{},[4])(4)},6596:e=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},7629:(e,t,r)=>{var i=r(2450),n=r(7194);r(6596),t.M9=n,t.qg=i.parse,i.parseParams,i.parseFmtpConfig,i.parsePayloads,i.parseRemoteCandidates,i.parseImageAttributes,i.parseSimulcastStreamList},2450:(e,t,r)=>{var i=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,r){var n=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:n&&!t[e.name]&&(t[e.name]={});var o=e.push?{}:n?t[e.name]:t;!function(e,t,r,n){if(n&&!r)t[n]=i(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(t[r[o]]=i(e[o+1]))}(r.match(e.reg),o,e.names,e.name),e.push&&t[e.push].push(o)},o=r(6596),s=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},r=[],i=t;return e.split(/(\r\n|\r|\n)/).filter(s).forEach((function(e){var t=e[0],s=e.slice(2);"m"===t&&(r.push({rtp:[],fmtp:[]}),i=r[r.length-1]);for(var a=0;a<(o[t]||[]).length;a+=1){var c=o[t][a];if(c.reg.test(s))return n(c,i,s)}})),t.media=r,t};var a=function(e,t){var r=t.split(/=(.+)/,2);return 2===r.length?e[r[0]]=i(r[1]):1===r.length&&t.length>1&&(e[r[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],r=e.split(" ").map(i),n=0;n<r.length;n+=3)t.push({component:r[n],ip:r[n+1],port:r[n+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,r=!1;return"~"!==e[0]?t=i(e):(t=i(e.substring(1,e.length)),r=!0),{scid:t,paused:r}}))}))}},7194:(e,t,r)=>{var i=r(6596),n=/%[sdv%]/g,o=function(e){var t=1,r=arguments,i=r.length;return e.replace(n,(function(e){if(t>=i)return e;var n=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(n);case"%d":return Number(n);case"%v":return""}}))},s=function(e,t,r){var i=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var s=t.names[n];t.name?i.push(r[t.name][s]):i.push(r[t.names[n]])}else i.push(r[t.name]);return o.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,n=t.innerOrder||c,o=[];return r.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(s(t,r,e))}))}))})),e.media.forEach((function(e){o.push(s("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(s(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(s(t,r,e))}))}))}))})),o.join("\r\n")+"\r\n"}},5653:()=>{},8535:()=>{},4444:()=>{},9546:()=>{},2472:()=>{},477:()=>{},5995:()=>{},6351:e=>{e.exports={version:"0.7.1"}}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var i={};function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(i,{He:()=>xr,L0:()=>Q,Yk:()=>Vi,c3:()=>ji,Mz:()=>Mr,Ne:()=>z,_N:()=>Br,bq:()=>J,hj:()=>s,O4:()=>M,h4:()=>u,xk:()=>c,J:()=>Pi,a7:()=>Oi,tg:()=>Ji,s_:()=>Ri,VO:()=>Ii,VF:()=>Mi,M0:()=>xi,$b:()=>ge,WI:()=>pe,cp:()=>Ui,PN:()=>_i,ez:()=>ei,EQ:()=>Zr,$t:()=>ii,jL:()=>sn,Ps:()=>qi,VV:()=>Wi,Fp:()=>N,_b:()=>K,dT:()=>gr,CM:()=>$,Zq:()=>Jr});class o{}n(o,"CHANNEL_UPDATE","channel_update"),n(o,"JOIN_SUCCEED","join_succeed"),n(o,"ME_UPDATE","me_update"),n(o,"RECONNECTING","reconnecting"),n(o,"RECONNECTED","reconnected"),n(o,"DISCONNECTED","disconnected"),n(o,"USER_JOIN","user_join"),n(o,"USER_UPDATE","user_update"),n(o,"USER_LEAVE","user_leave"),n(o,"USER_TRACK_ADD","user_track_add"),n(o,"USER_TRACK_UPDATE","user_track_update"),n(o,"USER_TRACK_REMOVE","user_track_remove"),n(o,"CUSTOM_MSG","custom_msg"),n(o,"TRACK_MUTED","track_muted"),n(o,"TRACK_UNMUTED","track_unmuted"),n(o,"TRACK_ENDED","track_ended");let s=function(e){return e[e.Error=-1]="Error",e[e.Self=1]="Self",e[e.Kicked=2]="Kicked",e[e.Replace=3]="Replace",e[e.Timeout=4]="Timeout",e[e.Destroy=5]="Destroy",e}({});class a{}n(a,"INFO_UPDATE","info_update"),n(a,"MUTED","muted"),n(a,"UNMUTED","unmuted"),n(a,"ENDED","ended");class c{}n(c,"ENABLE_SUCCEED","enable_succeed"),n(c,"RECONNECTING","reconnecting"),n(c,"RECONNECTED","reconnected"),n(c,"DISCONNECTED","disconnected"),n(c,"IM_MSG","im_msg");let u=function(e){return e[e.Error=-1]="Error",e[e.Self=1]="Self",e[e.Kicked=2]="Kicked",e[e.Timeout=4]="Timeout",e}({});var l=r(497),h=r.n(l),d=r(4422),f=r(6077),p=r.n(f);function g(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(){return"undefined"!=typeof uni&&"mp-weixin"===uni.getSystemInfoSync().uniPlatform||"undefined"==typeof uni&&"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfo}function v(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function y(e){return Object.keys(e).filter((t=>null!==e[t]&&void 0!==e[t])).reduce(((t,r)=>({...t,[r]:e[r]})),{})}function b(e){return"string"==typeof e}function w(){}class S{constructor(){g(this,"m_lastPromise",Promise.resolve())}async lock(){let e=w;if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return e;const t=this.m_lastPromise;return this.m_lastPromise=new Promise((t=>e=t)),await t,e}}async function _(e){return new Promise((t=>{setTimeout(t,e)}))}function k(e,t){let r=!1;t={maxRetries:10,initialDelay:500,...t};let i=()=>new Promise(((i,n)=>{let o=0,s=async a=>{if(r)n("canceled");else try{if(o>0){var c;if(null!==(c=t)&&void 0!==c&&c.onRetry&&!1===t.onRetry(o,a))return void n(a);let e=Math.pow(2,o-1)*t.initialDelay;await _(e)}let r=await e();i(r)}catch(e){t.maxRetries>0&&o>=t.maxRetries?n("maxretry"):(o++,s(e))}};s()}));return i.cancel=()=>{r=!0},i}function E(e,t,r){let i=[];var n;return(n=t,Object.getOwnPropertyNames(n)).forEach((n=>{let o=!0;v(e[n])?JSON.stringify(e[n])!==JSON.stringify(t[n])&&(o=!1):e[n]!==t[n]&&(o=!1),o||(i.push({prop:n,value:t[n],old:e[n]}),r&&r[n]?r[n](t[n],e[n]):e[n]=t[n])})),i}function T(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;for(var r="",i=t.getMonth(),n=i+1,o=t.getDay(),s=t.getDate(),a=t.getFullYear(),c=t.getHours(),u=t.getMinutes(),l=t.getSeconds(),h=0,d=e.length;h<d;h++)switch(e[h]){case"j":r+=s;break;case"d":r+=s<10?"0"+s:s;break;case"l":var f=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");r+=f[o];break;case"w":r+=o;break;case"D":r+=(f=Array("Sun","Mon","Tue","Wed","Thr","Fri","Sat"))[o];break;case"m":r+=n<10?"0"+n:n;break;case"n":r+=n;break;case"F":var p=Array("January","February","March","April","May","June","July","August","September","October","November","December");r+=p[i];break;case"M":r+=(p=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"))[i];break;case"Y":r+=a;break;case"y":r+=a.toString().slice(-2);break;case"H":r+=c<10?"0"+c:c;break;case"g":var g=0===c?12:c;r+=g>12?g-12:g;break;case"h":r+=(g=(g=0===c?12:c)>12?g-12:g)<10?"0"+g:g;break;case"a":r+=c<12?"am":"pm";break;case"i":r+=u<10?"0"+u:u;break;case"s":r+=l<10?"0"+l:l;break;case"c":r+=t.toISOString();break;default:r+=e[h]}return r}function C(e,t){if(t<0)throw new Error("Decimal places must be a non-negative integer");const r=Math.pow(10,t);return Math.round(e*r)/r}function P(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:18;e=e||32;let t="ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz1234567890",r="";for(let i=0;i<e;i++)r+=t.charAt(Math.floor(61*Math.random()));return r}function A(e){const t=e.match(/^(?:.+?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im);return t&&t[1]?t[1]:""}function I(e){return JSON.parse(p().decrypt(e,d.enc.Utf8.parse("6o30j79YRE39bEwI"),{iv:d.enc.Utf8.parse("2apW3WiFl72ZVS3x"),padding:d.pad.Pkcs7,mode:d.mode.CBC}).toString(d.enc.Utf8))}function R(e){return e<=0?-60:Math.max(-60,Math.round(20*Math.log10(e)))}function x(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const O=1e5;let M=function(e){return e[e.Unknown=0]="Unknown",e[e.NotInChannel=1]="NotInChannel",e[e.TokenExpired=2]="TokenExpired",e[e.TrackNotFound=3]="TrackNotFound",e[e.TokenInvalid=4]="TokenInvalid",e[e.AlreadyJoined=5]="AlreadyJoined",e[e.ConnectionFailed=6]="ConnectionFailed",e[e.ConnectionTimeout=7]="ConnectionTimeout",e[e.SignalingConnectFailed=9]="SignalingConnectFailed",e[e.SignalingSubscribeFailed=10]="SignalingSubscribeFailed",e[e.MessageDecodeFailed=11]="MessageDecodeFailed",e[e.SdpNegotiationFailed=13]="SdpNegotiationFailed",e[e.TransportNotReady=14]="TransportNotReady",e[e.PeerConnectionFailed=15]="PeerConnectionFailed",e[e.CaptureFailed=18]="CaptureFailed",e[e.CodecNotSupported=19]="CodecNotSupported",e[e.MaxPublishLimitReached=20]="MaxPublishLimitReached",e[e.DeviceNotFound=21]="DeviceNotFound",e[e.EngineNotSupported=22]="EngineNotSupported",e[e.InvalidState=24]="InvalidState",e[e.InternalError=25]="InternalError",e[e.Cancelled=26]="Cancelled",e[e.InvalidArgument=31]="InvalidArgument",e[e.FeatureNotSupported=32]="FeatureNotSupported",e[e.TrackNotCaptured=33]="TrackNotCaptured",e[e.MaxSubscribeLimitReached=34]="MaxSubscribeLimitReached",e[e.PublishDescConflict=35]="PublishDescConflict",e[e.PlayFailed=36]="PlayFailed",e[e.PlayViewNotFound=37]="PlayViewNotFound",e[e.PopupBlocked=38]="PopupBlocked",e[e.ScreenShareDenied=39]="ScreenShareDenied",e[e.UserNotFound=204]="UserNotFound",e[e.CameraPermissionDenied=231]="CameraPermissionDenied",e[e.MicPermissionDenied=251]="MicPermissionDenied",e[e.PublishFailed=300]="PublishFailed",e[e.SubscribeFailed=301]="SubscribeFailed",e[e.PublishTimeout=302]="PublishTimeout",e[e.SubscribeTimeout=303]="SubscribeTimeout",e}({});class N extends Error{prefixCode(){return m()?"107":"106"}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.Unknown;super(e),x(this,"code",void 0),x(this,"msg",void 0),x(this,"cause",void 0),Object.setPrototypeOf(this,new.target.prototype),this.name="SdkError",this.msg=e,this.code=t<1e3?Number(this.prefixCode()+String(t).padStart(3,"0")):t}get baseCode(){const e=String(this.code);return this.code>=O&&6===e.length&&e.startsWith(this.prefixCode())?this.code%1e3:this.code}static fromError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:M.Unknown;return new this(e.name+":"+e.message,t)}static fromCaptureError(e,t){var r;if(e instanceof N)return e;const i=null!==(r=null==e?void 0:e.name)&&void 0!==r?r:"",n=(null==e?void 0:e.message)||String(e);let o;switch(i){case"NotAllowedError":case"SecurityError":o="screen"===t?M.ScreenShareDenied:"camera"===t?M.CameraPermissionDenied:M.MicPermissionDenied;break;case"NotFoundError":case"OverconstrainedError":o=M.DeviceNotFound;break;default:o=M.CaptureFailed}const s=new this(n,o);return i&&(s.name=i),s.cause=e,s}toString(){return`${this.code}: ${this.msg}`}toJSON(){return{code:this.code,msg:this.msg}}}const L=()=>new N("Not in channel",M.NotInChannel),B=()=>new N("Token has expired",M.TokenExpired),D=function(e){return new N(e||"Track not found",M.TrackNotFound)};function j(e){return e instanceof N&&e.code>=1e3&&e.code<O}const U=new Set([1033,1034,1035]);function F(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const V="__amixer__",W="__amcu__",q="__mcu__",H="__mcu__";let K=function(e){return e.Video="video",e.Audio="audio",e}({}),z=function(e){return e[e.H264=27]="H264",e[e.H265=36]="H265",e[e.AAC=15]="AAC",e[e.VP8=56]="VP8",e[e.VP9=57]="VP9",e[e.AV1=58]="AV1",e[e.OPUS=1398100047]="OPUS",e}({});function $(e){for(const[t,r]of Object.entries(z))if(r===e)return t;return""}class G{constructor(e){F(this,"publishers",new Set),F(this,"defaultPublishOptions",void 0),this.track=e}retain(e){this.publishers.add(e)}release(e){this.publishers.delete(e)}get count(){return this.publishers.size}soleRecord(){if(1===this.publishers.size)return this.publishers.values().next().value.getPublishRecord(this.track)}resolveInfo(){if(this.publishers.size>1)throw new N(`Track is published to ${this.publishers.size} channels with different descs; use channel.getPublishInfo(track) instead`,M.InvalidState);let e=this.soleRecord();if(!e)return;let t={...e.info};return t.props={...t.props},t}}class Q extends(h()){constructor(e,t){super(),F(this,"info",void 0),F(this,"uid",void 0),F(this,"prevStats",void 0),this.info=e,this.uid=t}getRawInfo(){let e={...this.info};return e.props={...e.props},e}get id(){return this.info.id}get kind(){return this.info.kind}get desc(){return this.info.desc}get variant(){return this.info.variant}get angle(){return this.info.angle}getInfo(){return this.getRawInfo()}updateInfo(e){let t=E(this.info,e);return t.length>0&&this.emit(a.INFO_UPDATE,this),t}getUid(){return this.uid}strPrefix(){return"Track"}toString(){const e=[this.uid?`uid:${this.uid}`:null,this.info.desc?`desc:${this.info.desc}`:null,this.id?`id:${this.info.id}`:null].filter(Boolean);return this.strPrefix()+"["+e.join("; ")+"]"}}let J=function(e){return e[e.Unknown=0]="Unknown",e[e.Windows=1]="Windows",e[e.Android=2]="Android",e[e.IOS=3]="IOS",e[e.Linux=4]="Linux",e[e.MacOS=5]="MacOS",e[e.WebRTC=6]="WebRTC",e[e.XCX=7]="XCX",e}({});const Y={zh:{message:"浏览器阻止了自动播放,点击「确定」恢复播放",confirm:"确定"},en:{message:"Playback was blocked by the browser. Click OK to resume.",confirm:"OK"}},X="zh";let Z,ee;function te(e){if("string"!=typeof e)return;return e.trim().replace(/_/g,"-")||void 0}function re(){var e,t;return null!==(e=null!==(t=Z)&&void 0!==t?t:function(){try{if(m())return"undefined"!=typeof wx&&"function"==typeof wx.getAppBaseInfo?te(wx.getAppBaseInfo().language):void 0;if("undefined"!=typeof navigator)return te(navigator.language)}catch(e){}}())&&void 0!==e?e:X}function ie(){var e,t;const r=Y[re().toLowerCase().startsWith("zh")?"zh":"en"];return{message:(null===(e=ee)||void 0===e?void 0:e.message)||r.message,confirm:(null===(t=ee)||void 0===t?void 0:t.confirm)||r.confirm}}var ne=r(3836),oe=r.n(ne);let se={keyPrefix:"",_driver:"localForageWxDriver",_initStorage:function(e){this.keyPrefix=e.name+"/"+e.storeName+"/"},_support:!!m(),getItem:function(e,t){return new Promise(((t,r)=>{try{t(wx.getStorageSync(this.keyPrefix+e))}catch(e){r(e)}}))},setItem:function(e,t,r){return new Promise(((r,i)=>{try{wx.setStorageSync(this.keyPrefix+e,t),r(t)}catch(e){i(e)}}))},removeItem:function(e,t){return new Promise(((t,r)=>{try{wx.removeStorageSync(this.keyPrefix+e),t()}catch(e){r(e)}}))},clear:async function(e){const t=(await this.keys()).map((e=>this.removeItem(e)));await Promise.all(t)},length:async function(e){return(await this.keys()).length},key:async function(e,t){return(await this.keys())[e]},keys:function(e){return new Promise(((e,t)=>{try{var r=this.keyPrefix.length;const t=wx.getStorageInfoSync();let n=[];for(let e=0;e<t.keys.length;e++){var i=t.keys[e];i.startsWith(this.keyPrefix)&&n.push(i.substring(r))}e(n)}catch(e){t(e)}}))},iterate:async function(e,t){const r=await this.keys();let i=1;for(var n=0;n<r.length;n++){const t=r[n];let o=e(await this.getItem(t),t,i++);if(void 0!==o)return o}},dropInstance:function(e,t){return this.clear()}};function ae(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let ce=function(e){return e[e.Undefined=0]="Undefined",e[e.Trace=1]="Trace",e[e.Debug=5]="Debug",e[e.Info=9]="Info",e[e.Warn=13]="Warn",e[e.Error=17]="Error",e[e.FATAL=21]="FATAL",e}({}),ue=function(e){return e.AppStart="app.start",e.AppResource="app.resource",e.AppNetwork="app.network",e.RtcEvtAudioInput="rtc.event.audioinput",e.RtcEvtAudioOutput="rtc.event.audiooutput",e.RtcEvtVideoInput="rtc.event.videoinput",e.RtcEvtVideoOutput="rtc.event.videooutput",e.RtcEvtRemoteStream="rtc.event.remotestream",e.RtcEvtConnection="rtc.event.connection",e.RtcMqtt="rtc.mqtt",e.RtcRequest="rtc.request",e.RtcOok="rtc.ook",e.RtcMarker="rtc.marker",e.RtcLog="rtc.log",e.AppLog="app.log",e}({});var le=function(e){return e[e.Log=0]="Log",e[e.Metric=1]="Metric",e}(le||{});class he{constructor(e,t,r,i){if(ae(this,"enabled",void 0),ae(this,"token",void 0),ae(this,"deviceID",void 0),ae(this,"deviceType",void 0),ae(this,"api",void 0),ae(this,"storage",void 0),ae(this,"workTimer",void 0),ae(this,"isWorking",!1),ae(this,"keyIdx",0),ae(this,"startTime",Date.now()),this.enabled=i,this.token=e,this.deviceID=t,this.deviceType=r,this.api=new de(e.app_id,e.log_center,t,r,"vaZ7MQ45m0KRjJ2u"),!i)return;r==J.XCX&&oe().defineDriver(se);let n=e.app_id+":"+e.uid+":"+("channel"in e?e.channel:"im");r==J.XCX?this.storage=oe().createInstance({name:"rtcsdk",storeName:n,driver:se._driver}):this.storage=oe().createInstance({name:"rtcsdk",storeName:n}),this.storage.ready().then((()=>{console.debug("localforage initialized",this.storage.driver()),this.work()})).catch((e=>{console.debug("localforage initialize error",e),this.storage=void 0})),this.workTimer=setInterval((()=>{this.work()}),6e4)}flush(){this.work()}shutdown(){clearInterval(this.workTimer)}async work(){if(this.enabled&&!this.isWorking){this.isWorking=!0;try{await this.upload()}catch(e){console.error("rtc日志上传报错",e)}finally{this.isWorking=!1}}}makeKey(e){let t=[e==le.Log?"log":"metric",this.startTime,this.keyIdx].join("_");return this.keyIdx++,t}async appendToStorage(e,t){if(!this.storage)return;let r=this.makeKey(e);await this.storage.setItem(r,t);let i=await this.storage.keys();if(i.length>=5e3){i.sort(((e,t)=>{let r=parseFloat(e.split("_").slice(1).join(".")),i=parseFloat(t.split("_").slice(1).join("."));return r<i?-1:r>i?1:0}));const e=i.slice(0,1e3).map((e=>this.storage.removeItem(e)));await Promise.all(e)}}async peekFromStorage(){if(!this.storage)return[];let e=await this.storage.keys();e.sort(((e,t)=>{let r=parseFloat(e.split("_").slice(1).join(".")),i=parseFloat(t.split("_").slice(1).join("."));return r<i?-1:r>i?1:0})),console.debug("rtclog storage count="+e.length);let t=[];for(let r=0;r<e.length;r++){let i=e[r],n={type:le.Log,key:i,content:void 0};if(i.startsWith("log_"))n.type=le.Log;else{if(!i.startsWith("metric_"))continue;n.type=le.Metric}if(n.content=await this.storage.getItem(i),n.content&&n.content.body&&Array.isArray(n.content.body)&&(n.content.body=JSON.stringify(n.content.body)),t.push(n),t.length>=500)break}return t}async removeStorage(e){if(!this.storage)return;const t=e.map((e=>this.storage.removeItem(e.key)));await Promise.all(t)}async upload(){let e=await this.peekFromStorage();if(0==e.length)return;let t={device_id:this.deviceID,device_type:this.deviceType,app_id:this.token.app_id,uid:this.token.uid,logs:[],metrics:[]};for(let r=0;r<e.length;r++){let i=e[r];i.type==le.Log?t.logs.push(i.content):i.type==le.Metric&&t.metrics.push(i.content)}await this.api.push(t),await this.removeStorage(e)}async addLog(e){let{body:t,level:r=ce.Undefined,type:i=ue.AppLog}=e;if(!this.enabled)return;let n={time:Date.now(),type:i,serverity:r,channel:"channel"in this.token?this.token.channel:void 0,attr:v(t)?JSON.parse(JSON.stringify(t)):{},body:v(t)?"":b(t)?t:JSON.stringify(t)};return await this.appendToStorage(le.Log,n)}async addMetric(e){if(this.enabled)return e.time=Date.now(),e.channel="channel"in this.token?this.token.channel:void 0,await this.appendToStorage(le.Metric,JSON.parse(JSON.stringify(e)))}}class de{constructor(e,t,r,i,n){ae(this,"appID",void 0),ae(this,"serverPrefix",void 0),ae(this,"deviceID",void 0),ae(this,"deviceType",void 0),ae(this,"logSecretKey",void 0),ae(this,"logToken",void 0),this.appID=e,"/"!==t.substring(t.length-1)&&(t+="/"),t+="v1/",this.serverPrefix=t,this.deviceID=r,this.deviceType=i,this.logSecretKey=n}async refreshToken(){let e={app_id:this.appID,device_id:this.deviceID,device_type:this.deviceType,requested_at:Date.now()};e.sign=this.signutreRequest(e);let t=await this.request("auth/gettoken",e);if(void 0===(null==t?void 0:t.code)||null===(null==t?void 0:t.code))throw new N("Invalid response: missing code (auth/gettoken)",M.MessageDecodeFailed);if(0!=t.code)throw new N("Failed to get log center token: "+t.msg,t.code);this.logToken=t.data.token}async push(e){this.logToken||await this.refreshToken();let t=await this.request("data/push",e);if(void 0===(null==t?void 0:t.code)||null===(null==t?void 0:t.code))throw new N("Invalid response: missing code (data/push)",M.MessageDecodeFailed);if(10041==t.code||10042==t.code||10043==t.code)return this.logToken="",this.push(e);if(0!=t.code)throw new N(t.msg,t.code);console.debug("上传rtc日志成功")}signutreRequest(e){let t,r=[];for(t in e)r.push(t+"="+e[t]);r.sort();let i=r.join("&")+"&"+this.logSecretKey;return(0,d.SHA256)(i).toString()}request(e,t){let r=this.serverPrefix+e,i={"Content-Type":"application/json;charset=UTF-8"};return this.logToken&&(i.Authorization="Bearer "+this.logToken),this.deviceType==J.XCX?new Promise(((e,n)=>{wx.request({url:r,method:"POST",header:i,data:JSON.stringify(t),success(t){if(200!=t.statusCode)n(new N(`HTTP ${t.statusCode} ${t.errMsg}`.trim(),M.ConnectionFailed));else{let r=t.data;e(r)}},fail:function(e){n(new N(`Network request failed: ${e.errMsg}`,M.ConnectionFailed))}})})):new Promise(((e,n)=>{fetch(r,{method:"POST",headers:i,body:JSON.stringify(t)}).then((t=>{200!=t.status?n(new N(`HTTP ${t.status} ${t.statusText}`.trim(),M.ConnectionFailed)):t.json().then((t=>{e(t)})).catch((e=>{var t;n(new N(`Invalid response: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.MessageDecodeFailed))}))})).catch((e=>{var t;n(new N(`Network request failed: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.ConnectionFailed))}))}))}}function fe(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let pe=function(e){return e.CONSOLE="console",e.WXREALTIME="wxrealtime",e.NONE="none",e}({}),ge=function(e){return e.DEBUG="debug",e.INFO="info",e.WARN="warn",e.ERROR="error",e}({}),me=pe.CONSOLE,ve=ge.INFO;class ye{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rtc",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ue.RtcLog;fe(this,"center",void 0),fe(this,"dftPrefix",void 0),fe(this,"dftCenterLogType",void 0),fe(this,"logCss","border: 1px solid; padding:2px 5px; border-radius: 3px"),this.dftPrefix=e,this.dftCenterLogType=t}setTarget(e){me=e}setLevel(e){ve=e}get logTarget(){return me}get logLevel(){return ve}getPrefix(e){return`%c ${T("H:i:s")} ${this.dftPrefix}_${e}`}debug(){var e;if(this.logTarget!=pe.NONE){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.snapshotArgs(r),m()&&wx.getLogManager({level:1}).debug(this.dftPrefix+"_debug",...r),null===(e=this.center)||void 0===e||e.addLog({level:ce.Debug,type:this.dftCenterLogType,body:r}),this.logLevel===ge.DEBUG)switch(this.logTarget){case pe.CONSOLE:return console.debug(this.getPrefix("debug"),this.logCss,...r);case pe.WXREALTIME:return wx.getRealtimeLogManager().info(this.dftPrefix+"_debug",...r)}}}info(){var e;if(this.logTarget!=pe.NONE){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.snapshotArgs(r),m()&&wx.getLogManager({level:1}).info(this.dftPrefix+"_info",...r),null===(e=this.center)||void 0===e||e.addLog({level:ce.Info,type:this.dftCenterLogType,body:r}),this.logLevel===ge.DEBUG||this.logLevel===ge.INFO)switch(this.logTarget){case pe.CONSOLE:return console.log(this.getPrefix("info"),this.logCss,...r);case pe.WXREALTIME:return wx.getRealtimeLogManager().info(this.dftPrefix+"_info",...r)}}}warn(){var e;if(this.logTarget!=pe.NONE){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(this.snapshotArgs(r),m()&&wx.getLogManager({level:1}).warn(this.dftPrefix+"_warn",...r),null===(e=this.center)||void 0===e||e.addLog({level:ce.Warn,type:this.dftCenterLogType,body:r}),this.logLevel===ge.DEBUG||this.logLevel===ge.INFO||this.logLevel===ge.WARN)switch(this.logTarget){case pe.CONSOLE:return console.warn(this.getPrefix("warn"),this.logCss,...r);case pe.WXREALTIME:return wx.getRealtimeLogManager().warn(this.dftPrefix+"_warn",...r)}}}error(){var e;if(this.logTarget!=pe.NONE){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];switch(this.snapshotArgs(r),m()&&wx.getLogManager({level:1}).warn(this.dftPrefix+"_error",...r),console.error(this.getPrefix("error"),this.logCss,...r),null===(e=this.center)||void 0===e||e.addLog({level:ce.Error,type:this.dftCenterLogType,body:r}),this.logTarget){case pe.CONSOLE:return;case pe.WXREALTIME:return wx.getRealtimeLogManager().error(this.dftPrefix+"_error",...r)}}}snapshotArgs(e){e.forEach(((t,r)=>{v(t)&&(t instanceof Error?e[r]=t.toString():e[r]=JSON.parse(JSON.stringify(t)))}))}}let be=new ye,we=function(e){return e.UserJoin="user_join",e.UserUpdate="user_update",e.UserLeave="user_leave",e.StreamUpdate="stream_update",e.ChannelUpdate="channel_update",e.ChannelDestroy="channel_destroy",e.Custom="custom",e.ImMsg="im_msg",e.ImDisconnect="im_disconnect",e}({});var Se,_e,ke,Ee=r(7594),Te=r.n(Ee),Ce=r(5995).Buffer;try{Se=new TextDecoder}catch(e){}var Pe=0;const Ae=[];var Ie,Re,xe,Oe,Me,Ne=Ae,Le=0,Be={},De=0,je=0,Ue=[],Fe={useRecords:!1,mapsAsObjects:!0};class Ve{}const We=new Ve;We.name="MessagePack 0xC1";var qe,He,Ke,ze=!1,$e=2;try{new Function("")}catch(e){$e=1/0}class Ge{constructor(e){e&&(!1===e.useRecords&&void 0===e.mapsAsObjects&&(e.mapsAsObjects=!0),e.sequential&&!1!==e.trusted&&(e.trusted=!0,e.structures||0==e.useRecords||(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(_e)return kt((()=>(Et(),this?this.unpack(e,t):Ge.prototype.unpack.call(Fe,e,t))));e.buffer||e.constructor!==ArrayBuffer||(e=void 0!==Ce?Ce.from(e):new Uint8Array(e)),"object"==typeof t?(ke=t.end||e.length,Pe=t.start||0):(Pe=0,ke=t>-1?t:e.length),Le=0,je=0,Re=null,Ne=Ae,xe=null,_e=e;try{Me=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){if(_e=null,e instanceof Uint8Array)throw t;throw new Error("Source must be a Uint8Array or Buffer but was a "+(e&&"object"==typeof e?e.constructor.name:typeof e))}if(this instanceof Ge){if(Be=this,this.structures)return Ie=this.structures,Qe(t);(!Ie||Ie.length>0)&&(Ie=[])}else Be=Fe,(!Ie||Ie.length>0)&&(Ie=[]);return Qe(t)}unpackMultiple(e,t){let r,i=0;try{ze=!0;let n=e.length,o=this?this.unpack(e,n):Ct.unpack(e,n);if(!t){for(r=[o];Pe<n;)i=Pe,r.push(Qe());return r}if(!1===t(o,i,Pe))return;for(;Pe<n;)if(i=Pe,!1===t(Qe(),i,Pe))return}catch(e){throw e.lastPosition=i,e.values=r,e}finally{ze=!1,Et()}}_mergeStructures(e,t){He&&(e=He.call(this,e)),e=e||[],Object.isFrozen(e)&&(e=e.map((e=>e.slice(0))));for(let t=0,r=e.length;t<r;t++){let r=e[t];r&&(r.isShared=!0,t>=32&&(r.highByte=t-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let i=e[r],n=t[r];n&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[r]=i),e[r]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function Qe(e){try{if(!Be.trusted&&!ze){let e=Ie.sharedLength||0;e<Ie.length&&(Ie.length=e)}let t;if(Be.randomAccessStructure&&_e[Pe]<64&&_e[Pe]>=32&&qe?(t=qe(_e,Pe,ke,Be),_e=null,e&&e.lazy||!t||(t=t.toJSON()),Pe=ke):t=Ye(),xe&&(Pe=xe.postBundlePosition,xe=null),ze&&(Ie.restoreStructures=null),Pe==ke)Ie&&Ie.restoreStructures&&Je(),Ie=null,_e=null,Oe&&(Oe=null);else{if(Pe>ke)throw new Error("Unexpected end of MessagePack data");if(!ze){let e;try{e=JSON.stringify(t,((e,t)=>"bigint"==typeof t?`${t}n`:t)).slice(0,100)}catch(t){e="(JSON view not available "+t+")"}throw new Error("Data read, but end of buffer not reached "+e)}}return t}catch(e){throw Ie&&Ie.restoreStructures&&Je(),Et(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||Pe>ke)&&(e.incomplete=!0),e}}function Je(){for(let e in Ie.restoreStructures)Ie[e]=Ie.restoreStructures[e];Ie.restoreStructures=null}function Ye(){let e=_e[Pe++];if(e<160){if(e<128){if(e<64)return e;{let t=Ie[63&e]||Be.getStructures&&tt()[63&e];return t?(t.read||(t.read=Ze(t,63&e)),t.read()):e}}if(e<144){if(e-=128,Be.mapsAsObjects){let t={};for(let r=0;r<e;r++){let e=mt();"__proto__"===e&&(e="__proto_"),t[e]=Ye()}return t}{let t=new Map;for(let r=0;r<e;r++)t.set(Ye(),Ye());return t}}{e-=144;let t=new Array(e);for(let r=0;r<e;r++)t[r]=Ye();return Be.freezeData?Object.freeze(t):t}}if(e<192){let t=e-160;if(je>=Pe)return Re.slice(Pe-De,(Pe+=t)-De);if(0==je&&ke<140){let e=t<16?ht(t):lt(t);if(null!=e)return e}return rt(t)}{let t;switch(e){case 192:return null;case 193:return xe?(t=Ye(),t>0?xe[1].slice(xe.position1,xe.position1+=t):xe[0].slice(xe.position0,xe.position0-=t)):We;case 194:return!1;case 195:return!0;case 196:if(t=_e[Pe++],void 0===t)throw new Error("Unexpected end of buffer");return ft(t);case 197:return t=Me.getUint16(Pe),Pe+=2,ft(t);case 198:return t=Me.getUint32(Pe),Pe+=4,ft(t);case 199:return pt(_e[Pe++]);case 200:return t=Me.getUint16(Pe),Pe+=2,pt(t);case 201:return t=Me.getUint32(Pe),Pe+=4,pt(t);case 202:if(t=Me.getFloat32(Pe),Be.useFloat32>2){let e=Tt[(127&_e[Pe])<<1|_e[Pe+1]>>7];return Pe+=4,(e*t+(t>0?.5:-.5)|0)/e}return Pe+=4,t;case 203:return t=Me.getFloat64(Pe),Pe+=8,t;case 204:return _e[Pe++];case 205:return t=Me.getUint16(Pe),Pe+=2,t;case 206:return t=Me.getUint32(Pe),Pe+=4,t;case 207:return"number"===Be.int64AsType?(t=4294967296*Me.getUint32(Pe),t+=Me.getUint32(Pe+4)):"string"===Be.int64AsType?t=Me.getBigUint64(Pe).toString():"auto"===Be.int64AsType?(t=Me.getBigUint64(Pe),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Me.getBigUint64(Pe),Pe+=8,t;case 208:return Me.getInt8(Pe++);case 209:return t=Me.getInt16(Pe),Pe+=2,t;case 210:return t=Me.getInt32(Pe),Pe+=4,t;case 211:return"number"===Be.int64AsType?(t=4294967296*Me.getInt32(Pe),t+=Me.getUint32(Pe+4)):"string"===Be.int64AsType?t=Me.getBigInt64(Pe).toString():"auto"===Be.int64AsType?(t=Me.getBigInt64(Pe),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=Me.getBigInt64(Pe),Pe+=8,t;case 212:if(t=_e[Pe++],114==t)return yt(63&_e[Pe++]);{let e=Ue[t];if(e)return e.read?(Pe++,e.read(Ye())):e.noBuffer?(Pe++,e()):e(_e.subarray(Pe,++Pe));throw new Error("Unknown extension "+t)}case 213:return t=_e[Pe],114==t?(Pe++,yt(63&_e[Pe++],_e[Pe++])):pt(2);case 214:return pt(4);case 215:return pt(8);case 216:return pt(16);case 217:return t=_e[Pe++],je>=Pe?Re.slice(Pe-De,(Pe+=t)-De):it(t);case 218:return t=Me.getUint16(Pe),je>=(Pe+=2)?Re.slice(Pe-De,(Pe+=t)-De):nt(t);case 219:return t=Me.getUint32(Pe),je>=(Pe+=4)?Re.slice(Pe-De,(Pe+=t)-De):ot(t);case 220:return t=Me.getUint16(Pe),Pe+=2,at(t);case 221:return t=Me.getUint32(Pe),Pe+=4,at(t);case 222:return t=Me.getUint16(Pe),Pe+=2,ct(t);case 223:return t=Me.getUint32(Pe),Pe+=4,ct(t);default:if(e>=224)return e-256;if(void 0===e){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+e)}}}const Xe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ze(e,t){function r(){if(r.count++>$e){let r=e.read=new Function("r","return function(){return "+(Be.freezeData?"Object.freeze":"")+"({"+e.map((e=>"__proto__"===e?"__proto_:r()":Xe.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()")).join(",")+"})}")(Ye);return 0===e.highByte&&(e.read=et(t,e.read)),r()}let i={};for(let t=0,r=e.length;t<r;t++){let r=e[t];"__proto__"===r&&(r="__proto_"),i[r]=Ye()}return Be.freezeData?Object.freeze(i):i}return r.count=0,0===e.highByte?et(t,r):r}const et=(e,t)=>function(){let r=_e[Pe++];if(0===r)return t();let i=e<32?-(e+(r<<5)):e+(r<<5),n=Ie[i]||tt()[i];if(!n)throw new Error("Record id is not defined for "+i);return n.read||(n.read=Ze(n,e)),n.read()};function tt(){let e=kt((()=>(_e=null,Be.getStructures())));return Ie=Be._mergeStructures(e,Ie)}var rt=st,it=st,nt=st,ot=st;function st(e){let t;if(e<16&&(t=ht(e)))return t;if(e>64&&Se)return Se.decode(_e.subarray(Pe,Pe+=e));const r=Pe+e,i=[];for(t="";Pe<r;){const e=_e[Pe++];if(128&e)if(192==(224&e)){const t=63&_e[Pe++];i.push((31&e)<<6|t)}else if(224==(240&e)){const t=63&_e[Pe++],r=63&_e[Pe++];i.push((31&e)<<12|t<<6|r)}else if(240==(248&e)){let t=(7&e)<<18|(63&_e[Pe++])<<12|(63&_e[Pe++])<<6|63&_e[Pe++];t>65535&&(t-=65536,i.push(t>>>10&1023|55296),t=56320|1023&t),i.push(t)}else i.push(e);else i.push(e);i.length>=4096&&(t+=ut.apply(String,i),i.length=0)}return i.length>0&&(t+=ut.apply(String,i)),t}function at(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=Ye();return Be.freezeData?Object.freeze(t):t}function ct(e){if(Be.mapsAsObjects){let t={};for(let r=0;r<e;r++){let e=mt();"__proto__"===e&&(e="__proto_"),t[e]=Ye()}return t}{let t=new Map;for(let r=0;r<e;r++)t.set(Ye(),Ye());return t}}var ut=String.fromCharCode;function lt(e){let t=Pe,r=new Array(e);for(let i=0;i<e;i++){const e=_e[Pe++];if((128&e)>0)return void(Pe=t);r[i]=e}return ut.apply(String,r)}function ht(e){if(e<4){if(e<2){if(0===e)return"";{let e=_e[Pe++];return(128&e)>1?void(Pe-=1):ut(e)}}{let t=_e[Pe++],r=_e[Pe++];if((128&t)>0||(128&r)>0)return void(Pe-=2);if(e<3)return ut(t,r);let i=_e[Pe++];return(128&i)>0?void(Pe-=3):ut(t,r,i)}}{let t=_e[Pe++],r=_e[Pe++],i=_e[Pe++],n=_e[Pe++];if((128&t)>0||(128&r)>0||(128&i)>0||(128&n)>0)return void(Pe-=4);if(e<6){if(4===e)return ut(t,r,i,n);{let e=_e[Pe++];return(128&e)>0?void(Pe-=5):ut(t,r,i,n,e)}}if(e<8){let o=_e[Pe++],s=_e[Pe++];if((128&o)>0||(128&s)>0)return void(Pe-=6);if(e<7)return ut(t,r,i,n,o,s);let a=_e[Pe++];return(128&a)>0?void(Pe-=7):ut(t,r,i,n,o,s,a)}{let o=_e[Pe++],s=_e[Pe++],a=_e[Pe++],c=_e[Pe++];if((128&o)>0||(128&s)>0||(128&a)>0||(128&c)>0)return void(Pe-=8);if(e<10){if(8===e)return ut(t,r,i,n,o,s,a,c);{let e=_e[Pe++];return(128&e)>0?void(Pe-=9):ut(t,r,i,n,o,s,a,c,e)}}if(e<12){let u=_e[Pe++],l=_e[Pe++];if((128&u)>0||(128&l)>0)return void(Pe-=10);if(e<11)return ut(t,r,i,n,o,s,a,c,u,l);let h=_e[Pe++];return(128&h)>0?void(Pe-=11):ut(t,r,i,n,o,s,a,c,u,l,h)}{let u=_e[Pe++],l=_e[Pe++],h=_e[Pe++],d=_e[Pe++];if((128&u)>0||(128&l)>0||(128&h)>0||(128&d)>0)return void(Pe-=12);if(e<14){if(12===e)return ut(t,r,i,n,o,s,a,c,u,l,h,d);{let e=_e[Pe++];return(128&e)>0?void(Pe-=13):ut(t,r,i,n,o,s,a,c,u,l,h,d,e)}}{let f=_e[Pe++],p=_e[Pe++];if((128&f)>0||(128&p)>0)return void(Pe-=14);if(e<15)return ut(t,r,i,n,o,s,a,c,u,l,h,d,f,p);let g=_e[Pe++];return(128&g)>0?void(Pe-=15):ut(t,r,i,n,o,s,a,c,u,l,h,d,f,p,g)}}}}}function dt(){let e,t=_e[Pe++];if(t<192)e=t-160;else switch(t){case 217:e=_e[Pe++];break;case 218:e=Me.getUint16(Pe),Pe+=2;break;case 219:e=Me.getUint32(Pe),Pe+=4;break;default:throw new Error("Expected string")}return st(e)}function ft(e){return Be.copyBuffers?Uint8Array.prototype.slice.call(_e,Pe,Pe+=e):_e.subarray(Pe,Pe+=e)}function pt(e){let t=_e[Pe++];if(Ue[t]){let r;return Ue[t](_e.subarray(Pe,r=Pe+=e),(e=>{Pe=e;try{return Ye()}finally{Pe=r}}))}throw new Error("Unknown extension type "+t)}var gt=new Array(4096);function mt(){let e=_e[Pe++];if(!(e>=160&&e<192))return Pe--,vt(Ye());if(e-=160,je>=Pe)return Re.slice(Pe-De,(Pe+=e)-De);if(!(0==je&&ke<180))return rt(e);let t,r=4095&(e<<5^(e>1?Me.getUint16(Pe):e>0?_e[Pe]:0)),i=gt[r],n=Pe,o=Pe+e-3,s=0;if(i&&i.bytes==e){for(;n<o;){if(t=Me.getUint32(n),t!=i[s++]){n=1879048192;break}n+=4}for(o+=3;n<o;)if(t=_e[n++],t!=i[s++]){n=1879048192;break}if(n===o)return Pe=n,i.string;o-=3,n=Pe}for(i=[],gt[r]=i,i.bytes=e;n<o;)t=Me.getUint32(n),i.push(t),n+=4;for(o+=3;n<o;)t=_e[n++],i.push(t);let a=e<16?ht(e):lt(e);return i.string=null!=a?a:rt(e)}function vt(e){if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return e.toString();if(null==e)return e+"";throw new Error("Invalid property type for record",typeof e)}const yt=(e,t)=>{let r=Ye().map(vt),i=e;void 0!==t&&(e=e<32?-((t<<5)+e):(t<<5)+e,r.highByte=t);let n=Ie[e];return n&&(n.isShared||ze)&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[e]=n),Ie[e]=r,r.read=Ze(r,i),r.read()};Ue[0]=()=>{},Ue[0].noBuffer=!0,Ue[66]=e=>{let t=e.length,r=BigInt(128&e[0]?e[0]-256:e[0]);for(let i=1;i<t;i++)r<<=BigInt("8"),r+=BigInt(e[i]);return r};let bt={Error,TypeError,ReferenceError};Ue[101]=()=>{let e=Ye();return(bt[e[0]]||Error)(e[1],{cause:e[2]})},Ue[105]=e=>{if(!1===Be.structuredClone)throw new Error("Structured clone extension is disabled");let t=Me.getUint32(Pe-4);Oe||(Oe=new Map);let r,i=_e[Pe];r=i>=144&&i<160||220==i||221==i?[]:{};let n={target:r};Oe.set(t,n);let o=Ye();return n.used?Object.assign(r,o):(n.target=o,o)},Ue[112]=e=>{if(!1===Be.structuredClone)throw new Error("Structured clone extension is disabled");let t=Me.getUint32(Pe-4),r=Oe.get(t);return r.used=!0,r.target},Ue[115]=()=>new Set(Ye());const wt=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((e=>e+"Array"));let St="object"==typeof globalThis?globalThis:window;Ue[116]=e=>{let t=e[0],r=wt[t];if(!r){if(16===t){let t=new ArrayBuffer(e.length-1);return new Uint8Array(t).set(e.subarray(1)),t}throw new Error("Could not find typed array for code "+t)}return new St[r](Uint8Array.prototype.slice.call(e,1).buffer)},Ue[120]=()=>{let e=Ye();return new RegExp(e[0],e[1])};const _t=[];function kt(e){Ke&&Ke();let t=ke,r=Pe,i=Le,n=De,o=je,s=Re,a=Ne,c=Oe,u=xe,l=new Uint8Array(_e.slice(0,ke)),h=Ie,d=Ie.slice(0,Ie.length),f=Be,p=ze,g=e();return ke=t,Pe=r,Le=i,De=n,je=o,Re=s,Ne=a,Oe=c,xe=u,_e=l,ze=p,(Ie=h).splice(0,Ie.length,...d),Be=f,Me=new DataView(_e.buffer,_e.byteOffset,_e.byteLength),g}function Et(){_e=null,Oe=null,Ie=null}Ue[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],r=Pe;return Pe+=t-e.length,xe=_t,(xe=[dt(),dt()]).position0=0,xe.position1=0,xe.postBundlePosition=Pe,Pe=r,Ye()},Ue[255]=e=>4==e.length?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):8==e.length?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):12==e.length?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid");const Tt=new Array(147);for(let e=0;e<256;e++)Tt[e]=+("1e"+Math.floor(45.15-.30103*e));var Ct=new Ge({useRecords:!1});Ct.unpack,Ct.unpackMultiple,Ct.unpack;let Pt=new Float32Array(1);new Uint8Array(Pt.buffer,0,4);var At=r(5995).Buffer;let It,Rt,xt;try{It=new TextEncoder}catch(e){}const Ot=void 0!==At,Mt=Ot?function(e){return At.allocUnsafeSlow(e)}:Uint8Array,Nt=Ot?At:Uint8Array,Lt=Ot?4294967296:2144337920;let Bt,Dt,jt,Ut,Ft,Vt=0,Wt=null;const qt=/[\u0080-\uFFFF]/,Ht=Symbol("record-id");class Kt extends Ge{constructor(e){let t,r,i,n;super(e),this.offset=0;let o=Nt.prototype.utf8Write?function(e,t){return Bt.utf8Write(e,t,4294967295)}:!(!It||!It.encodeInto)&&function(e,t){return It.encodeInto(e,Bt.subarray(t)).written},s=this;e||(e={});let a=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(null==u&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&null==e.moreTypes&&(this.moreTypes=!0);let l=e.maxOwnStructures;null==l&&(l=c?32:64),this.structures||0==e.useRecords||(this.structures=[]);let h=u>32||l+u>64,d=u+64,f=u+l+64;if(f>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let p=[],g=0,m=0;this.pack=this.encode=function(e,o){if(Bt||(Bt=new Mt(8192),jt=Bt.dataView||(Bt.dataView=new DataView(Bt.buffer,0,8192)),Vt=0),Ut=Bt.length-10,Ut-Vt<2048?(Bt=new Mt(Bt.length),jt=Bt.dataView||(Bt.dataView=new DataView(Bt.buffer,0,Bt.length)),Ut=Bt.length-10,Vt=0):Vt=Vt+7&2147483640,t=Vt,o&nr&&(Vt+=255&o),n=s.structuredClone?new Map:null,s.bundleStrings&&"string"!=typeof e?(Wt=[],Wt.size=1/0):Wt=null,i=s.structures,i){i.uninitialized&&(i=s._mergeStructures(s.getStructures()));let e=i.sharedLength||0;if(e>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let t=0;t<e;t++){let e=i[t];if(!e)continue;let r,n=i.transitions;for(let t=0,i=e.length;t<i;t++){let i=e[t];r=n[i],r||(r=n[i]=Object.create(null)),n=r}n[Ht]=t+64}this.lastNamedStructuresLength=e}a||(i.nextId=e+64)}let c;r&&(r=!1);try{s.randomAccessStructure&&e&&e.constructor&&e.constructor===Object?P(e):b(e);let r=Wt;if(Wt&&Qt(t,b,0),n&&n.idsToInsert){let e=n.idsToInsert.sort(((e,t)=>e.offset>t.offset?1:-1)),i=e.length,o=-1;for(;r&&i>0;){let n=e[--i].offset+t;n<r.stringsPosition+t&&-1===o&&(o=0),n>r.position+t?o>=0&&(o+=6):(o>=0&&(jt.setUint32(r.position+t,jt.getUint32(r.position+t)+o),o=-1),r=r.previous,i++)}o>=0&&r&&jt.setUint32(r.position+t,jt.getUint32(r.position+t)+o),Vt+=6*e.length,Vt>Ut&&E(Vt),s.offset=Vt;let a=function(e,t){let r,i=6*t.length,n=e.length-i;for(;r=t.pop();){let t=r.offset,o=r.id;e.copyWithin(t+i,t,n),i-=6;let s=t+i;e[s++]=214,e[s++]=105,e[s++]=o>>24,e[s++]=o>>16&255,e[s++]=o>>8&255,e[s++]=255&o,n=t}return e}(Bt.subarray(t,Vt),e);return n=null,a}return s.offset=Vt,o&rr?(Bt.start=t,Bt.end=Vt,Bt):Bt.subarray(t,Vt)}catch(e){throw c=e,e}finally{if(i&&(v(),r&&s.saveStructures)){let r=i.sharedLength||0,n=Bt.subarray(t,Vt),a=Jt(i,s);if(!c)return!1===s.saveStructures(a,a.isCompatible)?s.pack(e,o):(s.lastNamedStructuresLength=r,Bt.length>1073741824&&(Bt=null),n)}Bt.length>1073741824&&(Bt=null),o&ir&&(Vt=t)}};const v=()=>{m<10&&m++;let e=i.sharedLength||0;if(i.length>e&&!a&&(i.length=e),g>1e4)i.transitions=null,m=0,g=0,p.length>0&&(p=[]);else if(p.length>0&&!a){for(let e=0,t=p.length;e<t;e++)p[e][Ht]=0;p=[]}},y=e=>{var t=e.length;t<16?Bt[Vt++]=144|t:t<65536?(Bt[Vt++]=220,Bt[Vt++]=t>>8,Bt[Vt++]=255&t):(Bt[Vt++]=221,jt.setUint32(Vt,t),Vt+=4);for(let r=0;r<t;r++)b(e[r])},b=e=>{Vt>Ut&&(Bt=E(Vt));var r,i=typeof e;if("string"===i){let i,n=e.length;if(Wt&&n>=4&&n<4096){if((Wt.size+=n)>21760){let e,r,i=(Wt[0]?3*Wt[0].length+Wt[1].length:0)+10;Vt+i>Ut&&(Bt=E(Vt+i)),Wt.position?(r=Wt,Bt[Vt]=200,Vt+=3,Bt[Vt++]=98,e=Vt-t,Vt+=4,Qt(t,b,0),jt.setUint16(e+t-3,Vt-t-e)):(Bt[Vt++]=214,Bt[Vt++]=98,e=Vt-t,Vt+=4),Wt=["",""],Wt.previous=r,Wt.size=0,Wt.position=e}let r=qt.test(e);return Wt[r?0:1]+=e,Bt[Vt++]=193,void b(r?-n:n)}i=n<32?1:n<256?2:n<65536?3:5;let s=3*n;if(Vt+s>Ut&&(Bt=E(Vt+s)),n<64||!o){let t,o,s,a=Vt+i;for(t=0;t<n;t++)o=e.charCodeAt(t),o<128?Bt[a++]=o:o<2048?(Bt[a++]=o>>6|192,Bt[a++]=63&o|128):55296==(64512&o)&&56320==(64512&(s=e.charCodeAt(t+1)))?(o=65536+((1023&o)<<10)+(1023&s),t++,Bt[a++]=o>>18|240,Bt[a++]=o>>12&63|128,Bt[a++]=o>>6&63|128,Bt[a++]=63&o|128):(Bt[a++]=o>>12|224,Bt[a++]=o>>6&63|128,Bt[a++]=63&o|128);r=a-Vt-i}else r=o(e,Vt+i);r<32?Bt[Vt++]=160|r:r<256?(i<2&&Bt.copyWithin(Vt+2,Vt+1,Vt+1+r),Bt[Vt++]=217,Bt[Vt++]=r):r<65536?(i<3&&Bt.copyWithin(Vt+3,Vt+2,Vt+2+r),Bt[Vt++]=218,Bt[Vt++]=r>>8,Bt[Vt++]=255&r):(i<5&&Bt.copyWithin(Vt+5,Vt+3,Vt+3+r),Bt[Vt++]=219,jt.setUint32(Vt,r),Vt+=4),Vt+=r}else if("number"===i)if(e>>>0===e)e<32||e<128&&!1===this.useRecords||e<64&&!this.randomAccessStructure?Bt[Vt++]=e:e<256?(Bt[Vt++]=204,Bt[Vt++]=e):e<65536?(Bt[Vt++]=205,Bt[Vt++]=e>>8,Bt[Vt++]=255&e):(Bt[Vt++]=206,jt.setUint32(Vt,e),Vt+=4);else if((e|0)===e)e>=-32?Bt[Vt++]=256+e:e>=-128?(Bt[Vt++]=208,Bt[Vt++]=e+256):e>=-32768?(Bt[Vt++]=209,jt.setInt16(Vt,e),Vt+=2):(Bt[Vt++]=210,jt.setInt32(Vt,e),Vt+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){let r;if(Bt[Vt++]=202,jt.setFloat32(Vt,e),t<4||((r=e*Tt[(127&Bt[Vt])<<1|Bt[Vt+1]>>7])|0)===r)return void(Vt+=4);Vt--}Bt[Vt++]=203,jt.setFloat64(Vt,e),Vt+=8}else if("object"===i||"function"===i)if(e){if(n){let r=n.get(e);if(r){if(!r.id){let e=n.idsToInsert||(n.idsToInsert=[]);r.id=e.push(r)}return Bt[Vt++]=214,Bt[Vt++]=112,jt.setUint32(Vt,r.id),void(Vt+=4)}n.set(e,{offset:Vt-t})}let o=e.constructor;if(o===Object)k(e);else if(o===Array)y(e);else if(o===Map)if(this.mapAsEmptyObject)Bt[Vt++]=128;else{(r=e.size)<16?Bt[Vt++]=128|r:r<65536?(Bt[Vt++]=222,Bt[Vt++]=r>>8,Bt[Vt++]=255&r):(Bt[Vt++]=223,jt.setUint32(Vt,r),Vt+=4);for(let[t,r]of e)b(t),b(r)}else{for(let t=0,r=Rt.length;t<r;t++){if(e instanceof xt[t]){let r=Rt[t];if(r.write){r.type&&(Bt[Vt++]=212,Bt[Vt++]=r.type,Bt[Vt++]=0);let t=r.write.call(this,e);return void(t===e?Array.isArray(e)?y(e):k(e):b(t))}let i,n=Bt,o=jt,s=Vt;Bt=null;try{i=r.pack.call(this,e,(e=>(Bt=n,n=null,Vt+=e,Vt>Ut&&E(Vt),{target:Bt,targetView:jt,position:Vt-e})),b)}finally{n&&(Bt=n,jt=o,Vt=s,Ut=Bt.length-10)}return void(i&&(i.length+Vt>Ut&&E(i.length+Vt),Vt=Gt(i,Bt,Vt,r.type)))}}if(Array.isArray(e))y(e);else{if(e.toJSON){const t=e.toJSON();if(t!==e)return b(t)}if("function"===i)return b(this.writeFunction&&this.writeFunction(e));k(e)}}}else Bt[Vt++]=192;else if("boolean"===i)Bt[Vt++]=e?195:194;else if("bigint"===i){if(e<BigInt(1)<<BigInt(63)&&e>=-(BigInt(1)<<BigInt(63)))Bt[Vt++]=211,jt.setBigInt64(Vt,e);else if(e<BigInt(1)<<BigInt(64)&&e>0)Bt[Vt++]=207,jt.setBigUint64(Vt,e);else{if(!this.largeBigIntToFloat){if(this.useBigIntExtension&&e<BigInt("2")**BigInt("1023")&&e>-(BigInt("2")**BigInt("1023"))){Bt[Vt++]=199,Vt++,Bt[Vt++]=66;let t,r=[];do{let i=e&BigInt("0xff");t=(i&BigInt("0x80"))===(e<BigInt("0")?BigInt("0x80"):BigInt("0")),r.push(i),e>>=BigInt("8")}while(e!==BigInt("0")&&e!==-BigInt("1")||!t);Bt[Vt-2]=r.length;for(let e=r.length;e>0;)Bt[Vt++]=Number(r[--e]);return}throw new RangeError(e+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension or set largeBigIntToFloat to convert to float-64")}Bt[Vt++]=203,jt.setFloat64(Vt,Number(e))}Vt+=8}else{if("undefined"!==i)throw new Error("Unknown type: "+i);this.encodeUndefinedAsNil?Bt[Vt++]=192:(Bt[Vt++]=212,Bt[Vt++]=0,Bt[Vt++]=0)}},w=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let r in e)"function"==typeof e.hasOwnProperty&&!e.hasOwnProperty(r)||this.skipValues.includes(e[r])||t.push(r)}else t=Object.keys(e);let r,i=t.length;if(i<16?Bt[Vt++]=128|i:i<65536?(Bt[Vt++]=222,Bt[Vt++]=i>>8,Bt[Vt++]=255&i):(Bt[Vt++]=223,jt.setUint32(Vt,i),Vt+=4),this.coercibleKeyAsNumber)for(let n=0;n<i;n++){r=t[n];let i=Number(r);b(isNaN(i)?r:i),b(e[r])}else for(let n=0;n<i;n++)b(r=t[n]),b(e[r])}:e=>{Bt[Vt++]=222;let r=Vt-t;Vt+=2;let i=0;for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&(b(t),b(e[t]),i++);Bt[r+++t]=i>>8,Bt[r+t]=255&i},S=!1===this.useRecords?w:e.progressiveRecords&&!h?e=>{let r,n,o=i.transitions||(i.transitions=Object.create(null)),s=Vt++-t;for(let a in e)if("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(a)){if(r=o[a],r)o=r;else{let c=Object.keys(e),u=o;o=i.transitions;let l=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];r=o[t],r||(r=o[t]=Object.create(null),l++),o=r}s+t+1==Vt?(Vt--,T(o,c,l)):C(o,c,s,l),n=!0,o=u[a]}b(e[a])}if(!n){let r=o[Ht];r?Bt[s+t]=r:C(o,Object.keys(e),s,0)}}:e=>{let t,r=i.transitions||(i.transitions=Object.create(null)),n=0;for(let i in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(i))&&(t=r[i],t||(t=r[i]=Object.create(null),n++),r=t);let o=r[Ht];o?o>=96&&h?(Bt[Vt++]=96+(31&(o-=96)),Bt[Vt++]=o>>5):Bt[Vt++]=o:T(r,r.__keys__||Object.keys(e),n);for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&b(e[t])},_="function"==typeof this.useRecords&&this.useRecords,k=_?e=>{_(e)?S(e):w(e)}:S,E=e=>{let r;if(e>16777216){if(e-t>Lt)throw new Error("Packed buffer would be larger than maximum buffer size");r=Math.min(Lt,4096*Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096))}else r=1+(Math.max(e-t<<2,Bt.length-1)>>12)<<12;let i=new Mt(r);return jt=i.dataView||(i.dataView=new DataView(i.buffer,0,r)),e=Math.min(e,Bt.length),Bt.copy?Bt.copy(i,0,t,e):i.set(Bt.slice(t,e)),Vt-=t,t=0,Ut=i.length-10,Bt=i},T=(e,t,n)=>{let o=i.nextId;o||(o=64),o<d&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(o=i.nextOwnId,o<f||(o=d),i.nextOwnId=o+1):(o>=f&&(o=d),i.nextId=o+1);let s=t.highByte=o>=96&&h?o-96>>5:-1;e[Ht]=o,e.__keys__=t,i[o-64]=t,o<d?(t.isShared=!0,i.sharedLength=o-63,r=!0,s>=0?(Bt[Vt++]=96+(31&o),Bt[Vt++]=s):Bt[Vt++]=o):(s>=0?(Bt[Vt++]=213,Bt[Vt++]=114,Bt[Vt++]=96+(31&o),Bt[Vt++]=s):(Bt[Vt++]=212,Bt[Vt++]=114,Bt[Vt++]=o),n&&(g+=m*n),p.length>=l&&(p.shift()[Ht]=0),p.push(e),b(t))},C=(e,r,i,n)=>{let o=Bt,s=Vt,a=Ut,c=t;Bt=Dt,Vt=0,t=0,Bt||(Dt=Bt=new Mt(8192)),Ut=Bt.length-10,T(e,r,n),Dt=Bt;let u=Vt;if(Bt=o,Vt=s,Ut=a,t=c,u>1){let e=Vt+u-1;e>Ut&&E(e);let r=i+t;Bt.copyWithin(r+u,r+1,Vt),Bt.set(Dt.slice(0,u),r),Vt=e}else Bt[i+t]=Dt[0]},P=e=>{let n=Ft(e,Bt,t,Vt,i,E,((e,t,i)=>{if(i)return r=!0;Vt=t;let n=Bt;return b(e),v(),n!==Bt?{position:Vt,targetView:jt,target:Bt}:Vt}),this);if(0===n)return k(e);Vt=n}}useBuffer(e){Bt=e,Bt.dataView||(Bt.dataView=new DataView(Bt.buffer,Bt.byteOffset,Bt.byteLength)),Vt=0}set position(e){Vt=e}get position(){return Vt}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}function zt(e,t,r,i){let n=e.byteLength;if(n+1<256){var{target:o,position:s}=r(4+n);o[s++]=199,o[s++]=n+1}else if(n+1<65536){var{target:o,position:s}=r(5+n);o[s++]=200,o[s++]=n+1>>8,o[s++]=n+1&255}else{var{target:o,position:s,targetView:a}=r(7+n);o[s++]=201,a.setUint32(s,n+1),s+=4}o[s++]=116,o[s++]=t,e.buffer||(e=new Uint8Array(e)),o.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s)}function $t(e,t){let r=e.byteLength;var i,n;if(r<256){var{target:i,position:n}=t(r+2);i[n++]=196,i[n++]=r}else if(r<65536){var{target:i,position:n}=t(r+3);i[n++]=197,i[n++]=r>>8,i[n++]=255&r}else{var{target:i,position:n,targetView:o}=t(r+5);i[n++]=198,o.setUint32(n,r),n+=4}i.set(e,n)}function Gt(e,t,r,i){let n=e.length;switch(n){case 1:t[r++]=212;break;case 2:t[r++]=213;break;case 4:t[r++]=214;break;case 8:t[r++]=215;break;case 16:t[r++]=216;break;default:n<256?(t[r++]=199,t[r++]=n):n<65536?(t[r++]=200,t[r++]=n>>8,t[r++]=255&n):(t[r++]=201,t[r++]=n>>24,t[r++]=n>>16&255,t[r++]=n>>8&255,t[r++]=255&n)}return t[r++]=i,t.set(e,r),r+=n}function Qt(e,t,r){if(Wt.length>0){jt.setUint32(Wt.position+e,Vt+r-Wt.position-e),Wt.stringsPosition=Vt-e;let i=Wt;Wt=null,t(i[0]),t(i[1])}}function Jt(e,t){return e.isCompatible=e=>{let r=!e||(t.lastNamedStructuresLength||0)===e.length;return r||t._mergeStructures(e),r},e}xt=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ve],Rt=[{pack(e,t,r){let i=e.getTime()/1e3;if((this.useTimestamp32||0===e.getMilliseconds())&&i>=0&&i<4294967296){let{target:e,targetView:r,position:n}=t(6);e[n++]=214,e[n++]=255,r.setUint32(n,i)}else if(i>0&&i<4294967296){let{target:r,targetView:n,position:o}=t(10);r[o++]=215,r[o++]=255,n.setUint32(o,4e6*e.getMilliseconds()+(i/1e3/4294967296|0)),n.setUint32(o+4,i)}else if(isNaN(i)){if(this.onInvalidDate)return t(0),r(this.onInvalidDate());let{target:e,targetView:i,position:n}=t(3);e[n++]=212,e[n++]=255,e[n++]=255}else{let{target:r,targetView:n,position:o}=t(15);r[o++]=199,r[o++]=12,r[o++]=255,n.setUint32(o,1e6*e.getMilliseconds()),n.setBigInt64(o+4,BigInt(Math.floor(i)))}}},{pack(e,t,r){if(this.setAsEmptyObject)return t(0),r({});let i=Array.from(e),{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=115,n[o++]=0),r(i)}},{pack(e,t,r){let{target:i,position:n}=t(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=101,i[n++]=0),r([e.name,e.message,e.cause])}},{pack(e,t,r){let{target:i,position:n}=t(this.moreTypes?3:0);this.moreTypes&&(i[n++]=212,i[n++]=120,i[n++]=0),r([e.source,e.flags])}},{pack(e,t){this.moreTypes?zt(e,16,t):$t(Ot?At.from(e):new Uint8Array(e),t)}},{pack(e,t){let r=e.constructor;r!==Nt&&this.moreTypes?zt(e,wt.indexOf(r.name),t):$t(e,t)}},{pack(e,t){let{target:r,position:i}=t(1);r[i]=193}}];let Yt=new Kt({useRecords:!1});Yt.pack,Yt.pack;const{NEVER:Xt,ALWAYS:Zt,DECIMAL_ROUND:er,DECIMAL_FIT:tr}={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},rr=512,ir=1024,nr=2048;r(5995).Buffer;function or(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let sr=function(e){return e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.CHANNEL_MESSAGE="channelmessage",e.IM_MESSAGE="immessage",e.WHITEBOARD_MESSAGE="whiteboardmessage",e.CUSTOM_TOPIC_MESSAGE="custommessage",e}({});class ar extends(h()){constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be;super(),or(this,"logger",void 0),or(this,"client",void 0),or(this,"version",1),or(this,"ssTopics",{}),or(this,"authReconnect",void 0),or(this,"isFirstConnect",!0),or(this,"unpacker",void 0),this.authReconnect=e,this.logger=t,this.unpacker=new Ge({useRecords:!1,int64AsType:"number"})}initClient(e){let t=this.getBrokerUrl(e.ws);return Te().connect(t,{keepalive:30,clean:!1,connectTimeout:1e4,reconnectPeriod:3e3,resubscribe:!1,clientId:e.client_id,username:e.username,password:e.jwt_token,protocolVersion:5,properties:{sessionExpiryInterval:400},transformWsUrl:this.authReconnect})}getBrokerUrl(e){return e}async connect(e){return this.client&&await this.close(!0),this.isFirstConnect=!0,new Promise(((t,r)=>{this.client=this.initClient(e);let i=e=>{o(),setTimeout((()=>{this.close(!0)}),0);let t=e?N.fromError(e,M.SignalingConnectFailed):new N("Failed to connect to signaling server",M.SignalingConnectFailed);r(t)},n=async i=>{o();try{await this.subscribe(e.topics,2)}catch(e){return this.close(!0),void r(e)}this.addListeners(),this.client.emit("connect",i),this.isFirstConnect=!1,t()},o=()=>{this.client.off("connect",n),this.client.off("error",i),this.client.off("offline",i),this.client.off("close",i)};this.client.once("connect",n),this.client.once("error",i),this.client.once("offline",i),this.client.once("close",i)}))}addListeners(){this.client.on("connect",(()=>{if(!this.isFirstConnect)for(const e in this.ssTopics)k((()=>this.subscribe(e,this.ssTopics[e])),{maxRetries:10})().catch((t=>{"maxretry"==t&&this.logger.error(`socket尝试订阅${e}多次重试依旧失败,已放弃`)}));this.emit(sr.CONNECTED)})),this.client.on("reconnect",(()=>{this.logger.info("socket start reconnect"),this.emit(sr.RECONNECTING)})),this.client.on("close",(()=>{this.logger.info("socket closed")})),this.client.on("offline",(()=>{this.logger.info("socket offline")})),this.client.on("error",(e=>{throw this.logger.error("socket error",e),N.fromError(e,M.SignalingConnectFailed)})),this.onMsg=this.onMsg.bind(this),this.client.on("message",this.onMsg)}subscribe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new Promise(((r,i)=>{this.client.subscribe(e,{qos:t},((t,n)=>{t?(this.logger.error(`subscribe ${e} error`,t),i(N.fromError(t,M.SignalingSubscribeFailed))):n&&(this.logger.debug(`subscribe ${e} success`,n),n.forEach((e=>{this.ssTopics[e.topic]=e.qos})),r())}))}))}unsubscribe(e){return new Promise(((t,r)=>{this.client.unsubscribe(e,(i=>{if(i)this.logger.error(`unsubscribe ${e} error`,i),r(N.fromError(i,M.SignalingConnectFailed));else{("string"==typeof e?[e]:e).forEach((e=>{delete this.ssTopics[e]})),t()}}))}))}async close(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(((t,r)=>{this.client.end(e,(e=>{this.ssTopics={},null!=e?r(N.fromError(e,M.SignalingConnectFailed)):t()}))}))}sendMsg(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new Promise(((i,n)=>{this.client.publish(t,e,{qos:r},(e=>{null!=e?n(N.fromError(e,M.SignalingConnectFailed)):i()}))}))}onMsg(e,t,r){try{if(0!==e.indexOf("/rtc/"))return void this.emit(sr.CUSTOM_TOPIC_MESSAGE,e,t);let r=this.unpacker.unpack(t);if(null==r)return void this.logger.error("解析报文失败",e,t);this.logger.debug(r.data.channel?"收到会控消息":r.data.board?"收到电子白板消息":"收到im消息",r),this.emit(r.data.channel?sr.CHANNEL_MESSAGE:r.data.board?sr.WHITEBOARD_MESSAGE:sr.IM_MESSAGE,e,r)}catch(e){this.logger.error("消息处理报错",e)}}}function cr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ur=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.DISCONNECTED="disconnected",e}(ur||{});class lr extends(h()){constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new ye;super(),cr(this,"rtcApi",void 0),cr(this,"rtcSocket",void 0),cr(this,"connectState",void 0),cr(this,"heartbeatIntervalID",void 0),cr(this,"eventCB",void 0),cr(this,"logger",void 0),this.rtcApi=e,this.rtcSocket=t,this.logger=i,this.eventCB=r,this.addSocketListeners(),this.connectState=ur.INIT}addSocketListeners(){this.onConnected=this.onConnected.bind(this),this.onStartReconnect=this.onStartReconnect.bind(this),this.onImMessage=this.onImMessage.bind(this),this.rtcSocket.on(sr.CONNECTED,this.onConnected),this.rtcSocket.on(sr.RECONNECTING,this.onStartReconnect),this.rtcSocket.on(sr.IM_MESSAGE,this.onImMessage)}removeSocketListeners(){this.rtcSocket.off(sr.CONNECTED,this.onConnected),this.rtcSocket.off(sr.RECONNECTING,this.onStartReconnect),this.rtcSocket.off(sr.IM_MESSAGE,this.onImMessage)}triggerEvent(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];const n=r[0];try{const t={type:e,data:n};this.emit(e,t),this.eventCB&&this.eventCB(t)}catch(t){this.logger.error(`im事件${e}上层响应出错,请sdk调用者检查`,t,n)}}async heartbeat(){let e=this.heartbeatIntervalID;if(this.connectState!=ur.CONNECTED)throw this.logger.info(`异常im心跳,当前im状态${this.connectState}`),clearInterval(e),new N(`Unexpected IM heartbeat, state: ${this.connectState}`,M.InvalidState);try{await this.rtcApi.imHeartbeat()}catch(e){this.logger.error("im心跳失败",e),j(e)&&this.disconnnect(u.Error,e)}this.logger.debug("im heartbeat interval",e)}async onConnected(){let e=this.connectState;this.logger.warn(e==ur.RECONNECTING?"imsocket重连成功":"imsocket连接成功"),this.connectState=ur.CONNECTED,this.heartbeatIntervalID&&clearInterval(this.heartbeatIntervalID);let t=this.heartbeatIntervalID=setInterval((()=>this.heartbeat()),3e4);this.logger.debug("imheartbeat interval started",t),e==ur.RECONNECTING?this.triggerEvent(c.RECONNECTED):this.triggerEvent(c.ENABLE_SUCCEED)}onStartReconnect(){this.logger.warn("imsocket开始重连"),clearInterval(this.heartbeatIntervalID),this.connectState=ur.RECONNECTING,this.triggerEvent(c.RECONNECTING)}onImMessage(e,t){switch(t.type){case we.ImDisconnect:const e=t.data;if(!e)return;this.disconnnect(e.reason);break;case we.ImMsg:{const e=t.data;if(!e)return;this.triggerEvent(c.IM_MSG,e);break}}}async disconnnect(e,t){var r;if(this.connectState!==ur.DISCONNECTED){clearInterval(this.heartbeatIntervalID),this.removeSocketListeners();try{await this.rtcSocket.close()}catch(e){this.logger.error("断开imsocket报错",e)}try{await this.rtcApi.imDisconnect()}catch(e){this.logger.error("调im断开api报错",e)}this.connectState=ur.DISCONNECTED,this.triggerEvent(c.DISCONNECTED,{reason:e,error:t}),this.removeAllListeners(),this.eventCB=null,null===(r=this.logger.center)||void 0===r||r.flush(),this.logger.info("disconnected im",e)}}}function hr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class dr{supportsMultiChannel(){return!0}get defaultChannel(){var e;return null!==(e=this.channels[0])&&void 0!==e?e:null}isDefaultChannel(e,t){const r=this.channels[0];return!(!r||!e)&&(r===e||!!t&&this.getChannelId(r)===t)}getChannelId(e){try{var t,r;return null!==(t=null==e||null===(r=e.getInfo())||void 0===r?void 0:r.channel)&&void 0!==t?t:""}catch{return""}}warnIfReactiveProxy(){const e=this;(e.__v_isReactive||e.__v_isReadonly||e.__v_raw)&&be.warn("SRTC 实例被响应式框架代理(如 Vue reactive / Pinia state),请改用 markRaw() 或 shallowRef 存放 SDK 实例,否则可能出现频道事件丢失等问题")}constructor(e){var t,r;hr(this,"channels",[]),hr(this,"im",void 0),hr(this,"imLogger",void 0),hr(this,"isAppHide",void 0),hr(this,"destroyed",!1),hr(this,"onNotifyChannelEvent",null),hr(this,"onNotifyImEvent",null),this.isAppHide=!1,e.logLevel&&(dr.liveInstanceCount>0&&be.warn("logLevel 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),be.setLevel(e.logLevel)),e.logTarget&&(m()||e.logTarget!=pe.WXREALTIME||(e.logTarget=pe.CONSOLE,be.warn("仅微信小程序支持实时日志")),dr.liveInstanceCount>0&&be.warn("logTarget 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),be.setTarget(e.logTarget)),void 0!==e.language&&(dr.liveInstanceCount>0&&be.warn("language 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),t=e.language,Z=te(t)),void 0!==e.autoPlayDialogText&&(dr.liveInstanceCount>0&&be.warn("autoPlayDialogText 是 SDK 全局配置,当前已有其它 SRTC 实例存活,此处设置会影响所有实例"),r=e.autoPlayDialogText,ee=r?{...r}:void 0),dr.liveInstanceCount++;let i=this.buildInfo();be.warn("srtc "+(m()?"wechat":"webrtc")+" sdk version:",i.version,"build time:",T("Y-m-d H:i:s",new Date(1e3*i.timestamp)))}get joinVersion(){return this.buildInfo().version}async join(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.destroyed)throw new N("SRTC instance has been destroyed",M.InvalidState);if(this.warnIfReactiveProxy(),!this.supportsMultiChannel()&&this.channels.length>0)throw new N("Already joined a channel; leave it first (multi-channel not supported on this platform)",M.AlreadyJoined);t={autoSubscribeAudio:!1,autoSubscribeVideo:!1,adaptiveStream:!0,...t};const r=Math.floor(Date.now()/1e3);let i=I(e);if(i.exp_at&&i.exp_at<r)throw B();let n,a=new ye;i.log_center&&(a.center=new he(i,this.getStoredDeviceId(),this.getDeviceType(),!0));let c="";const u=e=>{n&&this.isDefaultChannel(n,c)&&this.onNotifyChannelEvent&&this.onNotifyChannelEvent(e),n&&e.type===o.DISCONNECTED&&this.removeChannel(n)};let l,h;try{let e=this.newRtcApi(i,a);h=await e.join({deviceType:this.getDeviceType(),deviceID:this.getStoredDeviceId(),version:this.joinVersion}),c=h.channel;let r=this.newStreamEngine(t,h,e,a);await r.connect();let o=(t,r,i)=>{const o=Math.floor(Date.now()/1e3);return h.mqtt.token_exp_at<o&&e.reconnect({type:0}).then((e=>{h.mqtt=e.mqtt,h.upload=e.upload,h.rtmp=e.rtmp,h.webrtc=e.webrtc})).catch((e=>{var t;j(e)&&(null===(t=n)||void 0===t||t.leave(s.Error,e))})),i.options.username=h.mqtt.username,i.options.clientId=h.mqtt.client_id,i.options.password=h.mqtt.jwt_token,h.mqtt.ws};l=this.newRtcSocket(o,a),n=this.newChannel(t,h,e,r,l,u,a)}catch(e){var d;throw null===(d=a.center)||void 0===d||d.shutdown(),a.center=void 0,e}const f=n;return this.channels.push(f),this.syncGlobalLogCenter(),new Promise((async(e,t)=>{f.once(o.JOIN_SUCCEED,(()=>{a.info("joined channel: "+h.channel),e(f)})),f.once(o.DISCONNECTED,(e=>{t(e.data)}));try{await l.connect(h.mqtt)}catch(e){f.leave(s.Error,e).catch((()=>{})),t(e)}}))}async leave(){let e=this.defaultChannel;if(e)try{await e.leave(s.Self)}catch(t){this.removeChannel(e),be.error("离开频道报错,强制离开",t)}else be.warn("您不在频道中,无需调用离开")}removeChannel(e){var t;let r=this.channels.indexOf(e);if(r<0){const t=this.getChannelId(e);t&&(r=this.channels.findIndex((e=>this.getChannelId(e)===t)))}r>=0&&this.channels.splice(r,1),this.syncGlobalLogCenter(),null===(t=e.getLogCenter())||void 0===t||t.shutdown(),e.setLogCenter(void 0),this.postLeave(e)}syncGlobalLogCenter(){var e;be.center=null===(e=this.defaultChannel)||void 0===e?void 0:e.getLogCenter()}postLeave(e){}getChannelInfo(){return this.defaultChannel?this.defaultChannel.getInfo():null}getPublishInfo(e){if(!this.defaultChannel)throw L();return this.defaultChannel.getPublishInfo(e)}getUserInfo(e){if(!this.defaultChannel)throw L();return this.defaultChannel.getUser(e).getInfo()}getUsersInfo(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.defaultChannel)throw L();return this.defaultChannel.getUsersInfo(e)}async subscribeRemoteAudioMixTrack(e){if(!this.defaultChannel)throw L();return await this.defaultChannel.subscribeRemoteAudioMixTrack(e)}async subscribeRemoteAudioTrack(e,t){if(!this.defaultChannel)throw L();return await this.defaultChannel.subscribeRemoteAudioTrack(e,t)}async subscribeRemoteVideoMcuTrack(){if(!this.defaultChannel)throw L();return await this.defaultChannel.subscribeRemoteVideoMcuTrack()}async subscribeRemoteVideoTrack(e,t){if(!this.defaultChannel)throw L();return await this.defaultChannel.subscribeRemoteVideoTrack(e,t)}async unsubscribeRemoteTrack(e){if(!this.defaultChannel)throw L();await this.defaultChannel.unsubscribeRemoteTrack(e)}getRemoteTrack(e,t,r){if(!this.defaultChannel)throw L();if(!t&&!r)throw new N("Either id or desc must be provided",M.InvalidArgument);let i=t?this.defaultChannel.getUser(e).getTrack(t):this.defaultChannel.getUser(e).getTrackByDesc(r);if(!i)throw D(t?`Track not found: uid=${e}, id=${t}`:`Track not found: uid=${e}, desc=${r}`);return i}async enableIm(e){if(this.destroyed)throw new N("SRTC instance has been destroyed",M.InvalidState);if(this.im)throw new N("IM channel is already enabled",M.AlreadyJoined);const t=Math.floor(Date.now()/1e3);let r=I(e);if(r.exp_at&&r.exp_at<t)throw B();let i=new ye;r.log_center&&(this.imLogger=new he(r,this.getStoredDeviceId(),this.getDeviceType(),!0),i.center=this.imLogger);let n,o=this.newRtcApi(r,i);try{n=await o.imConnect({deviceType:this.getDeviceType(),deviceID:this.getStoredDeviceId(),version:this.joinVersion})}catch(e){var s;throw null===(s=this.imLogger)||void 0===s||s.shutdown(),this.imLogger=void 0,e}let a=this.newRtcSocket(((e,t,r)=>{const i=Math.floor(Date.now()/1e3);return n.mqtt.token_exp_at<i&&o.imReconnect().then((e=>{n.mqtt=e.mqtt})).catch((e=>{j(e)&&(null==l||l.disconnnect(u.Error,e))})),r.options.username=n.mqtt.username,r.options.clientId=n.mqtt.client_id,r.options.password=n.mqtt.jwt_token,n.mqtt.ws}),i),l=this.im=new lr(o,a,(e=>{this.onNotifyImEvent&&this.onNotifyImEvent(e)}),i);return new Promise((async(e,t)=>{l.once(c.ENABLE_SUCCEED,(()=>{e(r.sid)})),l.once(c.DISCONNECTED,(e=>{this.postDisableIm(),t(e.data)}));try{await a.connect(n.mqtt)}catch(e){t(e)}}))}async disableIm(){if(this.im)try{await this.im.disconnnect(u.Self)}catch(e){this.postDisableIm(),be.error("离开频道报错,强制离开",e)}else be.warn("您尚未启用im频道外消息通道")}postDisableIm(){this.im=null,this.imLogger&&(this.imLogger.shutdown(),this.imLogger=void 0)}onAppShow(e){e?be.warn("页面恢复显示",e):be.warn("页面恢复显示"),this.isAppHide=!1}onAppHide(){be.warn("页面切后台或最小化"),this.isAppHide=!0}async destroy(){if(this.destroyed)return;this.destroyed=!0,dr.liveInstanceCount--;let e=[];for(const t of[...this.channels])await t.leave(s.Self).catch((t=>e.push(t)));if(this.im&&await this.disableIm().catch((t=>e.push(t))),this.releaseGlobalListeners(),e.length>0)throw be.error("destroy 过程中部分清理步骤报错,已尽量清理完毕",e),new N("Some cleanup steps failed during destroy: "+e.map((e=>{var t;return null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e})).join("; "),M.InternalError)}releaseGlobalListeners(){}}hr(dr,"liveInstanceCount",0);var fr=r(3303),pr=r.n(fr);let gr;function mr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e.BaseSRTC_I=dr,e.CommonChannelEventType_I=o,e.isWxxcx_I=m,e.Logger_I=ye,e.SdkError_I=N,e.getSdkLanguage_I=re,e.propAssign_I=E,e.isObject_I=v,e.isString_I=b,e.sleep_I=_,e.retry_I=k,e.dateFormat_I=T,e.genNonce_I=P,e.getHostnameFromUrl_I=A,e.dct_I=I;e.hmac_I=function(e,t){return pr()(e,t).toString()}}(gr||(gr={}));let vr=function(e){return e.OOK="ook",e.WangsuCDN="wangsucdn",e.Seastart="seastart",e}({});class yr extends(h()){constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:be;super(),mr(this,"joinRsp",void 0),mr(this,"published",void 0),mr(this,"subscribed",void 0),mr(this,"ability",void 0),mr(this,"logger",void 0),mr(this,"publisher",void 0),mr(this,"monitorInterval",void 0),mr(this,"prevMetric",void 0),this.joinRsp=e,this.logger=r,this.published={},this.subscribed={},t&&setTimeout((()=>{this.ability?E(this.ability,t):this.ability=t}),0)}async connect(){this.startMonitor()}async publish(e,t,r){let i=0;if(e.kind==K.Audio&&this.ability&&void 0!==this.ability.audioMaxPub&&-1!=this.ability.audioMaxPub){for(const e in this.published){this.published[e].kind==K.Audio&&i++}if(this.ability.audioMaxPub>0&&i>=this.ability.audioMaxPub)throw new N(`Max ${this.ability.audioMaxPub} audio tracks can be published`,M.MaxPublishLimitReached)}else if(e.kind==K.Video&&this.ability&&void 0!==this.ability.videoMaxPub&&-1!=this.ability.videoMaxPub){for(const e in this.published){this.published[e].kind==K.Video&&i++}if(this.ability.videoMaxPub>0&&i>=this.ability.videoMaxPub)throw new N(`Max ${this.ability.videoMaxPub} video tracks can be published`,M.MaxPublishLimitReached)}}setPublisher(e){this.publisher=e}updatePublishInfo(e,t){var r;null===(r=this.publisher)||void 0===r||r.updatePublishInfo(e,t)}async subscribe(e,t){let r=0;if(e.kind==K.Audio&&this.ability&&void 0!==this.ability.audioMaxSub&&-1!=this.ability.audioMaxSub){for(const e in this.subscribed){this.subscribed[e].kind==K.Audio&&r++}if(this.ability.audioMaxSub>0&&r>=this.ability.audioMaxSub)throw new N(`Max ${this.ability.audioMaxSub} audio tracks can be subscribed`,M.MaxSubscribeLimitReached)}else if(e.kind==K.Video&&this.ability&&void 0!==this.ability.videoMaxSub&&-1!=this.ability.videoMaxSub){for(const e in this.subscribed){this.subscribed[e].kind==K.Video&&r++}if(this.ability.videoMaxSub>0&&r>=this.ability.videoMaxSub)throw new N(`Max ${this.ability.videoMaxSub} video tracks can be subscribed`,M.MaxSubscribeLimitReached)}}haveSubscribed(e){return!!this.subscribed[e.id]}async disconnect(){this.stopMonitor();for(const e in this.published){const t=this.published[e];try{await this.unpublish(t.track)}catch(e){this.logger.error(t.track.toString(),"取消发布失败",e)}}for(const e in this.subscribed){const t=this.subscribed[e];try{await this.unsubscribe(t.track)}catch(e){this.logger.error(t.track.toString(),"取消订阅失败")}}this.published={},this.subscribed={}}getMetricSnapshot(){return this.prevMetric}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval((async()=>{try{var e;const t=await this.getMetric();null===(e=this.logger.center)||void 0===e||e.addMetric(t),this.logger.debug("metric",t)}catch(e){this.logger.error("metric","采集metric失败")}}),1e4))}stopMonitor(){this.monitorInterval&&(window.clearInterval(this.monitorInterval),this.monitorInterval=void 0,this.prevMetric=void 0)}}var br=r(6526),wr=r.n(br);let Sr;function _r(){var e,t,r,i,n,o,s,a;(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||void 0===Sr)&&(Sr={...wr().parse(null===(e=navigator)||void 0===e?void 0:e.userAgent),supported:"undefined"!=typeof RTCPeerConnection&&("addTransceiver"in RTCPeerConnection.prototype||"addTrack"in RTCPeerConnection.prototype),secure:isSecureContext,mediaDevices:void 0!==(null===(t=navigator)||void 0===t?void 0:t.mediaDevices),screenshare:void 0!==(null===(r=navigator)||void 0===r||null===(r=r.mediaDevices)||void 0===r?void 0:r.getDisplayMedia),h264Enc:kr.checkVideoCodec("h264"),h264Dec:kr.checkVideoCodec("h264",!1),vp8Enc:kr.checkVideoCodec("vp8"),vp8Dec:kr.checkVideoCodec("vp8",!1),opusEnc:kr.checkAudioCodec("opus"),opusDec:kr.checkAudioCodec("opus",!1),videoEncCodecs:kr.videoEncCodecs(),videoDecCodecs:kr.videoDecCodecs(),audeoEncCodecs:kr.audioEncCodecs(),audeoDecCodecs:kr.audioDecCodecs(),ua:null===(i=navigator)||void 0===i?void 0:i.userAgent,screenWidth:(null===(n=screen)||void 0===n?void 0:n.width)||0,screenHeight:(null===(o=screen)||void 0===o?void 0:o.height)||0,clientWidth:(null===(s=document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.clientWidth)||0,clientHeight:(null===(a=document)||void 0===a||null===(a=a.documentElement)||void 0===a?void 0:a.clientHeight)||0,devicePixelRatio});return Sr}class kr{static async checkCameraPermission(){}static async checkMicPermission(){}static videoEncCodecs(){return"getCapabilities"in RTCRtpSender?RTCRtpSender.getCapabilities("video"):(be.warn("当前环境不支持getCapabilities获取支持的视频编码类型"),null)}static audioEncCodecs(){return"getCapabilities"in RTCRtpSender?RTCRtpSender.getCapabilities("audio"):(be.warn("当前环境不支持getCapabilities获取支持的音频编码类型"),null)}static videoDecCodecs(){return"getCapabilities"in RTCRtpReceiver?RTCRtpReceiver.getCapabilities("video"):(be.warn("当前环境不支持getCapabilities获取支持的视频解码类型"),null)}static audioDecCodecs(){return"getCapabilities"in RTCRtpReceiver?RTCRtpReceiver.getCapabilities("audio"):(be.warn("当前环境不支持getCapabilities获取支持的音频解码类型"),null)}static checkVideoCodec(e){const t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?this.videoEncCodecs():this.videoDecCodecs();if(t)for(const r of t.codecs)if(r.mimeType.toLowerCase().replace("video/","")===e.toLowerCase())return!0;return!1}static checkAudioCodec(e){const t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?this.audioEncCodecs():this.audioDecCodecs();if(t)for(const r of t.codecs)if(r.mimeType.toLowerCase().replace("audio/","")===e.toLowerCase())return!0;return!1}static preferAudioEncCodec(e){let t=this.audioEncCodecs(),r=[],i=[];if(t)for(const n of t.codecs)n.mimeType.toLowerCase().replace("audio/","")===e.toLowerCase()?i.push(n):r.push(n);return i.push(...r),i}static preferVideoEncCodec(e){let t=this.videoEncCodecs(),r=[],i=[],n=[];if(t)for(const o of t.codecs)o.mimeType.toLowerCase().replace("video/","")===e.toLowerCase()?"h264"===e.toLowerCase()&&o.sdpFmtpLine&&o.sdpFmtpLine.includes("profile-level-id=42e01f")?i.push(o):n.push(o):r.push(o);return i.push(...n),i.push(...r),i}}function Er(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Tr{constructor(e,t,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:be;Er(this,"appID",void 0),Er(this,"sid",void 0),Er(this,"clientKey",void 0),Er(this,"serverPrefix",void 0),Er(this,"logger",void 0),this.appID=e,this.sid=t,this.clientKey=r,this.logger=n,"/"!==i.substring(i.length-1)&&(i+="/"),this.serverPrefix=i+"v1/"}async join(e){let t=await this.req("channel/join",{device_type:e.deviceType,device_id:e.deviceID,version:e.version});return t.device_type=e.deviceType,t.device_id=e.deviceID,t.version=e.version,t}async detail(e){let t=await this.req("channel/detail",{with_userlist:e});if(e){let e=t.users;return delete t.users,{channelinfo:t,userinfos:e}}return{channelinfo:t,userinfos:null}}async leave(){return this.req("channel/leave",{})}async heartbeat(){return this.req("channel/heartbeat",{})}async reconnect(e){return this.req("channel/reconnect",{type:e.type})}async updateStream(e){return this.req("channel/update-stream",{stream_tracks:e})}async imConnect(e){return this.req("im/connect",{device_type:e.deviceType,device_id:e.deviceID,version:e.version})}async imReconnect(){return this.req("im/reconnect",{})}async imHeartbeat(){return this.req("im/heartbeat",{})}async imDisconnect(){return this.req("im/disconnect",{})}async req(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=Math.floor(Date.now()/1e3),n=P(16);r.app_id=this.appID,r.sid=this.sid,r.nonce=n,r.timestamp=i+"";let o=this.signature(t,n,i);r.signature=o,r["Accept-Language"]=re();let s=Date.now(),a=(r,i)=>{this.logger[r]("rtc api: "+this.serverPrefix+e,t,i,Date.now()-s+"ms")};return this.http(e,t,{...r,"Content-Type":"application/json"}).then((t=>{if(0==t.code)return a(ge.DEBUG,t),t.data;throw void 0===t.code||null===t.code?new N(`Invalid response: missing code (${e})`,M.MessageDecodeFailed):new N(t.msg,t.code)})).catch((e=>{throw a(ge.ERROR,e),e}))}signature(e,t,r){let i=`app_id=${this.appID}&sid=${this.sid}&nonce=${t}&timestamp=${r}&`+JSON.stringify(e);return pr()(i,this.clientKey).toString()}}class Cr extends Tr{http(e,t,r){return new Promise(((i,n)=>{fetch(this.serverPrefix+e,{method:"POST",headers:r,body:JSON.stringify(t)}).then((e=>{200!=e.status?n(new N(`HTTP ${e.status} ${e.statusText}`.trim(),M.ConnectionFailed)):e.json().then((e=>{i(e)})).catch((e=>{var t;n(new N(`Invalid response: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.MessageDecodeFailed))}))})).catch((e=>{var t;n(new N(`Network request failed: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.ConnectionFailed))}))}))}async cdnURL(e){return(await this.req("cdn/url",e)).url}async sfuConnect(e,t){return this.req("sfu/connect",{publish_offer:e,net:t})}async sfuDisconnect(){return this.req("sfu/disconnect",{})}async sfuOfferPublish(e,t){return this.req("sfu/offer-publish",{offer:e,track_hints:t})}async sfuSubscribe(e){return this.req("sfu/subscribe",{tracks:e})}async sfuAnswerSubscribe(e){return this.req("sfu/answer-subscribe",{answer:e})}}function Pr(e,t,r){var i,n,o;void 0===t&&(t=50),void 0===r&&(r={});var s=null!=(i=r.isImmediate)&&i,a=null!=(n=r.callback)&&n,c=r.maxWait,u=Date.now(),l=[];function h(){if(void 0!==c){var e=Date.now()-u;if(e+t>=c)return c-e}return t}var d=function(){var t=[].slice.call(arguments),r=this;return new Promise((function(i,n){var c=s&&void 0===o;if(void 0!==o&&clearTimeout(o),o=setTimeout((function(){if(o=void 0,u=Date.now(),!s){var i=e.apply(r,t);a&&a(i),l.forEach((function(e){return(0,e.resolve)(i)})),l=[]}}),h()),c){var d=e.apply(r,t);return a&&a(d),i(d)}l.push({resolve:i,reject:n})}))};return d.cancel=function(e){void 0!==o&&clearTimeout(o),l.forEach((function(t){return(0,t.reject)(e)})),l=[]},d}function Ar(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Ir{constructor(){Ar(this,"ctn",{}),Ar(this,"linkids",{})}*[Symbol.iterator](){yield*Object.entries(this.ctn)}set(e,t){this.ctn[e]=t,t.link_id&&(this.linkids[t.link_id]=e)}get(e){return this.ctn[e]}getByLinkid(e){return this.get(this.linkids[e])}del(e){delete this.ctn[e]}clear(){this.ctn={},this.linkids={}}listInfo(e){if(e){let e={};for(const t in this.ctn)e[t]=this.ctn[t].getInfo();return e}{let e=[];for(const t in this.ctn)e.push(this.ctn[t].getInfo());return e}}}var Rr=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.LEAVED="leaved",e}(Rr||{});class xr extends(h()){constructor(e,t,r,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:new ye;super(),Ar(this,"options",void 0),Ar(this,"publishRecords",new Map),Ar(this,"joinRsp",void 0),Ar(this,"me",void 0),Ar(this,"users",void 0),Ar(this,"info",void 0),Ar(this,"heartbeatIntervalID",void 0),Ar(this,"connectState",void 0),Ar(this,"leaving",!1),Ar(this,"logger",void 0),Ar(this,"rtcApi",void 0),Ar(this,"rtcSocket",void 0),Ar(this,"rtcStreamEngine",void 0),Ar(this,"audioMixTrack",void 0),Ar(this,"videoMcuTrack",void 0),Ar(this,"audioMcuTrack",void 0),Ar(this,"eventCB",void 0),Ar(this,"onNotifyEvent",null),Ar(this,"trackMutex",void 0),Ar(this,"trackDebounce",void 0),this.options=e,this.joinRsp=t,this.users=new Ir,this.trackMutex={},this.trackDebounce={},this.logger=s,this.rtcApi=r,this.rtcSocket=n,this.rtcStreamEngine=i,this.rtcStreamEngine.setPublisher(this),this.eventCB=o,this.addSocketListeners(),this.addStreamEngineListeners(),this.connectState=Rr.INIT}async refresh(e){if(!e){const{channelinfo:e,userinfos:t}=await this.rtcApi.detail(!0);if(this.info=e,this.users.clear(),t&&t.forEach((e=>{let t=this.newUser(e);this.users.set(e.uid,t),e.sid==this.joinRsp.sid&&(this.me=t)})),null==this.me){let e={app_id:this.joinRsp.app_id,uid:this.joinRsp.uid,name:"me_fake",device_id:this.joinRsp.device_id,device_type:this.joinRsp.device_type,version:this.joinRsp.version,channel:this.joinRsp.channel,sid:this.joinRsp.sid,is_audience:!0,join_at:Math.floor((new Date).getTime()/1e3)};this.me=this.newUser(e),this.users.set(this.joinRsp.uid,this.me)}this.autoSubscribeExistingTracks()}this.heartbeatIntervalID&&clearInterval(this.heartbeatIntervalID);let t=this.heartbeatIntervalID=setInterval((()=>this.heartbeat()),3e4);this.logger.debug("channel heartbeat interval started",t),this.connectState=Rr.CONNECTED}autoSubscribeExistingTracks(){if(this.options.autoSubscribeAudio||this.options.autoSubscribeVideo)for(const[e,t]of this.users){if(e===this.joinRsp.uid)continue;const r=t.getTracks();for(const t in r){const i=r[t];i.variant||(this.options.autoSubscribeAudio&&i.kind===K.Audio&&this.subscribeRemoteAudioTrack(e,t),this.options.autoSubscribeVideo&&i.kind===K.Video&&this.subscribeRemoteVideoTrack(e,t))}}}checkNotLeft(){if(this.leaving||this.connectState==Rr.LEAVED)throw new N("Channel has been left",M.NotInChannel)}addSocketListeners(){this.onConnected=this.onConnected.bind(this),this.onStartReconnect=this.onStartReconnect.bind(this),this.onChannelMessage=this.onChannelMessage.bind(this),this.rtcSocket.on(sr.CONNECTED,this.onConnected),this.rtcSocket.on(sr.RECONNECTING,this.onStartReconnect),this.rtcSocket.on(sr.CHANNEL_MESSAGE,this.onChannelMessage)}removeSocketListeners(){this.rtcSocket.off(sr.CONNECTED,this.onConnected),this.rtcSocket.off(sr.RECONNECTING,this.onStartReconnect),this.rtcSocket.off(sr.CHANNEL_MESSAGE,this.onChannelMessage)}triggerEvent(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];const n=r[0];try{const t={type:e,data:n};this.emit(e,t),this.onNotifyEvent&&this.onNotifyEvent(t),this.eventCB&&this.eventCB(t)}catch(t){this.logger.error(`事件${e}上层响应出错,请sdk调用者检查`,t,n)}}async heartbeat(){let e=this.heartbeatIntervalID;if(this.connectState!=Rr.CONNECTED)throw this.logger.info(`异常channel心跳,当前频道状态${this.connectState}`),clearInterval(e),new N(`Unexpected channel heartbeat, state: ${this.connectState}`,M.InvalidState);try{await this.rtcApi.heartbeat()}catch(e){this.logger.error("channel心跳失败",e),j(e)&&this.leave(s.Error,e)}this.logger.debug("channel heartbeat interval",e)}async onConnected(){let e=this.connectState;this.logger.warn(e==Rr.RECONNECTING?"会控socket重连成功":"会控socket连接成功");try{this.connectState=Rr.CONNECTED,await this.refresh(e==Rr.RECONNECTING),e==Rr.RECONNECTING?this.triggerEvent(o.RECONNECTED):this.triggerEvent(o.JOIN_SUCCEED,this.getInfo())}catch(e){this.leave(s.Error,e)}}onStartReconnect(){this.logger.warn("会控socket开始重连"),clearInterval(this.heartbeatIntervalID),this.connectState=Rr.RECONNECTING,this.triggerEvent(o.RECONNECTING)}onChannelMessage(e,t){switch(t.type){case we.ChannelUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;this.info.props=e.props,this.info.updated_at=e.updated_at,this.triggerEvent(o.CHANNEL_UPDATE,this.getInfo());break}case we.ChannelDestroy:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;this.leave(s.Destroy);break}case we.UserUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;let r=this.users.get(e.uid);r&&(r.updateInfo(e),this.triggerEvent(e.sid==this.joinRsp.sid?o.ME_UPDATE:o.USER_UPDATE,r.getInfo()));break}case we.UserLeave:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel)return;if(e.sid==this.joinRsp.sid)this.leave(e.reason);else{let t=this.users.get(e.uid);if(!t)return void this.logger.error(`收到用户${e.uid}离开消息,但其不在频道内`);for(const e in t.getTracks()){let r=t.getTracks()[e];this.rtcStreamEngine.haveSubscribed(r)&&this.unsubscribeRemoteTrack(r,0)}this.users.del(e.uid),this.triggerEvent(o.USER_LEAVE,{uid:e.uid,reason:e.reason})}break}case we.UserJoin:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel||e.sid==this.joinRsp.sid)return;let r=this.users.get(e.uid);if(r){this.logger.warn(`收到成员${e.uid}(${e.name})入会消息,但其已经在频道内,先模拟一次离开频道`);for(const e in r.getTracks()){let t=r.getTracks()[e];this.rtcStreamEngine.haveSubscribed(t)&&this.unsubscribeRemoteTrack(t,0)}this.users.del(e.uid),this.triggerEvent(o.USER_LEAVE,{uid:e.uid,reason:s.Error})}r=this.newUser(e),this.users.set(e.uid,r),this.triggerEvent(o.USER_JOIN,r.getInfo());break}case we.StreamUpdate:{const e=t.data;if(!e||e.channel!=this.joinRsp.channel||e.sid==this.joinRsp.sid)return;let r=this.users.get(e.uid),{added:i,updated:n,deleted:s}=r.updateTracks(e.stream_tracks),a=r.getInfo();s.forEach((e=>{this.rtcStreamEngine.haveSubscribed(e)&&this.unsubscribeRemoteTrack(e,0),"stopPlay"in e&&"function"==typeof e.stopPlay&&e.stopPlay(),"removeAllPlayViews"in e&&"function"==typeof e.removeAllPlayViews&&e.removeAllPlayViews(),this.triggerEvent(o.USER_TRACK_REMOVE,{user:a,track:e.getInfo()})})),n.forEach((e=>{this.triggerEvent(o.USER_TRACK_UPDATE,{user:a,track:e.getInfo()})})),i.forEach((e=>{!e.variant&&this.options.autoSubscribeAudio&&e.kind==K.Audio&&this.subscribeRemoteAudioTrack(a.uid,e.id),!e.variant&&this.options.autoSubscribeVideo&&e.kind==K.Video&&this.subscribeRemoteVideoTrack(a.uid,e.id),this.triggerEvent(o.USER_TRACK_ADD,{user:a,track:e.getInfo()})})),this.triggerEvent(o.USER_UPDATE,a);break}case we.Custom:{const r=t.data;if(!r||r.channel!=this.joinRsp.channel)return;r.private=-1!==e.indexOf("/channel-user/"),this.triggerEvent(o.CUSTOM_MSG,r);break}}}getMe(){if(!this.me)throw new N("Local user info is not available yet",M.InvalidState);return this.me}getUser(e){let t=this.users.get(e);if(!t)throw new N(`User not found in channel: ${e}`,M.UserNotFound);return t}getUsersInfo(e){return this.users.listInfo(e)}async leave(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.Self,r=arguments.length>1?arguments[1]:void 0;if(this.connectState!==Rr.LEAVED){this.leaving=!0,clearInterval(this.heartbeatIntervalID),this.removeSocketListeners();try{await this.rtcSocket.close()}catch(e){this.logger.error("断开会控socket报错",e)}try{await this.rtcApi.leave()}catch(e){this.logger.error("调离开频道api报错",e)}try{await this.rtcStreamEngine.disconnect()}catch(e){this.logger.error("断开流媒体引擎报错",e)}this.connectState=Rr.LEAVED,[...this.publishRecords.keys()].forEach((e=>this.deletePublishRecord(e))),this.logger.info("leaved channel",this.joinRsp.channel,t),null===(e=this.logger.center)||void 0===e||e.flush(),this.triggerEvent(o.DISCONNECTED,{reason:t,error:r}),this.removeAllListeners(),this.eventCB=null,this.onNotifyEvent=null}}getInfo(){let e={...this.info};return e.props={...e.props},e}addStreamEngineListeners(){}getStreamEngineVendor(){return this.rtcStreamEngine.vendor()}async getPublishExOption(e,t){return{}}getPublishRecord(e){return this.publishRecords.get(e)}getPublishInfo(e){let t=this.publishRecords.get(e);if(!t)return;let r={...t.info};return r.props={...r.props},r}updatePublishInfo(e,t){let r=this.publishRecords.get(e);r&&E(r.info,t).length>0&&e.emitInfoUpdate()}newPublishRecord(e,t){let r={info:e.getRawInfo(),uid:""};return E(r.info,t),this.publishRecords.set(e,r),e.publishState.retain(this),r}createPublishRecords(e,t){if(e.kind==K.Audio){let r=t;this.newPublishRecord(e,y({desc:r.desc,codec:r.codec,bitrate:r.maxBitrate,props:r.props}))}else{let r=t;this.newPublishRecord(e,y({desc:r.desc,codec:r.codec,width:r.width,height:r.height,fps:r.maxFramerate,bitrate:r.maxBitrate,props:r.props}))}return[e]}getDeletedTracksAfterUnpublish(e){return this.publishRecords.has(e)?[e]:[]}deletePublishRecord(e){this.publishRecords.delete(e),e.publishState.release(this)}resolvePublishOptions(e,t){let r=e.publishState.defaultPublishOptions;if(r&&t!==r&&(t&&E(r,t),t=r),!t)throw new N("Publish options are required",M.InvalidArgument);return t}async publishLocalTrack(e,t){this.checkNotLeft();const r=this.resolvePublishOptions(e,t);if(!r.desc)throw new N("Publish desc is required",M.InvalidArgument);e.publishState.count>0&&!this.getPublishRecord(e)&&this.logger.warn(e.toString(),"已发布到其它频道,本次为多频道发布;多频道期间 track.getInfo() 会抛错,请用 channel.getPublishInfo(track) 查询指定频道内的轨道描述");const i=[...this.publishRecords].find((t=>{let[i,n]=t;return i!==e&&n.info.desc===r.desc}));if(i)throw new N(`desc "${r.desc}" is already used by ${i[0].toString()}; one desc can only be published once`,M.PublishDescConflict);let n=this.getMe();const s=await this.lockTrack(e.id);try{let t=this.createPublishRecords(e,r);try{let t=await this.getPublishExOption(e,r);await this.rtcStreamEngine.publish(e,r,t)}catch(e){throw t.forEach((e=>this.deletePublishRecord(e))),e}try{let e=[...this.publishRecords].filter((e=>{let[r]=e;return!t.includes(r)})).map((e=>{let[,t]=e;return t.info}));e.push(...t.map((e=>this.publishRecords.get(e).info))),await this.rtcApi.updateStream(e),t.forEach((e=>{let t=this.publishRecords.get(e);t.uid=n.uid,n.getTracks()[t.info.id]=e})),n.updateInfo({stream_tracks:e}),this.triggerEvent(o.ME_UPDATE,n.getInfo())}catch(t){throw this.unpublishLocalTrack(e),t}return this.getPublishInfo(e)}finally{s()}}setLogCenter(e){this.logger.center=e}getLogCenter(){return this.logger.center}getLocalTracks(){return this.me?Object.values(this.me.getTracks()):[]}async unpublishLocalTrack(e){let t=this.getMe();const r=await this.lockTrack(e.id);try{let r=[...this.publishRecords.values()].map((e=>e.info));if(!this.publishRecords.has(e))return void this.logger.warn(e.toString()+"已取消发布,无需再次取消发布");let i=this.getDeletedTracksAfterUnpublish(e),n=i.map((e=>this.publishRecords.get(e).info.id)),s=r.filter((e=>!n.includes(e.id)));await this.rtcApi.updateStream(s);try{await this.rtcStreamEngine.unpublish(e),i.forEach((e=>{delete t.getTracks()[this.publishRecords.get(e).info.id],this.deletePublishRecord(e)})),t.updateInfo({stream_tracks:s}),this.triggerEvent(o.ME_UPDATE,t.getInfo())}catch(e){throw await this.rtcApi.updateStream(r),e}}finally{r()}}async getSubscribeExOption(e){return{}}async subscribeRemoteAudioMixTrack(e){this.checkNotLeft();let t=this.audioMixTrack;if(t)if("RemoteAudioMixTrack"===t.__type){let r=t.getFilterUids(),i=[];e&&Array.isArray(e)&&(i=e),r.join(",")!==i.join(",")&&this.rtcStreamEngine.haveSubscribed(t)&&await this.unsubscribeRemoteTrack(t,0)}else t.stop(),this.audioMixTrack=t=void 0;t||(t=this.newRemoteAudioMixTrack(e));const r=await this.lockTrack(t.id);try{if("RemoteAudioMixTrack"===t.__type){let e=await this.getSubscribeExOption(t);await this.rtcStreamEngine.subscribe(t,e)}else if("MockRemoteAudioMixTrack"===t.__type){this.options.autoSubscribeAudio=!0;for(const[e,r]of this.users){if(e===this.joinRsp.uid)continue;let i=r.getTracks();for(const r in i){let n=i[r];n.kind!==K.Audio||t.checkFilter(n)||(this.subscribeRemoteAudioTrack(e,r),t.addTrack(n))}}}return this.audioMixTrack=t,t}finally{r()}}async subscribeRemoteAudioTrack(e,t){this.checkNotLeft();let r=this.getUser(e),i=r.getTrack(t);if(!i)throw D(`Audio track not found: uid=${e}, id=${t}`);if(i.kind!=K.Audio)throw new N(`Track ${e}/${t} is ${i.kind}, not audio`,M.InvalidArgument);const n=e===this.joinRsp.uid?r.spawnTrack(i.getInfo()):i,o=await this.lockTrack(i.id);try{let t=await this.getSubscribeExOption(n);return await this.rtcStreamEngine.subscribe(n,t),e!==this.joinRsp.uid&&this.audioMixTrack&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type&&!this.audioMixTrack.checkFilter(i)&&this.audioMixTrack.addTrack(i),n}finally{o()}}async subscribeRemoteVideoMcuTrack(){this.checkNotLeft();let e=this.videoMcuTrack;e||(e=this.newRemoteVideoMcuTrack());const t=await this.lockTrack(e.id);try{let t=await this.getSubscribeExOption(e);return await this.rtcStreamEngine.subscribe(e,t),this.videoMcuTrack=e,e}finally{t()}}async subscribeRemoteAudioMcuTrack(){this.checkNotLeft();let e=this.audioMcuTrack;e||(e=this.newRemoteAudioMcuTrack());const t=await this.lockTrack(e.id);try{let t=await this.getSubscribeExOption(e);return await this.rtcStreamEngine.subscribe(e,t),this.audioMcuTrack=e,e}finally{t()}}async subscribeRemoteVideoTrack(e,t){var r;this.checkNotLeft();let i=this.getUser(e),n=i.getTrack(t);if(!n)throw D(`Video track not found: uid=${e}, id=${t}`);if(n.kind!=K.Video)throw new N(`Track ${e}/${t} is ${n.kind}, not video`,M.InvalidArgument);const o=e===this.joinRsp.uid?i.spawnTrack(n.getInfo()):n;null===(r=this.trackDebounce[n.id])||void 0===r||r.cancel("subscribe");const s=await this.lockTrack(n.id);try{let e=await this.getSubscribeExOption(o);return await this.rtcStreamEngine.subscribe(o,e),o}finally{s()}}async unsubscribeRemoteTrack(e){if((arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3)<=0){const t=await this.lockTrack(e.id);try{this.audioMixTrack&&this.audioMixTrack===e&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type?(this.audioMixTrack.stop(),this.audioMixTrack=void 0):(await this.rtcStreamEngine.unsubscribe(e),e.kind===K.Audio&&this.audioMixTrack&&"MockRemoteAudioMixTrack"===this.audioMixTrack.__type&&this.audioMixTrack.removeTrack(e))}finally{t()}}else(this.trackDebounce[e.id]=Pr((async()=>{await this.unsubscribeRemoteTrack(e,0)}),2e3))().catch((t=>{this.logger.warn(e.toString()+"取消订阅动作被终止",t)}))}async lockTrack(e){let t=this.trackMutex[e];return t||(this.trackMutex[e]=t=new S),t.lock()}}function Or(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Mr extends o{}Or(Mr,"DEVICE_ADD","device_add"),Or(Mr,"DEVICE_REMOVE","device_remove"),Or(Mr,"TRACK_AUTOPLAY_FAIL","track_autoplay_fail"),Or(Mr,"TRACK_PIP_ENTER","track_pip_enter"),Or(Mr,"TRACK_PIP_EXIT","track_pip_exit"),Or(Mr,"TRACK_POPOUT_OPEN","track_popout_open"),Or(Mr,"TRACK_POPOUT_CLOSE","track_popout_close"),Or(Mr,"CONNECTION_QUALITY_CHANGED","connection_quality_changed"),Or(Mr,"CPU_CONSTRAINED","cpu_constrained"),Or(Mr,"BANDWIDTH_CONSTRAINED","bandwidth_constrained"),Or(Mr,"ACTIVE_SPEAKERS_CHANGED","active_speakers_changed");class Nr extends a{}Or(Nr,"AUTOPLAY_FAIL","autoplay_fail"),Or(Nr,"MSTRACK_REPLACED","mstrack_replaced"),Or(Nr,"RECONNECTING","reconnecting"),Or(Nr,"RECONNECTED","reconnected"),Or(Nr,"PIP_ENTER","pip_enter"),Or(Nr,"PIP_EXIT","pip_exit"),Or(Nr,"POPOUT_OPEN","popout_open"),Or(Nr,"POPOUT_CLOSE","popout_close");let Lr=function(e){return e.ActiveSpeakersChanged="activeSpeakersChanged",e}({}),Br=function(e){return e.Unknown="unknown",e.Excellent="excellent",e.Good="good",e.Poor="poor",e.Lost="lost",e}({}),Dr=function(e){return e.ConnectionQualityChanged="connectionQualityChanged",e.CpuConstrained="cpuConstrained",e.BandwidthConstrained="bandwidthConstrained",e.NetworkUnstable="networkUnstable",e}({});const jr={scoreGood:80,scorePoor:40,scoreLost:20,packetLossWeight:8,emaIncrease:.4,emaDecrease:.8,scoreFloor:30};function Ur(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Fr{constructor(){var e,t,r;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ur(this,"thresholds",void 0),Ur(this,"lostSampleCount",void 0),Ur(this,"constraintSampleCount",void 0),Ur(this,"uplinkScore",100),Ur(this,"downlinkScore",100),Ur(this,"lastEvaluation",void 0),Ur(this,"noTrafficCount",0),Ur(this,"cpuLimitedCount",0),Ur(this,"bwLimitedCount",0),Ur(this,"prevFreezeTotal",0),Ur(this,"hasSample",!1),this.thresholds=null!==(e=i.thresholds)&&void 0!==e?e:jr,this.lostSampleCount=null!==(t=i.lostSampleCount)&&void 0!==t?t:3,this.constraintSampleCount=null!==(r=i.constraintSampleCount)&&void 0!==r?r:2}update(e){const t=this.extractSample(e);this.noTrafficCount=t.hasTraffic?0:this.noTrafficCount+1,this.cpuLimitedCount=t.cpuLimited?this.cpuLimitedCount+1:0,this.bwLimitedCount=t.bwLimited?this.bwLimitedCount+1:0;const r=this.packetScore(t.uplinkLoss,t.uplinkRtt,t.uplinkJitter),i=this.packetScore(t.downlinkLoss,t.downlinkRtt,t.downlinkJitter);this.uplinkScore=this.hasSample?this.emaMerge(this.uplinkScore,r):r,this.downlinkScore=this.hasSample?this.emaMerge(this.downlinkScore,i):i,this.hasSample=!0;const n=this.evaluate(t);return this.lastEvaluation=n,n}shouldEmitCpuConstrained(){return this.cpuLimitedCount===this.constraintSampleCount}shouldEmitBandwidthConstrained(){return this.bwLimitedCount===this.constraintSampleCount}getLastEvaluation(){return this.lastEvaluation}reset(){this.uplinkScore=100,this.downlinkScore=100,this.lastEvaluation=void 0,this.noTrafficCount=0,this.cpuLimitedCount=0,this.bwLimitedCount=0,this.prevFreezeTotal=0,this.hasSample=!1}extractSample(e){var t,r,i,n,o,s,a;const c=e.network,u=[...e.local_audios||[],...e.local_videos||[]],l=[...e.remote_audios||[],...e.remote_videos||[]];let h=null!==(t=null==c?void 0:c.rtt_up)&&void 0!==t?t:0;if(0===h){let e=0,t=0;for(const r of u){const i=r.stats;null!=(null==i?void 0:i.roundTripTime)&&(e+=i.roundTripTime,t++)}t>0&&(h=e/t)}let d=null!==(r=null==c?void 0:c.rtt_down)&&void 0!==r?r:0;0===d&&(d=h);let f=!1,p=!1;for(const e of u){const t=e.stats;"cpu"===(null==t?void 0:t.qualityLimitationReason)&&(f=!0),"bandwidth"===(null==t?void 0:t.qualityLimitationReason)&&(p=!0)}let g=0,m=0;for(const e of u){const t=e.stats;null!=(null==t?void 0:t.jitter)&&(g+=t.jitter,m++)}let v=0,y=0,b=0;for(const e of l){const t=e.stats;null!=(null==t?void 0:t.jitter)&&(v+=t.jitter,y++),"number"==typeof(null==t?void 0:t.freezeCount)&&(b+=t.freezeCount)}const w=0===this.prevFreezeTotal?0:Math.max(0,b-this.prevFreezeTotal);this.prevFreezeTotal=b;const S=null!==(i=null==c?void 0:c.available_outgoing_bitrate)&&void 0!==i?i:0,_=S>0&&null!=c&&c.bitrate_up?c.bitrate_up/S:0,k=u.length>0||l.length>0,E=(null!==(n=null==c?void 0:c.bitrate_up)&&void 0!==n?n:0)>0||(null!==(o=null==c?void 0:c.bitrate_down)&&void 0!==o?o:0)>0;return{timestamp:Date.now(),uplinkLoss:null!==(s=null==c?void 0:c.lossrate_up)&&void 0!==s?s:0,downlinkLoss:null!==(a=null==c?void 0:c.lossrate_down)&&void 0!==a?a:0,uplinkRtt:h,downlinkRtt:d,uplinkJitter:m?g/m:0,downlinkJitter:y?v/y:0,cpuLimited:f,bwLimited:p,hasActiveTrack:k,hasTraffic:E,freezeDelta:w,uplinkBwPressure:_}}packetScore(e,t,r){const i=t/2+2*r;let n;n=i<=160?i/40:(i-120)/10;const o=100-n-e*this.thresholds.packetLossWeight;return Math.max(0,Math.min(100,o))}emaMerge(e,t){const r=t<e?this.thresholds.emaDecrease:this.thresholds.emaIncrease,i=r*t+(1-r)*e;return Math.max(this.thresholds.scoreFloor,i)}scoreToQuality(e){const t=this.thresholds;return e>t.scoreGood?Br.Excellent:e>t.scorePoor?Br.Good:e>t.scoreLost?Br.Poor:Br.Lost}scoreToMos(e){if(e<=0)return 1;if(e>=100)return 4.5;const t=1+.035*e+7e-6*e*(e-60)*(100-e);return Number(Math.max(1,Math.min(4.5,t)).toFixed(2))}evaluate(e){const t=[];if(e.hasActiveTrack&&this.noTrafficCount>=this.lostSampleCount)return t.push(`no traffic for ${this.noTrafficCount} consecutive samples`),{uplink:Br.Lost,downlink:Br.Lost,overall:Br.Lost,mos:1,reasons:t,timestamp:e.timestamp};if(!this.hasSample)return{uplink:Br.Unknown,downlink:Br.Unknown,overall:Br.Unknown,mos:4,reasons:["insufficient samples"],timestamp:e.timestamp};let r=this.scoreToQuality(this.uplinkScore),i=this.scoreToQuality(this.downlinkScore);this.cpuLimitedCount>=this.constraintSampleCount&&(t.push("cpu limited"),r=Wr(r,Br.Poor)),this.bwLimitedCount>=this.constraintSampleCount&&(t.push("bandwidth limited"),r=Wr(r,Br.Poor)),e.uplinkBwPressure>=.9&&(t.push(`uplink bandwidth pressure ${(100*e.uplinkBwPressure).toFixed(0)}%`),r=Wr(r,Br.Good)),e.freezeDelta>0&&e.downlinkLoss>1?(t.push(`downlink freezes ${e.freezeDelta}, loss ${e.downlinkLoss.toFixed(1)}%`),i=Wr(i,Br.Poor)):e.freezeDelta>0&&t.push(`downlink freezes ${e.freezeDelta} (no local loss, likely publisher side)`),t.push(`score up=${this.uplinkScore.toFixed(0)} down=${this.downlinkScore.toFixed(0)}`);return{uplink:r,downlink:i,overall:Wr(r,i),mos:this.scoreToMos(Math.min(this.uplinkScore,this.downlinkScore)),reasons:t,timestamp:e.timestamp}}}const Vr={[Br.Unknown]:0,[Br.Excellent]:1,[Br.Good]:2,[Br.Poor]:3,[Br.Lost]:4};function Wr(e,t){return e===Br.Unknown?t:t===Br.Unknown||Vr[e]>=Vr[t]?e:t}function qr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Hr{static show(e,t){if(this.callbacks.push(t),this.isShowing)return;this.isShowing=!0;const r=document.createElement("style");r.textContent=this.cssTpl,document.head.appendChild(r);const i=ie(),n=document.createElement("div");n.id="autoplay-"+e,n.className="autoplay-dialog-container";const o=document.createElement("div");o.className="autoplay-dialog";const s=document.createElement("div");s.className="autoplay-dialog-content";const a=document.createElement("p");a.textContent=i.message,s.appendChild(a);const c=document.createElement("div");c.className="autoplay-dialog-actions";const u=document.createElement("button");u.className="autoplay-dialog-button",u.textContent=i.confirm,c.appendChild(u),o.appendChild(s),o.appendChild(c),n.appendChild(o),document.body.append(n),n.onclick=()=>{r.remove(),n.remove();const e=this.callbacks.slice();this.callbacks=[],this.isShowing=!1,e.forEach((e=>{try{e()}catch(e){be.error("AutoPlayDialog callback error",e)}}))}}}function Kr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}qr(Hr,"cssTpl",".autoplay-dialog-container {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n}\n\n.autoplay-dialog {\n background-color: white;\n padding: 20px;\n border-radius: 5px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);\n text-align: center;\n}\n\n.autoplay-dialog-content {\n margin-bottom: 20px;\n}\n\n.autoplay-dialog-button {\n background-color: #007bff;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 5px;\n cursor: pointer;\n}"),qr(Hr,"callbacks",[]),qr(Hr,"isShowing",!1);class zr extends Q{constructor(e,t){super(e,t),Kr(this,"mediaStream",void 0),Kr(this,"mediaStreamTrack",void 0),this.onMute=this.onMute.bind(this),this.onUnmute=this.onUnmute.bind(this),this.onEnded=this.onEnded.bind(this),this.mediaStream=new MediaStream}addMsTrackListeners(e){e.addEventListener("mute",this.onMute),e.addEventListener("unmute",this.onUnmute),e.addEventListener("ended",this.onEnded)}removeMsTrackListeners(e){e.removeEventListener("mute",this.onMute),e.removeEventListener("unmute",this.onUnmute),e.removeEventListener("ended",this.onEnded)}onMute(){be.info(this.toString(),"muted"),this.emit(a.MUTED,this)}onUnmute(){be.info(this.toString(),"unmuted"),this.emit(a.UNMUTED,this)}onEnded(){be.info(this.toString(),"ended"),this.emit(a.ENDED,this)}setMediaStreamTrack(e){let t=this.mediaStreamTrack;if(t!=e){if(t&&(this.mediaStream.removeTrack(t),this.removeMsTrackListeners(t)),this.mediaStreamTrack=e,e){this.mediaStream.addTrack(e),this.addMsTrackListeners(e);let t=e.getSettings();be.debug(this.toString(),"实际采集到的mstrack设置",t)}this.emit(Nr.MSTRACK_REPLACED,this,t)}}getMediaStreamTrack(){return this.mediaStreamTrack}getMediaStream(){return this.mediaStream}}class $r{constructor(e,t){Kr(this,"track",void 0),Kr(this,"rtpReceiver",void 0),Kr(this,"targetMs",void 0),this.track=e,this.targetMs=t}setRtpReceiver(e){if(!e)return this.apply(void 0),void(this.rtpReceiver=void 0);this.rtpReceiver=e,this.apply(this.targetMs)}setTarget(e){this.targetMs=e,this.apply(e)}getTarget(){return this.targetMs}apply(e){const t=this.rtpReceiver;if(t)try{"jitterBufferTarget"in t&&(t.jitterBufferTarget=null==e?null:Math.min(Math.max(e,0),4e3)),"playoutDelayHint"in t&&(t.playoutDelayHint=null==e?void 0:e/1e3)}catch(e){be.warn(this.track.toString(),"设置 jitterBufferTarget 失败",e)}}}class Gr{constructor(e){Kr(this,"track",void 0),Kr(this,"audioElements",void 0),this.track=e,this.audioElements=[]}isPlaying(){return this.audioElements.length>0}destroyAudioElement(e){e.srcObject=null,e.remove()}async startPlay(e){this.stopPlay();let t=this.track.getMediaStreamTrack();if(!t)throw new N(this.track.toString()+" has no MediaStreamTrack, cannot play audio",M.TrackNotCaptured);const r=t.context;if(r&&"running"!==r.state){try{await Promise.race([r.resume(),new Promise(((e,t)=>setTimeout((()=>t(new Error("resume timeout"))),500)))])}catch(e){be.warn("混音音频上下文恢复失败或超时",e)}if("running"!==r.state)return!1}let i=document.createElement("audio");return i.autoplay=!1,i.srcObject=this.track.getMediaStream(),i.style.display="none",document.body.appendChild(i),null!=e&&e.deviceId&&("setSinkId"in i?await i.setSinkId(e.deviceId):be.error("当前环境不支持setSinkId,将从默认扬声器播放")),null!=e&&e.volume&&(i.volume=e.volume),i.addEventListener("pause",(()=>{i.play().catch((e=>{console.error("音频暂停,尝试恢复播放失败",e)}))})),new Promise((async(e,t)=>{let r=setTimeout((()=>{be.warn("音频play超时未响应,默认视为浏览器权限问题处理"),this.destroyAudioElement(i),e(!1)}),1e3);try{await i.play(),clearTimeout(r),this.audioElements.push(i),e(!0)}catch(n){clearTimeout(r),this.destroyAudioElement(i),n instanceof DOMException&&"NotAllowedError"===n.name?e(!1):t(new N(this.track.toString()+" failed to play: "+n,M.PlayFailed))}}))}stopPlay(){this.audioElements.forEach((e=>this.destroyAudioElement(e))),this.audioElements=[]}setVolume(e){this.audioElements.forEach((t=>t.volume=e))}}class Qr{constructor(e,t){Kr(this,"track",void 0),Kr(this,"videoElements",void 0),Kr(this,"resizeObserver",void 0),Kr(this,"intersectionObserver",void 0),Kr(this,"pipStates",new Map),Kr(this,"popOutStates",new Map),Kr(this,"hiddenOriginViews",new Map),Kr(this,"playViewStates",new Map),Kr(this,"detachedViewStates",new Map),Kr(this,"elementIds",new WeakMap),Kr(this,"nextElementId",0),Kr(this,"isAppHidden","undefined"!=typeof document&&"hidden"===document.visibilityState),Kr(this,"onAdaptiveStateChange",void 0),Kr(this,"onAppShowHide",(()=>{this.isAppHidden="hidden"===document.visibilityState,this.emitAdaptiveState(),"hidden"!==document.visibilityState&&this.videoElements.forEach((e=>{e.play().catch((e=>{console.error("视频播放失败",e)}))}))})),this.track=e,this.videoElements=[],this.onAdaptiveStateChange=t,this.track.on(Nr.INFO_UPDATE,(()=>{this.videoElements.forEach((e=>{this.freshTransform(e)}))})),this.track.on(Nr.MSTRACK_REPLACED,(()=>{this.videoElements.forEach((e=>{this.freshTransform(e)}))})),this.resizeObserver=new ResizeObserver((e=>{for(const t of e){const e=this.videoElements.find((e=>e.parentElement===t.target));e&&(this.freshTransform(e),this.updatePlayViewState(t.target,{width:t.target.clientWidth,height:t.target.clientHeight}))}})),"undefined"!=typeof IntersectionObserver&&(this.intersectionObserver=new IntersectionObserver((e=>{for(const t of e)this.updatePlayViewState(t.target,{visible:t.isIntersecting&&this.isElementRenderable(t.target)})}),{threshold:[0,.01]}))}addPlayView(e){var t;if(!this.track.getMediaStreamTrack())throw new N(this.track.toString()+" has no MediaStreamTrack, cannot add play view",M.TrackNotCaptured);if(this.videoElements.find((t=>t.parentElement==e)))return;"static"===getComputedStyle(e).position&&(e.style.position="relative"),e.style.overflow="hidden";let r=document.createElement("video");var i,n,o,s;r.muted=!0,r.controls=!1,r.playsInline=!0,r.style.objectFit="contain",r.onloadedmetadata=()=>{this.freshTransform(r)},r.srcObject=this.track.getMediaStream(),"safari"===(null===(n=_r().browser)||void 0===n||null===(n=n.name)||void 0===n?void 0:n.toLowerCase())||"firefox"===(null===(i=_r())||void 0===i||null===(i=i.browser)||void 0===i||null===(i=i.name)||void 0===i?void 0:i.toLowerCase())?setTimeout((()=>{r.srcObject=this.track.getMediaStream(),r.play().catch((e=>{console.error("视频播放失败",e)}))}),0):r.autoplay=!0,("miniprogram"===window.__wxjs_environment||(null===(s=navigator)||void 0===s?void 0:s.userAgent.toLowerCase().includes("miniprogram"))||(null===(o=navigator)||void 0===o?void 0:o.userAgent.toLowerCase().includes("micromessenger")))&&r.play().catch((e=>{Hr.show(this.track.id,(()=>{r.play().catch((e=>{console.error("视频播放失败",e)}))}))})),r.addEventListener("pause",(()=>{r.play().catch((e=>{console.error("视频暂停,尝试恢复播放失败",e)}))})),e.appendChild(r),this.videoElements.push(r),this.resizeObserver.observe(e),null===(t=this.intersectionObserver)||void 0===t||t.observe(e),this.playViewStates.set(e,this.snapshotPlayViewState(e)),this.emitAdaptiveState(),1==this.videoElements.length&&this.watchAppShowHide()}watchAppShowHide(){document.addEventListener("visibilitychange",this.onAppShowHide)}unwatchAppShowHide(){document.removeEventListener("visibilitychange",this.onAppShowHide)}needSwapDimensions(e){return 1129136434===e||1129136441===e}freshTransform(e){const t=e.parentElement;if(!t)return;const r=this.track.angle,i=t.clientWidth,n=t.clientHeight;switch(e.style.position="absolute",e.style.left="50%",e.style.top="50%",this.needSwapDimensions(r)?(e.style.width=`${n}px`,e.style.height=`${i}px`):(e.style.width=`${i}px`,e.style.height=`${n}px`),r){case 1129136434:e.style.transform="translate(-50%, -50%) rotate(270deg)";break;case 1129136433:e.style.transform="translate(-50%, -50%) rotate(180deg)";break;case 1129136441:e.style.transform="translate(-50%, -50%) rotateY(180deg) rotate(-90deg)";break;default:e.style.transform="translate(-50%, -50%)"}this.shouldMirrorView()&&(e.style.transform+=" scaleX(-1)")}shouldMirrorView(){const e=this.track;return"function"==typeof e.isMirrored&&e.isMirrored()}refreshTransform(){this.videoElements.forEach((e=>this.freshTransform(e))),this.popOutStates.forEach((e=>{this.freshTransformForPopOut(e.video,e.handle.window)})),this.pipStates.forEach((e=>{e.pipVideo&&e.pipWindow&&this.freshTransformForPopOut(e.pipVideo,e.pipWindow)}))}hasPlayView(){return this.videoElements.length>0}removePlayView(e){this.cleanupPipState(e),this.cleanupPopOutState(e),this.restoreOriginView(e);let t=this.videoElements.findIndex((t=>t.parentElement==e));var r;t>=0&&(this.resizeObserver.unobserve(e),null===(r=this.intersectionObserver)||void 0===r||r.unobserve(e),this.playViewStates.delete(e),this.videoElements[t].remove(),this.videoElements.splice(t,1),this.emitAdaptiveState());0==this.videoElements.length&&this.unwatchAppShowHide()}removeAllPlayViews(){this.hiddenOriginViews.clear(),this.exitAllPictureInPicture(),this.closeAllPopOutWindows(),this.videoElements.forEach((e=>{var t;e.parentElement&&(this.resizeObserver.unobserve(e.parentElement),null===(t=this.intersectionObserver)||void 0===t||t.unobserve(e.parentElement));e.remove()})),this.videoElements=[],this.playViewStates.clear(),this.detachedViewStates.clear(),this.unwatchAppShowHide(),this.emitAdaptiveState()}destroy(){var e;this.removeAllPlayViews(),this.resizeObserver.disconnect(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect()}async enterPictureInPicture(e,t){const r=this.videoElements.find((t=>t.parentElement===e));if(!r)throw new N(this.track.toString()+": no video found for this container, call addPlayView first",M.PlayViewNotFound);this.pipStates.has(e)&&await this.exitPictureInPicture(e);const i=!1!==(null==t?void 0:t.preferDocumentPip),n=(null==t?void 0:t.width)||320,o=(null==t?void 0:t.height)||240,s=!1!==(null==t?void 0:t.hideOriginView);if(i&&"documentPictureInPicture"in window)return this.enterDocumentPip(e,n,o,s);if("requestPictureInPicture"in r)return this.enterVideoPip(e,r);throw new N("Picture-in-Picture is not supported by this browser",M.FeatureNotSupported)}async enterDocumentPip(e,t,r,i){const n=window.documentPictureInPicture,o=await n.requestWindow({width:t,height:r}),s=o.document.createElement("style");s.textContent="\n body { margin: 0; background: #000; overflow: hidden; width: 100vw; height: 100vh; }\n video { width: 100%; height: 100%; object-fit: contain; }\n ",o.document.head.appendChild(s);const a=o.document.createElement("video");a.muted=!0,a.autoplay=!0,a.playsInline=!0,a.srcObject=this.track.getMediaStream(),o.document.body.appendChild(a);const c=this.getDetachedViewKey("doc-pip",e),u=()=>{this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState)};o.document.addEventListener("visibilitychange",u);const l=new ResizeObserver((()=>{this.freshTransformForPopOut(a,o),this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState)}));l.observe(o.document.body),this.updateDetachedViewState(c,o.innerWidth,o.innerHeight,"hidden"!==o.document.visibilityState);const h=()=>{a.srcObject=this.track.getMediaStream()};this.track.on(Nr.MSTRACK_REPLACED,h);const d={type:"document-pip",pipWindow:o,exit:async()=>{this.cleanupPipState(e)}},f=()=>{this.cleanupPipState(e)};return o.addEventListener("pagehide",f),i&&this.hideOriginView(e),this.pipStates.set(e,{container:e,handle:d,pipVideo:a,pipWindow:o,hideOriginView:i,cleanup:()=>{o.removeEventListener("pagehide",f),o.document.removeEventListener("visibilitychange",u),this.track.off(Nr.MSTRACK_REPLACED,h),l.disconnect(),this.removeDetachedViewState(c),a.srcObject=null,o.closed||o.close(),i&&this.restoreOriginView(e),this.track.emit(Nr.PIP_EXIT,this.track)}}),this.track.emit(Nr.PIP_ENTER,this.track),this.emitAdaptiveState(),d}async enterVideoPip(e,t){await t.requestPictureInPicture();const r={type:"video-pip",exit:async()=>{this.cleanupPipState(e)}},i=()=>{this.cleanupPipState(e)};return t.addEventListener("leavepictureinpicture",i),this.pipStates.set(e,{container:e,handle:r,hideOriginView:!1,cleanup:()=>{t.removeEventListener("leavepictureinpicture",i),document.pictureInPictureElement===t&&document.exitPictureInPicture().catch((()=>{})),this.track.emit(Nr.PIP_EXIT,this.track)}}),this.track.emit(Nr.PIP_ENTER,this.track),this.updateDetachedViewState(this.getDetachedViewKey("video-pip",e),t.clientWidth,t.clientHeight,!0),this.emitAdaptiveState(),r}cleanupPipState(e){const t=this.pipStates.get(e);t&&(this.pipStates.delete(e),this.removeDetachedViewState(this.getDetachedViewKey("doc-pip",e)),this.removeDetachedViewState(this.getDetachedViewKey("video-pip",e)),t.cleanup(),this.emitAdaptiveState())}async exitPictureInPicture(e){this.cleanupPipState(e)}isPictureInPicture(e){return this.pipStates.has(e)}exitAllPictureInPicture(){[...this.pipStates.keys()].forEach((e=>this.cleanupPipState(e)))}popOutToWindow(e,t){if(!this.videoElements.find((t=>t.parentElement===e)))throw new N(this.track.toString()+": no video found for this container, call addPlayView first",M.PlayViewNotFound);this.popOutStates.has(e)&&this.closePopOutWindow(e);const r=(null==t?void 0:t.width)||640,i=(null==t?void 0:t.height)||480,n=(null==t?void 0:t.title)||this.track.toString(),o=Math.round((screen.width-r)/2),s=Math.round((screen.height-i)/2),a=window.open("","_blank",`width=${r},height=${i},left=${o},top=${s},resizable=yes,scrollbars=no`);if(!a)throw new N("Popup window was blocked by the browser",M.PopupBlocked);a.document.title=n;const c=a.document.createElement("style");c.textContent="\n body { margin: 0; background: #000; overflow: hidden; width: 100vw; height: 100vh; }\n video { width: 100%; height: 100%; object-fit: contain; }\n ",a.document.head.appendChild(c);const u=a.document.createElement("video");u.muted=!0,u.autoplay=!0,u.playsInline=!0,u.srcObject=this.track.getMediaStream(),a.document.body.appendChild(u);const l=this.getDetachedViewKey("popout",e),h=()=>{this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState)};a.document.addEventListener("visibilitychange",h);const d=new ResizeObserver((()=>{this.freshTransformForPopOut(u,a),this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState)}));d.observe(a.document.body),this.updateDetachedViewState(l,a.innerWidth,a.innerHeight,"hidden"!==a.document.visibilityState);const f={window:a,moveBack:t=>{this.moveBackFromPopOut(e,t)},close:()=>{this.closePopOutWindow(e)}},p=()=>{this.cleanupPopOutState(e)};a.addEventListener("beforeunload",p);const g=()=>{u.srcObject=this.track.getMediaStream()};return this.track.on(Nr.MSTRACK_REPLACED,g),this.popOutStates.set(e,{originContainer:e,handle:f,video:u,hideOriginView:!1!==(null==t?void 0:t.hideOriginView),cleanup:()=>{this.track.off(Nr.MSTRACK_REPLACED,g),a.removeEventListener("beforeunload",p),a.document.removeEventListener("visibilitychange",h),d.disconnect(),this.removeDetachedViewState(l),u.srcObject=null,a.closed||a.close(),!1!==(null==t?void 0:t.hideOriginView)&&this.restoreOriginView(e),this.track.emit(Nr.POPOUT_CLOSE,this.track)}}),!1!==(null==t?void 0:t.hideOriginView)&&this.hideOriginView(e),this.track.emit(Nr.POPOUT_OPEN,this.track),this.emitAdaptiveState(),f}freshTransformForPopOut(e,t){const r=this.track.angle,i=t.innerWidth,n=t.innerHeight;switch(e.style.position="absolute",e.style.left="50%",e.style.top="50%",this.needSwapDimensions(r)?(e.style.width=`${n}px`,e.style.height=`${i}px`):(e.style.width=`${i}px`,e.style.height=`${n}px`),r){case 1129136434:e.style.transform="translate(-50%, -50%) rotate(270deg)";break;case 1129136433:e.style.transform="translate(-50%, -50%) rotate(180deg)";break;case 1129136441:e.style.transform="translate(-50%, -50%) rotateY(180deg) rotate(-90deg)";break;default:e.style.transform="translate(-50%, -50%)"}this.shouldMirrorView()&&(e.style.transform+=" scaleX(-1)")}moveBackFromPopOut(e,t){const r=this.popOutStates.get(e);r&&(r.cleanup(),this.popOutStates.delete(e),this.videoElements.find((e=>e.parentElement===t))||this.addPlayView(t))}closePopOutWindow(e){this.cleanupPopOutState(e)}cleanupPopOutState(e){const t=this.popOutStates.get(e);t&&(this.popOutStates.delete(e),this.removeDetachedViewState(this.getDetachedViewKey("popout",e)),t.cleanup(),this.emitAdaptiveState())}isPopOut(e){return this.popOutStates.has(e)}closeAllPopOutWindows(){[...this.popOutStates.keys()].forEach((e=>this.cleanupPopOutState(e)))}hideOriginView(e){const t=this.hiddenOriginViews.get(e);if(t)return void t.count++;const r=this.videoElements.find((t=>t.parentElement===e));r&&(this.hiddenOriginViews.set(e,{video:r,count:1,display:r.style.display}),r.style.display="none",this.updatePlayViewState(e,{visible:!1}))}restoreOriginView(e){const t=this.hiddenOriginViews.get(e);t&&(t.count--,t.count>0||(t.video.style.display=t.display,this.hiddenOriginViews.delete(e),this.freshTransform(t.video),this.updatePlayViewState(e,{visible:this.isElementVisible(e)}),t.video.play().catch((e=>{console.error("视频播放失败",e)}))))}refreshAdaptiveState(){this.emitAdaptiveState()}updatePlayViewState(e,t){const r=this.playViewStates.get(e)||this.snapshotPlayViewState(e);this.playViewStates.set(e,{...r,...t}),this.emitAdaptiveState()}updateDetachedViewState(e,t,r,i){this.detachedViewStates.set(e,{width:t,height:r,visible:i}),this.emitAdaptiveState()}removeDetachedViewState(e){this.detachedViewStates.delete(e)&&this.emitAdaptiveState()}emitAdaptiveState(){if(!this.onAdaptiveStateChange)return;let e=!1,t=0,r=0,i=0,n=!1;const o=(n,o)=>{if(!o)return;e=!0;const s=n.width*n.height;s>=i&&(i=s,t=n.width,r=n.height)};for(const e of this.playViewStates.values())o(e,e.visible&&!this.isAppHidden);for(const e of this.detachedViewStates.values())e.visible&&(n=!0),o(e,e.visible);this.onAdaptiveStateChange({viewCount:this.playViewStates.size+this.detachedViewStates.size,visible:e,width:t,height:r,inBackground:this.isAppHidden&&!n})}snapshotPlayViewState(e){return{width:e.clientWidth,height:e.clientHeight,visible:this.isElementVisible(e)}}getDetachedViewKey(e,t){let r=this.elementIds.get(t);return void 0===r&&(r=++this.nextElementId,this.elementIds.set(t,r)),`${e}:${this.track.id}:${r}`}isElementRenderable(e){const t=getComputedStyle(e);return!e.hidden&&"none"!==t.display&&"hidden"!==t.visibility}isElementVisible(e){if(!this.isElementRenderable(e))return!1;const t=e.getBoundingClientRect();return!(t.width<=0||t.height<=0)&&(t.bottom>0&&t.right>0&&t.top<window.innerHeight&&t.left<window.innerWidth)}}function Jr(e){const t=new AudioContext,r=t.createMediaStreamDestination(),i=r.stream.getAudioTracks()[0];if(!i)throw new N("Failed to create mixed audio track",M.InternalError);i.context=t,i.trackCount=0;const n=t.createGain();let o,s;if(n.gain.value=0,n.connect(t.destination),i.speakerGain=n,e){o=t.createAnalyser(),o.fftSize=256;const r=o.frequencyBinCount,i=new Uint8Array(r),n=()=>{s=requestAnimationFrame(n),o.getByteFrequencyData(i);const t=e.canvas;e.fillStyle="rgb(0, 0, 0)",e.fillRect(0,0,t.width,t.height);const a=t.width/r*2.5;let c,u=0;for(let n=0;n<r;n++)c=i[n]/255*t.height,e.fillStyle=`rgb(${c+100}, 50, 50)`,e.fillRect(u,t.height-c/2,a,c/2),u+=a+1};n()}const a=new Map;return i.addTrack=e=>{if("ended"===e.readyState||!t||a.has(e))return;const s=new MediaStream([e]),c=t.createMediaStreamSource(s);o&&c.connect(o),c.connect(r),c.connect(n),a.set(e,{source:c,stream:s}),e.addEventListener("ended",(()=>{i.removeTrack(e)})),i.trackCount++},i.removeTrack=e=>{const t=a.get(e);t&&(t.source.disconnect(),a.delete(e),i.trackCount--)},i}class Yr{constructor(){Kr(this,"mediaStreamTrack",void 0),Kr(this,"tracks",void 0),Kr(this,"contextResumeRequested",void 0),Kr(this,"speakerPlaying",void 0),Kr(this,"warmupElements",void 0),Kr(this,"onTrackMsTrackReplace",((e,t)=>{var r;t&&(null===(r=this.mediaStreamTrack)||void 0===r||r.removeTrack(t));this.releaseWarmupElement(e.id);const i=e.getMediaStreamTrack();var n;i&&(e instanceof Zr&&this.warnupRemoteAudioTrack(e),null===(n=this.mediaStreamTrack)||void 0===n||n.addTrack(i),this.requestContextResumeIfNeeded())})),this.mediaStreamTrack=Jr(),this.tracks={},this.contextResumeRequested=!1,this.speakerPlaying=!1,this.warmupElements={}}requestContextResumeIfNeeded(){var e;const t=null===(e=this.mediaStreamTrack)||void 0===e?void 0:e.context;t&&"running"!==t.state&&!this.contextResumeRequested&&(this.contextResumeRequested=!0,t.resume().catch((e=>{be.warn("混音音频上下文自动恢复失败,等待用户交互",e),Hr.show(this.mediaStreamTrack.id,(async()=>{try{"suspended"===t.state&&await t.resume()}catch(e){be.error("混音音频上下文恢复失败",e)}}))})).finally((()=>{this.contextResumeRequested=!1})))}warnupRemoteAudioTrack(e){const t=e.getMediaStreamTrack();if(!t||e.isPlaying()||this.warmupElements[e.id])return;const r=new Audio;r.muted=!0,r.srcObject=new MediaStream([t]),this.warmupElements[e.id]=r}releaseWarmupElement(e){const t=this.warmupElements[e];t&&(t.srcObject=null,delete this.warmupElements[e])}addTrack(e){if(this.tracks[e.id])return;const t=e.getMediaStreamTrack();var r;t&&(e instanceof Zr&&this.warnupRemoteAudioTrack(e),null===(r=this.mediaStreamTrack)||void 0===r||r.addTrack(t),this.requestContextResumeIfNeeded());e.on(Nr.MSTRACK_REPLACED,this.onTrackMsTrackReplace),this.tracks[e.id]=new WeakRef(e)}removeTrack(e){let t=e.getMediaStreamTrack();var r;t&&(null===(r=this.mediaStreamTrack)||void 0===r||r.removeTrack(t));e.off(Nr.MSTRACK_REPLACED,this.onTrackMsTrackReplace),this.releaseWarmupElement(e.id),delete this.tracks[e.id]}async startSpeakerPlay(e){var t;const r=null===(t=this.mediaStreamTrack)||void 0===t?void 0:t.context;if(!r)return!1;if(null!=e&&e.deviceId){if("function"!=typeof r.setSinkId)return"unsupported-sink";try{await r.setSinkId(e.deviceId)}catch(e){return be.warn("混音输出设备切换失败",e),"unsupported-sink"}}if("running"!==r.state){try{await Promise.race([r.resume(),new Promise(((e,t)=>setTimeout((()=>t(new Error("resume timeout"))),500)))])}catch(e){be.warn("混音音频上下文恢复失败或超时",e)}if("running"!==r.state)return!1}return this.mediaStreamTrack.speakerGain.gain.value=null!=(null==e?void 0:e.volume)?e.volume:1,this.speakerPlaying=!0,!0}stopSpeakerPlay(){var e;null!==(e=this.mediaStreamTrack)&&void 0!==e&&e.speakerGain&&(this.mediaStreamTrack.speakerGain.gain.value=0),this.speakerPlaying=!1}isSpeakerPlaying(){return this.speakerPlaying}setSpeakerVolume(e){var t;this.speakerPlaying&&null!==(t=this.mediaStreamTrack)&&void 0!==t&&t.speakerGain&&(this.mediaStreamTrack.speakerGain.gain.value=e)}getTrackCount(){return Object.keys(this.tracks).length}stop(){var e,t;for(const e in this.tracks){const t=this.tracks[e].deref();t&&this.removeTrack(t)}this.tracks={},Object.keys(this.warmupElements).forEach((e=>this.releaseWarmupElement(e))),null===(e=this.mediaStreamTrack)||void 0===e||e.context.close(),null===(t=this.mediaStreamTrack)||void 0===t||t.stop()}getMixedMediaStreamTrack(){return this.mediaStreamTrack}}function Xr(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Zr extends zr{constructor(e,t){super(e,t),Xr(this,"playTrait",void 0),Xr(this,"jitterTrait",void 0),this.playTrait=new Gr(this),this.jitterTrait=new $r(this),this.on(a.ENDED,(()=>{this.jitterTrait.setRtpReceiver(void 0)}))}setRtpReceiver(e){this.jitterTrait.setRtpReceiver(e)}setJitterBufferTarget(e){this.jitterTrait.setTarget(e)}getJitterBufferTarget(){return this.jitterTrait.getTarget()}strPrefix(){return"RemoteAudioTrack"}isPlaying(){return this.playTrait.isPlaying()}async startPlay(e){await this.playTrait.startPlay(e)||(e&&e.disableAutoPlayDialog?this.emit(Nr.AUTOPLAY_FAIL,this):Hr.show(this.id,(()=>{this.startPlay(e)})))}stopPlay(){this.playTrait.stopPlay()}}class ei extends Zr{constructor(e,t){super(e,""),Xr(this,"__type","RemoteAudioMixTrack"),Xr(this,"filterUids",void 0),this.filterUids=t||[]}getFilterUids(){return this.filterUids}strPrefix(){return"RemoteAudioMixTrack"}}class ti extends Zr{constructor(e,t){super(e,""),Xr(this,"__type","MockRemoteAudioMixTrack"),Xr(this,"audioMixTrait",void 0),Xr(this,"filter",void 0),this.audioMixTrait=new Yr,this.setMediaStreamTrack(this.audioMixTrait.getMixedMediaStreamTrack()),this.filter=t}checkFilter(e){return!!this.filter&&this.filter(e)}addTrack(e){this.checkFilter(e)||this.audioMixTrait.addTrack(e)}removeTrack(e){this.audioMixTrait.removeTrack(e)}async startPlay(e){const t=await this.audioMixTrait.startSpeakerPlay(e);if("unsupported-sink"===t)return this.audioMixTrait.stopSpeakerPlay(),super.startPlay(e);!1===t&&(e&&e.disableAutoPlayDialog?this.emit(Nr.AUTOPLAY_FAIL,this):Hr.show(this.id,(()=>{this.startPlay(e)})))}stopPlay(){this.audioMixTrait.stopSpeakerPlay(),super.stopPlay()}isPlaying(){return this.audioMixTrait.isSpeakerPlaying()||super.isPlaying()}stop(){this.audioMixTrait.stop()}strPrefix(){return"LocalMixedRemoteAudioTrack"}}class ri extends Zr{constructor(){super({id:W,desc:"频道音频合成流",kind:K.Audio},H)}strPrefix(){return"RemoteAudioMcuTrack"}}class ii extends zr{constructor(e,t){super(e,t),Xr(this,"playTrait",void 0),Xr(this,"adaptiveStreamController",void 0),Xr(this,"jitterTrait",void 0),this.playTrait=new Qr(this,(e=>{var t;null===(t=this.adaptiveStreamController)||void 0===t||t.call(this,e)})),this.jitterTrait=new $r(this),this.on(a.ENDED,(()=>{this.jitterTrait.setRtpReceiver(void 0)}))}strPrefix(){return"RemoteVideoTrack"}addPlayView(e){this.playTrait.addPlayView(e)}hasPlayView(){return this.playTrait.hasPlayView()}removePlayView(e){this.playTrait.removePlayView(e)}removeAllPlayViews(){this.playTrait.removeAllPlayViews()}async enterPictureInPicture(e,t){return this.playTrait.enterPictureInPicture(e,t)}async exitPictureInPicture(e){return this.playTrait.exitPictureInPicture(e)}isPictureInPicture(e){return this.playTrait.isPictureInPicture(e)}popOutToWindow(e,t){return this.playTrait.popOutToWindow(e,t)}closePopOutWindow(e){this.playTrait.closePopOutWindow(e)}isPopOut(e){return this.playTrait.isPopOut(e)}setAdaptiveStreamController(e){this.adaptiveStreamController=e,this.playTrait.refreshAdaptiveState()}setRtpReceiver(e){this.jitterTrait.setRtpReceiver(e)}setJitterBufferTarget(e){this.jitterTrait.setTarget(e)}getJitterBufferTarget(){return this.jitterTrait.getTarget()}}class ni extends ii{constructor(){super({id:q,desc:"视频合成流",kind:K.Video},H)}strPrefix(){return"RemoteVideoMcuTrack"}}function oi(e,t){if(!t)return 0;let r,i;return"bytesReceived"in e?(r=e.bytesReceived,i=t.bytesReceived):"bytesSent"in e&&(r=e.bytesSent,i=t.bytesSent),void 0===r||void 0===i||void 0===e.timestamp||void 0===t.timestamp||e.timestamp<=t.timestamp?0:C(8*(r-i)/(e.timestamp-t.timestamp),2)}function si(e){let t,r;return e.forEach((e=>{"candidate-pair"===e.type&&(e.nominated&&"succeeded"===e.state?t&&!e.selected||(t=e):"succeeded"!==e.state||r||(r=e))})),t||r}function ai(e,t){var r,i,n,o;if(!t)return;const s=(null!==(r=e.jitterBufferDelay)&&void 0!==r?r:0)-(null!==(i=t.jitterBufferDelay)&&void 0!==i?i:0),a=(null!==(n=e.jitterBufferEmittedCount)&&void 0!==n?n:0)-(null!==(o=t.jitterBufferEmittedCount)&&void 0!==o?o:0);return a<=0?void 0:C(s/a,2)}function ci(e,t){return t?void 0===e.framesDecoded||void 0===t.framesDecoded||void 0===e.timestamp||void 0===t.timestamp||e.timestamp<=t.timestamp?0:Math.round(1e3*(e.framesDecoded-t.framesDecoded)/(e.timestamp-t.timestamp)):0}function ui(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class li extends yr{constructor(){super(...arguments),ui(this,"qualityMonitor",new Fr),ui(this,"lastBroadcastQuality",Br.Unknown),ui(this,"lastQualityEvaluation",void 0),ui(this,"qualityInterval",void 0),ui(this,"dftPCConfig",{bundlePolicy:"max-bundle",iceServers:[]}),ui(this,"onPubMsTrackReplace",((e,t)=>{var r,i;if(!this.published[e.id])return;null===(r=this.published[e.id].sender)||void 0===r||r.replaceTrack(null!==(i=e.getMediaStreamTrack())&&void 0!==i?i:null)}))}startMonitor(){super.startMonitor(),this.qualityInterval||(this.qualityInterval=setInterval((async()=>{try{const e=await this.getMetric();this.evaluateQuality(e)}catch(e){this.logger.error("metric","质量评分采集失败",e)}}),2e3))}evaluateQuality(e){const t=this.qualityMonitor.update(e),r=this.refineQualityEvaluation(t);if(this.lastQualityEvaluation=r,r.overall!==this.lastBroadcastQuality){const e=this.lastBroadcastQuality;this.lastBroadcastQuality=r.overall,this.emit(Dr.ConnectionQualityChanged,r,e),this.logger.debug("quality",`连接质量: ${e} -> ${r.overall}`,r.reasons)}this.qualityMonitor.shouldEmitCpuConstrained()&&this.emit(Dr.CpuConstrained,r),this.qualityMonitor.shouldEmitBandwidthConstrained()&&this.emit(Dr.BandwidthConstrained,r)}getQualityEvaluation(){return this.lastQualityEvaluation}stopMonitor(){super.stopMonitor(),this.qualityInterval&&(window.clearInterval(this.qualityInterval),this.qualityInterval=void 0),this.qualityMonitor.reset(),this.lastBroadcastQuality=Br.Unknown,this.lastQualityEvaluation=void 0}refineQualityEvaluation(e){return e}async publish(e,t,r){if(await super.publish(e,t,r),!e.getMediaStreamTrack())throw new N(e.toString()+" has no MediaStreamTrack, call startCapture before publishing",M.TrackNotCaptured);if(e.kind==K.Audio&&!kr.checkAudioCodec("OPUS"))throw new N("OPUS is not supported in this environment, "+e.toString()+" cannot be published",M.CodecNotSupported);if(e.kind==K.Video&&!kr.checkVideoCodec("H264"))throw new N("H264 is not supported in this environment, "+e.toString()+" cannot be published",M.CodecNotSupported);if(!("addTransceiver"in RTCPeerConnection.prototype)&&!("addTrack"in RTCPeerConnection.prototype))throw new N("addTransceiver/addTrack is not supported, cannot publish",M.FeatureNotSupported)}updateTrackInfoAfterPublish(e){if(!this.published[e.id])return;const t=this.published[e.id];if(!t.sender)return;let r=t.sender.getParameters().codecs;if(0===r.length)return void this.logger.warn("推流成功后,无法获取编码器信息",e.toString());let i=r[0];this.logger.debug("推流成功后,更新trackinfo codec",e.toString(),"codecInfo",i);let n=i.mimeType;if(e.kind==K.Video){let t=z[n.replace("video/","").toUpperCase()];this.updatePublishInfo(e,{codec:t})}else{let t=z[n.replace("audio/","").toUpperCase()];this.updatePublishInfo(e,{codec:t,sample_rate:i.clockRate,channel_count:i.channels})}}}function hi(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var di=function(e){return e.INIT="init",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.DISCONNECTED="disconnected",e}(di||{});const fi=12e3;class pi extends li{constructor(e,t,r,i){super(t,r,i),hi(this,"publishPc",void 0),hi(this,"subscribePc",void 0),hi(this,"publishNegotiationPromise",null),hi(this,"isPublishNegotiating",!1),hi(this,"state",di.INIT),hi(this,"api",void 0),hi(this,"signalDataChannel",null),hi(this,"onDataChannelMessage",null),hi(this,"pendingSubscribeTracks",[]),hi(this,"subscribeDebounce",void 0),hi(this,"subscribeHit",{}),hi(this,"lastServerQualityReport",void 0),hi(this,"lastClientStatsReportAt",0),hi(this,"simulcastTracks",{}),hi(this,"activeSpeakers",new Map),hi(this,"ability",{audioCodecs:[z.OPUS],videoCodecs:[z.H264,z.VP8,z.VP9,z.AV1,z.H265],audioMaxPub:-1,videoMaxPub:-1,audioMaxSub:-1,videoMaxSub:-1}),this.api=e,this.publishPc=this.newPublishPc(),this.subscribePc=this.newSubscribePc(),this.subscribeDebounce=Pr((async()=>{if(0===this.pendingSubscribeTracks.length)return{ignored:{},failed:{},hit:{}};try{const e=[...this.pendingSubscribeTracks];this.pendingSubscribeTracks=[],this.logger.debug("执行批量订阅操作",JSON.stringify(e));const t=await this.sfuApiWithRetry("subscribe",(()=>this.api.sfuSubscribe(e)));return t.offer&&await this.handleSfuSubscribeOffer(t.offer),{ignored:t.ignored||{},failed:t.failed||{},hit:t.hit||{}}}catch(e){throw this.logger.error("批量订阅操作失败",e),e}}),100,{isImmediate:!1})}newPublishPc(){return this.publishPc=new RTCPeerConnection(this.dftPCConfig),this.publishPc.createDataChannel("dummy",{ordered:!1,maxRetransmits:0}),this.setupPublishPcListeners(),this.publishPc}newSubscribePc(){return this.subscribePc=new RTCPeerConnection(this.dftPCConfig),this.setupSubscribePcListeners(),this.subscribePc}vendor(){return vr.Seastart}refineQualityEvaluation(e){const t=this.lastServerQualityReport;if(!t||!Number.isFinite(t.ts)||Date.now()-t.ts>fi)return e;let r=Wr(t.pub.level,e.uplink),i=Wr(t.sub.level,e.downlink);return{uplink:r,downlink:i,overall:Wr(r,i),mos:Math.min(t.pub.mos,t.sub.mos,e.mos),reasons:e.reasons,timestamp:e.timestamp}}async connect(){const e=await this.publishPc.createOffer();await this.publishPc.setLocalDescription(e),await this.waitForIceGathering(this.publishPc);const{publish_answer:t,subscribe_offer:r,prefer_video_codec:i,prefer_audio_codec:n}=await this.sfuApiWithRetry("connect",(()=>this.api.sfuConnect(this.publishPc.localDescription,this.joinRsp.net)));i&&!this.ability.preferVideoCodec&&(this.ability.preferVideoCodec=z[i.toUpperCase()]),n&&!this.ability.preferAudioCodec&&(this.ability.preferAudioCodec=z[n.toUpperCase()]),await this.publishPc.setRemoteDescription(t),await this.handleSfuSubscribeOffer(r),await this.waitForPCConnected(this.publishPc,5e3),await this.waitForPCConnected(this.subscribePc,5e3),await super.connect(),this.state=di.CONNECTED}async sfuApiWithRetry(e,t){try{return await k(t,{maxRetries:3,initialDelay:10,onRetry:(t,r)=>(this.logger.warn(`SFU API ${e} 调用失败第${t}次`,r),!j(r))})()}catch(t){throw"maxretry"==t?(t=new N(`SFU API ${e} failed after retries`,M.ConnectionFailed),this.logger.error(`SFU API ${e} 多次重试依旧无法调用,已放弃调用`)):"canceled"==t?(t=new N(`SFU API ${e} was canceled`,M.Cancelled),this.logger.error(`SFU API ${e} 调用被取消`)):this.logger.error(`SFU API ${e} 调用失败,不再重试`,t),t}}async reconnectWithRetry(e){if(this.state!=di.CONNECTED)return;this.state=di.RECONNECTING,this.logger.warn("SFU 开始重连",e),this.stopMonitor(),this.clearSignalDataChannel(),this.lastServerQualityReport=void 0,this.resetActiveSpeakers(),this.publishPc.close(),this.subscribePc.close();for(const e in this.published){const t=this.published[e];t.track.emit(Nr.RECONNECTING,t.track,t.opt,t.exopt)}for(const e in this.subscribed){const t=this.subscribed[e];t.track.emit(Nr.RECONNECTING,t.track,t.exopt)}try{await k((async()=>{this.clearSignalDataChannel(),this.publishPc.close(),this.subscribePc.close(),this.publishPc=this.newPublishPc(),this.subscribePc=this.newSubscribePc(),await this.connect()}),{maxRetries:10,initialDelay:500,onRetry:(e,t)=>(this.logger.warn(`SFU 重连失败第${e}次`,t),this.state==di.RECONNECTING&&(function(e){return e instanceof N&&U.has(e.code)}(t)?(this.logger.warn("SFU 重连遇到暂时性错误(容量不足),继续退避重试",t),!0):!j(t)))})()}catch(e){throw"maxretry"==e?this.logger.error("SFU 重连多次重试依旧无法连接,已放弃重连"):"canceled"==e?this.logger.error("SFU 重连被取消"):this.logger.error("SFU 重连失败,不再重试",e),e}let t=this.published,r=this.subscribed;this.published={},this.simulcastTracks={},this.subscribed={},this.subscribeHit={};for(const e in t){const r=t[e];try{await this.publish(r.track,r.opt,r.exopt),r.track.emit(Nr.RECONNECTED,r.track)}catch(e){this.logger.error(`SFU 重连后,重新发布 ${r.track.toString()} 失败`,e)}}for(const e in r){const t=r[e];try{await this.subscribe(t.track,t.exopt),t.track.emit(Nr.RECONNECTED,t.track)}catch(e){this.logger.error(`SFU 重连后,重新订阅 ${t.track.toString()} 失败`,e)}}this.logger.warn("SFU 重连成功"),this.state=di.CONNECTED}async disconnect(){await super.disconnect(),this.clearSignalDataChannel(),this.lastServerQualityReport=void 0,this.resetActiveSpeakers(),this.publishPc.close(),this.subscribePc.close(),this.onDataChannelMessage=null,this.state=di.DISCONNECTED}setupPublishPcListeners(){this.publishPc.addEventListener("icecandidate",(e=>{this.logger.debug("发布PeerConnection","icecandidate",e.candidate)})),this.publishPc.addEventListener("iceconnectionstatechange",(e=>{var t,r;this.logger.debug("发布PeerConnection","ICE connection state change",null===(t=this.publishPc)||void 0===t?void 0:t.iceConnectionState),"failed"==(null===(r=this.publishPc)||void 0===r?void 0:r.iceConnectionState)&&this.reconnectWithRetry("发布PeerConnection iceConnectionState: failed")})),this.publishPc.addEventListener("signalingstatechange",(e=>{var t,r;this.logger.debug("发布PeerConnection","signaling state change",null===(t=this.publishPc)||void 0===t?void 0:t.signalingState),"closed"==(null===(r=this.publishPc)||void 0===r?void 0:r.signalingState)&&this.reconnectWithRetry("发布PeerConnection signaling state: closed")})),this.publishPc.addEventListener("connectionstatechange",(e=>{var t;if(this.logger.info("发布PeerConnection","connection state",null===(t=this.publishPc)||void 0===t?void 0:t.connectionState),this.publishPc)switch(this.publishPc.connectionState){case"failed":case"closed":this.reconnectWithRetry("发布PeerConnection连接状态: "+this.publishPc.connectionState);break;case"connected":this.logger.info("发布PeerConnection已连接")}}))}setupSubscribePcListeners(){this.subscribePc.addEventListener("icecandidate",(e=>{this.logger.debug("订阅PeerConnection","icecandidate",e.candidate)})),this.subscribePc.addEventListener("iceconnectionstatechange",(e=>{var t,r;this.logger.debug("订阅PeerConnection","ICE connection state change",null===(t=this.subscribePc)||void 0===t?void 0:t.iceConnectionState),"failed"==(null===(r=this.subscribePc)||void 0===r?void 0:r.iceConnectionState)&&this.reconnectWithRetry("订阅PeerConnection iceConnectionState: failed")})),this.subscribePc.addEventListener("signalingstatechange",(e=>{var t,r;this.logger.debug("订阅PeerConnection","signaling state change",null===(t=this.subscribePc)||void 0===t?void 0:t.signalingState),"closed"==(null===(r=this.subscribePc)||void 0===r?void 0:r.signalingState)&&this.reconnectWithRetry("订阅PeerConnection signaling state: closed")})),this.subscribePc.addEventListener("track",(e=>{var t;const r=(null===(t=e.streams[0])||void 0===t?void 0:t.id)||e.track.id;this.logger.info("订阅PeerConnection","收到远程轨道",e.track.kind,e.track.id,r);let i=this.subscribed[r];i?(i.track.setMediaStreamTrack(e.track),(i.track instanceof ii||i.track instanceof Zr)&&i.track.setRtpReceiver(e.receiver),this.logger.warn("拉流",i.track.toString(),"mstrack got"),e.streams[0].onremovetrack=()=>{this.logger.warn("拉流",i.track.toString(),"mstrack removed"),i.track.emit(a.ENDED,i.track)}):this.logger.warn("收到的远程轨道",e.track.kind,e.track.id,"未订阅或已取消")})),this.subscribePc.addEventListener("connectionstatechange",(e=>{var t;if(this.logger.debug("订阅PeerConnection","connection state",null===(t=this.subscribePc)||void 0===t?void 0:t.connectionState),this.subscribePc)switch(this.subscribePc.connectionState){case"failed":case"closed":this.reconnectWithRetry("订阅PeerConnection连接状态: "+this.subscribePc.connectionState);break;case"connected":this.logger.info("订阅PeerConnection已连接")}})),this.subscribePc.addEventListener("datachannel",(e=>{this.logger.info("订阅PeerConnection","收到数据通道",e.channel.label),this.clearSignalDataChannel(),this.signalDataChannel=e.channel,this.setupDataChannelListeners()}))}async publish(e,t,r){if(this.state==di.RECONNECTING)throw new N("Cannot publish while stream engine is reconnecting",M.TransportNotReady);if(this.state!=di.CONNECTED)throw new N("Cannot publish in stream engine state: "+this.state,M.PublishFailed);if("connected"!=this.publishPc.connectionState)throw new N("Publish PeerConnection is not connected",M.TransportNotReady);if(this.published[e.id])return void this.logger.warn("推流",e.toString(),"进行中,当前状态",this.published[e.id].pc.connectionState);await super.publish(e,t,r);let i={priority:t.priority,networkPriority:t.priority,maxBitrate:t.maxBitrate},n=[i];if(e.kind==K.Video){let r=e,o=t;if(i.maxFramerate=o.maxFramerate,i.scaleResolutionDownBy=r.getScaleResolutionDownBy(),o.simulcasts&&o.simulcasts.length>0){if(!("addTransceiver"in RTCPeerConnection.prototype))throw new N("Simulcast is not supported: addTransceiver is unavailable",M.FeatureNotSupported);i.rid="0",this.simulcastTracks[e.id]={};for(let t=1;t<=o.simulcasts.length;t++){let i=o.simulcasts[t-1],s=r.getSimulcastTrack(i,o.width,o.height);n.push({rid:t.toString(),priority:i.priority,networkPriority:i.priority,maxBitrate:i.maxBitrate,maxFramerate:i.maxFramerate,scaleResolutionDownBy:s.getScaleResolutionDownBy()}),this.simulcastTracks[e.id][t.toString()]=s}}}let o=this.publishPc,s={kind:e.kind,pc:o,track:e,opt:t,exopt:r||{}};this.published[e.id]=s,this.logger.debug("推流编码参数",e.toString(),"encodings",n);let a=!1;if("addTransceiver"in RTCPeerConnection.prototype){let r=o.addTransceiver(e.getMediaStreamTrack(),{direction:"sendonly",sendEncodings:n,streams:[e.getMediaStream()]});if(s.sender=r.sender,e.kind==K.Video){let e=t.codec||this.ability.preferVideoCodec;if(e){let t=kr.preferVideoEncCodec($(e));try{r.setCodecPreferences(t)}catch(e){this.logger.warn("setCodecPreferences(video) 失败,将使用浏览器默认编码顺序",e)}}}else{let e=t.codec||this.ability.preferAudioCodec;if(e){let t=kr.preferAudioEncCodec($(e));try{r.setCodecPreferences(t)}catch(e){this.logger.warn("setCodecPreferences(audio) 失败,将使用浏览器默认编码顺序",e)}}}}else{let t=o.addTrack(e.getMediaStreamTrack(),e.getMediaStream());s.sender=t,a=!0}let c=s.sender.getParameters();a&&(c.encodings=n),e.kind==K.Video&&t.degradationPreference&&(c.degradationPreference=t.degradationPreference),await s.sender.setParameters(c);try{await this.negotiatePublishPc()}catch(t){throw delete this.published[e.id],delete this.simulcastTracks[e.id],t}this.updateTrackInfoAfterPublish(e),e.on(Nr.MSTRACK_REPLACED,this.onPubMsTrackReplace)}updateTrackInfoAfterPublish(e){if(super.updateTrackInfoAfterPublish(e),e.kind==K.Video){let r=[];for(const i in this.simulcastTracks[e.id]){var t;let n=this.simulcastTracks[e.id][i],o=e.id+"_"+i;this.updatePublishInfo(n,{id:o,codec:null===(t=this.publisher)||void 0===t||null===(t=t.getPublishInfo(e))||void 0===t?void 0:t.codec,variant:!0}),r.push(o)}r.length>0&&this.updatePublishInfo(e,{fallback_ids:r})}}async unpublish(e){if(!this.published[e.id])return void this.logger.warn("推流",e.toString(),"已取消,无需取消发布");e.off(Nr.MSTRACK_REPLACED,this.onPubMsTrackReplace);const t=this.published[e.id];if(this.logger.warn("推流",e.toString(),"unpublished"),delete this.published[e.id],delete this.simulcastTracks[e.id],this.state==di.CONNECTED)try{t.pc.removeTrack(t.sender),await this.negotiatePublishPc()}catch(t){this.logger.warn("推流",e.toString(),"取消发布失败",t)}}async subscribe(e,t){if(this.state==di.INIT||this.state==di.DISCONNECTED)throw new N("Cannot subscribe in stream engine state: "+this.state,M.SubscribeFailed);if("connected"!=this.subscribePc.connectionState)throw new N("Subscribe PeerConnection is not connected",M.TransportNotReady);if(this.subscribed[e.id])return void this.logger.warn("拉流",e.toString(),"进行中,当前状态",this.subscribed[e.id].pc.connectionState);await super.subscribe(e,t);let r={kind:e.kind,pc:this.subscribePc,track:e,exopt:t||{}};this.subscribed[e.id]=r;const i=null==t?void 0:t.prefer_track_ids;try{await k((()=>this.debouncedSfuSubscribe(e.getUid(),e.id,!0,i)),{maxRetries:3,initialDelay:1e3,onRetry:(t,r)=>"not found"==r?(this.logger.warn(`SFU track ${e.toString()}不存在,重试第${t}次`),!0):(this.logger.warn(`SFU track ${e.toString()}订阅失败`,r),!1)})()}catch(t){throw delete this.subscribed[e.id],t}}async unsubscribe(e){if(this.subscribed[e.id]){if(this.logger.warn("拉流",e.toString(),"unsubscribed"),delete this.subscribed[e.id],delete this.subscribeHit[`${e.getUid()}:${e.id}`],this.state==di.CONNECTED)try{await this.debouncedSfuSubscribe(e.getUid(),e.id,!1)}catch(t){this.logger.warn("拉流",e.toString(),"取消订阅失败",t)}}else this.logger.warn("拉流",e.toString(),"未订阅或已取消,无需取消订阅")}getSubscribeHit(e){return this.subscribeHit[`${e.getUid()}:${e.id}`]}async debouncedSfuSubscribe(e,t,r,i){const n={pub_uid:e,track_id:t,subscribe:r,prefer_track_ids:i},o=this.pendingSubscribeTracks.findIndex((r=>r.pub_uid===e&&r.track_id===t));if(-1!==o){this.pendingSubscribeTracks[o].subscribe!==r&&(this.pendingSubscribeTracks.splice(o,1),this.logger.debug("订阅操作",`${e}:${t}`,"订阅和取消订阅操作相互抵消"))}else this.pendingSubscribeTracks.push(n);const s=await this.subscribeDebounce(),a=`${e}:${t}`;if(s.ignored[a]&&this.logger.warn(`轨道 ${a} 订阅被忽略: ${s.ignored[a]}`),s.failed[a])throw s.failed[a];s.hit[a]&&(this.logger.debug(`轨道 ${a} 订阅命中层: ${s.hit[a]}`),this.updateSubscribeHit(a,s.hit[a]))}async negotiatePublishPc(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isPublishNegotiating)return this.publishNegotiationPromise?void await this.publishNegotiationPromise:(await _(100),this.negotiatePublishPc(e));this.isPublishNegotiating=!0,this.publishNegotiationPromise=(async()=>{try{if(await new Promise((e=>setTimeout(e,100))),this.publishNegotiationPromise=null,"stable"===this.publishPc.signalingState&&"connected"===this.publishPc.connectionState){const r=await this.publishPc.createOffer({iceRestart:e}),i=[];for(const e in this.published){var t;const r=this.published[e].track;i.push({track_id:e,stream_id:r.getMediaStream().id,mstrack_id:null===(t=r.getMediaStreamTrack())||void 0===t?void 0:t.id})}await this.publishPc.setLocalDescription(r),await this.waitForIceGathering(this.publishPc);const n=await this.sfuApiWithRetry("offerPublish",(()=>this.api.sfuOfferPublish(this.publishPc.localDescription,i)));await this.publishPc.setRemoteDescription(n.answer),this.logger.info("发布PeerConnection协商成功")}}catch(e){throw this.logger.error("发布PeerConnection协商失败",e),this.reconnectWithRetry(e),e}finally{this.isPublishNegotiating=!1}})(),await this.publishNegotiationPromise}async handleSfuSubscribeOffer(e){this.logger.info("收到订阅PeerConnection Offer");try{await this.subscribePc.setRemoteDescription(e);const t=await this.subscribePc.createAnswer();await this.subscribePc.setLocalDescription(t),await this.waitForIceGathering(this.subscribePc),await this.sfuApiWithRetry("answerSubscribe",(()=>this.api.sfuAnswerSubscribe(this.subscribePc.localDescription))),this.logger.info("订阅PeerConnection Answer已发送")}catch(e){throw this.logger.error("处理订阅PeerConnection Offer失败",e),this.reconnectWithRetry(e),e}}async waitForPCConnected(e,t){if("connected"!==e.connectionState)return new Promise(((r,i)=>{const n=()=>{"connected"===e.connectionState&&(clearTimeout(o),e.removeEventListener("connectionstatechange",n),r())};e.addEventListener("connectionstatechange",n);const o=setTimeout((()=>{e.removeEventListener("connectionstatechange",n),i(new N("PeerConnection connection timeout",M.ConnectionTimeout))}),t)}))}async waitForIceGathering(e){if("complete"!==e.iceGatheringState)return new Promise((t=>{const r=()=>{"complete"===e.iceGatheringState&&(clearTimeout(i),e.removeEventListener("icegatheringstatechange",r),t())};e.addEventListener("icegatheringstatechange",r);const i=setTimeout((()=>{e.removeEventListener("icegatheringstatechange",r),this.logger.warn("ICE收集超时,继续处理"),t()}),5e3)}))}clearSignalDataChannel(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.signalDataChannel;e&&(e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null,e===this.signalDataChannel&&(this.signalDataChannel=null))}setupDataChannelListeners(){if(!this.signalDataChannel)return;const e=this.signalDataChannel;e.onopen=e=>{this.logger.info("信令DataChannel已打开")},e.onclose=()=>{this.logger.warn("信令DataChannel已关闭"),this.signalDataChannel===e&&this.clearSignalDataChannel(e)},e.onerror=t=>{const r=e.readyState;console.log(t),this.logger.warn("信令DataChannel错误",{readyState:r},t.error)},this.onDataChannelMessage=e=>{try{const t=JSON.parse(e.data);switch(this.logger.debug("收到信令DataChannel消息",t),t.type){case"layer-switched":this.handleLayerSwitched(t);break;case"quality":this.handleConnectionQualityReport(t);break;case"active-speakers":this.handleActiveSpeakersMessage(t);break;default:this.logger.debug("未知的DataChannel消息类型",t.type)}}catch(t){this.logger.error("处理信令DataChannel消息失败",t,e.data)}},e.onmessage=this.onDataChannelMessage}updateSubscribeHit(e,t){e&&t&&(this.subscribeHit[e]=t)}handleLayerSwitched(e){this.updateSubscribeHit(e.sub_key,e.to_track_id),this.logger.info("订阅层切换",e.sub_key,`${e.from_track_id||"none"} -> ${e.to_track_id}`,`reason=${e.reason}`,`latency=${e.latency_ms}ms`)}handleConnectionQualityReport(e){e&&Number.isFinite(e.ts)&&(this.lastServerQualityReport=e)}handleActiveSpeakersMessage(e){if(!e||!Array.isArray(e.speakers))return;let t=!1;for(const r of e.speakers){if(!r||!r.uid||!r.track_id)continue;const e=`${r.uid}:${r.track_id}`;if(r.active){const i=this.activeSpeakers.get(e);i&&i.level===r.level||(this.activeSpeakers.set(e,{uid:r.uid,trackId:r.track_id,level:r.level}),t=!0)}else this.activeSpeakers.delete(e)&&(t=!0)}if(!t)return;const r=Array.from(this.activeSpeakers.values()).sort(((e,t)=>t.level-e.level)),i={ts:e.ts,speakers:r};this.emit(Lr.ActiveSpeakersChanged,i)}resetActiveSpeakers(){if(0===this.activeSpeakers.size)return;this.activeSpeakers.clear();const e={ts:Date.now(),speakers:[]};this.emit(Lr.ActiveSpeakersChanged,e)}sendSignalMessage(e,t){if(!this.signalDataChannel||"open"!==this.signalDataChannel.readyState)return this.logger.warn("信令DataChannel未打开,无法发送消息"),!1;try{const r=JSON.stringify({type:e,...t});return this.signalDataChannel.send(r),!0}catch(e){return this.logger.error("发送信令DataChannel消息失败",e),!1}}requestSwitchSubscribedLayer(e,t){return this.sendSignalMessage("switch-layer",{sub_key:`${e.getUid()}:${e.id}`,track_id:t})}findPublishTrackByMidRid(e,t){var r;if(!e)return;const i=this.publishPc.getTransceivers().find((t=>t.mid===e)),n=null==i||null===(r=i.sender)||void 0===r||null===(r=r.track)||void 0===r?void 0:r.id;if(n)for(const e in this.published){var o;const r=this.published[e];if((null===(o=r.track.getMediaStreamTrack())||void 0===o?void 0:o.id)===n){if(t&&"0"!==t){var s;const r=null===(s=this.simulcastTracks[e])||void 0===s?void 0:s[t];if(r)return r}return r.track}}}findSubscribedTrackByMid(e){var t;if(!e)return;const r=this.subscribePc.getTransceivers().find((t=>t.mid===e)),i=null==r||null===(t=r.receiver)||void 0===t||null===(t=t.track)||void 0===t?void 0:t.id;if(i)for(const e in this.subscribed){var n;const t=this.subscribed[e];if((null===(n=t.track.getMediaStreamTrack())||void 0===n?void 0:n.id)===i)return t.track}}async getMetric(){var e,t,r,i,n;const o={bitrate_down:0,bitrate_up:0,lossrate_down:0,lossrate_up:0,pkt_up:0,pkt_down:0,pkt_loss_up:0,pkt_loss_down:0},s=null===(e=this.prevMetric)||void 0===e?void 0:e.network,a=[],c=[],u=await this.publishPc.getStats();u.forEach((e=>{var t,r;if("outbound-rtp"!==e.type)return;const i=this.findPublishTrackByMidRid(e.mid,e.rid);if(!i)return;const n=null!==(t=null===(r=this.publisher)||void 0===r?void 0:r.getPublishInfo(i))&&void 0!==t?t:i.getRawInfo(),s=i.prevStats;if("audio"==e.kind){var l;const t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,bytesSent:e.bytesSent,timestamp:e.timestamp,audioLevel:e.mediaSourceId?null===(l=u.get(e.mediaSourceId))||void 0===l?void 0:l.audioLevel:void 0},r=u.get(e.remoteId);r&&(t.jitter=null!=r.jitter?1e3*r.jitter:void 0,t.packetsLost=r.packetsLost,t.roundTripTime=null!=r.roundTripTime?1e3*r.roundTripTime:void 0),n.bitrate=s?oi(t,s):0,n.db=t.audioLevel?R(t.audioLevel):-60,n.stats=t,i.prevStats=t,o.bitrate_up+=n.bitrate,o.pkt_up+=t.packetsSent||0,o.pkt_loss_up+=t.packetsLost||0,a.push(n)}else if("video"==e.kind){var h;const t={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,framesPerSecond:e.framesPerSecond,framesSent:e.framesSent,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationDurations:e.qualityLimitationDurations,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges,rid:null!==(h=e.rid)&&void 0!==h?h:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,targetBitrate:e.targetBitrate,timestamp:e.timestamp},r=u.get(e.remoteId);r&&(t.jitter=null!=r.jitter?1e3*r.jitter:void 0,t.packetsLost=r.packetsLost,t.roundTripTime=null!=r.roundTripTime?1e3*r.roundTripTime:void 0),n.width=t.frameWidth,n.height=t.frameHeight,n.fps=t.framesPerSecond,n.bitrate=s?oi(t,s):0,n.stats=t,i.prevStats=t,o.bitrate_up+=n.bitrate,o.pkt_up+=t.packetsSent||0,o.pkt_loss_up+=t.packetsLost||0,c.push(n)}}));const l=[],h=[],d=await this.subscribePc.getStats();let f,p;d.forEach((e=>{if("inbound-rtp"!==e.type)return;const t=this.findSubscribedTrackByMid(e.mid);if(!t)return;const r=t.getInfo();r.uid=t.getUid();const i=t.prevStats;if("audio"==e.kind){const n={type:"audio",streamId:e.id,timestamp:e.timestamp,jitter:null!=e.jitter?1e3*e.jitter:void 0,jitterBufferDelay:null!=e.jitterBufferDelay?1e3*e.jitterBufferDelay:void 0,jitterBufferEmittedCount:e.jitterBufferEmittedCount,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,bytesReceived:e.bytesReceived,concealedSamples:e.concealedSamples,concealmentEvents:e.concealmentEvents,silentConcealedSamples:e.silentConcealedSamples,silentConcealmentEvents:e.silentConcealmentEvents,audioLevel:e.audioLevel,totalAudioEnergy:e.totalAudioEnergy,totalSamplesDuration:e.totalSamplesDuration};n.jitterBufferAvgDelay=ai(n,i),r.bitrate=i?oi(n,i):0,r.db=n.audioLevel?R(n.audioLevel):-60,r.stats=n,t.prevStats=n,o.bitrate_down+=r.bitrate,o.pkt_down+=n.packetsReceived||0,o.pkt_loss_down+=n.packetsLost||0,l.push(r)}else if("video"==e.kind){const n={type:"video",streamId:e.id,framesDecoded:e.framesDecoded,framesDropped:e.framesDropped,framesReceived:e.framesReceived,packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,framesPerSecond:e.framesPerSecond,frameWidth:e.frameWidth,frameHeight:e.frameHeight,pliCount:e.pliCount,firCount:e.firCount,nackCount:e.nackCount,jitter:null!=e.jitter?1e3*e.jitter:void 0,jitterBufferDelay:null!=e.jitterBufferDelay?1e3*e.jitterBufferDelay:void 0,jitterBufferEmittedCount:e.jitterBufferEmittedCount,timestamp:e.timestamp,bytesReceived:e.bytesReceived,decoderImplementation:e.decoderImplementation,freezeCount:e.freezeCount,totalFreezesDuration:e.totalFreezesDuration,pauseCount:e.pauseCount,totalPausesDuration:e.totalPausesDuration,framesAssembledFromMultiplePackets:e.framesAssembledFromMultiplePackets,totalAssemblyTime:e.totalAssemblyTime};if(e.codecId){const t=d.get(e.codecId);t&&(n.mimeType=t.mimeType)}n.jitterBufferAvgDelay=ai(n,i),r.width=n.frameWidth,r.height=n.frameHeight,r.fps=e.framesPerSecond||(i?ci(n,i):0),r.bitrate=i?oi(n,i):0,r.stats=n,t.prevStats=n,o.bitrate_down+=r.bitrate,o.pkt_down+=n.packetsReceived||0,o.pkt_loss_down+=n.packetsLost||0,h.push(r)}}));const g=si(u);g&&(null!=g.availableOutgoingBitrate&&(o.available_outgoing_bitrate=C(g.availableOutgoingBitrate/1e3,2)),null!=g.currentRoundTripTime&&(f=C(1e3*g.currentRoundTripTime,2)));const m=si(d);m&&(null!=m.availableIncomingBitrate&&(o.available_incoming_bitrate=C(m.availableIncomingBitrate/1e3,2)),null!=m.currentRoundTripTime&&(p=C(1e3*m.currentRoundTripTime,2))),o.rtt_up=f,o.rtt_down=p;const v=o.pkt_up-(null!==(t=null==s?void 0:s.pkt_up)&&void 0!==t?t:0),y=o.pkt_down-(null!==(r=null==s?void 0:s.pkt_down)&&void 0!==r?r:0),b=o.pkt_loss_up-(null!==(i=null==s?void 0:s.pkt_loss_up)&&void 0!==i?i:0),w=o.pkt_loss_down-(null!==(n=null==s?void 0:s.pkt_loss_down)&&void 0!==n?n:0);o.lossrate_up=C(v>0?b/v*100:0,2),o.lossrate_down=C(y>0?w/y*100:0,2);const S=this.lastServerQualityReport;S&&Number.isFinite(S.ts)&&Date.now()-S.ts<=fi&&(o.server={ts:S.ts,pub:S.pub,sub:S.sub});let _=this.prevMetric={local_audios:a,local_videos:c,remote_audios:l,remote_videos:h,network:o};return this.maybeReportClientStatsToSfu(a,c,l,h,o,f,p),_}maybeReportClientStatsToSfu(e,t,r,i,n,o,s){if(!this.signalDataChannel||"open"!==this.signalDataChannel.readyState)return;const a="undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now();if(!this.shouldReportClientStats(a))return;this.lastClientStatsReportAt=a;const c=[];for(const t of e){var u,l,h;const e=t.stats;e&&c.push({track_id:t.id,kind:"audio",packets_sent:null!==(u=e.packetsSent)&&void 0!==u?u:0,packets_lost:null!==(l=e.packetsLost)&&void 0!==l?l:0,bytes_sent:null!==(h=e.bytesSent)&&void 0!==h?h:0,nack_count:0,pli_count:0,fir_count:0,retransmitted_packets:0,jitter_ms:e.jitter,rtt_ms:e.roundTripTime})}for(const e of t){var d,f,p,g,m,v,y;const t=e.stats;t&&c.push({track_id:e.id,rid:t.rid,kind:"video",packets_sent:null!==(d=t.packetsSent)&&void 0!==d?d:0,packets_lost:null!==(f=t.packetsLost)&&void 0!==f?f:0,bytes_sent:null!==(p=t.bytesSent)&&void 0!==p?p:0,nack_count:null!==(g=t.nackCount)&&void 0!==g?g:0,pli_count:null!==(m=t.pliCount)&&void 0!==m?m:0,fir_count:null!==(v=t.firCount)&&void 0!==v?v:0,retransmitted_packets:null!==(y=t.retransmittedPacketsSent)&&void 0!==y?y:0,target_bitrate_bps:t.targetBitrate,frame_width:t.frameWidth,frame_height:t.frameHeight,frames_per_second:t.framesPerSecond,frames_sent:t.framesSent,quality_limitation_reason:t.qualityLimitationReason,jitter_ms:t.jitter,rtt_ms:t.roundTripTime})}const b=[];for(const e of r){var w,S,_;const t=e.stats;t&&b.push({track_id:e.id,pub_uid:e.uid,kind:"audio",packets_received:null!==(w=t.packetsReceived)&&void 0!==w?w:0,packets_lost:null!==(S=t.packetsLost)&&void 0!==S?S:0,bytes_received:null!==(_=t.bytesReceived)&&void 0!==_?_:0,nack_count:0,pli_count:0,fir_count:0,jitter_ms:t.jitter,jitter_buffer_delay_ms:t.jitterBufferDelay,jitter_buffer_emitted_count:t.jitterBufferEmittedCount})}for(const e of i){var k,E,T,C,P,A;const t=e.stats;t&&b.push({track_id:e.id,pub_uid:e.uid,kind:"video",packets_received:null!==(k=t.packetsReceived)&&void 0!==k?k:0,packets_lost:null!==(E=t.packetsLost)&&void 0!==E?E:0,bytes_received:null!==(T=t.bytesReceived)&&void 0!==T?T:0,nack_count:null!==(C=t.nackCount)&&void 0!==C?C:0,pli_count:null!==(P=t.pliCount)&&void 0!==P?P:0,fir_count:null!==(A=t.firCount)&&void 0!==A?A:0,jitter_ms:t.jitter,jitter_buffer_delay_ms:t.jitterBufferDelay,jitter_buffer_emitted_count:t.jitterBufferEmittedCount,frames_decoded:t.framesDecoded,frames_dropped:t.framesDropped,frames_received:t.framesReceived,freeze_count:t.freezeCount,total_freezes_duration_ms:null!=t.totalFreezesDuration?1e3*t.totalFreezesDuration:void 0,pause_count:t.pauseCount,total_pauses_duration_ms:null!=t.totalPausesDuration?1e3*t.totalPausesDuration:void 0,frames_per_second:t.framesPerSecond,frame_width:t.frameWidth,frame_height:t.frameHeight})}const I={ts:Date.now(),available_outgoing_bitrate_bps:null!=n.available_outgoing_bitrate?Math.round(1e3*n.available_outgoing_bitrate):void 0,pub_rtt_ms:o,sub_rtt_ms:s,pub:c,sub:b};try{this.sendSignalMessage("client-stats",I)}catch(e){this.logger.debug("client-stats","DC 上报失败",e)}}shouldReportClientStats(e){if(this.lastClientStatsReportAt>0&&e-this.lastClientStatsReportAt<5e3)return!1;const t=this.lastServerQualityReport;if(!t||!Number.isFinite(t.ts)||Date.now()-t.ts>fi)return!0;return!(t.pub.level===Br.Excellent&&t.sub.level===Br.Excellent)||!(this.lastClientStatsReportAt>0&&e-this.lastClientStatsReportAt<3e4)}}function gi(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class mi{constructor(e,t,r){gi(this,"enabled",void 0),gi(this,"settings",void 0),gi(this,"debouncers",new Map),this.sengine=e,this.resolveCandidates=r,this.settings=t&&!0!==t?t:void 0,this.enabled=!!t&&e instanceof pi}attach(e){if(!this.enabled)return void e.setAdaptiveStreamController(void 0);this.clearDebouncer(e.id);const t=Pr((t=>{this.handleState(e,t)}),100);this.debouncers.set(e.id,t),e.setAdaptiveStreamController((e=>{t(e)}))}detach(e){this.clearDebouncer(e.id),e.setAdaptiveStreamController(void 0)}clearDebouncer(e){const t=this.debouncers.get(e);t&&(t.cancel(),this.debouncers.delete(e))}handleState(e,t){if(!this.enabled||!this.sengine.haveSubscribed(e))return;const r=this.sengine;if(!(r instanceof pi))return;if(t.visible&&0===t.width&&0===t.height)return;const i=this.pickTargetTrackId(e,t);if(!i)return;if((r.getSubscribeHit(e)||e.id)!==i&&r.requestSwitchSubscribedLayer(e,i)){const r=this.getPixelDensity();be.debug("自适应流切层",e.toString(),`views=${t.viewCount}`,`visible=${t.visible}`,`size=${Math.round(t.width)}x${Math.round(t.height)}`,`density=${r}`,`background=${t.inBackground}`,`target=${i}`)}}pickTargetTrackId(e,t){var r,i;const n=this.resolveCandidates(e);if(0===n.length)return;if(1===n.length)return n[0].id;const o=null===(r=null===(i=this.settings)||void 0===i?void 0:i.pauseVideoInBackground)||void 0===r||r;if(0===t.viewCount||!t.visible||o&&t.inBackground)return n[n.length-1].id;const s=this.getPixelDensity(),a=Math.max(1,Math.ceil(t.width*s))*Math.max(1,Math.ceil(t.height*s))*.9;for(let e=n.length-1;e>=0;e--){const t=n[e].getInfo();if(t.width*t.height>=a)return t.id}return n[0].id}getPixelDensity(){var e;const t=null===(e=this.settings)||void 0===e?void 0:e.pixelDensity;if("screen"===t)return window.devicePixelRatio||1;if("number"==typeof t&&t>0)return t;return(window.devicePixelRatio||1)>2?2:1}}var vi;function yi(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const bi="default";class wi extends(h()){static getInstance(){if(void 0===wi.instance){var e,t;wi.instance=new wi;"undefined"==typeof window||window.isSecureContext||void 0!==(null===(e=navigator)||void 0===e?void 0:e.mediaDevices)||be.warn("当前非安全环境(https或localhost或127.0.0.1),将无法获取麦克风、摄像头等媒体设备进行枚举、音视频采集、推流"),null===(t=navigator)||void 0===t||null===(t=t.mediaDevices)||void 0===t||t.addEventListener("devicechange",(()=>{wi.debouncedDeviceChangeHandler()}))}return wi.instance}async addWaitMediaDevice(e,t,r){let i=wi.waitingMediaDevicePromises;i.push(e);try{return await e}catch(e){throw be.error(`mediaDevices.${t} error`,e,r),e}finally{i.splice(i.indexOf(e),1)}}async enum(){let e=navigator.mediaDevices.enumerateDevices();return this.addWaitMediaDevice(e,"enumerateDevices")}async getUserMedia(e){let t=navigator.mediaDevices.getUserMedia(e);return this.addWaitMediaDevice(t,"getUserMedia",e)}async waitMediaDevices(){return Promise.allSettled(wi.waitingMediaDevicePromises)}async getDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=await this.enum();if(t){if(0===r.length||r.some((t=>{const r=""===t.label,i=!e||t.kind===e;return r&&i}))){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e};for(;;)try{const e=await this.getUserMedia(t);r=await this.enum(),e.getTracks().forEach((e=>{e.stop()}));break}catch(e){if(e instanceof DOMException&&"NotFoundError"===e.name&&(t.video?t.video=!1:t.audio&&(t.audio=!1),t.audio||t.video))continue;throw N.fromCaptureError(e,t.video?"camera":"mic")}}}return e?r=r.filter((t=>t.kind===e)):t&&(wi.devices=r),r}async normalizeDeviceId(e,t,r){if(t!==bi)return t;const i=await this.getDevices(e),n=new Map(i.map((e=>[e.groupId,0])));i.forEach((e=>{var t;return n.set(e.groupId,(null!==(t=n.get(e.groupId))&&void 0!==t?t:0)+1)}));const o=i.find((e=>{var t;return(r===e.groupId||(null!==(t=n.get(e.groupId))&&void 0!==t?t:0)>1)&&e.deviceId!==bi}));return null==o?void 0:o.deviceId}}function Si(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}vi=wi,yi(wi,"instance",void 0),yi(wi,"devices",[]),yi(wi,"debouncedDeviceChangeHandler",Pr((async()=>{let e=vi.devices,t=await vi.instance.getDevices();const r=t.filter((t=>!e.some((e=>e.deviceId===t.deviceId)))),i=e.filter((e=>!t.some((t=>e.deviceId===t.deviceId))));r.forEach((e=>{be.info("新设备插入:",e),vi.instance.emit("add",e)})),i.forEach((e=>{be.info("设备被拔出:",e),vi.instance.emit("remove",e)}))}),100,{isImmediate:!1})),yi(wi,"waitingMediaDevicePromises",[]);class _i{constructor(e){if(Si(this,"name",void 0),Si(this,"processedTrack",void 0),Si(this,"processors",void 0),Si(this,"ownedAudioContext",void 0),!e.length)throw new N("ProcessorPipeline requires at least one processor",M.InvalidArgument);this.processors=e,this.name=e.map((e=>e.name)).join(" -> ")}async init(e){let t=e.audioContext;e.kind!==K.Audio||t||(t=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3,latencyHint:"interactive"}),this.ownedAudioContext=t);let r=e.track;for(const i of this.processors){if(await i.init({track:r,kind:e.kind,audioContext:t}),!i.processedTrack)throw new N(`Processor ${i.name} did not produce a processedTrack`,M.InternalError);r=i.processedTrack}this.processedTrack=r}async destroy(){for(const e of[...this.processors].reverse())try{await e.destroy()}catch(t){be.warn("ProcessorPipeline",`处理器 ${e.name} 释放失败`,t)}this.ownedAudioContext&&"closed"!==this.ownedAudioContext.state&&await this.ownedAudioContext.close(),this.ownedAudioContext=void 0,this.processedTrack=void 0}}function ki(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Ei{constructor(e){ki(this,"track",void 0),ki(this,"processor",void 0),ki(this,"originMsTrack",void 0),ki(this,"applying",!1),this.track=e,this.onMsTrackReplaced=this.onMsTrackReplaced.bind(this),this.track.on(Nr.MSTRACK_REPLACED,this.onMsTrackReplaced)}async setProcessor(e){const t=this.track.getMediaStreamTrack();if(!t)throw new N("Call startCapture before setProcessor",M.TrackNotCaptured);this.processor&&await this.removeProcessor();const r=Array.isArray(e)?new _i(e):e;this.applying=!0;try{await this.applyProcessor(r,t)}finally{this.applying=!1}}async removeProcessor(){const e=this.processor;e&&(this.processor=void 0,this.originMsTrack&&this.track.setMediaStreamTrack(this.originMsTrack),this.originMsTrack=void 0,await e.destroy())}getProcessor(){return this.processor}async applyProcessor(e,t){await e.init({track:t,kind:this.track.kind});const r=e.processedTrack;if(!r)throw new N(`Processor ${e.name} did not produce a processedTrack`,M.InternalError);this.processor=e,this.originMsTrack=t,this.track.setMediaStreamTrack(r)}onMsTrackReplaced(){if(!this.processor||this.applying)return;const e=this.track.getMediaStreamTrack();if(!e||e===this.processor.processedTrack)return;const t=this.processor,r=e;this.applying=!0,(async()=>{try{await t.destroy(),await this.applyProcessor(t,r)}catch(e){be.warn("ProcessorController","切换设备后自动重挂处理器失败",e)}finally{this.applying=!1}})()}}function Ti(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Ci extends zr{constructor(){super(...arguments),Ti(this,"publishState",new G(this))}emitInfoUpdate(){this.emit(a.INFO_UPDATE,this)}get id(){var e,t;return null!==(e=null===(t=this.publishState.soleRecord())||void 0===t?void 0:t.info.id)&&void 0!==e?e:this.info.id}get desc(){var e,t;return null!==(e=null===(t=this.publishState.soleRecord())||void 0===t?void 0:t.info.desc)&&void 0!==e?e:this.info.desc}get variant(){var e,t;return null!==(e=null===(t=this.publishState.soleRecord())||void 0===t?void 0:t.info.variant)&&void 0!==e?e:this.info.variant}get angle(){var e,t;return null!==(e=null===(t=this.publishState.soleRecord())||void 0===t?void 0:t.info.angle)&&void 0!==e?e:this.info.angle}getInfo(){var e;return null!==(e=this.publishState.resolveInfo())&&void 0!==e?e:super.getInfo()}getUid(){var e,t;return null!==(e=null===(t=this.publishState.soleRecord())||void 0===t?void 0:t.uid)&&void 0!==e?e:this.uid}}class Pi extends Ci{constructor(){super({id:P(20),kind:K.Audio,track:-1},""),Ti(this,"playTrait",void 0),Ti(this,"processorCtrl",void 0),this.playTrait=new Gr(this),this.processorCtrl=new Ei(this)}async setProcessor(e){return this.processorCtrl.setProcessor(e)}async removeProcessor(){return this.processorCtrl.removeProcessor()}getVolume(){return 0}strPrefix(){return"LocalAudioTrack"}isPlaying(){return this.playTrait.isPlaying()}async startPlay(e){await this.playTrait.startPlay(e)||(e&&e.disableAutoPlayDialog?this.emit(Nr.AUTOPLAY_FAIL,this):Hr.show(this.id,(()=>{this.startPlay(e)})))}stopPlay(){this.playTrait.stopPlay()}}class Ai extends Pi{constructor(){super(),Ti(this,"audioMixTrait",void 0),this.audioMixTrait=new Yr,this.setMediaStreamTrack(this.audioMixTrait.getMixedMediaStreamTrack())}addTrack(e){this.audioMixTrait.addTrack(e)}removeTrack(e){this.audioMixTrait.removeTrack(e)}getTrackCount(){return this.audioMixTrait.getTrackCount()}stop(){this.audioMixTrait.stop()}strPrefix(){return"LocalMixAudioTrack"}}class Ii extends Pi{constructor(e){super(),Ti(this,"captureOptions",void 0),this.captureOptions=!0===e||{...e}}strPrefix(){return"LocalScreenAudioTrack"}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):be.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}}class Ri extends Pi{constructor(e){super(),Ti(this,"captureOptions",void 0),this.captureOptions={...e}}strPrefix(){return"LocalMicTrack"}onEnded(){be.warn(this.toString(),"异常结束,自动尝试默认麦克风(最多重试3次)"),k((()=>this.changeDeviceId(bi)),{maxRetries:3,initialDelay:500,onRetry:(e,t)=>{be.warn(this.toString(),`自动恢复默认麦克风第${e}次重试`,t)}})().catch((e=>{be.error(this.toString(),"异常结束,自动恢复默认麦克风最终失败",e),this.setMediaStreamTrack(void 0),super.onEnded()}))}async startCapture(e){e&&E(this.captureOptions,e);let t=this.captureOptions;t.deviceId&&t.deviceId!=bi&&(t={...this.captureOptions},t.deviceId={exact:this.captureOptions.deviceId});let r=await wi.getInstance().getUserMedia({audio:t,video:!1}).catch((e=>{throw N.fromCaptureError(e,"mic")}));this.setMediaStreamTrack(r.getTracks()[0])}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):be.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}async changeDeviceId(e){if(this.captureOptions.deviceId===e&&e!=bi)return;return this.captureOptions.deviceId=e,this.getMediaStreamTrack()?(this.stopCapture(),this.startCapture()):void 0}}class xi extends Ci{constructor(){super({id:P(20),kind:K.Video,track:-1},""),Ti(this,"playTrait",void 0),Ti(this,"simulcastTracks",{}),Ti(this,"scaleResolutionDownBy",1),Ti(this,"processorCtrl",void 0),this.playTrait=new Qr(this),this.processorCtrl=new Ei(this)}async setProcessor(e){return this.processorCtrl.setProcessor(e)}async removeProcessor(){return this.processorCtrl.removeProcessor()}strPrefix(){return"LocalVideoTrack"}setMediaStreamTrack(e){super.setMediaStreamTrack(e);for(let t in this.simulcastTracks)this.simulcastTracks[t].setMediaStreamTrack(e)}getSimulcastTrack(e,t,r){if(!e.desc)throw new N("Simulcast publish desc is required",M.InvalidArgument);let i=this.simulcastTracks[e.desc];if(!i){var n,o;i=this.simulcastTracks[e.desc]=new xi;const s=Math.min(t||(null===(n=this.mediaStreamTrack)||void 0===n?void 0:n.getSettings().width)||0,r||(null===(o=this.mediaStreamTrack)||void 0===o?void 0:o.getSettings().height)||0);s>0&&e.width&&e.height&&(i.scaleResolutionDownBy=Math.max(1,s/Math.min(e.width,e.height)),be.debug(i.toString(),`编码缩放倍数:${i.scaleResolutionDownBy}`)),i.setMediaStreamTrack(this.mediaStreamTrack)}return i}getSimulcastTracks(){return this.simulcastTracks}clearSimulcastTracks(){this.simulcastTracks={}}getScaleResolutionDownBy(){return this.scaleResolutionDownBy}addPlayView(e){this.playTrait.addPlayView(e)}refreshPlayView(){this.playTrait.refreshTransform()}hasPlayView(){return this.playTrait.hasPlayView()}removePlayView(e){this.playTrait.removePlayView(e)}removeAllPlayViews(){this.playTrait.removeAllPlayViews()}async enterPictureInPicture(e,t){return this.playTrait.enterPictureInPicture(e,t)}async exitPictureInPicture(e){return this.playTrait.exitPictureInPicture(e)}isPictureInPicture(e){return this.playTrait.isPictureInPicture(e)}popOutToWindow(e,t){return this.playTrait.popOutToWindow(e,t)}closePopOutWindow(e){this.playTrait.closePopOutWindow(e)}isPopOut(e){return this.playTrait.isPopOut(e)}}class Oi extends xi{constructor(e){super(),Ti(this,"captureOptions",void 0),Ti(this,"mirror",!0),this.captureOptions={...e}}strPrefix(){return"LocalCameraTrack"}onEnded(){be.warn(this.toString(),"异常结束,自动尝试默认摄像头(最多重试3次)"),k((()=>this.changeDeviceId(bi)),{maxRetries:3,initialDelay:500,onRetry:(e,t)=>{be.warn(this.toString(),`自动恢复默认摄像头第${e}次重试`,t)}})().catch((e=>{be.error(this.toString(),"异常结束,自动恢复默认摄像头最终失败",e),this.setMediaStreamTrack(void 0),super.onEnded()}))}async startCapture(e){e&&E(this.captureOptions,e);let t=this.captureOptions;t.deviceId&&t.deviceId!=bi&&(t={...this.captureOptions},t.deviceId={exact:this.captureOptions.deviceId});let r=await wi.getInstance().getUserMedia({audio:!1,video:t}).catch((e=>{throw N.fromCaptureError(e,"camera")}));this.setMediaStreamTrack(r.getTracks()[0])}stopCapture(){let e=this.getMediaStreamTrack();e?(e.stop(),this.setMediaStreamTrack(void 0)):be.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}async changeDeviceId(e){if(this.captureOptions.deviceId===e&&e!=bi)return;return this.captureOptions.deviceId=e,this.getMediaStreamTrack()?(this.stopCapture(),this.startCapture()):void 0}isFrontFacing(){return"environment"!==this.captureOptions.facingMode}setMirror(e){this.isFrontFacing()&&this.mirror!==e&&(this.mirror=e,this.refreshPlayView())}isMirrored(){return this.isFrontFacing()&&this.mirror}async switchFacingMode(){if(this.captureOptions.facingMode="environment"==this.captureOptions.facingMode?"user":"environment",this.getMediaStreamTrack())return this.stopCapture(),this.startCapture()}}class Mi extends xi{constructor(e){super(),Ti(this,"captureOptions",void 0),Ti(this,"audioTrack",void 0),this.captureOptions={...e}}strPrefix(){return"LocalScreenTrack"}setAudioTrack(e){this.audioTrack=e}getAudioTrack(){return this.audioTrack}async startCapture(e){if(e&&E(this.captureOptions,e),void 0===navigator.mediaDevices.getDisplayMedia)throw new N("getDisplayMedia is not supported by this browser",M.FeatureNotSupported);(await navigator.mediaDevices.getDisplayMedia({audio:!!this.audioTrack&&this.audioTrack.captureOptions,video:{displaySurface:"monitor",selfBrowserSurface:"exclude",surfaceSwitching:"include",...this.captureOptions}}).catch((e=>{throw N.fromCaptureError(e,"screen")}))).getTracks().forEach((e=>{var t;e.kind==K.Audio?null===(t=this.audioTrack)||void 0===t||t.setMediaStreamTrack(e):(this.setMediaStreamTrack(e),this.captureOptions.contentHint&&(e.contentHint=this.captureOptions.contentHint))}))}stopCapture(){var e;let t=this.getMediaStreamTrack();t?(t.stop(),this.setMediaStreamTrack(void 0),null===(e=this.audioTrack)||void 0===e||e.stopCapture()):be.warn(this.toString()+"的mediaStreamTrack不存在,无需停止采集")}}function Ni(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Li{constructor(e){var t;Ni(this,"tracks",void 0),Ni(this,"info",void 0),this.info=e,this.tracks={},null===(t=e.stream_tracks)||void 0===t||t.forEach((e=>{let t=this.newTrack(e);this.tracks[e.id]=t}))}getTrack(e){return this.tracks[e]}spawnTrack(e){return this.newTrack(e)}getTrackByDesc(e){for(let t in this.tracks)if(this.tracks[t].desc===e)return this.tracks[t]}getTracks(){return this.tracks}updateTracks(e){let t=[],r=[],i=[],n={},o={};for(let e in this.tracks)n[e]=!0,o[e]=this.tracks[e];e.forEach((e=>{let i=o[e.id];if(i){let t=i.updateInfo(e);delete n[e.id],t.length>0&&r.push(i)}else{let r=this.newTrack(e);this.tracks[e.id]=r,t.push(r)}}));for(let e in n){let t=this.tracks[e];t&&(delete this.tracks[e],i.push(t))}return this.info.stream_tracks=e,{added:t,updated:r,deleted:i}}get uid(){return this.info.uid}get sid(){return this.info.sid}get device_type(){return this.info.device_type}get device_id(){return this.info.device_id}get link_id(){return this.info.link_id}getInfo(){var e;let t={...this.info};return t.props={...t.props},t.stream_tracks=null===(e=t.stream_tracks)||void 0===e?void 0:e.map((e=>({...e}))),t}updateInfo(e){E(this.info,e)}}class Bi extends Li{newTrack(e){switch(e.kind){case K.Video:return new ii(e,this.uid);case K.Audio:return new Zr(e,this.uid)}}}function Di(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class ji extends xr{constructor(){super(...arguments),Di(this,"_trackIdx",0),Di(this,"trackRegistrar",void 0),Di(this,"adaptiveStream",void 0)}static create(e,t,r,i,n,o,s){return new ji(e,t,r,i,n,o,s)}newUser(e){return new Bi(e)}addStreamEngineListeners(){this.rtcStreamEngine.on(Dr.ConnectionQualityChanged,((e,t)=>{const r={evaluation:e,previous:t};this.triggerEvent(Mr.CONNECTION_QUALITY_CHANGED,r)})),this.rtcStreamEngine.on(Dr.CpuConstrained,(e=>{this.triggerEvent(Mr.CPU_CONSTRAINED,e)})),this.rtcStreamEngine.on(Dr.BandwidthConstrained,(e=>{this.triggerEvent(Mr.BANDWIDTH_CONSTRAINED,e)})),this.rtcStreamEngine.on(Lr.ActiveSpeakersChanged,(e=>{this.triggerEvent(Mr.ACTIVE_SPEAKERS_CHANGED,e)}))}getStreamMetric(){return this.rtcStreamEngine.getMetricSnapshot()}getNetworkStats(){var e;return null===(e=this.getStreamMetric())||void 0===e?void 0:e.network}getConnectionQuality(){return this.rtcStreamEngine.getQualityEvaluation()}async publishLocalTrack(e,t){this.checkNotLeft();const r=this.resolvePublishOptions(e,t);if(e instanceof Mi){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.publishLocalTrack(t)}if(e.kind==K.Video&&this.rtcStreamEngine.vendor()!=vr.Seastart){let t=r,i=e;if(t.simulcasts&&t.simulcasts.length>0)for(let e of t.simulcasts)await this.publishLocalTrack(i.getSimulcastTrack(e,t.width,t.height),e)}return super.publishLocalTrack(e,r)}async unpublishLocalTrack(e){if(await super.unpublishLocalTrack(e),e instanceof Mi){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.unpublishLocalTrack(t)}if(e.kind==K.Video){let t=e,r=t.getSimulcastTracks();if(this.rtcStreamEngine.vendor()!=vr.Seastart)for(let e in r)await this.unpublishLocalTrack(r[e]);0===e.publishState.count&&t.clearSimulcastTracks()}}async getPublishExOption(e,t){let r={};if(this.rtcStreamEngine.vendor()===vr.OOK){let t=-1;e.kind==K.Video&&(t=this.rtcStreamEngine.getAvailableVideoTrackNo()),r={track:t},this.updatePublishInfo(e,{track:t})}else this.updatePublishInfo(e,{track:this._trackIdx++});return r}createPublishRecords(e,t){let r=super.createPublishRecords(e,t);if(e.kind==K.Video){let i=t,n=e;if(i.simulcasts&&i.simulcasts.length>0)switch(this.rtcStreamEngine.vendor()){case vr.Seastart:for(let e=0;e<i.simulcasts.length;e++){let t=i.simulcasts[e],o=n.getSimulcastTrack(t,i.width,i.height);this.newPublishRecord(o,y({desc:t.desc,codec:t.codec,width:t.width,height:t.height,fps:t.maxFramerate,bitrate:t.maxBitrate,props:t.props})),r.push(o)}break;default:{const t=i.simulcasts.map((e=>{var t;return null===(t=this.getPublishRecord(n.getSimulcastTrack(e,i.width,i.height)))||void 0===t?void 0:t.info.id})).filter((e=>!!e));t.length>0&&this.updatePublishInfo(e,{variant:!0,fallback_ids:t});break}}}return r}getDeletedTracksAfterUnpublish(e){let t=super.getDeletedTracksAfterUnpublish(e);if(this.rtcStreamEngine.vendor()===vr.Seastart)if(e.kind==K.Video){let r=e;for(let e of Object.values(r.getSimulcastTracks()))this.getPublishRecord(e)&&t.push(e)}return t}async getSubscribeExOption(e){let t={};switch(this.rtcStreamEngine.vendor()){case vr.OOK:if(e instanceof ei){let r=[];e.getFilterUids().forEach((e=>{if(e&&e!=this.joinRsp.uid)try{let t=this.getUser(e);r.push(t.link_id)}catch(e){}})),t={filter_link_ids:r}}else if(e instanceof ni)t={};else{let r=this.getUser(e.getUid()),i=e.getInfo();t={link_id:r.link_id,track:i.track}}break;case vr.Seastart:{var r;const i=e.getInfo();t={prefer_track_ids:null!==(r=i.fallback_ids)&&void 0!==r&&r.length?[e.id,...i.fallback_ids]:[]};break}}return t}newRemoteAudioMixTrack(e){if(this.getStreamEngineVendor()==vr.OOK)return new ei({id:V,desc:"频道混音流",kind:K.Audio},Array.isArray(e)?e:[]);if(e&&Array.isArray(e)){let t=e;e=e=>t.includes(e.getUid())}return new ti({id:V,desc:"频道混音流",kind:K.Audio},e)}newRemoteVideoMcuTrack(){return new ni}newRemoteAudioMcuTrack(){return new ri}async subscribeRemoteAudioMixTrack(e){var t;const r=await super.subscribeRemoteAudioMixTrack(e);return null===(t=this.trackRegistrar)||void 0===t||t.call(this,r),r}async subscribeRemoteAudioTrack(e,t){var r;const i=await super.subscribeRemoteAudioTrack(e,t);return null===(r=this.trackRegistrar)||void 0===r||r.call(this,i),i}async subscribeRemoteVideoMcuTrack(){var e;const t=await super.subscribeRemoteVideoMcuTrack();return null===(e=this.trackRegistrar)||void 0===e||e.call(this,t),t}async subscribeRemoteAudioMcuTrack(){var e;const t=await super.subscribeRemoteAudioMcuTrack();return null===(e=this.trackRegistrar)||void 0===e||e.call(this,t),t}async subscribeRemoteVideoTrack(e,t){var r;const i=await super.subscribeRemoteVideoTrack(e,t);return i instanceof ii&&this.getAdaptiveStream().attach(i),null===(r=this.trackRegistrar)||void 0===r||r.call(this,i),i}async unsubscribeRemoteTrack(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3;t<=0&&e instanceof ii&&this.getAdaptiveStream().detach(e),await super.unsubscribeRemoteTrack(e,t)}getAdaptiveStream(){return this.adaptiveStream||(this.adaptiveStream=new mi(this.rtcStreamEngine,this.options.adaptiveStream,(e=>this.getAdaptiveVideoCandidates(e)))),this.adaptiveStream}getAdaptiveVideoCandidates(e){const t=this.getUser(e.getUid()),r=[e.id,...e.getInfo().fallback_ids||[]],i=[];for(const e of r){const r=t.getTrack(e);r instanceof ii&&i.push(r)}return i}}const Ui={speech:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:24e3,priority:"high"}},music:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:32e3,priority:"high"}},musicStereo:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:2,sampleRate:48e3},publish:{desc:"mic",maxBitrate:48e3,priority:"high"}},musicHighQuality:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:1,sampleRate:48e3},publish:{desc:"mic",maxBitrate:64e3,priority:"high"}},musicHighQualityStereo:{capture:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,channelCount:2,sampleRate:48e3},publish:{desc:"mic",maxBitrate:96e3,priority:"high"}}},Fi=[{desc:"camera_small",width:320,height:180,maxBitrate:25e4,maxFramerate:15}],Vi={"1080p":{capture:{width:1920,height:1080,frameRate:15},publish:{desc:"camera_big",maxBitrate:25e5,maxFramerate:15,simulcasts:Fi,degradationPreference:"maintain-resolution"}},"720p":{capture:{width:1280,height:720,frameRate:15},publish:{desc:"camera_big",maxBitrate:12e5,maxFramerate:15,simulcasts:Fi,degradationPreference:"maintain-resolution"}},"360p":{capture:{width:640,height:360,frameRate:15},publish:{maxBitrate:55e4,maxFramerate:15}},"180p":{capture:{width:320,height:180,frameRate:15},publish:{maxBitrate:25e4,maxFramerate:15}}},Wi={"1080p":{capture:{width:1920,height:1080,frameRate:10},publish:{desc:"screen",maxBitrate:2e6,maxFramerate:10,priority:"medium",degradationPreference:"maintain-resolution"}},"720p":{capture:{width:1280,height:720,frameRate:10},publish:{desc:"screen",maxBitrate:15e5,maxFramerate:10,priority:"medium",degradationPreference:"maintain-resolution"}}},qi={default:{capture:!0,publish:{desc:"screen_audio",maxBitrate:24e3,priority:"high"}}};class Hi extends ar{}function Ki(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const zi="#101216",$i="rgba(0, 0, 0, 0.58)",Gi=1129136434,Qi=1129136441;class Ji{constructor(){Ki(this,"canvas",void 0),Ki(this,"canvasContext",void 0),Ki(this,"canvasStream",void 0),Ki(this,"recordStream",void 0),Ki(this,"mediaRecorder",void 0),Ki(this,"audioContext",void 0),Ki(this,"audioDestination",void 0),Ki(this,"audioSources",new Map),Ki(this,"audioInputTracks",[]),Ki(this,"trackedTrackListeners",new Map),Ki(this,"videoElements",new Map),Ki(this,"avatarImages",new Map),Ki(this,"avatarFailedUrls",new Set),Ki(this,"chunks",[]),Ki(this,"videoItems",[]),Ki(this,"width",1280),Ki(this,"height",720),Ki(this,"fps",15),Ki(this,"background",zi),Ki(this,"labelBackground",$i),Ki(this,"animationFrameId",0),Ki(this,"onDataAvailable",void 0),Ki(this,"render",(()=>{if(!this.canvas||!this.canvasContext)return;const e=this.canvasContext;e.fillStyle=this.background,e.fillRect(0,0,this.width,this.height),this.videoItems.forEach((t=>{const r=t.rect;e.fillStyle=t.background||"#1a1c22",e.fillRect(r.x,r.y,r.width,r.height);const i=this.resolveMediaStreamTrack(t.track),n=i?this.videoElements.get(i):void 0;!!n&&n.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&n.videoWidth>0&&n.videoHeight>0?this.drawVideo(e,n,t):i||!t.avatar&&!t.label||this.drawAvatarPlaceholder(e,t),t.label&&this.drawLabel(e,t)})),this.animationFrameId=requestAnimationFrame(this.render)}))}getState(){var e;const t=null===(e=this.mediaRecorder)||void 0===e?void 0:e.state;return"recording"===t||"paused"===t?t:"inactive"}async start(e){var t;if("inactive"!==this.getState())return;if("undefined"==typeof MediaRecorder)throw new N("MediaRecorder is not supported by this browser",M.FeatureNotSupported);this.width=e.width||1280,this.height=e.height||720,this.fps=e.fps||15,this.background=e.background||zi,this.labelBackground=e.labelBackground||$i,this.onDataAvailable=e.onDataAvailable,this.videoItems=e.videoItems.slice(),this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height;const r=this.canvas.getContext("2d");if(!r)throw new N("Failed to create recorder canvas context",M.InternalError);this.canvasContext=r,this.canvasStream=this.canvas.captureStream(this.fps),await this.initAudio(e.audioTracks||[]),this.syncTrackedTrackListeners(),this.syncVideoElements(),this.syncAvatarImages();const i=[...this.canvasStream.getVideoTracks(),...(null===(t=this.audioDestination)||void 0===t?void 0:t.stream.getAudioTracks())||[]];this.recordStream=new MediaStream(i);const n=(o=e.mimeType)&&MediaRecorder.isTypeSupported(o)?o:["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find((e=>MediaRecorder.isTypeSupported(e)))||"";var o;this.mediaRecorder=new MediaRecorder(this.recordStream,n?{mimeType:n}:void 0),this.mediaRecorder.ondataavailable=e=>{var t;e.data.size<=0||(this.chunks.push(e.data),null===(t=this.onDataAvailable)||void 0===t||t.call(this,e.data))},this.render(),this.mediaRecorder.start(e.timeslice)}updateVideoItems(e){this.videoItems=e.slice(),this.syncTrackedTrackListeners(),this.syncVideoElements(),this.syncAvatarImages()}async updateAudioTracks(e){this.audioContext&&this.audioDestination&&(this.audioInputTracks=e.slice(),this.syncTrackedTrackListeners(),this.setAudioTracks(e),"suspended"===this.audioContext.state&&await this.audioContext.resume())}pause(){var e;"recording"===(null===(e=this.mediaRecorder)||void 0===e?void 0:e.state)&&this.mediaRecorder.pause()}resume(){var e;"paused"===(null===(e=this.mediaRecorder)||void 0===e?void 0:e.state)&&this.mediaRecorder.resume()}stop(){if(!this.mediaRecorder)return Promise.resolve(new Blob([],{type:"video/webm"}));const e=this.mediaRecorder;return new Promise((t=>{e.onstop=()=>{const r=new Blob(this.chunks,{type:e.mimeType||"video/webm"});this.cleanup(),t(r)},"inactive"===e.state?e.onstop(new Event("stop")):e.stop()}))}destroy(){this.mediaRecorder&&"inactive"!==this.mediaRecorder.state&&this.mediaRecorder.stop(),this.cleanup()}async initAudio(e){this.audioContext=new AudioContext,this.audioDestination=this.audioContext.createMediaStreamDestination(),this.audioInputTracks=e.slice(),this.setAudioTracks(e),"suspended"===this.audioContext.state&&await this.audioContext.resume()}setAudioTracks(e){this.clearAudioSources(),e.forEach((e=>{const t=this.resolveMediaStreamTrack(e);if(!t||"live"!==t.readyState||!this.audioContext||!this.audioDestination)return;const r=new MediaStream([t]),i=this.audioContext.createMediaStreamSource(r);i.connect(this.audioDestination),this.audioSources.set(t.id,{source:i,stream:r})}))}clearAudioSources(){this.audioSources.forEach((e=>{let{source:t}=e;return t.disconnect()})),this.audioSources.clear()}resolveMediaStreamTrack(e){if(e)return e instanceof MediaStreamTrack?e:e.getMediaStreamTrack()}resolveTrackAngle(e){var t;const r=e;return null!==(t=null==r?void 0:r.angle)&&void 0!==t?t:1129136432}isTrackLike(e){return!(!e||e instanceof MediaStreamTrack||"function"!=typeof e.getMediaStreamTrack||"function"!=typeof e.on||"function"!=typeof e.off)}syncTrackedTrackListeners(){const e=new Set;this.videoItems.forEach((t=>{this.isTrackLike(t.track)&&e.add(t.track)})),this.audioInputTracks.forEach((t=>{this.isTrackLike(t)&&e.add(t)})),this.trackedTrackListeners.forEach(((t,r)=>{e.has(r)||(r.off(Nr.MSTRACK_REPLACED,t),this.trackedTrackListeners.delete(r))})),e.forEach((e=>{if(this.trackedTrackListeners.has(e))return;const t=()=>{this.syncVideoElements(),this.setAudioTracks(this.audioInputTracks)};e.on(Nr.MSTRACK_REPLACED,t),this.trackedTrackListeners.set(e,t)}))}clearTrackedTrackListeners(){this.trackedTrackListeners.forEach(((e,t)=>{t.off(Nr.MSTRACK_REPLACED,e)})),this.trackedTrackListeners.clear()}syncVideoElements(){const e=new Set;this.videoItems.forEach((t=>{const r=this.resolveMediaStreamTrack(t.track);if(!r||"live"!==r.readyState)return;if(e.add(r),this.videoElements.has(r))return;const i=document.createElement("video");i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.srcObject=new MediaStream([r]),i.play().catch((()=>{})),this.videoElements.set(r,i)})),this.videoElements.forEach(((t,r)=>{e.has(r)||(t.srcObject=null,this.videoElements.delete(r))}))}syncAvatarImages(){const e=new Set;this.videoItems.forEach((t=>{if(!t.avatar)return;if(e.add(t.avatar),this.avatarImages.has(t.avatar))return;const r=t.avatar,i=new Image;i.crossOrigin="anonymous",i.onerror=()=>{this.avatarFailedUrls.add(r)},i.src=r,this.avatarImages.set(r,i)})),this.avatarImages.forEach(((t,r)=>{e.has(r)||(this.avatarImages.delete(r),this.avatarFailedUrls.delete(r))}))}drawVideo(e,t,r){const i=r.rect,n=r.fit||"contain",o=this.resolveTrackAngle(r.track),s=function(e){return e===Gi||e===Qi}(o),a=s?t.videoHeight/t.videoWidth:t.videoWidth/t.videoHeight,c=i.width/i.height;let u,l;("cover"===n?a>c:a<c)?(l=i.height,u=l*a):(u=i.width,l=u/a);const h=s?l:u,d=s?u:l;switch(e.save(),e.beginPath(),e.rect(i.x,i.y,i.width,i.height),e.clip(),e.translate(i.x+i.width/2,i.y+i.height/2),o){case Qi:e.scale(-1,1),e.rotate(-Math.PI/2);break;case Gi:e.rotate(3*Math.PI/2);break;case 1129136433:e.rotate(Math.PI)}e.drawImage(t,-h/2,-d/2,h,d),e.restore()}drawLabel(e,t){const r=t.rect,i=r.x+12,n=r.y+r.height-42,o=Math.max(80,r.width-24);e.fillStyle=this.labelBackground,e.fillRect(i,n,o,30),e.fillStyle="#fff",e.font="16px sans-serif",e.textAlign="left",e.textBaseline="middle",e.fillText(t.label||"",i+10,n+15,o-20)}drawAvatarPlaceholder(e,t){const r=t.rect,i=r.x+r.width/2,n=r.y+r.height/2,o=Math.min(Math.max(.4*Math.min(r.width,r.height),48),180),s=o/2,a=t.avatar?this.avatarImages.get(t.avatar):void 0;if(!!a&&!!t.avatar&&!this.avatarFailedUrls.has(t.avatar)&&a.complete&&a.naturalWidth>0&&a.naturalHeight>0){const t=a.naturalWidth/a.naturalHeight;let r=o,c=o;return t>1?r=o*t:c=o/t,e.save(),e.beginPath(),e.arc(i,n,s,0,2*Math.PI),e.clip(),e.drawImage(a,i-r/2,n-c/2,r,c),void e.restore()}e.save(),e.beginPath(),e.arc(i,n,s,0,2*Math.PI),e.fillStyle="#4a4e57",e.fill(),e.fillStyle="#e6e8ec",e.font=`${Math.round(s)}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(this.avatarInitial(t.label),i,n),e.restore()}avatarInitial(e){const t=Array.from((e||"").trim())[0];return t?t.toUpperCase():"?"}cleanup(){var e,t,r;cancelAnimationFrame(this.animationFrameId),null===(e=this.canvasStream)||void 0===e||e.getTracks().forEach((e=>e.stop())),null===(t=this.recordStream)||void 0===t||t.getTracks().forEach((e=>{var t;null!==(t=this.canvasStream)&&void 0!==t&&t.getTracks().includes(e)||e.stop()})),this.videoElements.forEach((e=>{e.srcObject=null})),this.videoElements.clear(),this.avatarImages.clear(),this.avatarFailedUrls.clear(),this.clearAudioSources(),this.clearTrackedTrackListeners(),null===(r=this.audioContext)||void 0===r||r.close(),this.audioContext=void 0,this.audioDestination=void 0,this.canvas=void 0,this.canvasContext=void 0,this.canvasStream=void 0,this.recordStream=void 0,this.mediaRecorder=void 0,this.audioInputTracks=[],this.videoItems=[],this.chunks=[],this.onDataAvailable=void 0}}function Yi(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Xi extends li{constructor(){super(...arguments),Yi(this,"streamNameStates",{}),Yi(this,"onPubTrackReconnecting",((e,t,r)=>{if(!this.published[e.id])return;const i=this.published[e.id];"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=vr.OOK&&"closed"!=i.pc.signalingState?i.pc.restartIce():(i.pc.close(),this.doPublish(e,t,r,!0))})),Yi(this,"onSubTrackReconnecting",((e,t)=>{if(!this.subscribed[e.id])return!1;const r=this.subscribed[e.id];"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=vr.OOK&&"closed"!=r.pc.signalingState?r.pc.restartIce():(r.pc.close(),this.doSubscribe(e,t,!0))}))}createMockAudioTrack(){const e=new AudioContext,t=e.createOscillator(),r=e.createMediaStreamDestination();t.connect(r),t.start();const i=r.stream.getAudioTracks()[0];return i.enabled=!1,i}createMockVideoTrack(){const e=document.createElement("canvas");e.width=640,e.height=480;const t=e.getContext("2d");t.fillStyle="black",t.fillRect(0,0,e.width,e.height);return e.captureStream(1).getVideoTracks()[0]}async publish(e,t,r){this.published[e.id]?this.logger.warn("推流",e.toString(),"进行中,当前状态",this.published[e.id].pc.connectionState):(await super.publish(e,t,r),await this.doPublish(e,t,r,!1),e.on(Nr.MSTRACK_REPLACED,this.onPubMsTrackReplace),e.on(Nr.RECONNECTING,this.onPubTrackReconnecting))}async unpublish(e){var t;if(!this.published[e.id])return void this.logger.warn("推流",e.toString(),"已取消,无需取消发布");e.off(Nr.MSTRACK_REPLACED,this.onPubMsTrackReplace),e.off(Nr.RECONNECTING,this.onPubTrackReconnecting);const r=this.published[e.id],i=null===(t=r.opt)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.streamName;if(i&&this.streamNameStates[i]){const t=this.streamNameStates[i];var n;if(e.kind===K.Audio&&t.audioTrack===e)await(null===(n=t.audioSender)||void 0===n?void 0:n.replaceTrack(t.mockAudioTrack)),t.audioTrack=null,this.logger.warn("推流",e.toString(),`unpublished (替换为mock,streamName=${i})`);else if(e.kind===K.Video&&t.videoTrack===e){var o;await(null===(o=t.videoSender)||void 0===o?void 0:o.replaceTrack(t.mockVideoTrack)),t.videoTrack=null,this.logger.warn("推流",e.toString(),`unpublished (替换为mock,streamName=${i})`)}return delete this.published[e.id],void(null===t.audioTrack&&null===t.videoTrack&&(t.pc.close(),t.mockAudioTrack.stop(),t.mockVideoTrack.stop(),delete this.streamNameStates[i],this.logger.info("推流",`streamName=${i},所有 track 已 unpublish,关闭 PC`)))}r.pc.close(),delete this.published[e.id],this.logger.warn("推流",e.toString(),"unpublished")}async doPublish(e,t,r,i){var n;let o=e.getMediaStreamTrack();const s=null===(n=t.props)||void 0===n?void 0:n.streamName,a=s&&!i?this.streamNameStates[s]:void 0;if(a){if(e.kind===K.Audio&&null!==a.audioTrack)throw new N(`streamName=${s} already has an audio track, unpublish it first`,M.PublishDescConflict);if(e.kind===K.Video&&null!==a.videoTrack)throw new N(`streamName=${s} already has a video track, unpublish it first`,M.PublishDescConflict)}let c=a?a.pc:new RTCPeerConnection(this.dftPCConfig),u={kind:e.kind,pc:c,track:e,opt:t,exopt:r||{}};this.published[e.id]=u;let l={maxBitrate:t.maxBitrate,priority:t.priority,networkPriority:t.priority};e.kind==K.Video&&(l.maxFramerate=t.maxFramerate,l.scaleResolutionDownBy=e.getScaleResolutionDownBy());let h=k((()=>this.negotiateSDP(u,"publish")),{maxRetries:10,initialDelay:500,onRetry:(t,r)=>!!this.published[e.id]&&(this.logger.warn("推流",e.toString(),`建连重试第${t}次`,r),!0)}),d=()=>{h().catch((t=>{"maxretry"==t&&this.logger.error("推流",e.toString(),"建连多次重试依旧无法连接,已放弃")}))},f=()=>{i?(this.vendor()!=vr.OOK&&"closed"!=c.signalingState||h.cancel(),this.logger.error("推流",e.toString(),"已断开,将自动尝试重连"),e.emit(Nr.RECONNECTING,e,t,r)):(h.cancel(),this.unpublish(e))};return new Promise((async(r,n)=>{let h=setTimeout((()=>{f(),n(new N("Publish timeout",M.PublishTimeout))}),6e4);if(c.addEventListener("negotiationneeded",(()=>{this.logger.info("推流",e.toString(),"重新协商"),d()})),c.addEventListener("icecandidate",(t=>{this.logger.debug("推流",e.toString(),"icecandidate",t.candidate)})),c.addEventListener("iceconnectionstatechange",(t=>{this.logger.debug("推流",e.toString(),"ICE connection state change",c.iceConnectionState)})),c.addEventListener("signalingstatechange",(t=>{this.logger.debug("推流",e.toString(),"signaling state change",c.signalingState),"closed"==c.signalingState&&(f(),n(new N("Publish PeerConnection closed",M.PeerConnectionFailed)))})),c.addEventListener("connectionstatechange",(t=>{switch(this.logger.debug("推流",e.toString(),"connection state",c.connectionState),c.connectionState){case"failed":case"closed":f(),n(new N("Publish PeerConnection "+c.connectionState,M.PeerConnectionFailed));break;case"connected":this.logger.warn("推流",e.toString(),"connected"),clearTimeout(h),i?e.emit(Nr.RECONNECTED,e):i=!0,this.updateTrackInfoAfterPublish(e),r()}})),a){var p,g;if(e.kind===K.Audio)await(null===(p=a.audioSender)||void 0===p?void 0:p.replaceTrack(o)),a.audioTrack=e,u.sender=a.audioSender;else await(null===(g=a.videoSender)||void 0===g?void 0:g.replaceTrack(o)),a.videoTrack=e,u.sender=a.videoSender;let i=u.sender.getParameters();return i.encodings=[l],e.kind==K.Video&&t.degradationPreference&&(i.degradationPreference=t.degradationPreference),u.sender.setParameters(i),this.updateTrackInfoAfterPublish(e),clearTimeout(h),this.logger.warn("推流",e.toString(),`streamName=${s},replaceTrack 成功`),void r()}s&&!this.streamNameStates[s]&&this.initStreamNameState(c,s);let m=!1;if("addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=vr.OOK){let e=c.addTransceiver(o,{direction:"sendonly",sendEncodings:[l]});u.sender=e.sender}else{let e=c.addTrack(o);u.sender=e,m=!0}let v=u.sender.getParameters();if(m&&(v.encodings=[l]),e.kind==K.Video&&t.degradationPreference&&(v.degradationPreference=t.degradationPreference),u.sender.setParameters(v),s&&this.streamNameStates[s]){const t=this.streamNameStates[s];if(e.kind===K.Audio){t.audioTrack=e,t.audioSender=u.sender;const r=c.addTransceiver(t.mockVideoTrack,{direction:"sendonly"});t.videoSender=r.sender}else{t.videoTrack=e,t.videoSender=u.sender;const r=c.addTransceiver(t.mockAudioTrack,{direction:"sendonly"});t.audioSender=r.sender}}}))}initStreamNameState(e,t){const r={pc:e,audioTrack:null,audioSender:null,mockAudioTrack:this.createMockAudioTrack(),videoTrack:null,videoSender:null,mockVideoTrack:this.createMockVideoTrack()};return this.streamNameStates[t]=r,this.logger.info("推流",`streamName=${t},初始化合流状态`),r}async subscribe(e,t){this.subscribed[e.id]?this.logger.warn("拉流",e.toString(),"进行中,当前状态",this.subscribed[e.id].pc.connectionState):(await super.subscribe(e,t),await this.doSubscribe(e,t,!1),e.on(Nr.RECONNECTING,this.onSubTrackReconnecting))}async unsubscribe(e){if(!this.subscribed[e.id])return void this.logger.warn("拉流",e.toString(),"未订阅或已取消,无需取消订阅");e.off(Nr.RECONNECTING,this.onSubTrackReconnecting);this.subscribed[e.id].pc.close(),this.logger.warn("拉流",e.toString(),"unsubscribed"),delete this.subscribed[e.id]}async doSubscribe(e,t,r){let i=new RTCPeerConnection(this.dftPCConfig),n={kind:e.kind,pc:i,track:e,exopt:t||{}};this.subscribed[e.id]=n;let o=k((()=>this.negotiateSDP(n,"subscribe")),{maxRetries:10,initialDelay:500,onRetry:(t,r)=>!!this.subscribed[e.id]&&(this.logger.warn("拉流",e.toString(),`建连重试第${t}次`,r),!0)}),s=()=>{o().catch((t=>{"maxretry"==t&&this.logger.error("拉流",e.toString(),"建连多次重试依旧无法连接,已放弃")}))},c=()=>{r?(this.vendor()!=vr.OOK&&"closed"!=i.signalingState||o.cancel(),this.logger.error("拉流",e.toString(),"已断开,将自动尝试重连"),e.emit(Nr.RECONNECTING,e,t)):(o.cancel(),this.unsubscribe(e))};return new Promise((async(t,n)=>{let o=setTimeout((()=>{c(),n(new N("Subscribe timeout",M.SubscribeTimeout))}),6e4);i.addEventListener("negotiationneeded",(()=>{this.logger.info("拉流",e.toString(),"重新协商"),s()})),i.addEventListener("icecandidate",(t=>{this.logger.debug("拉流",e.toString(),"icecandidate",t.candidate)})),i.addEventListener("iceconnectionstatechange",(t=>{this.logger.debug("拉流",e.toString(),"ICE connection state change",i.iceConnectionState)})),i.addEventListener("signalingstatechange",(t=>{this.logger.debug("拉流",e.toString(),"signaling state change",i.signalingState),"closed"==i.signalingState&&(c(),n(new N("Subscribe PeerConnection closed",M.PeerConnectionFailed)))})),i.addEventListener("track",(t=>{e.setMediaStreamTrack(t.track),(e instanceof ii||e instanceof Zr)&&e.setRtpReceiver(t.receiver),t.streams[0].onremovetrack=t=>{this.logger.warn("拉流",e.toString(),"mstrack removed"),e.emit(a.ENDED,e)},this.logger.warn("拉流",e.toString(),"mstrack got")})),i.addEventListener("connectionstatechange",(s=>{switch(this.logger.debug("拉流",e.toString(),"connection state",i.connectionState),i.connectionState){case"failed":case"closed":c(),n(new N("Subscribe PeerConnection "+i.connectionState,M.PeerConnectionFailed));break;case"connected":this.logger.warn("拉流",e.toString(),"connected"),clearTimeout(o),r?e.emit(Nr.RECONNECTED,e):r=!0,t()}})),"addTransceiver"in RTCPeerConnection.prototype&&this.vendor()!=vr.OOK?i.addTransceiver(e.kind,{direction:"recvonly"}):s()}))}async getMetric(){var e,t,r,i,n;const o={bitrate_down:0,bitrate_up:0,lossrate_down:0,lossrate_up:0,pkt_up:0,pkt_down:0,pkt_loss_up:0,pkt_loss_down:0},s=null===(e=this.prevMetric)||void 0===e?void 0:e.network;let a=0,c=0,u=0,l=0,h=0,d=0;const f=[],p=[];for(const e in this.published){var g,m;const t=this.published[e],r=null!==(g=null===(m=this.publisher)||void 0===m?void 0:m.getPublishInfo(t.track))&&void 0!==g?g:t.track.getRawInfo(),i=t.track.prevStats,n=await t.pc.getStats(),s=si(n);s&&(null!=s.availableOutgoingBitrate&&(a=Math.max(a,s.availableOutgoingBitrate)),null!=s.currentRoundTripTime&&(u+=1e3*s.currentRoundTripTime,l++)),t.kind==K.Audio?(n.forEach((e=>{if("outbound-rtp"===e.type){const s={type:"audio",streamId:e.id,packetsSent:e.packetsSent,bytesSent:e.bytesSent,timestamp:e.timestamp},a=n.get(e.mediaSourceId);a&&(s.audioLevel=a.audioLevel);const c=n.get(e.remoteId);c&&(s.jitter=null!=c.jitter?1e3*c.jitter:void 0,s.packetsLost=c.packetsLost,s.roundTripTime=null!=c.roundTripTime?1e3*c.roundTripTime:void 0),r.bitrate=i?oi(s,i):0,r.db=s.audioLevel?R(s.audioLevel):-60,r.stats=s,t.track.prevStats=s,o.bitrate_up+=r.bitrate,o.pkt_up+=s.packetsSent||0,o.pkt_loss_up+=s.packetsLost||0}})),f.push(r)):(n.forEach((e=>{if("outbound-rtp"===e.type){var s;const a={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,framesPerSecond:e.framesPerSecond,framesSent:e.framesSent,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationDurations:e.qualityLimitationDurations,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges,rid:null!==(s=e.rid)&&void 0!==s?s:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,targetBitrate:e.targetBitrate,timestamp:e.timestamp},c=n.get(e.remoteId);c&&(a.jitter=null!=c.jitter?1e3*c.jitter:void 0,a.packetsLost=c.packetsLost,a.roundTripTime=null!=c.roundTripTime?1e3*c.roundTripTime:void 0),r.width=a.frameWidth,r.height=a.frameHeight,r.fps=a.framesPerSecond,r.bitrate=i?oi(a,i):0,r.stats=a,t.track.prevStats=a,o.bitrate_up+=r.bitrate,o.pkt_up+=a.packetsSent||0,o.pkt_loss_up+=a.packetsLost||0}})),p.push(r))}const v=[],y=[];for(const e in this.subscribed){const t=this.subscribed[e],r=t.track.getInfo();r.uid=t.track.getUid();const i=t.track.prevStats,n=await t.pc.getStats(),s=si(n);null!=(null==s?void 0:s.availableIncomingBitrate)&&(c=Math.max(c,s.availableIncomingBitrate)),null!=(null==s?void 0:s.currentRoundTripTime)&&(h+=1e3*s.currentRoundTripTime,d++),t.kind==K.Audio?(n.forEach((e=>{if("inbound-rtp"===e.type){const n={type:"audio",streamId:e.id,timestamp:e.timestamp,jitter:null!=e.jitter?1e3*e.jitter:void 0,jitterBufferDelay:null!=e.jitterBufferDelay?1e3*e.jitterBufferDelay:void 0,jitterBufferEmittedCount:e.jitterBufferEmittedCount,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,bytesReceived:e.bytesReceived,concealedSamples:e.concealedSamples,concealmentEvents:e.concealmentEvents,silentConcealedSamples:e.silentConcealedSamples,silentConcealmentEvents:e.silentConcealmentEvents,audioLevel:e.audioLevel,totalAudioEnergy:e.totalAudioEnergy,totalSamplesDuration:e.totalSamplesDuration};n.jitterBufferAvgDelay=ai(n,i),r.bitrate=i?oi(n,i):0,r.db=n.audioLevel?R(n.audioLevel):-60,r.stats=n,t.track.prevStats=n,o.bitrate_down+=r.bitrate,o.pkt_down+=n.packetsReceived||0,o.pkt_loss_down+=n.packetsLost||0}})),v.push(r)):(n.forEach((e=>{if("inbound-rtp"===e.type){const s={type:"video",streamId:e.id,framesDecoded:e.framesDecoded,framesDropped:e.framesDropped,framesReceived:e.framesReceived,packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,framesPerSecond:e.framesPerSecond,frameWidth:e.frameWidth,frameHeight:e.frameHeight,pliCount:e.pliCount,firCount:e.firCount,nackCount:e.nackCount,jitter:null!=e.jitter?1e3*e.jitter:void 0,jitterBufferDelay:null!=e.jitterBufferDelay?1e3*e.jitterBufferDelay:void 0,jitterBufferEmittedCount:e.jitterBufferEmittedCount,timestamp:e.timestamp,bytesReceived:e.bytesReceived,decoderImplementation:e.decoderImplementation,freezeCount:e.freezeCount,totalFreezesDuration:e.totalFreezesDuration,pauseCount:e.pauseCount,totalPausesDuration:e.totalPausesDuration,framesAssembledFromMultiplePackets:e.framesAssembledFromMultiplePackets,totalAssemblyTime:e.totalAssemblyTime},a=n.get(e.codecId);a&&(s.mimeType=a.mimeType),s.jitterBufferAvgDelay=ai(s,i),r.width=s.frameWidth,r.height=s.frameHeight,r.fps=e.framesPerSecond||(i?ci(s,i):0),r.bitrate=i?oi(s,i):0,r.stats=s,t.track.prevStats=s,o.bitrate_down+=r.bitrate,o.pkt_down+=s.packetsReceived||0,o.pkt_loss_down+=s.packetsLost||0}})),y.push(r))}a>0&&(o.available_outgoing_bitrate=C(a/1e3,2)),c>0&&(o.available_incoming_bitrate=C(c/1e3,2)),l>0&&(o.rtt_up=C(u/l,2)),d>0&&(o.rtt_down=C(h/d,2));const b=o.pkt_up-(null!==(t=null==s?void 0:s.pkt_up)&&void 0!==t?t:0),w=o.pkt_down-(null!==(r=null==s?void 0:s.pkt_down)&&void 0!==r?r:0),S=o.pkt_loss_up-(null!==(i=null==s?void 0:s.pkt_loss_up)&&void 0!==i?i:0),_=o.pkt_loss_down-(null!==(n=null==s?void 0:s.pkt_loss_down)&&void 0!==n?n:0);return o.lossrate_up=C(b>0?S/b*100:0,2),o.lossrate_down=C(w>0?_/w*100:0,2),this.prevMetric={local_audios:f,local_videos:p,remote_audios:v,remote_videos:y,network:o}}}function Zi(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class en extends Xi{constructor(){super(...arguments),Zi(this,"localAudioMixTrack",new Ai),Zi(this,"ability",{audioCodecs:[z.OPUS,z.AAC],videoCodecs:[z.H264,z.H265],audioMaxPub:1,videoMaxPub:7,audioMaxSub:9,videoMaxSub:32})}vendor(){return vr.OOK}async connect(){try{await this.free()}catch(e){}await this.create(),await super.connect()}async disconnect(){await super.disconnect(),await this.free()}async publish(e,t,r){if(e!=this.localAudioMixTrack&&e.kind==K.Audio)return this.localAudioMixTrack.addTrack(e),this.published[this.localAudioMixTrack.id]?void 0:await this.publish(this.localAudioMixTrack,t,r);await super.publish(e,t,r)}async unpublish(e){if(e!=this.localAudioMixTrack&&e.kind==K.Audio)return this.localAudioMixTrack.removeTrack(e),void(0==this.localAudioMixTrack.getTrackCount()&&await this.unpublish(this.localAudioMixTrack));let t=this.published[e.id];if(await super.unpublish(e),t)try{await this.freshAVState(t.exopt.session),await this.hangup(t.exopt.session)}catch(e){this.logger.error("ook webrtc取消发布接口报错",e)}}async unsubscribe(e){let t=this.subscribed[e.id];if(await super.unsubscribe(e),t)try{await this.hangup(t.exopt.session)}catch(e){this.logger.error("ook webrtc取消订阅接口报错",e)}}async negotiateSDP(e,t){var r;let i=this.genSessionId();if(e.exopt.session)try{await this.hangup(e.exopt.session)}catch(t){i=e.exopt.session,this.logger.error("ook webrtc挂断接口报错",t)}e.exopt.session=i;let n=e.pc,o="";if("publish"==t&&e.kind==K.Audio)o=await this.offerWithRetry((()=>this.offerPushAudio(i)));else if("publish"==t&&e.kind==K.Video)o=await this.offerWithRetry((()=>this.offerPushVideo(i,e.exopt.track)));else if("subscribe"==t&&e.kind==K.Audio)o=e.track instanceof ei?await this.offerWithRetry((()=>this.offerPullAmixer(i,e.exopt.filter_link_ids.join(",")))):await this.offerWithRetry((()=>this.offerPullAudio(i,e.exopt.link_id)));else{if("subscribe"!=t||e.kind!=K.Video)throw new N("Unknown SDP direction: "+t+", "+e.track.toString(),M.InternalError);o=e.track instanceof ni?await this.offerWithRetry((()=>this.offerPullMcuVideo(i))):await this.offerWithRetry((()=>this.offerPullVideo(i,e.exopt.link_id,e.exopt.track)))}await n.setRemoteDescription({sdp:o,type:"offer"});let s=await n.createAnswer();await n.setLocalDescription(s),await(()=>new Promise(((e,t)=>{"complete"===n.iceGatheringState?e():n.onicegatheringstatechange=()=>{"complete"==n.iceGatheringState&&e()}}))).bind(this)(),await this.answer(i,null===(r=n.localDescription)||void 0===r?void 0:r.sdp),"publish"==t&&await this.freshAVState(i)}async freshAVState(e){let t=!1,r=!1,i=0;for(const e in this.published){const n=this.published[e];n.kind==K.Audio?t=!0:n.kind==K.Video&&(r=!0,i|=Math.pow(2,n.exopt.track))}k((()=>this.setMcuTrack(e,i)),{maxRetries:3})(),await this.setAVState(e,t,r)}getAvailableVideoTrackNo(){let e=-1,t=[];for(const e in this.published){const r=this.published[e];r.kind==K.Video&&t.push(r.track.getInfo().track)}for(let r=0;r<this.ability.videoMaxPub;r++)if(-1==t.indexOf(r)){e=r;break}return e}create(){return this.req("create/"+this.joinRsp.link_id,{serv:this.joinRsp.webrtc.upload_host,conf:this.joinRsp.channel_link_id,token:this.joinRsp.session_key,amixer:1})}free(){return this.req("free/"+this.joinRsp.link_id)}async offerWithRetry(e){try{return await e()}catch(t){try{await this.create()}catch(e){}return e()}}async offerPushVideo(e,t){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,track:t+""}),{mode:"recvonly",type:"video"})).sdp}async offerPushAudio(e){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{mode:"recvonly",type:"audio"})).sdp}async offerPullVideo(e,t,r){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:t+"",track:r+""}),{mode:"sendonly",type:"video"})).sdp}async offerPullMcuVideo(e){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:"1",track:"0"}),{mode:"sendonly",type:"video"})).sdp}switchPullVideoTrack(e,t){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{type:"track",setting:{track:t}})}async offerPullAudio(e,t){return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:t+""}),{mode:"sendonly",type:"audio"})).sdp}async offerPullAmixer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(await this.req("offer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e,peer:"amixer",filter:t}),{mode:"sendonly",type:"audio"})).sdp}answer(e,t){return this.req("answer/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:t})}setAVState(e,t,r){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:JSON.stringify({type:"media",setting:{audio:t?1:0,video:r?1:0}})})}setMcuTrack(e,t){return this.req("setting/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}),{totalBody:JSON.stringify({type:"deftrack",setting:{mmask:t}})})}hangup(e){return this.req("hangup/"+this.joinRsp.link_id+"?"+new URLSearchParams({session:e}))}req(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.joinRsp.webrtc.cmd_url;"/"!==i.substring(i.length-1)&&(i+="/");let n=t.totalBody;n||(n=Object.keys(t).filter((e=>void 0!==t[e]&&null!==t[e])).map((e=>`${e}=${t[e]}`)).join("\r\n"));let o=Date.now(),s=(r,i)=>{this.logger[r]("ook webrtc gateway api: "+e,t,i,Date.now()-o+"ms")};return new Promise(((t,o)=>{fetch(i+e,{method:"POST",headers:{...r,Accept:"application/json"},body:n}).then((e=>{if(200!=e.status){let t=new N(`HTTP ${e.status} ${e.statusText}`.trim(),M.ConnectionFailed);s(ge.ERROR,t),o(t)}else e.json().then((e=>{s(0==e.code?ge.DEBUG:ge.ERROR,e),0==e.code?t(e):o(new N(e.code+":"+e.msg,M.SdpNegotiationFailed))})).catch((e=>{var t;s(ge.ERROR,e),o(new N(`Invalid response: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.MessageDecodeFailed))}))})).catch((e=>{var t;s(ge.ERROR,e),o(new N(`Network request failed: ${null!==(t=null==e?void 0:e.message)&&void 0!==t?t:e}`,M.ConnectionFailed))}))}))}genSessionId(){return`${`${this.joinRsp.app_id}`}-${P(6)}`}}var tn=r(7629);function rn(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class nn extends Xi{vendor(){return vr.WangsuCDN}constructor(e,t,r,i){super(t,r,i),rn(this,"api",void 0),rn(this,"ability",{audioCodecs:[z.OPUS],videoCodecs:[z.H264],audioMaxPub:-1,videoMaxPub:-1,audioMaxSub:-1,videoMaxSub:-1}),this.api=e}async negotiateSDP(e,t){var r,i;let n=e.pc,o=await n.createOffer();await n.setLocalDescription(o);let s="";const a="publish"==t?null===(r=e.opt)||void 0===r||null===(r=r.props)||void 0===r?void 0:r.streamName:null===(i=e.track.getInfo())||void 0===i||null===(i=i.props)||void 0===i?void 0:i.streamName;if(a)s=a;else if("publish"==t&&e.kind==K.Audio)s=e.track.getUid()==H&&e.track.id==W?"rtc_a_channel_"+this.joinRsp.channel:"rtc_a_user_"+this.joinRsp.uid+"_"+e.track.id;else if("publish"==t&&e.kind==K.Video)s=e.track.getUid()==H&&e.track.id==q?"rtc_v_channel_"+this.joinRsp.channel:"rtc_v_user_"+this.joinRsp.uid+"_"+e.track.id;else if("subscribe"==t&&e.kind==K.Audio)s=e.track.getUid()==H&&e.track.id==W?"rtc_a_channel_"+this.joinRsp.channel:"rtc_a_user_"+e.track.getUid()+"_"+e.track.id;else{if("subscribe"!=t||e.kind!=K.Video)throw new N("Unknown SDP direction: "+t+", "+e.track.toString(),M.InternalError);s=e.track.getUid()==H&&e.track.id==q?"rtc_v_channel_"+this.joinRsp.channel:"rtc_v_user_"+e.track.getUid()+"_"+e.track.id}let c=await this.exchangeSDP("publish"==t,s,o);c=this.reorderAnswerMLines(o,c),await n.setRemoteDescription(c)}reorderAnswerMLines(e,t){if(!e.sdp||!t.sdp)return t;const r=tn.qg(e.sdp),i=tn.qg(t.sdp);if(r.media.length<=1)return t;const n=r.media.map((e=>String(e.mid))),o=i.media.map((e=>String(e.mid)));if(n.join(",")===o.join(","))return t;this.logger.info("wangsu",`调整 answer m-line 顺序: ${o.join(",")} -> ${n.join(",")}`);const s=[];for(const e of n){const t=i.media.find((t=>String(t.mid)===e));t&&s.push(t)}if(i.media=s,i.groups)for(const e of i.groups)"BUNDLE"===e.type&&(e.mids=n.join(" "));return{type:t.type,sdp:tn.M9(i)}}async exchangeSDP(e,t,r){let i=await this.api.cdnURL({vendor:this.vendor(),stream_name:t,publish:e}),n=Date.now(),o=(r,i)=>{this.logger[r](`wangsu ${e?"publish":"subscribe"} ${t}, sdp exchange cost: ${Date.now()-n}ms`,i)};return new Promise(((e,t)=>{fetch(i,{method:"POST",headers:{Accept:"application/json"},body:JSON.stringify({version:"v1.0",sessionId:"sidtest",localSdp:r})}).then((r=>{if(200!=r.status){let e=new N(`HTTP ${r.status} ${r.statusText}`.trim(),M.ConnectionFailed);o(ge.ERROR,e),t(e)}else r.json().then((r=>{o(200==r.code?ge.DEBUG:ge.ERROR,r),200==r.code?e(r.remoteSdp):t(new N(r.code+":"+r.message,M.SdpNegotiationFailed))})).catch((e=>{var r;o(ge.ERROR,e),t(new N(`Invalid response: ${null!==(r=null==e?void 0:e.message)&&void 0!==r?r:e}`,M.MessageDecodeFailed))}))})).catch((e=>{var r;o(ge.ERROR,e),t(new N(`Network request failed: ${null!==(r=null==e?void 0:e.message)&&void 0!==r?r:e}`,M.ConnectionFailed))}))}))}}function on(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class sn extends dr{get defaultChannel(){var e;return null!==(e=this.channels[0])&&void 0!==e?e:null}getStreamMetric(){if(!this.defaultChannel)throw L();return this.defaultChannel.getStreamMetric()}getNetworkStats(){if(!this.defaultChannel)throw L();return this.defaultChannel.getNetworkStats()}getConnectionQuality(){if(!this.defaultChannel)throw L();return this.defaultChannel.getConnectionQuality()}buildInfo(){let{version:e}=r(6351);return{version:e,timestamp:1793762369}}getEnvInfo(){return _r()}createLocalCompositeRecorder(){return new Ji}getStoredDeviceId(){let e=localStorage.getItem("device_id");return e||(e=P(18),localStorage.setItem("device_id",e)),e}getDeviceType(){return J.WebRTC}newRtcApi(e,t){return new Cr(e.app_id,e.sid,e.client_key,e.client_api,t)}newRtcSocket(e,t){return new Hi(e,t)}newChannel(e,t,r,i,n,o,s){const a=ji.create(e,t,r,i,n,o,s);return a.trackRegistrar=e=>this.addTrackListeners(e),a}newStreamEngine(e,t,r,i){switch(t.stream_vendor){case void 0:case vr.OOK:return new en(t,void 0,i);case vr.WangsuCDN:return new nn(r,t,void 0,i);case vr.Seastart:return new pi(r,t,{preferVideoCodec:e.preferVideoCodec,preferAudioCodec:e.preferAudioCodec},i);default:throw new N("Unsupported stream engine: "+t.stream_vendor,M.EngineNotSupported)}}constructor(e){super(e),on(this,"localTracks",void 0),on(this,"onDeviceAdd",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.DEVICE_ADD,data:e})})),on(this,"onDeviceRemove",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.DEVICE_REMOVE,data:e})})),on(this,"onVisibilityChange",(()=>{"visible"===document.visibilityState?this.onAppShow():this.onAppHide()})),on(this,"muteCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_MUTED,data:e})})),on(this,"unmuteCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_UNMUTED,data:e})})),on(this,"endCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_ENDED,data:e})})),on(this,"autoPlayFailCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_AUTOPLAY_FAIL,data:e})})),on(this,"pipEnterCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_PIP_ENTER,data:e})})),on(this,"pipExitCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_PIP_EXIT,data:e})})),on(this,"popOutOpenCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_POPOUT_OPEN,data:e})})),on(this,"popOutCloseCallback",(e=>{this.onNotifyChannelEvent&&this.onNotifyChannelEvent({type:Mr.TRACK_POPOUT_CLOSE,data:e})})),this.localTracks=new Set,wi.getInstance().on("add",this.onDeviceAdd),wi.getInstance().on("remove",this.onDeviceRemove),document.addEventListener("visibilitychange",this.onVisibilityChange)}join(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return super.join(e,t)}releaseGlobalListeners(){wi.getInstance().off("add",this.onDeviceAdd),wi.getInstance().off("remove",this.onDeviceRemove),document.removeEventListener("visibilitychange",this.onVisibilityChange)}postLeave(e){let t=new Set(e.getLocalTracks());0===this.channels.length&&this.localTracks.forEach((e=>t.add(e)));for(let e of t)if(e.publishState.count>0)be.info("离开频道",e.toString(),`仍有 ${e.publishState.count} 个频道在发布,保留采集`);else try{e instanceof Pi?e.stopPlay():e instanceof xi&&e.removeAllPlayViews(),(e instanceof Ri||e instanceof Oi||e instanceof Mi)&&(e.stopCapture(),be.info("离开频道",e.toString(),"自动停止采集"))}catch(e){}super.postLeave(e)}onAppShow(e){super.onAppShow(e);for(let e of this.localTracks){let t=e.getMediaStreamTrack();t&&("ended"===t.readyState&&(be.warn(e.toString(),"页面恢复时发现 track 已 ended,尝试重新采集"),(e instanceof Ri||e instanceof Oi)&&e.startCapture().catch((t=>{be.error(e.toString(),"页面恢复时重新采集失败",t)}))))}}async getDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return wi.getInstance().getDevices(e,t)}addTrackListeners(e){e.listeners(a.MUTED).includes(this.muteCallback)||e.on(a.MUTED,this.muteCallback),e.listeners(a.UNMUTED).includes(this.unmuteCallback)||e.on(a.UNMUTED,this.unmuteCallback),e.listeners(a.ENDED).includes(this.endCallback)||e.on(a.ENDED,this.endCallback),e.listeners(Nr.AUTOPLAY_FAIL).includes(this.autoPlayFailCallback)||e.on(Nr.AUTOPLAY_FAIL,this.autoPlayFailCallback),e.listeners(Nr.PIP_ENTER).includes(this.pipEnterCallback)||e.on(Nr.PIP_ENTER,this.pipEnterCallback),e.listeners(Nr.PIP_EXIT).includes(this.pipExitCallback)||e.on(Nr.PIP_EXIT,this.pipExitCallback),e.listeners(Nr.POPOUT_OPEN).includes(this.popOutOpenCallback)||e.on(Nr.POPOUT_OPEN,this.popOutOpenCallback),e.listeners(Nr.POPOUT_CLOSE).includes(this.popOutCloseCallback)||e.on(Nr.POPOUT_CLOSE,this.popOutCloseCallback)}createLocalMicTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ui.music,t=new Ri(e.capture);return t.publishState.defaultPublishOptions={...e.publish},this.localTracks.add(t),this.addTrackListeners(t),t}createLocalCustomAudioTrack(e){if(e.kind!=K.Audio)throw new N("MediaStreamTrack must be an audio track",M.InvalidArgument);let t=new Pi;return t.setMediaStreamTrack(e),this.localTracks.add(t),this.addTrackListeners(t),t}createLocalCameraTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Vi["720p"],t=new Oi(e.capture);return t.publishState.defaultPublishOptions={width:e.capture.width,height:e.capture.height,...e.publish},this.localTracks.add(t),this.addTrackListeners(t),t}createLocalScreenTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Wi["1080p"],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qi.default,r=new Mi(e.capture);if(r.publishState.defaultPublishOptions={width:e.capture.width,height:e.capture.height,...e.publish},this.localTracks.add(r),this.addTrackListeners(r),t){let e=new Ii(t.capture);e.publishState.defaultPublishOptions={...t.publish},this.localTracks.add(e),this.addTrackListeners(e),r.setAudioTrack(e)}return r}createLocalCustomVideoTrack(e){if(e.kind!=K.Video)throw new N("MediaStreamTrack must be a video track",M.InvalidArgument);let t=new xi;return t.setMediaStreamTrack(e),this.localTracks.add(t),this.addTrackListeners(t),t}async enableLocalTrack(e){let t=e.getMediaStreamTrack();if(t&&"ended"===t.readyState){if(be.warn(e.toString(),"enableLocalTrack 时 track 已 ended,尝试重新采集"),e instanceof Ri||e instanceof Oi)try{await e.startCapture()}catch(t){be.error(e.toString(),"重新采集失败",t)}}else t&&(t.enabled=!0);if(e instanceof Mi){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&await this.enableLocalTrack(t)}}disableLocalTrack(e){let t=e.getMediaStreamTrack();if(t&&(t.enabled=!1),e instanceof Mi){let t=e.getAudioTrack();t&&t.getMediaStreamTrack()&&this.disableLocalTrack(t)}}async publishLocalTrack(e,t){if(!this.defaultChannel)throw L();return this.defaultChannel.publishLocalTrack(e,t)}async unpublishLocalTrack(e){if(!this.defaultChannel)throw L();await this.defaultChannel.unpublishLocalTrack(e)}async subscribeRemoteAudioMixTrack(e){let t=await super.subscribeRemoteAudioMixTrack(e);return this.addTrackListeners(t),t}async subscribeRemoteAudioTrack(e,t){let r=await super.subscribeRemoteAudioTrack(e,t);return this.addTrackListeners(r),r}async subscribeRemoteVideoMcuTrack(){let e=await super.subscribeRemoteVideoMcuTrack();return this.addTrackListeners(e),e}async subscribeRemoteVideoTrack(e,t){let r=await super.subscribeRemoteVideoTrack(e,t);return this.addTrackListeners(r),r}async unsubscribeRemoteTrack(e){await super.unsubscribeRemoteTrack(e)}getRemoteTrack(e,t,r){return super.getRemoteTrack(e,t,r)}}var an=i.He,cn=i.L0,un=i.Yk,ln=i.c3,hn=i.Mz,dn=i.Ne,fn=i._N,pn=i.bq,gn=i.hj,mn=i.O4,vn=i.h4,yn=i.xk,bn=i.J,wn=i.a7,Sn=i.tg,_n=i.s_,kn=i.VO,En=i.VF,Tn=i.M0,Cn=i.$b,Pn=i.WI,An=i.cp,In=i.PN,Rn=i.ez,xn=i.EQ,On=i.$t,Mn=i.jL,Nn=i.Ps,Ln=i.VV,Bn=i.Fp,Dn=i._b,jn=i.dT,Un=i.CM,Fn=i.Zq;export{an as BaseChannel,cn as BaseTrack,un as CameraPresets,ln as Channel,hn as ChannelEventType,dn as Codec,fn as ConnectionQuality,pn as DeviceType,gn as DisconnectReason,mn as ErrorCode,vn as ImDisconnectReason,yn as ImEventType,bn as LocalAudioTrack,wn as LocalCameraTrack,Sn as LocalCompositeRecorder,_n as LocalMicTrack,kn as LocalScreenAudioTrack,En as LocalScreenTrack,Tn as LocalVideoTrack,Cn as LogLevel,Pn as LogTarget,An as MicPresets,In as ProcessorPipeline,Rn as RemoteAudioMixTrack,xn as RemoteAudioTrack,On as RemoteVideoTrack,Mn as SRTC,Nn as ScreenAudioPresets,Ln as ScreenPresets,Bn as SdkError,Dn as TrackKind,jn as __INNER__,Un as codec2str,Fn as createMixedAudioMediaStreamTrack};